Project1

标题: 【地图显示HP脚本】如何设置当X号开关打开时脚本才有效? [打印本页]

作者: 天使喝可乐    时间: 2011-1-7 17:11
标题: 【地图显示HP脚本】如何设置当X号开关打开时脚本才有效?
昨天重新弄了下这个脚本,这个是在地图上显示HPSP。
但是有时候我不想让它显示,所以问下,如何设置当17号开关打开时,该脚本才生效?(关闭时不显示咯)
谢谢啦{:nm_4:} ~下面是脚本:
  1. #_______________________________________________________________________________
  2. # MOG_MPW HUD Elena V2.0           
  3. #_______________________________________________________________________________
  4. # By Moghunter
  5. # http://www.atelier-rgss.com
  6. #_______________________________________________________________________________
  7. module MOG
  8. #HUD Position.
  9. STMAPX = 0   # X Pos
  10. STMAPY = 370 # Y Pos
  11. #Disable HUD Switch ID.  
  12. STMAPVIS = 1
  13. #Windowskin name.
  14. STMAPSKIN = "RO"
  15. #Window Opacity.
  16. STMAPOPA = 0
  17. end
  18. $mogscript = {} if $mogscript == nil
  19. $mogscript["mpstelen"] = true
  20. ###############
  21. # Window_Base #
  22. ###############
  23. class Window_Base < Window   
  24. def draw_maphp2(actor, x, y)
  25. back = RPG::Cache.picture("BAR_Meter")   
  26. cw = back.width  
  27. ch = back.height
  28. src_rect = Rect.new(0, 0, cw, ch)   
  29. self.contents.blt(x + 65, y - ch + 30, back, src_rect)
  30. meter = RPG::Cache.picture("HP_Meter")   
  31. cw = meter.width  * actor.hp / actor.maxhp
  32. ch = meter.height
  33. src_rect = Rect.new(0, 0, cw, ch)
  34. self.contents.blt(x + 65, y - ch + 30, meter, src_rect)
  35. text = RPG::Cache.picture("HP_Tx")   
  36. cw = text.width  
  37. ch = text.height
  38. src_rect = Rect.new(0, 0, cw, ch)
  39. self.contents.blt(x + 35, y - ch + 30, text, src_rect)
  40. self.contents.font.color = Color.new(0,0,0,255)
  41. self.contents.draw_text(x + 161, y - 1, 48, 32, actor.hp.to_s, 2)
  42. self.contents.font.color = Color.new(250,255,255,255)
  43. self.contents.draw_text(x + 160, y - 2, 48, 32, actor.hp.to_s, 2)   
  44. end  
  45. def draw_mapsp2(actor, x, y)
  46. back = RPG::Cache.picture("BAR_Meter")   
  47. cw = back.width  
  48. ch = back.height
  49. src_rect = Rect.new(0, 0, cw, ch)   
  50. self.contents.blt(x + 65, y - ch + 30, back, src_rect)
  51. meter = RPG::Cache.picture("SP_Meter")   
  52. cw = meter.width  * actor.sp / actor.maxsp
  53. ch = meter.height
  54. src_rect = Rect.new(0, 0, cw, ch)
  55. self.contents.blt(x + 65, y - ch + 30, meter, src_rect)
  56. text = RPG::Cache.picture("SP_Tx")   
  57. cw = text.width  
  58. ch = text.height
  59. src_rect = Rect.new(0, 0, cw, ch)
  60. self.contents.blt(x + 40, y - ch + 30, text, src_rect)
  61. self.contents.font.color = Color.new(0,0,0,255)
  62. self.contents.draw_text(x + 161, y - 1, 48, 32, actor.sp.to_s, 2)   
  63. self.contents.font.color = Color.new(250,255,255,255)
  64. self.contents.draw_text(x + 160, y - 2, 48, 32, actor.sp.to_s, 2)   
  65. end
  66. def draw_mexp(actor, x, y)
  67. actor = $game_party.actors[0]
  68. bitmap2 = RPG::Cache.picture("Exp_Back")
  69. cw = bitmap2.width
  70. ch = bitmap2.height
  71. src_rect = Rect.new(0, 0, cw, ch)
  72. self.contents.blt(x + 60 , y - ch + 30, bitmap2, src_rect)
  73. if actor.next_exp != 0
  74. rate = actor.now_exp.to_f / actor.next_exp
  75. else
  76. rate = 1
  77. end
  78. bitmap = RPG::Cache.picture("Exp_Meter")
  79. if actor.level < 99
  80. cw = bitmap.width * rate
  81. else
  82. cw = bitmap.width
  83. end   
  84. ch = bitmap.height
  85. src_rect = Rect.new(0, 0, cw, ch)
  86. self.contents.blt(x + 60 , y - ch + 30, bitmap, src_rect)
  87. self.contents.font.color = Color.new(0,0,0,255)
  88. self.contents.draw_text(x + 55, y + 1, 84, 32, "Exp",0)
  89. self.contents.font.color = Color.new(255,255,255,255)
  90. self.contents.draw_text(x + 54, y, 84, 32, "Exp",0)
  91. end
  92. def nada
  93. face = RPG::Cache.picture("")
  94. end  
  95. def draw_heroface(actor,x,y)
  96. face = RPG::Cache.picture(actor.name + "_face") rescue nada
  97. cw = face.width
  98. ch = face.height
  99. src_rect = Rect.new(0, 0, cw, ch)
  100. self.contents.blt(x , y - ch, face, src_rect)   
  101. end  
  102. def draw_actor_statemap(actor, x, y, width = 120)
  103. text = make_battler_state_text(actor, width, true)
  104. self.contents.font.color = Color.new(0,0,0,255)
  105. self.contents.draw_text(x + 1, y + 1, width, 32, text)
  106. self.contents.font.color = Color.new(250,255,255,255)
  107. self.contents.draw_text(x, y, width, 32, text)
  108. end
  109. def draw_actor_levelmap(actor, x, y)
  110. self.contents.font.color = Color.new(0,0,0,255)
  111. self.contents.draw_text(x, y, 32, 32, "Lv")
  112. self.contents.font.color = Color.new(50,255,250,255)   
  113. self.contents.draw_text(x + 1, y + 1, 32, 32, "Lv")
  114. self.contents.font.color = Color.new(0,0,0,255)
  115. self.contents.draw_text(x + 30, y, 24, 32, actor.level.to_s, 1)
  116. self.contents.font.color = Color.new(255,255,255,255)   
  117. self.contents.draw_text(x + 31, y + 1, 24, 32, actor.level.to_s, 1)   
  118. end
  119. end
  120. ##############
  121. # Game_Actor #
  122. ##############
  123. class Game_Actor < Game_Battler
  124. def now_exp
  125. return @exp - @exp_list[@level]
  126. end
  127. def next_exp
  128. return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  129. end
  130. end
  131. #####################
  132. # Window_Status_Map #
  133. #####################
  134. class Window_Sthero < Window_Base
  135. def initialize
  136. super(0, 0, 310, 120)
  137. self.contents = Bitmap.new(width - 32, height - 32)
  138. self.windowskin = RPG::Cache.windowskin(MOG::STMAPSKIN)   
  139. self.contents.font.bold = true
  140. self.contents.font.size = 20
  141. self.contents.font.name = "Georgia"
  142. self.opacity = MOG::STMAPOPA
  143. refresh
  144. end  
  145. def refresh
  146. self.contents.clear
  147. actor = $game_party.actors[0]
  148. draw_maphp2(actor, 35, 35)
  149. draw_mapsp2(actor, - 40, 60)
  150. draw_heroface(actor, 0, 70)
  151. draw_actor_statemap(actor, 200, 60, 70)
  152. draw_actor_levelmap(actor, 80, 10)   
  153. draw_mexp(actor, 100, 10)
  154. end
  155. end
  156. ###############
  157. # Game_Player #
  158. ###############
  159. class Game_Player < Game_Character
  160. attr_accessor :wref
  161. end
  162. #############
  163. # Scene_Map #
  164. #############
  165. class Scene_Map
  166. alias mog11_main main
  167. def main
  168. @sthero = Window_Sthero.new
  169. @sthero.x = MOG::STMAPX
  170. @sthero.y = MOG::STMAPY
  171. if $game_switches[MOG::STMAPVIS] == false
  172. @sthero.visible = true  
  173. else
  174. @sthero.visible = false  
  175. end  
  176. mog11_main
  177. @sthero.dispose
  178. end
  179. alias mog11_update update
  180. def update
  181. if $game_switches[MOG::STMAPVIS] == false
  182. @sthero.visible = true  
  183. else
  184. @sthero.visible = false  
  185. end  
  186. if $game_player.wref == true
  187. @sthero.refresh
  188. $game_player.wref = false
  189. end
  190. mog11_update
  191. end  
  192. end  
  193. ##############
  194. # Game_Party #
  195. ###############
  196. class Game_Party
  197. alias mog11_check_map_slip_damage check_map_slip_damage  
  198. def check_map_slip_damage
  199. for actor in @actors
  200. if actor.hp > 0 and actor.slip_damage?
  201. $game_player.wref = true
  202. end
  203. end
  204. mog11_check_map_slip_damage  
  205. end
  206. end
  207. ###############
  208. # Interpreter #
  209. ###############
  210. class Interpreter
  211. alias mog11_command_311 command_311
  212. def command_311
  213. mog11_command_311
  214. $game_player.wref = true   
  215. end   
  216. alias mog11_command_312 command_312
  217. def command_312
  218. mog11_command_312
  219. $game_player.wref = true   
  220. end   
  221. alias mog11_command_313 command_313
  222. def command_313
  223. mog11_command_313
  224. $game_player.wref = true   
  225. end   
  226. alias mog11_command_314 command_314
  227. def command_314
  228. mog11_command_314
  229. $game_player.wref = true   
  230. end   
  231. alias mog11_command_315 command_315
  232. def command_315
  233. mog11_command_315
  234. $game_player.wref = true   
  235. end   
  236. end   
  237. ################
  238. # Game_Battler #
  239. ################
  240. class Game_Battler
  241. alias mog11_attack_effect attack_effect
  242. def attack_effect(attacker)
  243. mog11_attack_effect(attacker)  
  244. $game_player.wref = true
  245. end
  246. alias mog11_skill_effect skill_effect
  247. def skill_effect(user, skill)
  248. mog11_skill_effect(user, skill)
  249. $game_player.wref = true  
  250. end  
  251. alias mog11_item_effect item_effect
  252. def item_effect(item)
  253. mog11_item_effect(item)
  254. $game_player.wref = true  
  255. end
  256. alias mog11_add_state add_state
  257. def add_state(state_id, force = false)
  258. mog11_add_state(state_id, force = false)
  259. $game_player.wref = true  
  260. end
  261. end
复制代码
素材:
Pictures.rar (9.73 KB, 下载次数: 271)
作者: 烁灵    时间: 2011-1-7 17:22
本帖最后由 烁灵 于 2011-1-7 17:23 编辑
  1. module MOG
复制代码
之前加上
  1. $不显示地图血条 = 45#45号开关开启时显示
复制代码
  1. def refresh
复制代码
里边加判断:
  1. def refresh
  2. self.contents.clear
  3. if $game_switches[$不显示地图血条] == true
  4. actor = $game_party.actors[0]
  5. draw_maphp2(actor, 35, 35)
  6. draw_mapsp2(actor, - 40, 60)
  7. draw_heroface(actor, 0, 70)
  8. draw_actor_statemap(actor, 200, 60, 70)
  9. draw_actor_levelmap(actor, 80, 10)   
  10. draw_mexp(actor, 100, 10)
  11. end
  12. end
  13. end
  14. ###############
复制代码

作者: 天使喝可乐    时间: 2011-1-7 18:07
烁灵 发表于 2011-1-7 17:22
之前加上里边加判断:

这样改了以后,开开关不刷新,要按ESC切菜单再切回来才有显示
消失也是 关闭开关后不消失 只是不刷新 然后按ESC切菜单再切回来HPSP条才消失。
可能还要添加什么吧
作者: 烁灵    时间: 2011-1-7 19:19
  1. #Disable HUD Switch ID.  

  2. STMAPVIS = 1

复制代码
唉,咱又自大了,本来脚本里已经带了消失和显示的开关了,试试一号开关的打开和关闭,
晚辈的改动就删了吧


烁灵于2011-1-7 19:19补充以下内容:
  1. #Disable HUD Switch ID.  

  2. STMAPVIS = 1

复制代码
唉,咱又自大了,本来脚本里已经带了消失和显示的开关了,试试一号开关的打开和关闭,
晚辈的改动就删了吧




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1