Adding items to AI on death

Buttface

OpenDayZ Rockstar!
Hi there, I'm currently looking for a way to add items to an AI unit when it dies, and only if the killer is a player. So far, I have a "Killed" eventhandler that should be adding items to an AI unit's inventory when it dies.

The eventhandler:

Code:
_unit addEventHandler ["Killed",{_this call fnc_banditAIKilled;}];                // Update current AI count, add additional loot.

The script called by the eventhandler:

Code:
private["_weapongrade","_unit","_killer"];
_unit = _this select 0;
_killer = _this select 1;
 
DZAI_numAIUnits = (DZAI_numAIUnits - 1);
 
if (DZAI_extdebug) then {diag_log format["DZAI Extended Debug: AI killed. %1 AI units left.",DZAI_numAIUnits];};
 
if (!isPlayer _killer) exitWith {};                                // Generate additional loot only if killer is a player
_weapongrade = call fnc_selectRandomGrade;   
[_unit, _weapongrade] call fnc_unitSelectPistol;                // Assign sidearm
[_unit, _weapongrade] call fnc_unitConsumables;                // Generate loot: food, medical, misc, skin
[_unit, _weapongrade] call fnc_unitTools;                        // Generate tools and gadget

The three scripts called after the isPlayer check are supposed to add items to the dead AI's inventory, but the end result is that nothing is added. My best guess is that items can't be added to a dead unit's inventory, but this is also how meat is added to a dead animal's corpse after gutting it.
 
Back
Top