Custom Event upon actor death

Hi everyone,

So I'm trying to get a Common Event to play when an actor is knocked out, which is working fine... Except for the fact that event plays whenever an enemy dies as well, which mucks up what I'm trying to do.

I'm using the current JS on the death state, but it's not filtering out enemy deaths, and my knowledge of JS is limited at best so I can't figure out how to fix it. Do I need to use a different term to check the target receiving the death state or something like that?

<JS On Add State>
if(target.isActor)($gameTemp.reserveCommonEvent(4))
</JS On Add State>

Any help would be greatly appreciated.
Shouldn't it be

if(target.isActor())

?
werzaque is correct.

Your condition currently is checking for the *presence* of an "isActor" function on the target, and enemies have that function too otherwise they'd have no way of knowing whether they're actors or not. So it always returns true. You need the brackets to actually call the function and check its return value instead of whether the function exists.
Your condition currently is checking for the *presence* of an "isActor" function on the target, and enemies have that function too otherwise they'd have no way of knowing whether they're actors or not. So it always returns true. You need the brackets to actually call the function and check its return value instead of whether the function exists.
Okay, so I can see the problem, so I need to change the is "isActor" function to one that checks if the target is a party member. Are there any other functions that do that? I have 12 party members if that's any help with anything.
For starters:

<JS On Add State>
if(target.isActor)($gameTemp.reserveCommonEvent(4))
</JS On Add State>

Needs to be:

<JS On Add State>
if(target.isActor())($gameTemp.reserveCommonEvent(4))
</JS On Add State>

Does this fix your problem?
Okay, so I can see the problem, so I need to change the is "isActor" function to one that checks if the target is a party member. Are there any other functions that do that? I have 12 party members if that's any help with anything.
No you literally just add () on the end of isActor. That's it.
For starters:

<JS On Add State>
if(target.isActor)($gameTemp.reserveCommonEvent(4))
</JS On Add State>

Needs to be:

<JS On Add State>
if(target.isActor())($gameTemp.reserveCommonEvent(4))
</JS On Add State>

Does this fix your problem?
No you literally just add () on the end of isActor. That's it.

Wow that actually works. Thanks so much guys. 🙂

Original thread: https://forums.rpgmakerweb.com/threads/custom-event-upon-actor-death.163472/