Counting enemy defeats

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Does anyone know if a script exists for Ace which counts the number of kills per character?  i.e. Actor #1 so many, Actor #2 so many, etc.  I've hunted around and can't find anything.

Thanks.
 

Euphoria

Veteran
Veteran
Joined
Jun 27, 2013
Messages
378
Reaction score
93
First Language
English
Primarily Uses
I don't think there is one specifically for that, unless something new has come out. It doesn't sound like something too hard to code though. So if I find some time today between doctor calls, C++ homework, and other script updates/requests (being sick put me WAY behind) I'll probably take a crack at it.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Thank you. That is most generous of you.

EDIT

Perhaps I should have said that I am using Yanfly's Battle Engine.  I don't know if that makes any difference.
 
Last edited by a moderator:

Euphoria

Veteran
Veteran
Joined
Jun 27, 2013
Messages
378
Reaction score
93
First Language
English
Primarily Uses
Hey, just letting you know I haven't forgot about you. Progress has been slow since I've been struggling to catch up with life after two weeks of being sick, and it seems that I'm getting sick AGAIN... so, I hope this isn't urgently needed as it may be a few days before I get it finished.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Thanks for the update.  Don't worry about it - your health is more important.

Hope you feel better soon.  I know it's debilitating to have a long spell of ill health.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
In its most basic form you could define a new class variable "@kills" for Game_Battler (remember to initialize it to 0 and to use an attribute ACCESSOR rather than a reader when defining it, so that you can change it elsewhere), and then change the execute_damage method (also in Game_Battler) as such:

#-------------------------------------------------------------------------- # * Damage Processing # @result.hp_damage @result.mp_damage @result.hp_drain # @result.mp_drain must be set before call. #-------------------------------------------------------------------------- def execute_damage(user) on_damage(@result.hp_damage) if @result.hp_damage > 0 self.hp -= @result.hp_damage if self.hp <= 0 user.kills += 1 end self.mp -= @result.mp_damage user.hp += @result.hp_drain user.mp += @result.mp_drain endThis would still leave out a few odds and ends - for example, slip damage wouldn't credit anyone for the kill (probably the hardest thing to add in since states don't come with a "user that inflicted me on an enemy" property), and if the user somehow killed themself or an ally with a skill, they'd get credit for it (not too hard to fix by checking whether the user and self are both party members or both enemies).  But this is your basic setup.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@wavelength

Thank you very much for this.

You have assumed that I know rather more about scripting than in fact I do.  When you say: "you could define a new class variable "@kills" for Game_Battler (remember to initialize it to 0 and to use an attribute ACCESSOR rather than a reader when defining it, so that you can change it elsewhere)" I have absolutely no idea what that means or how to do it.  Could you possibly talk me through the process in baby steps?

I'm not bothered by counting slip damage if that is going to be hugely complicated to sort out.
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
Sure.  Go to Game_Battler and you'll see this:

  #--------------------------------------------------------------------------  # * Public Instance Variables  #--------------------------------------------------------------------------  attr_reader   :battler_name             # battle graphic filename  attr_reader   :battler_hue              # battle graphic hue  attr_reader   :action_times             # action times  attr_reader   :actions                  # combat actions (action side)  attr_reader   :speed                    # action speed  attr_reader   :result                   # action result (target side)  attr_accessor :last_target_index        # last target  attr_accessor :animation_id             # animation ID  attr_accessor :animation_mirror         # animation flip horizontal flag  attr_accessor :sprite_effect_type       # sprite effect  attr_accessor :magic_reflection         # reflection flag  #--------------------------------------------------------------------------  # * Object Initialization  #--------------------------------------------------------------------------  def initialize    @battler_name = ""    @battler_hue = 0    @actions = []    @speed = 0    @result = Game_ActionResult.new(self)    @last_target_index = 0    @guarding = false    clear_sprite_effects    super  endI'm adding one line to each of these sections in order to define a new variable:

#-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :battler_name # battle graphic filename attr_reader :battler_hue # battle graphic hue attr_reader :action_times # action times attr_reader :actions # combat actions (action side) attr_reader :speed # action speed attr_reader :result # action result (target side) attr_accessor :last_target_index # last target attr_accessor :animation_id # animation ID attr_accessor :animation_mirror # animation flip horizontal flag attr_accessor :sprite_effect_type # sprite effect attr_accessor :magic_reflection # reflection flag attr_accessor :kills # knockouts inflicted count #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize @kills = 0 @battler_name = "" @battler_hue = 0 @actions = [] @speed = 0 @result = Game_ActionResult.new(self) @last_target_index = 0 @guarding = false clear_sprite_effects super endSo now when you say "user.kills += 1" in the damage application method (as I gave you in my previous post), it's taking the Game_Battler object that was passed into the damage application method as "user" (in other words, the character or enemy that used the attack/spell/item), and adds 1 to his or her knockouts ("kills") inflicted count.
 
Last edited by a moderator:
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Okay, I've got that bit.

So, I make the alteration in the post above. Then the one in your previous post.  And then?  How do I set it up so that it identifies that e.g. Actor #1 made 6 kills, Actor #2 made 3, Actor #3 made 11, and so on?  Presumably I have to feed whatever is being generated by these script changes to a set of variables, but I don't see how to do that.

Sorry for being so dumb about this.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
By using the event command, control variables


Control Variables: [VARIABLE_ID] = Script: $game_actors[iD].kills
 
Last edited by a moderator:
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Okay, maybe I'm doing something wrong.  this is what I did.

Made the alterations to the Game_Battler script as detailed above.

Made a variable for each actor.

Used the event command given above, one for each actor, put the specific variable and ID for each actor individually.

Did some battles and checked the event which gave a text reading for each variable

Everyone had 0 (zero) kills.

The variables (using F9 to check) all showed up as zero as well.
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
How many times did you set the variable? You should do it whenever you want to check, not just once or something


Variables only get values, not addresses... So if you like only used the command once to set the variable to be equal to the kill count and never again, the variable would just be equal to whatever value the kill count has at that moment that you used the event command.


Example:


$game_actors[1].kills = 0


Control Variables: Variable[11] = $game_actors[1].kills


$game_actors[1].kills += 1


Show Text: Show Variable[11] => Will show 0 since kills is 0 when we set Variable 11 to be equal to it
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Ah, that explains it.  I thought the variable was keeping count as you went along.  That seems to solve the whole thing.

Thanks very much to you and to Wavelength.  
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
You're welcome!

I was really surprised when I looked through the Master Script List and didn't see any scripts for this.  I'm just gonna wait a couple weeks to see if someone pops in and says "you fools!  There was a script right here!" and points to it.  If not, it's definitely some low-hanging fruit for me to alias the methods properly, add a couple of options (and have the game write the counts to variables automatically), and make it into a complete script.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
That's a very good idea.  I'll leave this thread open for a bit to see if said person does indeed pop in and enlighten us.  Though having spent quite some time searching, I think it's unlikely.

If you are doing a script, what sort of options did you have in mind?

For example, would it be able to distinguish between defeats through physical attack and defeats through magic attack?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
If you are doing a script, what sort of options did you have in mind?
For example, would it be able to distinguish between defeats through physical attack and defeats through magic attack?
Here are a few of the features I might add:

* Additional, party-wide tracking of KO counts

* Automatic linking of character/party KO counts to variables

* Options for how to handle KO by slip damage

* Options to make some enemies worth more (or less) than 1 KO

* Option to have a Switch turn the KO counts off

* Ability for weapons and armor to have their stats scale based off of the wearer's (or party's) KO count
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Sounds good. If you have room for one more would it be possible to add having the stat show up in the character's status screen? In an ideal world it would be compatible with Yanfly's status screen script.

Thanks
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,624
Reaction score
5,104
First Language
English
Primarily Uses
RMVXA
That's a cool idea.  I'll take a look into how difficult it would be to make compatiable with Yanfly's script, but I could definitely add it to the default status screen.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,085
Members
137,583
Latest member
write2dgray
Top