Jump to content
Sign in to follow this  
icebreakr

Booby trapped crate (compatible w/ dedicated)?

Recommended Posts

Can someone give hint how to make an empty crate that explodes when first person comes near it for at least 2 seconds?

And that it works with dedicated/server.

Share this post


Link to post
Share on other sites

Not sure about the dedi, but would it work to put a trigger on the position of the crate, use that to launch a script, get the list of units either in the trigger list or within a certain distance, get the game time, waituntil gametime + 2 sec, check the list again and if the count is > 1, then spawn the lgb/grenade/whatever. :)

Also, if you're interested, I've kinda spent some time making my own explosions in the config. :) It is kinda fun... channeling my inner combat engineer. You can create a custom explosion of the intensity you want, and createVehicle it (IIRC) and it goes boom.

Share this post


Link to post
Share on other sites

There is no reason to launch a script if you're going to use a trigger anyway (which would be the easiest way to do it). Simply make the trigger timeout value 2 seconds (make sure you use timeout, not countdown) and have the bomb created in the activation field of the trigger. If you want this to work on a dedicated server -- or any multiplayer environment, for that matter -- make sure that the bomb is created only once using an if statement server check. As an example:

On Activation:

if (isServer) then {nul = createVehicle ["ARTY_Sh_81_HE",position nameOfCrate,[],0,"CAN_COLLIDE"]}

If you don't use a server check, then the code will be run on every machine and then broadcast to every machine (because createVehicle is a global command), meaning you would spawn one bomb per client + one for the dedicated server. With a high player-count, this could cause latency issues (not to mention it would look ridiculous). NB: nameOfCrate in the example needs to be changed to the name you have given the booby-trapped crate, and the class name for the type of bomb/shell to spawn can be changed to whatever you'd like.

Edited by ST_Dux

Share this post


Link to post
Share on other sites

ST_Dux: thanks for this, I'll try it. The problem is that my crate is placed on several random spots each time your replay the mission. Is trigger also moveable as for example marker is?

What does isDedicted do opposed to isServer?

Share this post


Link to post
Share on other sites

isServer: Returns true if the machine is either a server in a multiplayer game or if it is running a singleplayer game.

isDedicated: Return true if the machine (executing the command) is a dedicated server.

SetPos and setDir the crate after creation, even if you provide a position for createVehicle. See if that helps.

Move trigger around with script, then setMarkerPos the triggers position and see if it updates.

Share this post


Link to post
Share on other sites

I think triggers are setPos'd like regular vehicles?

Share this post


Link to post
Share on other sites

If your placing the boxes in the editor you can attach the trigger to the box.

You give the trigger a name say trig1 and then in the init of the crate put trig1 attachto [this,[0,0,0]]

where ever the crate is placed the trigger will go to it.

Share this post


Link to post
Share on other sites

you could probably script it. this is off hand so no guarantees.

Place an ammo box.

in its init put this exec "trap.sqs";

then in trap.sqs put.

#check

~2

if (_this distance player <= 1) then {goto "explode"} else {goto "check"}

#explode

trapbomb = "Bo_GBU12_LGB" createVehicle [getPos _this select 0, getPos _this select 1, 0];

exit;

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×