Issues with Custom Inits

  1. 9 years ago

    I've followed the code here .

    I've got

    class Extended_Init_EventHandlers {
    	class Man {
    		init = "_obj call (compile preprocessFileLineNumbers 'ai_init.sqf')";
    	};
    };

    in my description.ext

    But the init only seems to apply to civilian units, not CSAT forces. Is there any reason for this? Or is there another way to do custom unit inits.

  2. If you don't mind sharing it, what is the code that is being executed inside ai_init.sqf?
    It should apply to all AI unless you made a check inside the script.

  3. Sure.

    INS_fnc_initAIUnit = {
    	private ["_unit"];
    	_unit = _this;
    	
    	_unit setSkill ['aimingAccuracy', 0.2];
    	_unit setSkill ['aimingShake', 0.5];
    	_unit setSkill ['aimingSpeed', 0.2];
    	_unit setSkill ['spotDistance', 0.4];
    	_unit setSkill ['spotTime', 0.4];
    	_unit setSkill ['courage', 0.5];
    	_unit setSkill ['reloadSpeed', 0.5];
    	_unit setSkill ['commanding', 0.5];
    	_unit setSkill ['general', 0.5];
    
    	_unit addEventHandler ["Killed", INS_fnc_onDeathListener];
    };
    
    INS_fnc_onDeathListener = {
    	["unit died", true, true] call dl_fnc_hintMP;
    	_tempRandom = random 100;
    
    	if (_tempRandom > (100 - 100) || true) then {
    		_unit = _this select 0;
    		_pos = position _unit;
    		_intel = createVehicle ["Land_Suitcase_F", _pos, [], 0, "CAN_COLLIDE"];
    		_intel setVariable ["INTEL_STRENGTH", (rank _unit) call INS_fnc_getRankModifier];
    
    		[_intel] spawn {
    			// do stuff
    		};	
    	};
    };
    
    _obj call INS_fnc_initAIUnit;

    The only time the ["unit died", true, true] call dl_fnc_hintMP; fires is if it's a civ.

  4. Weird, see no reason for it to exclude other units. Hopefully a dev or Savage can explain it more.

  5. Anyone else have any ideas?

  6. Edited 9 years ago by SpyderBlack723

    No fix but I can say that I reproduced this on a very basic level. Not sure what the issue is because I have done this before if my memory serves me right. From my testing it only inits on CIVS and not on any military unit (BLU,OPF)

  7. might actually be a bug with CBA, then. who knows...

  8. Edited 9 years ago by SpyderBlack723

    I think something changed/got bugged. All of mine that I used in past missions are now broken.

  9. highhead

    18 Apr 2015 Administrator

    It has never worked this way :)

    class Extended_Init_EventHandlers {
    class Man {
    init = "_obj call (compile preprocessFileLineNumbers 'my_script.sqf')";
    };
    };

    it needs to be

    init = _this call (compile....) -------> not _obj

    need to update wiki again!

  10. Friznit

    18 Apr 2015 Administrator

    _obj is just variable that needs to be defined, as per the the script example right below that line in the wiki.

  11. Someone else on the CBA bi forums page is having problems with it too, Says it doesn't work on RC6 but does on RC4.

  12. @highhead It has never worked this way :)

    class Extended_Init_EventHandlers {
    class Man {
    init = "_obj call (compile preprocessFileLineNumbers 'my_script.sqf')";
    };
    };

    it needs to be

    init = _this call (compile....) -------> not _obj

    need to update wiki again!

    I got that from the wiki... and it works, just not on OPFOR/BLUFOR.

  13. @SpyderBlack723 Someone else on the CBA bi forums page is having problems with it too, Says it doesn't work on RC6 but does on RC4.

    can you link me the post so I can keep myself updated there?

  14. @tills13 can you link me the post so I can keep myself updated there?

    http://forums.bistudio.com/showthread.php?178224-CBA-Community-Base-Addons-ARMA-3/page30

  15. ^ thanks @SpyderBlack723

  16. Edited 9 years ago by SpyderBlack723

    Issue was apparently a bug in CBA RC4 and was fixed in RC6 hence why it doesn't work now.

    This parts for Friz/anyone else who edits the wiki
    Fix according to KillSwitch: https://dev.withsix.com/issues/76194

    (Correct way to call it in description.ext - Appears to be fixed already)

    class Extended_Init_EventHandlers
    {
      class Man
      {
        my_init = "_this call (compile preprocessFileLineNumbers 'my_script.sqf')";
      };
    };

    (This is a corrected version of the example my_script.sqf)

    private "_obj";
    
    _obj = _this select 0;
    
    if ((side _obj == west) and (!isPlayer _obj)) then
    {
      removeAllWeapons _obj;
      removeGoggles _obj;removeHeadgear _obj;removeVest _obj;removeUniform _obj;removeAllAssignedItems _obj;removeBackpack _obj;
      _obj addHeadgear 'Helmet_ACU';_obj addUniform 'Uniform_ACU';_obj addVest 'Vest_ACU';_obj addBackPack 'ACU_Backpack';
      { _obj addItemToBackpack "rhs_mag_30Rnd_556x45_M855A1_Stanag"; } forEach [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,18, 19, 20, 21];
      { _obj addItemToBackpack "rhs_mag_m67"; } forEach [1, 2, 3, 4];
      { _obj addItemToBackpack "SmokeShell"; } forEach [1, 2, 3, 4];
      { _obj addItem "FirstAidKit"; } forEach [1, 2, 3, 4, 5];
      _obj addweapon 'rhs_m4_grip_acog';_obj addPrimaryWeaponItem 'rhsusf_acc_ACOG';_obj linkItem "ItemMap";
    };
  17. gah use code tags >.<

    so the only change is that I need to use _this... and my_init?

    seems weird.

  18. Edited 9 years ago by SpyderBlack723

    You need to put this at the top of the sqf that is being triggered

       private "_obj";
    
        _obj = _this select 0;

    So yours would be called using

    class Extended_Init_EventHandlers {
    	class Man {
    		init = "_this call (compile preprocessFileLineNumbers 'ai_init.sqf')";
    	};
    };

    And the ai_unit.sqf would be

    INS_fnc_initAIUnit = {
    	private "_unit";
    	_unit = _this;
    	
    	_unit setSkill ['aimingAccuracy', 0.2];
    	_unit setSkill ['aimingShake', 0.5];
    	_unit setSkill ['aimingSpeed', 0.2];
    	_unit setSkill ['spotDistance', 0.4];
    	_unit setSkill ['spotTime', 0.4];
    	_unit setSkill ['courage', 0.5];
    	_unit setSkill ['reloadSpeed', 0.5];
    	_unit setSkill ['commanding', 0.5];
    	_unit setSkill ['general', 0.5];
    
    	_unit addEventHandler ["Killed", INS_fnc_onDeathListener];
    };
    
    INS_fnc_onDeathListener = {
    	["unit died", true, true] call dl_fnc_hintMP;
    	_tempRandom = random 100;
    
    	if (_tempRandom > (100 - 100) || true) then {
    		_unit = _this select 0;
    		_pos = position _unit;
    		_intel = createVehicle ["Land_Suitcase_F", _pos, [], 0, "CAN_COLLIDE"];
    		_intel setVariable ["INTEL_STRENGTH", (rank _unit) call INS_fnc_getRankModifier];
    
    		[_intel] spawn {
    			// do stuff
    		};	
    	};
    };
    
    _obj call INS_fnc_initAIUnit;
  19. yup - I got it now, thank you.

    Finally, I can actually make progress on my damn mission.

  20. @SpyderBlack723 You need to put this at the top of the sqf that is being triggered

    ...

    I think you mean

    my_init = "[b]_this[/b] call (compile preprocessFileLineNumbers 'ai_init.sqf')";

    but yeah, thanks

 

or Sign Up to reply!