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.

Is it possible to make damage rely on a stat?

Hey folks,
Came across this line in Game_Battler 3 :

Code:
      atk = [attacker.atk - self.pdef / 2, 0].max

      self.damage = atk * (20 + attacker.str) / 20

      # Element?

      self.damage *= elements_correct(attacker.element_set)

      self.damage /= 100

Now I was wondering if this could be modified per class.
As in only the Warrior class needs 'the' Strength, but the Hunter relies on Dexterity, a Mage on Intelligence and a Rogue on Agility.
To make it so each class has it's specific 'Strength Stat'.

For example an attacking Hunter, I was thinking of something along the lines of this:

Code:
      if $game_actors[class_id] == 2

      self.damage = atk * (20 + attacker.dex) / 20

      elsif .. etc

 

But I'm just getting into Ruby again so.. yeah.

Any help is appreciated! :)
 
Well, I thought it was impossible to work that way. From experience, for me, it was impossible. Instead I did:
Code:
 

      case attacker.class_id

      when 1

      atk = [attacker.atk - self.pdef / 2, 0].max

      self.damage = atk * (20 + attacker.dex) / 20

      self.damage *= elements_correct(attacker.element_set)

      self.damage /= 100

      else

      atk = [attacker.atk - self.pdef / 2, 0].max

      self.damage = atk * (20 + attacker.str) / 20

      self.damage *= elements_correct(attacker.element_set)

      self.damage /= 100

      end

 
Thanks anyways!
 

Injury

Awesome Bro

I don't think you would use the "else"

in VB or C++ your case statement would kind be like
case attacker.class ID
when 1
-code-
when 2
-code-
end

yeah, it looks like you did just fine! did it pop an error out? you could have it print out info on test runs like

when 1
-code-
print(self.damage)
when 2
-code-
etc

to make sure that your code actually made the change. No need for a else since everyone who is attacking using that equation should have a class. Maybe I'm mistaken when it comes to actual enemies...

anywho, thanks for letting me put my two cents in
 

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