Jump to content
Blitzen88

Need Help Tweaking AI Skill Script

Recommended Posts

I have modified my description.ext file to add an init eventhandler to the CAManBase:

class Extended_Init_Eventhandlers {
    class CAManBase {
        init = "_this execVM 'Scripts\AISkillSettings.sqf';";
    };
};

That code snippet executes my AI skill script whenever the unit is spawned.  The relevant part of the script is:

 

{
_x AllowFleeing 0;
_x AllowCrewInImmobile True;
_x setSkill ["aimingAccuracy", 0.5 + (random 0.25)];
_x setSkill ["aimingShake", 0.25 + (random 0.25)];
_x setSkill ["aimingSpeed", 0.75 + (random 0.25)];
_x setSkill ["commanding", 1 + (random 0.15)];
_x setSkill ["courage", 1 + (random 0.15)];
_x setSkill ["general", 0.75 + (random 0.25)];
_x setSkill ["reloadSpeed", 0.8 + (random 0.05)];
_x setSkill ["spotDistance", 1 + (random 0.20)];
_x setSkill ["spotTime", 0.75+ (random 0.25)];
} forEach allUnits;

Is there anyway to change this script from applying to all units to just applying to the individual unit that has spawned?  I have tried "this" and "_this" instead of "foreach allunits" but it I always get errors when I mess around with it.

 

Thanks

Share this post


Link to post
Share on other sites

I'm not familiar with Extended_Init_Eventhandlers at all.

Give this a try:

 

class Extended_Init_Eventhandlers {
    class CAManBase {
        init = "(_this select 0) execVM 'Scripts\AISkillSettings.sqf';";
    };
};

 


_this AllowFleeing 0;
_this AllowCrewInImmobile True;
_this setSkill ["aimingAccuracy", 0.5 + (random 0.25)];
_this setSkill ["aimingShake", 0.25 + (random 0.25)];
_this setSkill ["aimingSpeed", 0.75 + (random 0.25)];
_this setSkill ["commanding", 1 + (random 0.15)];
_this setSkill ["courage", 1 + (random 0.15)];
_this setSkill ["general", 0.75 + (random 0.25)];
_this setSkill ["reloadSpeed", 0.8 + (random 0.05)];
_this setSkill ["spotDistance", 1 + (random 0.20)];
_this setSkill ["spotTime", 0.75+ (random 0.25)];

 

Share this post


Link to post
Share on other sites

Give this a try:

Not tested.

 

Spoiler

class Extended_Init_Eventhandlers {
    class CAManBase {
        init = "_this execVM 'Scripts\AISkillSettings.sqf';";
    };
};

params ["_unit"];

_unit AllowFleeing 0;
_unit AllowCrewInImmobile True;
_unit setSkill ["aimingAccuracy", 0.5 + (random 0.25)];
_unit setSkill ["aimingShake", 0.25 + (random 0.25)];
_unit setSkill ["aimingSpeed", 0.75 + (random 0.25)];
_unit setSkill ["commanding", 1 + (random 0.15)];
_unit setSkill ["courage", 1 + (random 0.15)];
_unit setSkill ["general", 0.75 + (random 0.25)];
_unit setSkill ["reloadSpeed", 0.8 + (random 0.05)];
_unit setSkill ["spotDistance", 1 + (random 0.20)];
_unit setSkill ["spotTime", 0.75+ (random 0.25)];

systemChat format ["%1 : 'I haz skillz!'.", name _unit];

 

 

After a quick Google, I am starting to doubt that Extended_Init_Eventhandlers can be used in description.ext.
I only saw it used inside addons. I could be very very wrong though!

 

  • Like 2

Share this post


Link to post
Share on other sites
On 8/12/2019 at 2:45 PM, Maff said:

Give this a try:

Not tested.

 

  Hide contents


class Extended_Init_Eventhandlers {
    class CAManBase {
        init = "_this execVM 'Scripts\AISkillSettings.sqf';";
    };
};


params ["_unit"];

_unit AllowFleeing 0;
_unit AllowCrewInImmobile True;
_unit setSkill ["aimingAccuracy", 0.5 + (random 0.25)];
_unit setSkill ["aimingShake", 0.25 + (random 0.25)];
_unit setSkill ["aimingSpeed", 0.75 + (random 0.25)];
_unit setSkill ["commanding", 1 + (random 0.15)];
_unit setSkill ["courage", 1 + (random 0.15)];
_unit setSkill ["general", 0.75 + (random 0.25)];
_unit setSkill ["reloadSpeed", 0.8 + (random 0.05)];
_unit setSkill ["spotDistance", 1 + (random 0.20)];
_unit setSkill ["spotTime", 0.75+ (random 0.25)];

systemChat format ["%1 : 'I haz skillz!'.", name _unit];

 

 

After a quick Google, I am starting to doubt that Extended_Init_Eventhandlers can be used in description.ext.
I only saw it used inside addons. I could be very very wrong though!

 

That seems to work.  Thank you!

  • Like 1

Share this post


Link to post
Share on other sites
10 minutes ago, Blitzen88 said:

That seems to work.  Thank you!

 

Excellent!

  • 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

×