Jump to content
Sign in to follow this  
kocrachon

Issues with addaction

Recommended Posts

So right now I am working on a mission, where I have a triggere where when activated, it does an addaction, which is accomplished by a guy entering the area. And the same trigger, on deactivation, will remove the addaction if he leaves the circle. Basically I am making it to where when he is close enough it adds the action, and if he leaves it removes it.

For my addaction, I have this in the init.

_bomb1 = Soldier1 addAction ["Deactivate Bomb", "defuse1.sqf"]

My problem occurs when I wan to remove said action. When I try to do removeaction, in order for it to work constantly. I have had to do this in the deactivate because it gives every addaction a new number when ever he leaves and comes back.

Soldier1  removeAction 0; 
Soldier1  removeAction 1;
Soldier1  removeAction 2;
Soldier1  removeAction 3;
Soldier1  removeAction 4; 
Soldier1  removeAction 5; 
Soldier1  removeAction 6; 
Soldier1  removeAction 7;
Soldier1  removeAction 8;
Soldier1  removeAction 9;
Soldier1  removeAction 10;

Is there an easier way to accomplish this?

Also, another part. I currently have it in the script that when he does the addaction, he does a 30 second animation, and after that animation, the bomb deletes itself and the mission moves on. How do I make it so the script doesn't "finish" if the guy dies half way through the animation?

Share this post


Link to post
Share on other sites

The ID of the action is sent to the script it executes. So if you had an addAction on an object and wanted to remove the action after using it try this:

_object = _this select 0;
_player = _this select 1;
_action = _this select 2;

_object removeAction _action;

Rather than remove it and add it just make distance to the bomb the condition of the action. So he's always got the action but it's "removed" automatically since the bomb disappears and he's no longer within range. Once it reappears it'll "turn back on" since he'll be within range again, 50m in this case.

soldier1 addAction ["Defuse Bomb","defusebomb.sqf",[],1,false,true,"","(_this distance bomb1) < 50"];

For your defusing animation thing... umm... delete it at the start so it doesn't matter? :)

Share this post


Link to post
Share on other sites

EDIT: ^^ Ninja'd

try using

On Activation

_bomb1 = Soldier1 addAction ["Deactivate Bomb", "defuse1.sqf"]

On Deactivation

 soldier1 removeaction bomb;

By using Bomb as a variable it will always remove it and you don't have to worry about the numbering of the addaction.

Edited by KevsnoTrev
Ninja'd

Share this post


Link to post
Share on other sites

For your defusing animation thing... umm... delete it at the start so it doesn't matter? :)

Thanks for the help.

The animation thing I asked about on the second half, is because I want the enemy to be able to interrupt the defusing.

Essentially I have a squad trying to disarm the bomb, it plays a 30 second activation, and I have a 30 second "sleep" so that right as the animation finishes, the bomb is delted and considered "disarmed". But I want to make it to where if the person disarming is killed, it stops the script, and then some one else has to disarm the bomb.

Share this post


Link to post
Share on other sites

To interrupt an animation try:

unit playMove "";

or

unit switchmove "";

Share this post


Link to post
Share on other sites
To interrupt an animation try:

unit playMove "";

or

unit switchmove "";

Where would I put the check for "if killed" in this current script?


_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;

_caller removeAction _bomb1;


_caller playMove "ActsPercSnonWnonDnon_carFixing2";

sleep 37;

deleteVehicle bomb1;

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  

×