% chance AI drop Item (feature in DEV and solved)

  1. 7 years ago

    Hi,

    Is there a way I can add a EH to all AI , as I need a % chance they drop certain Items on the floor when killed.

    Thanks

  2. http://alivemod.com/wiki/index.php?title=Script_Snippets#Adding_Custom_Inits_to_Spawned_Units

  3. Hmmmm ok, but don't they already have a Killed EH i could tap into , or would i need to add another then ?

    Would this work ?

    Description.ext

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

    my_randomEH.sqf

    private "_this";
    _this = _this select 0;
     
    if ((side _this == EAST) and (!isPlayer _this)) then {
    
    _this addEventHandler [ "killed", { _this execVM "scripts\AIdeath.sqf"; }]; 
    
    
    };

    AIdeath.sqf

    *** run a random % change they drop a item when killed...
  4. highhead

    27 Apr 2016 Administrator

    Funny enough, I just implemented EXACTLY that yesterday in ALiVE!

    By chance (adjustable on module) AI drops INTEL (some topsecret, research, etc. files) when killed.

  5. highhead

    27 Apr 2016 Administrator
    Edited 7 years ago by highhead

    use this:

    class Extended_Killed_Eventhandlers
    {
    	class CAManBase
    	{
    		class WhatEverClassYouNameIt
    		{
    			killed = "_this call yourFunction";
    		};
    	};
    };

    whereas with _this you get [_killed,_killer] so your function needs to take into account _this select 0 and _this select 1

  6. Ahhhhh Perfect !!!!!

    Thanks !!!

  7. @highhead Funny enough, I just implemented EXACTLY that yesterday in ALiVE!

    By chance (adjustable on module) AI drops INTEL (some topsecret, research, etc. files) when killed.

    Hell yes!!!!!

  8. @highhead Funny enough, I just implemented EXACTLY that yesterday in ALiVE!

    By chance (adjustable on module) AI drops INTEL (some topsecret, research, etc. files) when killed.

    I just may be in love with you right now :P

 

or Sign Up to reply!