public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

A fixnum turning into nil.

BMM_Archive · July 15, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: A fixnum turning into nil.
  • Original author: jonathan4210
  • Original date: July 26, 2016
  • Source thread: https://forums.rpgmakerweb.com/threads/a-fixnum-turning-into-nil.65936/
  • Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSSx Script Support

Summary

In my game, where I use Moghunter's Action Battle System script, there's these 2 states I've added that when the player receives both and when you attack/get hit, I get an error. It appears that some variable gets turned to nil, and when the script checks the loop time of a state, it crashes. I'll attach the error message, the code, and the 2 states from the database. One state is repeatedly healing your SP (energetic), and the other is repeatedly taking away HP (burn). If you have any questions, please...

Archived First Post

In my game, where I use Moghunter's Action Battle System script, there's these 2 states I've added that when the player receives both and when you attack/get hit, I get an error. It appears that some variable gets turned to nil, and when the script checks the loop time of a state, it crashes. I'll attach the error message, the code, and the 2 states from the database. One state is repeatedly healing your SP (energetic), and the other is repeatedly taking away HP (burn).


If you have any questions, please ask.


Protected download


Protected download


Protected download


Protected download


Here is the rest of the code in case:



Spoiler



#==============================================================================
# ■ Game Character
#==============================================================================
class Game_Character
  
 #--------------------------------------------------------------------------
 # ● Display Damage
 #--------------------------------------------------------------------------    
 def display_damage(value) 
     self.battler.damage = value
     self.battler.damage_pop = true   
 end  
  
 #--------------------------------------------------------------------------
 # ● Update Counter
 #--------------------------------------------------------------------------
 def update_counter
     return if self.battler.is_a?(Game_Actor)
     if self.battler.xas_counter_time > 0 
        self.battler.xas_counter_time -= 1       
        if self.battler.xas_counter_time == 0        
           display_damage(XAS_BA_ENEMY::COUNTER_TEXT) 
           counter_action = XAS_BA_ENEMY::COUNTER_ACTION[self.battler.id]
           turn_toward_player
           if counter_action != nil
              counter_id = counter_action[rand(counter_action.size)]  
              self.shoot(counter_id)
           elsif XAS_BA_ENEMY::COUNTER_SAME_ACTION.include?(self.battler.id)
              self.shoot(self.battler.xas_counter_skill_id)        
           end    
        end   
     end 
 end


 #--------------------------------------------------------------------------
 # ● Update Final Attack 
 #--------------------------------------------------------------------------
 def update_final_attack
     return unless self.dead?
     return if self.battler.last_attack_time == 0 
     self.battler.last_attack_time -= 1
     if  self.battler.last_attack_time == 0
         last_attack = XAS_BA_ENEMY::ENEMY_FINAL_ATTACK[self.battler.id]
         last_attack_id = last_attack[rand(last_attack.size)]        
         self.shoot(last_attack_id)
         self.battler.damage = XAS_BA_ENEMY::FINAL_ATTACK_TEXT
         self.battler.damage_pop = true           
    end
 end  
 
 #--------------------------------------------------------------------------
 # ● Update Statespopup 
 #--------------------------------------------------------------------------
 def update_statespopup
     if self.battler.xas_states_pop_time > 0
        self.battler.xas_states_pop_time -= 1 
        if self.battler.xas_states_pop_time == 0
           self.battler.damage = self.battler.xas_states_pop_text
           self.battler.damage_pop = true   
           self.battler.state = true
        end   
     end  
 end  
 
 #--------------------------------------------------------------------------
 # ● Enable States Effect
 #--------------------------------------------------------------------------  
 def states_effects(state)  
   if self.battler.state_sleep and not self.knockbacking?
      self.need_refresh_pose = true  
   end     
   #Poison HP
   if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT:OISON_HP))  
      dam_per = state.shock_release_prob
      damage_value = self.battler.maxhp * dam_per / 100
      self.battler.hp -= damage_value
      display_damage(damage_value) 
   #Regen HP
   elsif state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::REGEN_HP))   
      dam_per = state.shock_release_prob
      damage_value = self.battler.maxhp * -dam_per / 100      
      self.battler.hp -= damage_value
      #display_damage(damage_value)
   end     
   #Poison SP 
   if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT:OISON_SP))  
      dam_per = state.shock_release_prob
      damage_value = self.battler.maxsp * dam_per / 100
      self.battler.sp -= damage_value
      value = $data_system.words.sp.to_s + " " + damage_value.to_s
      display_damage(value)        
   #Regen SP
   elsif state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::REGEN_SP))  
      dam_per = state.shock_release_prob
      damage_value = self.battler.maxsp * -dam_per / 100
      self.battler.sp -= damage_value
      value = $data_system.words.sp.to_s + " " + damage_value.to_s
      display_damage(value)        
   end    
   #Deathcount
   if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT:EATHCOUNT))  
      self.battler.state_time[state.id] -= 100
      death_number = self.battler.state_time[state.id] / 100
       if death_number > 0   
         display_damage(XAS:EATHCOUNT_TEXT_COUNT.to_s + death_number.abs.truncate.to_s) 
      else  
         self.battler.hp = 0 if self.battler.is_a?(Game_Enemy)  
         $scene = Scene_Gameover.new if self.battler.is_a?(Game_Actor)  
      end
   end
 end
   
 #--------------------------------------------------------------------------
 # ● Status Effect Update
 #--------------------------------------------------------------------------
 def update_status_effect
     update_counter    
     if self.battler.states.size == 0  
        self.battler.state_move_speed = 0
        return
     end  
     self.battler.remove_states_auto
     for i in self.battler.states
         state = $data_states  

         return if state == nil


         if self.battler.state_loop_effect_time
== nil

            self.battler.remove_state(state.id) 


            return


         end  


         #Make Effects    


         self.battler.state_loop_effect_time
+= 1

         if self.battler.state_loop_effect_time
> self.battler.state_loop_speed

            self.battler.state_loop_effect_time
= 0

            self.animation_id = state.animation_id


            states_effects(state)          


         end       


         #Remove State-------


         unless state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT:EATHCOUNT))  


            self.battler.state_time
-= 1

            if self.battler.state_time
<= 0     

               self.battler.remove_state(state.id) 


               self.need_refresh_pose = true  


            end      


         end 


     end 


     update_statespopup   


 end


   


end





#===============================================================================


# ■ Game_Battler


#===============================================================================


class Game_Battler


   attr_accessor :state_time  


   attr_accessor :state_loop_effect_time  


   attr_accessor :state_loop_speed


   attr_accessor :state_move_speed


   attr_accessor :stop


   attr_accessor :state_sleep


   attr_accessor :state_berserk


   attr_accessor :state_drain


   attr_accessor :state_invincible


   attr_accessor :state_life


   attr_accessor :state_seal_attack


   attr_accessor :state_seal_skill


   attr_accessor :state_seal_item


   attr_accessor :state_mute


   attr_accessor :state_ctup   


   attr_accessor :state_ctdown


   attr_accessor :state_confuse


   attr_accessor :state_reflect


   attr_accessor :state_death_count


   attr_accessor :state_cancel_sensor


   attr_accessor :state_pose_refresh


   attr_accessor :after_damage_pop


   attr_accessor :after_damage_pop_time


   attr_accessor :after_animation_time


   attr_accessor :after_animation_id


  


  #--------------------------------------------------------------------------


  # * Object Initialization


  #--------------------------------------------------------------------------


  alias states_initialize initialize


  def initialize


      @state_time = []


      @state_loop_effect_time = []


      @state_loop_speed = []


      @state_move_speed = 0


      @stop = false


      @state_sleep = false


      @state_drain = false


      @state_invincible = false


      @state_life = false


      @state_berserk = false


      @state_seal_attack = false


      @state_seal_skill = false


      @state_seal_item = false


      @state_death_count = true


      @state_mute = false


      @state_ctup = false   


      @state_ctdown = false      


      @state_confuse = false


      @state_reflect = false


      @state_cancel_sensor = false


      @state_pose_refresh = false


      @after_damage_pop = ""


      @after_damage_pop_time = 0


      @after_animation_time = 0


      @after_animation_id = 0   


      states_initialize


  end 





  #--------------------------------------------------------------------------


  # ● Add State Effect


  #--------------------------------------------------------------------------  


  def add_state_effect(state)    


      add_state_popup(state.id)  


      @state_time[state.id] = $data_states[state.id].hold_turn


      @state_loop_effect_time[state.id] = 0 


      @state_loop_speed[state.id] = $data_states[state.id].auto_release_prob


     #Cancel Sensor


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SENSOR_0))


        self.state_cancel_sensor = true


     end          


     #Reflect


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::REFLECT))


        self.state_reflect = true


     end        


     #Drain


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT:RAIN_STATE))


        self.state_drain = true


     end  


     #Drain


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::INVINCIBLE))


        self.state_invincible = true


     end       


     #Life


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::LIFE))


        self.state_life = true


     end       


     #Berserk


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::BERSERK))


        self.state_berserk = true


     end 


     #Mute


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::MUTE))


        self.state_mute = true     


     end


     #Seal Attack


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SEALATTACK))


        self.state_seal_attack = true


     end 


     #Seal Skill


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SEALSKILL))


        self.state_seal_skill = true


     end 


     #Seal Item


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SEALITEM))


        self.state_seal_item = true


     end      


     #CT UP


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::CTUP))


        self.state_ctup = true


     end   


     #CT DOWN


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::CTDOWN))


        self.state_ctdown = true


     end       


     #Stop


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::STOP))


        $game_player.reset_pickup if self.is_a?(Game_Actor)


        self.stop = true


     end   


     #Sleep   


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SLEEP))


        $game_player.reset_pickup if self.is_a?(Game_Actor)


        self.state_sleep = true   


     end   


     #Slow   


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SLOW))  


        self.state_move_speed = -1  


     end   


     #Fast


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::FAST))    


        self.state_move_speed = 1


     end


     #Confuse


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::CONFUSE))


        self.state_confuse = true


     end


  end


   


  #--------------------------------------------------------------------------


  # ● Remove State Effect


  #--------------------------------------------------------------------------  


  def remove_state_effect(state)   


      remove_state_popup(state.id)         


      @state_time.delete(state.id)


      @state_loop_effect_time.delete(state.id)


      @state_loop_speed.delete(state.id)


     #Cancel Sensor


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SENSOR_0))


        self.state_cancel_sensor = false


     end          


     #Reflect


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::REFLECT))


        self.state_reflect = false


     end        


     #Drain


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT:RAIN_STATE))


        self.state_drain = false


     end  


     #Drain


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::INVINCIBLE))


        self.state_invincible = false


     end       


     #Life


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::LIFE))


        self.state_life = false


     end       


     #Berserk


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::BERSERK))


        self.state_berserk = false


     end 


     #Mute


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::MUTE))


        self.state_mute = false    


     end


     #Seal Attack


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SEALATTACK))


        self.state_seal_attack = false


     end 


     #Seal Skill


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SEALSKILL))


        self.state_seal_skill = false


     end 


     #Seal Item


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SEALITEM))


        self.state_seal_item = false      


     end 


     #CT UP


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::CTUP))


        self.state_ctup = false


     end   


     #CT DOWN


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::CTDOWN))


        self.state_ctdown = false


     end       


     #Stop


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::STOP))


        self.stop = false


     #Sleep 


     end


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SLEEP))


        self.state_sleep = false 


     end   


     #Slow   


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::SLOW))  


        self.state_move_speed = 0


     end   


     #Fast


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::FAST))    


        self.state_move_speed = 0


     end


     #Confuse


     if state.guard_element_set.include?($data_system.elements.index(XAS_ELEMENT::CONFUSE))


        self.state_confuse = false


     end    


  end  


  


  #--------------------------------------------------------------------------


  # ● Remove State Popup


  #--------------------------------------------------------------------------


  def remove_state_popup(state_id)


      self.state = true


      self.after_damage_pop_time = 1


      self.after_damage_pop = "status_minus" + $data_states[state_id].name  


  end  


  


  #--------------------------------------------------------------------------


  # ● Add State Popup


  #--------------------------------------------------------------------------


  def add_state_popup(state_id) 


      @xas_states_pop_time = 15


      @xas_states_pop_text = "status_plus" + $data_states[state_id].name         


  end    


  


  #--------------------------------------------------------------------------


  # * Add State


  #--------------------------------------------------------------------------


  def add_state(state_id, force = false)


      return if $data_states[state_id] == nil


      unless force


      for i in @states


        if $data_states
.minus_state_set.include?(state_id) and

           not $data_states[state_id].minus_state_set.include?(i)


          return


        end


      end


    end


    unless state?(state_id)


      @states.push(state_id)


      if $data_states[state_id].zero_hp


        @hp = 0


      end


      for i in 1...$data_states.size


        if $data_states[state_id].plus_state_set.include?(i)


          add_state(i)


          state = $data_states
 

          add_state_effect(state) 


        end


        if $data_states[state_id].minus_state_set.include?(i)


          remove_state(i)


        end


      end


      @states.sort! do |a, b|


        state_a = $data_states[a]


        state_b = $data_states


        if state_a.rating > state_b.rating


          -1


        elsif state_a.rating < state_b.rating


          +1


        elsif state_a.restriction > state_b.restriction


          -1


        elsif state_a.restriction < state_b.restriction


          +1


        else


          a <=> b


        end


      end


    end


    if force


      @states_turn[state_id] = -1


    end


    unless  @states_turn[state_id] == -1


      @states_turn[state_id] = $data_states[state_id].hold_turn


    end


    unless movable?


      @current_action.clear


    end


    @hp = [@hp, self.maxhp].min


    @sp = [@sp, self.maxsp].min


  end


  


  #--------------------------------------------------------------------------


  # * Remove State


  #--------------------------------------------------------------------------


  def remove_state(state_id, force = false)


    if state?(state_id)


       return if @states_turn[state_id] == -1 and not force


       if @hp == 0 and $data_states[state_id].zero_hp


        zero_hp = false


        for i in @states


          if i != state_id and $data_states
.zero_hp

            zero_hp = true


          end


        end


        if zero_hp == false


          @hp = 1


        end


      end


      @states.delete(state_id) 


      @states_turn.delete(state_id)


      state = $data_states[state_id]      


      remove_state_effect(state) #Edit   


    end


    @hp = [@hp, self.maxhp].min


    @sp = [@sp, self.maxsp].min


  end  


  


end











 

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download

Referenced Images / Attachments

Error.PNG
Error.PNG
Energetic.PNG
Energetic.PNG
Code.PNG
Code.PNG
Burn.PNG
Burn.PNG
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#poison#regen#display_damage#deathcount

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar