Guest User

Untitled

a guest
Mar 9th, 2019
3
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2.  
  3. Damage Text Revamp 2.1
  4. by PK8
  5. Created: 11/18/2009
  6. Modified: 4/8/2012
  7. ──────────────────────────────────────────────────────────────────────────────
  8. ■ Table of Contents
  9. ○ Author's Notes - Line 27-37
  10. ○ Introduction & Description - Line 39-43
  11. ○ Features - Line 45-52
  12. ○ Methods Aliased - Line 54-57
  13. ○ Thanks - Line 59-70
  14. ○ Changelog - Line 72-76
  15. ○ What is this? - Line 78-288
  16. ○ General & Initial Settings - Line 80-106
  17. ○ Settings for Critical/Damage/Heal/Miss - Line 107-119
  18. ○ Iteration Settings - Line 120-127
  19. ○ All Keyframe Settings - Line 128-187
  20. ○ Settings for Damage and Iteration - Line 130-140
  21. ○ All Keyframe_Iteration Settings - Line 141-164
  22. ○ All Normal Keyframe Settings - Line 165-187
  23. ○ Getting into Keyframes - Line 188-288
  24. ○ Keyframe_Advanced: Simple vs. Advanced - Line 190-215
  25. ○ Modifying properties through keyframes - Line 216-288
  26. ──────────────────────────────────────────────────────────────────────────────
  27. ■ Author's Notes
  28. When I first made this script, I remember making it because I was bored and I
  29. was watching people play Eternal Sonata. I couldn't help but love how fancy
  30. the damage text looked, so I wanted to make something kind of like it here.
  31.  
  32. Now when I was working on this version, I went in there thinking
  33. "okay, I'll just edit a few settings and call it a day." It sounds mean, I
  34. know, but that was because I didn't think I'd be able to improve the script
  35. much further. That was, until I saw Victor Sant's collapse script thread for
  36. RPG Maker VX Ace. Seeing that thread gave me some new ideas for what I wanted
  37. to do for this script.
  38. ──────────────────────────────────────────────────────────────────────────────
  39. ■ Introduction & Description
  40. Tired of looking at that rather dull Arial Black font in battle? Are you
  41. looking to fancy the look and animation of your damage text? Look no further,
  42. this is the Damage Text Revamp! It's customisable and it's heavily packed
  43. with options. Have a look for youself!
  44. ──────────────────────────────────────────────────────────────────────────────
  45. ■ Features
  46. o Set X, Y, Blend Type, Angle, Zoom_X, Zoom_Y, Color, Tone of Damage Text.
  47. o Set format, color, and outlines for Damage/Heal/Miss/Critical Val+Text
  48. o Set keyframe animations for damage text.
  49. o Set specific keyframe animations for Damage/Heal/Miss/Critical text.
  50. o Enable or disable damage counting (known as Iteration).
  51. o Create keyframe animations for damage counting.
  52. o Create specific damage counting keyfreame animations for Dmg/Heal/Miss/Crit
  53. ──────────────────────────────────────────────────────────────────────────────
  54. ■ Methods Aliased
  55. o damage of Sprite < ::Sprite class in the RPG module.
  56. Note that it kind of... rewrites the whole damage method.
  57. o update of Sprite < ::Sprite class in the RPG module.
  58. ──────────────────────────────────────────────────────────────────────────────
  59. ■ Thanks
  60. Yeyinde's help with fixing stacking error issues.
  61. Rhyme helped me out a few years ago on drawing outlines better.
  62. Kain Nobel asking for the Miss text to have a custom string to it, and
  63. suggesting a scrolling text option. My Iteration feature probably looks
  64. nothing like what he requested but it should be just as epic.
  65. MetalRenard pretty much telling me to "make this as epic as possible" made
  66. want to go all out on this script. Again for asking about it being
  67. possible to make the sprite flash every time the value reaches +100 more,
  68. which made me add the dmg_v variable.
  69. Victor Sant's Collapse script for RPG Maker VX Ace inspired me to attempt
  70. a custom animation feature for Damage Text.
  71. ──────────────────────────────────────────────────────────────────────────────
  72. ■ Changelog (MM/DD/YYYY)
  73. v1 (11/18/2009) - Initial release.
  74. v2 (4/6/2012) - Remade, added a plethora of new settings.
  75. v2.0.1 (4/6/2012) - New dmg_v variable to help ease script calling needs.
  76. v2.1 (4/8/2012) - New switch setting added.
  77. ──────────────────────────────────────────────────────────────────────────────
  78. ■ What is this?
  79. ┌──────────────────────────────────────────────────────────────────────────┐
  80. │ ■ General and initial settings. │
  81. └──────────────────────────────────────────────────────────────────────────┘
  82. o Switch: TRUE turns it on, FALSE turns it off. Can be turned on or off at
  83. any time by calling: PK8::DamageText::Switch = bool*
  84. * Replace bool with either true or false
  85. o X: Adjust X offset of the damage text sprite.
  86. o Y: Adjust Y offset of the damage text sprite.
  87. o Angle: Set angle of damage text sprite.
  88. o Blend: Set blend type of damage text sprite. (0: Normal, 1: Add, 2: Sub)
  89. o Color: Set color for damage text sprite. [red, green, blue, alpha]
  90. red : Set amount of red. (Values: 0 - 255)
  91. green: Set amount of green. (Values: 0 - 255)
  92. blue : Set amount of blue. (Values: 0 - 255)
  93. alpha: Set amount of alpha. (Values: 0 - 255, optional)
  94. o Mirror: Flip sprite horizontally? (true or false)
  95. o Tone: Set tone for damage text sprite. [red, green, blue, grey]
  96. red : Set amount of red. (Values: -255 - 255)
  97. green: Set amount of green. (Values: -255 - 255)
  98. blue : Set amount of blue. (Values: -255 - 255)
  99. grey : Set amount of grey. (Values: 0 - 255, optional)
  100. o Zoom_X: Adjust the damage text sprite's X-Axis zoom level.
  101. * 1.0 denotes actual pixel size.
  102. o Zoom_Y: Adjust the damage text sprite's Y-Axis zoom level.
  103. * 1.0 denotes actual pixel size.
  104. o Debug: You can set which keyframe animations you'd like to preview by
  105. changing the string of this setting. Only works during DEBUG.
  106.  
  107. ┌──────────────────────────────────────────────────────────────────────────┐
  108. │ ■ Setting format and colors for Damage, Heal, Miss, and Critical. │
  109. └──────────────────────────────────────────────────────────────────────────┘
  110. o *_String: Set text. (For CriticalText and Miss)
  111. o *_Font: Set font(s).
  112. o *_Size: Set font size. (CriticalText: 20, Others: 48)
  113. o *_Bold: Boldface text? (true or false)
  114. o *_Italic: Italicize text? (true or false)
  115. o *_Color: Set the color of the text. (r, g, b[, a]) (0 - 255)
  116. o *_Outline: Set the outline of the text. (r, g, b[, a]) (0 - 255)
  117.  
  118. *: Heal, Miss, Damage, CriticalText, CriticalVal
  119.  
  120. ┌──────────────────────────────────────────────────────────────────────────┐
  121. │ ■ Iteration settings. │
  122. └──────────────────────────────────────────────────────────────────────────┘
  123. o Iteration: How many times should the damage sprite be rendered with a
  124. reduced value before it reaches the damage's real value?
  125. * Do not use a large integer. To disable, set this to 1.
  126. o Iteration_Countdown: If TRUE, counts down. If FALSE, counts up from 0.
  127.  
  128. ┌──────────────────────────────────────────────────────────────────────────┐
  129. │ ■ All Keyframe settings │
  130. └┬────────────────────────────────────────────────────────┬────────────────┘
  131. │ Keyframe settings that applies to Damage and Iteration │
  132. └────────────────────────────────────────────────────────┘
  133. o Keyframe_Advanced: Allow for more advanced keyframe customization?
  134. * false: Simple version. | true: Advanced version.
  135. * "" : Don't override
  136. "critical": Override with Critical
  137. "damage" : Override with Damage
  138. "miss" : Override with Miss
  139. "heal" : Override with Heal
  140.  
  141. └┬─────────────────────────────────┬───────────────────────────────────────┘
  142. │ All Keyframe_Iteration settings │
  143. └─────────────────────────────────┘
  144. o Keyframe_Iteration_Flag: Enable custom damage text animations for damage
  145. counting? (true or false)
  146.  
  147. o Keyframe_Iteration[id]: Set keyframe animations when counting for all
  148. damage text. Acts as a fallback should any of
  149. the Keyframe_Iteration_*_Flag settings get set
  150. to FALSE.
  151. o Keyframe_Iteration_Heal[id]: Set keyframe animations when counting for
  152. healing text.
  153. o Keyframe_Iteration_Damage[id]: Set keyframe animations when counting for
  154. damage text.
  155. o Keyframe_Iteration_Critical[id]: Set keyframe animations when counting
  156. for critical damage text.
  157. * Only customize these when Keyframe_Iteration_*_Flag is set to TRUE.
  158.  
  159. o Keyframe_Iteration_Heal_Flag: Enable counting animations for healing?
  160. o Keyframe_Iteration_Damage_Flag: Enable counting animations for normal dmg
  161. o Keyframe_Iteration_Critical_Flag: Enable counting animations for crit dmg
  162.  
  163. * It animates from the duration of the animation to 0
  164.  
  165. └┬──────────────────────────────┬──────────────────────────────────────────┘
  166. │ All Normal Keyframe settings │
  167. └──────────────────────────────┘
  168. o Keyframe_Flag: Enable custom damage text animations? (true or false)
  169. o Keyframe_Duration: How many frames would the animation last for?
  170. more information about Keyframes_Advanced starting at 164.
  171.  
  172. o Keyframe[id]: Set keyframe animations for all damage text. Acts as a
  173. fallback should any of the Keyframe_*_Flag settings get
  174. set to FALSE
  175. o Keyframe_Heal[id] = Set keyframe animations for Heal text.
  176. o Keyframe_Miss[id] = Set keyframe animations for Miss text.
  177. o Keyframe_Damage[id] = Set keyframe animations for Damage text.
  178. o Keyframe_Critical[id] = Set keyframe animations for Critical Damage text.
  179. * Only customize these when Keyframe_*_Flag is set to TRUE.
  180.  
  181. o Keyframe_Heal_Flag: Enable damage text animations for healing?
  182. o Keyframe_Miss_Flag: Enable damage text animations for missing?
  183. o Keyframe_Damage_Flag: Enable damage text animations for normal attacks?
  184. o Keyframe_Critical_Flag: Enable damage text animations for critical hits?
  185.  
  186. * It animates from the duration of the animation to 0
  187.  
  188. ┌──────────────────────────────────────────────────────────────────────────┐
  189. │ ■ Getting into keyframes │
  190. └┬───────────────────────────────────────┬─────────────────────────────────┘
  191. │ Keyframe_Advanced: Simple vs Advanced │
  192. └───────────────────────────────────────┘
  193. o true: allows for some serious scripting freedom for the damage text
  194. [ advanced] animation. You get to script in script calls, big conditionals,
  195. and other things without having to start off with a call to alter
  196. the damage text sprite.
  197.  
  198. Example: Keyframe[40] = ["dmg.opacity = 0", "dmg.y -= 2"]
  199. Keyframe[39] = ["dmg.opacity += 25", "dmg.y -= 2"]
  200. Keyframe[34] = ["dmg.opacity += 25", "dmg.y -= 1"]
  201. Keyframe[29] = ["dmg.y -= 0"]
  202. Keyframe[11] = ["dmg.opacity -= 25", "dmg.y -= 1"]
  203. Keyframe[6] = ["dmg.opacity -= 25", "dmg.y -= 2"]
  204.  
  205. o false: Offers the same customisation as advanced mode but with the
  206. [ simple] requirement that creators start off with modifying the property
  207. of a sprite.
  208.  
  209. Example: Keyframe[40] = ["opacity = 0", "y -= 2"]
  210. Keyframe[39] = ["opacity += 25", "y -= 2"]
  211. Keyframe[34] = ["opacity += 25", "y -= 1"]
  212. Keyframe[29] = ["y -= 0"]
  213. Keyframe[11] = ["opacity -= 25", "y -= 1"]
  214. Keyframe[6] = ["opacity -= 25", "y -= 2"]
  215.  
  216. └┬────────────────────────────────────────┬────────────────────────────────┘
  217. │ Modifying properties through keyframes │
  218. └────────────────────────────────────────┘
  219. You can use certain variables I created to aid creating your script calls.
  220.  
  221. Variable Variable Description
  222. ────────────────┬──────────────────────────────────────────────────────────
  223. dmg: │ It stores the damage text sprite and with it, all of its
  224. │ properties that can be altered.
  225. dmg_i: │ This stores the frame the animation is currently up to.
  226. [n..1] │ Useful for tweening formulas involving iteration count.
  227. dmg_d: │ This stores the duration of the animation. Useful for
  228. [n] │ tweening formulas involving iteration count.
  229. dmg_v: │ Gets damage value.
  230. dmg_iv: │ Gets iterated damage value.
  231. i: │ This stores the frame the animation is currently up to in
  232. [1..n] │ ascending order. Useful for tweening formulas involving
  233. │ iteration count.
  234. ────────────────┴──────────────────────────────────────────────────────────
  235. ──────────────────────────────────
  236. For future reference, you can always look up the Help File for RPG Maker on
  237. Sprite and read up on all of their properties. (That's where this is taken
  238. from.)
  239.  
  240. Property/Method Property/Method Description
  241. ────────────────┬──────────────────────────────────────────────────────────
  242. o angle: │ Angle of rotation. Specifies up to 360 degrees of
  243. │ counterclockwise rotation. However, drawing a rotated
  244. │ sprite is time-consuming, so avoid overuse.
  245. o animation: │ Give the damage text sprite an animation.
  246. │ * Syntax : animation(animation, hit)
  247. │ * Example: animation($data_animations[20], true)
  248. o blend_type: │ Blending mode.
  249. │ * 0: normal, 1: addition, 2: subtraction
  250. o color: │ The color to be blended with the sprite. Alpha values are
  251. │ used in the blending ratio.
  252. │ * Example: color = Color.new(red, green, blue[, alpha])
  253. o color.red: │ Accesses the amount of red coloring.
  254. o color.green: │ Accesses the amount of green coloring.
  255. o color.blue: │ Accesses the amount of blue coloring.
  256. o color.alpha: │ Accesses the amount of alpha in the color.
  257. o flash: │ Begins flashing the sprite. Duration specifies the number
  258. │ of frames the flash will last. If color is set to nil,
  259. │ the sprite will disappear while flashing.
  260. │ * Syntax: flash(Color.new(r, g, b[, a]), duration)
  261. │ * Example: flash(Color.new(255, 255, 255), 10)
  262. o loop_animation│ Plays the animation specified in animation in a loop on
  263. │ the indicated sprite. Can be displayed at the same time
  264. │ as a normal animation.
  265. │ * Syntax : loop_animation(animation)
  266. │ * Example: loop_animation($data_animations[20])
  267. o mirror: │ Flag denoting the sprite has been flipped horizontally.
  268. │ If TRUE, the sprite will be drawn flipped.
  269. o opacity: │ Opacity. 0 - 255. Out of range values are auto-corrected
  270. o tone: │ Color tone.
  271. │ * Example: tone = Tone.new(red, green, blue[, gray])
  272. o tone.red: │ Accesses the amount of red in the tone.
  273. o tone.green: │ Accesses the amount of green in the tone.
  274. o tone.blue: │ Accesses the amount of blue in the tone.
  275. o tone.gray: │ Accesses the amount of gray in the tone.
  276. o visible: │ Visibility. If TRUE, the sprite is visible.
  277. o x: │ X coordinate.
  278. o y: │ Y coordinate.
  279. o zoom_x: │ X-axis zoom level. 1.0 denotes actual pixel size.
  280. o zoom_y: │ Y-axis zoom level. 1.0 denotes actual pixel size.
  281. ────────────────┴──────────────────────────────────────────────────────────
  282. ──────────────────────────────────
  283. Operator Expressions that could be useful for tweening
  284.  
  285. ┌─────────┬──────────┬──────────┬────────┬──────────┬──────────┬───────────┐
  286. │ = │ += │ -= │ *= │ /= │ %= │ **= │
  287. └─────────┴──────────┴──────────┴────────┴──────────┴──────────┴───────────┘
  288.  
  289. =end
  290.  
  291. #===============================================================================​
  292. # * Configuration
  293. #===============================================================================​
  294. module PK8
  295. class DamageText
  296. #---------------------------------------------------------------------------
  297. # * Do not modify.
  298. #---------------------------------------------------------------------------
  299. Keyframes = []
  300. Keyframes_Heal = []
  301. Keyframes_Damage = []
  302. Keyframes_Critical = []
  303. Keyframes_Miss = []
  304. Keyframes_Iteration = []
  305. Keyframes_Iteration_Heal = []
  306. Keyframes_Iteration_Damage = []
  307. Keyframes_Iteration_Critical = []
  308.  
  309. #---------------------------------------------------------------------------
  310. # * General and initial settings.
  311. #---------------------------------------------------------------------------
  312. Switch = true # Turn the system on or off.
  313. X = 80 # Sprite X-offset
  314. Y = 20 # Sprite Y-offset
  315. Angle = 0 # Sprite Angle
  316. Blend = 0 # Sprite Blend Type (0: Normal, 1: Add, 2: Sub)
  317. Color = [0,0,0,0] # Color: Red, Green, Blue[, Alpha]
  318. Mirror = false # Flip sprite horizontally?
  319. Tone = [0,0,0,0] # Tone: Red, Green, Blue[, Gray]
  320. Zoom_X = 1.0 # X-Axis Zoom Level (1.0 = Actual size)
  321. Zoom_Y = 1.0 # Y-Axis Zoom Level (1.0 = Actual size)
  322. Debug = "" # "", "critical", "damage", "heal", or "miss"
  323.  
  324. #---------------------------------------------------------------------------
  325. # * Set format and colors for Damage, Heal, Miss, and Critical
  326. #---------------------------------------------------------------------------
  327. # Settings for the Damage value text
  328. Damage_Font = ["VCR OSD Mono"]
  329. Damage_Size = 22
  330. Damage_Bold = true
  331. Damage_Italic = false
  332. Damage_Color = [255, 255, 255, 255]
  333. Damage_Outline = [0, 0, 0, 255]
  334.  
  335. # Settings for the Heal value text
  336. Heal_Font = ["VCR OSD Mono"]
  337. Heal_Size = 22
  338. Heal_Bold = true
  339. Heal_Italic = false
  340. Heal_Color = [0, 255, 0, 255]
  341. Heal_Outline = [0, 0, 0, 255]
  342.  
  343. # Settings for the Miss text
  344. Miss_Font = ["VCR OSD Mono"]
  345. Miss_String = "miss"
  346. Miss_Size = 22
  347. Miss_Bold = false
  348. Miss_Italic = true
  349. Miss_Color = [224, 224, 224, 255]
  350. Miss_Outline = [32, 32, 32, 255]
  351.  
  352. # Settings for the "Critical" text.
  353. CriticalText_Font = ["VCR OSD Mono"]
  354. CriticalText_String = "critical"
  355. CriticalText_Size = 22
  356. CriticalText_Bold = true
  357. CriticalText_Italic = false
  358. CriticalText_Color = [255, 255, 0, 255]
  359. CriticalText_Outline = [0, 0, 0, 255]
  360.  
  361. # Settings for the critical damage value text
  362. CriticalVal_Font = ["VCR OSD Mono"]
  363. CriticalVal_Size = 22
  364. CriticalVal_Bold = true
  365. CriticalVal_Italic = false
  366. CriticalVal_Color = [255, 255, 0, 255]
  367. CriticalVal_Outline = [0, 0, 0, 255]
  368.  
  369. #---------------------------------------------------------------------------
  370. # * Iteration settings
  371. #---------------------------------------------------------------------------
  372. Iteration = 8
  373. Iteration_Countdown = false # (true: counts down | false: counts up)
  374.  
  375. #---------------------------------------------------------------------------
  376. # * Keyframe settings that applies to everything
  377. #---------------------------------------------------------------------------
  378. Keyframes_Advanced = false # false: simple | true: advanced
  379.  
  380. #---------------------------------------------------------------------------
  381. # * Keyframe Iteration settings
  382. #---------------------------------------------------------------------------
  383. # Iteration Keyframes for everything. Used as a fallback whenever iteration
  384. # keyframe flags for specific damage types are set to FALSE.
  385. Keyframes_Iteration_Flag = true # If TRUE, set everything below up.
  386. Keyframes_Iteration[8] = ["opacity = 0", "opacity += 50"]
  387. Keyframes_Iteration[7] = ["opacity += 50", "y -= 0.1"]
  388.  
  389. # Miss Iteration Keyframes
  390. Keyframes_Iteration_Heal_Flag = true
  391. Keyframes_Iteration_Heal[8] = ["opacity = 0", "opacity += 50"]
  392. Keyframes_Iteration_Heal[7] = ["opacity += 50", "y -= 0.5"]
  393.  
  394. # Damage Iteration Keyframes
  395. Keyframes_Iteration_Damage_Flag = true
  396. Keyframes_Iteration_Damage[8] = ["opacity = 0", "opacity += 50"]
  397. Keyframes_Iteration_Damage[7] = ["opacity += 50", "y -= 0.1"]
  398.  
  399. # Critical Iteration Keyframes
  400. Keyframes_Iteration_Critical_Flag = true
  401. Keyframes_Iteration_Critical[8] = ["opacity = 0", "opacity += 32"]
  402. Keyframes_Iteration_Critical[7] = ["opacity += 32", "y -= 0.01",
  403. "zoom_x += 0.01", "zoom_y += 0.01"]
  404.  
  405. #---------------------------------------------------------------------------
  406. # * General Keyframe Settings
  407. #---------------------------------------------------------------------------
  408. Keyframes_Flag = false # If TRUE, set everything below up.
  409. Keyframes_Duration = 40
  410.  
  411. #---------------------------------------------------------------------------
  412. # * Set Keyframe animations for Heal, Miss, Damage, Critical!
  413. #---------------------------------------------------------------------------
  414. # Keyframes for everything. Used as a fallback whenever keyframe flags for
  415. # specific damage types are set to FALSE.
  416. Keyframes[40] = ["y -= 2", "opacity = 0"]
  417. Keyframes[39] = ["y -= 2", "opacity += 50"]
  418. Keyframes[35] = ["opacity += 50"]
  419. Keyframes[10] = ["opacity -= 25"]
  420.  
  421. # Heal Keyframes
  422. Keyframes_Heal_Flag = true # if TRUE, this animation gets used.
  423. Keyframes_Heal[40] = ["y -= 1", "flash(Color.new(255,255,200),10)"]
  424. Keyframes_Heal[39] = ["y -= 1"]
  425. Keyframes_Heal[25] = ["y -= 0.5"]
  426. Keyframes_Heal[10] = ["y -= 0.5", "opacity -= 25"]
  427.  
  428. # Miss Keyframes
  429. Keyframes_Miss_Flag = true # if TRUE, this animation gets used.
  430. Keyframes_Miss[40] = ["y -= 2", "opacity = 0",
  431. "x = x; Audio.se_play('Audio/SE/016-Jump02')"]
  432. Keyframes_Miss[39] = ["y -= 2", "opacity += 75"]
  433. Keyframes_Miss[36] = ["y -= 1"]
  434. Keyframes_Miss[32] = ["y -= 0.5"]
  435. Keyframes_Miss[28] = ["y -= 0.25"]
  436. Keyframes_Miss[24] = ["y -= 0.125"]
  437. Keyframes_Miss[20] = ["y -= 0.0625"]
  438. Keyframes_Miss[10] = ["opacity -= 25", "y -= 0.0625"]
  439.  
  440. # Damage Keyframes
  441. Keyframes_Damage_Flag = true # if TRUE, this animation gets used.
  442. Keyframes_Damage[40] = ["y -= 2", "flash(Color.new(255,255,255),10)"]
  443. Keyframes_Damage[39] = ["y -= 2"]
  444. Keyframes_Damage[35] = ["opacity += 50"]
  445. Keyframes_Damage[10] = ["opacity -= 25"]
  446.  
  447. # Critical Keyframes
  448. Keyframes_Critical_Flag = true # if TRUE, this animation gets used.
  449. Keyframes_Critical[40] = ["y -= 4", "flash(Color.new(255,255,255),40)",
  450. "x = x; Audio.se_play('Audio/SE/158-Skill02')"]
  451. Keyframes_Critical[39] = ["y -= 4", "opacity += 75",
  452. "opacity = 255 if dmg.opacity > 255"]
  453. Keyframes_Critical[35] = ["y -= 1"]
  454. Keyframes_Critical[10] = ["y -= 1", "opacity -= 25"]
  455.  
  456. #---------------------------------------------------------------------------
  457. # * Do not modify.
  458. #---------------------------------------------------------------------------
  459. for i in 0..Keyframes_Duration
  460. Keyframes[i] = [] if Keyframes[i] == nil
  461. Keyframes_Heal[i] = [] if Keyframes_Heal[i] == nil
  462. Keyframes_Miss[i] = [] if Keyframes_Miss[i] == nil
  463. Keyframes_Damage[i] = [] if Keyframes_Damage[i] == nil
  464. Keyframes_Critical[i] = [] if Keyframes_Critical[i] == nil
  465. end
  466. Iteration = 1 if Iteration <= 0
  467. for i in 0..Iteration
  468. Keyframes_Iteration[i] = [] if Keyframes_Iteration[i] == nil
  469. Keyframes_Iteration_Heal[i] = [] if Keyframes_Iteration_Heal[i] == nil
  470. Keyframes_Iteration_Damage[i] = [] if Keyframes_Iteration_Damage[i] == nil
  471. Keyframes_Iteration_Critical[i]=[] if Keyframes_Iteration_Critical[i]==nil
  472. end
  473. end
  474. end
  475.  
  476. #===============================================================================​
  477. # * RPG Module, Sprite Class.
  478. #===============================================================================​
  479. module RPG
  480. class Sprite < ::Sprite
  481. #---------------------------------------------------------------------------
  482. # * Alias Listings
  483. #---------------------------------------------------------------------------
  484. unless method_defined?(:pk8_newdamage_damage)
  485. alias_method(:pk8_newdamage_damage, :damage)
  486. end
  487. unless method_defined?(:pk8_newdamage_update)
  488. alias_method(:pk8_newdamage_update, :update)
  489. end
  490. #---------------------------------------------------------------------------
  491. # * Damage
  492. #---------------------------------------------------------------------------
  493. def damage(value, critical)
  494. pk8_newdamage_damage(value, critical)
  495. if PK8::DamageText::Switch == true
  496. dispose_damage
  497. # Always plays a certain animation. Debug only
  498. if $DEBUG and (!PK8::DamageText::Debug.empty? or
  499. PK8::DamageText::Debug != false)
  500. case PK8::DamageText::Debug.downcase
  501. when "critical", "crit"
  502. critical = true
  503. value = value * 1 if value.is_a?(Numeric)
  504. value = 0 if !value.is_a?(Numeric)
  505. when "damage", "dmg"
  506. critical = false
  507. value = value * 1 if value.is_a?(Numeric)
  508. value = 0 if !value.is_a?(Numeric)
  509. when "miss", "missing", "ms"
  510. critical = false
  511. value = "Miss!"
  512. when "heal", "healing"
  513. critical = false
  514. value = value * -1 if value.is_a?(Numeric)
  515. value = -1 if !value.is_a?(Numeric)
  516. end
  517. end
  518. # Sprite Creation
  519. @_damage_sprite = RPG::Sprite.new(self.viewport)
  520. @_damage_sprite.angle = PK8::DamageText::Angle
  521. @_damage_sprite.blend_type = PK8::DamageText::Blend
  522. @_damage_sprite.color = Color.new(*PK8::DamageText::Color)
  523. @_damage_sprite.mirror = PK8::DamageText::Mirror
  524. @_damage_sprite.tone = Tone.new(*PK8::DamageText::Tone)
  525. @_damage_sprite.zoom_x = PK8::DamageText::Zoom_X
  526. @_damage_sprite.zoom_y = PK8::DamageText::Zoom_Y
  527. @_damage_sprite.ox = PK8::DamageText::X
  528. @_damage_sprite.oy = PK8::DamageText::Y
  529. @_damage_sprite.x = self.x
  530. @_damage_sprite.y = self.y - self.oy / 2
  531. @_damage_sprite.z = 3000
  532. @_damage_value = value
  533. dmg = @_damage_sprite
  534. # Bitmap Creation
  535. bitmap = Bitmap.new(160, 48)
  536. if value.is_a?(Numeric) # If it's not a miss
  537. # Starts Iteration Animation (if flag is TRUE)
  538. if PK8::DamageText::Keyframes_Iteration_Flag == true
  539. if value < 0 # If healing
  540. if PK8::DamageText::Keyframes_Iteration_Heal_Flag == true
  541. keyframes = PK8::DamageText::Keyframes_Iteration_Heal
  542. else
  543. keyframes = PK8::DamageText::Keyframes_Iteration
  544. end
  545. else
  546. if critical == true # If critical
  547. if PK8::DamageText::Keyframes_Iteration_Critical_Flag == true
  548. keyframes = PK8::DamageText::Keyframes_Iteration_Critical
  549. else
  550. keyframes = PK8::DamageText::Keyframes_Iteration
  551. end
  552. else # If normal
  553. if PK8::DamageText::Keyframes_Iteration_Damage_Flag == true
  554. keyframes = PK8::DamageText::Keyframes_Iteration_Damage
  555. else
  556. keyframes = PK8::DamageText::Keyframes_Iteration
  557. end
  558. end
  559. end
  560. dmg_d = PK8::DamageText::Iteration
  561. end
  562. # Damage Counting
  563. for i in 1..PK8::DamageText::Iteration
  564. # New Iterated Value
  565. if PK8::DamageText::Iteration_Countdown == true
  566. damage_string = ((value.abs*2) - (value.abs / ((
  567. PK8::DamageText::Iteration+1)-i))).to_s
  568. else
  569. damage_string = (value.abs / ((
  570. PK8::DamageText::Iteration+1)-i)).to_s
  571. end
  572. # Stores variables for script calling in keyframes.
  573. dmg_v = value.to_i
  574. dmg_iv = damage_string.to_i
  575. # Plays damage counting animations
  576. if PK8::DamageText::Keyframes_Iteration_Flag == true
  577. # Animating sprite during iteration count
  578. dmg_i = (dmg_d + 1 - i)
  579. if keyframes[dmg_i].size > 0 # Detects keyframe
  580. @_damage_property = []
  581. for n in 0..keyframes[dmg_i].size-1
  582. if PK8::DamageText::Keyframes_Advanced == true
  583. @_damage_property[n] = eval("#{keyframes[dmg_i][n]}")
  584. else
  585. @_damage_property[n] = eval("dmg.#{keyframes[dmg_i][n]}")
  586. end
  587. end
  588. @_damage_keyframe = dmg_i
  589. else # Uses previous keyframe. Possibly for tweening purposes.
  590. @_damage_property = []
  591. if @_damage_keyframe != nil
  592. for n in 0..keyframes[@_damage_keyframe].size-1
  593. if PK8::DamageText::Keyframes_Advanced == true
  594. @_damage_property[n] = eval("#{keyframes[
  595. @_damage_keyframe][n]}")
  596. else
  597. @_damage_property[n] = eval("dmg.#{keyframes[
  598. @_damage_keyframe][n]}")
  599. end
  600. end
  601. end
  602. end
  603. dmg.update
  604. for n in 0..@_damage_property.size-1
  605. @_damage_property[n]
  606. end
  607. end
  608. if value < 0 # If healing
  609. @_damage_type = "heal"
  610. bitmap.font.name = PK8::DamageText::Heal_Font
  611. bitmap.font.size = PK8::DamageText::Heal_Size
  612. bitmap.font.bold = PK8::DamageText::Heal_Bold
  613. bitmap.font.italic = PK8::DamageText::Heal_Italic
  614. bitmap.font.color.set(*PK8::DamageText::Heal_Outline)
  615. bitmap.draw_text(-1, 12, 160, 36, damage_string, 1)
  616. bitmap.draw_text(1, 12, 160, 36, damage_string, 1)
  617. bitmap.draw_text(0, 12-1, 160, 36, damage_string, 1)
  618. bitmap.draw_text(0, 12+1, 160, 36, damage_string, 1)
  619. bitmap.font.color.set(*PK8::DamageText::Heal_Color)
  620. else
  621. if critical == true # If critical
  622. @_damage_type = "critical"
  623. # Drawing Critical Text
  624. bitmap.font.name = PK8::DamageText::CriticalText_Font
  625. bitmap.font.size = PK8::DamageText::CriticalText_Size
  626. bitmap.font.bold = PK8::DamageText::CriticalText_Bold
  627. bitmap.font.italic = PK8::DamageText::CriticalText_Italic
  628. # -- Draw Critical String Outline
  629. bitmap.font.color.set(*PK8::DamageText::CriticalText_Outline)
  630. bitmap.draw_text(-1, 0, 160, 20,
  631. PK8::DamageText::CriticalText_String,1)
  632. bitmap.draw_text(1, 0, 160, 20,
  633. PK8::DamageText::CriticalText_String,1)
  634. bitmap.draw_text(0, -1, 160, 20,
  635. PK8::DamageText::CriticalText_String,1)
  636. bitmap.draw_text(0, 1, 160, 20,
  637. PK8::DamageText::CriticalText_String,1)
  638. # -- Draw Critical String Text
  639. bitmap.font.color.set(*PK8::DamageText::CriticalText_Color)
  640. bitmap.draw_text(0, 0, 160, 20,
  641. PK8::DamageText::CriticalText_String, 1)
  642. # Drawing Critical Value
  643. bitmap.font.name = PK8::DamageText::CriticalVal_Font
  644. bitmap.font.size = PK8::DamageText::CriticalVal_Size
  645. bitmap.font.bold = PK8::DamageText::CriticalVal_Bold
  646. bitmap.font.italic = PK8::DamageText::CriticalVal_Italic
  647. # -- Draw Critical Value Outline
  648. bitmap.font.color.set(*PK8::DamageText::CriticalVal_Outline)
  649. bitmap.draw_text(-1, 12, 160, 36, damage_string, 1)
  650. bitmap.draw_text(1, 12, 160, 36, damage_string, 1)
  651. bitmap.draw_text(0, 12-1, 160, 36, damage_string, 1)
  652. bitmap.draw_text(0, 12+1, 160, 36, damage_string, 1)
  653. # -- Set color for Critical Value
  654. bitmap.font.color.set(*PK8::DamageText::CriticalVal_Color)
  655. else # If not critical
  656. @_damage_type = "damage"
  657. bitmap.font.name = PK8::DamageText::Damage_Font
  658. bitmap.font.size = PK8::DamageText::Damage_Size
  659. bitmap.font.bold = PK8::DamageText::Damage_Bold
  660. bitmap.font.italic = PK8::DamageText::Damage_Italic
  661. # Draw Damage Value Outline
  662. bitmap.font.color.set(*PK8::DamageText::Damage_Outline)
  663. bitmap.draw_text(-1, 12, 160, 36, damage_string, 1)
  664. bitmap.draw_text(1, 12, 160, 36, damage_string, 1)
  665. bitmap.draw_text(0, 12-1, 160, 36, damage_string, 1)
  666. bitmap.draw_text(0, 12+1, 160, 36, damage_string, 1)
  667. # Set color for Damage Value
  668. bitmap.font.color.set(*PK8::DamageText::Damage_Color)
  669. end
  670. end
  671. bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  672. @_damage_sprite.bitmap = bitmap
  673. damage_count = Graphics.frame_count
  674. if i < PK8::DamageText::Iteration
  675. loop do
  676. Graphics.update
  677. if Graphics.frame_count >= damage_count
  678. bitmap.clear
  679. break
  680. end
  681. end
  682. end
  683. end
  684. else # If it's a miss.
  685. @_damage_type = "miss"
  686. damage_string = value.to_s
  687. bitmap.font.name = PK8::DamageText::Miss_Font
  688. bitmap.font.size = PK8::DamageText::Miss_Size
  689. bitmap.font.bold = PK8::DamageText::Miss_Bold
  690. bitmap.font.italic = PK8::DamageText::Miss_Italic
  691. # Draw Miss Outline
  692. bitmap.font.color.set(*PK8::DamageText::Miss_Outline)
  693. bitmap.draw_text(-1, 12, 160, 36, PK8::DamageText::Miss_String, 1)
  694. bitmap.draw_text(1, 12, 160, 36, PK8::DamageText::Miss_String, 1)
  695. bitmap.draw_text(0, 12-1, 160, 36, PK8::DamageText::Miss_String, 1)
  696. bitmap.draw_text(0, 12+1, 160, 36, PK8::DamageText::Miss_String, 1)
  697. # Draw Miss Text
  698. bitmap.font.color.set(*PK8::DamageText::Miss_Color)
  699. bitmap.draw_text(0, 12, 160, 36, PK8::DamageText::Miss_String, 1)
  700. @_damage_sprite.bitmap = bitmap
  701. end
  702. if PK8::DamageText::Keyframes_Flag == true
  703. @_damage_duration = 0
  704. @_damage_duration2 = PK8::DamageText::Keyframes_Duration
  705. else
  706. @_damage_duration = PK8::DamageText::Keyframes_Duration
  707. end
  708. end
  709. end
  710. #---------------------------------------------------------------------------
  711. # * Update
  712. #---------------------------------------------------------------------------
  713. def update
  714. pk8_newdamage_update
  715. if PK8::DamageText::Switch == true
  716. @_damage_duration2 = 0 if @_damage_duration2 == nil
  717. if PK8::DamageText::Keyframes_Flag == true
  718. if @_damage_duration2 > 0
  719. # Stores variables for use in script calls.
  720. dmg = @_damage_sprite
  721. dmg_d = PK8::DamageText::Keyframes_Duration
  722. dmg_v = @_damage_value
  723. # Check for Damage Type
  724. case @_damage_type
  725. when "heal"
  726. if PK8::DamageText::Keyframes_Heal_Flag == true
  727. keyframes = PK8::DamageText::Keyframes_Heal
  728. else
  729. keyframes = PK8::DamageText::Keyframes
  730. end
  731. when "miss"
  732. if PK8::DamageText::Keyframes_Miss_Flag == true
  733. keyframes = PK8::DamageText::Keyframes_Miss
  734. else
  735. keyframes = PK8::DamageText::Keyframes
  736. end
  737. when "critical"
  738. if PK8::DamageText::Keyframes_Critical_Flag == true
  739. keyframes = PK8::DamageText::Keyframes_Critical
  740. else
  741. keyframes = PK8::DamageText::Keyframes
  742. end
  743. else
  744. if PK8::DamageText::Keyframes_Damage_Flag == true
  745. keyframes = PK8::DamageText::Keyframes_Damage
  746. else
  747. keyframes = PK8::DamageText::Keyframes
  748. end
  749. end
  750. # Animate
  751. case @_damage_duration2
  752. when 0..PK8::DamageText::Keyframes_Duration
  753. dmg_i = @_damage_duration2
  754. i = PK8::DamageText::Keyframes_Duration - dmg_i
  755. if keyframes[@_damage_duration2].size > 0 # Detects keyframe
  756. @_damage_property = []
  757. for n in 0..keyframes[@_damage_duration2].size-1
  758. if PK8::DamageText::Keyframes_Advanced == true
  759. @_damage_property[n] = eval("dmg; #{keyframes[dmg_i][n]}")
  760. else
  761. @_damage_property[n] = eval("dmg.#{keyframes[dmg_i][n]}")
  762. end
  763. end
  764. @_damage_keyframe = @_damage_duration2
  765. else # Uses previous keyframe. Possibly for tweening purposes.
  766. @_damage_property = []
  767. if @_damage_keyframe != nil
  768. for n in 0..keyframes[@_damage_keyframe].size-1
  769. if PK8::DamageText::Keyframes_Advanced == true
  770. @_damage_property[n] = eval("dmg; #{keyframes[
  771. @_damage_keyframe][n]}")
  772. else
  773. @_damage_property[n] = eval("dmg.#{keyframes[
  774. @_damage_keyframe][n]}")
  775. end
  776. end
  777. end
  778. end
  779. dmg.update
  780. for n in 0..@_damage_property.size-1
  781. @_damage_property[n]
  782. end
  783. end
  784. @_damage_duration2 -= 1
  785. dispose_damage if @_damage_duration2 == 0
  786. end
  787. end
  788. end
  789. end
  790. end
  791. end
RAW Paste Data