Jump to content
pcc

Random crew/cargo of vehicles spawned by spawn AI module

Recommended Posts

I want to replace the crew and fill cargo with random units from an array for vehicles spawned by spawn AI module.

Could it be done from the expression field?

 

Also, is it possible to adjust spawn AI module units' skill and merge all spawned units into one group?

Share this post


Link to post
Share on other sites

Yes, you can do that in expression field. You can spawn a code (or execVM an sqf) to change the crew/cargo of possible vehicle(s) spawned. I have no time to write a script, trying to guess what you need, but as you can see, the init field can manage 3 parameters:

[<group>,<module>,<groupData>]

For example:

1st parameter

 B Alpha 1-2, // group

2nd parameter

L Modules:4, // module for spawning AI

3rd parameter (array)

[bin\config.bin/CfgGroups/West/BLU_F/Armored/BUS_SPGSection_Scorcher,  // the config of the group used in bis_fnc_spawnGroup

45.8,   // "manpower" or value of the spawned AIs (useless here, but if you hack the crew/cargo this behavior has no more sense)

2.79,  //   no idea (something related to sector tactic?)

8,  // probably the number of units/vehicles spawned

["B_MBT_01_arty_F","B_crew_F","B_crew_F","B_crew_F","B_MBT_01_arty_F","B_crew_F","B_crew_F","B_crew_F"], // the classes of units/ vehicles spawned

"artillerySProp"] // probably a string of variable for the module (useless here)

 

So, _this select 0 is the spawned group and you can work with:

units (_this select 0) for the spawned units, and join (_this select 0) if you want to add some spawned units in this group.

(_this select 3 select 4) gives you the array of what is spawned (class names) Here two scorchers and their crew.

 

I don't want to work on that because I think these modules are good for sector tactics but not adequate for spawning/patrolling some infantry inside vehicles. The positions are not very randomized , the composition of the groups refers to existing groups in faction, the bis_fnc_spawnGroup fails to place safely vehicles in town.

 

 

  • Like 1

Share this post


Link to post
Share on other sites
On 6/25/2020 at 5:46 AM, pierremgi said:

Yes, you can do that in expression field. You can spawn a code (or execVM an sqf) to change the crew/cargo of possible vehicle(s) spawned. I have no time to write a script, trying to guess what you need, but as you can see, the init field can manage 3 parameters:

[<group>,<module>,<groupData>]

For example:

1st parameter

 B Alpha 1-2, // group

2nd parameter

L Modules:4, // module for spawning AI

3rd parameter (array)

[bin\config.bin/CfgGroups/West/BLU_F/Armored/BUS_SPGSection_Scorcher,  // the config of the group used in bis_fnc_spawnGroup

45.8,   // "manpower" or value of the spawned AIs (useless here, but if you hack the crew/cargo this behavior has no more sense)

2.79,  //   no idea (something related to sector tactic?)

8,  // probably the number of units/vehicles spawned

["B_MBT_01_arty_F","B_crew_F","B_crew_F","B_crew_F","B_MBT_01_arty_F","B_crew_F","B_crew_F","B_crew_F"], // the classes of units/ vehicles spawned

"artillerySProp"] // probably a string of variable for the module (useless here)

 

So, _this select 0 is the spawned group and you can work with:

units (_this select 0) for the spawned units, and join (_this select 0) if you want to add some spawned units in this group.

(_this select 3 select 4) gives you the array of what is spawned (class names) Here two scorchers and their crew.

 

I don't want to work on that because I think these modules are good for sector tactics but not adequate for spawning/patrolling some infantry inside vehicles. The positions are not very randomized , the composition of the groups refers to existing groups in faction, the bis_fnc_spawnGroup fails to place safely vehicles in town.

My mission is sector control, so it requires spawn AI module. 

I'm trying to fill vehicle's cargo with units picked randomly from an array.  I could only get it to work by editing the module files directly, but I read that's bad practice.

 

Another issue with the module is that it removes all AI weapon attachments, disables stamina, and lowers skill.  Can I get the module to read from customized initGroup.sqf instead of it's default in modules_f_heli\Misc\Functions\ModuleSpawnAISectorTactic? 

 

I've seen it done with warfare module in Arma 2, but not sure how it's done for this module.

Share this post


Link to post
Share on other sites

If you spawn new vehicles, only by the sector control, I mean no other script or even module for that, you can seek for the new vehicles (the spawned ones) and post-treat what you want then. A simple loop on server (initServer.sqf for example) can do that:

0 = [] spawn {

  private "_vehs";
  {_x setVariable ["treatedAsSpawned",TRUE] } forEach vehicles;
  while {TRUE} do {
    sleep 2;

    _vehs = vehicles select { !isNil {_x getVariable "treatedAsSpawned"} });
    {
      _x setVariable ["treatedAsSpawned",TRUE];
      <code for this vehicle /crew /group... >
    } forEach _vehs;

  };
};

 

The first set before the loop is just a filter to skip the edited vehicles. Then; the loop will treat only the new vehicles as you "mark" by variable the vehicles on which you apply a code. The vehicle is sufficient for finding its group /units/ crew... You can even extra spawn your own units/vehicles on this "event". (the eventHandler detecting new vehicles/units doesn't exist). And no need to "on each frame" that. The loop is "cooled down" with a 2 sec. sleep.

 

To be exhaustive, if you spawn some vehicles which don't need to be post-treated, just apply them the variable "treatedAsSpawned" just after they are created. No or very, very few chances to enter in the process.
   

  • 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

×