Jump to content
Casio91Fin

Spawn unit in each vehicle?

Recommended Posts

How do I get each vehicle's AI so it's full? Yes, I get a full group in one vehicle, but not 3 at the same time. 

Are there any suggestions on how I could be done?

 

script which i am using

 

_Pos_1 = SP_Mission_Pos;

 

_Pos_Spawn = [[[_Pos_1, 25 + random 250]],["water"]] call BIS_fnc_randomPos;

 

_Group = createGroup SP_Missions_Enemy_Side;

_Group_Crew = createGroup SP_Missions_Enemy_Side;

_Light_Vehicle = selectRandom SP_Patrols_Vehicle_Array;

_Spawned_Light_Vehicle = for "_x" from 1 to 3 do {_Light_Vehicle createVehicle _Pos_Spawn;};

 

_Seats_Number = [_Light_Vehicle,true] call BIS_fnc_crewCount;   

_Seats_Number_Crew = [_Light_Vehicle,false] call BIS_fnc_crewCount;

 

for "_x" from 1 to _Seats_Number_Crew do 

{

 

    _unit_Crew = _Group_Crew createunit [SP_Civilian_Array select floor(random count SP_Civilian_Array), _Pos_Spawn, [], 0, "None"];

    [_unit_Crew] JoinSilent _Group_Crew;

    _unit_Crew moveInAny _Spawned_Light_Vehicle;

    (leader _Group_Crew) setSkill 1;

    _Spawned_Light_Vehicle forceFollowRoad true;

    _Spawned_Light_Vehicle setConvoySeparation 30;

 

    removeAllWeapons _unit_Crew;

    removeAllItems _unit_Crew;

    removeAllAssignedItems _unit_Crew;

    removeVest _unit_Crew;

    removeBackpack _unit_Crew;

    removeGoggles _unit_Crew;

 

    _Headgear = selectRandom SP_Civilian_Headgear_Array;

    _Goggles = selectRandom SP_Civilian_Goggles_Array;

    _Vests = selectRandom SP_Civilian_Vests_Array;

    _Backpacks = selectRandom SP_Civilian_Backpacks_Array;

 

    _unit_Crew addHeadgear _Headgear;

    //_unit_Crew addGoggles _Goggles;

 

    //  add possibility 

    if (floor (random 30) < 6) then {_unit_Crew addGoggles _Goggles;};

    if (floor (random 30) < 5) then {_unit_Crew addVest _Vests;};

    if (floor (random 30) < 15) then {_unit_Crew addBackpack _Backpacks;};

 

    _Primary_Weapon = selectRandom SP_Civilian_primaryWeapon_array;

    _secondaryWeapon = selectRandom SP_Civilian_secondaryWeapon_array;

    _handgunWeapon = selectRandom SP_Civilian_HandGunWeapon_array;

 

    _Primary_Weapon_Magazines = getArray (configFile / "CfgWeapons" / _Primary_Weapon / "magazines");

    _Spawn_Primary_Weapon_magazines = selectRandom _Primary_Weapon_Magazines;

 

    _unit_Crew addWeapon _Primary_Weapon;

 

    for "_i" from 1 to 3 do {_unit_Crew addItemToUniform _Spawn_Primary_Weapon_magazines;};

    for "_i" from 1 to 1 do {_unit_Crew addItemToUniform "FirstAidKit";};

    for "_i" from 1 to 1 do {_unit_Crew addItemToUniform "LIB_Shg24";};

 

    for "_i" from 1 to 2 do {_unit_Crew addItemToVest _Spawn_Primary_Weapon_magazines;}; 

    for "_i" from 1 to 2 do {_unit_Crew addItemToBackpack _Spawn_Primary_Weapon_magazines;};

 

    _unit_Crew selectweapon primaryWeapon _unit_Crew;

    reload _unit_Crew;

 

    //  add possibility 

    if (floor (random 10) < 4) then {_unit_Crew linkItem "ItemMap";};

    if (floor (random 10) < 4) then {_unit_Crew linkItem "LIB_GER_ItemCompass";};

    if (floor (random 10) < 4) then {_unit_Crew linkItem "LIB_GER_ItemWatch";};

};

 

_Seats_Number_Cargo = _Seats_Number - _Seats_Number_Crew;

 

for "_x" from 1 to _Seats_Number_Cargo do 

{

 

    _unit = _Group createunit [SP_Civilian_Array select floor(random count SP_Civilian_Array),_Pos_Spawn,[],0,"None"];

    [_unit] JoinSilent _Group;

    _unit moveInAny _Spawned_Light_Vehicle;

    (leader _Group) setSkill 1;

 

    removeAllWeapons _Unit;

    removeAllItems _Unit;

    removeAllAssignedItems _Unit;

    removeVest _Unit;

    removeBackpack _Unit;

    removeGoggles _Unit;

 

    _Headgear = selectRandom SP_Civilian_Headgear_Array;

    _Goggles = selectRandom SP_Civilian_Goggles_Array;

    _Vests = selectRandom SP_Civilian_Vests_Array;

    _Backpacks = selectRandom SP_Civilian_Backpacks_Array;

 

    _Unit addHeadgear _Headgear;

    //_Unit addGoggles _Goggles;

 

    //  add possibility 

    if (floor (random 30) < 6) then {_Unit addGoggles _Goggles;};

    if (floor (random 30) < 5) then {_Unit addVest _Vests;};

    if (floor (random 30) < 15) then {_Unit addBackpack _Backpacks;};

 

    _Primary_Weapon = selectRandom SP_Civilian_primaryWeapon_array;

    _secondaryWeapon = selectRandom SP_Civilian_secondaryWeapon_array;

    _handgunWeapon = selectRandom SP_Civilian_HandGunWeapon_array;

 

    _Primary_Weapon_Magazines = getArray (configFile / "CfgWeapons" / _Primary_Weapon / "magazines");

    _Spawn_Primary_Weapon_magazines = selectRandom _Primary_Weapon_Magazines;

 

    _Unit addWeapon _Primary_Weapon;

 

    for "_i" from 1 to 3 do {_Unit addItemToUniform _Spawn_Primary_Weapon_magazines;};

    for "_i" from 1 to 1 do {_Unit addItemToUniform "FirstAidKit";};

    for "_i" from 1 to 1 do {_Unit addItemToUniform "LIB_Shg24";};

 

    for "_i" from 1 to 2 do {_Unit addItemToVest _Spawn_Primary_Weapon_magazines;}; 

    for "_i" from 1 to 2 do {_Unit addItemToBackpack _Spawn_Primary_Weapon_magazines;};

 

    _Unit selectweapon primaryWeapon _Unit;

    reload _Unit;

 

    //  add possibility 

    if (floor (random 10) < 4) then {_Unit linkItem "ItemMap";};

    if (floor (random 10) < 4) then {_Unit linkItem "LIB_GER_ItemCompass";};

    if (floor (random 10) < 4) then {_Unit linkItem "LIB_GER_ItemWatch";};

};

 

[_Group_Crew, _Pos_1, 5000] call BIS_fnc_taskPatrol;

[_Group, _Pos_1, 5000] call BIS_fnc_taskPatrol;

Share this post


Link to post
Share on other sites

not sure if I get the question but there's different commands when it comes to crew 

 

Create crew for empty vehicle:

https://community.bistudio.com/wiki/createVehicleCrew

 

Create vehicle with crew:

https://community.bistudio.com/wiki/BIS_fnc_spawnVehicle

 

Get vehicle's empty positions:

(Useful for manually creating each crew member)

https://community.bistudio.com/wiki/emptyPositions

 

 

hope that helps

Share this post


Link to post
Share on other sites

i don't use the top two because array creates units for vehicles.

emptyPositions it was not good thing, because they was outside vehicles

 

Share this post


Link to post
Share on other sites

Maybe, just loop 3 times the script where you create the vehicles and use alternative synthax of createVehicle command.

 

Finally add some distance between spawned vehicles to avoid collisions.

 

 _Pos_1 = SP_Mission_Pos;

 _Pos_Spawn = [[[_Pos_1, 25 + random 250]],["water"]] call BIS_fnc_randomPos;

_Light_Vehicle = selectRandom SP_Patrols_Vehicle_Array; // This line can be inside the "_i" loop to get random vehicles for the groups **


for "_i" from 1 to 3 do {

    // ** here

    _Spawned_Light_Vehicle = createVehicle [_Light_Vehicle, _Pos_Spawn, [], 0, "NONE"];

    _Seats_Number = [_Light_Vehicle,true] call BIS_fnc_crewCount;   

    _Seats_Number_Crew = [_Light_Vehicle,false] call BIS_fnc_crewCount;


    _Group = createGroup SP_Missions_Enemy_Side;

_Group_Crew = createGroup SP_Missions_Enemy_Side;


    for "_x" from 1 to _Seats_Number_Crew do 

    {

        _unit_Crew = _Group_Crew createunit [SP_Civilian_Array select floor(random count SP_Civilian_Array), _Pos_Spawn, [], 0, "None"];

        [_unit_Crew] JoinSilent _Group_Crew;

        _unit_Crew moveInAny _Spawned_Light_Vehicle;

        (leader _Group_Crew) setSkill 1;

        _Spawned_Light_Vehicle forceFollowRoad true;

        _Spawned_Light_Vehicle setConvoySeparation 30;

     

        removeAllWeapons _unit_Crew;

        removeAllItems _unit_Crew;

        removeAllAssignedItems _unit_Crew;

        removeVest _unit_Crew;

        removeBackpack _unit_Crew;

        removeGoggles _unit_Crew;

     

        _Headgear = selectRandom SP_Civilian_Headgear_Array;

        _Goggles = selectRandom SP_Civilian_Goggles_Array;

        _Vests = selectRandom SP_Civilian_Vests_Array;

        _Backpacks = selectRandom SP_Civilian_Backpacks_Array;

     

        _unit_Crew addHeadgear _Headgear;

        //_unit_Crew addGoggles _Goggles;

     

        //  add possibility 

        if (floor (random 30) < 6) then {_unit_Crew addGoggles _Goggles;};

        if (floor (random 30) < 5) then {_unit_Crew addVest _Vests;};

        if (floor (random 30) < 15) then {_unit_Crew addBackpack _Backpacks;};

     

        _Primary_Weapon = selectRandom SP_Civilian_primaryWeapon_array;

        _secondaryWeapon = selectRandom SP_Civilian_secondaryWeapon_array;

        _handgunWeapon = selectRandom SP_Civilian_HandGunWeapon_array;

     

        _Primary_Weapon_Magazines = getArray (configFile / "CfgWeapons" / _Primary_Weapon / "magazines");

        _Spawn_Primary_Weapon_magazines = selectRandom _Primary_Weapon_Magazines;

     

        _unit_Crew addWeapon _Primary_Weapon;

     

        for "_i" from 1 to 3 do {_unit_Crew addItemToUniform _Spawn_Primary_Weapon_magazines;};

        for "_i" from 1 to 1 do {_unit_Crew addItemToUniform "FirstAidKit";};

        for "_i" from 1 to 1 do {_unit_Crew addItemToUniform "LIB_Shg24";};

     

        for "_i" from 1 to 2 do {_unit_Crew addItemToVest _Spawn_Primary_Weapon_magazines;}; 

        for "_i" from 1 to 2 do {_unit_Crew addItemToBackpack _Spawn_Primary_Weapon_magazines;};

     

        _unit_Crew selectweapon primaryWeapon _unit_Crew;

        reload _unit_Crew;

     

        //  add possibility 

        if (floor (random 10) < 4) then {_unit_Crew linkItem "ItemMap";};

        if (floor (random 10) < 4) then {_unit_Crew linkItem "LIB_GER_ItemCompass";};

        if (floor (random 10) < 4) then {_unit_Crew linkItem "LIB_GER_ItemWatch";};

    };

     

    _Seats_Number_Cargo = _Seats_Number - _Seats_Number_Crew;

     

    for "_x" from 1 to _Seats_Number_Cargo do 

    {

     

        _unit = _Group createunit [SP_Civilian_Array select floor(random count SP_Civilian_Array),_Pos_Spawn,[],0,"None"];

        [_unit] JoinSilent _Group;

        _unit moveInAny _Spawned_Light_Vehicle;

        (leader _Group) setSkill 1;

     

        removeAllWeapons _Unit;

        removeAllItems _Unit;

        removeAllAssignedItems _Unit;

        removeVest _Unit;

        removeBackpack _Unit;

        removeGoggles _Unit;

     

        _Headgear = selectRandom SP_Civilian_Headgear_Array;

        _Goggles = selectRandom SP_Civilian_Goggles_Array;

        _Vests = selectRandom SP_Civilian_Vests_Array;

        _Backpacks = selectRandom SP_Civilian_Backpacks_Array;

     

        _Unit addHeadgear _Headgear;

        //_Unit addGoggles _Goggles;

     

        //  add possibility 

        if (floor (random 30) < 6) then {_Unit addGoggles _Goggles;};

        if (floor (random 30) < 5) then {_Unit addVest _Vests;};

        if (floor (random 30) < 15) then {_Unit addBackpack _Backpacks;};

     

        _Primary_Weapon = selectRandom SP_Civilian_primaryWeapon_array;

        _secondaryWeapon = selectRandom SP_Civilian_secondaryWeapon_array;

        _handgunWeapon = selectRandom SP_Civilian_HandGunWeapon_array;

     

        _Primary_Weapon_Magazines = getArray (configFile / "CfgWeapons" / _Primary_Weapon / "magazines");

        _Spawn_Primary_Weapon_magazines = selectRandom _Primary_Weapon_Magazines;

     

        _Unit addWeapon _Primary_Weapon;

     

        for "_i" from 1 to 3 do {_Unit addItemToUniform _Spawn_Primary_Weapon_magazines;};

        for "_i" from 1 to 1 do {_Unit addItemToUniform "FirstAidKit";};

        for "_i" from 1 to 1 do {_Unit addItemToUniform "LIB_Shg24";};

     

        for "_i" from 1 to 2 do {_Unit addItemToVest _Spawn_Primary_Weapon_magazines;}; 

        for "_i" from 1 to 2 do {_Unit addItemToBackpack _Spawn_Primary_Weapon_magazines;};

     

        _Unit selectweapon primaryWeapon _Unit;

        reload _Unit;

     

        //  add possibility 

        if (floor (random 10) < 4) then {_Unit linkItem "ItemMap";};

        if (floor (random 10) < 4) then {_Unit linkItem "LIB_GER_ItemCompass";};

        if (floor (random 10) < 4) then {_Unit linkItem "LIB_GER_ItemWatch";};

    };

     

    [_Group_Crew, _Pos_1, 5000] call BIS_fnc_taskPatrol;

    [_Group, _Pos_1, 5000] call BIS_fnc_taskPatrol;

    _Pos_Spawn = [(_Pos_Spawn select 0) + 5, _Pos_Spawn select 1, 0]; // Make space between spawned vehicles to avoid BOOM! ^^

};

Hope this help 😉

  • 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

×