another status instead of death

Feli

Veteran
Veteran
Joined
Jan 12, 2013
Messages
37
Reaction score
5
First Language
portuguese
Primarily Uses
RMVXA
Hello guys! I wonder if anyone knows a way for this script to add another status instead of death, when hunger reaches 0 ... thanks!

Obs.: script in portuguese...

Code:
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#                             Script de Fome                       
#|Autor: RD12|         
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# A fome vai de 0 a 100, quanto maior o valor mais com fome o membro estará
# Se a fome chegar no 100 o membro irá fifcar com hp=0 (morre)
#
# Para um item diminuir a fome bote em sua Nota: -fome valor
# E para um item aumentar a fome, bote na nota: +fome valor

module Fome
  #Tempo em segundos que irá aumentar a fome
  Segundos = 5
  #Valor que irá aumentar de fome para cada personagem
  Actor = []#Declara a var
  Actor[0] = 9 #Primeiro personagem
  Actor[1] = 6 #Segundo
  Actor[2] = 4 #Terceiro
  Actor[3] = 11#Quarto
  #Actor[4] = 11#Quinto
 
  #Modifique a posição da Hud aqui
  HUDs_x = 1
  HUDs_y = 190
end

#===========================================================================================
#Hud da fome dos jogadores
class Hud_Fome < Sprite
  def initialize
    super
    self.bitmap = bitmap = Bitmap.new(100,300)
    self.bitmap.font.size = 14
    self.bitmap.font.name = "Segoe UI"
    self.x = Fome::HUDs_x
    self.y = Fome::HUDs_y
    refresh
  end
  
  def update
    super
    refresh
  end
 
  def refresh
    self.bitmap.clear
    for i in 0..$game_party.members.size-1
      @actor = $game_party.members
      base = Cache.picture("Fome_Base")
      rect = Rect.new(0,0,base.width,base.height)
      self.bitmap.blt(10,21+30*i,base,rect)
      self.bitmap.draw_text(10, 30*i, 100, 32, @actor[i].name, 0)
      if @actor[i].fome >= 100
         @actor[i].hp = 0
         hud_name = "Fome_100"
       else
         hud_name = "Fome_Hud"
      end
      base = Cache.picture(hud_name)
      rect = Rect.new(0,0,base.width * @actor[i].fome / 100,base.height)
      self.bitmap.blt(10,21+30*i,base,rect)
     end
  end
end

#===========================================================================================
#Atualiza a Hud e Aumenta a fome de acordo com o tempo configurado
class Scene_Map
  alias rd12_main main
  def main
    $Fome = Hud_Fome.new
    @segundos = 0
    rd12_main
    $Fome.dispose
  end
  alias rd12_update update
  def update
    if Graphics.frame_count % 60 == 0
      @segundos += 1
    end
    if @segundos == Fome::Segundos
     for i in 0..$game_party.members.size-1
      $game_party.members[i].fome = (Fome::Actor[i])
     end
    @segundos = 0
    end
    rd12_update
  end
end

#===========================================================================================
#Adiciona a fome nos personagens
class Game_Actor < Game_Battler
  alias rd12_initialize initialize
  def initialize(actor_id)
    @fome = 0
    rd12_initialize(actor_id)
  end
 
  def fome=(arg)
   @fome = 0 if @fome == nil
   @fome += arg
   @fome = 0 if @fome < 0
   $Fome.refresh
  end
 
  def fome
   @fome
  end
end

#===========================================================================================
#Modifica o método para poder usar o item de fome
class Game_Battler < Game_BattlerBase
  def item_test(user, item)
    return false if item.for_dead_friend? != dead?
    return true if $game_party.in_battle
    return true if item.for_opponent?
    return true if item.damage.recover? && item.damage.to_hp? && hp < mhp
    return true if item.damage.recover? && item.damage.to_mp? && mp < mmp
    return true if item_has_any_valid_effects?(user, item)
    arg = item.note.split
    return true if arg[0] == "-fome" or arg[0] == "+fome"
    return false
 end
end

#===========================================================================================
#Modifica o método para ganhar ou perder Fome
class Scene_Item < Scene_ItemBase
  def use_item_to_actors
    item_target_actors.each do |target|
      arg = item.note.split
      if arg[0] == "-fome"
        target.fome = -arg[1].to_i
        #Mostra mensagem com a fome atual
        msgbox("Fome diminuída em -#{arg[1]}\n","Fome atual: #{target.fome}/100")
      end
      if arg[0] == "+fome"
        target.fome = arg[1].to_i
        #Mostra mensagem com a fome atual
        msgbox("Fome aumentada em +#{arg[1]}\n","Fome atual: #{target.fome}/100")
      end
      item.repeats.times { target.item_apply(user, item) }
    end
  end
end
#===========================================================================================
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,175
Reaction score
831
First Language
Hungarian
Primarily Uses
RMVXA
Change this method:
Code:
  def refresh
    self.bitmap.clear
    for i in 0..$game_party.members.size-1
      @actor = $game_party.members
      base = Cache.picture("Fome_Base")
      rect = Rect.new(0,0,base.width,base.height)
      self.bitmap.blt(10,21+30*i,base,rect)
      self.bitmap.draw_text(10, 30*i, 100, 32, @actor[i].name, 0)
      if @actor[i].fome >= 100
         @actor[i].hp = 0
         hud_name = "Fome_100"
       else
         hud_name = "Fome_Hud"
      end
      base = Cache.picture(hud_name)
      rect = Rect.new(0,0,base.width * @actor[i].fome / 100,base.height)
      self.bitmap.blt(10,21+30*i,base,rect)
     end
  end
To this:
Code:
  def refresh
    self.bitmap.clear
    for i in 0..$game_party.members.size-1
      @actor = $game_party.members
      base = Cache.picture("Fome_Base")
      rect = Rect.new(0,0,base.width,base.height)
      self.bitmap.blt(10,21+30*i,base,rect)
      self.bitmap.draw_text(10, 30*i, 100, 32, @actor[i].name, 0)
      if @actor[i].fome >= 100
         @actor[i].add_state(123)
         hud_name = "Fome_100"
       else
         @actor[i].remove_state(123)
         hud_name = "Fome_Hud"
      end
      base = Cache.picture(hud_name)
      rect = Rect.new(0,0,base.width * @actor[i].fome / 100,base.height)
      self.bitmap.blt(10,21+30*i,base,rect)
     end
  end
Change the state ID in the add_state and remove_state calls to the database ID of the state you want to use for this (I used 123 for it).
Disclaimer: I did not test any of this.
 

Feli

Veteran
Veteran
Joined
Jan 12, 2013
Messages
37
Reaction score
5
First Language
portuguese
Primarily Uses
RMVXA
I searched here a lot (even without being good with scripts) until I got a method to do it .. but yours is a little different. But I tested it here and it works too, including it complements what was missing for me, which was the removal of the status! Thanks! :LZSjoy:

EDIT: Is there any way to stop the script? Or at least disable the hud or the system for a while and then activate it again?
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

I turned 17 two months ago and I feel like I've grown (personality-wise) more in this 1 year than all the 16 years I had lived combined.
Ugh, I may have been cumbersomely eventing a bunch of stuff I could have easily done changing the tileset "Passage (4 dir)" and "Ladder" options. Oops :D
I have no idea why some of the program "splash screen" always on top. E.g, RMMZ loading screen stuck on the top blocking anything I want to do until it fully loaded. What is even the purpose?
One of the secret places in the game.
Had a dream last night that I died -- what a way to start the weekend! :'D

Forum statistics

Threads
107,639
Messages
1,031,071
Members
139,760
Latest member
MEATLOAFMAN
Top