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.

Okay, guessed it wasn't solved (custom variables for actors/enemies) [RESOLVED]

kkxkn

Member

Well, last time I had the problem I was just changing the ways I was using existing ones.

But this time, I'm trying to define a custom variable from scratch for Game_Battlers, it's needed on both actors and enemies. I've tried both putting it in Game_Battlers, and putting a copy of it into each of Game_Actors  and Game_Enemy. No luck either way.

While I don't get any error messages, the value doesn't change as it should.

I have this in Game_Battlers3, just below where damage is subtracted from HP(in both skills and physical attacks):
Code:
      if self.damage > 0
        breakoutup = [(self.damage * 70) / self.maxhp, 5].max
        self.breakout += breakoutup
        if (self.breakout == 100) && self.is_a?(Game_Enemy)
          $Game_Switches[51] = 1
        end
      end

And this in Game_Battler1 (I also tried putting this into Game_Actor and Game_Enemy):
Code:
  def breakout
    if @breakout > 100
      @breakout = 100
    end
    if @breakout < 0
      @breakout = 0
    end
    return Integer(@breakout)
  end
  def breakout=(brkout)
    @breakout = brkout
    if @breakout > 100
      @breakout = 100
    end
  end

While it doesn't give any errors, the value doesn't seem to be changing - even though the functions are executing (which I can confirm by intentionally putting code in them that will crash the game).

Any suggestions?

EDIT: Should probably mention... XP.
 
1st - rather than intentionally crashing the game, just used the 'p' or 'print' statement to show the current value..

print self.breakout
or
print @breakout

Try the 2nd version in the 'def breakout' method.  It's possible that self.breakout is assigning the value to @breakout instead of executing the method???
 

kkxkn

Member

The value does seem to be changing as it's meant to (according to the print statement) but the switch never turns on and also, an in-event script I have (for testing, again) to set the character's max SP to the current value of breakout, keeps putting it at zero. (Yes, I did put "Full recovery" after it. :P)

Also, the def breakout method indeed doesn't seem to be working (the def breakout= is working fine). :/
 
If the 'def breakout' method is not getting called, then the problem is most likely that the value is never exactly equal to 100.

Try changing the 4th line in your first script segment to:

if (self.breakout >= 100) && self.is_a?(Game_Enemy)
 

kkxkn

Member

Problem is that it's not being called in the "set SP to breakout" either, which since it's just for testing and not part of the actual game, just runs every turn in the battle.

With some more testing - here's the weirdest part of all. The switch is now activating fine, but I have no idea whether it's working for the actor, because it's still not changing SP... :/


EDIT: Nevermind, the problem with THIS one was in the event. The event was set to execute only once per battle, rather than every turn (I didn't realise you had to change another setting as well as setting it to execute on Turn 1X). :/ It's working fine now.
 
I assume you fixed "$Game_Switches[51]" to "$game_switches[51]"

It's also a good idea to initialize @breakout = 0 in the initialize method.

The other issue I noticed is that the only way the switch will get set is if the attacker deals 43% greater damage than the enemy's max in a single blow.  (100 / 70).  Meaning it should only work on relatively low powered enemies. Otherwise, the 'breakout' value will approach 70, then the enemy will die before it ever gets to 100.

Note: I have no idea what "breakout" is supposed to do.  :scruff:

Be Well
 

kkxkn

Member

Yeah, I noticed that, I've changed it to 130 now. Although previously it would be possible on powerful enemies that can survive 20 hits, since the minimum charge is 5. (And my game's having some pretty powerful enemies as optional bosses...)
 

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