Jump to content
  • 0

Problem with WAI dynamic crates


JasonTM

Question

In WAI, when the AI spawn it chooses a random array from ai_wep_random and chooses a random gun from the selected array. It does this for each AI that spawns. See below from spawn_group.

if(_gun == "random") 	exitWith { _aiweapon = ai_wep_random call BIS_fnc_selectRandom; };

However, since only one crate spawns it will choose a random array from ai_wep_random and spawn random weapons from within that one array. So, you do not get a completely random gun selection in the crate. See below from dynamic_crate.

_weapons_array	= ai_wep_random call BIS_fnc_selectRandom;
if(_num_weapons > 0) then {

	_num_weapons = (ceil((_num_weapons) / 2) + floor(random (_num_weapons / 2)));

	for "_i" from 1 to _num_weapons do {
		_weapon = _weapons_array call BIS_fnc_selectRandom;
		_ammo = _weapon call find_suitable_ammunition;
		_crate addWeaponCargoGlobal [_weapon,1];
		_crate addMagazineCargoGlobal [_ammo, (1 + floor(random 5))];
	};

Is there a way to make this completely random?

In 1051 my solution was to create an array called crate_weapons and throw all of the guns I wanted in that array and change...

_weapons_array	= ai_wep_random call BIS_fnc_selectRandom;

to...

_weapons_array	= crate_weapons;

Then I would get a random gun selection. Should I just do it this way or is there a better solution?

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

That is what I did in 1051. I was just curious if the code could be altered in dynamic_crate to avoid the redundancy of having another weapon array in the configs. I added the Overwatch weapons to the configs so the arrays are pretty long.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...