Jump to content
Sign in to follow this  
Vectif

How to make a script of 'protesting' civilians that disperse?

Recommended Posts

Hello! I'm interested in replicating something as seen in this Arma 2 mission:
https://youtu.be/y0RdVjhsgEk?t=286

How would I go about doing this? I had a sort of mental idea that I could make a group of civilians set as careless, with a waypoint synced to a trigger to make them flee somehow, but that trigger would need to detect when a smoke is in proximity or if a shot is fired at them or when standing in proximity/nearby them. How could I make a trigger detect either of these two conditions? Is there a way I can make that trigger set all the civs to flee? And how about syncing a sound to them to play within their vicinity up until that trigger is activated?

I have a sort of idea but I'm not sure which snippets of code I could use, but seeing as it was done in Arma 2, I believe it could be possible.
Thanks!

Share this post


Link to post
Share on other sites

I would suggest looking into the FiredNear eventhandler, as it can detect when shots are fired near a unit and even thrown stuff like grenades since Arma 3 1.30. For example, you can add it to the civilians in question ( or just the group leaders) and then use it to give them a simple move command to somewhere else.

 

To illustrate, try putting this into the init field of a civilian or civilian group leader:

this addEventHandler ["FiredNear", 
{
	params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"];

	group _unit setSpeedMode "FULL";
	group _unit setCombatMode "BLUE";
	group _unit setBehaviourStrong "AWARE";
	group _unit move getMarkerPos "civsFleeToHere"; // <---- Replace civsFleeToHere with the marker var name of your choosing
	
}];

 

You might want to play around with the values of the commands inside like combatMode and behaviour to get exactly what you're looking for.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
13 hours ago, alpha993 said:

I would suggest looking into the FiredNear eventhandler, as it can detect when shots are fired near a unit and even thrown stuff like grenades since Arma 3 1.30. For example, you can add it to the civilians in question ( or just the group leaders) and then use it to give them a simple move command to somewhere else.

 

To illustrate, try putting this into the init field of a civilian or civilian group leader:


this addEventHandler ["FiredNear", 
{
	params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"];

	group _unit setSpeedMode "FULL";
	group _unit setCombatMode "BLUE";
	group _unit setBehaviourStrong "AWARE";
	group _unit move getMarkerPos "civsFleeToHere"; // <---- Replace civsFleeToHere with the marker var name of your choosing
	
}];

 

You might want to play around with the values of the commands inside like combatMode and behaviour to get exactly what you're looking for.

Once again, this is golden! I really appreciate your help with these. I've been wanting to work on some missions with objectives that are a little bit different compared to "just go there shoot some bad guys" and this definitely helps for making some interesting scenarios. Thank you very much!!! Much appreciated 🙂

  • Like 1

Share this post


Link to post
Share on other sites

What kind of value goes into the "_distance" parameter? e.g. if I want to reduce the maximum distance for which FiredNearEH will trigger. I know the maximum is 70m, but I want to lower it to around 5m-10m. I've tried setting it as "5", "5m", "_5", "_5m", "_distance 5", "_distance [5]",  "_distance < 5" and none of these make a difference. Is it possible to change the maximum distance to be any lower? Or am I doing something wrong?

edit: Got some help from R3vo on the Arma 3 Discord, the following code works for setting the maximum distance!
 

Quote

this addEventHandler ["FiredNear",  

 params ["_unit", "_firer", "_distance", "_weapon", "_muzzle", "_mode", "_ammo", "_gunner"]; 
 if (_distance > 5) exitWith {}; //Exit if _distance variable is greater than 5. Code after this will not be executed
 group _unit setSpeedMode "FULL"; 
 group _unit setCombatMode "BLUE"; 
 group _unit setBehaviourStrong "AWARE"; 
 group _unit move getMarkerPos "CivsFlee";
}];


I've also figured out a way around a variant of my own which makes some civilians pull out a pistol on the soldiers when they threaten them to go away for it to be a little bit more interesting!

  • Like 1

Share this post


Link to post
Share on other sites

Glad it worked out! But yeah, event handler parameters usually are the values of what triggered them, so simple conditionals like if statements are always useful to restrict when the handlers actually execute their code.

  • Like 1

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  

×