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

Project1

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

[已经过期] 彩虹神剑高手,进!

[复制链接]

Lv3.寻梦者

梦石
0
星屑
995
在线时间
180 小时
注册时间
2013-2-16
帖子
176
跳转到指定楼层
1
 楼主| 发表于 2013-3-6 21:20:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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


我自己实在是改的都昏了,才来求救的.......
谢了{:2_264:}  

点评

LBQ
彩虹神剑这个不是本质。改不改我认为都无所谓。  发表于 2013-3-7 05:35
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-11-15 02:16

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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