Jump to content
Sign in to follow this  
evans d [16aa]

AddAction when unit is in Trigger and Removing when out of Trigger

Recommended Posts

Ok guys, I'm back!

2 questions, one of which is more pressing than the second so I'll start off with that:

I want my soldiers to free some captured civilians and I've set up an action with a trigger:

triggerCaptives:

Activation:   BLUEFOR PRESENT REPEATEDLY
Condition:    this
On Act.:      nul = execVM "freecaptives.sqf";

freecaptives.sqf

freeCaptives = player addAction ["Free Captives","free.sqf"]

free.sqf

free = true;

player removeAction freeCaptives;

"tskCivilian" objStatus "DONE";

tskCivilian setTaskState "Succeeded";

taskHint ["Free Civilians\nObjective complete",[0,1,0,1],"taskDone"];

Ok, so here's a little more detailed information on what I want to do:

Soldier a is going to walk to the captives. In doing so, he passes through triggerCaptives. This gives him an action to use. However, he decides not to bother freeing the innocent civilians and moves on. Rather than him having an action to free the captives all the way through the mission I'd like to remove the action when he leaves the area of triggerCaptives.

Can anyone tell me how to do that?

Also, can someone confirm that the way to remove the trigger would be:

deleteVehicle triggerCaptives

I did sue the search function but I couldn't find anything. If someone finds something that could be of use to me please post a link here and I'll be very grateful.

Thank you,

Bashkire

Share this post


Link to post
Share on other sites

It would be much simpler and logical to add the action to the prisoners instead imo.

Yes you use deleteVehicle to delete the trigger.

Share this post


Link to post
Share on other sites

The problem with adding the action to the civilians is that, as they against a wall the player can get the action from behind the wall, when they don't even know the civilians are there. By using a trigger I can limit the area in which the actions is given.

Share this post


Link to post
Share on other sites

triggerCaptives:

Activation: BLUFOR PRESENT REPEATEDLY
Condition:  this
Name:       trgCaptives

init.sqf

waituntil {!isnull player};
actFree = player addAction ["Free Captives", "free.sqf", [], 7, true, true, "", "player in list trgCaptives"];

free.sqf

free = true;

player removeAction actFree;

deleteVehicle trgCaptives;

"tskCivilian" objStatus "DONE";

tskCivilian setTaskState "Succeeded";

taskHint ["Free Civilians\nObjective complete",[0,1,0,1],"taskDone"];

Share this post


Link to post
Share on other sites

Another way would be to just give each soldier an addaction on mission initialization. The addAction command supports conditions. That means you can control when the action will be visible without having to remove and re-add using addAction.

_actionId = this addAction ["Free Captives", "free.sqf", [], 1, false, true, "", "driver player == player and position Civilian distance player < 3"];

Alternatively to make the entry only show when the player is in a trigger (activated by the player's side, repeatedly and named "trigger1Name")

_actionId = this addAction ["Free Captives", "free.sqf", [], 1, false, true, "", "driver player == player and _target in list trigger1Name"];

driver player == player

This part ensures that the action menu entry is only visible to the person attached to.

  • Thanks 1

Share this post


Link to post
Share on other sites

Apologies for the late reply, gentlemen. I'll just try those two suggestions out now.

EDIT: Shuko, your code works like a dream! This will be great for my mission! And even better that it doesn't register for other units! Thank you both for your suggestions once again.

Mondkalb, apologies but I couldn't get your method to work. Can you explain where each bit goes to make sure I wasn't doing anything wrong? While I have managed to get Shuko's to work I would like to have all options open to me in case this sort of thing happens again.

Thanks again guys!

Bashkire.

Edited by Bashkire

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  

×