plugin for enemy slain?

Hi everyone
i been looking for a script wherever you kill an enemy
like the bat, you get +1 to the assigned variable

i used the Kill Counter plugin of Shaz buts its not working properly
i randomly got from 1 to 2 of each kill and i dont know why its happening.
here some screenies....
Spoiler: before fight
tw3TNfs.jpg
Spoiler: in fight
Rlv34q1.jpg
Spoiler: after fight
zG9PkN4.jpg
Spoiler: debbug window
92fayBj.jpg

thanks
What battle plugins are you using? If you have mine before them, try putting it after; if you have mine after them, try putting it before. See if it makes any difference.

If it doesn't, provide a link to both plugin threads and someone might be able to give you a compatibility patch.

Your imps don't get revived at all during the battle, and killed twice, do they?
What battle plugins are you using? If you have mine before them, try putting it after; if you have mine after them, try putting it before. See if it makes any difference.

If it doesn't, provide a link to both plugin threads and someone might be able to give you a compatibility patch.

Your imps don't get revived at all during the battle, and killed twice, do they?
im using yanfly battle engine, they dont get revived,
also i tried to turn off the battle plugins with its expansions and changed the plugins order, still gives me random values
Is the variable used by any other plugins or other events that you've just forgotten about?
Is the variable used by any other plugins or other events that you've just forgotten about?
no it doesnt, but i just made an another solution, at troops events when enemies reach 0, gives me that variable, but the problem its i need to do it in every troop event so, will take me alot of time lol
So if you disable ALL other plugins, the problem still happens? Could you show a screenshot of the event where you run the start/end counter commands?
I know exactly what is happening here, I was having the same problem when I was making my own kill tracking plugin. When you are using Yanfly's Battle Engine, he calls the collapse event many different times through his script (the reasoning behind it I do not fully understand), but if you go and remove all but the collapse effect in the remove Immortal section, it will work.

I have made these edits myself and tested in my game for a very long time and I have yet to see any downside or bugs arise from removing all the extra calls. I will list the ones that I have edited out because of the multiple collapse calling. Just copy/paste or simply comment out each of the perform collapse lines in each section of your plugin.

Spoiler: Yanfly Dupe Collapse Snippets
Code:
Yanfly.BEC.BattleManager_invokeMagicReflection =
    BattleManager.invokeMagicReflection;
BattleManager.invokeMagicReflection = function(subject, target) {
    Yanfly.BEC.BattleManager_invokeMagicReflection.call(this, subject, target);
    // if (subject.isDead()) subject.performCollapse(); // Edit: cause of duplicate collapse calls

Code:
BattleManager.actionActionEffect = function(actionArgs) {
    if (actionArgs && actionArgs[0]) {
      var targets = this.makeActionTargets(actionArgs[0]);
    } else {
      var targets = this._targets;
    }
    targets.forEach(function(target) {
      if (target !== undefined) {
        var alreadyDead = target.isDead();
        this.invokeAction(this._subject, target);
        if (target.isDead() && !alreadyDead) {
            //target.performCollapse(); // Edit: cause of duplicate collapse calls
        }
      }
    }, this);
    return true;
};

Code:
Yanfly.BEC.Game_Battler_regenerateAll = Game_Battler.prototype.regenerateAll;
Game_Battler.prototype.regenerateAll = function() {
    this.clearResult();
    var lifeState = this.isAlive();
    Yanfly.BEC.Game_Battler_regenerateAll.call(this);
    if (!BattleManager.timeBasedStates()) this.updateStateTurns();
    if (!BattleManager.timeBasedBuffs()) {
      this.updateBuffTurns();
      this.removeBuffsAuto();
    }
    if (this.isDead() && lifeState === true) {
      //this.performCollapse(); // Edit: cause of duplicate collapse calls
    }
    if ($gameParty.inBattle()) this.startDamagePopup();
};

Code:
BattleManager.invokeCounterAttack = function(subject, target) {
    var realTarget = this.applySubstitute(target); // EDIT
    this._action.apply(realTarget); // EDIT
    if (target.hp == 0) { // EDIT
    } // EDIT
    else { // EDIT
        var action = new Game_Action(target);
        this._logWindow.displayCounter(target);
        action.setAttack();
        action.apply(subject);
        this._logWindow.displayActionResults(subject, subject);
        // if (subject.isDead()) subject.performCollapse(); // Edit: cause of duplicate collapse calls
    }
};
WARNING: The above counter attack snippet has been edited to prevent a "dead enemy" from counter attacking. It is only used to show what section needed to be commented out from the bottom line. If you do not want this feature, just find that section in your plugin and edit out the line manually instead of copy/pasting the whole section.
woah thank you very much
i appreciate it alot
you are the very best of the world 😍

Original thread: https://forums.rpgmakerweb.com/threads/plugin-for-enemy-slain.94834/