赞 | 0 |
VIP | 385 |
好人卡 | 115 |
积分 | 1 |
经验 | 96276 |
最后登录 | 2017-6-4 |
在线时间 | 2188 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 2188 小时
- 注册时间
- 2011-6-23
- 帖子
- 1044
|
本帖最后由 lsu666666 于 2012-5-4 23:37 编辑
套用就可以
腳本來源:魔劍腳本鋪
腳本說明:魔劍腳本鋪
直接套用就可以顯示血量這裡可以修改定義值 不使用則輸入0
Sword32_HP = 1000 # 設定主角的初始HP,0表示不使用
Sword32_SP = 0 # 設定主角的初始SP,0表示不使用
圖片中只開啟HP槽 要開啟MP槽 請將 Sword32_SP = 0 修改為1000
- module Sword
- ON = true ; OFF = false
- #=======================================
- #★ 魔劍工舖 - 事件角色顯示HP、SP條 1.01
- # 轉貼腳本請著名出處:http://blog.yam.com/a870053jjkj/
- # 如果採用在遊戲中,看你高興是否顯示腳本出處,但嚴禁說是自己寫的腳本!!
- #=======================================
- #● 使用者自定設置
- Sword32_Width = 32 # 設定血條的寬度
- Sword32_Amendment = [0, 0] # 血條顯示位置的 [X座標, Y座標] 修正
- Sword32_HP = 1000 # 設定主角的初始HP,0表示不使用
- Sword32_SP = 0 # 設定主角的初始SP,0表示不使用
- Sword32_Full = OFF # 當變更血量上限時,是否要自將血量回滿
- Sword32_ColorHP = Color.new(255, 0, 0) # HP條的顏色 (紅, 綠, 藍)
- Sword32_ColorSP = Color.new(0, 0, 255) # SP條的顏色 (紅, 綠, 藍)
- Sword32_Switche = 20 # 指定1個開關編號,該開關為ON時不顯示血條,0為不使用
- =begin
- ========================================
- ● 設置方法
- 強制更新全部血條:$game_party.blood_update
- 角色目前HP變量:$game_player.hp
- 角色目前SP變量:$game_player.sp
- 角色上限HP變量:$game_player.maxhp
- 角色上限SP變量:$game_player.maxsp
- 事件目前HP變量:$game_map.events[事件編號].hp
- 事件目前SP變量:$game_map.events[事件編號].sp
- 事件上限HP變量:$game_map.events[事件編號].maxhp
- 事件上限SP變量:$game_map.events[事件編號].maxsp
- 事件編號設為 @event_id 表示本事件
- ========================================
- # 詳細設置說明請參考:http://blog.yam.com/a870053jjkj/article/26253688
- =end
- $Sword ? $Sword[32] = 100 : $Sword = {32=>100} # 腳本使用標誌
- $Sword_F12_Error = {} unless $Sword_F12_Error # F12除錯標誌
- Sword32_XPVX = 1 ; Vocab rescue Sword32_XPVX = 0 # 偵測XPVX
- end
- #=======================================
- #■ 處理同伴的類別
- class Game_Party
- attr_accessor :event_blood
- #-------------------------------------------------------------
- #● 初始化物件
- alias sword32_initialize initialize
- def initialize ; sword32_initialize ; @event_blood = {} ; end
- #-------------------------------------------------------------
- #● 強制更新全部血條的方法
- def blood_update
- $game_player.blood_update = true
- (1...$game_map.events.size).each {|i| $game_map.events[i].blood_update = true}
- end
- end
- #=======================================
- #■ 處理事件的類別
- class Game_Event < Game_Character
- include Sword # 連接自定設置
- attr_reader :erased # 暫時消除標誌
- attr_reader :hp # 目前 HP
- attr_reader :maxhp # 最大 HP
- attr_reader :sp # 目前 SP
- attr_reader :maxsp # 最大 SP
- attr_accessor :blood_update # 血條更新標誌
- #-------------------------------------------------------------
- #● 更新
- alias sword32_refresh refresh
- def refresh
- sword32_refresh
- return if ((not @page) or @smap_id == $game_map.map_id)
- @smap_id = $game_map.map_id
- a = 2 + ($Sword[9] ? 1 : 0) # 設定檢查的事件數
- (0..a).each do |i|
- if @page.list[i] # 有事件指令的情況下
- #○ 獲取事件的HP數值
- if @page.list[i].code == 118 ; if /[Hh][Pp][::](\d+)/ === @page.list[i].parameters[0]
- $game_party.event_blood[[@smap_id, @id]] = [] unless
- $game_party.event_blood[[@smap_id, @id]]
- if $game_party.event_blood[[@smap_id, @id]][0]
- @maxhp = $game_party.event_blood[[@smap_id, @id]][0] ; @hp = @maxhp
- else
- @maxhp = $1.to_i ; @hp = @maxhp
- @maxhp = $game_party.event_blood[[@smap_id, @id]][0] = @maxhp
- end
- end ; end
- #○ 獲取事件的SP數值
- if @page.list[i].code == 118 ; if /[Ss][Pp][::](\d+)/ === @page.list[i].parameters[0]
- $game_party.event_blood[[@smap_id, @id]] = [] unless
- $game_party.event_blood[[@smap_id, @id]]
- if $game_party.event_blood[[@smap_id, @id]][1]
- @maxsp = $game_party.event_blood[[@smap_id, @id]][1] ; @sp = @maxsp
- else
- @maxsp = $1.to_i ; @sp = @maxsp
- @maxsp = $game_party.event_blood[[@smap_id, @id]][1] = @maxsp
- end
- end ; end
- end
- end
- end
- #-------------------------------------------------------------
- #● 增減 HP
- def hp=(hp) ; @blood_update = true ; hp = [[hp, 0].max, @maxhp].min ; @hp = hp ; end
- #-------------------------------------------------------------
- #● 增減 SP
- def sp=(sp) ; @blood_update = true ; sp = [[sp, 0].max, @maxsp].min ; @sp = sp ; end
- #-------------------------------------------------------------
- #● HP上限
- def maxhp=(maxhp)
- @blood_update = true ; @maxhp = maxhp
- Sword32_Full ? @hp = @maxhp : @hp = [@hp, @maxhp].min
- $game_party.event_blood[[$game_map.map_id, @id]][0] = @maxhp
- end
- #-------------------------------------------------------------
- #● SP上限
- def maxsp=(maxsp)
- @blood_update = true ; @maxsp = maxsp
- Sword32_Full ? @sp = @maxsp : @sp = [@sp, @maxsp].min
- $game_party.event_blood[[$game_map.map_id, @id]][1] = @maxsp
- end
- end
- #=======================================
- #■ 處理主角的類別
- class Game_Player < Game_Character
- include Sword # 連接自定設置
- attr_reader :hp # 目前 HP
- attr_reader :maxhp # 最大 HP
- attr_reader :sp # 目前 SP
- attr_reader :maxsp # 最大 SP
- attr_accessor :blood_update # 血條更新標誌
- #-------------------------------------------------------------
- #● 更新
- alias sword32_refresh refresh
- def refresh
- sword32_refresh
- if (not $game_party.event_blood['actor']) and (Sword32_HP > 0 or Sword32_SP > 0)
- if Sword32_HP > 0 # 有設置角色HP的場合
- $game_party.event_blood['actor'] = [] unless $game_party.event_blood['actor']
- @maxhp = Sword32_HP ; @hp = @maxhp
- $game_party.event_blood['actor'][0] = Sword32_HP
- end ; if Sword32_SP > 0 # 有設置角色SP的場合
- $game_party.event_blood['actor'] = [] unless $game_party.event_blood['actor']
- @maxsp = Sword32_SP ; @sp = @maxsp
- $game_party.event_blood['actor'][1] = Sword32_SP
- end
- elsif $game_party.event_blood['actor'] and Sword32_HP > 0
- @maxhp = $game_party.event_blood['actor'][0] ; @hp = @maxhp
- end
- if $game_party.event_blood['actor'] and Sword32_SP > 0
- @maxsp = $game_party.event_blood['actor'][1] ; @sp = @maxsp
- end
- end
- #-------------------------------------------------------------
- #● 增減 HP
- def hp=(hp) ; @blood_update = true ; hp = [[hp, 0].max, @maxhp].min ; @hp = hp ; end
- #-------------------------------------------------------------
- #● 增減 SP
- def sp=(sp) ; @blood_update = true ; sp = [[sp, 0].max, @maxsp].min ; @sp = sp ; end
- #-------------------------------------------------------------
- #● HP上限
- def maxhp=(maxhp)
- @blood_update = true ; @maxhp = maxhp
- Sword32_Full ? @hp = @maxhp : @hp = [@hp, @maxhp].min
- $game_party.event_blood['actor'][0] = @maxhp
- end
- #-------------------------------------------------------------
- #● SP上限
- def maxsp=(maxsp)
- @blood_update = true ; @maxsp = maxsp
- Sword32_Full ? @sp = @maxsp : @sp = [@sp, @maxsp].min
- $game_party.event_blood['actor'][1] = @maxsp
- end
- end
- #=======================================
- #■ 角色顯示用腳本
- a = Sword::Sword32_XPVX == 0 ? RPG::Sprite : Sprite_Base
- class Sprite_Character < eval('a')
- include Sword # 連接自定設置
- #-------------------------------------------------------------
- #● 初始化物件
- alias sword32_initialize initialize
- def initialize(viewport, character = nil)
- @show_blood = [] unless @show_name # 產生儲存用的數組
- @show_blood[character.id] = Sprite.new(Viewport.new(0, 0, 640, 480)) # 顯示用精靈
- blood_long(character) if character.hp
- sword32_initialize(viewport, character)
- end
- #-------------------------------------------------------------
- #● 更新畫面
- alias sword32_update update
- def update
- sword32_update
- return if @character.is_a?(Game_Player) if Sword32_HP == 0 # 角色沒血就中斷
- return if @character.is_a?(Game_Vehicle) if Sword32_XPVX == 1 # 中斷交通工具
- if @character.blood_update # 更新血條標誌
- blood_long(@character) ; @character.blood_update = false
- end
- #○ 更新血條顯示的座標
- a = Sword32_XPVX == 0 ? 4 : 8
- @show_blood[@character.id].x = character.real_x / a - 32 / 2 + 16 +
- Sword32_Amendment[0] - $game_map.display_x / a
- @show_blood[@character.id].y = character.real_y / a - 24 +
- Sword32_Amendment[1] - $game_map.display_y / a
- end
- #-------------------------------------------------------------
- #● 描繪HP、SP條的方法
- def blood_long(character)
- if (character.is_a?(Game_Event) ? character.erased : character.transparent) or
- Sword32_Switche == 0 ? nil : $game_switches[Sword32_Switche]
- @show_blood[character.id].bitmap = Bitmap.new(Sword32_Width, 2)
- return
- end
- a = Sword32_XPVX == 0 ? 4 : 8
- @show_blood[character.id].x = character.real_x / a - 32 / 2 + 16 +
- Sword32_Amendment[0] - $game_map.display_x / a
- @show_blood[character.id].y = character.real_y / a - 24 +
- Sword32_Amendment[1] - $game_map.display_y / a
- @show_blood[character.id].bitmap = Bitmap.new(Sword32_Width, 5)
- if character.hp ; if character.maxhp > 0 # 有HP的場合
- width = Sword32_Width / 100.0 * (character.hp / (character.maxhp / 100.0)).to_i
- width = 1 if (width == 0 and character.hp > 0) # 如果血量過小就一律顯示1像素
- @show_blood[character.id].bitmap.fill_rect(0, 0, width, 2, Sword32_ColorHP)
- end ; end ; if character.sp ; if character.maxsp > 0 # 有SP的場合
- width = Sword32_Width / 100.0 * (character.sp / (character.maxsp / 100.0)).to_i
- width = 1 if (width == 0 and character.sp > 0) # 如果血量過小就一律顯示1像素
- @show_blood[character.id].bitmap.fill_rect(0, 3, width, 2, Sword32_ColorSP)
- end ; end
- end
- #-------------------------------------------------------------
- #● 釋放角色活動塊
- alias sword32_dispose dispose unless $Sword_F12_Error[32]
- def dispose
- (@show_blood = nil ; GC.start) if @show_blood
- sword32_dispose
- end
- end
- #=======================================
- #■ 執行事件指令的解釋器
- class Interpreter
- #-------------------------------------------------------------
- #● 事件消除事件
- alias sword32_command_116 command_116
- def command_116
- sword32_command_116 ; $game_map.events[@event_id].blood_update = true
- end
- #-------------------------------------------------------------
- #● 開關操作
- alias sword32_command_121 command_121
- def command_121
- sword32_command_121 ; $game_party.blood_update
- end
- #-------------------------------------------------------------
- #● 變更透明狀態
- alias sword32_command_208 command_208
- def command_208
- sword32_command_208 ; $game_player.blood_update = true
- end
- end
- $Sword_F12_Error[32] = true # 腳本讀取完畢,打開F12除錯標誌功能
复制代码 ������
��� |
|