OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: GavinP on 29 Sep 2006, 23:49:53
-
Hi, not really sure about MP scripting of triggers. I've a trigger set up to monitor when a vehicle gets within 15 of the player, and it then camcreates a shell125 at the vehicles position provided the driver is still alive. If the driver is dead obviously the player is safe from teh explosion, but to make things more realistic i've put an additional trigger monitoring when the player gets within 4 of the vehicle to allow "disable of bomb". These work perfectly well in SP but do I need to do anything in MP? I don't want a shell per player within 15 for example. I will have a named group for the playable positions, and each will be individually named also so can I use some sort of array? ???
-
Easy solution. In your bomb trigger Condition use count for your distance check and add a switch variable.
({(BoomBus distance _x) < 15} count units myGroup) > 0 and alive driver BoomBus and not GoBoomand in its OnActivation
GoBoom = TRUE ; publicVariable "GoBoom"
Another trigger. Condition:
GoBoomand in its OnActivation
"SHELL125" createVehicle (getPos BoomBus)
Instead of camCreate use createVehicle to make your shell. The trigger should then only fire once on the machine of the first player who gets too close. Since the shell is createVehicled it will be created once on all machines.
Similarly, in your trigger to disable the bomb in Condition:
({(BoomBus distance _x) < 4} count units myGroup) > 0 and not alive driver BoomBus and not GoBoomand in its OnActivation
BoomDisabled = TRUE ; publicVariable "BoomDisabled"
One more trigger. Condition:
BoomDisabledand in its OnActivation
hint "Bomb disabled"
I may have dropped a bracket or two...
-
Thanks for that. I have one question though. How does the addaction bit work in terms of MP. Obviously you've changed my "player" for the count units Mygroup method, but that won't work for the addaction, removeaction bits will it?
-
You want an action to appear when the unit is within 4m of the bomb bus?
In the second trigger where it currently says:
BoomDisabled = TRUE ; publicVariable "BoomDisabled"try putting the following
disarmaction = player addaction ["Disarm Bomb","disarm.sqs"
Then in disarm.sqs put the following:
player removeaction "disarmaction"
~0.5
;maybe replace this with some sort of disarm looking animation using playmove..
~0.5
BoomDisabled = TRUE
publicVariable "BoomDisabled"
exit
Can someone else check what I put out? Ive only just woken up >:(
-
Okay, I thought you wanted the truck to disarm automatically once the players got near...
Jason O is almost correct, except for removing the action. There is also one other problem. Once a player is gets an addaction it will stick with him until the truck is disarmed, no matter where he is. A better solution is to add the action to the truck.
Trigger to disable the bomb in Condition:
({(BoomBus distance _x) < 4} count units myGroup) > 0 and not alive driver BoomBus and not GoBoom and not BoomDisabledIn OnActivation:
truck addaction ["Disarm Bomb","disarm.sqs"]
addAction, I recently learned myself, (see the comments in the comref) passes its own ID to the script it calls. So:
disarm.sqs
_truck = _this select 0
_actionid = _this select 2
_truck removeaction _actionid
; move the next 2 lines to the top so that no one else gets the "Defuse Bomb" action.
BoomDisabled = TRUE
publicVariable "BoomDisabled"
;must use switchmove for all players to see anim in MP
;maybe replace this with some sort of disarm looking animation using switchmove..
exit
For completeness add this to the Init for the truck (I am assuming the players are WEST):
this addEventHandler["GETIN", {_this exec "boombuscheck.sqs"}]
boombuscheck.sqs
_truck = _this select 0
_unit = _this select 2
if (side _unit == WEST) then {if (not BoomDisabled) then {GoBoom = TRUE ; publicVariable "GoBoom"} else {_truck removeEventHandler "GETIN"}}
exit
Now the truck will blow up if the players get in before disarming it. I gotta run so I don't have a chance to double check. Check this space again later for possible edits...
-
Thanks for that Mr Peanut. I have one further question. Would it be possible to change the activation from group w1 to any west unit? I'm thniking along the lines of count units side== "west"?
-
I don't understand your question. What do you want to change?
-
Sorry. At present the boombus as you put it :clap: explodes when within a given distance of a unit from west group W1. What i want it to do is go boom when it gets within a given distance from any west unit. (My mission has changed itself, and i now need more than 1 west unit)
-
Okay,
In your init.sqs you need to make an array of all west units you want to include.
westUnitArray = [w1,w2,w3,w4,w5...]
Then everywhere in the code I've given you replace:
units myGroupwith:
westUnitArray
I have only thought of one hitch.... if the bus drives near a dead west soldier, it is still going to blow up. IF this is a possible problem then replace:
({(BoomBus distance _x) < 15} count westUnitArray) > 0with
({(BoomBus distance _x) < 15 and alive _x} count westUnitArray) > 0Make this change also for the less then 4 metres check.