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.

Revive actor when dead if variable five is more than 0

Jonny

Member

I'm trying to make it so that an actor gets revived when he dies if variable 5 is greater than 0. I'm using the scripts: xrxs tales of symphonia abs and game over when actor dies. I tried editing the game over when actor dies script so that it has this:
Code:
Actor_ID = 1

class Game_Actor
  #--------------------------------------------------------------------------
  # * Change HP
  #     hp : new HP
  #--------------------------------------------------------------------------
  def hp=(hp)
    @hp = [[hp, maxhp].min, 0].max
    
    # add or exclude incapacitation
    for i in 1...$data_states.size
      if $data_states[i].zero_hp
        if self.dead?
#start editing
            if $game_variables[5] > 0
              actor.hp += actor.maxhp
             $game_variables[5] -= 1
           else
#end editing
        if @actor_id == Actor_ID
            $game_temp.gameover = true
        return
    end
#start editing
   end
#end editing
          add_state(i)
        else
          remove_state(i)
        end
      end
    end
  end
end

But I get an error:
Script 'Game Over when actor dies' line 21:NameError occured.
undefined local variable or method `actor' for #<Game_Actor:0x3d200a0>
 

Jonny

Member

If I change
Code:
actor.hp += actor.maxhp
to
Code:
@hp += @maxhp
I get the error:
Script 'Game Over when actor dies' line 21:TypeError occurred
nil can't be coerced into Fixnum

Which to me is a string of words that I don't understand.:thumb:
 

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