[RESOLVED] Bar de stamina + ABS BLIZZ

Started by R5GAMER, November 28, 2014, 12:22:34 pm

Previous topic - Next topic

R5GAMER

November 28, 2014, 12:22:34 pm Last Edit: November 28, 2014, 06:50:40 pm by R5GAMER
I created a stamina bar system but the problem is that an error :

Here is my code:

#-------------------------------------------------------------------------------
# SYSTEME DE STAMINA                                 Créer le : 28/11/2014
#-------------------------------------------------------------------------------
# Créer par : R5GAMER.
#-------------------------------------------------------------------------------
# Configuration :
#-------------------------------------------------------------------------------
module Config
 GRAPHICS = RPG::Cache.picture("Bar_Stamina")  #  Image de la barre.
 MAX_SPEED = 4.7    #  Vitesse Maximum.
 NORM_SPEED = 3.5   #  Vitesse Normal.
 STAMINA = true     #  Active la barre de stamina ou la désactive
 LOSE_STAMI = 3     #  Perdre la stamina.
 RECHARGE = 0.5     #  Recupération de la stamina.
 MIN_STAMI = 3      #  Stamina min. nescessaire pour utiliser le dash.
 MAX_STAMI = 500    #  Valeur max. de Stamina.
 BAR_STAMINA = [114,428]  #  Position de la barre de stamina.
 STAMI = 0  #  Init.
end

#===============================================================================
# Class :: Game Player
#===============================================================================
class Game_Player < Game_Character
 alias dead_config_run_initialize initialize
 alias dead_config_run_update update
 def initialize
   dead_config_run_initialize
   $stamina = Config::MAX_STAMI
 end
 
 #-----------------------------------------------------------------------------
 # Update
 #-----------------------------------------------------------------------------
 def update
   actor = $game_party.actors[0]
   if Config::STAMINA == true
     if Input.press?(Input::X)
       if $stamina >= Config::STAMI
         $stamina -= Config::LOSE_STAMI
       end
       if $stamina >= Config::MIN_STAMI
         @character_name = actor.character_name
         @move_speed = Config::MAX_SPEED
         distance = 2 ** Config::MAX_SPEED
       elsif $stamina < Config::MIN_STAMI
         @character_name = actor.character_name
         @move_speed = Config::NORM_SPEED
         distance = 2 ** Config::NORM_SPEED
         if $stamina < Config::MAX_STAMI
           $stamina += Config::RECHARGE
         end
       end
       else unless Input.press?(Input::X)
       @character_name = actor.character_name
       @move_speed = Config::NORM_SPEED
       distance = 2 ** Config::NORM_SPEED
       $stamina += Config::RECHARGE
     end
   end
   elsif Config::STAMINA == false
     if Input.press?(Input::X)
       $stamina -= Config::LOSE_STAMI
       @character_name = actor.character_name
       @move_speed = Config::MAX_SPEED
       distance = 2 ** Config::MAX_SPEED
     else
       @character_name = actor.character_name
       @move_speed = Config::NORM_SPEED
       distance = 2 ** Config::NORM_SPEED
       $stamina += Config::RECHARGE
     end
   end
   
   #---------------------------------------------------------------------------
   # efect_anim
   #---------------------------------------------------------------------------
   def efect_anim(actor)
     begin
       RPG::Cache.character(actor.character_name.to_s, actor.character_hue)
     rescue
       return false
     end
     return true
   end
   dead_config_run_update
 end
end

#===============================================================================
# Class :: Player Stamina
#===============================================================================
class Player_Stamina < Window_Base
 include Config
 def initialize
   super(0,0,480,620)
   self.contents = Bitmap.new(width - 32,height - 32)
   self.opacity = 0
   self.back_opacity = 0
   Graphics.update
   Graphics.transition
   refresh
 end
 
 #-----------------------------------------------------------------------------
 # Refresh
 #-----------------------------------------------------------------------------
 def refresh
   self.contents.clear
   if STAMINA == true
     stamp = GRAPHICS
     stampwidth = stamp.width * $stamina / MAX_STAMI
     stampheight = stamp.height
     stamp_rect = Rect.new(0,0,stampwidth,stampheight)
     self.contents.blt(BAR_STAMINA[0],BAR_STAMINA[1],stamp,stamp_rect)
   end
 end
end

#===============================================================================
# Class :: Player Stamina
#===============================================================================
class Scene_Map
 
 #-----------------------------------------------------------------------------
 # Main
 #-----------------------------------------------------------------------------
 alias stam_main main
 def main
   @Player_Stamina = Player_Stamina.new
   stam_main
   @Player_Stamina.dispose
 end
 
 #-----------------------------------------------------------------------------
 # Update
 #-----------------------------------------------------------------------------
 alias stam_update update
 def update
   stam_update
   if $andando == true
     @Player_Stamina.refresh if Graphics.frame_count % 2 == 0
   else  
     @Player_Stamina.refresh if Graphics.frame_count % 2 == 0
   end
 end
end


Thanks..
..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

ThallionDarkshine

November 28, 2014, 03:20:57 pm #1 Last Edit: November 28, 2014, 03:50:55 pm by ThallionDarkshine
Alright, I think i found the error. By extending your modification of Game_Player from Game_Character, I believe you may completely overwrite the class, making it basically an exact copy of Game_Character. This takes away all the methods BABS has added into the Game_Player class.
So, to fix it all you have to do is change this line:
Code: rgss
class Game_Player < Game_Character

to this:
Code: rgss
class Game_Player


And also, one thing I noticed while reading through your script is that instead of just using an else statement, in many places you use and elseif with the exact opposite condition of the if. This is completely redundant, because if the first statement does not catch it, then the opposite of the condition must be true.

R5GAMER

when i delete Game_character, the stamina bar doesn't go down
but in an empty project without blizz's abs system it works
it doesn't work when i try to use that system...
..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

ThallionDarkshine

Well what key are you trying to use ingame to be the run key? Your setup would by default use the 'A' key. If you want to actually use the 'X' key, use Input::Key['X'] instead of Input::X.

R5GAMER

..........________
....'/,-Y"............."~-.
..l.Y.......................^.
./\............................_\
i.................... ___/"...."\
|.................../"...."\ .....o!
l..................].......o !__../
.\..._..._.........\..___./......"~\
..X...\/...\.....................___./
.(. \.___......_.....--~~".....~`-.           
....`.Z,--........./.....................\
.......\__....(......../.........._____)
...........\.........l......../---~~" /
............Y.......\................../
............|........"x_____.^
............|.....................\
............j.....................Y

ThallionDarkshine