Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Script allowing to count kills for each chara?

vorsho

Member

Is it possible with RMXP?
A script that would count, for each character, how many monsters he or she has killed?
Some pro games have it and I always thought it was a great feature. :D
 
Code:
#==============================================================================
# ** Game_Battler
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :kill_count
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_killcount_gmbtlr_init initialize
  alias seph_killcount_gmbtlr_ae attack_effect
  alias seph_killcount_gmbtlr_se skill_effect
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Original Initialization
    seph_killcount_gmbtlr_init
    # Starts Kill Count
    @kill_count = 0
  end
  #--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Original Attack Effect
    seph_killcount_gmbtlr_ae(attacker)
    # If Self is Dead
    if dead?
      # Adds to Kill Count
      attacker.kill_count += 1
    end
  end
  #--------------------------------------------------------------------------
  # * Apply Skill Effects
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # Original Attack Effect
    seph_killcount_gmbtlr_se(user, skill)
    # If Self is Dead
    if dead?
      # Adds to Kill Count
      user.kill_count += 1
    end
  end
end

Just use

<game_battler>.kill_count

Something like $game_actors[id], or $game_party.actors[index] in place of <game_battler>
 

vorsho

Member

Thanks for your answer!
But I'm not sure where to put this code, there are Game_Battler1, 2 and 3
But not just Game_Battler...
Or is it a new script?
I'm sorry but I'm new to scripting and I am not sure where to put the lines of this code...

And another question... is this line:
Something like $game_actors[id], or $game_party.actors[index] in place of <game_battler>

the way to display this number?
 

vorsho

Member

OK, I added it just below Game_Battler3, as a new script.

When I call this script:
$game_actors[id].kill_count

It gives an error message.
So I tried to replace id by a number, like 001 for the 1st character.
But this time, nothing happens. Is this normal?
 
OK, I added it just below Game_Battler3, as a new script.

When I call this script:
$game_actors[id].kill_count

It gives an error message.
So I tried to replace id by a number, like 001 for the 1st character.
But this time, nothing happens. Is this normal?

You must replace id with the id of the actor in the database, with no 0's (unless its 10, 20, 100, etc.)

So actor 3, would be

$game_actors[3].kill_count

Error message is:
NoMethodError
Undefined methpd 'kill count'for nil:NilClass

for nil:NilClass is telling me you are typing it wrong. Is saying you are trying to use a method from an object that hasn't been created.

Check your spelling and such. It must be exact.
 

vorsho

Member

Hi, it seems the healing spells are not working properly with this script.
The MP are not decreasing, although the character does get healed.
Besides, instead of the usual healing sound, you get a sound of "impossible spell to cast"... this is really weird... did the same thing happen to you DerVVulfman?
 

vorsho

Member

My project is still in its very earlier stages but I'm trying to form a collection of nice scripts before starting the game itself.
I could post something, though.
The thing is, when I removed the script, the Heal spell was back to normal.
If I put it back, it starts messing again... weird.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top