Jump to content
Sign in to follow this  
EBass

Sense casualty % on spawned units

Recommended Posts

Hi there, I'm doing an I44 mission where you take an objective which triggers a counter attack, the counter attack spawns multiple groups with this script.

Esec1= Creategroup EAST;

_Unit1= Esec1 createUnit ["I44_Man_G_WH_Camo_NCO_MP43",[(getMarkerPos "Es1") select 0,(getMarkerPos "Es1") select 1,0],[],0,"FORM"];

for [{_i = 0}, {_i <= 4}, {_i = _i + 1}] do

{

_Unit2= Esec1 createUnit ["I44_Man_G_WH_Camo_K98k",[(getMarkerPos "Es1") select 0,(getMarkerPos "Es1") select 1,0],[],0,"FORM"];

};

_Unit3= Esec1 createUnit ["I44_Man_G_WH_Camo_K98k_GGrGer",[(getMarkerPos "Es1") select 0,(getMarkerPos "Es1") select 1,0],[],0,"FORM"];

_Unit4= Esec1 createUnit ["I44_Man_G_WH_Camo_K98k_PzF60",[(getMarkerPos "Es1") select 0,(getMarkerPos "Es1") select 1,0],[],0,"FORM"];

_Unit5= Esec1 createUnit ["I44_Man_G_WH_Camo_MP40",[(getMarkerPos "Es1") select 0,(getMarkerPos "Es1") select 1,0],[],0,"FORM"];

_unit3 setunitrank "CORPORAL";

_unit1 setunitrank "SERGEANT";

_unit1=leader Esec1;

Esec2= Creategroup EAST;

etc

and two tanks with this script.

tank1 = "I44_Tank_G_PzKpfwIV_G_WH" createVehicle (getMarkerPos "as1");

_tank2 = "I44_Tank_G_PzKpfwIV_G_WH" createVehicle (getMarkerPos "as2");

sleep 1;

Acrew1= Creategroup EAST;

_Unit1= Acrew1 createUnit ["I44_Man_G_WH_Crew_MP40",[(getMarkerPos "AsC1") select 0,(getMarkerPos "AsC1") select 1,0],[],0,"FORM"];

_Unit2= Acrew1 createUnit ["I44_Man_G_WH_Crew_P38",[(getMarkerPos "AsC1") select 0,(getMarkerPos "AsC1") select 1,0],[],0,"FORM"];

_Unit3= Acrew1 createUnit ["I44_Man_G_WH_Crew_P38",[(getMarkerPos "AsC1") select 0,(getMarkerPos "AsC1") select 1,0],[],0,"FORM"];

Acrew2= Creategroup EAST;

_Unit4= Acrew2 createUnit ["I44_Man_G_WH_Crew_MP40",[(getMarkerPos "AsC2") select 0,(getMarkerPos "AsC2") select 1,0],[],0,"FORM"];

_Unit5= Acrew2 createUnit ["I44_Man_G_WH_Crew_P38",[(getMarkerPos "AsC2") select 0,(getMarkerPos "AsC2") select 1,0],[],0,"FORM"];

_Unit6= Acrew2 createUnit ["I44_Man_G_WH_Crew_P38",[(getMarkerPos "AsC2") select 0,(getMarkerPos "AsC2") select 1,0],[],0,"FORM"];

sleep 1;

_Unit1 assignAsCommander _tank1;

[_Unit1] orderGetIn true;

_Unit2 assignAsGunner _tank1;

[_Unit2] orderGetIn true;

_Unit3 assignAsDriver _tank1;

[_Unit3] orderGetIn true;

Basically I want the counter-attack to "fail" when this force takes about say 70% casualties and both tanks are decrewed/destroyed. Any way I can do this? Thanks.

Share this post


Link to post
Share on other sites

_myGroups = [group1,group2...];
_myUnits = [];
_myTanks = [tank1,tank2...];

{_myUnits = _myUnits + units _x;} foreach _myGroups;

_unitsCount = count _myUnits;
_unitsCountCasualties = _unitsCount * 0.3;

Condition:

({alive _x && !fleeing _x} count _myUnits < _unitsCountCasualties) && {!canMove _x OR !canFire _x} count _myTanks == 2 

Edited by 2nd Ranger

Share this post


Link to post
Share on other sites
_myGroups = [group1,group2...];
_myUnits = [];
_myTanks = [tank1,tank2...];

{_myUnits = _myUnits + units _x;} foreach _myGroups;

_unitsCount = count _myUnits;
_unitsCountCasualties = _unitsCount * 0.3;

Condition:

({alive _x && !fleeing _x} count _myUnits < _unitsCountCasualties) && {canMove _x OR canFire _x} count _myTanks == 0 

So its the first in a script and the second as a condition in a trigger? I'll try it out, thanks!

Share this post


Link to post
Share on other sites

No, you'd be better putting them at the end of your spawn script and putting a waitUntil on the condition, then setting any variables you might need. Like this.

waituntil {sleep 0.1; ({alive _x && !fleeing _x} count _myUnits < _unitsCountCasualties) && {!canMove _x OR !canFire _x} count _myTanks == 2};
hint "70% casualties!";
enemyDefeated = true;

EDIT: changed the tank damage check.

Edited by 2nd Ranger

Share this post


Link to post
Share on other sites
No, you'd be better putting them at the end of your spawn script and putting a waitUntil on the condition, then setting any variables you might need. Like this.

waituntil {sleep 0.1; ({alive _x && !fleeing _x} count _myUnits < _unitsCountCasualties) && {!canMove _x OR !canFire _x} count _myTanks == 2};
hint "70% casualties!";
enemyDefeated = true;

EDIT: changed the tank damage check.

Thanks mate, that seems to work like a charm, although the tank damage script seems to fire a little early. It seems to fire if they take a significant hit even if they are still active. But it works. Any idea how I can make them all retreat and then delete any unit after it retreats? I'm guessing I'd have to delete each groups waypoint and set a new one "running away"

Share this post


Link to post
Share on other sites

Look at copyWaypoints. Put down a single unit with a waypoint to where you want the groups to run to. In his init line, give him a group name and deleteVehicle this. Now at any time you can use copyWaypoints to cancel a group's waypoints and make them follow that one.

As for the tanks, if you want them completely destroyed then just change the check to !alive. But generally when a tank can't move or fire then the crew abandons it and it is no longer a threat.

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  

×