Jump to content
Ivanhereisvodka

AI to spawn with random class

Recommended Posts

Hi, 

I'm currently making a mission that is a deathmatch, in this mission I have in my onPlayerRespawn.sqf the following;

player setunitloadout selectRandom ["rhsusf_usmc_marpat_d_grenadier", "rhsusf_army_ucp_arb_marksman", "rhsgref_nat_machinegunner", "CUP_I_UN_CDF_Soldier_SL_DST", "rhs_vdv_des_rifleman_asval"];

This works fine for players, they respawn with a random class from the list, but I have been unable to find a way to apply this to AI, 

I'm sorry if I missed something in the forum but I have looked for quite a while and found nothing.

Thanks for any help.

Share this post


Link to post
Share on other sites

I see you have a CUP classname which relies on CBA.

This should run "random setUnitLoadout" on units already present in the mission AND created during the mission.
    
I have not tested this, but I have used CBA_fnc_addClassEventHandler before to customise units in a mission.


The only issue I can think of is if you have civilians or other units that you don't want to be given random loadouts in your mission.
That can be worked out though.
 

//    init.sqf

[
    "CAManBase",
    "init",
    {
        (_this select 0) setunitloadout selectRandom ["rhsusf_usmc_marpat_d_grenadier", "rhsusf_army_ucp_arb_marksman", "rhsgref_nat_machinegunner", "CUP_I_UN_CDF_Soldier_SL_DST", "rhs_vdv_des_rifleman_asval"];
    },
	true,
	[],
	true 
] call CBA_fnc_addClassEventHandler;

 

Edited by Maff
_this error?
  • 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

×