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.

removing experience

I'm having a little problem with a script witch I'm trying to make in RMVX

Actually I have done it already in RMXP, but I'm redoing it again. It is a leveling-up system, designed for my game(sorry guys, can't post it here)

I'm particularly having problems with this piece of code(witch worked just fine on XP)

Code:
def incatk        #def to increase attack
    atk = @actor.atk
    for item in @actor.equips.compact do atk -= item.atk end  #remove the attack of weapons to calculate exp
    exp = (atk*atk*atk)/10 + 2   #calculates the exp needed for increasing the stat
    inc = atk/10 + 2                   #calculates the amount the stat will increase at this level
    if @actor.exp < exp    #if you haven't enough experience...
      Sound.play_cancel   
      return                     #plays "cancel" sound and return to menu
    else
      Sound.play_decision   #but if you have the experience...
      @actor.atk += inc
      @actor.exp -= exp     #increase the stat and lower the experience
      return
    end
  end

The problem is, the game doesn't lowers the experience. In fact, it gives an error message and shuts.

My question is: Is there a diference in the way RMVX is handling the experience? how can I lower it, then?




P.S.: Please let me know if you want to help, but couldn't understand what I'm trying to say. My English is very bad, so I"m struggling to write some of these thing here(including translating the commentaries, witch are in portuguese, my native language)



Thanks!!!
 
ah, sure. The local variable is supposed to be "Inc"(I "translated" it from portuguese also, it should mean "increase"). Don't mind that.

and the error message is:

NoMethodError Ocurred

undefined method 'exp==' for #<Game_Actor:0x16625b0>

and is gives this line:
Code:
@actor.exp -= exp
 
Yeah, that worked!

Actually I never messed with these lines(Y' know, attr*). I think I was scared with messing with the game engine. I see that I can make some little changes now.

Thanks! You helped a lot!
 

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