赞 | 8 |
VIP | 1 |
好人卡 | 0 |
积分 | 96 |
经验 | 29580 |
最后登录 | 2023-4-8 |
在线时间 | 567 小时 |
Lv4.逐梦者
- 梦石
- 7
- 星屑
- 2585
- 在线时间
- 567 小时
- 注册时间
- 2009-4-30
- 帖子
- 271
|
本帖最后由 timmyyayaya 于 2011-11-26 13:03 编辑
這個腳本是用來切換隊員的,按下SHIFT鍵就會跑出下面這個訊息。
剧本 ‘MOG-XAS_Leader_Switch’的204行发生了NoMethodError。
undefined method '[]='for nil:NilClass
想请问是什么问题让他出错的…?
另外想请教38行的Input::SHIFT该如何写才会是TAB按键,感谢。- #==============================================================================#
- # +++ XAS - LEADER SWITCHER V1.0 +++ #
- #==============================================================================#
- # By Moghunter #
- # http://www.atelier-rgss.com #
- #==============================================================================#
- # Translated by Calvin624 #
- # http://www.xasabs.wordpress.com #
- #==============================================================================#
- ###############################-DESCRIPTION-####################################
- #==============================================================================#
- # ● Let's you change the position of the leader quickly #
- # ● Option to use a tool automatically when switching the leader #
- # ● AutoRecovery System (based on a percentage of HP) #
- # ● Allows you to equip different skills for each character #
- # ● Includes a Group HUD #
- #==============================================================================#
- # #
- # Graphics required: #
- # #
- # Party_Hp.png #
- # Party_Hud.png #
- # Party_Number.png #
- # #
- # All images must be in the Windowskin folder. #
- # #
- #==============================================================================#
- # Face graphics should be named as follows: #
- # #
- # Actor_Name + _MFace #
- # #
- # EXAMPLE: Aluxe_MFace.png #
- #==============================================================================#
- module MOG_LEADER_SWITCHER
- # Switch Leader......................................................[Shift Key]
- CHANGE_LEADER_BUTTON = Input::SHIFT
- # Time to wait between switches....................................[TIME_FRAMES]
- WAIT_DURATION = 0
- #==============================================================================#
- #........................[SKILLS USED WHEN YOU SWITCH].........................#
- #==============================================================================#
- # FORMAT: A=>B #
- # #
- # A = Actor ID (as listed in the ACTORS tab in the DATABASE) #
- # B = TOOL ID #
- #==============================================================================#
- SHIFT_ACTION_ID = {
- 1=>1, # Alice Cast Ice
- 2=>1 # Aluxes Cast Fire
- }
-
- #==============================================================================#
- #...............................[AUTO RECOVER].................................#
- #==============================================================================#
- # FORMAT: A=>B #
- # #
- # A = Actor ID (as listed in the ACTORS tab in the DATABASE) #
- # B = Percentage of HP restored #
- #==============================================================================#
- PERC_RECHP = {
- 1=> 4,
- 3=> 3
- }
-
- # The amount of time (in frames) of the Speed Auto Recovery........[TIME_FRAMES]
- # Note: 40 Frames = 1 sec
- RECOVER_SPEED = 60
- # Activate the Jump Effect between switches?........................[TRUE/FALSE]
- JUMP_EFFECT = true
- #==============================================================================#
- #............................[ACTOR SOUND EFFECTS].............................#
- #==============================================================================#
- # FORMAT: A=>["B","B","B","B"] #
- # #
- # A = ACTOR ID (as listed in the ACTORS tab in the DATABASE) #
- # B = Sound Effect played when actors switch #
- #==============================================================================#
- LEADER_VOICE= {
- 1=>["A_MISC3","A_SKILL01"],
- 2=>["V_SPECIAL1"],
- 3=>["S_MISC04"],
- 4=>["SA_SKILL01"]
- }
- # Position of the HUD on the X and Y axis......................[HUD_POSITIONING]
- # Layout
- LAYOUT_POS = [200, 5]
- # Face
- FACE_POS = [202, 5]
- # HP
- HP_POS = [235, 17]
- # Level
- LEVEL_POS = [255 , 5]
- # Tools
- TOOL_POS = [233, 25 ]
- # Cursor
- NEXT_POS = [202, 30]
- # Priority of the HUD
- HUD_PRIORITY_Z = 5000
- # Switch ID to disable the HUD..........................................[SWITCH]
- DISABLE_HUD_SWITCH = 5
- end
- #===============================================================================
- # ■ Game_Temp
- #===============================================================================
- class Game_Temp
- attr_accessor :shift_duration
- attr_accessor :shift_action_id
- attr_accessor :shift_pre_direction
- attr_accessor :refresh_hud
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- alias leader_initialize initialize
- def initialize
- leader_initialize
- @shift_duration = 0
- @shift_action_id = 0
- @shift_pre_direction = 6
- @refresh_hud = false
- end
-
- end
- #===============================================================================
- # ■ Game_system
- #===============================================================================
- class Game_System
- attr_accessor :party_skill_id
- attr_accessor :party_item_id
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- alias leader_initialize initialize
- def initialize
- leader_initialize
- @party_skill_id = []
- @party_item_id = []
- end
-
- end
- #===============================================================================
- # ■ Game_Player
- #===============================================================================
- class Game_Player
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- alias leader_switcher_update update
- def update
- if self.battler.hp == 0 and not $game_party.all_dead?
- $game_player.active_shift_movement
- @knock_back_duration = 1
- end
- if Input.trigger?(MOG_LEADER_SWITCHER::CHANGE_LEADER_BUTTON)
- if $game_party.actors.size > 1 and not $game_party.all_dead? and
- $game_temp.shift_duration == 0 and can_base_update? and
- self.battler.hp > 0
- survive = 0
- for i in $game_party.actors
- survive += 1 if i.hp > 0
- end
- if survive > 1
- $game_temp.shift_duration = 15 + MOG_LEADER_SWITCHER::WAIT_DURATION
- end
- end
- end
- active_leader_motion
- leader_switcher_update
- end
-
- #--------------------------------------------------------------------------
- # ● Active Leader Motion
- #--------------------------------------------------------------------------
- def active_leader_motion
- return if $game_temp.shift_duration == 0
- return unless can_base_update?
- return unless can_action?
- if $game_temp.shift_duration == 15 + MOG_LEADER_SWITCHER::WAIT_DURATION
- active_shift_movement
- end
- $game_temp.shift_duration -= 1
- end
-
- #--------------------------------------------------------------------------
- # ● Active_shift_movement
- #--------------------------------------------------------------------------
- def active_shift_movement
- @actor = $game_party.actors[0]
- $game_system.party_skill_id[@actor.id] = $game_system.xas_skill_id
- $game_system.party_item_id[@actor.id] = $game_system.xas_item_id
- if MOG_LEADER_SWITCHER::JUMP_EFFECT
- $game_player.real_y -= 480
- $game_player.real_x -= 2500
- $game_temp.shift_pre_direction = $game_player.direction
- $game_player.direction = 6
- jump(0,0)
- end
- refresh_leader
- end
-
- #--------------------------------------------------------------------------
- # ● Refresh Leader
- #--------------------------------------------------------------------------
- def refresh_leader(action = true)
- for i in 1..$game_party.actors.size
- pre_leader = $game_party.actors[0].id
- $game_party.remove_actor(pre_leader)
- $game_party.add_actor(pre_leader)
- break if $game_party.actors[0].hp > 0
- end
- @actor = $game_party.actors[0]
- @actor.pre_level = @actor.level
- $scene = Scene_Refresh.new
- @actor.hit_it = 30
- self.battler.after_damage_pop_time = 0
- self.battler.xas_states_pop_time
- shift_action = MOG_LEADER_SWITCHER::SHIFT_ACTION_ID[@actor.id]
- if $game_system.party_skill_id[@actor.id] != nil
- $game_system.xas_skill_id = $game_system.party_skill_id[@actor.id]
- else
- $game_system.xas_skill_id = 0
- end
- if $game_system.party_item_id[@actor.id] != nil
- $game_system.xas_item_id = $game_system.party_item_id[@actor.id]
- else
- $game_system.xas_item_id = 0
- end
- if shift_action != nil and action
- $game_temp.shift_action_id = shift_action
- end
- voice = MOG_LEADER_SWITCHER::LEADER_VOICE[@actor.id]
- if voice != nil and action
- Audio.se_play("Audio/SE/" + voice[rand(voice.size)],130,100) rescue nil
- end
- end
-
- #--------------------------------------------------------------------------
- # ● XAS - Force_Action_Now
- #--------------------------------------------------------------------------
- alias leader_shift_update_force_action update_force_action
- def update_force_action
- if $game_temp.shift_action_id != 0 and not jumping?
- action_id = $game_temp.shift_action_id
- id = Database_Bullet::DURATIONS[action_id]
- return if id == nil
- $game_player.direction = $game_temp.shift_pre_direction
- self.shoot(action_id)
- $game_temp.shift_action_id = 0
- return
- end
- leader_shift_update_force_action
- end
-
- end
- #===============================================================================
- # ■ Scene_Skill
- #===============================================================================
- class Scene_Skill
- #--------------------------------------------------------------------------
- # Update Skill
- #--------------------------------------------------------------------------
- alias mog_leader_shift_update_skill update_skill
- def update_skill
- if Input.trigger?(XAS_WINDOW_SKILL::BUTTON)
- @skill = @skill_window.skill
- unless @actor.skill_can_use?(@skill.id)
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.equip_se)
- if @actor == $game_party.actors[0]
- $game_system.xas_skill_id = @skill.id
- end
- $game_system.party_skill_id[@actor.id] = @skill.id
- @skill_text.visible = true
- @skill_text.x = 700
- @skill_text.opacity = @xastextime
- @xastextime = 355
- return
- end
- mog_leader_shift_update_skill
- end
- end
- #===============================================================================
- # ■ Party Hud
- #===============================================================================
- class Party_Hud
- include MOG_LEADER_SWITCHER
- #--------------------------------------------------------------------------
- # ● Initialize
- #--------------------------------------------------------------------------
- def initialize
- return if $game_party.actors.size <= 1
- @auto_recover_time = 0
- @leader_id = $game_party.actors[0].id
- create_layout
- create_face
- create_hp
- create_level
- create_tools
- end
-
- #--------------------------------------------------------------------------
- # ● create_layout
- #--------------------------------------------------------------------------
- def create_layout
- @layout_image = RPG::Cache.windowskin("Party_Hud")
- @w = @layout_image.width * $game_party.actors.size
- @layout_bitmap = Bitmap.new(@w,@layout_image.height)
- @layout_sprite = Sprite.new
- @layout_sprite.bitmap = @layout_bitmap
- @layout_sprite.z = HUD_PRIORITY_Z
- refresh_layout
- @layout_sprite.x = LAYOUT_POS[0]
- @layout_sprite.y = LAYOUT_POS[1]
- end
-
- #--------------------------------------------------------------------------
- # ● Refresh Layout
- #--------------------------------------------------------------------------
- def refresh_layout
- @layout_sprite.bitmap.clear
- for i in 0...$game_party.actors.size - 1
- @layout_src_rect = Rect.new(0, 0, @layout_image.width , @layout_image.height)
- @layout_bitmap.blt(@layout_image.width * i,0, @layout_image, @layout_src_rect)
- end
- end
-
- #--------------------------------------------------------------------------
- # ● Create Tools
- #--------------------------------------------------------------------------
- def create_tools
- @icon_bitmap = Bitmap.new(@w,24)
- @icon_sprite = Sprite.new
- @icon_sprite.bitmap = @icon_bitmap
- @icon_sprite.z = 3 + HUD_PRIORITY_Z
- @icon_sprite.x = TOOL_POS[0]
- @icon_sprite.y = TOOL_POS[1]
- icon_src_rect = Rect.new(0, 0, 24 , 24)
- index = 0
- for i in $game_party.actors
- next if i.id == @leader_id
- item = $data_items[$game_system.party_item_id[i.id]] rescue nil
- skill = $data_skills[$game_system.party_skill_id[i.id]] rescue nil
- if item != nil
- image = RPG::Cache.icon(item.icon_name)
- @icon_bitmap.blt(@layout_image.width * index,0, image, icon_src_rect)
- image.dispose
- end
- if skill != nil
- image = RPG::Cache.icon(skill.icon_name)
- @icon_bitmap.blt(29 + (@layout_image.width * index),0, image, icon_src_rect)
- image.dispose
- end
- index += 1
- end
- end
- #--------------------------------------------------------------------------
- # ● create_level
- #--------------------------------------------------------------------------
- def create_level
- @level_image = RPG::Cache.windowskin("Party_Number")
- @level_bitmap = Bitmap.new(@w,@level_image.height)
- @level_sprite = Sprite.new
- @level_sprite.bitmap = @level_bitmap
- @level_sprite.z = 3 + HUD_PRIORITY_Z
- @level_sprite.x = LEVEL_POS[0]
- @level_sprite.y = LEVEL_POS[1]
- @level_cw = @level_image.width / 10
- @level_ch = @level_image.height
- refresh_level
- end
-
- #--------------------------------------------------------------------------
- # ● refresh_level
- #--------------------------------------------------------------------------
- def refresh_level
- @level_sprite.bitmap.clear
- index = 0
- for i in $game_party.actors
- next if i.id == @leader_id
- @level_text = i.level.to_s.split(//)
- nx = @layout_image.width * index
- for r in 0..@level_text.size - 1
- @level_abs = @level_text[r].to_i
- @level_src_rect = Rect.new(@level_cw * @level_abs, 0, @level_cw, @level_ch)
- @level_bitmap.blt(nx + (@level_cw * r), 0, @level_image, @level_src_rect)
- end
- index += 1
- end
- end
-
- #--------------------------------------------------------------------------
- # ● create_hp
- #--------------------------------------------------------------------------
- def create_hp
- @hp_image = RPG::Cache.windowskin("Party_Hp")
- @hp_sprite = Sprite.new
- @hp_bitmap = Bitmap.new(@w,@hp_image.height)
- @hp_sprite.bitmap = @hp_bitmap
- refresh_hp
- @hp_sprite.z = 2 + HUD_PRIORITY_Z
- @hp_sprite.x = HP_POS[0]
- @hp_sprite.y = HP_POS[1]
- end
-
- #--------------------------------------------------------------------------
- # ● refresh_hp
- #--------------------------------------------------------------------------
- def refresh_hp
- return if $game_party.actors.size <= 1
- @hp_sprite.bitmap.clear
- index = 0
- for i in $game_party.actors
- next if i.id == @leader_id
- hp_size = @hp_image.width * i.hp / i.maxhp
- @hp_src_rect = Rect.new(0, 0, hp_size , @hp_image.height)
- @hp_bitmap.blt(@layout_image.width * index,0, @hp_image, @hp_src_rect)
- index += 1
- end
- end
-
- #--------------------------------------------------------------------------
- # ● create_face
- #--------------------------------------------------------------------------
- def create_face
- @face_sprite = Sprite.new
- @face_bitmap = Bitmap.new(@w,32)
- @face_sprite.bitmap = @face_bitmap
- @face_sprite.z = 1 + HUD_PRIORITY_Z
- @face_sprite.x = FACE_POS[0]
- @face_sprite.y = FACE_POS[1]
- refresh_face
- end
-
- #--------------------------------------------------------------------------
- # ● refresh_face
- #--------------------------------------------------------------------------
- def refresh_face
- @face_sprite.bitmap.clear
- index = 0
- for i in $game_party.actors
- next if i.id == @leader_id
- if @face_image != nil
- @face_image.dispose
- end
- file_name = i.name + "_MFace"
- @face_image = RPG::Cache.windowskin(file_name)
- if i.hp > 0
- @face_src_rect = Rect.new(0, 0, 24 , 24)
- else
- @face_src_rect = Rect.new(24, 0, 24 , 24)
- end
- @face_bitmap.blt(@layout_image.width * index,0, @face_image, @face_src_rect)
- index += 1
- end
- end
-
- #--------------------------------------------------------------------------
- # ● Dispose
- #--------------------------------------------------------------------------
- def dispose
- return if @layout_sprite == nil
- @layout_image.dispose
- @layout_bitmap.dispose
- @layout_sprite.bitmap.dispose
- @layout_sprite.dispose
- @face_image.dispose
- @face_bitmap.dispose
- @face_sprite.bitmap.dispose
- @face_sprite.dispose
- @hp_image.dispose
- @hp_bitmap.dispose
- @hp_sprite.bitmap.dispose
- @hp_sprite.dispose
- @level_image.dispose
- @level_bitmap.dispose
- @level_sprite.bitmap.dispose
- @level_sprite.dispose
- @icon_bitmap.dispose
- @icon_sprite.bitmap.dispose
- @icon_sprite.dispose
- end
-
- #--------------------------------------------------------------------------
- # ● update
- #--------------------------------------------------------------------------
- def update
- return if @layout_sprite == nil
- refresh if $game_temp.refresh_hud
- update_visible
- update_auto_recover
- end
-
- #--------------------------------------------------------------------------
- # ● Update Auto Recover
- #--------------------------------------------------------------------------
- def update_auto_recover
- return if $game_system.map_interpreter.running?
- @auto_recover_time += 1
- if @auto_recover_time > RECOVER_SPEED
- for i in $game_party.actors
- next if i.id == @leader_id
- perc = PERC_RECHP[i.id]
- if perc != nil and i.hp > 0
- rec = i.maxhp * perc / 100
- rec = 1 if rec < 1
- i.hp += rec
- end
- end
- refresh_hp
- @auto_recover_time = 0
- end
- end
-
- #--------------------------------------------------------------------------
- # ● Update Visible
- #--------------------------------------------------------------------------
- def update_visible
- if $game_switches[DISABLE_HUD_SWITCH]
- vis = false
- else
- vis = true
- end
- @layout_sprite.visible = vis
- @face_sprite.visible = vis
- @hp_sprite.visible = vis
- @icon_sprite.visible = vis
- @level_sprite.visible = vis
- end
-
- #--------------------------------------------------------------------------
- # ● update
- #--------------------------------------------------------------------------
- def refresh
- $game_temp.refresh_hud = false
- return if @layout_sprite == nil
- refresh_hp
- refresh_level
- end
-
- end
- #===============================================================================
- # ■ Interpreter
- #===============================================================================
- class Interpreter
- #--------------------------------------------------------------------------
- # ● command_129
- #--------------------------------------------------------------------------
- alias leader_shift_command_129 command_129
- def command_129
- party_max = $game_party.actors.size
- leader_shift_command_129
- if party_max != $game_party.actors.size
- $scene = Scene_Refresh.new
- end
- end
- #--------------------------------------------------------------------------
- # ● command_311
- #--------------------------------------------------------------------------
- alias leader_shift_command_311 command_311
- def command_311
- leader_shift_command_311
- $game_temp.refresh_hud = true
- end
-
- #--------------------------------------------------------------------------
- # ● command_312
- #--------------------------------------------------------------------------
- alias leader_shift_command_312 command_312
- def command_312
- leader_shift_command_312
- $game_temp.refresh_hud = true
- end
- #--------------------------------------------------------------------------
- # ● command_314
- #--------------------------------------------------------------------------
- alias leader_shift_command_314 command_314
- def command_314
- leader_shift_command_314
- $scene = Scene_Refresh.new
- end
-
- #--------------------------------------------------------------------------
- # ● command_315
- #--------------------------------------------------------------------------
- alias leader_shift_command_315 command_315
- def command_315
- leader_shift_command_315
- $game_temp.refresh_hud = true
- end
- #--------------------------------------------------------------------------
- # ● command_316
- #--------------------------------------------------------------------------
- alias leader_shift_command_316 command_316
- def command_316
- leader_shift_command_316
- $game_temp.refresh_hud = true
- end
- end
- #===============================================================================
- # ■ Spriteset_Map
- #===============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● initialize
- #--------------------------------------------------------------------------
- alias mog_party_initialize initialize
- def initialize
- @partyhud = Party_Hud.new
- mog_party_initialize
- end
-
- #--------------------------------------------------------------------------
- # ● Dispose
- #--------------------------------------------------------------------------
- alias mog_party_dispose dispose
- def dispose
- mog_party_dispose
- @partyhud.dispose
- end
-
- #--------------------------------------------------------------------------
- # ● Frame Update
- #--------------------------------------------------------------------------
- alias mog_party_update update
- def update
- mog_party_update
- @partyhud.update
- end
- end
- #===============================================================================
- # ■ XAS_ACTION
- #===============================================================================
- module XAS_ACTION
-
- #--------------------------------------------------------------------------
- # ● Voice Check
- #--------------------------------------------------------------------------
- alias leader_voice_check voice_check
- def voice_check(action_id)
- return if self.force_move_times != 0
- return if self.battler.is_a?(Game_Enemy)
- actor = $game_party.actors[0]
- voice = XAS_VOICE::ACTOR_SKILL_VOICE
- return if voice[actor.id] == nil
- leader_voice_check(action_id)
- end
- end
- #===============================================================================
- # ■ XAS_ACTION
- #===============================================================================
- module XAS_ACTION
- #--------------------------------------------------------------------------
- # ● check_action_exist?
- #--------------------------------------------------------------------------
- def check_action_exist?(action_id)
- return false if action_id == nil
- id = Database_Bullet::DURATIONS[action_id]
- return true if id != nil
- end
-
- #--------------------------------------------------------------------------
- # ● Check Battler Exist?
- #--------------------------------------------------------------------------
- def check_battler_exist?
- return true if self.battler != nil
- return false
- end
- end
-
- $mog_rgss_xas_leader_switcher = true
复制代码 |
|