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.

Never miss in battle

Where and what do I change to make it so that the characters and enemies never miss their target in battle? Instead of making changes in the database, is there something I can change in one of the scripts to do this, so that regardless of agility or dexterity, they never miss? Or better yet, is there a miniscript I can add above main? I would rather the characters or enemies do 0 damage if they're strong and I want their agility to only affect their turn in battle. Thanks if you can help me with this.
 
In game_Battler:
Code:
#--------------------------------------------------------------------------
  # * Applying Normal Attack Effects
  #     attacker : battler
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # Clear critical flag
    self.critical = false
    # First hit detection
    hit_result = (rand(100) < attacker.hit)
    # If hit occurs
    if hit_result == true
      # Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20
      # Element correction
      self.damage *= elements_correct(attacker.element_set)
      self.damage /= 100
      # If damage value is strictly positive
      if self.damage > 0
        # Critical correction
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage *= 2
          self.critical = true
        end
        # Guard correction
        if self.guarding?
          self.damage /= 2
        end
      end
      # Dispersion
      if self.damage.abs > 0
        amp = [self.damage.abs * 15 / 100, 1].max
        self.damage += rand(amp+1) + rand(amp+1) - amp
      end
      # Second hit detection
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # If hit occurs
    if hit_result == true
      # State Removed by Shock
      remove_states_shock
      # Substract damage from HP
      self.hp -= self.damage
      # State change
      @state_changed = false
      states_plus(attacker.plus_state_set)
      states_minus(attacker.minus_state_set)
    # When missing
    else
      # Set damage to "Miss"
      self.damage = "Miss"
      # Clear critical flag
      self.critical = false
    end
    # End Method
    return true
  end

Untested but I think all you have to do is instead of:

hit_result = (rand(100) < attacker.hit)

put this:

hit_result = (rand(100) < 100)
 
I changed line 46 with your suggestion (under first hit detection) and tested it with 1 agility and it worked. I'm going to keep it in game and see if it works under different circumstances. Thanks so much for your help.

**Does this also affect monsters attacking players, or does it just affect players attacking monsters? I'm going to check.

**EDIT**
I think it works both ways.
 
yeah it should.... Oh and If you want to change it so that only actors can't miss, I'll fix it for you....




EDIT::: If you want it so that Characters Always Miss... change the 100 to the right to 0
 

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