Home   Help Search Login Register  

Author Topic: "FOOLPROOF" addAction solution messed up by teamSwitch ?  (Read 1317 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
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
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: "FOOLPROOF" addAction solution messed up by teamSwitch ?
« Reply #1 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.
"When 900 years YOU reach, look as good you will not!"

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: "FOOLPROOF" addAction solution messed up by teamSwitch ?
« Reply #2 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
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.