Kill Counter

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
Kill Counter


2016.02.15


by Shaz


Introduction


This plugin allows you to track, in a variable, the number of enemies of a specific kind killed.  The counter can be turned on and off as desired.


How to use


Add to your plugins folder (file name does not matter, but I call mine KillCounter.js).  There are no parameters to set.


Use the following plugin commands:

Code:
StartKillCounter enemyId variableId maximumRequired
EndKillCounter enemyId
enemyId is the enemy's id as shown in the database - do not include leading zeros


variableId is the variable's id where the kill count is to be stored - do not include leading zeros


maximumRequired is the point at which the counter will stop accumulating.  This argument is optional - if omitted or 0, the variable will keep incrementing until the kill counter is ended.  Use this argument if you want to show the number of enemies killed in a text message via \v[...] and don't want it to go over the required amount (for example, if you will show \v[...] / 10 slimes, you would not want the variable to exceed 10).


Example:

Code:
StartKillCounter 1 15 10
will increment variable 15 for every bat (enemy 1 in the default database) killed after the plugin command is run.  When the variable reaches 10, it will not be incremented further.


Remember, if you don't pass in a maximum, the variable will keep incrementing, so if you only need 10 slimes, your test will have to be "if variable >= 10" rather than "if variable = 10".


Plugin


Download from pastebin


Credit


- Shaz


Terms


- free for use in commercial games


Notes


- You MUST define the maximum variables in the database to be large enough to include the variable you're using in the plugin command.  If your database only contains 50 variables and you use variable 100 for the plugin, it will not work.  I suggest using a Control Variables to set it to 0 (and give it a name) at the same time as the Plugin Command is called to start the counter
 
Last edited by a moderator:

Nisshoku

CEO NisshoTatsu Gaming
Veteran
Joined
Nov 12, 2013
Messages
104
Reaction score
25
First Language
English
Primarily Uses
RMMV
Hey Shaz. For one I am very impressed and excited you were able to push it out so fast. I just wanted to ask and clarify the increment portion. I have some troops set up with for example 3 slimes. Will it only count one kill for all 3, or 3 kills for all 3? Also, to make sure I understand the use, I can use the plugin command to start the count when the NPC gives you the quest, and then will increment when killed and stop when it hits max. And last, can I have 3 or 4 different kill quests going at once? So a kill quest for slimes and for bats will have separate counters?


Also thank you very much for this.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
[COLOR= rgb(39, 42, 52)]I just wanted to ask and clarify the increment portion. I have some troops set up with for example 3 slimes. Will it only count one kill for all 3, or 3 kills for all 3?[/COLOR]


It will count each enemy, not each troop.  If you have a troop of 3 and you defeat them all, it will count 3.  If you have a troop of 3 and you kill 2 then escape, it will count 2.  If you have a troop of 3 and you kill 2 and the remaining one transforms to a different enemy before you kill it, it will count 2 (I haven't tested this - if you have anything like that it might be worth doing a quick check).

[COLOR= rgb(39, 42, 52)]Also, to make sure I understand the use, I can use the plugin command to start the count when the NPC gives you the quest, and then will increment when killed and stop when it hits max.[/COLOR]


Yep.  And when you go back to the NPC and the quest is finished, call the plugin command to end the counter.  Also, if you don't pass in a max, it'll just keep incrementing the variable until you run the plugin command to end the counter.

[COLOR= rgb(39, 42, 52)]And last, can I have 3 or 4 different kill quests going at once? So a kill quest for slimes and for bats will have separate counters?[/COLOR]


That's right.  Just pass different variables for each enemy id.  
 
Last edited by a moderator:

Nisshoku

CEO NisshoTatsu Gaming
Veteran
Joined
Nov 12, 2013
Messages
104
Reaction score
25
First Language
English
Primarily Uses
RMMV
Well, I got everything set up, and did a bunch of tests, but the counter never increased. I tried with single enemies, double enemies, and everything set up into the correct events. Nothing happened. I even had a simple NPC with a text box set up as: "You have killed \V[101] spiders." And that never increased either. I will post screens of my events and whatnot.

Screenshot_2.png

Screenshot_1.png

Screenshot_3.png

Screenshot_4.png
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
Is your spider enemy #2?


Do your battles call troops with enemy #2?  Any chance you have spiders set up in multiple enemy slots and the troop is using the other one?


Have you actually saved the script to a .js file in the project's Plugins folder and added the plugin via the plugin manager and made sure it's active?
 

Nisshoku

CEO NisshoTatsu Gaming
Veteran
Joined
Nov 12, 2013
Messages
104
Reaction score
25
First Language
English
Primarily Uses
RMMV
Is your spider enemy #2?


Do your battles call troops with enemy #2?  Any chance you have spiders set up in multiple enemy slots and the troop is using the other one?
Yes, I have made spider the enemy #2 in my database.


Dunno what you mean really by my battles calling troops with enemy 2, only one spider in one enemy slot.

Have you actually saved the script to a .js file in the project's Plugins folder and added the plugin via the plugin manager and made sure it's active?
Yep, the kill counter is a .js file and added into my plugins folder, and is ON in the plugin manager.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
well, it works perfectly for me.  I have to assume that you've got something set up not quite right.  Can you please show me a screenshot of your Enemies tab, your Troops tab with the spider troop selected, and an in-game screenshot of a battle, with the "Spider Appeared" message visible?


You are not using variable 101 for something else, are you?  Maybe in another plugin?  Do you have other plugins?  If you do, could you disable ALL of them except this one and see if the issue still happens?


Edit ... okay, I think you may not HAVE a variable 101 - meaning you haven't increased the number of variables to cater for a 101.  Just go to the plugin command and either before or after it, do a Control Variables to set 101 to 0.  That should be enough.  You should always do something to name your variables when you use them in a plugin, otherwise you're likely to forget what you've used, and accidentally use it for something else later.  That's really hard to debug when that happens.
 
Last edited by a moderator:

Nisshoku

CEO NisshoTatsu Gaming
Veteran
Joined
Nov 12, 2013
Messages
104
Reaction score
25
First Language
English
Primarily Uses
RMMV
well, it works perfectly for me.  I have to assume that you've got something set up not quite right.  Can you please show me a screenshot of your Enemies tab, your Troops tab with the spider troop selected, and an in-game screenshot of a battle, with the "Spider Appeared" message visible?
I have uploaded the screenshots of what you requested.

You are not using variable 101 for something else, are you?  Maybe in another plugin?  Do you have other plugins?  If you do, could you disable ALL of them except this one and see if the issue still happens?
Nope, I didn't create variable 101 until I started setting up the Kill Counter. I also tried with just that plugin and still didn't work.

Edit ... okay, I think you may not HAVE a variable 101 - meaning you haven't increased the number of variables to cater for a 101.  Just go to the plugin command and either before or after it, do a Control Variables to set 101 to 0.  That should be enough.  You should always do something to name your variables when you use them in a plugin, otherwise you're likely to forget what you've used, and accidentally use it for something else later.  That's really hard to debug when that happens.
I already had the first 32 variables for my game, and I am a BIG stickler on keeping my database extremely organized, so I changed the max variables to 200. Starting at 101 is the questing variables.


I'm just either really blind and missing an obvious fix, or it is for some reason not working.

Screenshot_6.png

Screenshot_5.png

Screenshot_7.png
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
Your setting the number of variables to 200 should solve the problem - remember to name that 101 variable. It shouldn't matter whether you start a new game or resume a saved game after changing the maximum variables.  But if it's still not working and you ARE playing a saved game, try starting a new one and see if it works.


If it still doesn't work, add that Control Variables 101 = 0 just after the plugin call to start the counter.


Let me know if it's still not working after all that.
 
Last edited by a moderator:

Nisshoku

CEO NisshoTatsu Gaming
Veteran
Joined
Nov 12, 2013
Messages
104
Reaction score
25
First Language
English
Primarily Uses
RMMV
I did all that just now. Added the control variables to 0, still wasn't working. I have no idea what else to try.


EDIT:


Actually.....now I kind of feel extremely stupid, but I realized just now I did not have the plugin added into the manager....I just put it into my js folder and jumped the gun >.< my apologies for being a pain.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
Yep, the kill counter is a .js file and added into my plugins folder, and is ON in the plugin manager.


lol!  I specifically asked that and you said yes :D


Well, that would explain it, but you did help me find an issue.  I should probably go up and add that to the notes in case it traps anyone else (the maximum variable, that is).
 

Nisshoku

CEO NisshoTatsu Gaming
Veteran
Joined
Nov 12, 2013
Messages
104
Reaction score
25
First Language
English
Primarily Uses
RMMV
Yeah lol :D  After more checking, turns out I added it into the wrong project as well. I had two open at the time and was looking at the plugin manager of the other project. Thanks for the help though :D


Actually I was also wondering, how possible is it to either add in, or make a new plugin that can also do this with mob drops? For collect quests, I would still like to show the progress of the quest, however, as of now, the only way to accomplish this in RMMV is to check that a variable = amount of item in players inventory. However it's very unorthodox, and requires adding an entirely new event just for the check. Also either requires player interaction, or another event that would need auto run and/or parallel process.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
ah, that makes a bit more sense ;)


You could use my Linked Variables plugin to assign a formula to a variable.  This prevents you from changing the variable manually, but it means you can link, say, variable 5 to how many of a particular item is in inventory, and just use the variable in the conditional branch - you don't have to do the calculation to set it, as the plugin does that for you.


Look it up, and if you want to give it a go and need help setting it up, post in that thread rather than this one.
 
Last edited by a moderator:

Nisshoku

CEO NisshoTatsu Gaming
Veteran
Joined
Nov 12, 2013
Messages
104
Reaction score
25
First Language
English
Primarily Uses
RMMV
Thanks mate :)


I will be sure to take a look at that. Sounds interesting.
 

Janusz

Veteran
Veteran
Joined
Jul 4, 2015
Messages
26
Reaction score
4
Primarily Uses
Is possible to making something similar to Monster Capture System from FF:X?? Enemy count has increased only if they was killed by special weapon.
So, simply weapon has Capture element added to attack and enemies are counted only if was killed by Capture element.


Sorry for bad english.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
You would need to get someone to make a mod to it.  Unfortunately I don't have time to do it myself.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,141
Reaction score
12,416
First Language
English
Primarily Uses
RMMV
It's a rare moment - you should copy/paste it somewhere for posterity ;)
 

Ahuramazda

Veteran
Veteran
Joined
Nov 9, 2012
Messages
207
Reaction score
65
First Language
English
Primarily Uses
Heyo Shaz! I would like to inform you of a bug that comes with Yanfly's Battle Engine Core along with your plugin. Yanfly calls the "performCollapse" several times in his plugin and as such if you kill an enemy with a state, damage, effect, ect or any combo of these effect the kill counter will go berserk.


I know of this bug cause I was making my own kill counter and it took me several hours of messing with the code to get it right... I eventually made it work by not placing it into the section for performCollapse like you, but into "makeItemDrops" instead as that section is calculated once per battler regardless of how many times the enemy's performCollapse has been called upon.


Perhaps not the best fix, but in case you haven't heard of or seen this for yourself I figured I should mention it. :)
 

Solis

Veteran
Veteran
Joined
Oct 24, 2015
Messages
376
Reaction score
84
First Language
English
I love this...saves me all those common events. However, can you track more than one enemy at a time? 
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

So, uh, has anyone tried buying any resources from KokoroReflections? Because I've been looking for a 'buy' button on the site for like 10 minutes now and can't find one.
Any also thought it's too cringy to put the word "and you" in your credit as a special thanks?
Cause that's what I thought...
Everyone in the US right now: Please stay safe.
Symphony Celestia: Prophecy of the Falling Stars RPG Maker music pack WIP. Symphony Celestia is a new series that focuses on symphonic and orchestrated music to tell a story. Each story will include compositions that make up that story from beginning to end. Themes include: Battles, adventures, character themes, etc. Below is a video preview to the first story.

Jumping and gravitation 0.1 build - RPG Maker MV

Forum statistics

Threads
97,979
Messages
948,302
Members
129,241
Latest member
LordCola
Top