Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
I need a way of counting how many enemies each actor has actually killed either using physical, magical or certain hit.

I thought I had this because I have a script which uses variables to show this information in the Status window. However, it seems that it just adds them for the Status window alone, and does not add them to the variable, which always remains at zero.

Does anyone know of a script which would do this, or anyone who could write such a thing?

Thank you.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,518
Reaction score
1,563
First Language
Spanish
Primarily Uses
RMVXA
do those values come back as they should, when changing the active character?
if so, then they're definitely being stored somewhere.
you can easily backtrack from the status window's code itself.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@gstv87 Yes, they remain true no matter how often I change who is in the active party.

you can easily backtrack from the status window's code itself.

Whilst this may be true for a theoretical "you", when I am the actual "you" it doesn't apply, as I don't understand the coding.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,518
Reaction score
1,563
First Language
Spanish
Primarily Uses
RMVXA
can you post the block that manages that window?

actually,..... are they saved if you save a game?
if so, find the call to the object managing that being loaded, it should be tied to the DataManager somewhere.

do a broad search of all occurences of "module DataManager", or "extract_save_contents"
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@gstv87 Naturally they are saved. They are in the status window in order to give the information to the player. Unless they were saved there would be no point to them.

I did the 2 searches you suggested, but I don't know what to do with the information given.
Here is the result to extract_save_contents
upload_2018-6-27_17-27-34.png

and the other one
upload_2018-6-27_17-29-6.png

The particular script doesn't appear on either list.
 

Attachments

  • upload_2018-6-27_17-26-52.png
    upload_2018-6-27_17-26-52.png
    247.8 KB · Views: 5

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,518
Reaction score
1,563
First Language
Spanish
Primarily Uses
RMVXA
The particular script doesn't appear on either list.
the script that manages the feature in question, doesn't appear?
if so, the feature is tied to the $game_party object, which is saved by the default engine.
try a search for Window_BattleStatus.

if that script appears, find that class in that script, it should have ties to Game_Party, it probably defines a new function.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@gstv87 Nope, not in that list either. All I have is this:
upload_2018-6-27_17-50-47.png

I could give you the coding in a pm, but I can't do a public post of it. Would that help?
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,518
Reaction score
1,563
First Language
Spanish
Primarily Uses
RMVXA
sure, send it over.
or, tell me where to find it
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,484
Reaction score
8,272
First Language
Indonesian
Primarily Uses
RMVXA
My way to go is something like this
Code:
class Game_Battler
  attr_writer :kill_count
  def execute_damage(user)
    on_damage(@result.hp_damage) if @result.hp_damage > 0
    self.hp -= @result.hp_damage
    self.mp -= @result.mp_damage
    user.hp += @result.hp_drain
    user.mp += @result.mp_drain
    if self.dead?
      user.kill_count += 1
    end
  end
 
  def kill_count
    return @kill_count ||= 0
  end
end
It doesn't display anything, although it does track the kill count for every actor. If you want to display it, you either need an implementation on the window object or just store it in game variables by using script call.
Code:
$game_actors[id].kill_count
The limitation would be it wont track an enemy that is killed by DoT.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@TheoAllen I don't need to display the information anywhere, just be able to call up the total stored in the variable.

Sadly, though, the variable did not increase. I created a new variable for this, set up like this:
upload_2018-6-28_7-1-9.png

I got the actor to defeat a couple of enemies, but variable #67 stayed at zero, both using an existing save and in a new game. I also tried it with the Operation set to 'Add', just in case, but that didn't work either.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,484
Reaction score
8,272
First Language
Indonesian
Primarily Uses
RMVXA
It might because I wasn't using alias. I tried this and it seems to work on my game
Code:
class Game_Battler
  attr_writer :kill_count
  alias exe_damage execute_damage
  def execute_damage(user)
    exe_damage(user)
    if self.dead?
      user.kill_count += 1
    end
  end

  def kill_count
    return @kill_count ||= 0
  end
end
If you're unsure, try to put this below all of your scripts.
If you want to know the live update, add this
Code:
class Scene_Base
  alias update_x update_basic
  def update_basic
    update_x
    p $game_actors[1].kill_count
  end
end
Then use Game > Show Console. It will print 0 at first, and everytime actor 1 managed to kill an enemy, it should increase by one. Or how many enemy had been killed by AoE.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@TheoAllen I must be doing something wrong, because it is still not working.
I tried placing the new version below everything else, and included the bit for the console.

The console indeed showed zeros, but did not update when an actor defeated an enemy. Nor did variable #67 (or #68 for that matter, as the battle had 2 actors in it) increase from zero.

I am trying to set a variable for each of 5 actors which I can call up in common events to calculate various things, so I don't really need a live update, just a variable update.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,484
Reaction score
8,272
First Language
Indonesian
Primarily Uses
RMVXA
The live update is sort of debugging tool that you can remove on deployment later, it's really unnecessary code that only useful for tracking.
Can you confirm to me if it works on new project?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@TheoAllen In a totally new game the console display updates to show the number of kills, but the variable which I had set does not. Looking at the screen shot I gave above of how I set the variable, can you see what the problem might be?
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,484
Reaction score
8,272
First Language
Indonesian
Primarily Uses
RMVXA
@TheoAllen In a totally new game the console display updates to show the number of kills, but the variable which I had set does not. Looking at the screen shot I gave above of how I set the variable, can you see what the problem might be?
You set up the variable correctly, however it does not auto update. It's same as if you set $game_party.gold on a variable script call, it doesn't change even when the party gold is changed. You need to update it manually.

Now it's your call if you want to update the var manually, or use automatic one.
Code:
class Game_Variables
  alias :kill_var :[]
  def [](var_id)
    case var_id
    when 67 # <-- variable id
      $game_actors[1].kill_count
    when 68
      $game_actors[2].kill_count
   
    # Add more ....
    # Don't delete below this line
    else
      kill_var(var_id)
    end
  end
end
This extra code link a certain variable id to kill count so it will be automatically updated. However you have no control over it. If you change the variable value by event, it won't work. The value is totally fixed, and only increased by killing more enemies.

edit: fixed the code
 

GGZiron

Veteran
Veteran
Joined
Nov 6, 2016
Messages
95
Reaction score
41
First Language
Bulgarian
Primarily Uses
RMMZ
@Kes, do you set the game variable at begining of game, and expect it to track the kill count?
If so, it won't work this way. It will just assume the current kill count value.

Edit: ninjaed :).
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@TheoAllen It works perfectly in a vanilla new project, but not at all in my existing one. I therefore assume that another script must be blocking it, even though it is underneath everything else.

Could you suggest what I should do a global search for to see if I can identify which is the culprit script?

@GGZiron This is also the case when I set it for a new game and start a new game on my test map, and if I set it and then do a battle from an existing save file.
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
6,484
Reaction score
8,272
First Language
Indonesian
Primarily Uses
RMVXA
Try to global search this
Code:
def execute_damage

Edit: or this
Code:
def dead?

Edit2:
Now to think about it
I thought I had this because I have a script which uses variables to show this information in the Status window. However, it seems that it just adds them for the Status window alone, and does not add them to the variable, which always remains at zero.
It might because it also has the same issue of being blocked on your game
 
Last edited:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
@TheoAllen
The only other places def execute_damage is found is in the default script, Yanfly's Battle Engine and Yanfly's Lunatic States. I tried disabling Lunatic states, but it made no difference. I can't disable Battle Engine without messing up a whole host of things.

def dead? only appears in the default script.

I have already disabled the other script, just in case, but it has made no difference.

I shan't be able to test this any further for a few hours (RL has its demands).
 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Today the 2nd part of the RPGMakergame "A Thief's voyage" came out.


Go show DutchPowerCreations some love.
love it when you forget to put a certain thing in the movement route and suddenly a character starts spinning at 10000 rpm
I'm sorry. I have a bad feeling I've been manic the past couple of days. Antidepressants have only been making things worse somehow -- too drowsy to function, followed by insomnia. Why not making me go crazy to boot?
Cosmetix.gif

Hey man, why don't you do some progress on your game? Oh, because you'd rather wake up at 5am and spend the night making a cosmetics system for your side view battlers? Ok.
spillycup wrote on Finnuval's profile.
i love u so much! i’m so happy you’re in my life right now :kaocry:

Forum statistics

Threads
116,991
Messages
1,103,629
Members
152,880
Latest member
D_Supreme
Top