Advertisement
Guest User

YEZ Custom Status Properties

a guest
Oct 23rd, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.99 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Yanfly Engine Zealous - Custom Status Properties
  4. # Last Date Updated: 2010.02.07
  5. # Level: Normal, Hard, Lunatic
  6. #
  7. # Status effects are a very overlooked aspect in many RPG's. That's because
  8. # most of the time, they aren't worth using or have completely cheesy effects
  9. # that nobody wants. This script will allow for more effects in addition to
  10. # playing animations on battlers when inflicted with a status effect.
  11. #
  12. # This script has been remade from the YERD counterpart to have all of the near
  13. # useless effects removed. Math calculations are now done properly to fit the
  14. # order of operations, state stacking will return no errors, lunatic mode has
  15. # been revamped, and states can now play animations on the battlers.
  16. #
  17. #===============================================================================
  18. # Updates
  19. # -----------------------------------------------------------------------------
  20. # o 2010.02.07 - Added "immortality" trait.
  21. # o 2010.01.17 - Critical tag bugfix.
  22. # o 2010.01.16 - Added compatibility with Aggro and AI.
  23. # o 2010.01.08 - Job System: Passives Compatibility.
  24. # o 2010.01.04 - Core Fixes and Upgrades Compatibility.
  25. # o 2010.01.01 - Job System: Skill Levels Compatibility.
  26. # o 2009.12.30 - Animation clear bugfix.
  27. # o 2009.12.20 - Fixed strange bug where stacks don't update HP/MP when done
  28. # through the skill menu.
  29. # o 2009.12.19 - Animation loop bug fixed.
  30. # o 2009.12.17 - Started Script and Finished.
  31. #===============================================================================
  32. # Instructions
  33. # -----------------------------------------------------------------------------
  34. # To install this script, open up your script editor and copy/paste this script
  35. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  36. #
  37. # -----------------------------------------------------------------------------
  38. # Status Tags - Insert the following tags into a State's notebox.
  39. # -----------------------------------------------------------------------------
  40. # <animation n>
  41. # This will cause the state to play animation n on the battler. One animation
  42. # can play at a time only so the highest priority state with an animation will
  43. # take effect. Settings can be adjusted below.
  44. #
  45. # <max stack n>
  46. # This allows your state to stack n times. By default, this value is 1. When a
  47. # state is applied over again, the stack amount increases. If the stack amount
  48. # increases, the effects of that state will also be increased depending on the
  49. # effect and the power of the effect. Tags listed below will make mention of
  50. # which effects are stackable and which aren't.
  51. #
  52. # <stat +n> <stat -n> <stat n%>
  53. # Replace stat with maxhp, maxmp, atk, def, spi, agi, hit, eva, cri, or odds
  54. # to increase, decrease, or set the base stat to a percentage. This version
  55. # will allow you to exceed to the 200% minimum if you use n%. If you plan on
  56. # using state stacking, it is recommended to use this tag instead of the innate
  57. # rate system for more accurate calculations. Stackable.
  58. #
  59. # <hp degen n> <hp degen n%> or <mp degen n> <mp degen n%>
  60. # <hp regen n> <hp regen n%> or <mp regen n> <mp regen n%>
  61. # This causes HP or MP to regenerate or degenerate at the end of each turn. If
  62. # the tag is used without a %, the amount is set. Otherwise, the amount will be
  63. # relative to the battler's MaxHP or MP. Stackable.
  64. #
  65. # <trait: phrase>
  66. # This tag allows you to add special traits to the inflicted battlers. The
  67. # phrase used will cause a different effect. Nonstackable.
  68. # super guard - Guarding reduces damage by 4x instead of 2x.
  69. # pharmacology - Items used will have double effect.
  70. # fast attack - Early turn initiative.
  71. # dual attack - Normal attacks hit twice.
  72. # prevent critical - Criticals cannot occur on battler.
  73. # half mp cost - MP skills cost only half.
  74. # double exp gain - Inflicted actor gains double exp.
  75. # auto hp recover - Inflicted actor gains HP each turn and step.
  76. # anti hp degen - HP degen cannot occur on battler.
  77. # anti hp regen - HP regen cannot occur on battler.
  78. # anti mp degen - MP degen cannot occur on battler.
  79. # anti mp regen - MP regen cannot occur on battler.
  80. # immortal - Battler cannot die if HP reaches 0.
  81. #
  82. #===============================================================================
  83. # Compatibility
  84. # -----------------------------------------------------------------------------
  85. # - Works With: YEZ Battle Engine Zealous
  86. # -----------------------------------------------------------------------------
  87. # Note: This script may not work with former Yanfly Engine ReDux scripts.
  88. # Use Yanfly Engine Zealous scripts to work with this if available.
  89. #===============================================================================
  90.  
  91. $imported = {} if $imported == nil
  92. $imported["CustomStatusPropertiesZeal"] = true
  93.  
  94. module YEZ
  95. module STATE
  96.  
  97. # This decides whether or not your state animations will play sound when
  98. # they're on. Note that this will play sounds for all state animations
  99. # present on the screen. You may also turn off full screen animation flash
  100. # off here. Highly recommended to turn off both.
  101. ANIMATION_SOUND = false
  102. ANIMATION_FLASH = false
  103.  
  104. # The following determines various aspects for actors. You can decide on
  105. # whether or not actors will have animations playing on them, what zoom
  106. # rate will appear for the actors, and what not.
  107. ANI_ACTOR_SHOW = true
  108. ANI_ACTOR_ZOOM = 25
  109.  
  110. # The following adjusts the rules regarding remained states. A remained
  111. # state is a state that's already been applied to the battler but is being
  112. # reapplied. By default, nothing happens to the remained state, but you
  113. # can make a few changes.
  114. # 0 - No changes.
  115. # 1 - Reset turns to the state's starting turn capacity.
  116. # 2 - Adds extra turns to the state's already existing turns.
  117. REMAINED_RULES = 1
  118.  
  119. # If the following is set to true, then states will automatically update
  120. # HP and MP to higher amounts if changed. The amounts adjusted will be
  121. # equal to the HP/MP amount gained/lost.
  122. UPDATE_ADD = true # Update HP/MP when adding states.
  123. UPDATE_REM = true # Update HP/MP when removing states.
  124.  
  125. # The following will cause remained states to go down in turns after the
  126. # player takes a certain amount of steps.
  127. STEP_UPDATE_STATES = true # Enables/Disables state turn update.
  128. STEPS_PER_ST_TURNS = 3 # Steps for each turn to reduce.
  129.  
  130. end # STATE
  131. end # YEZ
  132.  
  133. #===============================================================================
  134. # Custom Status Properties - Lunatic Mode - Custom Effects
  135. # ----------------------------------------------------------------------------
  136. # This section is for all the lunatic scripters out there who want to do a bit
  137. # more with your status effects. Put these into your status effect's notebox
  138. # and then head over to the next section to script your own custom effects.
  139. #
  140. # Lunatic mode for status effects is now remade to share a common effects pool.
  141. # Here is a list of the different custom effects you can add to your states.
  142. #
  143. # <apply effect: phrase> - When adding the state.
  144. # <erase effect: phrase> - When removing the state.
  145. # <leave effect: phrase> - When states timer runs out.
  146. # <react effect: phrase> - Before taking damage.
  147. # <shock effect: phrase> - After taking damage.
  148. # <begin effect: phrase> - At the start of each turn.
  149. # <while effect: phrase> - During battler's turn.
  150. # <close effect: phrase> - At the end of each turn.
  151. #
  152. # Like the YEZ Lunatic Modes, you now enter phrases instead of numbers. Not
  153. # only that, entering multiple phrases will prompt them to trigger in that
  154. # order at the proper time for the custom effect to take place.
  155. #
  156. # state_origin(effect_state)
  157. # This new method will return the state's original caster. If no such caster
  158. # exists, it will be the battler itself. This allows more possibilities for
  159. # even more special effects.
  160. #
  161. #===============================================================================
  162.  
  163. class Game_Battler
  164.  
  165. #--------------------------------------------------------------------------
  166. # new method: custom_status_effects
  167. #--------------------------------------------------------------------------
  168. def custom_status_effects(effect_state, type = nil)
  169. return if effect_state == nil
  170. case type
  171. when "APPLY"; effects = effect_state.apply_effect
  172. when "ERASE"; effects = effect_state.erase_effect
  173. when "LEAVE"; effects = effect_state.leave_effect
  174. when "REACT"; effects = effect_state.react_effect
  175. when "SHOCK"; effects = effect_state.shock_effect
  176. when "BEGIN"; effects = effect_state.begin_effect
  177. when "WHILE"; effects = effect_state.while_effect
  178. when "CLOSE"; effects = effect_state.close_effect
  179. else; return
  180. end
  181. return unless effects != []
  182. for effect in effects
  183. case effect
  184. #----------------------------------------------------------------------
  185. # Start editting here.
  186. #----------------------------------------------------------------------
  187. when "DESEOLLUVIA"
  188. next unless state_origin(effect_state).state?(30)
  189. self.hp += self.maxhp * 0.67
  190.  
  191. when "FERVOR"
  192. self.add_state(12)
  193.  
  194. when "PROTECCION"
  195. next unless self.hp <= self.maxhp / 2
  196. self.add_state(14)
  197.  
  198. when "PROTECCION2"
  199. next unless self.hp > self.maxhp / 2
  200. self.remove_state(14)
  201.  
  202. when "INFAMIA"
  203. $game_troop.members.add_state(10)
  204.  
  205. #----------------------------------------------------------------------
  206. # Stop editting past this point.
  207. #----------------------------------------------------------------------
  208. end
  209. end # for effect in effects
  210. end # custom_status_effects
  211.  
  212. end # Game_Battler
  213.  
  214. #===============================================================================
  215. # Editting anything past this point may potentially result in causing computer
  216. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  217. # Therefore, edit at your own risk.
  218. #===============================================================================
  219.  
  220. module YEZ
  221. module REGEXP
  222. module STATE
  223.  
  224. CUSTOM_APPLY = /<(?:APPLY_EFFECT|apply effect):[ ](.*)>/i
  225. CUSTOM_ERASE = /<(?:ERASE_EFFECT|erase effect):[ ](.*)>/i
  226. CUSTOM_LEAVE = /<(?:LEAVE_EFFECT|leave effect):[ ](.*)>/i
  227. CUSTOM_REACT = /<(?:REACT_EFFECT|react effect):[ ](.*)>/i
  228. CUSTOM_SHOCK = /<(?:SHOCK_EFFECT|shock effect):[ ](.*)>/i
  229. CUSTOM_BEGIN = /<(?:BEGIN_EFFECT|begin effect):[ ](.*)>/i
  230. CUSTOM_WHILE = /<(?:WHILE_EFFECT|while effect):[ ](.*)>/i
  231. CUSTOM_CLOSE = /<(?:CLOSE_EFFECT|close effect):[ ](.*)>/i
  232.  
  233. STATEANI = /<(?:STATE_ANIMATION|state ani|animation|ani)[ ]*(\d+)>/i
  234. STAT_SET = /<\s*(MAXHP|MAXMP|HP|MP|ATK|DEF|SPI|AGI|HIT|EVA|CRI|ODDS)?\s*([\+\-]\d+)>/i
  235. STAT_PER = /<\s*(MAXHP|MAXMP|HP|MP|ATK|DEF|SPI|AGI|HIT|EVA|CRI|ODDS)?\s*(\d+)([%%])>/i
  236. MAXSTACK = /<(?:MAX_STACK|max stack)[ ]*(\d+)>/i
  237. TRAITS = /<(?:TRAITS|trait):[ ](.*)>/i
  238.  
  239. SLIP_SET = /<\s*(HP|MP)?\s*[ ]\s*(DEGEN|REGEN)?\s*(\d+)>/i
  240. SLIP_PER = /<\s*(HP|MP)?\s*[ ]\s*(DEGEN|REGEN)?\s*(\d+)([%%])>/i
  241.  
  242. end # STATE
  243. end # REGEXP
  244. end # YEZ
  245.  
  246. #===============================================================================
  247. # RPG::State
  248. #===============================================================================
  249.  
  250. class RPG::State
  251.  
  252. #--------------------------------------------------------------------------
  253. # common cache: yez_cache_state_csp
  254. #--------------------------------------------------------------------------
  255. def yez_cache_state_csp
  256. @max_stack = 1; @traits = []; @state_animation = 0
  257. @stat_set ={ :hp => 0, :mp => 0, :atk => 0, :def => 0, :spi => 0,
  258. :agi => 0, :hit => 0, :eva => 0, :cri => 0, :odds => 0}
  259. @stat_per ={ :hp => 100, :mp => 100, :atk => 100, :def => 100, :spi => 100,
  260. :agi => 100, :hit => 100, :eva => 100, :cri => 100, :odds => 100}
  261. @slip_set ={ :hpdegen => 0, :hpregen => 0, :mpdegen => 0, :mpregen => 0}
  262. @slip_per ={ :hpdegen => 0, :hpregen => 0, :mpdegen => 0, :mpregen => 0}
  263.  
  264. @apply_effect = []; @erase_effect = []; @leave_effect = [];
  265. @react_effect = []; @shock_effect = []; @begin_effect = [];
  266. @while_effect = []; @close_effect = [];
  267.  
  268. self.note.split(/[\r\n]+/).each { |line|
  269. case line
  270. #---
  271. when YEZ::REGEXP::STATE::CUSTOM_APPLY; @apply_effect.push($1.to_s)
  272. when YEZ::REGEXP::STATE::CUSTOM_ERASE; @erase_effect.push($1.to_s)
  273. when YEZ::REGEXP::STATE::CUSTOM_LEAVE; @leave_effect.push($1.to_s)
  274. when YEZ::REGEXP::STATE::CUSTOM_REACT; @react_effect.push($1.to_s)
  275. when YEZ::REGEXP::STATE::CUSTOM_SHOCK; @shock_effect.push($1.to_s)
  276. when YEZ::REGEXP::STATE::CUSTOM_BEGIN; @begin_effect.push($1.to_s)
  277. when YEZ::REGEXP::STATE::CUSTOM_WHILE; @while_effect.push($1.to_s)
  278. when YEZ::REGEXP::STATE::CUSTOM_CLOSE; @close_effect.push($1.to_s)
  279. #---
  280. when YEZ::REGEXP::STATE::STATEANI
  281. @state_animation = $1.to_i
  282. when YEZ::REGEXP::STATE::MAXSTACK
  283. @max_stack = [$1.to_i, 1].max
  284. when YEZ::REGEXP::STATE::TRAITS
  285. @traits.push($1.upcase)
  286. #---
  287. when YEZ::REGEXP::STATE::STAT_SET
  288. case $1.upcase
  289. when "HP","MAXHP"; @stat_set[:hp] = $2.to_i
  290. when "MP","MAXMP"; @stat_set[:mp] = $2.to_i
  291. when "ATK"; @stat_set[:atk] = $2.to_i
  292. when "DEF"; @stat_set[:def] = $2.to_i
  293. when "SPI"; @stat_set[:spi] = $2.to_i
  294. when "AGI"; @stat_set[:agi] = $2.to_i
  295. when "HIT"; @stat_set[:hit] = $2.to_i
  296. when "EVA"; @stat_set[:eva] = $2.to_i
  297. when "CRI"; @stat_set[:cri] = $2.to_i
  298. when "ODDS"; @stat_set[:odds] = $2.to_i
  299. end
  300. #---
  301. when YEZ::REGEXP::STATE::STAT_PER
  302. case $1.upcase
  303. when "HP","MAXHP"; @stat_per[:hp] = $2.to_i
  304. when "MP","MAXMP"; @stat_per[:mp] = $2.to_i
  305. when "ATK"; @stat_per[:atk] = $2.to_i
  306. when "DEF"; @stat_per[:def] = $2.to_i
  307. when "SPI"; @stat_per[:spi] = $2.to_i
  308. when "AGI"; @stat_per[:agi] = $2.to_i
  309. when "HIT"; @stat_per[:hit] = $2.to_i
  310. when "EVA"; @stat_per[:eva] = $2.to_i
  311. when "CRI"; @stat_per[:cri] = $2.to_i
  312. when "ODDS"; @stat_per[:odds] = $2.to_i
  313. end
  314. #---
  315. when YEZ::REGEXP::STATE::SLIP_SET
  316. case $1.upcase
  317. when "HP"
  318. case $2.upcase
  319. when "DEGEN"; @slip_set[:hpdegen] = $3.to_i
  320. when "REGEN"; @slip_set[:hpregen] = $3.to_i
  321. end
  322. @traits.push("HPSLIP")
  323. when "MP"
  324. case $2.upcase
  325. when "DEGEN"; @slip_set[:mpdegen] = $3.to_i
  326. when "REGEN"; @slip_set[:mpregen] = $3.to_i
  327. end
  328. @traits.push("MPSLIP")
  329. end
  330. #---
  331. when YEZ::REGEXP::STATE::SLIP_PER
  332. case $1.upcase
  333. when "HP"
  334. case $2.upcase
  335. when "DEGEN"; @slip_per[:hpdegen] = $3.to_i
  336. when "REGEN"; @slip_per[:hpregen] = $3.to_i
  337. end
  338. @traits.push("HPSLIP")
  339. when "MP"
  340. case $2.upcase
  341. when "DEGEN"; @slip_per[:mpdegen] = $3.to_i
  342. when "REGEN"; @slip_per[:mpregen] = $3.to_i
  343. end
  344. @traits.push("MPSLIP")
  345. end
  346. #---
  347. end
  348. } # end self.note.split
  349. end # yez_cache_state_csp
  350.  
  351. #--------------------------------------------------------------------------
  352. # new method: apply_effect
  353. #--------------------------------------------------------------------------
  354. def apply_effect
  355. yez_cache_state_csp if @apply_effect == nil
  356. return @apply_effect
  357. end
  358.  
  359. #--------------------------------------------------------------------------
  360. # new method: erase_effect
  361. #--------------------------------------------------------------------------
  362. def erase_effect
  363. yez_cache_state_csp if @erase_effect == nil
  364. return @erase_effect
  365. end
  366.  
  367. #--------------------------------------------------------------------------
  368. # new method: leave_effect
  369. #--------------------------------------------------------------------------
  370. def leave_effect
  371. yez_cache_state_csp if @leave_effect == nil
  372. return @leave_effect
  373. end
  374.  
  375. #--------------------------------------------------------------------------
  376. # new method: react_effect
  377. #--------------------------------------------------------------------------
  378. def react_effect
  379. yez_cache_state_csp if @react_effect == nil
  380. return @react_effect
  381. end
  382.  
  383. #--------------------------------------------------------------------------
  384. # new method: shock_effect
  385. #--------------------------------------------------------------------------
  386. def shock_effect
  387. yez_cache_state_csp if @shock_effect == nil
  388. return @shock_effect
  389. end
  390.  
  391. #--------------------------------------------------------------------------
  392. # new method: begin_effect
  393. #--------------------------------------------------------------------------
  394. def begin_effect
  395. yez_cache_state_csp if @begin_effect == nil
  396. return @begin_effect
  397. end
  398.  
  399. #--------------------------------------------------------------------------
  400. # new method: while_effect
  401. #--------------------------------------------------------------------------
  402. def while_effect
  403. yez_cache_state_csp if @while_effect == nil
  404. return @while_effect
  405. end
  406.  
  407. #--------------------------------------------------------------------------
  408. # new method: close_effect
  409. #--------------------------------------------------------------------------
  410. def close_effect
  411. yez_cache_state_csp if @close_effect == nil
  412. return @close_effect
  413. end
  414.  
  415. #--------------------------------------------------------------------------
  416. # new method: state_animation
  417. #--------------------------------------------------------------------------
  418. def state_animation
  419. yez_cache_state_csp if @state_animation == nil
  420. return @state_animation
  421. end
  422.  
  423. #--------------------------------------------------------------------------
  424. # new method: max_stack
  425. #--------------------------------------------------------------------------
  426. def max_stack
  427. yez_cache_state_csp if @max_stack == nil
  428. return @max_stack
  429. end
  430.  
  431. #--------------------------------------------------------------------------
  432. # new method: traits
  433. #--------------------------------------------------------------------------
  434. def traits
  435. yez_cache_state_csp if @traits == nil
  436. return @traits
  437. end
  438.  
  439. #--------------------------------------------------------------------------
  440. # new method: stat_set
  441. #--------------------------------------------------------------------------
  442. def stat_set
  443. yez_cache_state_csp if @stat_set == nil
  444. return @stat_set
  445. end
  446.  
  447. #--------------------------------------------------------------------------
  448. # new method: stat_per
  449. #--------------------------------------------------------------------------
  450. def stat_per
  451. yez_cache_state_csp if @stat_per == nil
  452. return @stat_per
  453. end
  454.  
  455. #--------------------------------------------------------------------------
  456. # new method: slip_set
  457. #--------------------------------------------------------------------------
  458. def slip_set
  459. yez_cache_state_csp if @slip_set == nil
  460. return @slip_set
  461. end
  462.  
  463. #--------------------------------------------------------------------------
  464. # new method: slip_per
  465. #--------------------------------------------------------------------------
  466. def slip_per
  467. yez_cache_state_csp if @slip_per == nil
  468. return @slip_per
  469. end
  470.  
  471. end # RPG::State
  472.  
  473. #===============================================================================
  474. # Game_Battler
  475. #===============================================================================
  476.  
  477. class Game_Battler
  478.  
  479. #--------------------------------------------------------------------------
  480. # public instance variables
  481. #--------------------------------------------------------------------------
  482. attr_accessor :state_stack
  483. attr_accessor :state_animation
  484.  
  485. #--------------------------------------------------------------------------
  486. # alias method: clear_extra_values
  487. #--------------------------------------------------------------------------
  488. alias clear_extra_values_csp clear_extra_values unless $@
  489. def clear_extra_values
  490. clear_extra_values_csp
  491. @stack_stack = {}
  492. @state_origin = {}
  493. @origin_side = {}
  494. end
  495.  
  496. #--------------------------------------------------------------------------
  497. # alias method: clear_sprite_effects
  498. #--------------------------------------------------------------------------
  499. alias clear_sprite_effects_csp clear_sprite_effects unless $@
  500. def clear_sprite_effects
  501. clear_sprite_effects_csp
  502. @state_animation = 0
  503. end
  504.  
  505. #--------------------------------------------------------------------------
  506. # new method: reload_state_animation
  507. #--------------------------------------------------------------------------
  508. def reload_state_animation
  509. @state_animation = 0
  510. return if actor? and !YEZ::STATE::ANI_ACTOR_SHOW
  511. for state in states
  512. next unless state.state_animation > 0
  513. @state_animation = state.state_animation
  514. break
  515. end
  516. end
  517.  
  518. #--------------------------------------------------------------------------
  519. # overwrite method: state?
  520. #--------------------------------------------------------------------------
  521. def state?(state_id)
  522. return states.include?($data_states[state_id])
  523. end
  524.  
  525. #--------------------------------------------------------------------------
  526. # overwrite method: apply_state_changes
  527. #--------------------------------------------------------------------------
  528. def apply_state_changes(obj)
  529. plus = obj.plus_state_set
  530. minus = obj.minus_state_set
  531. if obj.is_a?(RPG::Skill) or obj.is_a?(RPG::Item)
  532. plus += $scene.active_battler.plus_state_set if obj.physical_attack
  533. end
  534. for i in plus
  535. next if state_resist?(i)
  536. next if dead?
  537. next if i == 1 and @immortal
  538. if state?(i)
  539. remained_rules(i, obj)
  540. @remained_states.push(i) unless @remained_states.include?(i)
  541. next
  542. end
  543. if rand(100) < state_probability(i)
  544. add_state(i)
  545. @added_states.push(i) unless @added_states.include?(i)
  546. end
  547. end
  548. for i in minus
  549. next unless state?(i)
  550. remove_state(i)
  551. @removed_states.push(i) unless @removed_states.include?(i)
  552. end
  553. for i in @added_states & @removed_states
  554. @added_states.delete(i)
  555. @removed_states.delete(i)
  556. end
  557. for i in @added_states
  558. apply_state_turns(obj, i) if $imported["JobSystemSkillLevels"]
  559. end
  560. end
  561.  
  562. #--------------------------------------------------------------------------
  563. # new method: remained_rules
  564. #--------------------------------------------------------------------------
  565. def remained_rules(state_id, obj = nil)
  566. state = $data_states[state_id]
  567. return if state == nil
  568. hpdif = self.maxhp
  569. mpdif = self.maxmp
  570. increase_stack(state_id)
  571. case YEZ::STATE::REMAINED_RULES
  572. when 0 # No changes
  573. return
  574. when 1 # Reset Turns
  575. @state_turns[state_id] = state.hold_turn
  576. when 2 # Add Turns
  577. @state_turns[state_id] = state.hold_turn if !@state_turns.include?(state_id)
  578. @state_turns[state_id] += state.hold_turn
  579. end
  580. if !dead? and YEZ::STATE::UPDATE_ADD
  581. self.hp += maxhp - hpdif
  582. self.mp += maxmp - mpdif
  583. end
  584. end
  585.  
  586. #--------------------------------------------------------------------------
  587. # alias method: skill_test
  588. #--------------------------------------------------------------------------
  589. alias skill_test_csp skill_test unless $@
  590. def skill_test(user, skill)
  591. for state_id in skill.plus_state_set
  592. state = $data_states[state_id]
  593. next if state == nil
  594. return true if state.max_stack > self.stack(state)
  595. end
  596. return skill_test_csp(user, skill)
  597. end
  598.  
  599. #--------------------------------------------------------------------------
  600. # alias method: add_state
  601. #--------------------------------------------------------------------------
  602. alias add_state_csp add_state unless $@
  603. def add_state(state_id)
  604. create_state_origin(state_id)
  605. custom_status_effects($data_states[state_id], "APPLY")
  606. hpdif = maxhp
  607. mpdif = maxmp
  608. increase_stack(state_id)
  609. add_state_csp(state_id)
  610. if !dead? and YEZ::STATE::UPDATE_ADD
  611. self.hp += maxhp - hpdif
  612. self.mp += maxmp - mpdif
  613. end
  614. reload_state_animation
  615. end
  616.  
  617. #--------------------------------------------------------------------------
  618. # alias method: remove_state
  619. #--------------------------------------------------------------------------
  620. alias remove_state_csp remove_state unless $@
  621. def remove_state(state_id)
  622. custom_status_effects($data_states[state_id], "ERASE")
  623. hpdif = maxhp
  624. mpdif = maxmp
  625. reset_stack(state_id)
  626. remove_state_csp(state_id)
  627. if !dead? and YEZ::STATE::UPDATE_REM
  628. self.hp += maxhp - hpdif
  629. self.mp += maxmp - mpdif
  630. end
  631. @removed_states.push(1) if dead? and !@removed_states.include?(1)
  632. clear_state_origin(state_id)
  633. reload_state_animation
  634. end
  635.  
  636. #--------------------------------------------------------------------------
  637. # alias method: remove_states_auto
  638. #--------------------------------------------------------------------------
  639. alias remove_states_auto_csp remove_states_auto unless $@
  640. def remove_states_auto
  641. clear_action_results
  642. unless @hidden
  643. for state in states; custom_status_effects(state, "WHILE"); end
  644. for i in @state_turns.keys.clone
  645. custom_status_effects($data_states[id], "LEAVE") if @state_turns[i] == 0
  646. end
  647. end
  648. remove_states_auto_csp
  649. end
  650.  
  651. #--------------------------------------------------------------------------
  652. # alias method: execute_damage
  653. #--------------------------------------------------------------------------
  654. alias execute_damage_csp execute_damage unless $@
  655. def execute_damage(user)
  656. for state in states; custom_status_effects(state, "REACT"); end
  657. execute_damage_csp(user)
  658. for state in states; custom_status_effects(state, "SHOCK"); end
  659. end
  660.  
  661. #--------------------------------------------------------------------------
  662. # new method: create_state_origin
  663. #--------------------------------------------------------------------------
  664. def create_state_origin(state_id)
  665. @state_origin = {} if @state_origin == nil
  666. @origin_side = {} if @origin_side == nil
  667. return unless $scene.is_a?(Scene_Battle)
  668. return if $scene.active_battler == nil
  669. if $scene.active_battler.actor?
  670. @state_origin[state_id] = $scene.active_battler.id
  671. @origin_side[state_id] = 0
  672. else
  673. @state_origin[state_id] = $scene.active_battler.index
  674. @origin_side[state_id] = 1
  675. end
  676. end
  677.  
  678. #--------------------------------------------------------------------------
  679. # new method: clear_state_origin
  680. #--------------------------------------------------------------------------
  681. def clear_state_origin(state_id)
  682. @state_origin = {} if @state_origin == nil
  683. @origin_side = {} if @origin_side == nil
  684. @state_origin.delete(state_id)
  685. @origin_side.delete(state_id)
  686. end
  687.  
  688. #--------------------------------------------------------------------------
  689. # new method: state_origin
  690. #--------------------------------------------------------------------------
  691. def state_origin(state_id)
  692. state_id = state_id.id if state_id.is_a?(RPG::State)
  693. @state_origin = {} if @state_origin == nil
  694. @origin_side = {} if @origin_side == nil
  695. if @origin_side.include?(state_id)
  696. if @origin_side[state_id] == 0
  697. return $game_actors[@state_origin[state_id]]
  698. else
  699. return $game_troop.members[@state_origin[state_id]]
  700. end
  701. else
  702. return self
  703. end
  704. end
  705.  
  706. #--------------------------------------------------------------------------
  707. # new method: reset_state_origins
  708. #--------------------------------------------------------------------------
  709. def reset_state_origins
  710. @state_origin = {}
  711. @origin_side = {}
  712. end
  713.  
  714. #--------------------------------------------------------------------------
  715. # new method: stack
  716. #--------------------------------------------------------------------------
  717. def stack(state)
  718. @state_stack = {} if @state_stack == nil
  719. state = $data_states[state] if state.is_a?(Integer)
  720. return 0 if state == nil
  721. return 0 if !state?(state.id)
  722. n = 1
  723. m = @state_stack.include?(state.id) ? @state_stack[state.id] : 0
  724. return [n, m].max
  725. end
  726.  
  727. #--------------------------------------------------------------------------
  728. # new method: increase_stack
  729. #--------------------------------------------------------------------------
  730. def increase_stack(state_id, stack_up = 1)
  731. state = $data_states[state_id]
  732. return if state == nil
  733. @state_stack = {} if @state_stack == nil
  734. @state_stack[state_id] = 0 if @state_stack[state_id] == nil
  735. return if @state_stack[state_id] > state.max_stack
  736. @state_stack[state_id] += stack_up
  737. @state_stack[state_id] = [@state_stack[state_id], state.max_stack].min
  738. @added_states.push(state_id) unless state_id == 1
  739. end
  740.  
  741. #--------------------------------------------------------------------------
  742. # new method: reset_stack
  743. #--------------------------------------------------------------------------
  744. def reset_stack(state_id)
  745. @state_stack = {} if @state_stack == nil
  746. @state_stack.delete(state_id)
  747. end
  748.  
  749. #--------------------------------------------------------------------------
  750. # alias method: maxhp
  751. #--------------------------------------------------------------------------
  752. alias maxhp_csp maxhp unless $@
  753. def maxhp
  754. n = maxhp_csp
  755. for state in states
  756. percent = 100
  757. for i in 1..stack(state); percent += state.stat_per[:hp] - 100; end
  758. n = n * percent / 100.0
  759. end
  760. for state in states;
  761. for i in 1..stack(state); n += state.stat_set[:hp]; end
  762. end
  763. n = [[Integer(n), 1].max, maxhp_limit].min
  764. @hp = [@hp, n].min
  765. return Integer(n)
  766. end
  767.  
  768. #--------------------------------------------------------------------------
  769. # alias method: maxmp
  770. #--------------------------------------------------------------------------
  771. alias maxmp_csp maxmp unless $@
  772. def maxmp
  773. n = maxmp_csp
  774. for state in states
  775. percent = 100
  776. for i in 1..stack(state); percent += state.stat_per[:mp] - 100; end
  777. n = n * percent / 100.0
  778. end
  779. for state in states;
  780. for i in 1..stack(state); n += state.stat_set[:mp]; end
  781. end
  782. limit = (defined?(maxmp_limit) ? maxmp_limit : 9999)
  783. n = [[Integer(n), 1].max, limit].min
  784. @mp = [@mp, n].min
  785. return Integer(n)
  786. end
  787.  
  788. #--------------------------------------------------------------------------
  789. # alias method: atk
  790. #--------------------------------------------------------------------------
  791. alias atk_csp atk unless $@
  792. def atk
  793. n = atk_csp
  794. for state in states
  795. percent = 100
  796. for i in 2..stack(state); percent += state.atk_rate - 100; end
  797. n = n * percent / 100.0
  798. end
  799. for state in states
  800. percent = 100
  801. for i in 1..stack(state); percent += state.stat_per[:atk] - 100; end
  802. n = n * percent / 100.0
  803. end
  804. for state in states;
  805. for i in 1..stack(state); n += state.stat_set[:atk]; end
  806. end
  807. limit = (defined?(parameter_limit) ? parameter_limit : 999)
  808. n = [[Integer(n), 1].max, limit].min
  809. return Integer(n)
  810. end
  811.  
  812. #--------------------------------------------------------------------------
  813. # alias method: def
  814. #--------------------------------------------------------------------------
  815. alias def_csp def unless $@
  816. def def
  817. n = def_csp
  818. for state in states
  819. percent = 100
  820. for i in 2..stack(state); percent += state.def_rate - 100; end
  821. n = n * percent / 100.0
  822. end
  823. for state in states
  824. percent = 100
  825. for i in 1..stack(state); percent += state.stat_per[:def] - 100; end
  826. n = n * percent / 100.0
  827. end
  828. for state in states;
  829. for i in 1..stack(state); n += state.stat_set[:def]; end
  830. end
  831. limit = (defined?(parameter_limit) ? parameter_limit : 999)
  832. n = [[Integer(n), 1].max, limit].min
  833. return Integer(n)
  834. end
  835.  
  836. #--------------------------------------------------------------------------
  837. # alias method: spi
  838. #--------------------------------------------------------------------------
  839. alias spi_csp spi unless $@
  840. def spi
  841. n = spi_csp
  842. for state in states
  843. percent = 100
  844. for i in 2..stack(state); percent += state.spi_rate - 100; end
  845. n = n * percent / 100.0
  846. end
  847. for state in states
  848. percent = 100
  849. for i in 1..stack(state); percent += state.stat_per[:spi] - 100; end
  850. n = n * percent / 100.0
  851. end
  852. for state in states;
  853. for i in 1..stack(state); n += state.stat_set[:spi]; end
  854. end
  855. limit = (defined?(parameter_limit) ? parameter_limit : 999)
  856. n = [[Integer(n), 1].max, limit].min
  857. return Integer(n)
  858. end
  859.  
  860. #--------------------------------------------------------------------------
  861. # alias method: agi
  862. #--------------------------------------------------------------------------
  863. alias agi_csp agi unless $@
  864. def agi
  865. n = agi_csp
  866. for state in states
  867. percent = 100
  868. for i in 2..stack(state); percent += state.agi_rate - 100; end
  869. n = n * percent / 100.0
  870. end
  871. for state in states
  872. percent = 100
  873. for i in 1..stack(state); percent += state.stat_per[:agi] - 100; end
  874. n = n * percent / 100.0
  875. end
  876. for state in states;
  877. for i in 1..stack(state); n += state.stat_set[:agi]; end
  878. end
  879. limit = (defined?(parameter_limit) ? parameter_limit : 999)
  880. n = [[Integer(n), 1].max, limit].min
  881. return Integer(n)
  882. end
  883.  
  884. #--------------------------------------------------------------------------
  885. # new method: trait?
  886. #--------------------------------------------------------------------------
  887. def trait?(phrase)
  888. for state in states; return true if state.traits.include?(phrase); end
  889. return false
  890. end
  891.  
  892. #--------------------------------------------------------------------------
  893. # alias method: super_guard
  894. #--------------------------------------------------------------------------
  895. alias super_guard_battler_csp super_guard unless $@
  896. def super_guard
  897. traits = ["SUPER_GUARD", "SUPER GUARD", "SUPERGUARD"]
  898. for state in states; return true if (state.traits & traits) != []; end
  899. return super_guard_battler_csp
  900. end
  901.  
  902. #--------------------------------------------------------------------------
  903. # alias method: fast_attack
  904. #--------------------------------------------------------------------------
  905. alias fast_attack_battler_csp fast_attack unless $@
  906. def fast_attack
  907. traits = ["FAST_ATTACK", "FAST ATTACK", "FASTATTACK"]
  908. for state in states; return true if (state.traits & traits) != []; end
  909. return fast_attack_battler_csp
  910. end
  911.  
  912. #--------------------------------------------------------------------------
  913. # alias method: dual_attack
  914. #--------------------------------------------------------------------------
  915. alias dual_attack_battler_csp dual_attack unless $@
  916. def dual_attack
  917. traits = ["DUAL_ATTACK", "DUAL ATTACK", "DUALATTACK"]
  918. for state in states; return true if (state.traits & traits) != []; end
  919. return dual_attack_battler_csp
  920. end
  921.  
  922. #--------------------------------------------------------------------------
  923. # alias method: prevent_critical
  924. #--------------------------------------------------------------------------
  925. alias prevent_critical_battler_csp prevent_critical unless $@
  926. def prevent_critical
  927. traits = ["PREVENT_CRITICAL", "PREVENT CRITICAL", "PREVENTCRITICAL",
  928. "PREVENT_CRIT", "PREVENT CRIT"]
  929. for state in states; return true if (state.traits & traits) != []; end
  930. return prevent_critical_battler_csp
  931. end
  932.  
  933. #--------------------------------------------------------------------------
  934. # alias method: half_mp_cost
  935. #--------------------------------------------------------------------------
  936. alias half_mp_cost_battler_csp half_mp_cost unless $@
  937. def half_mp_cost
  938. traits = ["HALF_MP_COST", "HALF MP COST", "HALFMPCOST", "HALF_MP",
  939. "HALF MP", "HALFMP"]
  940. for state in states; return true if (state.traits & traits) != []; end
  941. return half_mp_cost_battler_csp
  942. end
  943.  
  944. #--------------------------------------------------------------------------
  945. # new method: immortal
  946. #--------------------------------------------------------------------------
  947. def immortal
  948. traits = ["IMMORTAL", "CANNOT DIE", "IMMORTALITY"]
  949. for state in states; return true if (state.traits & traits) != []; end
  950. return @immortal
  951. end
  952.  
  953. #--------------------------------------------------------------------------
  954. # alias method: slip_damage_effect
  955. #--------------------------------------------------------------------------
  956. alias slip_damage_effect_csp slip_damage_effect unless $@
  957. def slip_damage_effect
  958. slip_damage_effect_csp
  959. hpslip if trait?("HPSLIP")
  960. mpslip if trait?("MPSLIP")
  961. for state in states; custom_status_effects(state, "CLOSE"); end
  962. end
  963.  
  964. #--------------------------------------------------------------------------
  965. # new method: hpslip
  966. #--------------------------------------------------------------------------
  967. def hpslip
  968. return if dead?
  969. n = 0
  970. if !trait?("ANTI HP DEGEN") or !trait?("ANTI_HP_DEGEN")
  971. for state in states
  972. percent = 100
  973. for i in 1..stack(state); percent += state.slip_per[:hpdegen]; end
  974. n += maxhp * percent / 100.0
  975. end
  976. for state in states;
  977. for i in 1..stack(state); n += state.slip_set[:hpdegen]; end
  978. end
  979. end
  980. if !trait?("ANTI HP REGEN") or !trait?("ANTI_HP_REGEN")
  981. for state in states
  982. percent = 100
  983. for i in 1..stack(state); percent += state.slip_per[:hpregen]; end
  984. n -= maxhp * percent / 100.0
  985. end
  986. for state in states;
  987. for i in 1..stack(state); n -= state.slip_set[:hpregen]; end
  988. end
  989. end
  990. self.hp -= [Integer(n), self.hp - 1].min
  991. end
  992.  
  993. #--------------------------------------------------------------------------
  994. # new method: mpslip
  995. #--------------------------------------------------------------------------
  996. def mpslip
  997. return if dead?
  998. n = 0
  999. if !trait?("ANTI MP DEGEN") or !trait?("ANTI_MP_DEGEN")
  1000. for state in states
  1001. percent = 100
  1002. for i in 1..stack(state); percent += state.slip_per[:mpdegen]; end
  1003. n += maxmp * percent / 100.0
  1004. end
  1005. for state in states;
  1006. for i in 1..stack(state); n += state.slip_set[:mpdegen]; end
  1007. end
  1008. end
  1009. if !trait?("ANTI MP REGEN") or !trait?("ANTI_MP_REGEN")
  1010. for state in states
  1011. percent = 100
  1012. for i in 1..stack(state); percent += state.slip_per[:mpregen]; end
  1013. n -= maxmp * percent / 100.0
  1014. end
  1015. for state in states;
  1016. for i in 1..stack(state); n -= state.slip_set[:mpregen]; end
  1017. end
  1018. end
  1019. self.mp -= Integer(n)
  1020. end
  1021.  
  1022. end # Game_Battler
  1023.  
  1024. #===============================================================================
  1025. # Game_Actor
  1026. #===============================================================================
  1027.  
  1028. class Game_Actor
  1029.  
  1030. #--------------------------------------------------------------------------
  1031. # alias method: hit
  1032. #--------------------------------------------------------------------------
  1033. alias hit_actor_csp hit unless $@
  1034. def hit
  1035. n = hit_actor_csp
  1036. for state in states
  1037. percent = 100
  1038. for i in 1..stack(state); percent += state.stat_per[:hit] - 100; end
  1039. n = n * percent / 100.0
  1040. end
  1041. for state in states;
  1042. for i in 1..stack(state); n += state.stat_set[:hit]; end
  1043. end
  1044. n = [Integer(n), 0].max
  1045. return Integer(n)
  1046. end
  1047.  
  1048. #--------------------------------------------------------------------------
  1049. # alias method: eva
  1050. #--------------------------------------------------------------------------
  1051. alias eva_actor_csp eva unless $@
  1052. def eva
  1053. n = eva_actor_csp
  1054. for state in states
  1055. percent = 100
  1056. for i in 1..stack(state); percent += state.stat_per[:eva] - 100; end
  1057. n = n * percent / 100.0
  1058. end
  1059. for state in states;
  1060. for i in 1..stack(state); n += state.stat_set[:eva]; end
  1061. end
  1062. n = [Integer(n), 0].max
  1063. return Integer(n)
  1064. end
  1065.  
  1066. #--------------------------------------------------------------------------
  1067. # alias method: cri
  1068. #--------------------------------------------------------------------------
  1069. alias cri_actor_csp cri unless $@
  1070. def cri
  1071. n = cri_actor_csp
  1072. for state in states
  1073. percent = 100
  1074. for i in 1..stack(state); percent += state.stat_per[:cri] - 100; end
  1075. n = n * percent / 100.0
  1076. end
  1077. for state in states;
  1078. for i in 1..stack(state); n += state.stat_set[:cri]; end
  1079. end
  1080. n = [Integer(n), 0].max
  1081. return Integer(n)
  1082. end
  1083.  
  1084. #--------------------------------------------------------------------------
  1085. # alias method: odds
  1086. #--------------------------------------------------------------------------
  1087. alias odds_actor_csp odds unless $@
  1088. def odds
  1089. n = odds_actor_csp
  1090. for state in states
  1091. percent = 100
  1092. for i in 1..stack(state); percent += state.stat_per[:odds] - 100; end
  1093. n = n * percent / 100.0
  1094. end
  1095. for state in states;
  1096. for i in 1..stack(state); n += state.stat_set[:odds]; end
  1097. end
  1098. n = [Integer(n), 1].max
  1099. return Integer(n)
  1100. end
  1101.  
  1102. #--------------------------------------------------------------------------
  1103. # alias method: super_guard
  1104. #--------------------------------------------------------------------------
  1105. alias super_guard_actor_csp super_guard unless $@
  1106. def super_guard
  1107. return true if trait?("SUPER_GUARD")
  1108. return true if trait?("SUPER GUARD")
  1109. return true if trait?("SUPERGUARD")
  1110. return super_guard_actor_csp
  1111. end
  1112.  
  1113. #--------------------------------------------------------------------------
  1114. # alias method: pharmacology
  1115. #--------------------------------------------------------------------------
  1116. alias pharmacology_actor_csp pharmacology unless $@
  1117. def pharmacology
  1118. return true if trait?("PHARMACOLOGY")
  1119. return true if trait?("ITEM_BOOST")
  1120. return true if trait?("ITEM BOOST")
  1121. return pharmacology_actor_csp
  1122. end
  1123.  
  1124. #--------------------------------------------------------------------------
  1125. # alias method: fast_attack
  1126. #--------------------------------------------------------------------------
  1127. alias fast_attack_actor_csp fast_attack unless $@
  1128. def fast_attack
  1129. return true if trait?("FAST_ATTACK")
  1130. return true if trait?("FAST ATTACK")
  1131. return true if trait?("FASTATTACK")
  1132. return fast_attack_actor_csp
  1133. end
  1134.  
  1135. #--------------------------------------------------------------------------
  1136. # alias method: dual_attack
  1137. #--------------------------------------------------------------------------
  1138. alias dual_attack_actor_csp dual_attack unless $@
  1139. def dual_attack
  1140. return true if trait?("DUAL_ATTACK")
  1141. return true if trait?("DUAL ATTACK")
  1142. return true if trait?("DUALATTACK")
  1143. return dual_attack_actor_csp
  1144. end
  1145.  
  1146. #--------------------------------------------------------------------------
  1147. # alias method: prevent_critical
  1148. #--------------------------------------------------------------------------
  1149. alias prevent_critical_actor_csp prevent_critical unless $@
  1150. def prevent_critical
  1151. return true if trait?("PREVENT_CRITICAL")
  1152. return true if trait?("PREVENT CRITICAL")
  1153. return true if trait?("PREVENTCRITICAL")
  1154. return true if trait?("PREVENT_CRIT")
  1155. return true if trait?("PREVENT CRIT")
  1156. return prevent_critical_actor_csp
  1157. end
  1158.  
  1159. #--------------------------------------------------------------------------
  1160. # alias method: half_mp_cost
  1161. #--------------------------------------------------------------------------
  1162. alias half_mp_cost_actor_csp half_mp_cost unless $@
  1163. def half_mp_cost
  1164. return true if trait?("HALF_MP_COST")
  1165. return true if trait?("HALF MP COST")
  1166. return true if trait?("HALFMPCOST")
  1167. return true if trait?("HALF_MP")
  1168. return true if trait?("HALF MP")
  1169. return true if trait?("HALFMP")
  1170. return half_mp_cost_actor_csp
  1171. end
  1172.  
  1173. #--------------------------------------------------------------------------
  1174. # alias method: double_exp_gain
  1175. #--------------------------------------------------------------------------
  1176. alias double_exp_gain_actor_csp double_exp_gain unless $@
  1177. def double_exp_gain
  1178. return true if trait?("DOUBLE_EXP_GAIN")
  1179. return true if trait?("DOUBLE EXP GAIN")
  1180. return true if trait?("DOUBLE EXP")
  1181. return double_exp_gain_actor_csp
  1182. end
  1183.  
  1184. #--------------------------------------------------------------------------
  1185. # alias method: auto_hp_recover
  1186. #--------------------------------------------------------------------------
  1187. alias auto_hp_recover_actor_csp auto_hp_recover unless $@
  1188. def auto_hp_recover
  1189. return true if trait?("AUTO_HP_RECOVER")
  1190. return true if trait?("AUTO HP RECOVER")
  1191. return auto_hp_recover_actor_csp
  1192. end
  1193.  
  1194. end # Game_Actor
  1195.  
  1196. #===============================================================================
  1197. # Game_Enemy
  1198. #===============================================================================
  1199.  
  1200. class Game_Enemy < Game_Battler
  1201.  
  1202. #--------------------------------------------------------------------------
  1203. # alias method: hit
  1204. #--------------------------------------------------------------------------
  1205. alias hit_enemy_csp hit unless $@
  1206. def hit
  1207. n = hit_enemy_csp
  1208. for state in states
  1209. percent = 100
  1210. for i in 1..stack(state); percent += state.stat_per[:hit] - 100; end
  1211. n = n * percent / 100.0
  1212. end
  1213. for state in states;
  1214. for i in 1..stack(state); n += state.stat_set[:hit]; end
  1215. end
  1216. n = [Integer(n), 0].max
  1217. return Integer(n)
  1218. end
  1219.  
  1220. #--------------------------------------------------------------------------
  1221. # alias method: eva
  1222. #--------------------------------------------------------------------------
  1223. alias eva_enemy_csp eva unless $@
  1224. def eva
  1225. n = eva_enemy_csp
  1226. for state in states
  1227. percent = 100
  1228. for i in 1..stack(state); percent += state.stat_per[:eva] - 100; end
  1229. n = n * percent / 100.0
  1230. end
  1231. for state in states;
  1232. for i in 1..stack(state); n += state.stat_set[:eva]; end
  1233. end
  1234. n = [Integer(n), 0].max
  1235. return Integer(n)
  1236. end
  1237.  
  1238. #--------------------------------------------------------------------------
  1239. # alias method: cri
  1240. #--------------------------------------------------------------------------
  1241. alias cri_enemy_csp cri unless $@
  1242. def cri
  1243. n = cri_enemy_csp
  1244. for state in states
  1245. percent = 100
  1246. for i in 1..stack(state); percent += state.stat_per[:cri] - 100; end
  1247. n = n * percent / 100.0
  1248. end
  1249. for state in states;
  1250. for i in 1..stack(state); n += state.stat_set[:cri]; end
  1251. end
  1252. n = [Integer(n), 0].max
  1253. return Integer(n)
  1254. end
  1255.  
  1256. #--------------------------------------------------------------------------
  1257. # alias method: odds
  1258. #--------------------------------------------------------------------------
  1259. alias odds_enemy_csp odds unless $@
  1260. def odds
  1261. n = odds_enemy_csp
  1262. for state in states
  1263. percent = 100
  1264. for i in 1..stack(state); percent += state.stat_per[:odds] - 100; end
  1265. n = n * percent / 100.0
  1266. end
  1267. for state in states;
  1268. for i in 1..stack(state); n += state.stat_set[:odds]; end
  1269. end
  1270. n = [Integer(n), 1].max
  1271. return Integer(n)
  1272. end
  1273.  
  1274. end # Game_Enemy
  1275.  
  1276. #==============================================================================
  1277. # Game_Party
  1278. #==============================================================================
  1279.  
  1280. class Game_Party < Game_Unit
  1281.  
  1282. #--------------------------------------------------------------------------
  1283. # alias method: on_player_walk
  1284. #--------------------------------------------------------------------------
  1285. alias on_player_walk_csp on_player_walk unless $@
  1286. def on_player_walk
  1287. on_player_walk_csp
  1288. return unless YEZ::STATE::STEP_UPDATE_STATES
  1289. return unless @steps % YEZ::STATE::STEPS_PER_ST_TURNS == 0
  1290. for actor in members
  1291. actor.remove_states_auto
  1292. end
  1293. end
  1294.  
  1295. end # Game_Party
  1296.  
  1297. #===============================================================================
  1298. # Sprite_Battler
  1299. #===============================================================================
  1300.  
  1301. class Sprite_Battler < Sprite_Base
  1302.  
  1303. #--------------------------------------------------------------------------
  1304. # class variable
  1305. #--------------------------------------------------------------------------
  1306. @@state_animations = []
  1307. RATE = $imported["CoreFixesUpgrades"] ? YEZ::FIXES::ANIMATION_RATE : 4
  1308.  
  1309. #--------------------------------------------------------------------------
  1310. # alias method: initialize
  1311. #--------------------------------------------------------------------------
  1312. alias initialize_sprite_battler_csp initialize unless $@
  1313. def initialize(viewport, battler = nil)
  1314. initialize_sprite_battler_csp(viewport, battler)
  1315. @state_animation_duration = 0
  1316. end
  1317.  
  1318. #--------------------------------------------------------------------------
  1319. # alias method: dispose
  1320. #--------------------------------------------------------------------------
  1321. alias dispose_sprite_battler_csp dispose unless $@
  1322. def dispose
  1323. dispose_sprite_battler_csp
  1324. dispose_state_animation
  1325. end
  1326.  
  1327. #--------------------------------------------------------------------------
  1328. # alias method: update
  1329. #--------------------------------------------------------------------------
  1330. alias update_sprite_battler_csp update unless $@
  1331. def update
  1332. update_sprite_battler_csp
  1333. if @state_animation != nil
  1334. @state_animation_duration -= 1
  1335. if @state_animation_duration % RATE == 0
  1336. update_state_animation
  1337. end
  1338. end
  1339. @@state_animations.clear
  1340. end
  1341.  
  1342. #--------------------------------------------------------------------------
  1343. # alias method: setup_new_effect
  1344. #--------------------------------------------------------------------------
  1345. alias setup_new_effect_sprite_battler_csp setup_new_effect unless $@
  1346. def setup_new_effect
  1347. setup_new_effect_sprite_battler_csp
  1348. if @battler.state_animation != nil
  1349. if @battler.state_animation == 0
  1350. dispose_state_animation
  1351. else
  1352. start_state_animation($data_animations[@battler.state_animation])
  1353. end
  1354. end
  1355. end
  1356.  
  1357. #--------------------------------------------------------------------------
  1358. # new method: start_state_animation
  1359. #--------------------------------------------------------------------------
  1360. def start_state_animation(animation)
  1361. return if @state_animation != nil and @state_animation.id == animation.id
  1362. dispose_state_animation
  1363. @state_animation = animation
  1364. return if @state_animation == nil
  1365. @state_animation_mirror = false
  1366. @state_animation_duration = @state_animation.frame_max * RATE + 1
  1367. load_state_animation_bitmap
  1368. @state_animation_sprites = []
  1369. if @state_animation.position != 3 or !@@state_animations.include?(animation)
  1370. if @use_sprite
  1371. for i in 0..15
  1372. sprite = ::Sprite.new(viewport)
  1373. sprite.visible = false
  1374. @state_animation_sprites.push(sprite)
  1375. end
  1376. unless @@state_animations.include?(animation)
  1377. @@state_animations.push(animation)
  1378. end
  1379. end
  1380. end
  1381. if @state_animation.position == 3
  1382. if viewport == nil
  1383. @state_animation_ox = 544 / 2
  1384. @state_animation_oy = 416 / 2
  1385. else
  1386. @state_animation_ox = viewport.rect.width / 2
  1387. @state_animation_oy = viewport.rect.height / 2
  1388. end
  1389. else
  1390. @state_animation_ox = x - ox + width / 2
  1391. @state_animation_oy = y - oy + height / 2
  1392. if @state_animation.position == 0
  1393. @state_animation_oy -= height / 2
  1394. elsif @state_animation.position == 2
  1395. @state_animation_oy += height / 2
  1396. end
  1397. end
  1398. end
  1399.  
  1400. #--------------------------------------------------------------------------
  1401. # new method: load_state_animation_bitmap
  1402. #--------------------------------------------------------------------------
  1403. def load_state_animation_bitmap
  1404. animation1_name = @state_animation.animation1_name
  1405. animation1_hue = @state_animation.animation1_hue
  1406. animation2_name = @state_animation.animation2_name
  1407. animation2_hue = @state_animation.animation2_hue
  1408. @state_animation_bitmap1 = Cache.animation(animation1_name, animation1_hue)
  1409. @state_animation_bitmap2 = Cache.animation(animation2_name, animation2_hue)
  1410. if @@_reference_count.include?(@state_animation_bitmap1)
  1411. @@_reference_count[@state_animation_bitmap1] += 1
  1412. else
  1413. @@_reference_count[@state_animation_bitmap1] = 1
  1414. end
  1415. if @@_reference_count.include?(@state_animation_bitmap2)
  1416. @@_reference_count[@state_animation_bitmap2] += 1
  1417. else
  1418. @@_reference_count[@state_animation_bitmap2] = 1
  1419. end
  1420. Graphics.frame_reset
  1421. end
  1422.  
  1423. #--------------------------------------------------------------------------
  1424. # new method: dispose_state_animation
  1425. #--------------------------------------------------------------------------
  1426. def dispose_state_animation
  1427. if @state_animation_bitmap1 != nil
  1428. @@_reference_count[@state_animation_bitmap1] -= 1
  1429. if @@_reference_count[@state_animation_bitmap1] == 0
  1430. @state_animation_bitmap1.dispose
  1431. end
  1432. end
  1433. if @state_animation_bitmap2 != nil
  1434. @@_reference_count[@state_animation_bitmap2] -= 1
  1435. if @@_reference_count[@state_animation_bitmap2] == 0
  1436. @state_animation_bitmap2.dispose
  1437. end
  1438. end
  1439. if @state_animation_sprites != nil
  1440. for sprite in @state_animation_sprites
  1441. sprite.dispose
  1442. end
  1443. @state_animation_sprites = nil
  1444. @state_animation = nil
  1445. end
  1446. @state_animation_bitmap1 = nil
  1447. @state_animation_bitmap2 = nil
  1448. end
  1449.  
  1450. #--------------------------------------------------------------------------
  1451. # new method: update_state_animation
  1452. #--------------------------------------------------------------------------
  1453. def update_state_animation
  1454. if @state_animation_duration > 0
  1455. frame_index = @state_animation.frame_max -
  1456. (@state_animation_duration + RATE - 1) / RATE
  1457. state_animation_set_sprites(@state_animation.frames[frame_index])
  1458. for timing in @state_animation.timings
  1459. if timing.frame == frame_index
  1460. state_animation_process_timing(timing)
  1461. end
  1462. end
  1463. else
  1464. @state_animation_duration = @state_animation.frame_max * RATE + 1
  1465. end
  1466. if @state_animation.position == 3
  1467. if viewport == nil
  1468. @state_animation_ox = 544 / 2
  1469. @state_animation_oy = 416 / 2
  1470. else
  1471. @state_animation_ox = viewport.rect.width / 2
  1472. @state_animation_oy = viewport.rect.height / 2
  1473. end
  1474. else
  1475. @state_animation_ox = x - ox + width / 2
  1476. @state_animation_oy = y - oy + height / 2
  1477. if @state_animation.position == 0
  1478. @state_animation_oy -= height / 2
  1479. elsif @state_animation.position == 2
  1480. @state_animation_oy += height / 2
  1481. end
  1482. end
  1483. end
  1484.  
  1485. #--------------------------------------------------------------------------
  1486. # new method: state_animation_set_sprites
  1487. #--------------------------------------------------------------------------
  1488. def state_animation_set_sprites(frame)
  1489. cell_data = frame.cell_data
  1490. for i in 0..15
  1491. sprite = @state_animation_sprites[i]
  1492. next if sprite == nil
  1493. pattern = cell_data[i, 0]
  1494. if pattern == nil or pattern == -1
  1495. sprite.visible = false
  1496. next
  1497. end
  1498. if pattern < 100
  1499. sprite.bitmap = @state_animation_bitmap1
  1500. else
  1501. sprite.bitmap = @state_animation_bitmap2
  1502. end
  1503. sprite.visible = true
  1504. sprite.src_rect.set(pattern % 5 * 192,
  1505. pattern % 100 / 5 * 192, 192, 192)
  1506. if @state_animation_mirror
  1507. sprite.x = @state_animation_ox - cell_data[i, 1]
  1508. sprite.y = @state_animation_oy + cell_data[i, 2]
  1509. sprite.angle = (360 - cell_data[i, 4])
  1510. sprite.mirror = (cell_data[i, 5] == 0)
  1511. else
  1512. sprite.x = @state_animation_ox + cell_data[i, 1]
  1513. sprite.y = @state_animation_oy + cell_data[i, 2]
  1514. sprite.angle = cell_data[i, 4]
  1515. sprite.mirror = (cell_data[i, 5] == 1)
  1516. end
  1517. sprite.z = self.z + 300 + i
  1518. sprite.ox = 96
  1519. sprite.oy = 96
  1520. sprite.zoom_x = cell_data[i, 3] / 100.0
  1521. sprite.zoom_y = cell_data[i, 3] / 100.0
  1522. if @battler.actor?
  1523. sprite.zoom_x *= YEZ::STATE::ANI_ACTOR_ZOOM
  1524. sprite.zoom_x /= 100
  1525. sprite.zoom_y *= YEZ::STATE::ANI_ACTOR_ZOOM
  1526. sprite.zoom_y /= 100
  1527. end
  1528. sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  1529. sprite.blend_type = cell_data[i, 7]
  1530. end
  1531. end
  1532. #--------------------------------------------------------------------------
  1533. # new method: state_animation_process_timing
  1534. #--------------------------------------------------------------------------
  1535. def state_animation_process_timing(timing)
  1536. timing.se.play if YEZ::STATE::ANIMATION_SOUND
  1537. case timing.flash_scope
  1538. when 1
  1539. self.flash(timing.flash_color, timing.flash_duration * RATE)
  1540. when 2
  1541. return unless YEZ::STATE::ANIMATION_FLASH
  1542. if viewport != nil
  1543. viewport.flash(timing.flash_color, timing.flash_duration * RATE)
  1544. end
  1545. when 3
  1546. self.flash(nil, timing.flash_duration * RATE)
  1547. end
  1548. end
  1549.  
  1550. end # Sprite_Battler
  1551.  
  1552. #===============================================================================
  1553. # Scene_Battle
  1554. #===============================================================================
  1555.  
  1556. class Scene_Battle < Scene_Base
  1557.  
  1558. #--------------------------------------------------------------------------
  1559. # public instance variables
  1560. #--------------------------------------------------------------------------
  1561. attr_accessor :active_battler
  1562.  
  1563. #--------------------------------------------------------------------------
  1564. # alias method: start
  1565. #--------------------------------------------------------------------------
  1566. alias start_battle_csp start unless $@
  1567. def start
  1568. start_battle_csp
  1569. for member in $game_party.members + $game_troop.members
  1570. member.reload_state_animation
  1571. end
  1572. end
  1573.  
  1574. #--------------------------------------------------------------------------
  1575. # alias method: start_main
  1576. #--------------------------------------------------------------------------
  1577. alias start_main_csp start_main unless $@
  1578. def start_main
  1579. start_main_csp
  1580. for member in ($game_party.members + $game_troop.members)
  1581. for state in member.states
  1582. member.custom_status_effects(state, "BEGIN")
  1583. end
  1584. end
  1585. end
  1586.  
  1587. #--------------------------------------------------------------------------
  1588. # alias method: battle_end
  1589. #--------------------------------------------------------------------------
  1590. alias battle_end_csp battle_end unless $@
  1591. def battle_end(result)
  1592. battle_end_csp(result)
  1593. for member in $game_party.members; member.reset_state_origins; end
  1594. end
  1595.  
  1596. end # Scene_Battle
  1597.  
  1598. #===============================================================================
  1599. #
  1600. # END OF FILE
  1601. #
  1602. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement