Jump to content
quickdagger

How to make an enemy group spawn if you kill a civilian?

Recommended Posts

Hi all,

 

This time I would like to know what should be your codes for spawning an enemy group when the player kills a civilian. Interpret that as the civilian's family and friends coming to take revenge.

 

I am using Bangabob's COS - Civilian Occupation System, I am not placing civilian units on the map, in the editor, so, I presume I can't edit their init field.

I am also using Bangabob's EOS - Enemy Occupation system.

Both EOS and COS require that you place triggers on the map, which will serve as their spawn points. Somehow they recognize house interiors so, units respawn inside house if you config to do so. Really amazing.

I am also using CBA and ACE.

There could be a delay between killing the civilian and the spawn of the enemy group.

The spawn point should be the nearest village/base but not the current village/base. Or the nearest trigger on the mao, which I use as the spawn points to EOS or COS ?

EOS

 

@Leopard20 @opusfmspol @stburr91 @froggyluv @Play3r @vilas

Since you have provided great help the other day, I would like to invite you to this discussion but, pls feel free to move on with this idea or not if you will. 

 

Share this post


Link to post
Share on other sites

If you kill too much, bomb too much, etc, then you will have a hard time with enemies growing in Geometric Progression.

 

Share this post


Link to post
Share on other sites

@quickdagger,

Here's an event handler that will do what you ask,
 

Spoiler

this addEventHandler ["Killed", 
	{ params ["_unit", "_killer", "_instigator", "_useEffects"];
	missionNamespace setVariable ["spawnCAP", 30];
	private _grpCount = EAST countSide allUnits;
	private _capLimit= missionNamespace getVariable ["spawnCap", 0];
		if (_grpCount <_capLimit) exitWith {
			_nearTRIG = _unit nearObjects ["EmptyDetector", 1000]; 
		private	_grp=[getPos (_nearTrig select 0), east, 5] call BIS_fnc_spawnGroup;
		private	_wp = _grp addWaypoint [(getPos _unit), 0];
	};
}];

 

It includes a cap limit for the scenario to prevent too many units being spawned. Set the limit as you please and remember the number includes all units in the scene.

Here is the same as a function to call on all civs in the scene *this part is not tested yet*
 

Spoiler

you_fnc_avengers=
{
_this addEventHandler ["Killed", 
	{ params ["_unit", "_killer", "_instigator", "_useEffects"];
	missionNamespace setVariable ["spawnCAP", 30];
	private _grpCount = EAST countSide allUnits;
	private _capLimit= missionNamespace getVariable ["spawnCap", 0];
		if (_grpCount <_capLimit) exitWith {
			_nearTRIG = _unit nearObjects ["EmptyDetector", 1000]; 
		private	_grp=[getPos (_nearTrig select 0), east, 5] call BIS_fnc_spawnGroup;
		private	_wp = _grp addWaypoint [(getPos _unit), 0];
		};
	}];
};
_civs = allUnits side Civilian;
{[_x] call you_fnc_avengers} forEach _civs;

 

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, quickdagger said:

I am not placing civilian units on the map, in the editor, so, I presume I can't edit their init field.

 

From COS Armaholic page :

Quote

Open COS/AddScript_Unit.sqf to apply scripts to spawned units.
Open COS/AddScript_Vehicle.sqf to apply scripts to spawned vehicles.

 

Share this post


Link to post
Share on other sites

Nah, the init field on COS it is not working...

And, I am not using COS anymore, EOS spawning civilians is better for what I am trying to do...

 

@wogz187, I don't know how to use an event handler, pls where do I paste that piece of code?

 

Share this post


Link to post
Share on other sites

@quickdagger,

Quote

I don't know how to use an event handler, pls where do I paste that piece of code?


The event handler would be pasted into a civilian's Init dialog box. However this is less than ideal which is why I also posted the function version. If it works properly, calling that function into your map should make all the civilians automatically summon an avengers group (at the nearest trigger) when killed.

To call the function paste:
 

Spoiler

you_fnc_avengers=
{
_this addEventHandler ["Killed", 
	{ params ["_unit", "_killer", "_instigator", "_useEffects"];
	missionNamespace setVariable ["spawnCAP", 30];
	private _grpCount = EAST countSide allUnits;
	private _capLimit= missionNamespace getVariable ["spawnCap", 0];
		if (_grpCount <_capLimit) exitWith {
			_nearTRIG = _unit nearObjects ["EmptyDetector", 1000]; 
		private	_grp=[getPos (_nearTrig select 0), east, 5] call BIS_fnc_spawnGroup;
		private	_wp = _grp addWaypoint [(getPos _unit), 0];
		};
	}];
};
_civs = allUnits side Civilian;
{[_x] call you_fnc_avengers} forEach _civs;

 

into the mission init dialog OR your init file.

Have fun!

  • 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

×