Project1

标题: 把以下脚本 改成 要打开开关才启动脚本 [打印本页]

作者: cAiNiao丶    时间: 2009-4-5 19:20
提示: 作者被禁止或删除 内容自动屏蔽
作者: cAiNiao丶    时间: 2009-4-5 21:29
提示: 作者被禁止或删除 内容自动屏蔽
作者: 凌辰    时间: 2009-4-5 21:39
http://rpg.blue/viewthread.php?t ... D4%2D5+13%3A36%3A21
作者: cAiNiao丶    时间: 2009-4-5 21:54
提示: 作者被禁止或删除 内容自动屏蔽
作者: tommay    时间: 2009-4-5 23:04
LZ试试
  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 = 0 # Y Pos
  11. #use HUD Switch ID.  
  12. STMAPVIS = 99
  13. #Windowskin name.
  14. STMAPSKIN = "001-Blue01"
  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 - 35, y - ch + 40, 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 - 24, y - ch + 11, 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 - 37, y - ch + 6, text, src_rect)
  40. self.contents.font.color = Color.new(0,0,0,255)
  41. self.contents.draw_text(x + 1, y - 12, 48, 32, actor.hp.to_s, 2)
  42. self.contents.font.color = Color.new(250,255,255,255)
  43. self.contents.draw_text(x + 0, y - 13, 48, 32, actor.hp.to_s, 2)   
  44. end  
  45. def draw_mapsp2(actor, x, y)
  46. back = RPG::Cache.picture("")   
  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 + 27, 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 + 52, y - ch + 8, 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 + 39, y - ch + 6, text, src_rect)
  61. self.contents.font.color = Color.new(0,0,0,255)
  62. self.contents.draw_text(x + 80, y - 12, 48, 32, actor.sp.to_s, 2)   
  63. self.contents.font.color = Color.new(250,255,255,255)
  64. self.contents.draw_text(x + 79, y - 13, 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 + "") 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 - 41, y - 2, 32, 32, "Lv")
  112. self.contents.font.color = Color.new(50,255,250,255)   
  113. self.contents.draw_text(x - 42, y - 3, 32, 32, "Lv")
  114. self.contents.font.color = Color.new(0,0,0,255)
  115. self.contents.draw_text(x - 5, y - 2, 24, 32, actor.level.to_s, 1)
  116. self.contents.font.color = Color.new(255,255,255,255)   
  117. self.contents.draw_text(x - 6, y - 3, 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]
  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]
  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
复制代码
[LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: cAiNiao丶    时间: 2009-4-5 23:12
提示: 作者被禁止或删除 内容自动屏蔽
作者: tommay    时间: 2009-4-5 23:14
以下引用cAiNiao丶于2009-4-5 15:12:35的发言:

你是不是 只改了STMAPVIS = 99  这里  就可以了?

不止,STMAPVIS = 99 这里是 Disable 该脚本的开关,而你要的效果是“当开关打开时启用”,下面有微小的改动。
作者: cAiNiao丶    时间: 2009-4-5 23:26
提示: 作者被禁止或删除 内容自动屏蔽
作者: zphyp120    时间: 2009-4-5 23:33
自己拿出来对比下不就完了

作者: cAiNiao丶    时间: 2009-4-5 23:36
提示: 作者被禁止或删除 内容自动屏蔽
作者: tommay    时间: 2009-4-5 23:42
以下引用cAiNiao丶于2009-4-5 15:26:17的发言:

改了什么地方? 我提出问题 是为了 收获知识  而目的并不只为了 改这个脚本  我想学会怎么样修改!

应该说,这个脚本本身就已经具备了开关控制的功能,具体可以参见注释里的“#Disable HUD Switch ID”一行,下面的“STMAPVIS = 1”就说明是1号开关控制脚本。

具体是如何控制的,你可以在这个脚本中搜索“STMAPVIS”,你会找到两个地方有,都是“if $game_switches[MOG::STMAPVIS]==false”,参加下面的执行,可以知道,当$game_switches[MOG::STMAPVIS]这个开关关闭时,@sthero是可见的,否则是不可见的。这就说明默认情况下,开关关闭时是可见的,只有打开那个开关,才会使之不可见。

其实我改的方法很简单,直接把“if $game_switches[MOG::STMAPVIS]==false”改为“if $game_switches[MOG::STMAPVIS]”,别的我也没看,所以请你试一下满不满足要求。 [LINE]1,#dddddd[/LINE]版主对此帖的认可:『好孩子鼓励加分^_^』,积分『+250』。
作者: cAiNiao丶    时间: 2009-4-5 23:50
提示: 作者被禁止或删除 内容自动屏蔽




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