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] Battle Algorithm Help.

      if attacker.is_a?(Game_Enemy)
      atk = [(attacker.str * 6) + (attacker.dex + attacker.atk)] - self.pdef
      else
      atk = [(attacker.str * 6) + (attacker.level + attacker.atk)] - self.pdef
      end
      self.damage = atk

This is what i have but whenever i try to attack it says failed to turn fixum into array it also happen with my skills if i try to use them. If anyone could help that would be great. Thanks.

    hit = if user.is_a?(Game_Enemy)
      hit = [(user.int * 8) + (user.dex + skill.power)] - self.mdef
          else
      hit = [(user.int * 8) + (user.level + skill.power)] - self.mdef
          end
 
if attacker.is_a?(Game_Enemy)
  atk = [(attacker.str * 6) + (attacker.dex + attacker.atk)] - self.pdef
  else
  atk = [(attacker.str * 6) + (attacker.level + attacker.atk)] - self.pdef
  end
  self.damage = atk
You don't need to put brackets.

hit = if user.is_a?(Game_Enemy)
hit = [(user.int * 8) + (user.dex + skill.power)] - self.mdef
else
hit = [(user.int * 8) + (user.level + skill.power)] - self.mdef
end
This doesn't makes sense at all. It should be:
Code:
hit = 0 # just to make sure
if user.is_a?(Game_Enemy)
  hit = (user.int * 8) + (user.dex + skill.power) - self.mdef
else
  hit = (user.int * 8) + (user.level + skill.power) - self.mdef
end
 
Sobeman459":1b4951op said:
That still didnt work failed to create fixnum into an array
What? How did it even think about making it into an array after that change? All it does is calculating some values based on integers. Are you sure you used the correct snippet Dargor provided?
 

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