Enemy HP error

Discussion in 'RGSSx Script Support' started by Qeo, May 18, 2019.

  1. Qeo

    Qeo Veteran Veteran

    Messages:
    98
    Likes Received:
    19
    The enemies HP are drastically lower than they should be in battle. This only happens with this script, but I still want to keep the script. How should I edit it so that this glitch doesn't occur?

    #==============================================================================
    # ** Game_Battler
    #------------------------------------------------------------------------------
    # This class deals with battlers. It's used as a superclass for the Game_Actor
    # and Game_Enemy classes.
    #==============================================================================

    class Game_Battler
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias timed_hit_attack_effect attack_effect
    alias timed_hit_skill_effect skill_effect
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :timed_hit_hit_percent
    attr_accessor :timed_hit_use_percent
    attr_accessor :timed_hit_state_to_add
    #--------------------------------------------------------------------------
    # * Applying Normal Attack Effects
    # attacker : battler
    #--------------------------------------------------------------------------
    def attack_effect(attacker)
    effective = false
    # If part of Timed Hits
    if @timed_hit_use_percent
    hp = self.hp
    # Perform the original call and get effective
    effective = timed_hit_attack_effect(attacker)
    if self.damage != "Miss"
    self.hp = hp
    self.damage = Integer((@timed_hit_hit_percent * self.damage) / 100.0)
    self.hp -= Integer(self.damage)
    if @timed_hit_state_to_add != nil
    self.add_state(@timed_hit_state_to_add)
    end
    end
    # If not part of Timed Hits
    else
    # Perform the original call and get effective
    effective = timed_hit_attack_effect(attacker)
    end
    @timed_hit_use_percent = false
    @timed_hit_state_to_add = nil
    return effective
    end
    #--------------------------------------------------------------------------
    # * Apply Skill Effects
    # user : the one using skills (battler)
    # skill : skill
    #--------------------------------------------------------------------------
    def skill_effect(user, skill)
    effective = false
    # If part of Timed Hits
    if @timed_hit_use_percent
    hp = self.hp
    # Perform the original call and get effective
    effective = timed_hit_skill_effect(user, skill)
    if self.damage != "Miss"
    self.hp = hp
    self.damage = Integer((@timed_hit_hit_percent * self.damage) / 100.0)
    self.hp -= Integer(self.damage)
    end
    # If not part of Timed Hits
    else
    # Perform the original call and get effective
    effective = timed_hit_skill_effect(user, skill)
    end
    @timed_hit_use_percent = false
    return effective
    end
    end



    #==============================================================================
    # ** Game_Actor
    #------------------------------------------------------------------------------
    # This class handles the actor. It's used within the Game_Actors class
    # ($game_actors) and refers to the Game_Party class ($game_party).
    #==============================================================================

    class Game_Actor < Game_Battler
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_reader :actor_id
    end
     
    #1
  2. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    188
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Qeo You say it only happens with this script. What is the enemy HP without the script and how does that change when the script runs?
     
    #2
  3. Qeo

    Qeo Veteran Veteran

    Messages:
    98
    Likes Received:
    19
    Enemy HP without the script just works as you'd expect, an enemy with 10,000 HP has 10,000 HP. With it, an enemy with 10 thousand hp died at a little over 5000. So it seemed like enemies health were reduced by half, then I fight something with 80,000 health and it dies in less than 40,000.
     
    #3
  4. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    188
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Qeo It looks like the script is doing double duty. If an enemy is being dealt normal damage noted by the engine and then your script also subtracts the damage from the enemy, they will effectively have half hit points because they are taking damage twice, once from the source code and once again from your script. What happens if you just take out the self.hp -= Integer(self.damage) lines from the code?
     
    #4
  5. Qeo

    Qeo Veteran Veteran

    Messages:
    98
    Likes Received:
    19
    This seems to have fixed the problem entirely. Thank you!
     
    #5
    mathmaster74 likes this.
  6. mathmaster74

    mathmaster74 just...John Veteran

    Messages:
    285
    Likes Received:
    188
    Location:
    Sheboygan, WI USA
    First Language:
    English
    Primarily Uses:
    RMMV
    @Qeo You're welcome. :smile: Happy to have helped.
     
    #6
    Qeo likes this.

Share This Page