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

Project1

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

[已经过期] 谁能把彩虹神剑加上显示SP伤害的功能

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
45 小时
注册时间
2011-11-26
帖子
90
跳转到指定楼层
1
 楼主| 发表于 2013-1-30 19:53:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
谁能把下面这个彩虹神剑加上显示SP伤害的功能
加减sp都要显示出来,加的用蓝色,减的用紫色

(如果觉得很容易的话,那就再帮我加上显示状态伤害的功能吧)

RUBY 代码复制
  1. =begin
  2. ==============================================================================
  3.  
  4. 彩虹神剑(伤害分段显示)显示总伤害版 v1.0b
  5.  
  6. ==============================================================================
  7.  
  8. 彩虹神剑 by 柳柳
  9. 显示总伤害修改 by 叶子
  10.  
  11. ==============================================================================
  12.  
  13. 6-20-2006 v1.0
  14. 在彩虹神剑的基础上增加了显示总伤害的功能,而且总伤害的数字是弹出伤害时逐渐增加的
  15.  
  16. v1.0a
  17. 修正了显示伤害和实际伤害有差别的问题
  18. 修正了miss的情况下显示miss混乱的问题
  19. 修正了对己方技能重复显示伤害的问题
  20. 未修正播放目标动画第一帧时目标有时无端跳动的BUG
  21.  
  22. v1.0b
  23. 修改了总伤害数字的位置和z坐标
  24. 未修正播放目标动画第一帧时目标有时无端跳动的BUG
  25.  
  26. ==============================================================================
  27. =end
  28. # 核心的说明:
  29. # damage_pop 不再附带damage()的功能,这个放到animation里面去了
  30.  
  31. module RPG
  32. #--------------------------------------------------------------------------
  33. # ● 常量设定
  34. #--------------------------------------------------------------------------
  35. # 是否显示总伤害
  36. SHOW_TOTAL_DAMAGE = true
  37. # 角色受攻击时是否跳一下
  38. BATTLER_JUMP = false
  39. class Sprite < ::Sprite
  40. #==========================================
  41. # 修改说明:
  42. # @flash_shake用来制作挨打时候跳跃
  43. # @_damage 用来记录每次打击之后弹出数字
  44. # @_total_damage 记录总伤害
  45. # @_total_damage_duration 总伤害持续帧
  46. #==========================================
  47. #alias 66RPG_rainbow_initialize : initialize
  48. def initialize(viewport = nil)
  49. #66RPG_rainbow_initialize(viewport)
  50. super(viewport)
  51. @_whiten_duration = 0
  52. @_appear_duration = 0
  53. @_escape_duration = 0
  54. @_collapse_duration = 0
  55. @_damage_duration = 0
  56. @_animation_duration = 0
  57. @_blink = false
  58. # 挨打时候跳跃
  59. @flash_shake = 0
  60. # 伤害记录数组
  61. @_damage = []
  62. # 总伤害数字
  63. @_total_damage = 0
  64. # 总伤害持续帧
  65. @_total_damage_duration = 0
  66. end
  67. def damage(value, critical)
  68. if value.is_a?(Numeric)
  69. damage_string = value.abs.to_s
  70. else
  71. damage_string = value.to_s
  72. end
  73. bitmap = Bitmap.new(160, 48)
  74. bitmap.font.name = "Arial Black"
  75. bitmap.font.size = 32
  76. bitmap.font.color.set(0, 0, 0)
  77. bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  78. bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  79. bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  80. bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  81. #=======================================
  82. # 修改:颜色
  83. #=======================================
  84. if value.is_a?(Numeric) and value < 0
  85. bitmap.font.color.set(176, 255, 144)
  86. else
  87. bitmap.font.color.set(255, 55, 55)
  88. end
  89. bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  90. if critical
  91. bitmap.font.size = 20
  92. bitmap.font.color.set(0, 0, 0)
  93. bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  94. bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  95. bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  96. bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  97. bitmap.font.color.set(255, 255, 255)
  98. bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  99. end
  100. @_damage_sprite = ::Sprite.new(self.viewport)
  101. @_damage_sprite.bitmap = bitmap
  102. @_damage_sprite.ox = 80
  103. @_damage_sprite.oy = 20
  104. @_damage_sprite.x = self.x
  105. @_damage_sprite.y = self.y - self.oy / 2
  106. @_damage_sprite.z = 3000
  107. @_damage_duration = 40
  108. #=======================================
  109. # 修改:推入新的伤害
  110. #=======================================
  111. @_damage.push([@_damage_sprite,@_damage_duration-10,0, rand(30) - 15, rand(3)])
  112. # 总伤害处理
  113. make_total_damage(value)
  114. end
  115. #--------------------------------------------------------------------------
  116. # ● 总伤害处理
  117. #--------------------------------------------------------------------------
  118. def make_total_damage(value)
  119. if value.is_a?(Numeric) and SHOW_TOTAL_DAMAGE
  120. @_total_damage += value
  121. else
  122. return
  123. end
  124. bitmap = Bitmap.new(300, 150)
  125. bitmap.font.name = "Arial Black"
  126. bitmap.font.size = 48
  127. bitmap.font.color.set(0, 0, 0)
  128. bitmap.draw_text(+2, 12+2, 160, 36, @_total_damage.abs.to_s, 1)
  129. if @_total_damage < 0
  130. bitmap.font.color.set(80, 255, 00)
  131. else
  132. bitmap.font.color.set(255, 140, 0)
  133. end
  134. bitmap.draw_text(0, 12, 160, 36, @_total_damage.abs.to_s, 1)
  135. if @_total_damage_sprite.nil?
  136. @_total_damage_sprite = ::Sprite.new(self.viewport)
  137. @_total_damage_sprite.ox = 80
  138. @_total_damage_sprite.oy = 20
  139. @_total_damage_sprite.z = 3000
  140. end
  141. @_total_damage_sprite.bitmap = bitmap
  142. @_total_damage_sprite.zoom_x = 1.5
  143. @_total_damage_sprite.zoom_y = 1.5
  144. @_total_damage_sprite.x = self.x
  145. @_total_damage_sprite.y = self.y - self.oy / 2 - 64
  146. @_total_damage_sprite.z = 3001
  147. @_total_damage_duration = 80
  148. end
  149. def animation(animation, hit, battler_damage="", battler_critical=false)
  150. dispose_animation
  151. #=======================================
  152. # 修改:记录伤害和critical
  153. #=======================================
  154. @battler_damage = battler_damage
  155. @battler_critical = battler_critical
  156. @_animation = animation
  157. return if @_animation == nil
  158. @_animation_hit = hit
  159. @_animation_duration = @_animation.frame_max
  160. animation_name = @_animation.animation_name
  161. animation_hue = @_animation.animation_hue
  162. bitmap = RPG::Cache.animation(animation_name, animation_hue)
  163. #=======================================
  164. # 修改:计算总闪光权限值
  165. #=======================================
  166. for timing in @_animation.timings
  167. quanzhong = animation_process_timing(timing, @_animation_hit,true)
  168. @all_quanzhong += quanzhong
  169. # 记录最后一次闪光
  170. @_last_frame = timing.frame if quanzhong != 0
  171. end
  172. if @@_reference_count.include?(bitmap)
  173. @@_reference_count[bitmap] += 1
  174. else
  175. @@_reference_count[bitmap] = 1
  176. end
  177. #=======================================
  178. # 修改:行动方动画不显示伤害
  179. #=======================================
  180. if $scene.is_a?(Scene_Battle)
  181. if $scene.animation1_id == @battler.animation_id
  182. @battler_damage = ""
  183. end
  184. end
  185. @_animation_sprites = []
  186. if @_animation.position != 3 or not @@_animations.include?(animation)
  187. for i in 0..15
  188. sprite = ::Sprite.new(self.viewport)
  189. sprite.bitmap = bitmap
  190. sprite.visible = false
  191. @_animation_sprites.push(sprite)
  192. end
  193. unless @@_animations.include?(animation)
  194. @@_animations.push(animation)
  195. end
  196. end
  197. update_animation
  198. end
  199. #=======================================
  200. # 修改:更换清除伤害的算法,以防万一
  201. # 本内容在脚本中没有使用过
  202. #=======================================
  203. def dispose_damage
  204. for damage in @_damage.reverse
  205. damage[0].bitmap.dispose
  206. damage[0].dispose
  207. @_damage.delete(damage)
  208. end
  209. @_total_damage = 0
  210. @_last_frame = -1
  211. if @_total_damage_sprite != nil
  212. @_total_damage_duration = 0
  213. @_total_damage_sprite.bitmap.dispose
  214. @_total_damage_sprite.dispose
  215. @_total_damage_sprite = nil
  216. end
  217. end
  218. def dispose_animation
  219. #=======================================
  220. # 修改:清除记录的伤害,清除权重记录
  221. #=======================================
  222. @battler_damage = nil
  223. @battler_critical = nil
  224. @all_quanzhong = 1
  225. @_total_damage = 0
  226. @_last_frame = -1
  227. if @_animation_sprites != nil
  228. sprite = @_animation_sprites[0]
  229. if sprite != nil
  230. @@_reference_count[sprite.bitmap] -= 1
  231. if @@_reference_count[sprite.bitmap] == 0
  232. sprite.bitmap.dispose
  233. end
  234. end
  235. for sprite in @_animation_sprites
  236. sprite.dispose
  237. end
  238. @_animation_sprites = nil
  239. @_animation = nil
  240. end
  241. end
  242. def update
  243. super
  244. if @_whiten_duration > 0
  245. @_whiten_duration -= 1
  246. self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  247. end
  248. if @_appear_duration > 0
  249. @_appear_duration -= 1
  250. self.opacity = (16 - @_appear_duration) * 16
  251. end
  252. if @_escape_duration > 0
  253. @_escape_duration -= 1
  254. self.opacity = 256 - (32 - @_escape_duration) * 10
  255. end
  256. if @_collapse_duration > 0
  257. @_collapse_duration -= 1
  258. self.opacity = 256 - (48 - @_collapse_duration) * 6
  259. end
  260. #=======================================
  261. # 修改:更新算法,更新弹出
  262. #=======================================
  263. if @_damage_duration > 0
  264. @_damage_duration -= 1
  265. for damage in @_damage
  266. damage[0].x = self.x + self.viewport.rect.x -
  267. self.ox + self.src_rect.width / 2 +
  268. (40 - damage[1]) * damage[3] / 10
  269. damage[0].y -= damage[4]+damage[1]/10
  270. damage[0].opacity = damage[1]*20
  271. damage[1] -= 1
  272. if damage[1]==0
  273. damage[0].bitmap.dispose
  274. damage[0].dispose
  275. @_damage.delete(damage)
  276. next
  277. end
  278. end
  279. end
  280. #=======================================
  281. # 添加:弹出总伤害
  282. #=======================================
  283. if @_total_damage_duration > 0
  284. @_total_damage_duration -= 1
  285. @_total_damage_sprite.y -= 1 if @_total_damage_duration % 2 == 0
  286. if @_total_damage_sprite.zoom_x > 1.0
  287. @_total_damage_sprite.zoom_x -= 0.05
  288. end
  289. if @_total_damage_sprite.zoom_y > 1.0
  290. @_total_damage_sprite.zoom_y -= 0.05
  291. end
  292. @_total_damage_sprite.opacity = 256 - (24 - @_total_damage_duration) * 16
  293. if @_total_damage_duration <= 0
  294. @_total_damage = 0
  295. @_total_damage_duration = 0
  296. @_total_damage_sprite.bitmap.dispose
  297. @_total_damage_sprite.dispose
  298. @_total_damage_sprite = nil
  299. end
  300. end
  301. #=======================================
  302. if @_animation != nil and (Graphics.frame_count % 2 == 0)
  303. @_animation_duration -= 1
  304. update_animation
  305. end
  306. if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  307. update_loop_animation
  308. @_loop_animation_index += 1
  309. @_loop_animation_index %= @_loop_animation.frame_max
  310. end
  311. if @_blink
  312. @_blink_count = (@_blink_count + 1) % 32
  313. if @_blink_count < 16
  314. alpha = (16 - @_blink_count) * 6
  315. else
  316. alpha = (@_blink_count - 16) * 6
  317. end
  318. self.color.set(255, 255, 255, alpha)
  319. end
  320. @@_animations.clear
  321. end
  322. def update_animation
  323. if @_animation_duration > 0
  324. frame_index = @_animation.frame_max - @_animation_duration
  325. cell_data = @_animation.frames[frame_index].cell_data
  326. position = @_animation.position
  327. animation_set_sprites(@_animation_sprites, cell_data, position)
  328. #=======================================
  329. # 修改:弹出伤害,权重计算
  330. #=======================================
  331. for timing in @_animation.timings
  332. if timing.frame == frame_index
  333. t = 1.0 * animation_process_timing(timing, @_animation_hit)
  334. #p t,"当前权重", @all_quanzhong,"总权重"
  335. if @battler_damage.is_a?(Numeric) and t != 0
  336. t *= @battler_damage
  337. t /= @all_quanzhong
  338. #p t,"当前伤害",@battler_damage,"总伤害"
  339. t = t.to_i
  340. # 最后一次闪光的话,伤害修正
  341. if frame_index == @_last_frame
  342. @_total_damage = @battler_damage - t
  343. end
  344. #p t,@battler_damage,@all_quanzhong
  345. damage(t,@battler_critical)
  346. # 防止重复播放miss
  347. elsif !@battler_damage.is_a?(Numeric) and timing.flash_scope != 0
  348. damage(@battler_damage,@battler_critical)
  349. end
  350. end
  351. end
  352. else
  353. dispose_animation
  354. end
  355. end
  356. #=======================================
  357. # 修改:敌人跳跃的功能 + 添加返回数值
  358. #=======================================
  359. def animation_process_timing(timing, hit,dontflash=false)
  360. if (timing.condition == 0) or
  361. (timing.condition == 1 and hit == true) or
  362. (timing.condition == 2 and hit == false)
  363. unless dontflash
  364. if timing.se.name != ""
  365. se = timing.se
  366. Audio.se_play("Audio/SE/" + se.name, se.volume, se.pitch)
  367. end
  368. end
  369. case timing.flash_scope
  370. when 1
  371. unless dontflash
  372. self.flash(timing.flash_color, timing.flash_duration * 2)
  373. if @_total_damage >0
  374. @flash_shake_switch = true
  375. @flash_shake = 10
  376. end
  377. end
  378. return timing.flash_color.alpha * timing.flash_duration
  379. when 2
  380. unless dontflash
  381. if self.viewport != nil
  382. self.viewport.flash(timing.flash_color, timing.flash_duration * 2)
  383. return timing.flash_color.alpha * timing.flash_duration
  384. end
  385. end
  386. when 3
  387. unless dontflash
  388. self.flash(nil, timing.flash_duration * 2)
  389. end
  390. return timing.flash_color.alpha * timing.flash_duration
  391. end
  392. end
  393. return 0
  394. end
  395. end
  396. end
  397. #==============================================================================
  398. # ■ Sprite_Battler
  399. #==============================================================================
  400. class Sprite_Battler < RPG::Sprite
  401. #--------------------------------------------------------------------------
  402. # ● 初始化对像
  403. # 添加跳跃记录
  404. #--------------------------------------------------------------------------
  405. def initialize(viewport, battler = nil)
  406. super(viewport)
  407. [url=home.php?mod=space&uid=133701]@battler[/url] = battler
  408. @battler_visible = false
  409. @flash_shake_switch = true
  410. end
  411. #--------------------------------------------------------------------------
  412. # ● 刷新画面
  413. # 增添跳跃功能
  414. #--------------------------------------------------------------------------
  415. def update
  416. super
  417. # 战斗者为 nil 的情况下
  418. if @battler == nil
  419. self.bitmap = nil
  420. loop_animation(nil)
  421. return
  422. end
  423. # 文件名和色相与当前情况有差异的情况下
  424. if @battler.battler_name != @battler_name or
  425. @battler.battler_hue != @battler_hue
  426. # 获取、设置位图
  427. @battler_name = @battler.battler_name
  428. @battler_hue = @battler.battler_hue
  429. self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  430. @width = bitmap.width
  431. [url=home.php?mod=space&uid=291977]@height[/url] = bitmap.height
  432. self.ox = @width / 2
  433. self.oy = @height
  434. ###########################################################################
  435. if @battler.dead?
  436. self.bitmap = RPG::Cache.battler(@battler.id.to_s + "Dead", @battler_hue)
  437. @width = bitmap.width
  438. @height = bitmap.height
  439. self.ox = @width / 2
  440. self.oy = @height
  441. end
  442. # 如果是战斗不能或者是隐藏状态就把透明度设置成 0
  443. if (@battler.dead? or @battler.hidden) and @battler.is_a?(Game_Enemy)
  444. ###########################################################################
  445. self.opacity = 0
  446. end
  447. end
  448. # 动画 ID 与当前的情况有差异的情况下
  449. if @battler.damage == nil and
  450. @battler.state_animation_id != @state_animation_id
  451. @state_animation_id = @battler.state_animation_id
  452. loop_animation($data_animations[@state_animation_id])
  453. end
  454. # 应该被显示的角色的情况下
  455. if @battler.is_a?(Game_Actor) and @battler_visible
  456. # 不是主状态的时候稍稍降低点透明度
  457. if $game_temp.battle_main_phase
  458. self.opacity += 3 if self.opacity < 255
  459. else
  460. self.opacity -= 3 if self.opacity > 207
  461. end
  462. end
  463.  
  464.  
  465.  
  466.  
  467. # 明灭
  468. if @battler.blink
  469. blink_on
  470. else
  471. blink_off
  472. end
  473. # 不可见的情况下
  474. unless @battler_visible
  475. # 出现
  476. if not @battler.hidden and not @battler.dead? and
  477. ###########################################################################
  478. (@battler.damage == nil or @battler.damage_pop)
  479. if @battler.is_a?(Game_Enemy)
  480. ###########################################################################
  481. appear
  482. ###########################################################################
  483. else
  484. self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  485. @width = bitmap.width
  486. @height = bitmap.height
  487. self.ox = @width / 2
  488. self.oy = @height
  489. end
  490. @battler_visible = true
  491. ###########################################################################
  492. end
  493. end
  494. # 可见的情况下
  495. if @battler_visible
  496. # 逃跑
  497. if @battler.hidden
  498. $game_system.se_play($data_system.escape_se)
  499. escape
  500. @battler_visible = false
  501. end
  502. # 白色闪烁
  503. if @battler.white_flash
  504. whiten
  505. @battler.white_flash = false
  506. end
  507. # 动画
  508. if @battler.animation_id != 0
  509. animation = $data_animations[@battler.animation_id]
  510. animation(animation, @battler.animation_hit,@battler.damage, @battler.critical)
  511. @battler.animation_id = 0
  512. end
  513. # 伤害
  514. if @battler.damage_pop
  515.  
  516. @battler.damage = nil
  517. @battler.critical = false
  518. @battler.damage_pop = false
  519. end
  520. ###########################################################################
  521. # korapusu
  522. if @battler.damage == nil and @battler.dead?
  523. if @battler.is_a?(Game_Enemy)
  524. $game_system.se_play($data_system.enemy_collapse_se)
  525. collapse
  526. else
  527. $game_system.se_play($data_system.actor_collapse_se)
  528. # 角色战斗图变为角色ID+"Dead"的名字的战斗图
  529. self.bitmap = RPG::Cache.battler(@battler.id.to_s + "Dead", @battler_hue)
  530. @width = bitmap.width
  531. @height = bitmap.height
  532. self.ox = @width / 2
  533. self.oy = @height
  534. end
  535. @battler_visible = false
  536. ###########################################################################
  537. end
  538. end
  539. # 设置活动块的坐标
  540. if @flash_shake_switch == true
  541. self.x = @battler.screen_x
  542. self.y = @battler.screen_y
  543. self.z = @battler.screen_z
  544. @flash_shake_switch = false
  545. end
  546. if @flash_shake != 0 and @battler.damage != nil and RPG::BATTLER_JUMP
  547. case @flash_shake
  548. when 9..10
  549. self.x = @battler.screen_x
  550. self.y -=4
  551. self.z = @battler.screen_z
  552. when 6..8
  553. self.x = @battler.screen_x
  554. self.y -=2
  555. self.z = @battler.screen_z
  556. when 3..5
  557. self.x = @battler.screen_x
  558. self.y +=2
  559. self.z = @battler.screen_z
  560. when 2
  561. self.x = @battler.screen_x
  562. self.y += 4
  563. self.z = @battler.screen_z
  564. when 1
  565. self.x = @battler.screen_x
  566. self.y = @battler.screen_y
  567. self.z = @battler.screen_z
  568. end
  569. @flash_shake -= 1
  570. end
  571. end
  572. end
  573.  
  574. #==============================================================================
  575. # ■ Scene_Battle
  576. #------------------------------------------------------------------------------
  577. #  处理战斗画面的类。
  578. #==============================================================================
  579.  
  580. class Scene_Battle
  581. #--------------------------------------------------------------------------
  582. # ● 定义实例变量
  583. #--------------------------------------------------------------------------
  584. attr_reader :animation1_id # 行动方动画ID
  585. end
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-24 14:15

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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