OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: laggy on 27 Mar 2009, 23:49:49

Title: "FOOLPROOF" addAction solution messed up by teamSwitch ?
Post by: laggy on 27 Mar 2009, 23:49:49
A solution for addAction that has ALWAYS worked in SP and MP is:

Trigger Repetedly:

Con: player hasWeapon "myWeapon"
Act: myAction = player addAction ["Try Foolproof Action", "actionscript.sqf"]
DeAct: player removeAction myAction

When using teamSwitch to another unit that doesn't have the weapon you of course lose the action, but when you switch back to the original unit the action multiplies  :blink:

Why is this ?

Laggy
Title: Re: "FOOLPROOF" addAction solution messed up by teamSwitch ?
Post by: Wolfrug on 27 Mar 2009, 23:56:40
That's obvious ->

Trigger checks condition: TRUE -> add action
(switch player)
Trigger checks condition: FALSE -> run deactivation (remove action from current player, NOT the player who was given the action)
(switch player back)
Trigger checks condition: TRUE -> add action (again)

Solution: Store the original unit the action is applied to in a global variable, e.g. ActionPlayer = this. Then instead of running the removeaction on the player, run it on Actionplayer ->

Code: [Select]
Con: player hasWeapon "myWeapon"
Act: myAction = player addAction ["Try Foolproof Action", "actionscript.sqf"]; ActionPlayer = player;
DeAct: ActionPlayer removeAction myAction

Gets messy when you teamswitch to multiple units that have the needed weapon, of course -> you might want to have a separate trigger for each possible unit the action can be added to, and use the unit name instead of Player for adding/removing.

addAction was never a part of the original OFP scripts, it was added later - but before the eventhandler commands. That's probably why it's such a hopeless command to get right >_< Hopefully they fix it to look better for ArmA II (e.g. player addaction ["Name", {eventhandler-like script}])

Final solution: add a teamswitch-monitoring script that removes/adds actions as necessary.
Title: Re: "FOOLPROOF" addAction solution messed up by teamSwitch ?
Post by: laggy on 28 Mar 2009, 00:02:27
Ahhh,

Thanks a lot Wolfrug.

The "player" definition has to me been a little vague, until now  :good:

Laggy