Jump to content
Sign in to follow this  
hajimoto

Enemy reinforcement based on amount of remaining forces chopper

Recommended Posts

I saw a post earlier that worked on enemy counts and this thread got me thinking as it relates to the enemy calling in reinforcements to supplement their efforts.

What I want to happen is when the enemy unit count within the AO goes below a defined limit, a chopper is called in and 8 paratroopers are added to the mix. I have successfully created other scripts that work perfectly utilizing !Alive variable initiator but this query dynamic variable is something I need help with.

Here is what i have for variables and syntax, please evaluate and advise on the best way to accomplish this goal

_aliveInZone = {[[getMarkerPos NewAO, PARAMS_AOSize], _x] call BIS_fnc_inTrigger && side _x == opfor && alive _x} count AllUnits;

waitUntil {sleep 5; _aliveInZone > PARAMS_MinEnemyForce};

_nul = [NewAO, 2,true,true,2300,"random",true,150,50,8,1,70,false,false,false,true,plgroup,false,0.2,nil,nil,nil,false] execVM "LV\heliParadrop.sqf";

Thank you in advance guys

Share this post


Link to post
Share on other sites

the way I see this; the _aliveinzone is not updated on each death, it would have to be checked a number of times to get he value each time an opfor is taken out.

// code could be called at start of AO or from trigger as execvm
while {someway in here to test for current AO} do {        //would evaluate to true
   _aliveInZone = {[[getMarkerPos NewAO, PARAMS_AOSize], _x] call BIS_fnc_inTrigger && side _x == opfor && alive _x} count AllUnits;
   if(_aliveInZone > PARAMS_MinEnemyForce) exitwith {_nul = [NewAO, 2,true,true,2300,"random",true,150,50,8,1,70,false ,false,false,true,plgroup,false,0.2,nil,nil,nil,false] execVM "LV\heliParadrop.sqf"};
   sleep 5;
};

Share this post


Link to post
Share on other sites

I'm after something similar to this aswell. Wanting to use ground reinforcement convoys from bases to understrength fobs, and heli reinforcements from/to airbases resupplying understrength bases/airbases. Simulate some supply lines similar to warfare.

So far my poor man's methods haven't produced anything functional.

How will you deal with a full clear of the zone before the reinforcements arive? reinforcements become a counter-attack? I guess if it's a nearby ambient spawn it won't be a prob.

Edited by Focht

Share this post


Link to post
Share on other sites
the way I see this; the _aliveinzone is not updated on each death, it would have to be checked a number of times to get he value each time an opfor is taken out.

// code could be called at start of AO or from trigger as execvm
while {someway in here to test for current AO} do {        //would evaluate to true
   _aliveInZone = {[[getMarkerPos NewAO, PARAMS_AOSize], _x] call BIS_fnc_inTrigger && side _x == opfor && alive _x} count AllUnits;
   if(_aliveInZone > PARAMS_MinEnemyForce) exitwith {_nul = [NewAO, 2,true,true,2300,"random",true,150,50,8,1,70,false ,false,false,true,plgroup,false,0.2,nil,nil,nil,false] execVM "LV\heliParadrop.sqf"};
   sleep 5;
};

I always assumed that exitwith was an SP command and stayed away from it. Thank you for the clarification and concise resolve. I will try and implement this and report the results accordingly.

Share this post


Link to post
Share on other sites

i have found exitwith to be very useful to break out of a while {true} loop. usually with the IF then/exitwith option to test for the end of the loop.

I just want to reiterate - you will need to find a way of checking for your current AO - I don't know how you named them.

replace "someway in here to test for current AO" with the details

the other thing is that this will only reinforce once.

Share this post


Link to post
Share on other sites

@KevsnoTrev - This is will not work for me as i need to have the sequence continue to check the AO and if it is below the limit again and the tower is still up... send more reinforcements. I plan to use a % generator so that it may check every 30secs but the % generator will minimize the frequency of the chopper call in.

I think i will have to have another sqf that helps handle what it is that want to achieve. Ok my mind is mush now.... going to try again tomorrow.

Thank you for the help

Share this post


Link to post
Share on other sites

I am detecting a domination style mission here----so something like this then?

while {CurrentAO} do { //currentAO is set to true at the start of an AO
   if (_AliveinZone<20 && alive RadioTower) then {
   //put your spawn for reinforcements in here
 };
   if (!alive radiotower) exitwith {// end reinforcements here};
   sleep 30;
};

The drop in reinforcement % will be simple to do as a variable to store the number of units to spawn and just reduce after each use.

Share this post


Link to post
Share on other sites
I am detecting a domination style mission here----so something like this then?
while {CurrentAO} do { //currentAO is set to true at the start of an AO
   if (_AliveinZone<20 && alive RadioTower) then {
   //put your spawn for reinforcements in here
 };
   if (!alive radiotower) exitwith {// end reinforcements here};
   sleep 30;
};

The drop in reinforcement % will be simple to do as a variable to store the number of units to spawn and just reduce after each use.

It certainly is a Domination type script. It is a heavily modified early release of AW Invade & Annex. I have listed the section that I need help with and respectfully request that you look it over and advise accordingly. I am very new at scripting this deep and am way over my head on this one.

//Show global target start hint

GlobalHint = _targetStartText; publicVariable "GlobalHint"; hint parseText GlobalHint;

showNotification = ["NewMain", currentAO]; publicVariable "showNotification";

showNotification = ["NewSub", "Destroy the enemy radio tower."]; publicVariable "showNotification";

// WAIT FOR TARGET COMPLETION

_backup = "<t align='center' size='2.2' color='#b00007'>** ALERT **</t><br/><t size='1.5' color='#08b000' align='center'>Aircraft Inbound</t><br/>____________________<br/>AWACS Skyraider AEW.1 has alerted HQ that there is radar contacts inbound to the main AO!<br/><br/> Get that damn tower destroyed!! OUT!";

_aliveInTrigger = {[[getMarkerPos currentAO, PARAMS_AOSize], _x] call BIS_fnc_inTrigger && side _x == opfor && alive _x} count AllUnits;

if (_AliveinZone<60 && alive RadioTower) then {_nul = [currentAO,2,true,true,2300,"random",true,150,50,6,1,70,false,false,false,true,plgroup,false,0.2,nil,nil,nil,false] execVM "LV\heliParadrop.sqf"}; GlobalHint = _backup; publicVariable "GlobalHint"; hint parseText GlobalHint; showNotification = ["CompletedSub", "Radar Contact."]; publicVariable "showNotification";

} else {

waitUntil {sleep 5; count list _dt < PARAMS_EnemyLeftThreshhold}

waitUntil {sleep 0.5; !alive radioTower};

radioTowerAlive = false;

publicVariable "radioTowerAlive";

"radioMarker" setMarkerPos [0,0,0];

_airdrop = "<t align='center' size='2.2' color='#b00007'>** ALERT **</t><br/><t size='1.5' color='#08b000' align='center'>Aircraft Inbound</t><br/>____________________<br/>AWACS Skyraider AEW.1 has alerted HQ that there is radar contacts in the area! The enemy has scrambled a counter attack.<br/><br/> Dig in and take defensive positions! Prepare for their arrival, good luck and God speed!";

_radioTowerDownText =

"<t align='center' size='2.2'>Radio Tower</t><br/><t size='1.5' color='#08b000' align='center'>DESTROYED</t><br/>____________________<br/>The enemy radio tower has been destroyed! Fantastic job, guys! You're now all free to use your Personal UAVs!<br/><br/>Keep up the good work, guys; we're counting on you.";

GlobalHint = _radioTowerDownText; publicVariable "GlobalHint"; hint parseText GlobalHint;

showNotification = ["CompletedSub", "Enemy radio tower destroyed."]; publicVariable "showNotification";

sleep 5;

showNotification = ["Reward", "Personal UAVs now available."]; publicVariable "showNotification";

sleep 42;

_chance = random 10;

if (_chance < 5) then

{

showNotification = ["NewSub", "Enemy Counter Attack."]; publicVariable "showNotification";

_nul = [currentAO,2,true,true,2300,"random",true,150,50,9,1,70,false,false,false,true,plgroup,false,0.2,nil,nil,nil,false] execVM "LV\heliParadrop.sqf"; _nul = [currentAO,2,true,true,1100,"Random",true,100,70,10,1,70,true,false,false,true,plgroup,false,0.2,nil,nil,nil,false] execVM "LV\heliParadrop.sqf";

GlobalHint = _airdrop; publicVariable "GlobalHint"; hint parseText GlobalHint;

waitUntil {sleep 5; count list _dt < PARAMS_EnemyLeftThreshhold}

} else {

waitUntil {sleep 5; count list _dt < PARAMS_EnemyLeftThreshhold}

};

//Set enemy kill timer

[_enemiesArray] spawn AW_fnc_deleteOldAOUnits;

if (_isPerpetual) then

{

_lastTarget = currentAO;

if ((count (_targets)) == 1) then

{

_targets = _initialTargets;

} else {

_targets = _targets - [currentAO];

};

} else {

_targets = _targets - [currentAO];

};

publicVariable "refreshMarkers";

currentAOUp = false;

publicVariable "currentAOUp";

//Delete detection trigger and markers

deleteVehicle _dt;

radioTowerAlive = true;

publicVariable "radioTowerAlive";

//Small sleep to let deletions process

sleep 5;

//Set target completion text

_targetCompleteText = format

[

"<t align='center' size='2.2'>Target Taken</t><br/><t size='1.5' align='center' color='#FFCF11'>%1</t><br/>____________________<br/><t align='left'>Fantastic job taking %1, boys! Give us a moment here at HQ and we'll line up your next target for you.</t>",

currentAO

];

{_x setMarkerPos [0,0,0];} forEach ["aoCircle","aoMarker","radioMineCircle"];

//Show global target completion hint

GlobalHint = _targetCompleteText; publicVariable "GlobalHint"; hint parseText GlobalHint;

showNotification = ["CompletedMain", currentAO]; publicVariable "showNotification";

};

Any help that can be shared is appreciated.

Share this post


Link to post
Share on other sites

Hi,

Can you please try this and let me know how it goes? - I don't have the same version of I&A to test with.

I have to post it on my Google drive as pasting the code in doesn't seem to be keeping formatting today.

Google Drive Link just rename it to the one you have and it should be ok.

if anything I expect a few missing ; or } to come up.

What have I done?

I took out the if () then {} at the start and put in a while/do

that means you can call in reinforcements as often as you like.

If you want it to get longer (or shorter) between calls then you can put a variable in place - declare it near the top of the script you may need to add in to your private[""] area

_increase = 50;

Then replace the sleep 300 with:

sleep 300 - _increase;

Then after that:

if (_increase < 300) then {_increase = _increase +50};

this will make the reinforcements drop in less often but mean if it gets to 5 minutes (total of ten) it won't go any higher - especially important on a persistent server

I have done mine a different way.

Using a count of the total number of human players in mission

_playercount = {isplayer _x} count allunits

you can then run a multiplier on that to base the number of enemies on the total of people playing - I figure around random(1-3) enemy squads of 4 per player , mostly for stable high fps gameplay but also it allows things to be done from vehicles/air etc

Share this post


Link to post
Share on other sites

Well I made the changes and for the most part once I reduced the enemy below the threshold, two errors pop up every 300 secs. They are:

http://i.imgur.com/Pm13EwW.jpg (208 kB)

http://i.imgur.com/MhGyPze.jpg (228 kB)

The reason I have the < number so high was for play testing, I HALO Drop into the AO as a Captive and test. The error that is generated by "heliParadrop.sqf" is strange because I have had the 50% reinforcement call in place for weeks and it works perfectly.

Here is a screeny of the line 912 to help narrow things down.

http://i.imgur.com/SVCQxVU.jpg (216 kB)

Thank you again for the help.

Share this post


Link to post
Share on other sites

These are just undefined variable errors

the first in your paradrop.sqf

- you need to define _target it looks to me like finding how to use bis_fnc_param may help here as its either an object or array I suspect

The second in your Init.sqf again is undefined plGroup (player group?) it needs to be set up before being called.

iirc, isn't I&A all set up and run from the init.sqf? Do you have definitions for all variables, used in the whole script, anywhere?

Do you make use of the Private ["_varname",.....] it can help to make sure a variable is able to be used inside a loop where it wasn't created?

Can you post the whole file or PM me with it if you don't want it too public as I can't figure why you would have errors now you didn't before.

I have noted one thing. The loop I set up will only be called once every 5 minutes which is not what you want.

Change the sleep 300 to sleep 1. then add sleep 300 at the end of the heliparadrop.sqf"; <in here>};

that way it checks every second for the radiotower to be still alive and the count of enemies in the triggerarea.

if paradrop is called then it takes a 5 minute break.

Share this post


Link to post
Share on other sites

I will send you a link privately to the entire mission.

I have said it before I know, but thank you so much for the help on this.

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  

×