Home   Help Search Login Register  

Author Topic: addaction command questions  (Read 523 times)

0 Members and 1 Guest are viewing this topic.

Offline Fire-Fox

  • Members
  • *
  • Violence is just a friend walking on the right way
addaction command questions
« on: 25 Aug 2004, 23:14:50 »
Hi everyone! :)

I recently noticed (yes, stoopid Fire-Fox is a little bit slooooooweeeer than the rest of the world... ;) ) that after you have added an action to another unit than the player using the addaction command you can access this action as well if you are close enough to this unit. Is it possible to change the radius in which it is possible to execute an action added to another unit?

A second question I have concerning the addaction command is if there is any way to execute the script with one or more parameters? I have tested it like this...

unit addaction ["action name", [notthisunit] exec "action.sqs"]

...it did not work.

I have also found out that the script attached to an added action is able to recognize the following variables:

_this select 0 = the unit the action is added to
_this select 1 = the unit that executed the action (which is, as I have found out, not necessarily the same)
_this select 2 = the action's id

But I do not want to use this, I want to have something else as a parameter.


1) Thanks in advance, people! :)
2) It's good to be back here, I had quite some time off now- been busy building quite a big mission for my girlfriend :D

Offline General Barron

  • Former Staff
  • ****
  • Semper Fi!
Re:addaction command questions
« Reply #1 on: 25 Aug 2004, 23:27:59 »
Unfortunately, the addaction command doesn't work as... nicely as you or I would like it to. In short, the answer to everything is no.

You cannot make a radius for the action, but you can ensure that only the unit with the action can actually use it. Just make this the first line of the action's script:

? (_this select 0) != (_this select 1) : exit

However, you cannot pass parameters to the action's script, which is HIGHLY limiting and annoying. You will have to find some sort of a workaround, I'm afraid. Usually global variables work ok for this. Or, you can make a bunch of similar scripts, and depending on the situation, use a certain one in the action:

? Var > 1 : unit addaction ["Action", "action1.sqs"]
? Var < 1 : unit addaction ["Action", "action2.sqs"]

And so on. Both methods are crappy, but its the only way to really get around the problem.
HANDSIGNALS COMMAND SYSTEM-- A realistic squad-control modification for OFP
kexp.org-- The best radio station in the world, right here at home! Listen to John Richards!

Offline Blanco

  • Former Staff
  • ****
Re:addaction command questions
« Reply #2 on: 26 Aug 2004, 19:18:50 »
Quote
You cannot make a radius for the action,...

Yes, you can.
I know 2 ways to do  that.
Lets say you have a object (eg : button) with an attached addaction.
When you click the action, a bolean is set TRUE
eg : CLICKED =TRUE


With a trigger :

now, place a Trigger, repeatedly

Code: [Select]
CONDITION : !clicked && alive player && player distance button <= 2
ONACTIVATION : myaction = button addaction ["Click me","myscript.sqs"]
ONDEACTIVATION : button removeaction myaction
Make sure CLICKED = FALSE before the mission starts (put it in the init.sqs)

The action will only be visible when the player is 2 meters away from the button.

Same shit but this time with a script

Code: [Select]
_checkarray = []

#loop
?!(player in _checkarray) && alive player && !CLICKED && Player distance button <= 2 :  myaction = button addaction ["Click me","myscript.sqs"];_checkarray = _checkarray + [player]
?(player in _checkarray) && alive player && !CLICKED && Player distance button > 2: button removeaction myaction;_checkarray = _checkarray - [player]
~1
goto "loop"

« Last Edit: 26 Aug 2004, 21:53:38 by Blanco »
Search or search or search before you ask.

bored_onion

  • Guest
Re:addaction command questions
« Reply #3 on: 26 Aug 2004, 20:10:59 »
w0w i wish i had a gf who played flashpoint...