Advertisement
Guest User

Untitled

a guest
Jan 4th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.19 KB | None | 0 0
  1. STR_MOD_OVERCAP_MOD = 1 #0.5 # modifier values above softcap will apply at this rate
  2. # 1.0 in the above will disable this scaling
  3. STR_MOD_SOFTCAP = 2.22 # str modifier softcap
  4.  
  5. ATTACK_DAMAGE_STR_FOCUS = 200.0 # 300.0 previous default
  6. ATTACK_DAMAGE_VIT_FOCUS = 500.0 # 500.0 previous default
  7. HEAL_NORMAL_WIS_FOCUS = 1000.0
  8.  
  9. module DamageFormula
  10. # This new constant bank overrides all previous settings
  11. # dont change
  12. OFFENSE_STAT_FOCUS = {}
  13. DEFENSE_STAT_FOCUS = {}
  14. OFFENSE_MOD_SOFTCAP = {}
  15. OFFENSE_MOD_OVERCAP_RATIO = {}
  16. DEFENSE_MOD_SOFTCAP = {}
  17. DEFENSE_MOD_OVERCAP_RATIO = {}
  18.  
  19. # symbol bank
  20. # :attack_damage
  21. # :aura_glaive
  22. # :spell_damage
  23. # :xbow_damage
  24. # :blood_damage
  25. # :gun_damage
  26. # :heal_normal
  27. # :blood_heal_direct
  28. # for heals, only the offense stat matters
  29.  
  30. # Offense Stat Focus - The the amout of offensive stat it takes to reach double damage
  31. # calculated on a curve
  32. # (ie, 500 = double, 1000 = triple)
  33. # higher numbers means the stat takes longer to get to broken numbers
  34. OFFENSE_STAT_FOCUS.default = 500
  35. OFFENSE_STAT_FOCUS[:attack_damage] = 300 # primarily why attack is so OP
  36. OFFENSE_STAT_FOCUS[:aura_glaive] = 500
  37. OFFENSE_STAT_FOCUS[:xbow_damage] = 400
  38. OFFENSE_STAT_FOCUS[:spell_damage] = 500
  39. OFFENSE_STAT_FOCUS[:gun_damage] = 500 # uses weapon power as "str" for ingrid now, default disabled
  40. OFFENSE_STAT_FOCUS[:blood_damage] = 500
  41. OFFENSE_STAT_FOCUS[:heal_normal] = 1000
  42. OFFENSE_STAT_FOCUS[:blood_heal_direct] = 500 # blood heal is only half efficent by default, hence lower numbers here
  43.  
  44. # Defensive Stat Focus - The amout of defensive stat it takes to half damage
  45. # caluclated on a curve
  46. # (ie, 500 = half, 1000 = third)
  47. DEFENSE_STAT_FOCUS.default = 500
  48. DEFENSE_STAT_FOCUS[:attack_damage] = 450
  49. DEFENSE_STAT_FOCUS[:aura_glaive] = 500 # irrelevant/ignored in calc
  50. DEFENSE_STAT_FOCUS[:xbow_damage] = 500
  51. DEFENSE_STAT_FOCUS[:spell_damage] = 350
  52. DEFENSE_STAT_FOCUS[:gun_damage] = 500
  53. DEFENSE_STAT_FOCUS[:blood_damage] = 500
  54. DEFENSE_STAT_FOCUS[:heal_normal] = 500 # irrelevant/ignored in calc
  55. DEFENSE_STAT_FOCUS[:blood_heal_direct] = 500 # irrelevant/ignored in calc
  56.  
  57.  
  58. # Offense mod softcap - the point at which a damage modifier stops rising at a 1:1 ratio
  59. # ratios below
  60. # (a 3x modifier with a softcap of 2 and overcap ratio of 0.5 becomes 2.5)
  61. OFFENSE_MOD_SOFTCAP.default = 1.0
  62. OFFENSE_MOD_SOFTCAP[:attack_damage] = 2.22
  63. OFFENSE_MOD_SOFTCAP[:aura_glaive] = 1.0
  64. OFFENSE_MOD_SOFTCAP[:xbow_damage] = 2.22
  65. OFFENSE_MOD_SOFTCAP[:spell_damage] = 1.0
  66. OFFENSE_MOD_SOFTCAP[:gun_damage] = 1.0
  67. OFFENSE_MOD_SOFTCAP[:blood_damage] = 2.22
  68. OFFENSE_MOD_SOFTCAP[:heal_normal] = 1.0
  69. OFFENSE_MOD_SOFTCAP[:blood_heal_direct] = 1.0
  70.  
  71.  
  72. # Offense mod overcap ratio - how much of a bonus is applied
  73. # (a 3x modifier with a softcap of 2 and overcap ratio of 0.5 becomes 2.5)
  74. OFFENSE_MOD_OVERCAP_RATIO.default = 1.0
  75. OFFENSE_MOD_OVERCAP_RATIO[:attack_damage] = 0.5
  76. OFFENSE_MOD_OVERCAP_RATIO[:aura_glaive] = 1.0
  77. OFFENSE_MOD_OVERCAP_RATIO[:xbow_damage] = 0.5
  78. OFFENSE_MOD_OVERCAP_RATIO[:spell_damage] = 1.0
  79. OFFENSE_MOD_OVERCAP_RATIO[:gun_damage] = 0.0 # turned off gun scaling to match prior values
  80. OFFENSE_MOD_OVERCAP_RATIO[:blood_damage] = 0.5
  81. OFFENSE_MOD_OVERCAP_RATIO[:heal_normal] = 1.0
  82. OFFENSE_MOD_OVERCAP_RATIO[:blood_heal_direct] = 1.0
  83.  
  84. # same as with offense
  85. DEFENSE_MOD_SOFTCAP.default = 1.0
  86. DEFENSE_MOD_SOFTCAP[:attack_damage] = 1.0
  87. DEFENSE_MOD_SOFTCAP[:aura_glaive] = 1.0 # no defense stat
  88. DEFENSE_MOD_SOFTCAP[:xbow_damage] = 1.0
  89. DEFENSE_MOD_SOFTCAP[:spell_damage] = 1.0
  90. DEFENSE_MOD_SOFTCAP[:gun_damage] = 1.0
  91. DEFENSE_MOD_SOFTCAP[:blood_damage] = 2.22
  92. DEFENSE_MOD_SOFTCAP[:heal_normal] = 1.0 # no defense stat
  93. DEFENSE_MOD_SOFTCAP[:blood_heal_direct] = 1.0 # no defense stat
  94.  
  95. DEFENSE_MOD_OVERCAP_RATIO.default = 1.0
  96. DEFENSE_MOD_OVERCAP_RATIO[:attack_damage] = 1.0
  97. DEFENSE_MOD_OVERCAP_RATIO[:aura_glaive] = 1.0 # no defense stat
  98. DEFENSE_MOD_OVERCAP_RATIO[:xbow_damage] = 1.0
  99. DEFENSE_MOD_OVERCAP_RATIO[:spell_damage] = 1.0
  100. DEFENSE_MOD_OVERCAP_RATIO[:gun_damage] = 1.0
  101. DEFENSE_MOD_OVERCAP_RATIO[:blood_damage] = 1.0
  102. DEFENSE_MOD_OVERCAP_RATIO[:heal_normal] = 1.0 # no defense stat
  103. DEFENSE_MOD_OVERCAP_RATIO[:blood_heal_direct] = 1.0 # no defense stat
  104.  
  105.  
  106. end
  107.  
  108. # cannot be zero or negative
  109. # DAMAGE FORMULA
  110. # These additions are for linked proc skills with secondary effects
  111. #
  112. # formulas available
  113. # attack_damage - for normal attacks and physical skills
  114. # mixed_damage - ONLY for non-proc dual component skills with splash
  115. # deritivave_damage - does the skill power mod percent of the main skill's damage
  116. # gun_damage - for ingrid's gun attacks, no str mod but gains a very slight bonus
  117. # from level to keep it in line with other skills
  118. # xbow_damage - for Eskandar's xbow skills
  119. # blood_damage - for Soha's NON WEAPON blood skills
  120. # spell_damage - for any int based non-weapon power skill
  121. # heal_normal - normal heal based on wis
  122. # blood_heal_direct - heal from blood power, some is lost, less is lost with higher int
  123. # final_reckoning_damage - for the final reckoning skill, damage based on absorbed HP
  124.  
  125. # tags (goes in the skill's note)
  126. # <skill damage mod n> skill does n% of normal damage
  127. # <str scale mod n> str scaling is n% of normal
  128. # <int scale mod n> int scaling is n% of normal
  129. # <dex scale mod n> dex scaling is n% of normal (for extra hits on hits skills, and xbow damage)
  130. # <physical weight n> n is a value > 1. The weight given to physical for non-proc multicomponent skills
  131. # <magical weight n> n is a value > 1. The weight given to magical for non-proc multicomponent skills
  132. # <drain ratio n> n% HP is healed to the user from this skill (default is 50%)
  133. # only affects skills with the damage type "HP Drain"
  134. # <spell power mod n> affects the main component of spell_damage and blood_damage ONLY
  135. # <proc damage x y> skill with id x will proc with y% of its normal damage when this skill is used
  136. # if used on a state, damage will proc when a physical attack is used
  137. # <noproc> this skill will not proc "physical attack" based procs
  138. # (for use with the ice blades etc, since they are techincally physical)
  139. #
  140.  
  141. # spells, dots, and blood skills have 3 new tags
  142. # <base damage n>
  143. # sets the absolute base of the skill, default is 100
  144. # <offense scale n>
  145. # offensive stat will contribute n% toward the base
  146. # (default is 100%)
  147. # <defense scale n>
  148. # defending stat will subtract n% of its value from the base
  149. # (default is 50%)
  150. # new formula is (base + offense_stat - defense_stat) * scalar mods
  151. # recommend DoTs be reduced significantly in either skill power, or
  152. # offense / defense scale
  153. # 50 skill power DoT * 5 stacks = more damage /tick than a finisher
  154. # endgame power of spells will hopefully be around the same as weapon attacks
  155. # but is likely to drop off slightly in post game
  156.  
  157. class Game_Battler
  158. # original damage values
  159. #~ def make_damage_value(user, item)
  160. #~ value = item.damage.eval(user, self, $game_variables)
  161. #~ value *= item_element_rate(user, item)
  162. #~ #value *= pdr if item.physical?
  163. #~ #value *= mdr if item.magical?
  164. #~ check_force_remove_barrier(user, item)
  165. #~ value = 0 if barrier?
  166. #~ value *= rec if item.damage.recover?
  167. #~ value = apply_critical(value) if @result.critical
  168. #~ value = apply_variance(value, item.damage.variance)
  169. #~ value = apply_guard(value)
  170. #~ @result.make_damage(value.to_i, item)
  171. #~ end
  172. attr_accessor :backdash
  173.  
  174. def null_blood_cost
  175. false
  176. end
  177.  
  178. def force_action_counter(skill_id, target_index)
  179. #clear_actions
  180. action = Game_Action.new(self, true)
  181. action.set_skill(skill_id)
  182. if target_index == -2
  183. action.target_index = last_target_index
  184. elsif target_index == -1
  185. action.decide_random_target
  186. else
  187. action.target_index = target_index
  188. end
  189. @actions.unshift(action)
  190. end
  191.  
  192. #~ def make_damage_value_old(user, item, splash_index = 0, stacks = 1, result = @result)
  193. #~ main_damage = item.damage
  194. #~ base_value = item.damage.evaluate(user, self, $game_variables, $game_switches, item, nil, nil, 0)
  195. #~ base_value = apply_all_damage_mods(base_value, user, item, main_damage, splash_index, stacks)
  196. #~ value = base_value.to_i
  197. #~ values = [[base_value.to_i, main_damage, result.critical]]
  198. #~ hits = 1
  199. #~ proc_damages = item.proc_damages.clone
  200. #~ proc_damages += user.proc_damages if item.physical? && !item.noproc
  201. #~ #p user.proc_damages
  202. #~ proc_damages.each { |ary|
  203. #~ skill = ary[0]
  204. #~ rate = ary[1]
  205. #~ dmg = skill.damage
  206. #~ v = dmg.evaluate(user, self, $game_variables, $game_switches, skill, main_damage, base_value, hits)
  207. #~ v *= rate
  208. #~ v = apply_all_damage_mods(v, user, item, dmg, splash_index, stacks)
  209. #~ crit = skill.damage.critical && @result.critical
  210. #~ v = v.to_i
  211. #~ next if v == 0
  212. #~ value += v
  213. #~ values.push([v, dmg, crit])
  214. #~ hits += 1
  215. #~ }
  216. #~ if item.feral_frenzy != :none
  217. #~ extra_hits = calc_feral_frenzy(user, item, self)
  218. #~ elsif item.barrage > 0
  219. #~ extra_hits = calc_barrage(user, item, self)
  220. #~ elsif item.repeats > 1
  221. #~ extra_hits = item.repeats - 1
  222. #~ elsif item.normal_attack?
  223. #~ extra_hits = calc_multihit(user, item, self)
  224. #~ extra_hits += 1 if user == soha && soha.battle_skill_learn?(740) && item.normal_attack?
  225. #~ extra_hits += user.hits.to_i if user.hits > 0
  226. #~ extra_hits += user.atk_times_add.to_i
  227. #~ end
  228. #~ if extra_hits
  229. #~ extra_hits.times { |i|
  230. #~ v = item.damage.evaluate(user, self, $game_variables, $game_switches, item, main_damage, base_value, 0)
  231. #~ #v *= 0.10 * 0.9 ** i if item.normal_attack?
  232. #~ # weak extra hits - 20% for the first extra hit, 90% of that hit for additional
  233. #~ #v *= 0.95 * 0.95 ** i unless item.normal_attack?
  234. #~ # strong extra hits hits - 95% for the first extra hit, 95% of that hit for additional
  235. #~ v = v.to_i
  236. #~ next if v == 0
  237. #~ value += v
  238. #~ crit = item.damage.critical && result.critical
  239. #~ values.push([v, item.damage, crit])
  240. #~ hits += 1
  241. #~ }
  242.  
  243. #~ end
  244. #~ #check_force_remove_barrier(user, item)
  245. #~ ([[item, 100]] + proc_damages).each { |ary|
  246. #~ skill = ary[0]
  247. #~ rate = ary[1]
  248. #~ check_force_remove_barrier(user, skill)
  249. #~ no_damage = barrier? || state?(535) # last stand, barrier, invincibility
  250. #~ no_damage = true if state?(631)
  251. #~ value = 0 if no_damage
  252. #~ values = [[0, item.damage, false]] if no_damage
  253. #~ }
  254. #~ #p values.collect { |v| v[0] }
  255. #~ result.make_damage(value.to_i, item, user, self, values)
  256. #~ end
  257.  
  258. def make_damage_value(user, item, splash_index = 0, stacks = 1, result = @result)
  259. make_damage_value_main(user, item, splash_index, stacks, result)
  260. end
  261.  
  262. def make_damage_value_main(user, item, splash_index = 0, stacks = 1, result = @result)
  263. main_damage = item.damage
  264. unmod_value = item.damage.evaluate(user, self, $game_variables, $game_switches, item, nil, nil, 0)
  265. base_value = apply_all_damage_mods(unmod_value, user, item, main_damage, splash_index, stacks)
  266. value = base_value.to_i
  267. proc_damages = item.proc_damages.clone
  268. proc_damages += user.proc_damages if item.physical? && !item.noproc
  269. proc_damages.each { |ary|
  270. skill = ary[0]
  271. rate = ary[1]
  272. dmg = skill.damage
  273. v = dmg.evaluate(user, self, $game_variables, $game_switches, skill, main_damage, base_value, hits)
  274. v *= rate
  275. v = apply_all_damage_mods(v, user, item, dmg, splash_index, stacks)
  276. crit = skill.damage.critical && result.critical
  277. v = v.to_i
  278. value += v
  279. }
  280. ehits = user.element_hits
  281. ehits = [] unless item.physical?
  282. ehits.each_with_index { |ehit, i|
  283. next if ehit == 0
  284. rate = ehit
  285. ni = item.clone
  286. ni.damage = item.damage.clone
  287. ni.damage.element_id = i
  288. v = apply_all_damage_mods(unmod_value, user, ni, ni.damage, splash_index, stacks)
  289. v *= rate
  290. v = v.to_i
  291. value += v
  292. }
  293. no_damage = false
  294. ([[item, 100]] + proc_damages).each { |ary|
  295. skill = ary[0]
  296. rate = ary[1]
  297. check_force_remove_barrier(user, skill)
  298. no_damage = barrier? || state?(535) || state?(631) # last stand, barrier, invincibility
  299. }
  300. value = 0 if no_damage
  301. result.item = item
  302. result.user = user
  303. result.make_damage(value.to_i, item, user, self)
  304. end
  305.  
  306. def target_multihit_expand(item, targets)
  307. result = []
  308. targets.each { |target|
  309. hits = target.make_extra_hits(self, item) #, splash_index = 0, stacks = 1, result = @result)
  310. hits.times { result.push(target) }
  311. }
  312. result
  313. end
  314.  
  315. def make_extra_hits(user, item, splash_index = 0, stacks = 1, result = @result)
  316. extra_hits = 1
  317. if item.feral_frenzy != :none
  318. extra_hits += calc_feral_frenzy(user, item, self)
  319. elsif item.barrage > 0
  320. extra_hits += calc_barrage(user, item, self)
  321. elsif item.repeats > 1
  322. extra_hits += item.repeats - 1
  323. elsif item.normal_attack?
  324. extra_hits += calc_multihit(user, item, self)
  325. extra_hits += 1 if user == soha && soha.battle_skill_learn?(740) && item.normal_attack?
  326. extra_hits += user.hits.to_i if user.hits > 0
  327. extra_hits += user.atk_times_add.to_i
  328. end
  329. extra_hits
  330. end
  331.  
  332. def calc_multihit(user, item, target)
  333. value = item.repeats - 1
  334. return value
  335. #return value unless item.normal_attack?
  336. dex = user.luk * item.dex_mod / 100
  337. loop do
  338. if dex > rand(200) + 50
  339. value += 1
  340. dex -= 200
  341. else
  342. break
  343. end
  344. end
  345. value
  346. end
  347.  
  348. def proc_damages
  349. ary = []
  350. states.each { |obj|
  351. #p obj.proc_damages
  352. ary += obj.proc_damages unless obj.proc_damages.empty? # != :none
  353. }
  354. ary += [[$data_skills[188], 1.0]] if actor? && battle_skill_learn?(1135) # aura glaive
  355. #p ary
  356. ary
  357. end
  358.  
  359. def calc_feral_frenzy(user, item, target)
  360. return 9
  361. hit = calced_hit(user, item)
  362. hits = 0
  363. loop do
  364. hit *= item.feral_frenzy
  365. miss = rand > hit
  366. break if miss
  367. hits += 1
  368. return 9 if hits > 9
  369. end
  370. hits
  371. end
  372.  
  373. def calc_barrage(user, item, target)
  374. item.barrage + calc_multihit(user, item, target)
  375. end
  376.  
  377. def apply_all_damage_mods(value, user, item, dmg, splash_index, stacks = 1)
  378. return value if item.no_damage_mod
  379. value *= stacks
  380. value *= item_element_rate(user, item)
  381. value *= item_element_boost(user, item)
  382. value *= rec if item.damage.recover?
  383. value *= pdr if item.physical? && value > 0
  384. #p ["magic damage rate #{mdr}, prior value #{value}"] if item.magical?
  385. value *= mdr if item.magical? && value > 0
  386. value *= dra if value > 0
  387. value *= user.pda if item.physical? && value > 0
  388. value += value * item.chi_power * user.friends_unit.tp / 10000
  389. value *= cull_mod(user, item)
  390. value *= stealth_rate(user, item) if user.state?(425) # stealth
  391. value *= consume_stacks_mod(user, item)
  392. value = apply_regal_presence(value, user, item) if opposite?(user)
  393. value = apply_divine_barrier_mod(value, user, item) if opposite?(user)
  394. value = apply_critical(value, user, item) if result.critical && dmg.critical # only if this hit allows splash
  395. #value *= 2 if @result.critical && dmg.critical && user.actor? && user.battle_skill_learn?(545) && item.target_data_default_symbol == :ranged_single && item.physical?
  396. value = apply_splash_rate(value, user.action.splash_power(splash_index)) unless splash_index == 0
  397. value = apply_variance(value, item.damage.variance) if item.allow_variance
  398. value = apply_guard(value) #if value > 0
  399. value
  400. end
  401.  
  402. def consume_stacks_mod(user, item)
  403. return 1 unless item.consume_stacks
  404. state_id, rate = item.consume_stacks
  405. if state_id == 200 && user.is_a?(Game_Actor) && fire_mastery #opts[:user].battle_skill_learn?(350)
  406. state_id += 1
  407. elsif state_id == 205 && user.is_a?(Game_Actor) && ice_mastery #opts[:user].battle_skill_learn?(360)
  408. state_id += 1
  409. elsif state_id == 210 && user.is_a?(Game_Actor) && lightning_mastery # opts[:user].battle_skill_learn?(355)
  410. state_id += 1
  411. end
  412. rate /= 100.0
  413. state = find_state?(state_id)
  414. return 1 unless state
  415. return 1 unless state.id == state_id
  416. 1 + rate * state.stacks
  417. end
  418.  
  419. def cull_mod(user, item)
  420. return 1 if item.cull == 0
  421. 1 + (item.cull * (1 - hp_rate) / 100)
  422. end
  423.  
  424. def stealth_rate(user, item)
  425. item.stealth_mod
  426. end
  427.  
  428. def item_element_boost(user, item)
  429. rate = 1.0
  430. if user.actor? && user.battle_skill_learn?(350) # fire mastery
  431. rate *= 1.5 if item.damage.element_id == 3 # fire
  432. elsif item.id == 151 && lucian.battle_skill_learn?(350)
  433. rate *= 1.5 # burn
  434. end
  435. if user.actor? && user.battle_skill_learn?(360) # ice mastery
  436. rate *= 1.25 if item.damage.element_id == 4 # ice
  437. end
  438. if user.actor? && user.battle_skill_learn?(355) # lit mastery
  439. rate *= 1.25 if item.damage.element_id == 5 # thunder
  440. end
  441. if user.actor? && user.battle_skill_learn?(540) # pyromaniac
  442. rate *= 1.33 if item.damage.element_id == 3
  443. end
  444. p "element attack rate at #{rate}" if ECHO_ELEMENT_ATTACK_RATE
  445. rate
  446. end
  447.  
  448. def apply_divine_barrier_mod(value, user, item)
  449. return value unless state?(530)
  450. barrier_mod = 1 - (kesh.wis / (kesh.wis + 5000.0 / kesh.barrier_value))
  451. value * barrier_mod
  452. end
  453.  
  454. def barrier_value
  455. 5.times { |i|
  456. return 100 + i * 20 if battle_skill_learn?(1040 + i) # divine barrier
  457. }
  458. return 100
  459. end
  460.  
  461. def apply_critical(damage, user, item)
  462. mod = [(user.cdb + item.cdb - 2.0) * user.cdr * item.cdr, 2.0].max
  463. if item.target_data_default_symbol == :ranged_single && item.physical? && user == ingrid && user.battle_skill_learn?(545) # deadeye
  464. mod += 1.0
  465. end
  466. if user == eskandar && user.battle_skill_learn?(915) # acuity
  467. mod *= 1 / (1 - (user.int / (user.int + 500.0)))
  468. end
  469. mod *= item.cdr
  470. p "critical damage modifier #{mod}"
  471. damage * mod
  472. end
  473.  
  474. def apply_regal_presence(damage, user, item)
  475. return damage unless soha.battle_skill_learn?(715) # regal presence
  476. damage *= 1.25 if user == soha && opposite?(soha) && self.enemy.tagged_with?('human')
  477. damage *= 0.75 if self == soha && user.opposite?(soha) && user.enemy.tagged_with?('human')
  478. damage
  479. end
  480.  
  481. def item_element_rate(user, item)
  482. if item.damage.element_id < 0
  483. user.atk_elements.empty? ? 1.0 : elements_max_rate(user.atk_elements) #* user.element_attack(item.damage.element_id)
  484. else
  485. element_rate(item.damage.element_id) #* user.element_attack(item.damage.element_id)
  486. end
  487. end
  488.  
  489. def apply_splash_rate(value, splash_rate)
  490. value = value * splash_rate / 100
  491. end
  492.  
  493. def barrier?
  494. state?(185)
  495. end
  496.  
  497. def check_force_remove_barrier(user, item)
  498. if item.remove_barrier || user.remove_barrier
  499. remove_state(185)
  500. end
  501. end
  502.  
  503. def remove_barrier
  504. return false unless actor?
  505. lightfury_equipped?
  506. end
  507.  
  508. def lightfury_equipped?
  509. equips.any? { |i| i && i.object && i.object.tagged_with?('remove barrier') }
  510. end
  511.  
  512. def item_apply_old(user, item, splash_index = 0)
  513. #p "#{self} is getting used by #{item.name}"
  514. @result.clear
  515. @result.used = item_test(user, item)
  516. #@result.missed = false
  517. @result.missed = (@result.used && rand >= item_hit(user, item))
  518. @result.missed = true if state?(515) && item.target_data_default_symbol == :ranged_single && item.physical? # staff spin
  519. @result.evaded = (!@result.missed && rand < item_eva(user, item))
  520. check_backdash(user, item) if state?(440) && opposite?(user)
  521. @result.evaded = false unless opposite?(user)
  522. @result.evaded = true if @result.missed
  523. if @result.hit?
  524. grabby = state?(634)
  525. #p "#{self} is getting hit by #{item.name}"
  526. aspect_link = state?(630)
  527. unless item.damage.none?
  528. check_critical(user, item)
  529. make_damage_value(user, item, splash_index)
  530. check_damage_share(user, item) if actor?
  531. execute_damage(user)
  532. aether_battery_effect if self.actor? && $game_party.alive_members.include?(ingrid) && ingrid.battle_skill_learn?(555) && item.damage.element_id == 7
  533. apply_poison_coating(user, item) if user.actor? && user.battle_skill_learn?(925) #poison coating
  534. apply_deep_cuts(user, item) if user.actor? && user.battle_skill_learn?(905) # bleed/ deep cuts
  535. end
  536. item.effects.each {|effect| item_effect_apply(user, item, effect) }
  537. execute_ctb_damage(user, item)
  538. apply_ctb_gain(item)
  539. apply_stagger_damage(user, item)
  540. do_interrupt if item.interrupt
  541. apply_meditation_effect if item && (1080..1084).include?(item.id)
  542. apply_stack_consume(user, item)
  543. #p @result.hp_damage
  544. check_autostealth
  545. item_user_effect(user, item)
  546. user_hit_tp_gain(user, item)
  547. giovany_hit_check(user, item) if self.enemy?
  548. kormag_checks(user, item, aspect_link)
  549. soha_grab_release_check(user, item) if self.enemy?
  550. death_release_check(user, item) if self.actor? && grabby
  551. user.giovany_user_check(user, item) if user.enemy?
  552. #user.result.hits += 1
  553. #user.result.states_added += @result.added_states.size
  554. #user.result.success = true
  555. else
  556. user_miss_tp_gain(user, item)
  557. end
  558. user.tp_gain_buffer[:uses] += 1
  559. end
  560.  
  561. def check_item_hit(user, item, splash_index = 0, result = @result)
  562. #result.clear unless $game_party.in_battle
  563. result.used = item_test_simple(user, item)
  564. result.damage_fake = true if dead? && !item.allow_dead?
  565. p result.damage_fake
  566. #@result.missed = false
  567. result.missed = (result.used && rand >= item_hit(user, item))
  568. result.missed = true if state?(515) && item.target_data_default_symbol == :ranged_single && item.physical? # staff spin
  569. result.evaded = (!result.missed && rand < item_eva(user, item))
  570. check_backdash(user, item) if state?(440) && opposite?(user)
  571. result.evaded = false unless opposite?(user)
  572. result.evaded = true if result.missed
  573. end
  574.  
  575. def item_apply(user, item, splash_index = 0, result = nil)
  576. result ||= results.last
  577. clear_result unless $game_party.in_battle
  578. if result.used
  579. #p [@result.used, "herehere", results.size]
  580. add_result
  581. #self.results.push(Game_ActionResult.new(self))
  582. result = results.last
  583. #p [@result.used, "herehere", results.size]
  584. end
  585. check_item_hit(user, item, splash_index, result)
  586. if result.hit?
  587. grabby = state?(634)
  588. aspect_link = state?(630)
  589. unless item.damage.none?
  590. result.used_damage = true
  591. check_critical(user, item, result)
  592. make_damage_value(user, item, splash_index, 1, result)
  593. check_damage_share(user, item, result) if actor? unless result.damage_fake
  594. execute_damage(user, result) unless result.damage_fake
  595. aether_battery_effect if self == ingrid && battle_skill_learn?(555) && item.damage.element_id == 7
  596. apply_poison_coating(user, item) if user.actor? && user.battle_skill_learn?(925) #poison coating
  597. apply_deep_cuts(user, item) if user.actor? && user.battle_skill_learn?(905) # bleed/ deep cuts
  598. #p [user == soha, user.actor? ? user.battle_skill_learn?(750) : nil, item.element_id == 6 ]
  599. apply_forced_insight(user, item) if user == soha && user.battle_skill_learn?(750) && item.damage.element_id == 6 # psychic prowess
  600. end
  601. item.effects.each {|effect| item_effect_apply(user, item, effect) } unless result.damage_fake
  602. add_guaranteed_states(user, item) unless result.damage_fake
  603. execute_ctb_damage(user, item) unless result.damage_fake
  604. apply_ctb_gain(item) unless result.damage_fake
  605. apply_stagger_damage(user, item) unless result.damage_fake
  606. do_interrupt if item.interrupt unless result.damage_fake
  607. apply_meditation_effect(result) if item && (1080..1084).include?(item.id)
  608. apply_stack_consume(user, item) unless result.damage_fake
  609. check_autostealth unless result.damage_fake
  610. item_user_effect(user, item) unless result.damage_fake
  611. user_hit_tp_gain(user, item, result) unless result.damage_fake
  612. giovany_hit_check(user, item) if self.enemy? unless result.damage_fake
  613. kormag_checks(user, item, aspect_link) unless result.damage_fake
  614. soha_grab_release_check(user, item) if self.enemy? unless result.damage_fake
  615. death_release_check(user, item) if self.actor? && grabby unless result.damage_fake
  616. user.giovany_user_check(user, item) if user.enemy? unless result.damage_fake
  617. #p result.hp_damage
  618. else
  619. user_miss_tp_gain(user, item)
  620. end
  621. user.tp_gain_buffer[:uses] += 1
  622. end
  623.  
  624. def add_guaranteed_states(user, item)
  625. if item.guaranteed_state > 0
  626. opts = {}
  627. opts[:user] = user
  628. add_state(item.guaranteed_state, opts)
  629. end
  630. end
  631.  
  632. def check_backdash(user, item)
  633. blocked = friends_unit.at_position(position + 5)
  634. if position < 10 && !blocked
  635. self.backdash = true
  636. #self.position += 5
  637. @result.evaded = true
  638. remove_state(440)
  639. else
  640. remove_state(440)
  641. end
  642. end
  643.  
  644. def do_interrupt
  645. if ctb_count >= 0
  646. self.ctb_count = -100
  647. action.clear
  648. self.popup("Interrupt!", WHITE)
  649. end
  650. end
  651.  
  652. def item_test(user, item)
  653. return false if dead? && !item.allow_dead?
  654. return true if user.enemy? && user.call_for_help_test(item)
  655. return true if $game_party.in_battle
  656. return true if item.for_opponent?
  657. return true if item.damage.recover? && item.damage.to_hp? && hp < mhp
  658. return true if item.damage.recover? && item.damage.to_mp? && mp < mmp
  659. return true if item_has_any_valid_effects?(user, item)
  660. return false
  661. end
  662.  
  663. def item_test_simple(user, item)
  664. return true if user.enemy? && user.call_for_help_test(item)
  665. return true if $game_party.in_battle
  666. return true if item.for_opponent?
  667. return true if item.damage.recover? && item.damage.to_hp? && hp < mhp
  668. return true if item.damage.recover? && item.damage.to_mp? && mp < mmp
  669. return true if item_has_any_valid_effects?(user, item)
  670. return false
  671. end
  672.  
  673. def apply_stack_consume(user, item)
  674. return false unless item.consume_stacks
  675. state_id, rate = item.consume_stacks
  676. if state_id == 200 && user.is_a?(Game_Actor) && fire_mastery #opts[:user].battle_skill_learn?(350)
  677. state_id += 1
  678. elsif state_id == 205 && user.is_a?(Game_Actor) && ice_mastery #opts[:user].battle_skill_learn?(360)
  679. state_id += 1
  680. elsif state_id == 210 && user.is_a?(Game_Actor) && lightning_mastery # opts[:user].battle_skill_learn?(355)
  681. state_id += 1
  682. end
  683. remove_state(state_id) if state?(state_id)
  684. end
  685.  
  686. def apply_ctb_gain(item)
  687. self.ctb_count += item.ctb_gain
  688. end
  689.  
  690. def apply_poison_coating(user, item)
  691. return 0 unless item.is_a?(RPG::Skill)
  692. chance = 0.5
  693. chance = 0 unless opposite?(user)
  694. state_id = 190
  695. chance *= state_effect_rate(user, item, state_id) if opposite?(user) # poison
  696. opts = {}
  697. opts[:item] = item
  698. try_add_state(state_id, user, chance, opts)
  699. end
  700.  
  701. def apply_deep_cuts(user, item)
  702. return 0 unless item.is_a?(RPG::Skill)
  703. return 0 unless result.critical
  704. return 0 unless opposite?(user)
  705. chance = 2.0
  706. state_id = 195 # bleed
  707. chance *= state_effect_rate(user, item, state_id) if opposite?(user) # poison
  708. opts = {}
  709. opts[:item] = item
  710. try_add_state(state_id, user, chance, opts)
  711. end
  712.  
  713. def apply_forced_insight(user, item)
  714. #p "reached here"
  715. return 0 unless item.is_a?(RPG::Skill)
  716. return 0 unless opposite?(user)
  717. #p "but not here"
  718. chance = 1.0
  719. state_id = 405 # insight
  720. chance *= state_effect_rate(user, item, state_id) if opposite?(user) # poison
  721. opts = {}
  722. opts[:item] = item
  723. try_add_state(state_id, user, chance, opts)
  724. end
  725.  
  726. def apply_meditation_effect(result)
  727. #p debuff_states
  728. state = debuff_states.sample
  729. #p state
  730. return if state.nil?
  731. if state.stacks > 1
  732. state.stacks -= 1
  733. result.removed_states.push(state.id)
  734. result.used = true
  735. else
  736. remove_state(state.id)
  737. result.used = true
  738. end
  739. end
  740.  
  741. def execute_ctb_damage(user, item)
  742. if item.ctb_damage > 0 || item.ctb_gain > 0
  743. value = item.ctb_damage - item.ctb_gain
  744. apply_ctb_damage(item.ctb_damage * self.ctdr)
  745. end
  746. end
  747.  
  748. def apply_ctb_damage(value)
  749. self.ctb_count -= value if action && !action.charging
  750. end
  751.  
  752. def check_autostealth
  753. dmg_check = results.inject(0) { |m, o| m += o.hp_damage }
  754. if self == eskandar && alive? && battle_skill_learn?(930) # better part of valor
  755. add_state(425) if dmg_check > mhp / 3
  756. end
  757. end
  758.  
  759. def check_critical(user, item, result = nil)
  760. result.critical = (rand < item_cri(user, item))
  761. end
  762.  
  763. def aether_battery_effect
  764. # aether battery
  765. self.tp += 5
  766. self.ctb_count += 250 unless dead? || action_charging?
  767. end
  768.  
  769. def user_miss_tp_gain(user, item)
  770. user.tp_gain_buffer[:misses] += 1
  771. end
  772.  
  773. def user_hit_tp_gain(user, item, result)
  774. user.tp_gain_buffer[:kills] += result.added_states.include?(1) ? 1 : 0
  775. user.tp_gain_buffer[:kills] += 1 if $game_party.alive_members.include?(ingrid) && ingrid.skill_learn?($data_skills[530]) && dead? && enemy? && enemy.tagged_with?('automaton') # scavenge
  776. return if item.no_tp_gain
  777. user.tp_gain_buffer[:criticals] += 1 if result.critical
  778. # user.tp_gain_buffer[:hits] += 1 unless item.damage.none?
  779. # user.tp_gain_buffer[:hits] += item.damage.extra_damages.size - 1
  780. user.tp_gain_buffer[:hits] += 1 if result.hit? # all_hits.size
  781. # user.tp_gain_buffer[:hits] -= 1 if @result.critical # critical counts for all hits
  782. user.tp_gain_buffer[:states] += result.added_states.size
  783. if result.hp_damage >= 0 && !item.damage.recover?
  784. self.tp_gain_buffer[:damage] += 1 # charge tp for taking a hit
  785. self.tp_gain_buffer[:damage] += 2 if self == lucian && battle_skill_learn?(320) # battle hardened
  786. self.tp_gain_buffer[:damage] += 2 if item.magical? && actor? && $game_party.alive_members.include?(kesh) && kesh.battle_skill_learn?(1150)
  787. end
  788. self.tp_gain_buffer[:used] = true
  789. user.tp_gain_buffer[:used] = true
  790. end
  791.  
  792. def tp_gain_buffer
  793. @tp_gain_buffer ||= Hash.new(0)
  794. end
  795.  
  796. def clear_tp_buffer
  797. uses = tp_gain_buffer[:uses]
  798. used = tp_gain_buffer[:used]
  799. taken_damage = tp_gain_buffer[:damage]
  800. return unless used == true
  801. misses = tp_gain_buffer[:misses]
  802. hits = tp_gain_buffer[:hits]
  803. states = tp_gain_buffer[:states]
  804. kills = tp_gain_buffer[:kills]
  805. criticals = tp_gain_buffer[:criticals]
  806.  
  807. tp_gained = 0 #if hits == 0
  808. tp_gained = 3 + tp_hit_bonus if hits == 1
  809. tp_gained = 5 + tp_hit_bonus * 2 if hits == 2
  810. tp_gained += 5 + tp_hit_bonus + (1 + tp_hit_bonus) * hits ** 0.66 if hits > 2
  811. #tp_gained += hits - 2 if hits > 0 * tp_extra_hit_rate
  812. #tp_gained += states ** 0.66 * 2 * tp_state_rate
  813. # remove state
  814. tp_gained += misses * tp_miss_rate
  815. tp_gained += kills ** 1 * 3 * tp_kill_rate
  816. tp_gained += criticals ** 0.66 * tp_crit_rate
  817. #tp_gained = 3 if tp_gained < 3 && self == kesh && skill_learn?($data_skills[1115]) # Chi Channeling
  818. tp_gained += 3 if self == kesh && skill_learn?($data_skills[1115]) if uses > 0 # Chi Channeling
  819. tp_gained *= tcr
  820. tp_gained += taken_damage
  821. p "#{name} hit #{hits} time(s)" if ECHO_HITS && $TEST
  822. p "#{name} charged #{tp_gained.ceil} TP" if ECHO_TP_CHARGE && $TEST
  823. self.tp += tp_gained.ceil
  824. tp_gain_buffer.clear
  825. end
  826.  
  827. def tp_state_rate
  828. 1
  829. end
  830.  
  831. def tp_miss_rate
  832. 0
  833. end
  834.  
  835. def tp_kill_rate
  836. return 1 unless actor?
  837. skill_learn?($data_skills[935]) ? 2 : 1
  838. end
  839.  
  840. def tp_hit_bonus
  841. 0
  842. end
  843.  
  844. def tp_crit_rate
  845. return 3 unless actor?
  846. return 3 unless $game_party.battle_members.include?(lucian) && lucian.skill_learn?($data_skills[335])
  847. return 5
  848. end
  849.  
  850. def item_user_effect(user, item)
  851. user.tp += (item.tp_gain * user.tcr).to_i
  852. if item.self_buff_id > 0
  853. opts = {}
  854. opts[:user] = user
  855. opts[:item] = item
  856. user.add_state(item.self_buff_id, opts)
  857. user.result.used = true
  858. user.result.success = true
  859. user.result.no_damage = true
  860. end
  861. if item.success_buff_id > 0 && self.result.added_states.size > 0
  862. result.added_states.size.times { user.add_state(item.success_buff_id) }
  863. user.result.used = true
  864. user.result.success = true
  865. user.result.no_damage = true
  866. end
  867. end
  868.  
  869. def item_cri_old_version(user, item)
  870. return 0 unless item.damage.critical
  871. #return 50
  872. dex_mod = 1 / (1 - (user.luk / (user.luk + luk + 1000.0)))
  873. eagle_eye_mod = 1
  874. if user == eskandar && user.battle_skill_learn?(920) # eagle eye
  875. hit_mod = calced_hit(user, item)
  876. eagle_eye_mod = hit_mod + 0.1 if hit_mod > 0.9
  877. end
  878. thunder_mastery_bonus = 0.0
  879. if user.actor? && party.alive_members.include?(lucian)
  880. thunder_mastery_bonus = 0.2 if item.damage.element_id == 5 || (item.damage.element_id < 2 && state?(230)) # enchant lightning
  881. thunder_mastery_bonus = 0.2 if item.proc_damages.any? { |d| d[0].damage.element_id == 5 }
  882. end
  883. base = user.cri + self.hunters_mark + thunder_mastery_bonus
  884. base += 0.25 if user == soha && item.swordplay && soha.battle_skill_learn?(740) # swordplay mastery
  885. crit = base * dex_mod * eagle_eye_mod + item.cri
  886. p ["Critical Values #{user.cri} base, #{item.cri} item, #{self.hunters_mark} mark bonus, #{eagle_eye_mod} eagle eye mod #{thunder_mastery_bonus} thunder mastery bonus #{crit} TOTAL" ] if ECHO_CRIT && $TEST
  887. crit * (1 - cev)
  888. end
  889.  
  890. def item_cri(user, item)
  891. return 0 unless item.damage.critical
  892. #return 50
  893. dex_diff = user.luk - self.luk
  894. if dex_diff >= 0
  895. cri_plus = dex_diff / (dex_diff + 200.0) / 2
  896. else
  897. cri_plus = dex_diff / (-dex_diff + 200.0) / 2
  898. end
  899. eagle_eye_mod = 0.0
  900. if user == eskandar && user.battle_skill_learn?(920) # eagle eye
  901. hit_mod = calced_hit(user, item) - 0.9
  902. eagle_eye_mod = hit_mod / (hit_mod + 1.0) / 3 if hit_mod > 0
  903. end
  904. thunder_mastery_bonus = 0.0
  905. if user.actor? && party.alive_members.include?(lucian)
  906. thunder_mastery_bonus = 0.2 if item.damage.element_id == 5 || (item.damage.element_id < 2 && state?(230)) # enchant lightning
  907. thunder_mastery_bonus = 0.2 if item.proc_damages.any? { |d| d[0].damage.element_id == 5 }
  908. end
  909. swordplay = 0
  910. swordplay += 0.25 if user == soha && item.swordplay && soha.battle_skill_learn?(740) # swordplay mastery
  911. base = item.cri + user.cri + self.hunters_mark + thunder_mastery_bonus + cri_plus + swordplay - cev
  912. #crit = base # * dex_mod * eagle_eye_mod + item.cri
  913. #p ["Critical Values #{user.cri} base, #{item.cri} item, #{self.hunters_mark} mark bonus, #{eagle_eye_mod} eagle eye mod #{thunder_mastery_bonus} thunder mastery bonus #{crit} TOTAL" ] if $TEST
  914. crit = [base, thunder_mastery_bonus, eagle_eye_mod, swordplay, item.cri, user.cri - cev].max
  915. crit = 0 if cev == 1.0
  916. aStr = "\n\n\nCritical values NEW formula
  917. User: #{user.name}
  918. Target #{name}
  919. #{item.cri.round(3)}(skill cri) + #{user.cri.round(3)}(user cri) + #{swordplay.round(3)}(swordplay bonus)
  920. + #{hunters_mark.round(3)}(hunters mark) + #{thunder_mastery_bonus.round(3)}(thundermastery)
  921. - #{cev.round(3)}(target critical evasion) + #{cri_plus.round(3)}(dex component)
  922. Calculated CRI value: #{base}
  923. Actual value (minimum value from skill/bonuses/immunity) #{crit}\n\n\n"
  924. print aStr if $TEST && ECHO_CRI
  925. crit #* (1 - cev)
  926. end
  927.  
  928.  
  929. def execute_damage(user, result = @result)
  930. on_damage(result.hp_damage) if result.hp_damage > 0
  931. tapped = state?(375) # blood tap
  932. result.hp_damage = result.hp_damage.to_i
  933. dmg = result.hp_damage
  934. if self == kesh && self.battle_skill_learn?(1140) # iron will
  935. dmg = self.hp - 1 if dmg >= hp && rand < hp_rate
  936. end
  937. #p [dmg, self.name]
  938. self.hp -= dmg
  939. #self.tp += 1 if dmg > 0 # charge tp from damage
  940. #self.tp += 4 if dmg > 0 && self == lucian && battle_skill_learn?(320)
  941. #self.mp -= @result.mp_damage
  942. check_overdrain(user, result.hp_drain)
  943. user.draining = true if user.actor?
  944. user.hp += result.hp_drain
  945. user.draining = false if user.actor?
  946. #user.mp += @result.mp_drain
  947. apply_soul_steal(user, tapped, result) if dead?
  948. end
  949.  
  950. def apply_soul_steal(user, tapped, result = @result)
  951. return unless $game_party.alive_members.include?(soha) && soha.battle_skill_learn?(730)
  952. if (result.hp_drain > 0 && user == soha) || tapped
  953. #soha.result.added_states.push(420)
  954. soha.result.used = true
  955. soha.add_state(420) # empowered
  956. end
  957. end
  958.  
  959. def check_overdrain(user, drain)
  960. beacon = user.actor? && user.battle_skill_learn?(710) # Life Beacon
  961. #p "draining #{drain}" if beacon
  962. if beacon && drain + user.hp > user.mhp + user.overhp_max
  963. overdrain = drain + user.hp - (user.mhp + user.overhp_max)
  964. overdrain = user.mhp * 2 if overdrain > user.mhp * 2
  965. unit = user.friends_unit.alive_members.reject { |m| m == user }
  966. unit.each { |m|
  967. amount = overdrain / unit.size
  968. #p "overdrain #{amount} for #{m.name}"
  969. m.hp += amount
  970. m.result.hp_damage -= amount
  971. m.result.used_damage = true
  972. }
  973. result.hp_drain -= 0 #overdrain
  974. end
  975. end
  976.  
  977. def check_damage_share(user, item, result)
  978. link = find_state?(415) # blood link
  979. disperse = find_state?(520) # disperse damage
  980. if disperse
  981. damage = result.hp_damage
  982. damage = damage * disperse.sv / 100
  983. shared_damage = 0
  984. share_members = adjacent_alive_members
  985. share_members.each { |m|
  986. mresult = Game_ActionResult.new(m)
  987. m.results.push(mresult)
  988. mresult.hp_damage += damage
  989. shared_damage += damage
  990. mresult.used_damage = true
  991. m.execute_damage(user, mresult)
  992. }
  993. result.hp_damage -= shared_damage
  994. elsif link
  995. damage = result.hp_damage
  996. damage = damage * link.sv / 100
  997. #@result.all_hits.each { |d| d[0] = d[0] * link.sv / 100}
  998. share_members = $game_party.battle_members.select { |m| m.state?(415) }
  999. shared_damage = 0
  1000. share_members.each { |m|
  1001. next if m == self
  1002. mresult = Game_ActionResult.new(m)
  1003. m.results.push(mresult)
  1004. #p [m.name, damage]
  1005. mresult.hp_damage = damage / share_members.size
  1006. shared_damage += damage / share_members.size
  1007. mresult.used_damage = true
  1008. m.execute_damage(user, mresult) #unless m == self
  1009. }
  1010. #lhit = @result.all_hits.last
  1011. #lhit[0] = damage - shared_damage if lhit && lhit[0] == @result.hp_damage
  1012. result.hp_damage = damage - shared_damage
  1013. end
  1014. end
  1015.  
  1016. def adjacent_alive_members
  1017. friends_unit.alive_members.select { |m|
  1018. row_diff = (m.row - self.row).abs
  1019. col_diff = (m.column - self.column).abs
  1020. row_diff <= 1 && col_diff <= 1 && row_diff + col_diff <= 1
  1021. }
  1022. end
  1023.  
  1024. def intercept_damage_rate
  1025. intercept = find_state?(271)
  1026. if intercept && self == lucian
  1027. equipped_skills.max_by { |s| s.intercept_rate }.intercept_rate
  1028. else
  1029. 1.0
  1030. end
  1031. end
  1032.  
  1033.  
  1034. end
  1035.  
  1036. class Game_ActionResult
  1037. attr_accessor :stagger_damage
  1038. attr_accessor :states_added, :hits
  1039. attr_accessor :all_hits
  1040. attr_accessor :no_damage
  1041. attr_accessor :used_damage
  1042. attr_accessor :damage_fake
  1043. attr_accessor :user
  1044. attr_accessor :item
  1045. attr_accessor :dot # damage over time
  1046.  
  1047. def make_damage_old(value, item, user, target, all_hits = nil)
  1048. @critical = false if value == 0
  1049. @hp_damage = value if item.damage.to_hp?
  1050. all_hits.each { |hit|
  1051. value = hit[0]
  1052. dmg = hit[1]
  1053. @hp_drain += value if dmg.drain?
  1054. }
  1055. @all_hits = all_hits.clone
  1056. @hp_drain = @hp_damage if item.damage.drain?
  1057. #@mp_drain = @mp_damage if item.damage.drain?
  1058. @hp_drain *= user.drain_ratio # drain ratio of user
  1059. @hp_drain *= item.drain_ratio # drain ratio of skill
  1060. @hp_drain += @hp_damage * 15 / 100 if item.physical? && user.special_flag(5)
  1061. @hp_drain = [@battler.hp, @hp_drain].min.to_i # cap at target's HP
  1062. @success = true if item.damage.to_hp? # || @mp_damage != 0
  1063. #p [@hp_damage, @hp_drain]
  1064. end
  1065.  
  1066. def make_damage(value, item, user, target, all_hits = nil)
  1067. @critical = false if value == 0
  1068. @hp_damage = value if item.damage.to_hp?
  1069. @all_hits = all_hits.clone if all_hits
  1070. @hp_drain = @hp_damage if item.damage.drain?
  1071. @hp_drain *= user.drain_ratio # drain ratio of user
  1072. @hp_drain *= item.drain_ratio # drain ratio of skill
  1073. @hp_drain += @hp_damage * 15 / 100 if item.physical? && user.special_flag(5)
  1074. @hp_drain = [@battler.hp, @hp_drain].min.to_i # cap at target's HP
  1075. #p @hp_drain
  1076. @success = true if item.damage.to_hp?
  1077. end
  1078.  
  1079. def clear_hit_flags
  1080. @used = false
  1081. @missed = false
  1082. @evaded = false
  1083. @critical = false
  1084. @success = false
  1085. @no_damage = false
  1086. @used_damage = false
  1087. @damage_fake = false
  1088. @user = nil
  1089. @target = nil
  1090. @dot = false
  1091. end
  1092.  
  1093. def clear_damage_values
  1094. @all_hits = []
  1095. @hp_damage = 0
  1096. @mp_damage = 0
  1097. @tp_damage = 0
  1098. @hp_drain = 0
  1099. @mp_drain = 0
  1100. @hits = 0
  1101. @states_added = 0
  1102. @stagger_damage = 0
  1103. end
  1104.  
  1105. def added_state_stacks
  1106. h = Hash.new(0)
  1107. @added_states.each {|id| h[$data_states[id]] += 1 }
  1108. h
  1109. end
  1110.  
  1111. alias clear_b4_multiresult clear
  1112. def clear
  1113. clear_b4_multiresult
  1114. #@battler.results.clear
  1115. #@battler.results.push(@battler.result_orig)
  1116. end
  1117.  
  1118.  
  1119. end
  1120.  
  1121. class Game_ActionResultMerged < Game_ActionResult
  1122. NUMBERS_METHODS = ['hp_damage']
  1123.  
  1124. def hp_damage
  1125. @battler.results.inject(0) { |m, o| m += o.hp_damage }
  1126. end
  1127.  
  1128. def evaded
  1129. @battler.results.all? { |r| r.evaded }
  1130. end
  1131.  
  1132. def clear
  1133. super
  1134. #@battler.result_orig.clear
  1135. #@battler.results.clear
  1136. end
  1137.  
  1138. end
  1139.  
  1140.  
  1141.  
  1142. class RPG::BaseItem
  1143.  
  1144. def normal_multihit?
  1145. false
  1146. end
  1147.  
  1148. def intercept_rate
  1149. @intercept_rate ||= note =~ /<intercept (\d+)>/i ? $1.to_i / 100.0 : 1.0
  1150. end
  1151.  
  1152. def self_buff_id
  1153. @self_buff_id ||= note =~ /<self buff (\d+)>/i ? $1.to_i : 0
  1154. end
  1155.  
  1156. def success_buff_id
  1157. @success_buff_id ||= note =~ /<success self buff (\d+)>/i ? $1.to_i : 0
  1158. end
  1159.  
  1160. def no_tp_gain
  1161. tagged_with?('no tp gain')
  1162. end
  1163.  
  1164. def charge_time_text
  1165. return "Instant" if ready_cost <= 10
  1166. ready_cost
  1167. end
  1168.  
  1169. def proc_damages_note
  1170. @proc_damages_note ||= note_parse_proc_damages
  1171. end
  1172.  
  1173. def proc_damages
  1174. proc_damages_note
  1175. end
  1176.  
  1177. def note_parse_proc_damages
  1178. ary = []
  1179. note.each_line { |line|
  1180. if line =~ /<proc damage (\d+) (\d+)>/
  1181. skill_id = $1.to_i
  1182. rate = $2.to_i / 100.0
  1183. skill = $data_skills[skill_id]
  1184. ary.push([skill, rate])
  1185. end
  1186.  
  1187. }
  1188. ary
  1189. end
  1190.  
  1191. def chi_power
  1192. @chi_power ||= note =~ /<chi power (\d+)>/i ? $1.to_i : 0
  1193. end
  1194.  
  1195. def consume_stacks
  1196. @consume_stacks ||= note =~ /<consume (\d+) (\d+)/i ? [$1.to_i, $2.to_i] : nil
  1197. end
  1198.  
  1199. def guaranteed_state
  1200. @guaranteed_state ||= note =~ /<guaranteed state (\d+)>/i ? $1.to_i : 0
  1201. end
  1202.  
  1203. def damage_color
  1204. @damage_color ||= note =~ /<damage color (.+)>/i ? Color.html($1) : :none
  1205. end
  1206.  
  1207. def dot_color
  1208. @dot_color ||= note =~ /<dot color (.+)>/i ? Color.html($1) : :none
  1209. end
  1210.  
  1211. def dot_sound
  1212. @dot_sound ||= note =~ /<dot sound (.+)>/i ? $1.to_s : :none
  1213. end
  1214.  
  1215. def weapon_power_mod
  1216. @weapon_power_mod ||= note =~ /<weapon power mod (\d+)>/i ? $1.to_i : 100
  1217. end
  1218.  
  1219. def skill_power_mod
  1220. @skill_power_mod ||= note =~ /<skill power mod (\d+)>/i ? $1.to_i : 100
  1221. end
  1222.  
  1223. def stealth_mod
  1224. @stealth_mod ||= note =~ /<stealth mod (\d+)>/i ? $1.to_i / 100.0 : 1.0
  1225. end
  1226.  
  1227. def spell_power_mod
  1228. @spell_power_mod ||= note =~ /<spell power mod (\d+)>/i ? $1.to_i : 100
  1229. end
  1230.  
  1231. def str_scale_mod
  1232. @str_scale_mod ||= note =~ /<str scale mod (\d+)>/i ? $1.to_i : 100
  1233. end
  1234.  
  1235. def int_scale_mod
  1236. @int_scale_mod ||= note =~ /<int scale mod (\d+)>/i ? $1.to_i : 100
  1237. end
  1238.  
  1239. def dex_mod
  1240. @dex_mod ||= note =~ /<dex scale mod (\d+)>/i ? $1.to_i : 100
  1241. end
  1242.  
  1243. def final_reckoning
  1244. @final_reckoning ||= note =~ /<final reckoning (\d+)>/i ? $1.to_i : 0
  1245. end
  1246.  
  1247. def cull
  1248. @cull ||= note =~ /<cull (\d+)>/i ? $1.to_i : 0
  1249. end
  1250.  
  1251. def normal_attack?
  1252. false
  1253. end
  1254.  
  1255. def null_blood_cost
  1256. tagged_with?('null blood cost')
  1257. end
  1258.  
  1259. def feral_frenzy
  1260. @feral_frenzy ||= note =~ /<feral frenzy (\d+)%>/i ? $1.to_i / 100.0 : :none
  1261. end
  1262.  
  1263. def barrage
  1264. @barrage ||= note =~ /<barrage (\d+)>/i ? $1.to_i : 0
  1265. end
  1266.  
  1267. def drain_ratio
  1268. @drain_ratio ||= note =~ /<drain ratio (\d+)%?>/i ? $1.to_i / 100.0 : 1.0
  1269. end
  1270.  
  1271. def physical_weight
  1272. @physical_weight ||= note =~ /<physical weight (\d+)>/i ? $1.to_i : 1
  1273. end
  1274.  
  1275. def magical_weight
  1276. @magical_weight ||= note =~ /<magical weight (\d+)>/i ? $1.to_i : 1
  1277. end
  1278.  
  1279. def noproc
  1280. tagged_with?('noproc')
  1281. end
  1282.  
  1283. def remove_on_ready
  1284. tagged_with?('remove on ready')
  1285. end
  1286.  
  1287. def no_damage_mod
  1288. tagged_with?('no damage mod')
  1289. end
  1290.  
  1291. def allow_dead?
  1292. !target_data.target_restrictions.include?(:alive)
  1293. end
  1294.  
  1295. def base_damage
  1296. @base_damage ||= note =~ /<base damage (\d+)>/i ? $1.to_i : 100
  1297. end
  1298.  
  1299. def offense_scale
  1300. @offense_scale ||= note =~ /<offense scale (\d+)>/i ? $1.to_i / 100.0 : 1.0
  1301. end
  1302.  
  1303. def defense_scale
  1304. @defense_scale ||= note =~ /<defense scale (\d+)>/i ? $1.to_i / 100.0: 0.5
  1305. end
  1306.  
  1307. def no_cover
  1308. tagged_with?('no cover')
  1309. end
  1310.  
  1311. def interrupt
  1312. tagged_with?('interrupt')
  1313. end
  1314.  
  1315. end
  1316.  
  1317. class RPG::Skill
  1318. def normal_attack?
  1319. @id == 1 || @id == 5
  1320. end
  1321.  
  1322. def normal_multihit?
  1323. repeats > 1 && animate_type != :coup_de_grace
  1324. end
  1325.  
  1326. end
  1327.  
  1328. class RPG::UsableItem::Damage
  1329. include DamageFormula
  1330. # a - attacker
  1331. # b - defender
  1332. # v - variables
  1333. # s - switches
  1334. # i - item (skill used)
  1335. # md - main_damage (damage field of main skill used)
  1336. # bv - base_value (damage main skill has already inflicted)
  1337. # h = hits (hits so far)
  1338. def evaluate(a, b, v, s = nil, i = nil, md = nil, bv = 0, h)
  1339. # setting up main values
  1340. @user = a
  1341. @target = b
  1342. @variables = v
  1343. @switches = s
  1344. @item = i
  1345. @main_damage = md
  1346. @base_value = bv
  1347. #@blood_mod = @item.blood_mod
  1348. @wp_mod = @item.weapon_power_mod
  1349. @sp_mod = @item.skill_power_mod
  1350. #p [@item.name, @item.note, @item.skill_power_mod, @sp_mod, "sp mod here"]
  1351. @armor_rate = (1 - @user.armor_pierce / 100.0) * (1 - @item.armor_pierce / 100.0)
  1352. # inverse of armor pierce is armor rate, the rate of which enemy armor is effective
  1353. value = formula_eval(a, b, v)
  1354. clear
  1355. value
  1356. end
  1357.  
  1358. remove_method(:eval)
  1359.  
  1360. def formula_eval(a, b, v)
  1361. begin
  1362. v = [eval(@formula, binding), 0].max * sign #rescue 0
  1363. rescue => err
  1364. p "problem with damage formula: #{err}"
  1365. return 0
  1366. end
  1367. v
  1368. end
  1369.  
  1370. def clear
  1371. @user = @target = @variables = @switches = @item = @main_damage = @base_value =
  1372. @blood_mod = @wp_mod = @armor_rate = nil
  1373. end
  1374.  
  1375. def str_mod_softcap(str_mod) # deprecated
  1376. if str_mod > STR_MOD_SOFTCAP
  1377. mod_extra = str_mod - STR_MOD_SOFTCAP
  1378. mod_base = STR_MOD_SOFTCAP
  1379. mod_extra *= STR_MOD_OVERCAP_MOD
  1380. mod_extra + mod_base
  1381. else
  1382. str_mod
  1383. end
  1384. end
  1385.  
  1386. def shotgun_distance_mod(user, target)
  1387. dist = (user.row - target.row).abs + (user.column - target.column).abs
  1388. if dist < 4
  1389. 1 + 0.25 * (4 - dist)
  1390. else
  1391. 1.0
  1392. end
  1393. end
  1394.  
  1395. #~ def attack_damage
  1396. #~ wp = @user.weapon_power * @wp_mod / 100
  1397. #~ armor = @target.armor * @armor_rate
  1398. #~ vit = @target.def
  1399. #~ str = @user.atk * @item.str_scale_mod / 100 # unused for ingrid
  1400. #~ str_mod = 1 / (1 - (str / (str + ATTACK_DAMAGE_STR_FOCUS)))
  1401. #~ str_mod = str_mod_softcap(str_mod)
  1402. #~ vit_mod = 1 - (vit / (vit + ATTACK_DAMAGE_VIT_FOCUS))
  1403. #~ #str_ratio = 0
  1404. #~ #vit_ratio = vit / vit + 100
  1405. #~ vit = 0 if @user == soha && @target.state?(405)
  1406. #~ armor = 0 if @user == soha && @target.state?(405)
  1407. #~ armor = 0 if @item && @item.damage.element_id == 7
  1408. #~ damage = wp * 4 - armor
  1409. #~ damage += str / 2
  1410. #~ damage -= vit / 4 unless @item && @item.damage.element_id == 7
  1411. #~ base = damage
  1412. #~ #p [wp, armor, damage]
  1413. #~ damage = damage * str_mod * vit_mod
  1414. #~ damage = damage * @sp_mod / 100
  1415. #~ damage *= @user.intercept_damage_rate if @user.state?(271)
  1416. #~ p ["attack damage", "#{base} base", "#{str_mod.round(2)} attacking stat mod", "#{vit_mod.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1417. #~ damage.to_i
  1418. #~ end
  1419. #~
  1420. #~ def aura_glaive
  1421. #~ wp = @user.weapon_power * @wp_mod / 100
  1422. #~ armor = @target.armor * @armor_rate
  1423. #~ vit = @target.def
  1424. #~ str = @user.mdf # * @item.str_scale_mod / 100 # unused for ingrid
  1425. #~ str_mod = 1 / (1 - (str / (str + 500.0)))
  1426. #~ #vit_mod = 1 - (vit / (vit + 500.0))
  1427. #~ #str_ratio = 0
  1428. #~ #vit_ratio = vit / vit + 100
  1429. #~ #vit = 0 if @user == soha && @target.state?(405)
  1430. #~ #armor = 0 if @user == soha && @target.state?(405)
  1431. #~ damage = wp #* 4 - armor
  1432. #~ damage += str / 10
  1433. #~ #damage -= vit / 4
  1434. #~ #p [wp, armor, damage]
  1435. #~ damage = damage * str_mod #* vit_mod
  1436. #~ damage = damage * @sp_mod / 100
  1437. #~ #damage *= @user.intercept_damage_rate if @user.state?(271)
  1438. #~ damage.to_i
  1439. #~ end
  1440.  
  1441. #~
  1442. #~ def gun_damage
  1443. #~ wp = @user.weapon_power * @wp_mod / 100
  1444. #~ wp *= shotgun_distance_mod(@user, @target) if @user.actor? && @user.battle_skill_learn?(520)
  1445. #~ armor = @target.armor * @armor_rate
  1446. #~ vit = @target.def
  1447. #~ str = @user.weapon_power # unused for ingrid
  1448. #~ str_mod = 1 / (1 - (str / (str + 500.0)))
  1449. #~ level = @user.level
  1450. #~ #str_mod = 1 / (1 - (level / (level + 30.0)))
  1451. #~ #(level + 30) / 30.0 # for Ingrid
  1452. #~ vit_mod = 1 - (vit / (vit + 500.0))
  1453. #~ #str_ratio = 0
  1454. #~ #vit_ratio = vit / vit + 100
  1455. #~ armor = 0 if @item && @item.damage.element_id == 7
  1456. #~ base = damage = wp * 4 - armor
  1457. #~ damage = damage * str_mod * vit_mod
  1458. #~ damage = damage * @sp_mod / 100.0
  1459. #~ p ["gun", base, damage, str_mod, vit_mod, @sp_mod] if ECHO_DAMAGE
  1460. #~ damage.to_i
  1461. #~ end
  1462. #~
  1463. #~ def xbow_damage
  1464. #~ wp = @user.weapon_power * @wp_mod / 100
  1465. #~ armor = @target.armor * @armor_rate
  1466. #~ vit = @target.def
  1467. #~ str = @user.luk # dex replaced for xbow
  1468. #~ #level = @user.level
  1469. #~ str_mod = 1 / (1 - (str / (str + 400.0)))
  1470. #~ str_mod = str_mod_softcap(str_mod)
  1471. #~ #(level + 30) / 30.0 # for Ingrid
  1472. #~ vit_mod = 1 - (vit / (vit + 500.0))
  1473. #~ #str_ratio = 0
  1474. #~ #vit_ratio = vit / vit + 100
  1475. #~ armor = 0 if @item && @item.damage.element_id == 7
  1476. #~ damage = wp * 4 - armor * 2
  1477. #~ damage = damage * str_mod * vit_mod
  1478. #~ if @user == eskandar && @user.battle_skill_learn?(920) # Eagle Eye
  1479. #~ hit_rate = @target.calced_hit(@user, @item)
  1480. #~ p "#{hit_rate} eagle eye damage rate (if higher than 1.0)"
  1481. #~ damage *= hit_rate if hit_rate > 1.0
  1482. #~ end
  1483. #~ p "xbow skill #{damage} damage, #{str_mod} str mod #{vit_mod} vit mod" if ECHO_DAMAGE
  1484. #~ damage = damage * @sp_mod / 100.0
  1485. #~ damage.to_i
  1486. #~ end
  1487. #~
  1488. #~
  1489. #~ def spell_damage
  1490. #~ int = @user.mat
  1491. #~ wis = @target.mdf
  1492. #~ wis = 0 if @user == soha && @target.state?(405)
  1493. #~ level = @user.level
  1494. #~ sub_portion = @item.defense_scale * wis
  1495. #~ sub_portion = 0 if @item && @item.damage.element_id == 7
  1496. #~ base = @item.base_damage + int * @item.offense_scale - sub_portion
  1497. #~ base += @user.mdf if @user.state?(525) # Aura Guide
  1498. #~ base = @item.base_damage / 2 if base < @item.base_damage / 2
  1499. #~ int_mod1 = 1 / (1 - (int / (int + 500.0)))
  1500. #~ wis_mod1 = 1 - (wis / (wis + 500.0))
  1501. #~ damage = base * int_mod1 * wis_mod1 # * wis_mod2
  1502. #~ damage += damage * @item.blood_power / 100
  1503. #~ damage = damage * @sp_mod / 100
  1504. #~ damage *= 2 if @user.actor? && @user.battle_skill_learn?(370) # spellblade
  1505. #~ p ["spell damage", "#{base} base", "#{int_mod1.round(2)} attacking stat mod", "#{wis_mod1.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1506. #~ damage.to_i
  1507. #~ end
  1508. #~
  1509. #~ def blood_damage
  1510. #~ int = @user.atk
  1511. #~ wis = @target.def
  1512. #~ wis = 0 if @user == soha && @target.state?(405)
  1513. #~ base = @item.base_damage + int * @item.offense_scale - @item.defense_scale * wis
  1514. #~ base = @item.base_damage / 2 if base < @item.base_damage / 2
  1515. #~ int_mod1 = 1 / (1 - (int / (int + 500.0)))
  1516. #~ wis_mod1 = 1 - (wis / (wis + 500.0))
  1517. #~ damage = base * int_mod1 * wis_mod1
  1518. #~ damage += damage * @item.blood_power / 100
  1519. #~ damage = damage * @sp_mod / 100
  1520. #~ p ["Blood damage", "#{base} base", "#{int_mod1.round(2)} attacking stat mod", "#{wis_mod1.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1521. #~ damage.to_i
  1522. #~ end
  1523. #~
  1524. #~ def heal_normal
  1525. #~ wis = @user.mdf
  1526. #~ level = @user.level
  1527. #~ base = @item.base_damage + wis * @item.offense_scale
  1528. #~ #base += @user.mdf if @user.state?(525) # Aura Guide
  1529. #~ #base = @item.base_damage / 2 if base < @item.base_damage / 2
  1530. #~ wis_mod1 = 1 / (1 - (wis / (wis + HEAL_NORMAL_WIS_FOCUS)))
  1531. #~ damage = base * wis_mod1
  1532. #~ damage += damage * @item.blood_power / 100
  1533. #~ damage = damage * @sp_mod / 100
  1534. #~ p ["heal normal", "#{base} base", "#{wis_mod1.round(2)} stat mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total heal"] if ECHO_DAMAGE
  1535. #~ damage.to_i
  1536. #~ end
  1537.  
  1538. #~
  1539. #~ def blood_heal_direct
  1540. #~ base = @user.mhp * @item.blood_power / 200.0
  1541. #~ wis = @user.mat
  1542. #~ wis_mod = 1 / (1 - (wis / (wis + 500.0)))
  1543. #~ damage = base * wis_mod
  1544. #~ damage = damage * @sp_mod / 100
  1545. #~ p ["blood heal", base, wis_mod, damage] if ECHO_DAMAGE
  1546. #~ damage.to_i
  1547. #~ end
  1548.  
  1549. def mixed_damage
  1550. (attack_damage * @item.physical_weight + spell_damage * @item.magical_weight) / (@item.magical_weight + @item.physical_weight)
  1551. end
  1552.  
  1553. def dot_damage_magical
  1554. int = @user.mat
  1555. wis = @target.mdf
  1556. wis = 0 if @user == soha && @target.state?(405)
  1557. base = @item.base_damage + int * @item.offense_scale - @item.defense_scale * wis
  1558. base = @item.base_damage / 2 if base < @item.base_damage / 2
  1559. int_mod1 = 1 / (1 - (int / (int + 500.0)))
  1560. wis_mod1 = 1 - (wis / (wis + 500.0))
  1561. damage = base * int_mod1 * wis_mod1
  1562. damage += damage * @item.blood_power / 100
  1563. damage = damage * @sp_mod / 100
  1564. p ["Magical DoT", "#{base} base", "#{int_mod1.round(2)} attacking stat mod", "#{wis_mod1.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1565. damage.to_i
  1566. end
  1567.  
  1568. def dot_damage_physical
  1569. int = @user.mat
  1570. wis = @target.def
  1571. base = @item.base_damage + int * @item.offense_scale - @item.defense_scale * wis
  1572. base = @item.base_damage / 2 if base < @item.base_damage / 2
  1573. int_mod1 = 1 / (1 - (int / (int + 500.0)))
  1574. wis_mod1 = 1 - (wis / (wis + 500.0))
  1575. damage = base * int_mod1 * wis_mod1
  1576. damage += damage * @item.blood_power / 100
  1577. damage = damage * @sp_mod / 100
  1578. p ["Physical DoT", "#{base} base", "#{int_mod1.round(2)} attacking stat mod", "#{wis_mod1.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1579. damage.to_i
  1580. end
  1581.  
  1582. def dot_damage_blood_tap
  1583. int = @user.atk
  1584. wis = @target.def
  1585. wis = 0 if @user == soha && @target.state?(405)
  1586. base = @item.base_damage + int * @item.offense_scale - @item.defense_scale * wis
  1587. base = @item.base_damage / 2 if base < @item.base_damage / 2
  1588. int_mod1 = 1 / (1 - (int / (int + 500.0)))
  1589. wis_mod1 = 1 - (wis / (wis + 500.0))
  1590. damage = base * int_mod1 * wis_mod1
  1591. damage += damage * @item.blood_power / 100
  1592. damage = damage * @sp_mod / 100
  1593. p ["Blood tap DoT", "#{base} base", "#{int_mod1.round(2)} attacking stat mod", "#{wis_mod1.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1594. damage.to_i
  1595. end
  1596.  
  1597.  
  1598. def final_reckoning_damage
  1599. return @target.hp * @item.final_reckoning / 100 unless @target.opposite?(@user)
  1600. rc = @user.friends_unit.alive_members.inject(0) { |m, o| m += o.hp * @item.final_reckoning / 100 }
  1601. int = @user.mat
  1602. base = Math.sqrt(int) / (1 - (int / (int + 10000.0)))
  1603. fr_mod = ((rc + 1000) ** 0.33) * Math.log(rc + 5) - 50
  1604. int = @user.mat
  1605. int_mod = 1 / (1 - (int / (int + 2000.0)))
  1606. # very weak int scaling
  1607. damage = base * int_mod * fr_mod - 1000
  1608. damage = rc / 3 if damage < rc / 3
  1609. damage = damage * @sp_mod / 100
  1610. damage.to_i
  1611. end
  1612.  
  1613. def derivative_damage
  1614. base = base_value
  1615. damage = base * @sp_mod / 100
  1616. damage.to_i
  1617. end
  1618.  
  1619. def calc_stat_damage_mod(name, astat, dstat = 0) #, abase = nil, dbase = nil)
  1620. offense_focus = OFFENSE_STAT_FOCUS[name]
  1621. defense_focus = DEFENSE_STAT_FOCUS[name]
  1622. offense_cap = OFFENSE_MOD_SOFTCAP[name]
  1623. defense_cap = DEFENSE_MOD_SOFTCAP[name]
  1624. offense_cap_ratio = OFFENSE_MOD_OVERCAP_RATIO[name]
  1625. defense_cap_ratio = DEFENSE_MOD_OVERCAP_RATIO[name]
  1626. #astat = aparam ? @user.send(aparam) : 1.0
  1627. #dstat = dparam ? @target.send(dparam) : 0
  1628. dstat = 0 if @user == soha && @target.state?(405)
  1629. #base = abase ? @user.send(abase) : @item.base_damage
  1630. #base -= dbase ? @user.send(dbase) : 0
  1631. #base += astat * @item.offense_scale - dstat * @item.defense_scale
  1632. omod = 1 / (1 - (astat / (astat + offense_focus.to_f)))
  1633. dmod = 1 - (dstat / (dstat + defense_focus.to_f))
  1634. omod2 = apply_mod_softcap(omod, offense_cap, offense_cap_ratio)
  1635. dmod2 = apply_mod_softcap(dmod, defense_cap, defense_cap_ratio)
  1636. mod = omod2 * dmod2
  1637. if ECHO_DAMAGE_LONG
  1638. print "
  1639. Damage mods applied for #{name}:
  1640. Offensive: base mod - #{omod.round(2)} / after softcap - #{omod2.round(2)}
  1641. Defensive: base mod - #{dmod.round(2)} / after softcap - #{dmod2.round(2)}
  1642. total modifier applied to skill #{mod.round(4)}
  1643. "
  1644. end
  1645. mod
  1646. end
  1647.  
  1648. def apply_mod_softcap(value, softcap, ratio)
  1649. if value > softcap
  1650. mod_extra = value - softcap
  1651. mod_base = softcap
  1652. mod_extra *= ratio
  1653. mod_extra + mod_base
  1654. else
  1655. value
  1656. end
  1657. end
  1658.  
  1659. def attack_damage
  1660. wp = @user.weapon_power * @wp_mod / 100
  1661. armor = @target.armor * @armor_rate
  1662. armor = 0 if @user == soha && @target.state?(405)
  1663. armor = 0 if @item && @item.damage.element_id == 7
  1664. aparam = @user.atk * @item.str_scale_mod / 100
  1665. dparam = @target.def
  1666. mod = calc_stat_damage_mod(:attack_damage, aparam, dparam)
  1667. dparam = 0 if @user == soha && @target.state?(405)
  1668. damage = wp * 4 - armor
  1669. damage += aparam / 2
  1670. damage -= dparam / 4 unless @item && @item.damage.element_id == 7
  1671. base = damage
  1672. damage = damage * mod
  1673. damage = damage * @sp_mod / 100
  1674. damage *= @user.intercept_damage_rate if @user.state?(271)
  1675. #p ["attack damage", "#{base} base", "#{str_mod.round(2)} attacking stat mod", "#{vit_mod.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1676. damage.to_i
  1677. end
  1678.  
  1679. def aura_glaive
  1680. wp = @user.weapon_power * @wp_mod / 100
  1681. armor = @target.armor * @armor_rate
  1682. str = @user.mdf
  1683. mod = calc_stat_damage_mod(:aura_glaive, str, 0)
  1684. damage = wp
  1685. damage += str / 10
  1686. damage = damage * mod
  1687. damage = damage * @sp_mod / 100
  1688. #damage *= @user.intercept_damage_rate if @user.state?(271)
  1689. damage.to_i
  1690. end
  1691.  
  1692.  
  1693. def gun_damage
  1694. wp = @user.weapon_power * @wp_mod / 100
  1695. wp *= shotgun_distance_mod(@user, @target) if @user.actor? && @user.battle_skill_learn?(520)
  1696. armor = @target.armor * @armor_rate
  1697. armor = 0 if @item && @item.damage.element_id == 7
  1698. vit = @target.def
  1699. str = @user.weapon_power # unused for ingrid
  1700. mod = calc_stat_damage_mod(:gun_damage, str, vit)
  1701. base = damage = wp * 4 - armor
  1702. damage = damage * mod
  1703. damage = damage * @sp_mod / 100.0
  1704. #p ["gun", base, damage, str_mod, vit_mod, @sp_mod] if ECHO_DAMAGE
  1705. damage.to_i
  1706. end
  1707.  
  1708. def xbow_damage
  1709. wp = @user.weapon_power * @wp_mod / 100
  1710. armor = @target.armor * @armor_rate
  1711. vit = @target.def
  1712. str = @user.luk # dex replaced for xbow
  1713. mod = calc_stat_damage_mod(:xbow_damage, str, vit)
  1714. armor = 0 if @item && @item.damage.element_id == 7
  1715. damage = wp * 4 - armor * 2
  1716. damage = damage * mod
  1717. if @user == eskandar && @user.battle_skill_learn?(920) # Eagle Eye
  1718. hit_rate = @target.calced_hit(@user, @item)
  1719. p "#{hit_rate} eagle eye damage rate (if higher than 1.0)"
  1720. damage *= hit_rate if hit_rate > 1.0
  1721. end
  1722. #p "xbow skill #{damage} damage, #{str_mod} str mod #{vit_mod} vit mod" if ECHO_DAMAGE
  1723. damage = damage * @sp_mod / 100.0
  1724. damage.to_i
  1725. end
  1726.  
  1727.  
  1728. def spell_damage
  1729. int = @user.mat
  1730. wis = @target.mdf
  1731. wis = 0 if @user == soha && @target.state?(405)
  1732. level = @user.level
  1733. sub_portion = @item.defense_scale * wis
  1734. sub_portion = 0 if @item && @item.damage.element_id == 7
  1735. base = @item.base_damage + int * @item.offense_scale - sub_portion
  1736. base += @user.mdf if @user.state?(525) # Aura Guide
  1737. base = @item.base_damage / 2 if base < @item.base_damage / 2
  1738. mod = calc_stat_damage_mod(:spell_damage, int, wis)
  1739. damage = base * mod
  1740. damage += damage * @item.blood_power / 100
  1741. damage = damage * @sp_mod / 100
  1742. damage *= 2 if @user.actor? && @user.battle_skill_learn?(370) # spellblade
  1743. #p ["spell damage", "#{base} base", "#{int_mod1.round(2)} attacking stat mod", "#{wis_mod1.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1744. damage.to_i
  1745. end
  1746.  
  1747. def blood_damage
  1748. int = @user.atk
  1749. wis = @target.def
  1750. wis = 0 if @user == soha && @target.state?(405)
  1751. base = @item.base_damage + int * @item.offense_scale - @item.defense_scale * wis
  1752. base = @item.base_damage / 2 if base < @item.base_damage / 2
  1753. mod = calc_stat_damage_mod(:blood_damage, int, wis)
  1754. damage = base * mod
  1755. damage += damage * @item.blood_power / 100
  1756. damage = damage * @sp_mod / 100
  1757. #p ["Blood damage", "#{base} base", "#{int_mod1.round(2)} attacking stat mod", "#{wis_mod1.round(2)} defending mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total damage"] if ECHO_DAMAGE
  1758. damage.to_i
  1759. end
  1760.  
  1761. def heal_normal
  1762. wis = @user.mdf
  1763. level = @user.level
  1764. base = @item.base_damage + wis * @item.offense_scale
  1765. mod = calc_stat_damage_mod(:blood_damage, wis, 0)
  1766. damage = base * mod
  1767. damage += damage * @item.blood_power / 100
  1768. damage = damage * @sp_mod / 100
  1769. #p ["heal normal", "#{base} base", "#{wis_mod1.round(2)} stat mod", "#{@sp_mod / 100.0} skill power mod", "#{damage} total heal"] if ECHO_DAMAGE
  1770. damage.to_i
  1771. end
  1772.  
  1773.  
  1774. def blood_heal_direct
  1775. base = @user.mhp * @item.blood_power / 200.0
  1776. wis = @user.mat
  1777. mod = calc_stat_damage_mod(:blood_damage, wis, 0)
  1778. damage = base * mod
  1779. damage = damage * @sp_mod / 100
  1780. #p ["blood heal", base, wis_mod, damage] if ECHO_DAMAGE
  1781. damage.to_i
  1782. end
  1783.  
  1784. end
  1785.  
  1786. class Game_Enemy
  1787.  
  1788. def null_blood_cost
  1789. enemy.null_blood_cost
  1790. end
  1791.  
  1792. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement