Jump to content
Sign in to follow this  
pliskin124

Civilians Surrendering ONLY in Trigger Area

Recommended Posts

Title says it all. I'm trying to get the civilians to surrender when Blufor units enter the area, but only the ones caught within the specific radius (i.e. a vehicle pulling into the area)

 

Here is what I have so far, though I'm quite positive it's wrong.

 

in a "Surrender.sqf"

_CIVILIAN = [];



{if ((side _x) == CIVILIAN) then {_CIVILIAN Trigger1 _x}} forEach allUnits;
playMove "AmovPercMstpSsurWnonDnon"; 
disableAI "ANIM";

Any help would be much appreciated, thank you.

Share this post


Link to post
Share on other sites

Not on PC right now, but try this: ;)

_radius = 100;
_coward = nearestObjects [player, ["CAManBase"], _radius];
{

 _x switchMove "AmovPercMstpSsurWnonDnon";
 _x disableAI "Anim";

} forEach side _coward == CIVILIAN;

Share this post


Link to post
Share on other sites

Make sure trigger activation is set to "ANY", then just paste this into the "ON ACT." field:

if ({side _x == west}count thisList > 0) then //count objects in trigger and make sure at least 1 is blufor
{
	{
		if (side _x == civilian) then //only affect civ's
		{
			_x switchMove "AmovPercMstpSsurWnonDnon";
			_x disableAI "Anim";
		};
	} forEach thisList; //loop through array again
}

The last time I used the editor for actual mission making (or a trigger, really) was about a month after the alpha was released on steam, so I'm kind of hazy, but I think I remember that if a trigger condition has been satisfied it doesn't update until it deactivates, so there will be trouble because the civ's will activate it. Let me know if this happens and we can explore another way to do this.

Share this post


Link to post
Share on other sites

Make sure trigger activation is set to "ANY", then just paste this into the "ON ACT." field:

if ({side _x == west}count thisList > 0) then //count objects in trigger and make sure at least 1 is blufor
{
	{
		if (side _x == civilian) then //only affect civ's
		{
			_x switchMove "AmovPercMstpSsurWnonDnon";
			_x disableAI "Anim";
		};
	} forEach thisList; //loop through array again
}

The last time I used the editor for actual mission making (or a trigger, really) was about a month after the alpha was released on steam, so I'm kind of hazy, but I think I remember that if a trigger condition has been satisfied it doesn't update until it deactivates, so there will be trouble because the civ's will activate it. Let me know if this happens and we can explore another way to do this.

 

Getting syntax errors, ran it through a "Surrender.sqf" file and nothing happened.

Share this post


Link to post
Share on other sites

Not on PC right now, but try this: ;)

 

_radius = 100;
_coward = nearestObjects [player, ["CAManBase"], _radius];
{

 _x switchMove "AmovPercMstpSsurWnonDnon";
 _x disableAI "Anim";

} forEach side _coward == CIVILIAN;

I would have to define each civilian class right? I am using modded content, so I assume it would be...

 

**Didn't work, nevermind.

_radius = 100;
_coward = nearestObjects [player, ["CAF_AG_ME_CIV_02","CAF_AG_ME_CIV_03","CAF_AG_ME_CIV_04","CAF_AG_ME_CIV"], _radius];
{

 _x switchMove "AmovPercMstpSsurWnonDnon";
 _x disableAI "Anim";

} forEach side _coward == CIVILIAN;

Share this post


Link to post
Share on other sites

Separate question, sorry, thanks again for the responses.

 

The line

({side _x == civ}count thisList < 5)

can that be used to count how many civilians are on the side that are dead as well?  I assume its something like

({!alive _x && side _x == civ}count thisList > 2) 

Share this post


Link to post
Share on other sites

 

Separate question, sorry, thanks again for the responses.

 

The line

({side _x == civ}count thisList < 5)

can that be used to count how many civilians are on the side that are dead as well?  I assume its something like

({!alive _x && side _x == civ}count thisList > 2) 

 

This line can only return a boolean, therefor you would need to change it to

{!alive _x && (side _x == CIV)}count thisList

In addition, the wiki claims that all dead units are automatically switched over to the civilian side. So you could actually remove the check if the unit is civilian, if you only want to count the dead units.

count allDead
Once dead, a unit will be on the civilian side. https://community.bistudio.com/wiki/side

 

 

 

Correct me if I'm completely off track here.

Share this post


Link to post
Share on other sites

The code I posted was meant to be directly copied/pasted into the "ON ACT." field of the trigger through the editor. You didn't specify which error you were getting after placing the code into a script file, but I assume the error had to do with the "thisList" command, since it would be undefined as the script has no knowledge of what "thisList" is. To fix this, you need to call the script and supply it with thisList, and also make some changes to the original script.

 

copy to trigger "ON ACT." field

thisList execVM "Surrender.sqf"; 

Edited code to work in a script:

if ({side _x == west}count _this > 0) then //change "thisList" to "_this"
{
    {
        if (side _x == civilian) then
        {
            _x switchMove "AmovPercMstpSsurWnonDnon";
            _x disableAI "Anim";
        };
    } forEach _this; //change "thisList" to "_this"
}; //forgot a semicolon on this line.

This makes no sense to me, and I think it's absolutely wrong.


} forEach side _coward == CIVILIAN;

Share this post


Link to post
Share on other sites

This makes no sense to me, and I think it's absolutely wrong.

} forEach side _coward == CIVILIAN;

 

You are correct, forEach expects an array. side _coward == civilian will return a boolean instead.

 

 

I presume you want to only change the animation of civilian units. In order to do so, you have to add a "if-function".

_radius = 100;
_coward = nearestObjects [player, ["CAF_AG_ME_CIV_02","CAF_AG_ME_CIV_03","CAF_AG_ME_CIV_04","CAF_AG_ME_CIV"], _radius];
{
   if ((side_x) == CIVILIAN ) then
   {
     _x switchMove "AmovPercMstpSsurWnonDnon";
     _x disableAI "Anim";
   };
} forEach _coward

OFF TOPIC: Is there a way to put code into spoiler tags ? Worked fine for me with the old forum version.

Share this post


Link to post
Share on other sites

The code I posted was meant to be directly copied/pasted into the "ON ACT." field of the trigger through the editor. You didn't specify which error you were getting after placing the code into a script file, but I assume the error had to do with the "thisList" command, since it would be undefined as the script has no knowledge of what "thisList" is. To fix this, you need to call the script and supply it with thisList, and also make some changes to the original script.

 

copy to trigger "ON ACT." field

thisList execVM "Surrender.sqf"; 

Edited code to work in a script:

if ({side _x == west}count _this > 0) then //change "thisList" to "_this"
{
    {
        if (side _x == civilian) then
        {
            _x switchMove "AmovPercMstpSsurWnonDnon";
            _x disableAI "Anim";
        };
    } forEach _this; //change "thisList" to "_this"
}; //forgot a semicolon on this line.

This makes no sense to me, and I think it's absolutely wrong.

 

 

Type Script Expected Nothing error when trying to put into On Activation. Changed it to Nul = execVM "Surrender.sqf", script does not work still. The civilians just stand there.

thisList execVM "Surrender.sqf"; 

Share this post


Link to post
Share on other sites

Type Script Expected Nothing error when trying to put into On Activation. Changed it to Nul = execVM "Surrender.sqf", script does not work still. The civilians just stand there.

thisList execVM "Surrender.sqf"; 

You are very close. Try this:

0 = thisList execVM "Surrender.sqf";

 

OFF TOPIC: Is there a way to put code into spoiler tags ?

Yepp. ;)

Share this post


Link to post
Share on other sites

You are very close. Try this:

 

0 = thisList execVM "Surrender.sqf";

Still doesn't work :| The civilians just stand there and don't perform the animation.

Share this post


Link to post
Share on other sites
if ({side _x == west}count _this > 0) then

This line confused me somwhat.

 

_this refers to the trigger. So to count the units inside of the trigger, wouldn't you need to do it like that?

 
if ({side _x == west} count (list _this) 

Share this post


Link to post
Share on other sites
if ({side _x == west}count _this > 0) then
This line confused me somwhat.

 

_this refers to the trigger.

 

 

No, it does not. That line is inside the "Surrender.sqf" which is invoked this way:

thisList execVM "Surrender.sqf";

So it does in fact refer to the trigger's list.

If it still doesn't work, instead of the "switchMove" try this:

_x action ["Surrender", _x];

Source: https://community.bistudio.com/wiki/Arma_3_Actions#Surrender

Share this post


Link to post
Share on other sites

Ah my fault, I read thisTrigger instead of thisList.

Share this post


Link to post
Share on other sites

 

No, it does not. That line is inside the "Surrender.sqf" which is invoked this way:

thisList execVM "Surrender.sqf";

Thank you Johnny, R3vo keep in mind when you are doing trigger work in the editor, you have access to 3 commands, this, thisTrigger, and thisList

 

this: Refers to the trigger condition you set with the GUI menu. You can add extra extra conditions by using AND and OR:

this && (myVar == 0) //requires GUI condition be met AND myVar is equal to 0 before the trigger will execute

thisTrigger: Refers to the trigger object itself

thisList: Refers to an array of objects that are currently making the condition true (This may be old information, but last time I used triggers, once the condition has been met it will not update and refresh thisList until the trigger has deactivated and is waiting for the condition to be met again)

Share this post


Link to post
Share on other sites

Edit: wrong thread to post, forget I existed here. :p

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  

×