Status
Not open for further replies.

Kes

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
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

Regular
Regular
Joined
Oct 20, 2015
Messages
3,367
Reaction score
2,566
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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

Regular
Regular
Joined
Oct 20, 2015
Messages
3,367
Reaction score
2,566
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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: 9

gstv87

Regular
Regular
Joined
Oct 20, 2015
Messages
3,367
Reaction score
2,566
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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

Regular
Regular
Joined
Oct 20, 2015
Messages
3,367
Reaction score
2,566
First Language
Spanish
Primarily Uses
RMVXA
sure, send it over.
or, tell me where to find it
 

TheoAllen

Self-proclaimed jack of all trades
Regular
Joined
Mar 16, 2012
Messages
7,534
Reaction score
12,008
First Language
Indonesian
Primarily Uses
N/A
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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
Regular
Joined
Mar 16, 2012
Messages
7,534
Reaction score
12,008
First Language
Indonesian
Primarily Uses
N/A
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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
Regular
Joined
Mar 16, 2012
Messages
7,534
Reaction score
12,008
First Language
Indonesian
Primarily Uses
N/A
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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
Regular
Joined
Mar 16, 2012
Messages
7,534
Reaction score
12,008
First Language
Indonesian
Primarily Uses
N/A
@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

Regular
Regular
Joined
Nov 6, 2016
Messages
120
Reaction score
64
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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
Regular
Joined
Mar 16, 2012
Messages
7,534
Reaction score
12,008
First Language
Indonesian
Primarily Uses
N/A
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

Regular
Regular
Joined
Aug 3, 2012
Messages
23,888
Reaction score
13,900
First Language
English
Primarily Uses
RMMZ
@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

Time for the next chance for y'all to affect my advent calendar! Where should Day 7's sprite come from: land, sea, or demon realm? :rwink:
Throné's final boss is weird. He is a guy holding a baby while fighting off attackers. I think his name was Santos. I might be thinking of someone else.
I think I've just about finished fighting the fight with the tileset I was most intimidated by for game jam. No pictures yet, the map isn't presentable, but I think the tileset will work! I'm very relieved XD
Twitch! At it again with more gamedev for a couple hours, followed by some Valheim with my friend. Feel free to drop by~
these 80+ gb updates on several years old games are the absolute worst. I just want to play for an hour or so before bed to unwind. Sorry, gotta spend that time downloading an update. Then my mods will be broken so I'll have to start over or wait for those to be updated to. Is a complete game within three years of the pay to be a beta tester period really to much to ask?

Forum statistics

Threads
136,782
Messages
1,269,873
Members
180,522
Latest member
Reniawan
Top