Protection System
Descrizione
Questo script crea una tecnica che permette di proteggere un alleato da quasi tutti gli attacchi per un turno. Tutte le personalizzazioni si possono fare nello script attraverso la Configurazione.
È possibile scegliere quali abilità ignorano la protezione e tante altre piccole cose.
Autore
Avon Valentino (Io)
Allegati
DEMO LINK:
http://www.mediafire...urro3uudnr83dpw
SCRIPT LINK:
http://www.mediafire...ilmpeb8sksejfuu
#-------------------------------#PROTECTION SYSTEM#---------------------------- # # # # #Script creato da Valentino Avon #Se questo script viene utilizzato, per favore creditatemi ;) # #Questo script permette di difendere un alleato da quasi ogni attacco. #Tutto è personalizzabile nella sezione CONFIGURAZIONE. # # #--------------------------------#CONFIGURAZIONE#----------------------------- # #Se true la tecnica protezione sarà sempre la prima a essere eseguita nel corso #di una battaglia (se si vuole un utilizzo legato alla velocità del personaggio, #mettere false). FIRST_ACTION_PROTEZIONE = true # #ID Magie che ignorano la protezione (Magie status ad esempio) MAGIE_STATUS = [33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52] #id della classe con l'abilità di protezione. DIFENSORE = 9 #Nome dell'abilità visualizzata PROTEZIONE = "Proteggi" #nome visualizzato nell'uso della tecnica PROTEZIONE_HELP = "Protezione" #nome visualizzato quando un alleato viene protetto PROTEZIONE_AVVISO = "Protezione!" #permette la protezione anche dalle magie con target singolo (Mettere false se #non si vuole utilizzare) PROTEZIONE_MAGIE = true #animazione visualizzata quando un alleato viene protetto da un attacco fisico ATTACCO_ANIM = 64 #animazione visualizzata quando un alleato viene protetto da una magia MAGIE_ANIM = 65 #animazione visualizzata sull'alleato selezionato da proteggere USO_PROTEZIONE_ANIM = 64 #animazione visualizzata sul Difensore quando usa la tecnica PROTEZIONE_ANIM = 101 # # #--------------------------------#CONFIGURAZIONE#----------------------- #-----------------------------------#SCRIPT#-------------------------------- #============================================================================== # ** Game_Battler (part 1) #------------------------------------------------------------------------------ # This class deals with battlers. It's used as a superclass for the Game_Actor # and Game_Enemy classes. #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # * Determine Action Speed #-------------------------------------------------------------------------- def make_action_speed @current_action.speed = agi + rand(10 + agi / 4) if self.current_action.basic == 4 and FIRST_ACTION_PROTEZIONE @current_action.speed += 9999 end end end #============================================================================== # ** Game_Actor #------------------------------------------------------------------------------ # This class handles the actor. It's used within the Game_Actors class # ($game_actors) and refers to the Game_Party class ($game_party). #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :name # name attr_reader :character_name # character file name attr_reader :character_hue # character hue attr_reader :class_id # class ID attr_reader :weapon_id # weapon ID attr_reader :armor1_id # shield ID attr_reader :armor2_id # helmet ID attr_reader :armor3_id # body armor ID attr_reader :armor4_id # accessory ID attr_reader :level # level attr_reader :exp # EXP attr_reader :skills # skills attr_accessor :alleato # alleato da proteggere attr_accessor :actor_id # ID eroe #-------------------------------------------------------------------------- # * Object Initialization # actor_id : actor ID #-------------------------------------------------------------------------- def initialize(actor_id) super() setup(actor_id) end #-------------------------------------------------------------------------- # * Setup # actor_id : actor ID #-------------------------------------------------------------------------- def setup(actor_id) @alleato = nil actor = $data_actors[actor_id] @actor_id = actor_id @name = actor.name @character_name = actor.character_name @character_hue = actor.character_hue @battler_name = actor.battler_name @battler_hue = actor.battler_hue @class_id = actor.class_id @weapon_id = actor.weapon_id @armor1_id = actor.armor1_id @armor2_id = actor.armor2_id @armor3_id = actor.armor3_id @armor4_id = actor.armor4_id @level = actor.initial_level @exp_list = Array.new(101) make_exp_list @exp = @exp_list[@level] @skills = [] @hp = maxhp @sp = maxsp @states = [] @states_turn = {} @maxhp_plus = 0 @maxsp_plus = 0 @str_plus = 0 @dex_plus = 0 @agi_plus = 0 @int_plus = 0 # Learn skill for i in 1..@level for j in $data_classes[@class_id].learnings if j.level == i learn_skill(j.skill_id) end end end # Update auto state update_auto_state(nil, $data_armors[@armor1_id]) update_auto_state(nil, $data_armors[@armor2_id]) update_auto_state(nil, $data_armors[@armor3_id]) update_auto_state(nil, $data_armors[@armor4_id]) end def position return 0 if self == $game_party.actors[0] return 1 if self == $game_party.actors[1] return 2 if self == $game_party.actors[2] return 3 if self == $game_party.actors[3] end end #============================================================================== # ** Scene_Battle #------------------------------------------------------------------------------ # This class performs battle screen processing. #============================================================================== class Scene_Battle def main # Initialize each kind of temporary battle data $game_temp.in_battle = true $game_temp.battle_turn = 0 $game_temp.battle_event_flags.clear $game_temp.battle_abort = false $game_temp.battle_main_phase = false $game_temp.battleback_name = $game_map.battleback_name $game_temp.forcing_battler = nil # Initialize battle event interpreter $game_system.battle_interpreter.setup(nil, 0) # Prepare troop @troop_id = $game_temp.battle_troop_id $game_troop.setup(@troop_id) # Make actor command window s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item s5 = PROTEZIONE @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4]) @actor_command_window.y = 160 @actor_command_window.back_opacity = 160 @actor_command_window.active = false @actor_command_window.visible = false # Make other windows @party_command_window = Window_PartyCommand.new @help_window = Window_Help.new @help_window.back_opacity = 160 @help_window.visible = false @status_window = Window_BattleStatus.new @message_window = Window_Message.new # Make sprite set @spriteset = Spriteset_Battle.new # Initialize wait count @wait_count = 0 # Execute transition if $data_system.battle_transition == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition) end # Start pre-battle phase start_phase1 # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Refresh map $game_map.refresh # Prepare for transition Graphics.freeze # Dispose of windows @actor_command_window.dispose @party_command_window.dispose @help_window.dispose @status_window.dispose @message_window.dispose if @skill_window != nil @skill_window.dispose end if @item_window != nil @item_window.dispose end if @result_window != nil @result_window.dispose end # Dispose of sprite set @spriteset.dispose # If switching to title screen if $scene.is_a?(Scene_Title) # Fade out screen Graphics.transition Graphics.freeze end # If switching from battle test to any screen other than game over screen if $BTEST and not $scene.is_a?(Scene_Gameover) $scene = nil end end def update # If battle event is running if $game_system.battle_interpreter.running? # Update interpreter $game_system.battle_interpreter.update # If a battler which is forcing actions doesn't exist if $game_temp.forcing_battler == nil # If battle event has finished running unless $game_system.battle_interpreter.running? # Rerun battle event set up if battle continues unless judge setup_battle_event end end # If not after battle phase if @phase != 5 # Refresh status window @status_window.refresh end end end # Update system (timer) and screen $game_system.update $game_screen.update # If timer has reached 0 if $game_system.timer_working and $game_system.timer == 0 # Abort battle $game_temp.battle_abort = true end # Update windows @party_command_window.update @actor_command_window.update @status_window.update @message_window.update # Update sprite set @spriteset.update # If transition is processing if $game_temp.transition_processing # Clear transition processing flag $game_temp.transition_processing = false # Execute transition if $game_temp.transition_name == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $game_temp.transition_name) end end # If message window is showing if $game_temp.message_window_showing return end # If effect is showing if @spriteset.effect? return end # If game over if $game_temp.gameover # Switch to game over screen $scene = Scene_Gameover.new return end # If returning to title screen if $game_temp.to_title # Switch to title screen $scene = Scene_Title.new return end # If battle is aborted if $game_temp.battle_abort # Return to BGM used before battle started $game_system.bgm_play($game_temp.map_bgm) # Battle ends battle_end(1) return end # If waiting if @wait_count > 0 # Decrease wait count @wait_count -= 1 return end # If battler forcing an action doesn't exist, # and battle event is running if $game_temp.forcing_battler == nil and $game_system.battle_interpreter.running? return end # Branch according to phase case @phase when 1 # pre-battle phase update_phase1 when 2 # party command phase update_phase2 when 3 # actor command phase update_phase3 when 4 # main phase update_phase4 when 5 # after battle phase update_phase5 end end #-------------------------------------------------------------------------- # * Frame Update (actor command phase) #-------------------------------------------------------------------------- def update_phase3 # If enemy arrow is enabled if @enemy_arrow != nil update_phase3_enemy_select # If actor arrow is enabled elsif @actor_arrow != nil update_phase3_actor_select # If skill window is enabled elsif @skill_window != nil update_phase3_skill_select # If item window is enabled elsif @item_window != nil update_phase3_item_select # If actor command window is enabled elsif @actor_command_window.active update_phase3_basic_command end end #-------------------------------------------------------------------------- # * Frame Update (actor command phase : basic command) #-------------------------------------------------------------------------- def update_phase3_basic_command # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Go to command input for previous actor phase3_prior_actor return end # If C button was pressed if Input.trigger?(Input::C) # Branch by actor command window cursor position case @actor_command_window.index when 0 # attack # Play decision SE $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # Start enemy selection start_enemy_select when 1 # skill # Play decision SE $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 1 # Start skill selection start_skill_select when 2 # guard # Play decision SE $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 1 phase3_next_actor # Go to command input for next actor when 3 # item # Se è un difensore, proteggi if @active_battler.class_id == DIFENSORE $game_system.se_play($data_system.decision_se) @active_battler.current_action.basic = 4 start_actor_select else $game_system.se_play($data_system.decision_se) # Set action @active_battler.current_action.kind = 2 # Start item selection start_item_select end when 4 if @active_battler.class_id == DIFENSORE $game_system.se_play($data_system.decision_se) @active_battler.current_action.kind = 2 start_item_select end end return end end #-------------------------------------------------------------------------- # * Frame Update (actor command phase : actor selection) #-------------------------------------------------------------------------- def update_phase3_actor_select # Update actor arrow @actor_arrow.update # If B button was pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # End actor selection end_actor_select return end # If C button was pressed if Input.trigger?(Input::C) @active_battler.current_action.target_index = @actor_arrow.index if @active_battler.is_a?(Game_Actor) if @active_battler.current_action.basic == 4 and @active_battler.current_action.kind != 2 if @active_battler.class_id == DIFENSORE #se è un difensore if @actor_arrow.index == @active_battler.position #se non difende se stesso $game_system.se_play($data_system.buzzer_se) # @help.set_text("Non puoi auto-proteggerti!") return else @active_battler.alleato = @active_battler.current_action.target_index #proteggi alleato end end end end # Set action $game_system.se_play($data_system.decision_se) end_actor_select # If skill window is showing if @skill_window != nil # End skill selection end_skill_select end # If item window is showing if @item_window != nil # End item selection end_item_select end # Go to command input for next actor phase3_next_actor # End actor selection end end #-------------------------------------------------------------------------- # * Start Actor Selection #-------------------------------------------------------------------------- def start_actor_select # Make actor arrow @actor_arrow = Arrow_Actor.new(@spriteset.viewport2) @actor_arrow.index = @actor_index if @active_battler.is_a?(Game_Actor) if @active_battler.class_id == DIFENSORE if @active_battler.current_action.basic == 4 @help_window.visible = true #mostra obiettivo end end end # Associate help window @actor_arrow.help_window = @help_window # Disable actor command window @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # * End Actor Selection #-------------------------------------------------------------------------- def end_actor_select # Dispose of actor arrow @actor_arrow.dispose @actor_arrow = nil if @active_battler.is_a?(Game_Actor) if @active_battler.class_id == DIFENSORE if @active_battler.current_action.basic == 4 @actor_command_window.active = true @actor_command_window.visible = true @help_window.visible = false end end end end def make_basic_action_result # If attack if @active_battler.current_action.basic == 0 # Set anaimation ID @animation1_id = @active_battler.animation1_id @animation2_id = @active_battler.animation2_id # If action battler is enemy if @active_battler.is_a?(Game_Enemy) if @active_battler.restriction == 3 target = $game_troop.random_target_enemy elsif @active_battler.restriction == 2 target = $game_party.random_target_actor else index = @active_battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # If action battler is actor if @active_battler.is_a?(Game_Actor) if @active_battler.restriction == 3 target = $game_party.random_target_actor elsif @active_battler.restriction == 2 target = $game_troop.random_target_enemy else index = @active_battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end for actor in $game_party.actors if @active_battler.is_a?(Game_Enemy) #proteggi se attacca il protetto if actor.alleato == @active_battler.current_action.target_index and actor.hp > 0#target target.damage_pop = true target.animation_id = ATTACCO_ANIM target.damage = PROTEZIONE_AVVISO target = actor end end end # Set array of targeted battlers @target_battlers = [target] # Apply normal attack results for target in @target_battlers target.attack_effect(@active_battler) end return end # If guard if @active_battler.current_action.basic == 1 @help_window.set_text($data_system.words.guard, 1) return end if @active_battler.current_action.basic == 4 if @active_battler.class_id == DIFENSORE @active_battler.animation_id = PROTEZIONE_ANIM @help_window.set_text(PROTEZIONE_HELP, 1) end return end # If escape if @active_battler.is_a?(Game_Enemy) and @active_battler.current_action.basic == 2 # Display "Escape" in help window @help_window.set_text("Escape", 1) # Escape @active_battler.escape return end # If doing nothing if @active_battler.current_action.basic == 4 # Clear battler being forced into action $game_temp.forcing_battler = nil # Shift to step 1 @phase4_step = 1 return end end def set_target_battlers(scope) # If battler performing action is enemy if @active_battler.is_a?(Game_Enemy) # Branch by effect scope case scope when 1 # single enemy index = @active_battler.current_action.target_index if PROTEZIONE_MAGIE unless MAGIE_STATUS.include?(@skill.id) for actor in $game_party.actors if actor.class_id == DIFENSORE #proteggi se attacca il protetto if actor.alleato == @active_battler.current_action.target_index and actor.hp > 0#target $game_party.smooth_target_actor(index).damage_pop = true $game_party.smooth_target_actor(index).animation_id = MAGIE_ANIM $game_party.smooth_target_actor(index).damage = PROTEZIONE_AVVISO @target_battlers.push(actor) return end end end end end @target_battlers.push($game_party.smooth_target_actor(index)) when 2 # all enemies for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 3 # single ally index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4 # all allies for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5 # single ally (HP 0) index = @active_battler.current_action.target_index enemy = $game_troop.enemies[index] if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end when 6 # all allies (HP 0) for enemy in $game_troop.enemies if enemy != nil and enemy.hp0? @target_battlers.push(enemy) end end when 7 # user @target_battlers.push(@active_battler) end end # If battler performing action is actor if @active_battler.is_a?(Game_Actor) # Branch by effect scope case scope when 1 # single enemy index = @active_battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 2 # all enemies for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 3 # single ally index = @active_battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 4 # all allies for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 5 # single ally (HP 0) index = @active_battler.current_action.target_index actor = $game_party.actors[index] if actor != nil and actor.hp0? @target_battlers.push(actor) end when 6 # all allies (HP 0) for actor in $game_party.actors if actor != nil and actor.hp0? @target_battlers.push(actor) end end when 7 # user @target_battlers.push(@active_battler) end end end def battle_end(result) # Clear in battle flag $game_temp.in_battle = false # Clear entire party actions flag $game_party.clear_actions # Remove battle states for actor in $game_party.actors actor.alleato = nil actor.remove_states_battle end # Clear enemies $game_troop.enemies.clear # Call battle callback if $game_temp.battle_proc != nil $game_temp.battle_proc.call(result) $game_temp.battle_proc = nil end # Switch to map screen $scene = Scene_Map.new end def phase3_prior_actor @actor_command_window.dispose if @actor_index != 0 # Loop begin # Actor blink effect OFF if @active_battler != nil @active_battler.blink = false end # If first actor if @actor_index == 0 # Start party command phase start_phase2 return end # Return to actor index @actor_index -= 1 @active_battler = $game_party.actors[@actor_index] s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item s5 = PROTEZIONE if @active_battler.class_id == DIFENSORE @actor_command_window = Window_Command.new(160, [s1, s2, s3, s5, s4]) else @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4]) end @actor_command_window.y = 160 @actor_command_window.back_opacity = 160 @active_battler.alleato = nil @active_battler.blink = true # Once more if actor refuses command input end until @active_battler.inputable? # Set up actor command window phase3_setup_command_window end def phase3_next_actor @actor_command_window.dispose if @actor_index != $game_party.actors.size-1 # Loop begin # Actor blink effect OFF if @active_battler != nil @active_battler.blink = false end # If last actor if @actor_index == $game_party.actors.size-1 # Start main phase start_phase4 return end # Advance actor index @actor_index += 1 @active_battler = $game_party.actors[@actor_index] @active_battler.alleato = nil s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item s5 = PROTEZIONE if @active_battler.class_id == DIFENSORE @actor_command_window = Window_Command.new(160, [s1, s2, s3, s5, s4]) else @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4]) end @actor_command_window.y = 160 @actor_command_window.back_opacity = 160 @active_battler.blink = true # Once more if actor refuses command input end until @active_battler.inputable? # Set up actor command window phase3_setup_command_window end def update_phase4_step3 # Animation for action performer (if ID is 0, then white flash) if @animation1_id == 0 unless @active_battler.current_action.basic == 4 and @active_battler.class_id == DIFENSORE @active_battler.white_flash = true else case @active_battler.current_action.target_index when 0 $game_party.actors[0].animation_id = USO_PROTEZIONE_ANIM when 1 $game_party.actors[1].animation_id = USO_PROTEZIONE_ANIM when 2 $game_party.actors[2].animation_id = USO_PROTEZIONE_ANIM when 3 $game_party.actors[3].animation_id = USO_PROTEZIONE_ANIM end end else @active_battler.animation_id = @animation1_id @active_battler.animation_hit = true end # Shift to step 4 @phase4_step = 4 end def phase3_setup_command_window # Disable party command window @party_command_window.active = false @party_command_window.visible = false # Enable actor command window @actor_command_window.active = true @actor_command_window.visible = true @actor_command_window.y = 160 @actor_command_window.y = 128 if @active_battler.class_id == DIFENSORE # Set actor command window position @actor_command_window.x = @actor_index * 160 # Set index to 0 @actor_command_window.index = 0 end end #----------------------------------#SCRIPT#-------------------------------------
Istruzioni per l'uso
Trovate tutto all'interno dello script, se lo usate creditatemi per favore
Bugs e Conflitti Noti
N/A
Altri Dettagli
Per qualsiasi cosa rivolgetevi pure a me, non fatevi problemi. :)
Modificato da Dilos, 27 April 2013 - 02:01 AM.
Script monoriga sistemato.