设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2625|回复: 2
打印 上一主题 下一主题

[已经过期] 地图上显示血量的脚本.........

[复制链接]

Lv1.梦旅人

梦石
0
星屑
212
在线时间
291 小时
注册时间
2009-1-1
帖子
97
跳转到指定楼层
1
发表于 2012-5-2 20:11:48 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
我要的有点特殊,不要姓名,不要SP,血条或者血量都可以........

Lv1.梦旅人

梦石
0
星屑
50
在线时间
2188 小时
注册时间
2011-6-23
帖子
1044
2
发表于 2012-5-2 20:19:38 | 只看该作者
本帖最后由 lsu666666 于 2012-5-2 20:23 编辑

腳本來源:魔劍腳本鋪
腳本說明:魔劍腳本鋪
直接套用就可以顯示血量這裡可以修改定義值  不使用則輸入0
Sword32_HP = 1000 # 設定主角的初始HP,0表示不使用
Sword32_SP = 0 # 設定主角的初始SP,0表示不使用
  1. module Sword
  2.   ON = true ; OFF = false
  3. #=======================================
  4. #★ 魔劍工舖 - 事件角色顯示HP、SP條 1.01
  5. # 轉貼腳本請著名出處:http://blog.yam.com/a870053jjkj/
  6. # 如果採用在遊戲中,看你高興是否顯示腳本出處,但嚴禁說是自己寫的腳本!!
  7. #=======================================
  8. #● 使用者自定設置
  9. Sword32_Width = 32 # 設定血條的寬度
  10. Sword32_Amendment = [0, 0] # 血條顯示位置的 [X座標, Y座標] 修正
  11. Sword32_HP = 1000 # 設定主角的初始HP,0表示不使用
  12. Sword32_SP = 0 # 設定主角的初始SP,0表示不使用
  13. Sword32_Full = OFF # 當變更血量上限時,是否要自將血量回滿
  14. Sword32_ColorHP = Color.new(255, 0, 0) # HP條的顏色 (紅, 綠, 藍)
  15. Sword32_ColorSP = Color.new(0, 0, 255) # SP條的顏色 (紅, 綠, 藍)
  16. Sword32_Switche = 20 # 指定1個開關編號,該開關為ON時不顯示血條,0為不使用
  17. =begin
  18. ========================================
  19. ● 設置方法
  20. 強制更新全部血條:$game_party.blood_update
  21. 角色目前HP變量:$game_player.hp
  22. 角色目前SP變量:$game_player.sp
  23. 角色上限HP變量:$game_player.maxhp
  24. 角色上限SP變量:$game_player.maxsp
  25. 事件目前HP變量:$game_map.events[事件編號].hp
  26. 事件目前SP變量:$game_map.events[事件編號].sp
  27. 事件上限HP變量:$game_map.events[事件編號].maxhp
  28. 事件上限SP變量:$game_map.events[事件編號].maxsp
  29.          事件編號設為 @event_id 表示本事件
  30. ========================================
  31. # 詳細設置說明請參考:http://blog.yam.com/a870053jjkj/article/26253688
  32. =end
  33.   $Sword ? $Sword[32] = 100 : $Sword = {32=>100} # 腳本使用標誌
  34.   $Sword_F12_Error = {} unless $Sword_F12_Error # F12除錯標誌
  35.   Sword32_XPVX = 1 ; Vocab rescue Sword32_XPVX = 0 # 偵測XPVX
  36. end
  37. #=======================================
  38. #■ 處理同伴的類別
  39. class Game_Party
  40.   attr_accessor :event_blood
  41.   #-------------------------------------------------------------
  42.   #● 初始化物件
  43.   alias sword32_initialize initialize
  44.   def initialize ; sword32_initialize ; @event_blood = {} ; end
  45.   #-------------------------------------------------------------
  46.   #● 強制更新全部血條的方法
  47.   def blood_update
  48.     $game_player.blood_update = true
  49.     (1...$game_map.events.size).each {|i| $game_map.events[i].blood_update = true}
  50.   end
  51. end
  52. #=======================================
  53. #■ 處理事件的類別
  54. class Game_Event < Game_Character
  55.   include Sword # 連接自定設置
  56.   attr_reader    :erased # 暫時消除標誌
  57.   attr_reader    :hp # 目前 HP
  58.   attr_reader    :maxhp # 最大 HP
  59.   attr_reader    :sp # 目前 SP
  60.   attr_reader    :maxsp # 最大 SP
  61.   attr_accessor :blood_update # 血條更新標誌
  62.   #-------------------------------------------------------------
  63.   #● 更新
  64.   alias sword32_refresh refresh
  65.   def refresh
  66.     sword32_refresh
  67.     return if ((not @page) or @smap_id == $game_map.map_id)
  68.     @smap_id = $game_map.map_id
  69.     a = 2 + ($Sword[9] ? 1 : 0) # 設定檢查的事件數
  70.     (0..a).each do |i|
  71.       if @page.list[i] # 有事件指令的情況下
  72.         #○ 獲取事件的HP數值
  73.         if @page.list[i].code == 118 ; if  /[Hh][Pp][::](\d+)/ === @page.list[i].parameters[0]
  74.           $game_party.event_blood[[@smap_id, @id]] = [] unless
  75.           $game_party.event_blood[[@smap_id, @id]]
  76.           if $game_party.event_blood[[@smap_id, @id]][0]
  77.             @maxhp = $game_party.event_blood[[@smap_id, @id]][0] ; @hp = @maxhp
  78.           else
  79.             @maxhp = $1.to_i ; @hp = @maxhp
  80.             @maxhp = $game_party.event_blood[[@smap_id, @id]][0] = @maxhp
  81.           end
  82.         end ; end
  83.         #○ 獲取事件的SP數值
  84.         if @page.list[i].code == 118 ; if  /[Ss][Pp][::](\d+)/ === @page.list[i].parameters[0]
  85.           $game_party.event_blood[[@smap_id, @id]] = [] unless
  86.           $game_party.event_blood[[@smap_id, @id]]
  87.           if $game_party.event_blood[[@smap_id, @id]][1]
  88.             @maxsp = $game_party.event_blood[[@smap_id, @id]][1] ; @sp = @maxsp
  89.           else
  90.             @maxsp = $1.to_i ; @sp = @maxsp
  91.             @maxsp = $game_party.event_blood[[@smap_id, @id]][1] = @maxsp
  92.           end
  93.         end ; end
  94.       end
  95.     end
  96.   end
  97.   #-------------------------------------------------------------
  98.   #● 增減 HP
  99.   def hp=(hp) ; @blood_update = true ; hp = [[hp, 0].max, @maxhp].min ; @hp = hp ; end
  100.   #-------------------------------------------------------------
  101.   #● 增減 SP
  102.   def sp=(sp) ; @blood_update = true ; sp = [[sp, 0].max, @maxsp].min ; @sp = sp ; end
  103.   #-------------------------------------------------------------
  104.   #● HP上限
  105.   def maxhp=(maxhp)
  106.     @blood_update = true ; @maxhp = maxhp
  107.     Sword32_Full ? @hp = @maxhp : @hp = [@hp, @maxhp].min
  108.     $game_party.event_blood[[$game_map.map_id, @id]][0] = @maxhp
  109.   end
  110.   #-------------------------------------------------------------
  111.   #● SP上限
  112.   def maxsp=(maxsp)
  113.     @blood_update = true ; @maxsp = maxsp
  114.     Sword32_Full ? @sp = @maxsp : @sp = [@sp, @maxsp].min
  115.     $game_party.event_blood[[$game_map.map_id, @id]][1] = @maxsp
  116.   end
  117. end
  118. #=======================================
  119. #■ 處理主角的類別
  120. class Game_Player < Game_Character
  121.   include Sword # 連接自定設置
  122.   attr_reader    :hp # 目前 HP
  123.   attr_reader    :maxhp # 最大 HP
  124.   attr_reader    :sp # 目前 SP
  125.   attr_reader    :maxsp # 最大 SP
  126.   attr_accessor :blood_update # 血條更新標誌
  127.   #-------------------------------------------------------------
  128.   #● 更新
  129.   alias sword32_refresh refresh
  130.   def refresh
  131.     sword32_refresh
  132.     if (not $game_party.event_blood['actor']) and (Sword32_HP > 0 or Sword32_SP > 0)
  133.       if Sword32_HP > 0 # 有設置角色HP的場合
  134.         $game_party.event_blood['actor'] = [] unless $game_party.event_blood['actor']
  135.         @maxhp = Sword32_HP ; @hp = @maxhp
  136.         $game_party.event_blood['actor'][0] = Sword32_HP
  137.       end ; if Sword32_SP > 0 # 有設置角色SP的場合
  138.         $game_party.event_blood['actor'] = [] unless $game_party.event_blood['actor']
  139.         @maxsp = Sword32_SP ; @sp = @maxsp
  140.         $game_party.event_blood['actor'][1] = Sword32_SP
  141.       end
  142.     elsif $game_party.event_blood['actor'] and Sword32_HP > 0
  143.       @maxhp = $game_party.event_blood['actor'][0] ; @hp = @maxhp
  144.     end
  145.     if $game_party.event_blood['actor'] and Sword32_SP > 0
  146.       @maxsp = $game_party.event_blood['actor'][1] ; @sp = @maxsp
  147.     end
  148.   end
  149.   #-------------------------------------------------------------
  150.   #● 增減 HP
  151.   def hp=(hp) ; @blood_update = true ; hp = [[hp, 0].max, @maxhp].min ; @hp = hp ; end
  152.   #-------------------------------------------------------------
  153.   #● 增減 SP
  154.   def sp=(sp) ; @blood_update = true ; sp = [[sp, 0].max, @maxsp].min ; @sp = sp ; end
  155.   #-------------------------------------------------------------
  156.   #● HP上限
  157.   def maxhp=(maxhp)
  158.     @blood_update = true ; @maxhp = maxhp
  159.     Sword32_Full ? @hp = @maxhp : @hp = [@hp, @maxhp].min
  160.     $game_party.event_blood['actor'][0] = @maxhp
  161.   end
  162.   #-------------------------------------------------------------
  163.   #● SP上限
  164.   def maxsp=(maxsp)
  165.     @blood_update = true ; @maxsp = maxsp
  166.     Sword32_Full ? @sp = @maxsp : @sp = [@sp, @maxsp].min
  167.     $game_party.event_blood['actor'][1] = @maxsp
  168.   end
  169. end
  170. #=======================================
  171. #■ 角色顯示用腳本
  172. a = Sword::Sword32_XPVX == 0 ? RPG::Sprite : Sprite_Base
  173. class Sprite_Character < eval('a')
  174.   include Sword # 連接自定設置
  175.   #-------------------------------------------------------------
  176.   #● 初始化物件
  177.   alias sword32_initialize initialize
  178.   def initialize(viewport, character = nil)
  179.     @show_blood = [] unless @show_name # 產生儲存用的數組
  180.     @show_blood[character.id] = Sprite.new(Viewport.new(0, 0, 640, 480)) # 顯示用精靈
  181.     blood_long(character) if character.hp
  182.     sword32_initialize(viewport, character)
  183.   end
  184.   #-------------------------------------------------------------
  185.   #● 更新畫面
  186.   alias sword32_update update
  187.   def update
  188.     sword32_update
  189.     return if @character.is_a?(Game_Player) if Sword32_HP == 0 # 角色沒血就中斷
  190.     return if @character.is_a?(Game_Vehicle) if Sword32_XPVX == 1 # 中斷交通工具
  191.     if @character.blood_update # 更新血條標誌
  192.       blood_long(@character) ; @character.blood_update = false
  193.     end
  194.     #○ 更新血條顯示的座標
  195.     a = Sword32_XPVX == 0 ? 4 : 8
  196.     @show_blood[@character.id].x = character.real_x / a - 32 / 2 + 16 +
  197.     Sword32_Amendment[0] - $game_map.display_x / a
  198.     @show_blood[@character.id].y = character.real_y / a - 24 +
  199.     Sword32_Amendment[1] - $game_map.display_y / a
  200.   end
  201.   #-------------------------------------------------------------
  202.   #● 描繪HP、SP條的方法
  203.   def blood_long(character)
  204.     if (character.is_a?(Game_Event) ? character.erased : character.transparent) or
  205.     Sword32_Switche == 0 ? nil : $game_switches[Sword32_Switche]
  206.       @show_blood[character.id].bitmap = Bitmap.new(Sword32_Width, 2)
  207.       return
  208.     end
  209.     a = Sword32_XPVX == 0 ? 4 : 8
  210.     @show_blood[character.id].x = character.real_x / a - 32 / 2 + 16 +
  211.     Sword32_Amendment[0] - $game_map.display_x / a
  212.     @show_blood[character.id].y = character.real_y / a - 24 +
  213.     Sword32_Amendment[1] - $game_map.display_y / a
  214.     @show_blood[character.id].bitmap = Bitmap.new(Sword32_Width, 5)
  215.     if character.hp ; if character.maxhp > 0 # 有HP的場合
  216.       width = Sword32_Width / 100.0 * (character.hp / (character.maxhp / 100.0)).to_i
  217.       width = 1 if (width == 0 and character.hp > 0)  # 如果血量過小就一律顯示1像素
  218.       @show_blood[character.id].bitmap.fill_rect(0, 0, width, 2, Sword32_ColorHP)
  219.     end ; end ; if character.sp ; if character.maxsp > 0 # 有SP的場合
  220.       width = Sword32_Width / 100.0 * (character.sp / (character.maxsp / 100.0)).to_i
  221.       width = 1 if (width == 0 and character.sp > 0)  # 如果血量過小就一律顯示1像素
  222.       @show_blood[character.id].bitmap.fill_rect(0, 3, width, 2, Sword32_ColorSP)
  223.     end ; end
  224.   end
  225.   #-------------------------------------------------------------
  226.   #● 釋放角色活動塊
  227.   alias sword32_dispose dispose unless $Sword_F12_Error[32]
  228.   def dispose
  229.     (@show_blood = nil ; GC.start) if @show_blood
  230.     sword32_dispose
  231.   end
  232. end
  233. #=======================================
  234. #■ 執行事件指令的解釋器
  235. class Interpreter
  236.   #-------------------------------------------------------------
  237.   #● 事件消除事件
  238.   alias sword32_command_116 command_116
  239.   def command_116
  240.     sword32_command_116 ; $game_map.events[@event_id].blood_update = true
  241.   end
  242.   #-------------------------------------------------------------
  243.   #● 開關操作
  244.   alias sword32_command_121 command_121
  245.   def command_121
  246.     sword32_command_121 ; $game_party.blood_update
  247.   end
  248.   #-------------------------------------------------------------
  249.   #● 變更透明狀態
  250.   alias sword32_command_208 command_208
  251.   def command_208
  252.     sword32_command_208 ; $game_player.blood_update = true
  253.   end
  254. end
  255. $Sword_F12_Error[32] = true # 腳本讀取完畢,打開F12除錯標誌功能
复制代码
������

点评

虽然不是我想要的还是谢谢你了,出现个对话框,里面显示.........主要是以前有两个脚本冲突,不好修改于是来求了.........  发表于 2012-5-3 00:25
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
154 小时
注册时间
2011-7-9
帖子
423
3
发表于 2012-5-2 20:59:12 | 只看该作者
还可以显示个图片,根据血算的百分比缩方x轴放大率

点评

额,公共事件并行啊............感觉会卡........并行的东西多了  发表于 2012-5-3 00:23
New Game:  【QQ堂4.6单机版】(9月新版!【点此】)个人提供快速网盘http://ad.jlweb.tk/upload/ --- 密码:abcdefg
激零工作室孵化中.....网游make中。。招收游戏监督一名,上线时间:5~12 小时 招收脚本员,美工数位。。
本人Q:330639889 验证:zs    ----广:愿意帮我宣传签名的,站内PM
下面的东西是什么?!请进:http://tieba.baidu.com/p/1453289014【2012最新炸弹型ARPG游戏,历时2年间断坚持制作!】
[img=646,262]http://ftp.66rpg.com/WEB_PLUS/attachment/forum/201203/28/1655578kbk8bqkfazk2
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-6 02:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表