Dead but not deceased
Location: I'm lurking right behind you ;)
States : Auto-Life Version: 3.5 By: Kain Nobel Introduction This is a script which allows you to provide an Auto-Life effect to certain states. If a battler is inflicted with one of these auto-life states, when they die they'll imediately be brought back to life with a designated direct/percent of HP and/or SP restored. Also, this applies to both actors and enemies, so your baddies can inflict autolife states on each other as well ;)
Features Make states which have an autolife effect When battler dies, their HP (and possibly SP) can be restored Can set what kind of HP/SP is restored (direct/percent) when battler is revived with state The battle won't end if your last person dies with an autolife state Can set the font name and size and text for autolife damage pop Can set the main and background color of autolife damage pop Script
States : Auto Life (Updated 2009.08.12)
Spoiler
#=============================================================================== # ** States : Auto-Life #=============================================================================== #------------------------------------------------------------------------------- # * SDK Log #------------------------------------------------------------------------------- if Object .const_defined ?( :SDK ) SDK.log ( 'States.Auto-Life' , 'Kain Nobel ©' , 3.5 , '2009.08.12' ) end #=============================================================================== # ** RPG::State::AutoRevive #=============================================================================== module RPG::State::AutoRevive #----------------------------------------------------------------------------- # * State IDs #----------------------------------------------------------------------------- State_IDs = [ ] #----------------------------------------------------------------------------- # * Damage String displayed during Auto-Revive animation #----------------------------------------------------------------------------- DisplayText = "Auto-Revive!" #----------------------------------------------------------------------------- # * Font Name for damage display #----------------------------------------------------------------------------- Font_Name = "Arial Black" #----------------------------------------------------------------------------- # * Font Size for damage display #----------------------------------------------------------------------------- Font_Size = 40 #----------------------------------------------------------------------------- # * Color for text background #----------------------------------------------------------------------------- Color_Back = Color .new ( 255 , 255 , 0 ) #----------------------------------------------------------------------------- # * Color for text face #----------------------------------------------------------------------------- Color_Main = Color .new ( 255 ,255 ,255 ) #----------------------------------------------------------------------------- # * Animation # state_id => animation_id #----------------------------------------------------------------------------- Animation_ID = 26 #----------------------------------------------------------------------------- # * HP Percent Recovered from Auto-Revive state # state_id => value (Integer) #----------------------------------------------------------------------------- HP_Percent = { } #----------------------------------------------------------------------------- # * HP Directly Recovered from Auto-Revive state # state_id => value (Integer) #----------------------------------------------------------------------------- HP_Direct = { } #----------------------------------------------------------------------------- # * SP Percent Recovered from Auto-Revive state # state_id => value (Integer) #----------------------------------------------------------------------------- SP_Percent = { } #----------------------------------------------------------------------------- # * SP Directly Recovered from Auto-Revive state # state_id => value (Integer) #----------------------------------------------------------------------------- SP_Direct = { } #----------------------------------------------------------------------------- # * Is this state auto-removed when battler is revived? # state_id => true / false #----------------------------------------------------------------------------- AutoRemove = { #17 => false } #----------------------------------------------------------------------------- # * Item to lose, if it applies to this state # state_id => [item_id, quantity] # state_id => item_id #----------------------------------------------------------------------------- LoseItem = { } #----------------------------------------------------------------------------- # * Default Settings #----------------------------------------------------------------------------- HP_Percent.default = 0 SP_Percent.default = 0 HP_Direct.default = 0 SP_Percent.default = 0 AutoRemove.default = true LoseItem.default = 0 end #=============================================================================== # ** RPG::State #=============================================================================== class RPG::State #----------------------------------------------------------------------------- # * Autolife ? #----------------------------------------------------------------------------- def autolife? AutoRevive::State_IDs .include ?( id) end #----------------------------------------------------------------------------- # * Autolife HP #----------------------------------------------------------------------------- def autolife_hp( max) value = 0 if AutoRevive::HP_Percent [ id] .is_a ?( Numeric ) if AutoRevive::HP_Percent [ id] > 0 value = max * ( AutoRevive::HP_Percent [ id] / 100.0 ) end end if AutoRevive::HP_Direct [ id] .is_a ?( Numeric ) value += AutoRevive::HP_Direct [ id] end Integer ( [ value, 1 ] .max ) end #----------------------------------------------------------------------------- # * Autolife SP #----------------------------------------------------------------------------- def autolife_sp( max) value = 0 if AutoRevive::SP_Percent [ id] .is_a ?( Numeric ) if AutoRevive::SP_Percent [ id] > 0 value = max * ( AutoRevive::SP_Percent [ id] / 100.0 ) end end if AutoRevive::SP_Direct [ id] .is_a ?( Numeric ) value += AutoRevive::SP_Direct [ id] end Integer ( value) end #----------------------------------------------------------------------------- # * Autolife Remove? #----------------------------------------------------------------------------- def autolife_remove? ( autolife? && AutoRevive::AutoRemove [ id] ) end #----------------------------------------------------------------------------- # * Autolife Item ID? #----------------------------------------------------------------------------- def autolife_item_id? item = AutoRevive::LoseItem [ id] if item.is_a ?( Array ) item = item[ 0 ] end ( item.is_a ?( Integer ) ? item : false ) end #----------------------------------------------------------------------------- # * Autolife Item Quant? #----------------------------------------------------------------------------- def autolife_item_quant? return 0 unless autolife_item_id? quant = 0 if AutoRevive::LoseItem [ id] .is_a ?( Array ) quant = AutoRevive::LoseItem [ id] [ 1 ] end ( quant.is_a ?( Integer ) ? quant : 1 ) end end #=============================================================================== # ** RPG::Sprite #=============================================================================== class RPG::Sprite #----------------------------------------------------------------------------- # * Alias Listing #----------------------------------------------------------------------------- alias_method :autolife_rpgsprite_damage , :damage #----------------------------------------------------------------------------- # * Damage #----------------------------------------------------------------------------- def damage( value, critical) if value != RPG::State::AutoRevive::DisplayText autolife_rpgsprite_damage( value, critical) return end dispose_damage bitmap = Bitmap .new ( 160 , 48 ) bitmap.font .name = RPG::State::AutoRevive::Font_Name bitmap.font .size = RPG::State::AutoRevive::Font_Size bitmap.font .color = RPG::State::AutoRevive::Color_Back bitmap.draw_text ( -1 , 12 -1 , 160 , 36 , value, 1 ) bitmap.draw_text ( -1 , 12 +1 , 160 , 36 , value, 1 ) bitmap.draw_text ( 1 , 12 -1 , 160 , 36 , value, 1 ) bitmap.draw_text ( 1 , 12 +1 , 160 , 36 , value, 1 ) bitmap.font .color = RPG::State::AutoRevive::Color_Main bitmap.font .size = RPG::State::AutoRevive::Font_Size * 0.9 bitmap.draw_text ( 0 , 12 , 160 , 36 , value, 1 ) @_damage_sprite = ::Sprite .new ( self .viewport ) @_damage_sprite .bitmap = bitmap @_damage_sprite .ox = 80 @_damage_sprite .oy = 0 @_damage_sprite .x = self .x @_damage_sprite .y = self .y - self .oy / 2 @_damage_sprite .z = 10000 @_damage_duration = 40 end end #=============================================================================== # ** Game_Battler #=============================================================================== class Game_Battler #----------------------------------------------------------------------------- # * Autolife Effect #----------------------------------------------------------------------------- def autolife_effect return unless self .autolife_dead ? @states .each do |state_id| state = $data_states [ state_id] next unless state.is_a ?( RPG::State ) next unless ( state.zero_hp || state.autolife ?) if self .is_a ?( Game_Actor ) item, quant = state.autolife_item_id ?, state.autolife_item_quant ? if item && quant > 0 next unless $game_party .item_number ( item) >= quant end $game_party .lose_item ( item, quant) end if state.autolife ? self .hp += state.autolife_hp ( maxhp) self .sp += state.autolife_sp ( maxsp) end remove_state( state.id , true ) if state.autolife_remove ? end self .animation_id = RPG::State::AutoRevive::Animation_ID self .damage = RPG::State::AutoRevive::DisplayText self .damage_pop = true end #----------------------------------------------------------------------------- # * Autolife State ? #----------------------------------------------------------------------------- def autolife_state? @states .each { |i| return true if $data_states [ i] .autolife ?} false end #----------------------------------------------------------------------------- # * Autolife Dead ? #----------------------------------------------------------------------------- def autolife_dead? self .dead ? && self .autolife_state ? end end #=============================================================================== # ** Game_Party #=============================================================================== class Game_Party #----------------------------------------------------------------------------- # * Alias Listing #----------------------------------------------------------------------------- alias_method :autolife_gmparty_alldead ?, :all_dead ? #----------------------------------------------------------------------------- # * All Dead ? #----------------------------------------------------------------------------- def all_dead? @actors .each { |a| return false if a.autolife_state ?} autolife_gmparty_alldead? end #----------------------------------------------------------------------------- # * Autolife Effect #----------------------------------------------------------------------------- def autolife_effect @actors .each { |a| if a.autolife_dead ? ; a.autolife_effect ; end } end end #=============================================================================== # ** Game_Troop #=============================================================================== class Game_Troop #----------------------------------------------------------------------------- # * Autolife Effect #----------------------------------------------------------------------------- def autolife_effect @enemies .each { |e| if e.autolife_dead ? ; e.autolife_effect ; end } end end #=============================================================================== # ** Scene_Battle #=============================================================================== class Scene_Battle < SDK::Scene_Base #----------------------------------------------------------------------------- # * Alias Methods #----------------------------------------------------------------------------- alias_method :autolife_snbattle_judge , :judge #----------------------------------------------------------------------------- # * Judge #----------------------------------------------------------------------------- def judge if judging_autolife? $game_troop .autolife_effect $game_party .autolife_effect @status_window .refresh end autolife_snbattle_judge end #----------------------------------------------------------------------------- # * Judging Autolife ? #----------------------------------------------------------------------------- def judging_autolife? $game_party .actors .each { |a| return true if a.autolife_dead ?} $game_troop .enemies .each { |e| return true if e.autolife_dead ?} false end end Expand to see the code.
Instructions Place Above Main and Below SDK (only if using), this script DOES NOT require SDK but will log if SDK is present.
FAQ Coming soon if any confusion arrives.
Compatibility Compatible with or without SDK, might or might not work with certain CBS/ABS systems depending on how they're coded.
This script aliases the following methods...
Spoiler
Game_Party.all_dead? Scene_Battle.judge
Terms and Conditions Another "Free to use in commercial and non-commercial games" script, but please don't forget to credit yours truely
Last edited by Kain Nobel on Tue Aug 11, 2009 7:01 pm, edited 3 times in total.