Execute javascript on actor's death in battle

● ARCHIVED · READ-ONLY
Started by Kohlskui 3 posts View original ↗
  1. Hello everyone,

    I am currently working on a script with the purpose of displaying a window when an actor die during a battle.

    Unfortunately, I can't seem to find the function in rpg_managers.js, rpg_scenes.js and rpg_objects.js.

    Can somebody tell me how the game is supposed to know when an actor die, if there is no such specific function?

    It is probably hidden as a small portion of codes, but I can't tell apart which is it.

    I will continue my search and post an update if I find anything related.

    EDIT 1 :
    Inside the class BattleManager, the function getNextSubject test if the current actor is alive or not. I thought about using this as the point where to call the window, however it may be far too late as I need to make it appear upon the actor's death, and not when it's his turn to act. Still searching...
  2. Kohlskui said:
    Can somebody tell me how the game is supposed to know when an actor die, if there is no such specific function?
    In programming one way leads to another, there is no other way.
    So, you want to find out what function is called when the player dies.
    When it happens that a player dies? His hp needs to reach 0 or less.
    From this you can easily see that it might not be a bad idea to search for "hp <= 0".
    When is the most frequent that an actor's hp reaches 0? During an action.
    So from this you might see that perhaps it's during action processing.

    Nevertheless, this is merely the general approach. A concrete one, in this case, is actually simpler.
    What is death? It's in Database-States. It's the first state. So that's the solution. You need to enter rpg_objects, find a function that inflicts states and then use an if condition to determine whether the state ID is 1 or not. Simple as that.
  3. Thank you Poryg, indeed I didn't know exactly how an actor was 'inflicted' death. I will continue looking with this in mind and post an update when I find something.