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.

Enemy's level help (RMXP)

Hello. I want to ask for some help with this:

Code:
hit = skill.hit * user.level * 50 / self.int

I have this as part of a battle formula I made, but the obvious thing is that enemies don't have a level. Now, I was thinking I could use something like "user.level = " and then put the enemy's ATK or a stat I'm not using in the case the formula was going to be applied for an enemy. The thing is I don't know how to make a condition like "Only if it's an enemy and not a player".

Or maybe, I can use that formula like "hit = skill.hit * user.atk * 50 / self.int". But I still need how I can restrict this so that it works only with enemies. It would be something like:

Code:
if [condition]
   hit = skill.hit * user.atk * 50 / self.int
else
   hit = skill.hit * user.level * 50 / self.int
end

Please, I need help with this little thing. I don't know RGSS, but I am trying to do what I can, so I get stuck with these little things. Thank you in advance.
 
Hello Shiny Umbreon!
You are playing around with the Game_Battler 3's skill_effect method, right?
If you wish to check if it's an enemy in battle and make something happen if the condition is met you can use this:

Code:
    if user.is_a?(Game_Enemy)
      # Do what you want to happen if it's an enemy.
    else
      # If it's not an enemy, whatever you put here will happen.
    end

If you sould like to check if the user is an actor instead, just replace Game_Enemy with Game_Actor. Simple as that!
I hope that helped, and if you have any further questions don't hesitate to ask! :thumb:

Over and out - Gando
 

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