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.

Problem with Attack.

I've searched the forum and didn't found anything like this, and I'm not sure if this should be here.

In RMXP, if we don't have a weapon equipped, we can't do any damage, how can i change it?
How can I make the character do damage, without using weapons?

Help will be much apreciated.
Thank you.
 
Add this in a new script above main:

Code:
class Game_Battler
  alias daniel_attack_effect attack_effect
  def attack_effect(attacker)
    daniel_attack_effect(attacker)
    self.damage = 1 if self.damage == 0
  end
end

This just makes it to where you do at least 1 damage.
 
you'll need to go to Game_Battler 3

Find:

Code:
# Calculate basic damage
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20

and edit it. The "attacker.atk" is calling the character's Attack Power, which by default, is only above 0 if they have a weapon equipped. You could try changing attacker.atk to attacker.str which would look like this:
Code:
# Calculate basic damage
      atk = [attacker.str - self.pdef / 2, 0].max
      self.damage = atk * (20 + attacker.str) / 20

This makes the Attacker's Strength and the Defender's Physical Defense the only two factors in Attack Damage, as opposed to Attacker's Attack Power, and Defender's Physical Defense, with the Attacker's Strength playing as only a multiplier. Doing this, makes it so long as the character has a positive number for Strength, they can potentially do damage (so long as the Defender's Physical Defense isn't so high to stop this). I'm not sure what kind of effect this has on the overall damage output, since I don't use the default battle algorithms anyway.

An alternate method would be to institute a script that defines each character's Attack Power without the use of weapons, but I can't help you there, but I hope the above helps.
 
You could do that without editing Game_Battler 3 like this

Code:
class Game_Actor
  alias str_base_atk base_atk
  def base_atk
    n = str_base_atk
    n += base_str
    return n
  end
end

This way
atk = str + weapon atk

You can modify the method for other effects (attack = some percentage of strength or whatever)
 
Trickster said:
You could do that without editing Game_Battler 3 like this

Code:
class Game_Actor
  alias str_base_atk base_atk
  def base_atk
    n = str_base_atk
    n += base_str
    return n
  end
end

This way
atk = str + weapon atk

You can modify the method for other effects (attack = some percentage of strength or whatever)

... Man, I seriously gonna learn the power of Alias.
 
Another way is to replace your def battle in game battler 3 with this.
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
    # Set damage to at least 1
    self.damage = (attacker.str) +- rand(10)/5 if self.damage == 0
    # 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
It makes a weaponless attack deal damage equal to the attackers Strength divided by 5, with a randomization of 10 either way. Hope this helps.
 

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