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.

[Resolved]Adding Twice?

Already solved it. Sorry :blink:


I'm working in a little code to count how much time each character killed a enemy.
First, the code:

This is in Game_Actor:
Code:
  attr_accessor   :kills 
    def setup(actor_id)
      @kills = 0
      (original script here)
    end

    def kills
      @kills += 1
    end
end
And this is in Scene_Battle:
Code:
  def update_phase4_step6
   if @active_battler.is_a?(Game_Actor)
      for i in @target_battlers
        if i.hp <= i.oldhp
        @active_battler.kills
        p @active_battler.kills # to test what happened
        end
      end
    end
(original script here)
(this is just the part i added to the code, what is left remains untouched)

Now, the problem: Everytime that i call the "kills" method, it adds 2, instead 1. Why it is happening (i checked it trough that print in the code)
 

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