Author Topic: Help with usable objects  (Read 1371 times)

Offline spidersau

  • Rank: Private
  • *
  • Posts: 62
Help with usable objects
« on: November 19, 2011, 05:14:58 am »
Hey guys,

i hope you can help me with the scripting of a usable object.
Basically it is the same as planting the bomb in sd, but i simply can't find out how to do that.

Here's what i want to do:
A player has a bomb/c4 (whatever) and goes crouch anywhere he likes to plant it.
While holding the Use-Button he can plant the bomb.
The planting should be like in sd time based and shown with a progress bar.

Also the bomb should be disarmable.
For that a little message should be appear when a player is close to the bomb ("Hold [Use] to defuse")
Then the same procedure like planting the bomb.

Thanks
spidersau

Offline Joker{eXtreme}

  • Rank: Private
  • *
  • Posts: 6108
    • http://www.mycallofduty.com
Re: Help with usable objects
« Reply #1 on: November 19, 2011, 11:00:07 am »
Take a look through the script we have for the disarmable Claymores -- that is pretty much what you are asking for :)

Offline spidersau

  • Rank: Private
  • *
  • Posts: 62
Re: Help with usable objects
« Reply #2 on: November 19, 2011, 11:27:48 am »
To be honest i don't understand everything in this script.
But if i understood it correctly, then it's showing a timer how long you you have to wait till the bomb is defused.
Is there a simple way to do it with an usable object like the sd bomb?

thats what i found in the sd.gsc.
Code: [Select]
defuseObject = maps\mp\gametypes\_gameobjects::createUseObject( game["defenders"], trigger, visuals, (0,0,32) );
defuseObject maps\mp\gametypes\_gameobjects::allowUse( "friendly" );
defuseObject maps\mp\gametypes\_gameobjects::setUseTime( level.defuseTime * level.fps_multiplier );
defuseObject maps\mp\gametypes\_gameobjects::setUseText( &"MP_DEFUSING_EXPLOSIVE" );
defuseObject maps\mp\gametypes\_gameobjects::setUseHintText( &"PLATFORM_HOLD_TO_DEFUSE_EXPLOSIVES" );
defuseObject maps\mp\gametypes\_gameobjects::setVisibleTeam( "any" );

Offline Joker{eXtreme}

  • Rank: Private
  • *
  • Posts: 6108
    • http://www.mycallofduty.com
Re: Help with usable objects
« Reply #3 on: November 19, 2011, 12:02:24 pm »
Maybe if you paint a bigger picture of what you are trying to do here -- ie when, where, why, what gametype, etc, etc

I don't think I am fully understanding what you are meaning.

Offline spidersau

  • Rank: Private
  • *
  • Posts: 62
Re: Help with usable objects
« Reply #4 on: November 23, 2011, 04:47:46 pm »
I want to be able plant the sd bomb anywhere in the map instead of the bombplace.

Offline spidersau

  • Rank: Private
  • *
  • Posts: 62
Re: Help with usable objects
« Reply #5 on: November 26, 2011, 05:27:24 am »
I think it's still not clear, so here is what i got so far.
The problem is, that the planting can not be interrupted.

Code: [Select]
CheckPlant()
{
self endon("disconnect");
self endon("intermission");
self endon("death");

while(1)
{
wait .1;
if(self GetStance() == "crouch" && self UseButtonPressed() && self.hasbombs > 0) self PlantBomb();
else if(self GetStance() == "prone" && self UseButtonPressed() && self.hasbombs > 0) self PlantBomb();
else if(self GetStance() == "crouch" && self UseButtonPressed() && self.hasbombs == 0) self iprintlnbold("You have no bombs left!");
else if(self GetStance() == "prone" && self UseButtonPressed() && self.hasbombs == 0) self iprintlnbold("You have no bombs left!");
}
}

PlantBomb()
{
self.bomb = Spawn("script_model", self.origin + vector_scale(anglesToForward(self.angles),20));
self.bomb SetModel("mil_tntbomb_mp");
self playsound("MP_bomb_plant");

thread onOwnerDeath(self);

self DisableWeapons();
self FreezeControls(1);
self.bar = self maps\mp\gametypes\_hud_util::createBar((1,1,1), 128, 8);
self.bar maps\mp\gametypes\_hud_util::setPoint("CENTER", 0, 0, 5);
self.bar maps\mp\gametypes\_hud_util::updateBar(0, 0.2);
wait 5;
self EnableWeapons();
self FreezeControls(0);
self.bar maps\mp\gametypes\_hud_util::destroyElem();

self.bomb thread BombExplosion(self);

self.hasbombs--;

self.bomb notify("bomb_planted");
}