Project1
标题: 关于宠物脚本的小问题 [打印本页]
作者: 梦到叶子了 时间: 2011-9-18 16:43
标题: 关于宠物脚本的小问题
本帖最后由 梦到叶子了 于 2011-9-18 22:07 编辑
这是梦幻群侠传2的脚本,我加入了鼠标,当设置宠物的时候,如果点鼠标右键返回,就会全部关闭整个宠物窗口回到地图,而用键盘的 ESC就只会返回到上一步,不会关闭全部窗口,如何让鼠标返回正常?- #==============================================================================
- # ■ Scene_Baby
- #------------------------------------------------------------------------------
- # 对召唤兽的管理菜单
- #==============================================================================
- class Scene_Baby
- #--------------------------------------------------------------------------
- # ● 主处理
- #--------------------------------------------------------------------------
- def initialize(actor_index = 0)
- $kds_baby = actor_index
- $baby_face = 0
- if $game_party.actors[$kds_baby].kds_baby.size > 0
- if $game_party.actors[$kds_baby].kds_canzhan != 0
- $baby_index = $game_actors[$game_party.actors[$kds_baby].kds_canzhan]
- else
- $baby_index = $game_actors[$game_party.actors[$kds_baby].kds_baby[0]]
- end
- $stop = nil
- else
- $stop = 0
- end
- end
- def main
- #宠物界面
-
- @rp = Sprite.new
- @rp.bitmap = RPG::Cache.windowskin("skin_baby")
-
- # @skin = Sprite.new()
- # @skin.bitmap = RPG::Cache.windowskin("skin_baby")
- # @actor = $game_party.actors[0]
-
- @help_window = Window_Help.new
- @help_window.opacity = 0 # 宠物帮助窗口透明度
- @help_window.y = 480-64 #XY坐标
- @item_window = Window_Item2.new
- # @item_window.opacity = 0 # 宠物物品窗口透明度
- @item_window.active = false
- @item_window.help_window = @help_window
- @item_window.index = -1
- if $game_party.actors[$kds_baby].kds_baby.size > 0
- if $game_party.actors[$kds_baby].kds_canzhan != 0
- @skill_window = Window_Skill.new($game_actors[$game_party.actors[$kds_baby].kds_canzhan])
- @skill_window.opacity = 255 # 宠物特技窗口透明度
- @skill_window.help_window = @help_window
- else
- @skill_window = Window_Skill.new($game_actors[$game_party.actors[$kds_baby].kds_baby[0]])
- @skill_window.help_window = @help_window
- end
- else
- @skill_window = Window_Skill.new(0)
- end
- @skill_window.active = false#true
- @skill_window.index = -1
- @skill_window.update
- s1 = "设置参战"
- s2 = "查看技能"
- s3 = "使用物品"
- s4 = "能力分配"
- s5 = "放生守护"
- s6 = "退出菜单"
- @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5,s6])
- @command_window.opacity = 0 # 宠物普通窗口透明度
- @command_window.y = 480-64-192-32
- if $game_party.actors[$kds_baby].kds_baby.size == 0
- @command_window.disable_item(0)
- @command_window.disable_item(1)
- @command_window.disable_item(2)
- @command_window.disable_item(3)
- @command_window.disable_item(4)
- end
- @command_window.refresh
- @command_window.update
-
- s1 = ""
- s3 = ""
- s2 = ""
- s4 = ""
- s5 = ""
- @command2_window = Window_Command.new(110, [s1, s2, s3, s4, s5],1,16,14)
- @command2_window.x = 160+236+125-6
- @command2_window.y = -4+16+24+22+7+1
- @command2_window.index = -1
- @command2_window.back_opacity = 0
- @command2_window.opacity = 0
- @command2_window.active = false
- @command2_window.help_window = @help_window
-
- if $game_party.actors[$kds_baby].kds_baby.size > 0
- if $game_party.actors[$kds_baby].kds_canzhan != 0
- @status_window = Window_EquipLeft.new($game_actors[$game_party.actors[$kds_baby].kds_canzhan])
- else
- @status_window = Window_EquipLeft.new($game_actors[$game_party.actors[$kds_baby].kds_baby[0]])
- end
- else
- @status_window = Window_EquipLeft.new(0)
- end
- if $game_party.actors[$kds_baby].kds_baby.size > 0
- if $game_party.actors[$kds_baby].kds_canzhan != 0
- @head_window = Window_Head.new($game_actors[$game_party.actors[$kds_baby].kds_canzhan])
- else
- @head_window = Window_Head.new($game_actors[$game_party.actors[$kds_baby].kds_baby[0]])
- end
- else
- @head_window = Window_Head.new(0)
- end
- if $game_party.actors[$kds_baby].kds_baby.size > 0
- if $game_party.actors[$kds_baby].kds_canzhan != 0
- @babys_window = Window_Baby.new($game_actors[$game_party.actors[$kds_baby].kds_canzhan])
- else
- @babys_window = Window_Baby.new($game_actors[$game_party.actors[$kds_baby].kds_baby[0]])
- end
- else
- @babys_window = Window_Baby.new(0)
- end
- @babys_window.index = -1
- @babys_window.update
- @babys_window.active = false
- @babys_window.help_window = @help_window
- Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition)
- loop do
- Graphics.update
- Input.update
- update
- if $scene != self
- break
- end
- end
- # 装备过渡
- Graphics.freeze
- # 释放窗口
- $stop = nil
- @command_window.dispose
- @command2_window.dispose
- @help_window.dispose
- @item_window.dispose
- @head_window.dispose
- @status_window.dispose
- @skill_window.dispose
- @babys_window.dispose
- @rp.dispose
- end
- #--------------------------------------------------------------------------
- # ● 刷新画面
- #--------------------------------------------------------------------------
- def update
- @help_window.update
- $baby_face += 1
- if ($baby_face+12)%12 == 0 and $game_party.actors[$kds_baby].kds_baby.size > 0
- @head_window.refresh
- if $baby_face == 36
- $baby_face = 0
- end
- end
- if @command2_window.active
- @command2_window.update
- up_command2
- end
- if @babys_window.active
- @babys_window.update
- up_babys
- end
- if @skill_window.active
- @skill_window.update
- up_skill
- end
- if @command_window.active
- @command_window.update
- up_command
- end
- if @item_window.active
- @item_window.update
- up_item
- end
- end
-
- def up_command
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- $scene = Scene_Map.new
- return
- end
- if Input.trigger?(Input::C)
- $command_index = @command_window.index
- if @command_window.index != 5 and @command_window.index != 2
- if $game_party.actors[$kds_baby].kds_baby.size == 0
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- @command_window.active = false
- @babys_window.index = 0
- @babys_window.active = true
- $baby_index = $game_actors[$game_party.actors[$kds_baby].kds_baby[0]]
- @baby_index = 0
- @babys_window.refresh
- @head_window.refresh
- @skill_window.refresh
- @status_window.refresh2
- elsif @command_window.index == 5
- $game_system.se_play($data_system.cancel_se)
- #$scene = Scene_Map.new
- $scene = Scene_Map.new
- elsif @command_window.index == 2
- if $game_party.actors[$kds_baby].kds_baby.size == 0
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- @item_window.update
- @item_window.index = -1
- @command_window.active = false
- @babys_window.index = 0
- @babys_window.active = true
- $baby_index = $game_actors[$game_party.actors[$kds_baby].kds_baby[0]]
- @baby_index = 0
- @babys_window.refresh
- @head_window.refresh
- @skill_window.refresh
- @status_window.refresh2
- end
- return
- end
- end
-
- def up_babys
- if @babys_window.index != @baby_index
- @baby_index = @babys_window.index
- $baby_index = $game_actors[$game_party.actors[$kds_baby].kds_baby[@babys_window.index]]
- @babys_window.refresh
- @head_window.refresh
- @skill_window.refresh
- @status_window.refresh2
- end
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- Graphics.freeze
- @babys_window.index = -1
- @babys_window.active = false
- @command_window.active = true
- @help_window.set_text("")
- Graphics.transition
- return
- end
- if Input.trigger?(Input::C)
- Graphics.freeze
- $game_system.se_play($data_system.decision_se)
- @chong = $game_actors[$game_party.actors[$kds_baby].kds_baby[@babys_window.index]]
- @zhu = $game_party.actors[$kds_baby]
- case @command_window.index
- when 0
- if $game_party.actors[$kds_baby].kds_canzhan == $game_party.actors[$kds_baby].kds_baby[@babys_window.index]
- $game_party.actors[$kds_baby].kds_canzhan = 0
- else
- $game_party.actors[$kds_baby].kds_canzhan = $game_party.actors[$kds_baby].kds_baby[@babys_window.index]
- end
- @babys_window.refresh
- when 1
- @babys_window.active = false
- @skill_window.index = 0
- @skill_window.active = true
- when 2
- @babys_window.active = false
- @item_window.index = 0
- @item_window.active = true
- when 3
- @babys_window.active = false
- @command2_window.index = 0
- @command2_window.active = true
- when 4
- $game_variables[29] = $game_party.actors[$kds_baby].id
- $game_party.remove_actor(@chong.id)
- @baby_index = 0
- if @babys_window.index > 0
- @babys_window.index -= 1
- end
- if @zhu.kds_baby.size == 0
- $stop = 0
- @babys_window.index = -1
- @babys_window.active = false
- @command_window.active = true
- @help_window.set_text("")
- @command_window.disable_item(0)
- @command_window.disable_item(1)
- @command_window.disable_item(2)
- @command_window.disable_item(3)
- @command_window.disable_item(4)
- @command_window.refresh
- @command_window.update
- end
- @babys_window.refresh
- @head_window.refresh
- @skill_window.refresh
- @status_window.refresh2
- end
- Graphics.transition
- return
- end
- end
-
- def up_skill
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- Graphics.freeze
- @babys_window.active = true
- @skill_window.index = -1
- @skill_window.active = false
- Graphics.transition
- return
- end
- end
-
- def up_item
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- Graphics.freeze
- @babys_window.active = true
- @item_window.index = -1
- @item_window.active = false
- Graphics.transition
- return
- end
- if Input.trigger?(Input::C)
- @item = @item_window.item
- if @item == nil
- $game_system.se_play($data_system.buzzer_se)
- return
- end
-
- if @item.element_set.include?(11)
- if @chong.skills.include?(@item.recover_hp) == false
- @chong.learn_skill(@item.recover_hp)
- else
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- elsif @item.element_set.include?(12)
- @chong.level = 1
- @chong.maxhp = @chong.base_maxhp
- @chong.maxsp = @chong.base_maxsp
- @chong.str = @chong.base_str
- @chong.dex = @chong.base_dex
- @chong.agi = @chong.base_agi
- @chong.int = @chong.base_int
- @chong.qianli = 0
- end
- $game_system.se_play(@item.menu_se)
- if @item.consumable
- $game_party.lose_item(@item.id, 1)
- end
- @item_window.refresh
- @skill_window.refresh
- @status_window.refresh2
- return
- end
- end
- def up_command2
- if Input.trigger?(Input::B)
- $game_system.se_play($data_system.cancel_se)
- Graphics.freeze
- @babys_window.active = true
- @command2_window.index = -1
- @command2_window.active = false
- Graphics.transition
- return
- end
- if Input.trigger?(Input::C)
- if @chong.qianli <= 0
- $game_system.se_play($data_system.buzzer_se)
- return
- end
- $game_system.se_play($data_system.decision_se)
- case @command2_window.index
- when 0
- @chong.maxhp += 10
- @chong.hp += 10
- when 1
- @chong.maxsp += 6
- @chong.int += 1
- when 2
- @chong.str += 1
- when 3
- @chong.dex += 1
- when 4
- @chong.agi += 1
- end
- @chong.qianli -= 1
- @status_window.refresh2
- end
- end
- end
复制代码