Jump to content
READTHESCROLL

Apply onKilled.sqf to AI spawned from a module?

Recommended Posts

Noob mission editor here.. Is there a way to add an onKilled.sqf to AI spawned from a module? How would I got about doing something like that?

Share this post


Link to post
Share on other sites

What module are you talking about? I'd need to check the function behind the module to see what parameter selects the AI.

Share this post


Link to post
Share on other sites

Thanks for the reply R3vo. I'm using Ryan's Zombies and Demons mod and placing modules down for the spawners. If possible I'd like to add an onZombieKilled.sqf that drops a piece of gear or a couple magazines from an array when the zombie is killed. 

Share this post


Link to post
Share on other sites

Appreciate the replies. I think I might be able to overcome this by having a script that runs whenever a member of EAST is killed. I have my Zs set to Opfor so that was one idea I had. The other thing I'm thinking about is if I can call a variable from inside the zombie mod to apply a script to. The variable for zombies spawned by the mod is "_zombie". Then use a killed event handler to run the onKilled.sqf when it is killed. 

Share this post


Link to post
Share on other sites

Ignore the other people.

 

Here's how you do it:

 

You mentioned that the units were made from a module.  Your best bet is to just loop through all of the units and then try to specify which kind of one you're looking for.

{
  if (side _x == independent  && {whatever else you need to help figure out the unit(s) will go here I guess}) then
  {
    _x addMPEventHandler
    {
      "MPKilled",
      "onKilled.sqf"
    };
  };
} forEach allUnits;

As you can see, it's really really simple.  If you're confused about anything, just look it up in the BIKI thing and you'll be fine if you sit down and read a few things here and there.

 

If you knew more about how this stuff works, you could try to get into the actual module's scripting itself so that you can try to look for an opportunity to reference what you're looking for while it's still creating the units in the first place... but that's tricky and time consuming and really circumstancial.

Share this post


Link to post
Share on other sites

Ignore the other people.

Here's how you do it:

You mentioned that the units were made from a module. Your best bet is to just loop through all of the units and then try to specify which kind of one you're looking for.

{  if (side _x == independent  && {whatever else you need to help figure out the unit(s) will go here I guess}) then  {    _x addMPEventHandler    {	  "MPKilled",	  "onKilled.sqf"    };  };} forEach allUnits;
As you can see, it's really really simple. If you're confused about anything, just look it up in the BIKI thing and you'll be fine if you sit down and read a few things here and there.

If you knew more about how this stuff works, you could try to get into the actual module's scripting itself so that you can try to look for an opportunity to reference what you're looking for while it's still creating the units in the first place... but that's tricky and time consuming and really circumstancial.

Instead of finding it's side, you could also do:

TAG_EH_ZedInit = {
    {
        _ZedVar = _x getVariable "TAG_ZedEH_Killed";
        if ((isNil "_ZedVar") && (typeOf _x == "ZombieClassname")) then
        {
            _x addMPEventHandler ["MPKilled", "onKilledZed.sqf"];
            _x setVariable ["TAG_ZedEH_Killed", true];
        };
    } forEach allUnits;
    [] call TAG_EH_ZedInit;
};
I would advise adding a loop to your script for future reference. :)

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

×