Project1
标题: XAS的HOTKEY [打印本页]
作者: timmyyayaya    时间: 2012-3-31 14:38
标题: XAS的HOTKEY
 本帖最后由 timmyyayaya 于 2012-3-31 14:55 编辑 
在下找到了一个用在XAS的热键脚本,
不过好像有些冲突,不知道是否有哪位大大可以帮忙试一下?- #===============================================================================
 - # XAS - Hot Key HUD
 - #===============================================================================
 - # By Mr_Wiggles
 - # Version 1.3
 - # 7/6/10
 - #-------------------------------------------------------------------------------
 - # Instructions:
 - #  Fill in the constants bellow, paste this script above main and bellow XAS in
 - #  your script data base. BE SURE TO SET TO THE RIGHT XAS VERSION!!
 - # 
 - #  Place the "Hot_Keys_HUD" picture file into your game directory 
 - #  Graphics/Pictures folder.
 - #-------------------------------------------------------------------------------
 - # Directions of Use:
 - #  Simple just press a number key (1 - 5) when the quick skill or item menu is
 - #  Showing.
 - #===============================================================================
 - HUD_X = 0 # X pos of HUD
 - HUD_Y = 0 # Y pos of HUD
 
- # Set true  if XAS 3.7f
 - # set false if XAS 3.6
 - XASVER_37 = true
 
- #===============================================================================
 - # Numkeys Module
 - #===============================================================================
 - module Input
 -   Numkey = {1 => 1049, 2 => 1050, 3 => 1051, 4 => 1052, 5 => 1053}
 -   class << self
 -     Key = Win32API.new('user32','GetAsyncKeyState',['i'],'i')
 -     
 -     def testkey(key)
 -       Key.call(key) & 0x01 == 1
 -     end
 -     
 -     alias hud_key_update update
 -     def update
 -       hud_key_update
 -       @pressed = []
 -       for key in Numkey.values
 -         key -= 1000
 -         @pressed.push(key) if testkey(key)
 -       end
 -     end
 -     
 -     def pressed?(key)
 -       key -= 1000
 -       @pressed = [] if @pressed.nil?
 -       return true if @pressed.include?(key)
 -       return false
 -     end
 -     
 -     alias hud_key_press? press?
 -     def press?(key)
 -       return pressed?(key) if key.to_f > 1000
 -       hud_key_press?(key)
 -     end
 -   end
 - end
 
- #===============================================================================
 - # Game Player
 - #===============================================================================
 - class Game_Player < Game_Character
 -   attr_accessor :hud_equip
 -   
 -   alias hot_key_hud_init initialize
 -   def initialize
 -     hot_key_hud_init
 -     @hud_equip = []
 -   end
 -   
 -   def equip_item_to_hud(n, item)
 -     if item.nil?
 -       $game_system.se_play($data_system.buzzer_se)
 -       return
 -     end
 -     $game_system.se_play($data_system.decision_se)
 -     @hud_equip[@hud_equip.index(item)] = nil if @hud_equip.include?(item)
 -     @hud_equip[n] = item
 -   end
 - end
 
- #===============================================================================
 - # Quick Skill Window
 - #===============================================================================
 - if XASVER_37 == false
 -   class Xas_Scene_Skill
 -     alias hud_quick_menu_main main
 -     def main
 -       @hot_key_hud = Hot_Key_HUD.new
 -       hud_quick_menu_main
 -       @hot_key_hud.dispose
 -     end
 -     
 -     alias hotkey_hud_qucik_menu_update update
 -     def update
 -       hotkey_hud_qucik_menu_update
 -       # Hot Key num 1
 -       if Input.press?(Input::Numkey[1])
 -         $game_player.equip_item_to_hud(0, @skill_window.skill)
 -       # Hot Key num 2
 -       elsif Input.press?(Input::Numkey[2])
 -         $game_player.equip_item_to_hud(1, @skill_window.skill)
 -       # Hot Key num 3
 -       elsif Input.press?(Input::Numkey[3])
 -         $game_player.equip_item_to_hud(2, @skill_window.skill)
 -       # Hot Key num 4
 -       elsif Input.press?(Input::Numkey[4])
 -         $game_player.equip_item_to_hud(3, @skill_window.skill)
 -       # Hot Key num 5
 -       elsif Input.press?(Input::Numkey[5])
 -         $game_player.equip_item_to_hud(4, @skill_window.skill)
 -       end
 -       @hot_key_hud.update
 -     end
 -   end
 - else
 -   class Quick_Menu_Skill
 -     alias hud_quick_menu_main main
 -     def main
 -       @hot_key_hud = Hot_Key_HUD.new
 -       hud_quick_menu_main
 -       @hot_key_hud.dispose
 -     end
 -     
 -     alias hotkey_hud_qucik_menu_update update
 -     def update
 -       hotkey_hud_qucik_menu_update
 -       # Hot Key num 1
 -       if Input.press?(Input::Numkey[1])
 -         $game_player.equip_item_to_hud(0, @skill_window.skill)
 -       # Hot Key num 2
 -       elsif Input.press?(Input::Numkey[2])
 -         $game_player.equip_item_to_hud(1, @skill_window.skill)
 -       # Hot Key num 3
 -       elsif Input.press?(Input::Numkey[3])
 -         $game_player.equip_item_to_hud(2, @skill_window.skill)
 -       # Hot Key num 4
 -       elsif Input.press?(Input::Numkey[4])
 -         $game_player.equip_item_to_hud(3, @skill_window.skill)
 -       # Hot Key num 5
 -       elsif Input.press?(Input::Numkey[5])
 -         $game_player.equip_item_to_hud(4, @skill_window.skill)
 -       end
 -       @hot_key_hud.update
 -     end
 -   end
 - end
 
- #===============================================================================
 - # Quick Item Window
 - #===============================================================================
 - if XASVER_37 == false
 -   class Xas_Scene_Item
 -     alias hud_quick_menu_main main
 -     def main
 -       @hot_key_hud = Hot_Key_HUD.new
 -       hud_quick_menu_main
 -       @hot_key_hud.dispose
 -     end
 -     
 -     alias hud_key_update update
 -     def update
 -       hud_key_update
 -       # Hot Key num 1
 -       if Input.press?(Input::Numkey[1])
 -         $game_player.equip_item_to_hud(0, @item_window.item)
 -       # Hot Key num 2
 -       elsif Input.press?(Input::Numkey[2])
 -         $game_player.equip_item_to_hud(1, @item_window.item)
 -       # Hot Key num 3
 -       elsif Input.press?(Input::Numkey[3])
 -         $game_player.equip_item_to_hud(2, @item_window.item)
 -       # Hot Key num 4
 -       elsif Input.press?(Input::Numkey[4])
 -         $game_player.equip_item_to_hud(3, @item_window.item)
 -       # Hot Key num 5
 -       elsif Input.press?(Input::Numkey[5])
 -         $game_player.equip_item_to_hud(4, @item_window.item)
 -       end
 -       @hot_key_hud.update
 -     end
 -   end
 - else
 -   class Quick_Menu_Item
 -     alias hud_quick_menu_main main
 -     def main
 -       @hot_key_hud = Hot_Key_HUD.new
 -       hud_quick_menu_main
 -       @hot_key_hud.dispose
 -     end
 -     
 -     alias hud_key_update update
 -     def update
 -       hud_key_update
 -       # Hot Key num 1
 -       if Input.press?(Input::Numkey[1])
 -         $game_player.equip_item_to_hud(0, @item_window.item)
 -       # Hot Key num 2
 -       elsif Input.press?(Input::Numkey[2])
 -         $game_player.equip_item_to_hud(1, @item_window.item)
 -       # Hot Key num 3
 -       elsif Input.press?(Input::Numkey[3])
 -         $game_player.equip_item_to_hud(2, @item_window.item)
 -       # Hot Key num 4
 -       elsif Input.press?(Input::Numkey[4])
 -         $game_player.equip_item_to_hud(3, @item_window.item)
 -       # Hot Key num 5
 -       elsif Input.press?(Input::Numkey[5])
 -         $game_player.equip_item_to_hud(4, @item_window.item)
 -       end
 -       @hot_key_hud.update
 -     end
 -   end
 - end
 
- #===============================================================================
 - # HUD Window
 - #===============================================================================
 - class Hot_Key_HUD < Window_Base
 -   def initialize(x = HUD_X - 10, y = HUD_Y - 15)
 -     super(x, y, 220, 80)
 -     self.contents = Bitmap.new(width - 32, height - 32)
 -     self.opacity = 0
 -     @actor = $game_party.actors[0]
 -     refresh
 -   end
 
-   def refresh
 -     self.contents.clear
 -     bitmap = RPG::Cache.picture("Hot_Keys_HUD")
 -     self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 160, 32))
 -     for i in 0..4
 -       x = 32 * i + 4
 -       item = $game_player.hud_equip[i]
 -       next if item.nil?
 -       if item.is_a?(RPG::Weapon)
 -         item = nil if $game_party.weapon_number(item.id) == 0 and
 -           @actor.weapon_id != item.id
 -       elsif item.is_a?(RPG::Armor)
 -         item = nil if $game_party.armor_number(item.id) == 0 and 
 -           @actor.armor1_id != item.id
 -       elsif item.is_a?(RPG::Item)
 -         item = nil if $game_party.item_number(item.id) == 0 or
 -           !$game_party.item_can_use?(item.id)
 -       end
 -       bitmap = RPG::Cache.icon(item.icon_name)
 -       self.contents.blt(x, 4, bitmap, Rect.new(0, 0, 24, 24))
 -     end
 -   end
 -   
 -   def equip(item)
 -     if item.nil?
 -       $game_system.se_play($data_system.buzzer_se)
 -       return
 -     end
 -     if item.is_a?(RPG::Skill)
 -       if [email protected]_can_use?(item.id)
 -         $game_system.se_play($data_system.buzzer_se)
 -         return
 -       end
 -       $game_system.xas_skill_id = item.id
 -     elsif item.is_a?(RPG::Weapon)
 -       @actor.equip(0, item.id)
 -     elsif item.is_a?(RPG::Armor)
 -       @actor.equip(1, item.id)
 -     elsif item.is_a?(RPG::Item)
 -       item_tool_id = XAS::XASITEM_ID[item.id]
 -       if item_tool_id != nil
 -         unless $game_party.item_can_use?(item.id)
 -           $game_system.se_play($data_system.buzzer_se)
 -           return
 -         end
 -         $game_system.xas_item_id = item.id
 -       end
 -     end
 -     $game_system.se_play($data_system.equip_se)
 -   end
 -   
 -   def update
 -     @actor = $game_party.actors[0]
 -     @hot_keys = $game_player.hud_equip
 -     refresh
 -     return if !$scene.is_a?(Scene_Map)
 -     if Input.press?(Input::Numkey[1])
 -       equip($game_player.hud_equip[0])
 -     elsif Input.press?(Input::Numkey[2])
 -       equip($game_player.hud_equip[1])
 -     elsif Input.press?(Input::Numkey[3])
 -       equip($game_player.hud_equip[2]) 
 -     elsif Input.press?(Input::Numkey[4])
 -       equip($game_player.hud_equip[3]) 
 -     elsif Input.press?(Input::Numkey[5])
 -       equip($game_player.hud_equip[4])
 -     end
 -   end
 - end
 
- #===============================================================================
 - # Scene Map
 - #===============================================================================
 - class Scene_Map
 -   alias hot_key_hud_init main
 -   def main
 -     @hot_key_hud = Hot_Key_HUD.new
 -     @hot_key_hud.visible = !$game_switches[XAS_HUDDISABLE_HUD_SWITCH]
 -     hot_key_hud_init
 -     @hot_key_hud.dispose
 -   end
 -   
 -   alias hot_key_hud_update update
 -   def update
 -     hot_key_hud_update
 -     @hot_key_hud.update
 -     @hot_key_hud.visible = !$game_switches[XAS_HUDDISABLE_HUD_SWITCH]
 -     @hot_key_hud.update if !$game_switches[XAS_HUDDISABLE_HUD_SWITCH]
 -   end
 - end
 
 复制代码