Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Zare on December 30, 2009, 04:34:51 pm

Title: Tons of Addons - Auto Revive - Please Help me^^ [Resolved]
Post by: Zare on December 30, 2009, 04:34:51 pm
Hey^^ I have the auto revive skill from the tons of addons scripts.
My problem: When i equip an item(ring, shield) with auto-revive, and the char dies, auto revive
revives the char every time he dies. But i want it only to revive the char one time per battle. how can this be done?

Here's the script:

"Auto Revive": ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Auto-Revive Status Effect by Blizzard
# Version: 1.25b
# Type: Game Experience Improvement
# Date: 5.6.2006
# Date v1.2b: 14.11.2006
# Date v1.21b: 12.1.2007
# Date v1.22b: 13.11.2007
# Date v1.23b: 19.11.2007
# Date v1.24b: 10.12.2007
# Date v1.25b: 19.10.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# new in v1.2b:
#   - less and better code, much more compatible, easier to use
#
# new in v1.21b:
#   - removed an obsolete constant
#
# new in v1.22b:
#   - now possible to have more than one Auto-Revive status effect
#
# new in v1.23b:
#   - fixed bug where game over would be automatically initiated when in battle
#
# new in v1.24b:
#   - fixed bug due to typing mistake
#
# new in v1.25b:
#   - fixed bug with RTAB
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

AUTO_REVIVE_IDS = [28] # IDs of status effects
REVIVE_ANIMATION_ID = 25 # ID of the Revive animation
REVIVE_TEXT = 'Schutzengel!' # text displayed
DEAD_ID = 1 # ID of the "dead" status effect

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#==============================================================================
# Game_Party
#==============================================================================

class Game_Party

 alias all_dead_autorevive_later? all_dead?
 def all_dead?
   if $game_system.AUTO_REVIVE && (@actors.any? {|a| AUTO_REVIVE_IDS.any? {|i|
       a.states.include?(i)}})
     return false
   end
   return all_dead_autorevive_later?
 end

end

#==============================================================================
# Sprite
#==============================================================================

class RPG::Sprite
 
 alias damage_regen_later damage
 def damage(damage, critical, type = nil)
   if damage == REVIVE_TEXT
     dispose_damage
     bitmap = Bitmap.new(160, 48)
     bitmap.font.name, bitmap.font.size = 'Kartika', 32
     bitmap.font.color.set(0, 0, 0)
     bitmap.draw_text_shaded_later(-1, 12-1, 160, 36, REVIVE_TEXT, 1)
     bitmap.draw_text_shaded_later(-1, 12+1, 160, 36, REVIVE_TEXT, 1)
     bitmap.draw_text_shaded_later(1, 12-1, 160, 36, REVIVE_TEXT, 1)
     bitmap.draw_text_shaded_later(1, 12+1, 160, 36, REVIVE_TEXT, 1)
     bitmap.font.color.set(0, 192, 255)
     bitmap.font.size = 32
     bitmap.draw_text_shaded_later(0, 12, 160, 36, REVIVE_TEXT, 1)
     @_damage_sprite = ::Sprite.new(self.viewport)
     @_damage_sprite.bitmap = bitmap
     @_damage_sprite.ox, @_damage_sprite.oy = 80, 20
     @_damage_sprite.x, @_damage_sprite.y = self.x, self.y-self.oy/2
     @_damage_sprite.z, @_damage_duration = 3000, 40
   elsif type != nil
     damage_regen_later(damage, critical, type)
   else
     damage_regen_later(damage, critical)
   end
 end

end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle

 alias judge_autorevive_later judge
 def judge
   if $game_system.AUTO_REVIVE
     flag = false
     $game_party.actors.each {|actor|
         if actor.hp == 0 && AUTO_REVIVE_IDS.any? {|i| actor.states.include?(i)}
           actor.hp += actor.maxhp / 5
           (AUTO_REVIVE_IDS + [DEAD_ID]).each {|i| actor.remove_state(i)}
           actor.animation_id, actor.damage = REVIVE_ANIMATION_ID, REVIVE_TEXT
           actor.damage_pop = flag = true
         end}
     @status_window.refresh if flag
   end
   return judge_autorevive_later
 end

end



Please help me^^

Oh and i am using rmxp^^
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Blizzard on December 30, 2009, 04:52:43 pm
You need a script that changes the auto-status function. Instead of forcing the status over and over, it should inflict the status once at the beginning of the battle.
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Zare on December 30, 2009, 05:23:56 pm
ok first of all thx for your fast answer^^ is there a script like that? if not, i think it can be done
in a script, should be not to hard, but i am not a scripter^^ maybe someone could help me.
I think it should be like this:
if any actor has armor id (for example 6) equipped, add this actor state 28
end

and this line (in ruby language xD) could be added to the start of the battlephase, somewhere at the start of scene_battle.
so could someone translate this to ruby?
ty^^
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Blizzard on December 30, 2009, 05:40:43 pm
I don't know if there already is script for that, but I did that in my own game. It's really simple, even for somebody who doesn't have so much experience in scripting. *looks at game_guy*
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Zare on December 30, 2009, 06:01:05 pm
The problem is that i don't even know the words for this, for example any actor or equipped armor 6^^
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Zare on January 02, 2010, 01:58:08 pm
Blizz, could you post your solution of this prob plz?  :n00b:
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Blizzard on January 02, 2010, 03:09:50 pm
Eh, the mod is integrated into my game. But this code should do:

class Game_Actor
 def add_auto_states
   armors = []
   armors.push($data_armors[@armor1_id])
   armors.push($data_armors[@armor2_id])
   armors.push($data_armors[@armor3_id])
   armors.push($data_armors[@armor4_id])
   armors.compact!
   armors.each {|armor| remove_state(armor.auto_state_id)}
   armors.each {|armor| add_state(armor.auto_state_id)}
 end
 def update_auto_state(old_armor, new_armor)
 end
end

class Scene_Battle
 alias main_auto_state_mod_later main
 def main
   (1...$data_actors.size).each {|i| $game_actors[i].add_auto_states}
   main_auto_state_mod_later
 end
end


You should make the states disappear after the end of the battle.

EDIT: Just to make sure, this works for all states, not just the Auto-Revive state.
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Zare on January 02, 2010, 03:51:39 pm
great! just tried it and it works, but i don't know where to input the armor ids, so now every actor has the state auto revive^^
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Blizzard on January 02, 2010, 04:05:08 pm
Do you want this only for Auto-Revive? That's easy. Just use this instead:

class Game_Actor
 def add_auto_states
   armors = []
   armors.push($data_armors[@armor1_id])
   armors.push($data_armors[@armor2_id])
   armors.push($data_armors[@armor3_id])
   armors.push($data_armors[@armor4_id])
   armors.compact!
   ids = []
   armors.each {|armor| ids.push(armor.auto_state_id)}
   (ids & AUTO_REVIVE_IDS).each {|id|
       remove_state(id)
       add_state(id)}
 end
 alias add_state_auto_state_mod_later add_state
 def add_state(id, forced = false)
   return false if AUTO_REVIVE_IDS.include?(id) if forced
   return add_state_auto_state_mod_later(id, forced = false)
 end
end

class Scene_Battle
 alias main_auto_state_mod_later main
 def main
   (1...$data_actors.size).each {|i| $game_actors[i].add_auto_states}
   main_auto_state_mod_later
 end
end


No need to set up anything. It does everything automatically. It will all states like before. Only the Auto-Revive states will be added only once at the beginning of the battle.
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Zare on January 02, 2010, 04:29:37 pm
yes right, just for auto revive. so now it works almost xD the actor has auto revive at the begin of the battle. then he dies but nothing happens. he keeps dead. i think it releases the state to early.

EDIT: Just realized:

Any other actor has auto life instead, everytime they die they will be revived Oo but the state icon isn't shown
Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Blizzard on January 02, 2010, 05:30:39 pm
My bad.

class Game_Actor
 def add_auto_states
   armors = []
   armors.push($data_armors[@armor1_id])
   armors.push($data_armors[@armor2_id])
   armors.push($data_armors[@armor3_id])
   armors.push($data_armors[@armor4_id])
   armors.compact!
   ids = []
   armors.each {|armor| ids.push(armor.auto_state_id)}
   (ids & AUTO_REVIVE_IDS).each {|id|
       remove_state(id)
       add_state(id)}
 end
 alias add_state_auto_state_mod_later add_state
 def add_state(id, forced = false)
   return false if AUTO_REVIVE_IDS.include?(id) && forced
   return add_state_auto_state_mod_later(id, forced)
 end
end

class Scene_Battle
 alias main_auto_state_mod_later main
 def main
   (1...$data_actors.size).each {|i| $game_actors[i].add_auto_states}
   main_auto_state_mod_later
 end
end

Title: Re: Tons of Addons - Auto Revive - Please Help me^^
Post by: Zare on January 02, 2010, 05:45:17 pm
works perfect, ty so much^^