Jump to content
Sign in to follow this  
OckHAM

Respawn AI unit with same init line

Recommended Posts

I have a group of three AI units getting in an house with this init line:

_script = group this execVM "PlaceInBuilding.sqf";

_group = _this;

_leader = leader _group;

_check_distance = 50; // Change this to tweak building searching distance

_arr_buildings = nearestObjects [_leader, ["HOUSE"], _check_distance];

_buildingcount = count _buildings;

_arr_positions = [];

{

_i = 0;

_positions_checked = FALSE;

while {not _positions_checked} do {

_position = _x buildingPos _i;

_coord_x = _position select 0;

_coord_y = _position select 1;

_coord_z = _position select 2;

_coord_sum = _coord_x + _coord_y + _coord_z;

if (_coord_sum == 0) then {

_positions_checked = TRUE;

} else {

_arr_positions = _arr_positions + [_position];

_i = _i + 1;

};

};

} foreach _arr_buildings;

{

_newgroup = createGroup side _leader;

[_x] join _newgroup;

if (count _arr_positions == 0) then {

deleteVehicle _x;

};

_position = _arr_positions select random count _arr_positions;

_x setPos _position;

_x setDir random 360;

_x removeWeapon "HandGrenade_East"; _x removeMagazines "HandGrenade_East";

_x removeWeapon "HandGrenade_West"; _x removeMagazines "HandGrenade_West";

_x removeWeapon "HandGrenade"; _x removeMagazines "HandGrenade";

_x setUnitPos "UP";

} foreach units _group;

Now, I'd like to make this group respawn after 600 seconds that all three units are killed and go again inside the building using the PlaceInBuilding.sqf

Someone could help me doing this? Actually I've been able just to make them respawning using UPS adding the following line to init:

nul = [this, 1000, 1300, "S2","B3"] execVM "AI_respawn_UPS\AI_respawn_UPS_init.sqf";

Thanks in advance

Share this post


Link to post
Share on other sites

you can try this create the 3 men via script just place a functions module on the map

and a unit from the east faction in the corner of the map presence 0%

the code

my_men_respawn = {
   sleep 600; // this makes it wait 600 secounds before respawn
   [] spawn spawn_my_men; 


};


spawn_my_men = {

	  _mymen = [getMarkerpos "your_marker_name_here", EAST, 3] call BIS_fnc_spawnGroup
	  _handler = [_mymen] execVM "PlaceInBuilding.sqf";
         _mymen addEventHandler["killed", { (_this select 0) spawn my_men_respawn; }];

	  // lets give em some skill

{_x setSkill ["aimingAccuracy",0.65]} forEach units _mymen;
{_x setSkill ["aimingShake",0.65]} forEach units _mymen;
{_x setSkill ["aimingSpeed",0.65]} forEach units _mymen;
{_x setSkill ["endurance",0.85]} forEach units _mymen;
{_x setSkill ["spotDistance",0.99]} forEach units _mymen;
{_x setSkill ["spotTime",0.85]} forEach units _mymen;
{_x setSkill ["courage",0.85]} forEach units _mymen;
{_x setSkill ["reloadSpeed",0.85]} forEach units _mymen;
{_x setSkill ["commanding",0.85]} forEach units _mymen;
{_x setSkill ["general",0.85]} forEach units _mymen;
};



if (isServer) then {

    waituntil {!isnil "bis_fnc_init"};
    [] spawn spawn_my_men; 	     

};	


bit rushed but should work let me know when i get home ill double check

Share this post


Link to post
Share on other sites

Thanks, I'm checking, but:

- What if I want to use custom east units? Where do I define the class?

- Why the east unit with 0% presence?

- I have a lot of groups in my scenario, each with individual buildings, I'd need a marker and a script for each group with this?

Thanks

Share this post


Link to post
Share on other sites

if i remember right the PlaceInBuilding.sqf places the units inside the closest building to them i think.

if so u could do the below = now this will create 10 units u can make it as many as u want they will spawn within a random position at any given diameter of a marker then let the

PlaceInBuilding.sqf place them in a random building then even u will not know where they will be.

the code

for "_i" from 0 to 10 do {//this part tells the server to create this script 10 times so ten men spawned change the 10 to how many you want

//Set up Paramaters
_My_group = createGroup east;//setting a group to create units from
_distances = [30,50,70,80,120,200,250] call BIS_fnc_selectRandom;//distance around the marker you want these units to spawn.
_Mkr_area = getMarkerPos "your marker";// the marker you want to spawn them in or around.
_my_units = ["CDF_Soldier_Strela","CDF_Soldier_AR","CDF_Soldier_GL","CDF_Soldier_Officer"] BIS_fnc_selectRandom;//your units chosen randomly - have as many as u want.

//lets start this crap
_enemy = _my_units createUnit [_Mkr_area, _My_group];//creating the unit
[_enemy] execVM "PlaceInBuilding.sqf";

};


use it like this " notice this will make them respawn but everytime 1 dies 10 more spawn you will have to ask the community how to fix that

my_men_respawn = {

   [] spawn spawn_my_men; 


};


spawn_my_men = {

for "_i" from 0 to 10 do {//this part tells the server to create this script 10 times so ten men spawned change the 10 to how many you want

	  //Set up Paramaters
_My_group = createGroup east;//setting a group to create units from
_distances = [30,50,70,80,120,200,250] call BIS_fnc_selectRandom;//distance around the marker you want these units to spawn.
_Mkr_area = getMarkerPos "your marker";// the marker you want to spawn them in or around.
_my_units = ["CDF_Soldier_Strela","CDF_Soldier_AR","CDF_Soldier_GL","CDF_Soldier_Officer"] BIS_fnc_selectRandom;//your units chosen randomly - have as many as u want.

         //lets start this crap
         _enemy = _my_units createUnit [_Mkr_area, _My_group];//creating the unit
	  [_enemy] execVM "PlaceInBuilding.sqf";
         _mymen addEventHandler["killed", { (_this select 0) spawn my_men_respawn; }];

	  // lets give em some skill

{_x setSkill ["aimingAccuracy",0.65]} forEach units _mymen;
{_x setSkill ["aimingShake",0.65]} forEach units _mymen;
{_x setSkill ["aimingSpeed",0.65]} forEach units _mymen;
{_x setSkill ["endurance",0.85]} forEach units _mymen;
{_x setSkill ["spotDistance",0.99]} forEach units _mymen;
{_x setSkill ["spotTime",0.85]} forEach units _mymen;
{_x setSkill ["courage",0.85]} forEach units _mymen;
{_x setSkill ["reloadSpeed",0.85]} forEach units _mymen;
{_x setSkill ["commanding",0.85]} forEach units _mymen;
{_x setSkill ["general",0.85]} forEach units _mymen;
};

};



if (isServer) then {

    waituntil {!isnil "bis_fnc_init"};
    [] spawn spawn_my_men; 	     

};			




now you dont need to use this im just giving you ideas.

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  

×