Jump to content
Sign in to follow this  
dm610

AI Vehicle Respawn Help (Units in cargo)

Recommended Posts

So ive tried many ways and took the advice of some of the memebers here but i still cant seem to get this to work. I am trying to have a vehicle respawn with the units i have assigned to it. So that basically there is an empty vehicle the units spawn and board there assigned positions and when destroyed the vehicle and units respawn and repeat this process over and over. I have an empty vehicle that respawns no problem. I can assign a driver, a gunner, and a commander and they spawn in the vehicle no problem as i use: this moveindriver vehname; this moveingunner vehname; this moveincommander vehname;. Now i already knew that when i use "this moveincargo vehname; that the unit would not spawn in the vehicle so while searching the forums i found a thread that reccomended adding this "if (_loop == 3) then {_guy moveInCargo _vcl_new};" to the AIvcl_respawn.sqf. So that it now looks like this

for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do
{	
_guy = _unitsGroup select _loop;
_guy setSkill (_AI_skillArray select _loop);
if (_loop == 0) then {_guy moveInDriver _vcl_new};
if (_loop == 1) then {_guy moveInGunner _vcl_new};	
if (_loop == 2) then {_guy moveInCommander _vcl_new}; 
if (_loop == 3) then {_guy moveInCargo _vcl_new};

Now i have it so that the unit assigned to cargo now spawns in cargo but its just one unit, the rest of the units assigned to cargo spawn outside still. I tried modifying the loop ==#, adding multiple "if (_loop == 3) then {_guy moveInCargo _vcl_new};" so it appears like this

for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do
{	
_guy = _unitsGroup select _loop;
_guy setSkill (_AI_skillArray select _loop);
if (_loop == 0) then {_guy moveInDriver _vcl_new};
if (_loop == 1) then {_guy moveInGunner _vcl_new};	
if (_loop == 2) then {_guy moveInCommander _vcl_new}; 
if (_loop == 3) then {_guy moveInCargo _vcl_new};
            if (_loop == 4) then {_guy moveInCargo _vcl_new};
            if (_loop == 5) then {_guy moveInCargo _vcl_new};
            if (_loop == 6) then {_guy moveInCargo _vcl_new};

And still nothing, either one unit spawns in cargo sometimes two units but the rest of the units assigned to cargo do not spawn in the vehicle. Ive searched all over the web and am out of ideas. S.O.S.

Edit: Ok so now i have 4 soldiers each named "s1","s2

,"s3","s4" leader being "s1". Their vehicle is named "h1". In the leaders init i put:

nul = [this, 3, 10, "west_spawn","West_WP.sqf"] execVM "AI_respawn\AI_respawn_init.sqf"; s1 assignAsDriver h1; [s1,s2,s3,s4] orderGetIn true;

In the vehicle "h1" init i put:

nul = [this, 3, 10, "WS1"] execVM "AIvcl_respawn_WP\AIvcl_respawn_WP_init.sqf"; 

The 4 soldiers spawn board vehicle drive to waypoint they get killed they respawn, the vehicle respawns but the soldiers do not board the vehicle again. Ive almost reached my goal as now the vehicle doesnt drive off with missing cargo i just need to find a way so that

[s1,s2,s3,s4] orderGetIn true;

Repeats.

Edited by dm610

Share this post


Link to post
Share on other sites

Use the forum code # in advanced to wrap the code you posted so they are formatted, makes it easier to read.

Share this post


Link to post
Share on other sites

does anybody knows how to make "orderGetIn true;" repeat continuously?

Share this post


Link to post
Share on other sites

so nobody on bi forums knows how to do this. at this point i have a trigger with the same

[s1,s2,s3,s4] orderGetIn true;

but i cant get the trigger to repeat somebody has to know how to do this.

Share this post


Link to post
Share on other sites

This spawns a group and a vehicle and has the units board the vehicle.

group3 = [_pos1, east, ["TK_INS_Soldier_TL_EP1","TK_INS_Soldier_EP1","TK_INS_Soldier_AR_EP1"]] call BIS_fnc_spawnGroup;


group3veh = [[_pos1 select 0, (_pos1 select 1) - 5,.5], east, ["BTR40_MG_TK_INS_EP1"]] call BIS_fnc_spawnGroup;

_nObject = nearestObject [_pos1, "BTR40_MG_TK_INS_EP1"];

{ _x action ["getInCargo", _nObject]} forEach (units group3);

Just change the _pos1 , groups and veh for your tastes.

Share this post


Link to post
Share on other sites
does anybody knows how to make "orderGetIn true;" repeat continuously?

so nobody on bi forums knows how to do this. at this point i have a trigger with the same

You wouldn't want that, otherwise your soldiers would never fight they'd just constantly be getting back in their vehicles.

As with many posts by many editors recently you should release yourself from the "respawning waves of CoDish baddies" idea and think of groups as one time things. You spawn a singular group, you give it orders and you let it go. When it dies you spawn an entirely different group, give it the same orders and let it go. You don't "respawn" the same group.

Of course if you're not cleaning up groups you'll run into the group limit, so as part of the "Is the group dead?" check delete the actual group as well. You could reuse the group name, but the point is that you don't want commands to "repeat continuously" you want to issue the same commands to different groups.

Than again, I'm burned out of the Domi style hours long fighting the same things over and over style maps and really enjoy the one-shot-at-victory small scale scenarios much more. :)

Share this post


Link to post
Share on other sites
This spawns a group and a vehicle and has the units board the vehicle.

group3 = [_pos1, east, ["TK_INS_Soldier_TL_EP1","TK_INS_Soldier_EP1","TK_INS_Soldier_AR_EP1"]] call BIS_fnc_spawnGroup;


group3veh = [[_pos1 select 0, (_pos1 select 1) - 5,.5], east, ["BTR40_MG_TK_INS_EP1"]] call BIS_fnc_spawnGroup;

_nObject = nearestObject [_pos1, "BTR40_MG_TK_INS_EP1"];

{ _x action ["getInCargo", _nObject]} forEach (units group3);

Just change the _pos1 , groups and veh for your tastes.

thanks for the script i put it in the init of a trigger that is activated by opfor (to test if it works) and nothing no units spawn. am i missing something?

---------- Post added at 17:05 ---------- Previous post was at 16:54 ----------

You wouldn't want that, otherwise your soldiers would never fight they'd just constantly be getting back in their vehicles.

As with many posts by many editors recently you should release yourself from the "respawning waves of CoDish baddies" idea and think of groups as one time things. You spawn a singular group, you give it orders and you let it go. When it dies you spawn an entirely different group, give it the same orders and let it go. You don't "respawn" the same group.

Of course if you're not cleaning up groups you'll run into the group limit, so as part of the "Is the group dead?" check delete the actual group as well. You could reuse the group name, but the point is that you don't want commands to "repeat continuously" you want to issue the same commands to different groups.

Than again, I'm burned out of the Domi style hours long fighting the same things over and over style maps and really enjoy the one-shot-at-victory small scale scenarios much more. :)

I hear you its been reversed for me. Ive been playing the one-shot mil-sim missions and scenarios and its been a blast, but ive been wanting to make a sp mission template where theres a single enemy base that is guarded by the opfor and the blufor have there own base which they spawn board vehicles and attack, pretty straightforward. itll be similar to bf and cod in that you can just jump into a match get into the action immediately but encompases arma's approach to realism which makes the action more intense and not so dramatic\cinematic like cod. Thats my overall goal, so if it is possible to have an init command repeat or a trigger to repeat could you please show me as im still slowly learning how to script and its only very simple things as of now.

Share this post


Link to post
Share on other sites

You need three things to make it work.

1. You need to put the functions module down in your mission or you need to be running the mod CBA.

2. You need to create a center for the side you wish to spawn. If you do not have any other units of that type preplaced on the map then put down one unit of the same side and set its probability of presence to 0%. Or you can progmaticly create the center.

3. If your running this from a trigger, then you need to change "_pos1" to "pos1" and declare it before you run the above code. Or hard code the position in the code above.

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  

×