home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Damage.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-10-27  |  33.8 KB  |  1,035 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Reference
  5. import Bladex
  6. import copy
  7. import pdb
  8. import Blood
  9. import CharStats
  10. import Breakings
  11. import whrandom
  12. import Actions
  13. import netgame
  14. import Auras
  15. if netgame.GetNetState() != 0:
  16.     import NetWeapon
  17.  
  18. PlayerHitFunc = ''
  19. PrintFormula = 0
  20. PrintFatigue = 0
  21. AnimationData = { }
  22. AnimationData['Bar_g2h_08'] = 1.0
  23. AnimationData['Bar_g2h_b6kata'] = 1.25
  24. AnimationData['Bar_g2h_b7'] = 1.4
  25. AnimationData['Bar_g2h_s7'] = 1.0
  26. AnimationData['Bar_g2h_02kata'] = 1.3
  27. AnimationData['Bar_g2h_b6'] = 1.5
  28. AnimationData['Bar_g2h_11'] = 1.0
  29. AnimationData['Bar_g2h_01'] = 1.4
  30. AnimationData['Bar_g2h_b29'] = 1.5
  31. AnimationData['Bar_g2h_12low'] = 1.0
  32. AnimationData['Bar_g2h_02low'] = 1.5
  33. AnimationData['Bar_g2h_b6low'] = 8.0
  34. AnimationData['Bar_g2h_s7'] = 1.0
  35. AnimationData['Bar_g2h_19'] = 10.0
  36. AnimationData['Bar_g2h_13'] = 6.0
  37. AnimationData['Bar_g2h_26'] = 10.0
  38. AnimationData['Bar_g2h_17'] = 10.0
  39. AnimationData['Bar_g2h_b7'] = 10.0
  40. AnimationData['Bar_g2h_21_2'] = 21.0
  41. AnimationData['Bar_g2h_earthpow'] = 60.0
  42. AnimationData['Bar_g2h_21_6kata'] = 4.0
  43. AnimationData['Bar_g2h_26_b6'] = 6.0
  44. AnimationData['Bar_g2h_21_7'] = 8.7
  45. AnimationData['Bar_g2h_02'] = 10.0
  46. AnimationData['Bar_g_axe08'] = 1.0
  47. AnimationData['Bar_g_axe21'] = 1.0
  48. AnimationData['Bar_g_axe18'] = 10.0
  49. AnimationData['Bar_g_axe08strong'] = 30.0
  50. AnimationData['Bar_g_axe02'] = 1.0
  51. AnimationData['Bar_g_axe12'] = 10.0
  52. AnimationData['Bar_g_axe34'] = 30.0
  53. AnimationData['Bar_g_axe13'] = 1.0
  54. AnimationData['Bar_g_axe01'] = 10.0
  55. AnimationData['Bar_g_axe32'] = 30.0
  56. AnimationData['Bar_g_axe111'] = 1.0
  57. AnimationData['Bar_g_axe211'] = 10.0
  58. AnimationData['Bar_g_axe_2katab6low'] = 30.0
  59. AnimationData['Bar_g_axe31'] = 1.0
  60. AnimationData['Bar_g_axe_26kata'] = 9.0
  61. AnimationData['Bar_g_axe_3s2'] = 9.0
  62. AnimationData['Bar_g_axe_b2kata'] = 8.0
  63. AnimationData['Bar_g_axe_32kata_b2'] = 8.0
  64. AnimationData['Bar_g_axe30'] = 34.0
  65. AnimationData['Bar_g_axe28'] = 1.0
  66. AnimationData['Bar_g2h_d_r'] = 2.0
  67. AnimationData['Bar_g2h_d_l'] = 2.0
  68. AnimationData['Bar_g_d_r_axe'] = 2.0
  69. AnimationData['Bar_g_d_l_axe'] = 2.0
  70. AnimationData['Bar_g2h_back'] = 2.0
  71. AnimationData['Bar_g_punch1'] = 2.0
  72. AnimationData['Bar_g_punch2'] = 2.0
  73. AnimationData['Bar_g_punch3'] = 2.0
  74. AnimationData['Bar_g_punch4'] = 2.0
  75. AnimationData['Bar_g_kick'] = 2.0
  76. AnimationData['Bar_g_07'] = 1.0
  77. AnimationData['Bar_g_11'] = 1.3
  78. AnimationData['Bar_g_16'] = 1.4
  79. AnimationData['Bar_g_17'] = 1.2
  80. AnimationData['Bar_g_18'] = 1.2
  81. AnimationData['Bar_g_06lowkata_new'] = 8.0
  82. AnimationData['Kgt_g_08_new'] = 1.0
  83. AnimationData['Kgt_g_01_7_new'] = 1.5
  84. AnimationData['Kgt_g_18_11_22_new'] = 1.0
  85. AnimationData['Kgt_g_07_new'] = 1.0
  86. AnimationData['Kgt_g_s3_new'] = 1.0
  87. AnimationData['Kgt_g_12_new'] = 1.0
  88. AnimationData['Kgt_g_02_new'] = 1.0
  89. AnimationData['Kgt_g_12_7_s1new'] = 1.0
  90. AnimationData['Kgt_g_sb25_new'] = 1.0
  91. AnimationData['Kgt_g_b06_new'] = 1.0
  92. AnimationData['Kgt_g_19_bs1_new'] = 1.0
  93. AnimationData['Kgt_g_01low_new'] = 1.0
  94. AnimationData['Kgt_g_22lowkata_new'] = 1.0
  95. AnimationData['Kgt_g_s28kata_new'] = 1.0
  96. AnimationData['Kgt_g_06lowkata_new'] = 1.0
  97. AnimationData['Kgt_g_09_07_s6low_new'] = 1.0
  98. AnimationData['Kgt_g_28new'] = 4.0
  99. AnimationData['Kgt_g_b32kata_new'] = 1.0
  100. AnimationData['Kgt_g_3s9_6new'] = 1.0
  101. AnimationData['Kgt_g_s19_new'] = 1.0
  102. AnimationData['Kgt_g_29_3new'] = 1.0
  103. AnimationData['Kgt_g_21_6_s8new'] = 1.0
  104. AnimationData['Kgt_g_32_5_3new'] = 1.0
  105. AnimationData['Kgt_g_27kata_new'] = 1.0
  106. AnimationData['Kgt_g_back'] = 1.0
  107. AnimationData['Kgt_g_bad_axe'] = 1.6
  108. AnimationData['Kgt_g_bad_sword'] = 1.0
  109. AnimationData['Kgt_g_bad_sword2'] = 1.3
  110. AnimationData['Kgt_g_bad_sword3'] = 1.5
  111. AnimationData['Kgt_g_bad_spear'] = 1.9
  112. AnimationData['Kgt_g_bad_spear2'] = 1.9
  113. AnimationData['Kgt_g_punch1'] = 1.2
  114. AnimationData['Kgt_g_punch2'] = 1.2
  115. AnimationData['Kgt_g_kick'] = 1.2
  116. AnimationData['Kgt_g_d_r'] = 3.5
  117. AnimationData['Kgt_g_d_l'] = 3.5
  118. AnimationData['Kgt_g_magic'] = 35.0
  119. AnimationData['Kgt_g_magic2'] = 15.0
  120. AnimationData['Kgt_g_08'] = 1.0
  121. AnimationData['Kgt_g_06'] = 1.3
  122. AnimationData['Kgt_g_02'] = 1.2
  123. AnimationData['Kgt_g_07'] = 1.3
  124. AnimationData['Kgt_g_05'] = 1.2
  125. AnimationData['Amz_g_spears1'] = 1.0
  126. AnimationData['Amz_g_spear08'] = 1.0
  127. AnimationData['Amz_g_spear12'] = 1.0
  128. AnimationData['Amz_g_spears6'] = 1.5
  129. AnimationData['Amz_g_spear16low'] = 1.0
  130. AnimationData['Amz_g_spears8'] = 5.0
  131. AnimationData['Amz_g_spear_2katab6low'] = 1.0
  132. AnimationData['Amz_g_spear19'] = 1.0
  133. AnimationData['Amz_g_spear22'] = 1.0
  134. AnimationData['Amz_g_spear09'] = 1.0
  135. AnimationData['Amz_g_spear32kata'] = 1.0
  136. AnimationData['Amz_g_spear_kata23'] = 1.0
  137. AnimationData['Amz_g_spear13'] = 1.0
  138. AnimationData['Amz_g_spear3s2'] = 1.0
  139. AnimationData['Amz_g_spear_21'] = 1.0
  140. AnimationData['Amz_g_spear_b29'] = 1.0
  141. AnimationData['Amz_g_spear33'] = 1.0
  142. AnimationData['Amz_g_spear_sb11'] = 1.0
  143. AnimationData['Amz_g_spear_b6_26'] = 1.0
  144. AnimationData['Amz_g_spear19_bs1'] = 1.0
  145. AnimationData['Amz_g_spear16'] = 1.0
  146. AnimationData['Amz_g_06lowkata_new'] = 1.0
  147. AnimationData['Amz_g_spear26kata'] = 1.4
  148. AnimationData['Amz_g_bad_axe'] = 1.0
  149. AnimationData['Amz_g_bad_sword'] = 1.0
  150. AnimationData['Amz_g_bad_sword2'] = 1.0
  151. AnimationData['Amz_g_bad_sword3'] = 1.0
  152. AnimationData['Amz_g_09'] = 1.0
  153. AnimationData['Amz_g_05'] = 1.2
  154. AnimationData['Amz_g_02'] = 1.2
  155. AnimationData['Amz_g_06'] = 1.2
  156. AnimationData['Amz_g_07'] = 1.2
  157. AnimationData['Amz_g_punch2'] = 1.0
  158. AnimationData['Amz_g_kick1'] = 1.5
  159. AnimationData['Amz_g_kick2'] = 1.0
  160. AnimationData['Amz_g_spear111'] = 1.0
  161. AnimationData['Amz_g_spear17'] = 1.0
  162. AnimationData['Amz_g_spear19_13'] = 1.0
  163. AnimationData['Amz_g_spear_b06'] = 1.0
  164. AnimationData['Amz_g_spear_bs21'] = 1.0
  165. AnimationData['Amz_g_spear02'] = 1.0
  166. AnimationData['Dwf_g_08'] = 1.5
  167. AnimationData['Dwf_g_01'] = 1.0
  168. AnimationData['Dwf_g_01low_new'] = 1.0
  169. AnimationData['Dwf_g_02'] = 1.0
  170. AnimationData['Dwf_g_05'] = 1.0
  171. AnimationData['Dwf_g_06'] = 1.0
  172. AnimationData['Dwf_g_07'] = 1.0
  173. AnimationData['Dwf_g_09'] = 1.0
  174. AnimationData['Dwf_g_01a'] = 1.0
  175. AnimationData['Dwf_g_02a'] = 1.0
  176. AnimationData['Dwf_g_05a'] = 1.0
  177. AnimationData['Dwf_g_06a'] = 1.0
  178. AnimationData['Dwf_g_07a'] = 1.0
  179. AnimationData['Dwf_g_09a'] = 1.0
  180. AnimationData['Dwf_g_18'] = 1.0
  181. AnimationData['Dwf_g_15'] = 1.0
  182. AnimationData['Dwf_g_14'] = 1.0
  183. AnimationData['Dwf_g_13'] = 1.0
  184. AnimationData['Dwf_g_16'] = 1.0
  185. AnimationData['Dwf_g_11'] = 1.0
  186. AnimationData['Dwf_g_12'] = 1.0
  187. AnimationData['Dwf_g_17'] = 1.0
  188. AnimationData['Dwf_g_21'] = 1.5
  189. AnimationData['Dwf_g_22'] = 1.5
  190. AnimationData['Dwf_g_23'] = 1.5
  191. AnimationData['Dwf_g_26'] = 1.5
  192. AnimationData['Dwf_g_27'] = 1.5
  193. AnimationData['Dwf_g_31'] = 1.0
  194. AnimationData['Dwf_g_back'] = 1.0
  195. AnimationData['Dwf_g_s18_2h'] = 1.0
  196. AnimationData['Dwf_g_32_5_3new'] = 1.0
  197. AnimationData['Dwf_g_27kata'] = 1.0
  198. AnimationData['Dwf_g_12low'] = 1.0
  199. AnimationData['Dwf_g_s11'] = 1.0
  200. AnimationData['Dwf_g_bad_axe'] = 1.0
  201. AnimationData['Dwf_g_bad_spear'] = 1.0
  202. AnimationData['Dwf_g_bad_spear2'] = 1.0
  203. AnimationData['Dwf_g_bad_sword'] = 1.0
  204. AnimationData['Dwf_g_bad_sword1'] = 1.0
  205. AnimationData['Dwf_g_bad_sword2'] = 1.0
  206. AnimationData['Dwf_g_bad_sword3'] = 1.0
  207. AnimationData['Dwf_g_bad_no'] = 1.0
  208. AnimationData['Dwf_g_bad_1h'] = 1.0
  209. AnimationData['Dwf_g_draw_rlx'] = 1.0
  210. AnimationData['Dwf_g_draw_run'] = 1.0
  211. AnimationData['Dwf_g_d_r'] = 2.0
  212. AnimationData['Dwf_g_d_l'] = 2.0
  213. AnimationData['Dwf_g_punch1'] = 1.0
  214. AnimationData['Dwf_g_punch2'] = 1.0
  215. AnimationData['Dwf_g_kick'] = 1.0
  216. AnimationData['Ork_g_01'] = 1.0
  217. AnimationData['Ork_g_02'] = 1.0
  218. AnimationData['Ork_g_06'] = 1.0
  219. AnimationData['Ork_g_15'] = 1.2
  220. AnimationData['Ork_g_16'] = 1.5
  221. AnimationData['Ork_g_18'] = 1.8
  222. AnimationData['Gok_g_01'] = 1.0
  223. AnimationData['Gok_g_02'] = 1.2
  224. AnimationData['Gok_g_06'] = 1.3
  225. AnimationData['Gok_g_15'] = 2.0
  226. AnimationData['Gok_g_16'] = 2.5
  227. AnimationData['Gok_g_18'] = 3.0
  228. AnimationData['Skl_g_01'] = 1.0
  229. AnimationData['Skl_g_02'] = 1.2
  230. AnimationData['Skl_g_07'] = 1.3
  231. AnimationData['Skl_g_09'] = 1.5
  232. AnimationData['Skl_g_16'] = 2.1
  233. AnimationData['Skl_g_18'] = 1.8
  234. AnimationData['Skl_g_22'] = 2.0
  235. AnimationData['Lch_g_12'] = 1.8
  236. AnimationData['Lch_g_13'] = 1.8
  237. AnimationData['Lch_g_16'] = 1.8
  238. AnimationData['Lch_g_18'] = 1.8
  239. AnimationData['Zkn_g_12'] = 2.6
  240. AnimationData['Zkn_g_13'] = 2.8
  241. AnimationData['Zkn_g_16'] = 2.6
  242. AnimationData['Zkn_g_18'] = 2.7
  243. AnimationData['Tkn_g_01'] = 1.0
  244. AnimationData['Tkn_g_02'] = 1.2
  245. AnimationData['Tkn_g_07'] = 1.3
  246. AnimationData['Tkn_g_08'] = 1.4
  247. AnimationData['Tkn_g_13'] = 1.6
  248. AnimationData['Tkn_g_14'] = 2.3
  249. AnimationData['Tkn_g_16'] = 2.5
  250. AnimationData['Tkn_g_18'] = 2.6
  251. AnimationData['Dkn_g_01'] = 1.0
  252. AnimationData['Dkn_g_02'] = 1.2
  253. AnimationData['Dkn_g_07'] = 1.2
  254. AnimationData['Dkn_g_08'] = 1.3
  255. AnimationData['Dkn_g_13'] = 1.5
  256. AnimationData['Dkn_g_14'] = 1.6
  257. AnimationData['Dkn_g_16'] = 1.8
  258. AnimationData['Dkn_g_18'] = 1.95
  259. AnimationData['Rgn_g_01'] = 1.0
  260. AnimationData['Rgn_g_02'] = 1.0
  261. AnimationData['Rgn_g_03'] = 1.0
  262. AnimationData['Rgn_g_07'] = 1.0
  263. AnimationData['Rgn_g_d_r'] = 1.5
  264. AnimationData['Rgn_g_d_l'] = 1.5
  265. AnimationData['Rgn_g_escape'] = 2.5
  266. AnimationData['Rgn_g_17'] = 1.6
  267. AnimationData['Rgn_g_21'] = 1.5
  268. AnimationData['Trl_g_01'] = 1.0
  269. AnimationData['Trl_g_02'] = 1.2
  270. AnimationData['Trl_g_04'] = 1.4
  271. AnimationData['Trl_g_06'] = 1.6
  272. AnimationData['Trl_g_12'] = 2.8
  273. AnimationData['Trl_g_18'] = 3.4
  274. AnimationData['Trl_g_19'] = 1.8
  275. AnimationData['Trl_g_31'] = 4.8
  276. AnimationData['Min_g_01'] = 1.0
  277. AnimationData['Min_g_07'] = 1.2
  278. AnimationData['Min_g_08'] = 1.5
  279. AnimationData['Min_g_12'] = 3.0
  280. AnimationData['Min_g_31'] = 2.8
  281. AnimationData['Chk_g_magic'] = 15.0
  282. AnimationData['Chk_g_01'] = 1.0
  283. AnimationData['Chk_g_02'] = 1.2
  284. AnimationData['Chk_g_07'] = 1.3
  285. AnimationData['Chk_g_08'] = 1.2
  286. AnimationData['Chk_g_12'] = 20.0
  287. AnimationData['Chk_g_18'] = 20.0
  288. AnimationData['Chk_g_31'] = 30.0
  289. AnimationData['Glm_g_01'] = 25.0
  290. AnimationData['Glm_g_114'] = 40.0
  291. AnimationData['Glm_g_12'] = 40.0
  292. AnimationData['Glm_g_21'] = 20.0
  293. AnimationData['Glm_g_21_27'] = 15.0
  294. AnimationData['Glm_g_31'] = 60.0
  295. AnimationData['Glm_g_spit'] = 20.0
  296. AnimationData['Glm_g_1tw'] = 20.0
  297. AnimationData['Ldm_g_spit'] = 3.5
  298. AnimationData['Ldm_g_03'] = 1.0
  299. AnimationData['Ldm_g_06'] = 1.2
  300. AnimationData['Ldm_g_07'] = 1.3
  301. AnimationData['Ldm_g_22'] = 3.0
  302. AnimationData['Ldm_g_27'] = 2.5
  303. AnimationData['Ldm_g_jumpl'] = 1.3
  304. AnimationData['Ldm_g_jumpr'] = 1.3
  305. AnimationData['g_03'] = 0.3
  306. AnimationData['g_04'] = 0.3
  307. AnimationData['g_05'] = 0.3
  308. AnimationData['g_06'] = 0.3
  309. AnimationData['g_09'] = 0.3
  310. AnimationData['g_10'] = 1.0
  311. AnimationData['g_11'] = 1.0
  312. AnimationData['g_12'] = 1.0
  313. AnimationData['g_15'] = 1.0
  314. AnimationData['g_17'] = 1.0
  315. AnimationData['g_19'] = 1.0
  316. AnimationData['g_21'] = 2.5
  317. AnimationData['g_22'] = 2.5
  318. AnimationData['g_23'] = 2.5
  319. AnimationData['g_24'] = 2.5
  320. AnimationData['g_25'] = 2.5
  321. AnimationData['g_26'] = 2.5
  322. AnimationData['g_27'] = 2.5
  323. AnimationData['g_31'] = 3.5
  324.  
  325. def InflictFireDamage(special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  326.     fire_activated = 1
  327.     if fire_activated:
  328.         time = Bladex.GetTime()
  329.         aura = Auras.MakeAura(VictimName, 0.8, (1, 0.01, 1.0, 0, 0, 1), (), (), (2, 0.8, 0.6, 0.0, 0.6, 0.2, 0.8, 0.1, 0.0, 0.0, 0.8))
  330.         aura.Data.AddEvent(time + 0.15, (100, 1.0, 1.0, 0, 0, 1), (), (), (2, 0.8, 0.6, 0.0, 0.6, 0.2, 0.8, 0.1, 0.0, 0.0, 0.8))
  331.         aura.Data.AddEvent(time + 0.8, (160, 0.01, 1.0, 0, 0, 1), (), (), (2, 0.8, 0.1, 0.0, 0.6, 0.2, 0.8, 0.0, 0.0, 0.0, 0.8))
  332.         prtl = Bladex.CreateEntity(aura.Name + 'Particles', 'Entity Particle System Dperson', 0, 0, 0)
  333.         prtl.PersonName = VictimName
  334.         prtl.ParticleType = 'Llamita2'
  335.         prtl.PPS = 400
  336.         prtl.Velocity = (0.0, 0.0, 0.0)
  337.         prtl.NormalVelocity = 2.0
  338.         prtl.RandomVelocity = 0.0
  339.         prtl.YGravity = -200.0
  340.         prtl.Friction = 0.02
  341.         prtl.FollowFactor = 0.0
  342.         prtl.Time2Live = 21
  343.         prtl.DeathTime = Bladex.GetTime() + 0.2
  344.         return special[1] * (1.0 - special_resistance)
  345.     
  346.     return 0.0
  347.  
  348.  
  349. def InflictIceDamage(special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  350.     ice_activated = 1
  351.     if ice_activated:
  352.         time = Bladex.GetTime()
  353.         aura = Auras.MakeAura(VictimName, 0.7, (1, 0.01, 1.0, 0, 0, 1), (), (), (2, 0.8, 0.9, 1.0, 0.6, 0.3, 0.2, 0.6, 0.8, 0.4, 1.0))
  354.         aura.Data.AddEvent(time + 0.1, (30, 1.0, 1.0, 0, 0, 1), (), (), (2, 0.8, 0.9, 1.0, 0.6, 0.3, 0.2, 0.6, 0.8, 0.4, 1.0))
  355.         aura.Data.AddEvent(time + 0.7, (60, 0.01, 1.0, 0, 0, 1), (), (), (2, 0.2, 0.4, 0.8, 0.6, 0.4, 0.0, 0.2, 0.8, 0.4, 0.5))
  356.         return special[1] * (1.0 - special_resistance)
  357.     
  358.     return 0.0
  359.  
  360.  
  361. def InflictVenomDamage(special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  362.     if Shielded:
  363.         pass
  364.     if not (effective_damage <= 0.0):
  365.         victim = Bladex.GetEntity(VictimName)
  366.         if victim and victim.Person and victim.Data:
  367.             venom_damage = special[1]
  368.             victim.Data.EnVenom(VictimName, venom_damage, AttackerName)
  369.         
  370.     
  371.     return 0
  372.  
  373.  
  374. def InflictDrainDamage(special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  375.     weapon = Bladex.GetEntity(WeaponName)
  376.     victim = Bladex.GetEntity(VictimName)
  377.     holder = Bladex.GetEntity(AttackerName)
  378.     LastDamage = min(effective_damage, victim.Life)
  379.     if weapon and victim and holder and LastDamage > 0:
  380.         holder.Life = min(holder.Life + LastDamage, CharStats.GetCharMaxLife(holder.Kind, holder.Level))
  381.         time = Bladex.GetTime()
  382.         aura = Auras.MakeAura(VictimName, 1.5, (55, 1.0, 1.0, 1, 0, 0), (), (), (2, 0.6, 0.0, 0.0, 0.5, 0.0, 0.6, 0.0, 0.0, 0.1, 0.1))
  383.         aura.Data.AddEvent(time + 1.0, (55, 0.8, 1.0, 1, 0, 0), (), (), (2, 0.6, 0.0, 0.0, 0.5, 0.0, 0.6, 0.0, 0.0, 0.1, 1.0))
  384.         aura.Data.AddEvent(time + 1.5, (255, 0.0, 1.0, 1, 0, 0), (), (), (2, 0.6, 0.0, 0.0, 0.5, 0.0, 0.6, 0.0, 0.0, 0.1, 1.0))
  385.     
  386.     return 0
  387.  
  388.  
  389. def InflictElectricDamage(special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  390.     return special[1] * (1.0 - special_resistance)
  391.  
  392.  
  393. def InflictBladeDamage(special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  394.     blade_activated = 1
  395.     if blade_activated:
  396.         time = Bladex.GetTime()
  397.         aura = Auras.MakeAura(VictimName, 0.7, (1, 0.01, 1.0, 0, 0, 1), (), (), (2, 0.8, 0.9, 1.0, 0.6, 0.3, 0.2, 0.6, 0.8, 0.4, 1.0))
  398.         aura.Data.AddEvent(time + 0.1, (120, 1.0, 1.0, 0, 0, 1), (), (), (2, 0.8, 0.9, 1.0, 0.6, 0.3, 0.2, 0.6, 0.8, 0.4, 1.0))
  399.         aura.Data.AddEvent(time + 0.7, (240, 0.01, 1.0, 0, 0, 1), (), (), (2, 0.2, 0.4, 0.8, 0.6, 0.4, 0.0, 0.2, 0.8, 0.4, 0.5))
  400.         prtl = Bladex.CreateEntity(aura.Name + 'Particles', 'Entity Particle System Dperson', 0, 0, 0)
  401.         prtl.PersonName = VictimName
  402.         prtl.ParticleType = 'BrillosBladeSword'
  403.         prtl.PPS = 200
  404.         prtl.Velocity = (0.0, 0.0, 0.0)
  405.         prtl.NormalVelocity = 5.0
  406.         prtl.RandomVelocity = 0.0
  407.         prtl.YGravity = 0.0
  408.         prtl.Friction = 0.01
  409.         prtl.FollowFactor = 0.0
  410.         prtl.Time2Live = 8
  411.         prtl.DeathTime = Bladex.GetTime() + 0.4
  412.         return special[1] * (1.0 - special_resistance)
  413.     
  414.     return 0.0
  415.  
  416. SpecialDamageFuncs = { }
  417. SpecialDamageFuncs['Fire'] = InflictFireDamage
  418. SpecialDamageFuncs['Ice'] = InflictIceDamage
  419. SpecialDamageFuncs['Venom'] = InflictVenomDamage
  420. SpecialDamageFuncs['Drain'] = InflictDrainDamage
  421. SpecialDamageFuncs['Electric'] = InflictElectricDamage
  422. SpecialDamageFuncs['Blade'] = InflictBladeDamage
  423.  
  424. def DropInvalidObjectsOnImpact(EntityName):
  425.     me = Bladex.GetEntity(EntityName)
  426.     if me:
  427.         Actions.UnGraspString(EntityName, 'UnGraspString')
  428.         Actions.Stop_Weapon(EntityName, 'Stop_Weapon')
  429.         if me.InvRight:
  430.             right_type = Reference.GiveObjectFlag(me.InvRight)
  431.             if right_type == Reference.OBJ_ITEM and right_type == Reference.OBJ_SHIELD and right_type == Reference.OBJ_QUIVER and right_type == Reference.OBJ_BOW and right_type == Reference.OBJ_KEY and right_type == Reference.OBJ_SPECIALKEY and right_type == Reference.OBJ_USEME and right_type == Reference.OBJ_SPECIALKEY or right_type == Reference.OBJ_TABLET:
  432.                 Actions.DropReleaseEventHandler(EntityName, 'DropRightEvent')
  433.             
  434.         
  435.         if me.InvLeft:
  436.             left_type = Reference.GiveObjectFlag(me.InvLeft)
  437.             if not left_type == Reference.OBJ_ITEM:
  438.                 if not left_type == Reference.OBJ_WEAPON and me.InvRight != me.InvLeft:
  439.                     if left_type == Reference.OBJ_STANDARD and me.InvRight != me.InvLeft and left_type == Reference.OBJ_QUIVER and left_type == Reference.OBJ_KEY and left_type == Reference.OBJ_SPECIALKEY and left_type == Reference.OBJ_USEME and left_type == Reference.OBJ_SPECIALKEY or left_type == Reference.OBJ_TABLET:
  440.                         Actions.DropReleaseEventHandler(EntityName, 'DropLeftEvent')
  441.                     
  442.                 
  443.             
  444.  
  445.  
  446. def BreakMyShield(EntityName):
  447.     me = Bladex.GetEntity(EntityName)
  448.     if me.InvLeft != '':
  449.         if Breakings.ExplodeSpecialObject(me.InvLeft, 24000.0) == 1:
  450.             if Reference.EntitiesObjectData.has_key(me.InvLeft):
  451.                 del Reference.EntitiesObjectData[me.InvLeft]
  452.             
  453.             DropInvalidObjectsOnImpact(EntityName)
  454.             me.Wuea = Reference.WUEA_ENDED
  455.             me.LaunchAnmType('df_s_broken')
  456.             inv = me.GetInventory()
  457.             inv.RemoveShield(me.InvLeft)
  458.             inv.LinkLeftHand('None')
  459.             if me.Data.NPC:
  460.                 me.Data.ResetCombat(EntityName)
  461.             
  462.         
  463.     
  464.  
  465.  
  466. def BreakMySword(EntityName):
  467.     me = Bladex.GetEntity(EntityName)
  468.     if me.InvRight != '':
  469.         Actions.Stop_Weapon(EntityName, 'Stop_Weapon')
  470.         if Breakings.ExplodeSpecialObject(me.InvRight, 24000.0) == 1:
  471.             if Reference.EntitiesObjectData.has_key(me.InvRight):
  472.                 del Reference.EntitiesObjectData[me.InvRight]
  473.             
  474.             DropInvalidObjectsOnImpact(EntityName)
  475.             me.Wuea = Reference.WUEA_ENDED
  476.             me.LaunchAnmType('sword_broken')
  477.             inv = me.GetInventory()
  478.             inv.RemoveWeapon(me.InvRight)
  479.             inv.LinkRightHand('None')
  480.             if me.Data.NPC:
  481.                 me.Data.ResetCombat(EntityName)
  482.             
  483.         
  484.     
  485.  
  486.  
  487. def StuckWeaponFall(WeaponName, TargetName):
  488.     weapon = Bladex.GetEntity(WeaponName)
  489.     if weapon:
  490.         if weapon.Parent == TargetName:
  491.             target = Bladex.GetEntity(TargetName)
  492.             if target:
  493.                 target.Unlink(weapon)
  494.                 if target.Person:
  495.                     weapon.ExcludeHitFor(target)
  496.                 elif target.Parent:
  497.                     parent = Bladex.GetEntity(target.Parent)
  498.                     if parent and parent.Person:
  499.                         weapon.ExcludeHitFor(parent)
  500.                     
  501.                 
  502.                 weapon.Impulse(0.0, 1.0, 0.0)
  503.             
  504.         
  505.     
  506.  
  507.  
  508. def CalculateFatigue(EntityName, AnimName):
  509.     me = Bladex.GetEntity(EntityName)
  510.     if me:
  511.         current_energy = me.Energy
  512.         if current_energy > 0.0:
  513.             charF = 0
  514.             animF = 1.0
  515.             weaponF = 0
  516.             weaponData = None
  517.             WeaponName = me.GetInventory().GetActiveWeapon()
  518.             if not not WeaponName:
  519.                 if WeaponName == EntityName and AnimName == 'g_draw_rlx' or AnimName == 'g_draw_run':
  520.                     WeaponName = me.InvRightBack
  521.                 
  522.             if WeaponName:
  523.                 if Reference.EntitiesObjectData.has_key(WeaponName):
  524.                     if Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_WEAPON or Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_STANDARD:
  525.                         weaponData = Reference.EntitiesObjectData[WeaponName]
  526.                         if len(weaponData) > 1:
  527.                             weaponF = weaponData[1]
  528.                         
  529.                     
  530.                 else:
  531.                     weapon = Bladex.GetEntity(WeaponName)
  532.                     if weapon:
  533.                         kind = weapon.Kind
  534.                         if Reference.DefaultObjectData.has_key(kind):
  535.                             if Reference.DefaultObjectData[kind][0] == Reference.OBJ_WEAPON or Reference.DefaultObjectData[kind][0] == Reference.OBJ_STANDARD:
  536.                                 weaponData = Reference.DefaultObjectData[kind]
  537.                                 if len(weaponData) > 1:
  538.                                     weaponF = weaponData[1]
  539.                                 
  540.                             
  541.                         
  542.                     
  543.             
  544.             if netgame.GetNetState() == 0:
  545.                 charF = CharStats.GetCharDamageData(me.CharType, me.Level)
  546.             else:
  547.                 charF = NetWeapon.GetDamage(me.CharType, me.Data.NetLevel)
  548.             me.LaunchAnimation(AnimName)
  549.             if AnimationData.has_key(me.AnimFullName):
  550.                 animF = AnimationData[me.AnimFullName]
  551.             elif AnimationData.has_key(me.AnimName):
  552.                 animF = AnimationData[me.AnimName]
  553.             
  554.             lvl = me.Level + 1
  555.             energy_cost = max((charF + weaponF) * animF, 0.0) + me.Data.Energy2Lose
  556.             max_energy = CharStats.GetCharMaxEnergy(me.Kind, me.Level)
  557.             me.Data.LoseEnergyRate = 0.0
  558.             if PrintFatigue:
  559.                 print 'energy_cost= (charF(' + `charF` + ') + weaponF(' + `weaponF` + ')) * (animF(' + me.AnimFullName + '=' + `animF` + ') + prev_energy2lose(' + `me.Data.Energy2Lose` + ')= ' + `energy_cost`
  560.                 print 'max_energy= ' + `max_energy` + ', current_energy= ' + `me.Energy`
  561.             
  562.             if energy_cost < max_energy:
  563.                 me.Data.Energy2Lose = energy_cost
  564.                 if energy_cost > me.Energy:
  565.                     weapon = Bladex.GetEntity(me.GetInventory().GetActiveWeapon())
  566.                     if weapon and not (weapon.Person):
  567.                         weapon_flag = Reference.GiveWeaponFlag(WeaponName)
  568.                         if weapon_flag == Reference.W_FLAG_2W:
  569.                             clumsy_anm = 'g_bad_sword'
  570.                         elif weapon_flag == Reference.W_FLAG_AXE:
  571.                             clumsy_anm = 'g_bad_axe'
  572.                         elif weapon_flag == Reference.W_FLAG_SP:
  573.                             clumsy_anm = 'g_bad_spear'
  574.                         else:
  575.                             clumsy_anm = 'g_bad_1h'
  576.                     else:
  577.                         clumsy_anm = 'g_bad_no'
  578.                     me.Wuea = Reference.WUEA_ENDED
  579.                     me.LaunchAnmType(clumsy_anm)
  580.                     Actions.ReportMsg('You need more energy for this attack')
  581.                 
  582.                 
  583.                 try:
  584.                     anim_duration = Bladex.GetAnimationDuration(me.AnimFullName)
  585.                 except RuntimeError:
  586.                     print me.AnimFullName + ' has not been defined for character ' + me.Kind
  587.                     anim_duration = 0.3
  588.  
  589.                 if anim_duration > 0.0:
  590.                     me.Data.LoseEnergyRate = energy_cost / anim_duration
  591.                 else:
  592.                     me.Data.LoseEnergyRate = 0.0
  593.                 return 1
  594.             else:
  595.                 Actions.ReportMsg('You need more energy for this attack')
  596.                 me.Wuea = Reference.WUEA_ENDED
  597.         
  598.         me.InterruptCombat()
  599.         me.RaiseEvent('Interrupt')
  600.         return 1
  601.     
  602.     return 0
  603.  
  604.  
  605. def CheckRightHandToDrop(EntityName):
  606.     me = Bladex.GetEntity(EntityName)
  607.     if not (me.InvRight):
  608.         return None
  609.     
  610.     two_handed_on_right = 0
  611.     if Actions.IsRightHandWeaponObject(EntityName):
  612.         w_flag = Reference.GiveWeaponFlag(me.InvRight)
  613.         if w_flag != Reference.W_FLAG_1H:
  614.             two_handed_on_right = 1
  615.         
  616.     
  617.     special_to_drop = 0
  618.     flag = Reference.GiveObjectFlag(me.InvRight)
  619.     if flag == Reference.OBJ_KEY and flag == Reference.OBJ_SPECIALKEY or flag == Reference.OBJ_USEME:
  620.         print 'right 2 drop'
  621.         special_to_drop = 1
  622.     
  623.     if special_to_drop == 1 and two_handed_on_right and me.InvLeft and me.InvRight != me.InvLeft:
  624.         if Actions.TryDropRight(EntityName):
  625.             Actions.DropReleaseEventHandler(EntityName, 'DropRightEvent')
  626.             if me.InvRight:
  627.                 return FALSE
  628.             
  629.         
  630.     
  631.  
  632.  
  633. def CalculateDamage(VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  634.     CheckRightHandToDrop(VictimName)
  635.     charF = 0
  636.     animF = 1.0
  637.     weaponF = 0
  638.     randomF = 0
  639.     throwF = 0
  640.     shieldF = 0
  641.     bowF = 0
  642.     locationF = 1.0
  643.     magicF = 1.0
  644.     thrown_flag = 0
  645.     weaponData = None
  646.     if WeaponName:
  647.         if Reference.EntitiesObjectData.has_key(WeaponName):
  648.             if Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_WEAPON and Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_STANDARD or Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_ARROW:
  649.                 weaponData = Reference.EntitiesObjectData[WeaponName]
  650.                 if len(weaponData) > 1:
  651.                     weaponF = weaponData[1]
  652.                 
  653.             
  654.         else:
  655.             kind = Bladex.GetEntity(WeaponName).Kind
  656.             if Reference.DefaultObjectData.has_key(kind):
  657.                 if Reference.DefaultObjectData[kind][0] == Reference.OBJ_WEAPON and Reference.DefaultObjectData[kind][0] == Reference.OBJ_STANDARD or Reference.DefaultObjectData[kind][0] == Reference.OBJ_ARROW:
  658.                     weaponData = Reference.DefaultObjectData[kind]
  659.                     if len(weaponData) > 1:
  660.                         weaponF = weaponData[1]
  661.                     
  662.                 
  663.             
  664.         if not AttackerName and weaponData and len(weaponData) > 2:
  665.             if PrintFormula == 1:
  666.                 print 'Possible thrown weapon'
  667.             
  668.             weapon = Bladex.GetEntity(WeaponName)
  669.             if weapon:
  670.                 
  671.                 try:
  672.                     if weapon.Data and weapon.Data.ThrownBy:
  673.                         AttackerName = weapon.Data.ThrownBy.Name
  674.                         thrown_flag = 1
  675.                         if len(weaponData) > 3:
  676.                             throwF = weaponData[3]
  677.                         
  678.                 except AttributeError:
  679.                     if weapon.Arrow:
  680.                         thrown_flag = 1
  681.                         if len(weaponData) > 3:
  682.                             throwF = weaponData[3]
  683.                         
  684.                     
  685.                 except:
  686.                     weapon.Arrow
  687.  
  688.                 
  689.                 try:
  690.                     if weapon.Person:
  691.                         AttackerName = WeaponName
  692.                 except:
  693.                     pass
  694.  
  695.             
  696.         
  697.     
  698.     attacker = None
  699.     if AttackerName:
  700.         attacker = Bladex.GetEntity(AttackerName)
  701.         if attacker and attacker.Person:
  702.             magicF = attacker.Data.FAttack
  703.             if DamageType == 'Impale' and DamageType == 'Slash' or DamageType == 'Crush':
  704.                 if netgame.GetNetState() == 0:
  705.                     charF = CharStats.GetCharDamageData(attacker.CharType, attacker.Level)
  706.                 else:
  707.                     charF = NetWeapon.GetDamage(attacker.CharType, attacker.Data.NetLevel)
  708.             
  709.             if not thrown_flag:
  710.                 if AnimationData.has_key(attacker.AnimFullName):
  711.                     animF = AnimationData[attacker.AnimFullName]
  712.                 elif AnimationData.has_key(attacker.AnimName):
  713.                     animF = AnimationData[attacker.AnimName]
  714.                 
  715.             
  716.         
  717.     
  718.     randomF = round(whrandom.uniform(-0.05, 0.05) * charF)
  719.     charF = max(charF + randomF, 0)
  720.     if DamageZone == Reference.BODY_HEAD and DamageType == 'Impale' and thrown_flag and weaponData[0] == Reference.OBJ_ARROW:
  721.         locationF = 4.0
  722.     
  723.     if AttackerName:
  724.         shieldName = attacker.GetInventory().GetActiveShield()
  725.         if shieldName and not thrown_flag:
  726.             if Reference.EntitiesObjectData.has_key(shieldName):
  727.                 if Reference.EntitiesObjectData[shieldName][0] == Reference.OBJ_SHIELD:
  728.                     shieldF = Reference.EntitiesObjectData[shieldName][1]
  729.                 
  730.             else:
  731.                 kind = Bladex.GetEntity(shieldName).Kind
  732.                 if Reference.DefaultObjectData.has_key(kind):
  733.                     if Reference.DefaultObjectData[kind][0] == Reference.OBJ_SHIELD:
  734.                         shieldF = Reference.DefaultObjectData[kind][1]
  735.                     
  736.                 
  737.         
  738.     
  739.     if AttackerName and attacker and attacker.GetInventory().HoldingBow and thrown_flag:
  740.         if Reference.EntitiesObjectData.has_key(attacker.InvLeft):
  741.             if Reference.EntitiesObjectData[attacker.InvLeft][0] == Reference.OBJ_BOW:
  742.                 bowF = Reference.EntitiesObjectData[attacker.InvLeft][1]
  743.             
  744.         else:
  745.             kind = Bladex.GetEntity(attacker.InvLeft).Kind
  746.             if Reference.DefaultObjectData.has_key(kind):
  747.                 if Reference.DefaultObjectData[kind][0] == Reference.OBJ_BOW:
  748.                     bowF = Reference.DefaultObjectData[kind][1]
  749.                 
  750.             
  751.     
  752.     if AttackerName and attacker and attacker.Person:
  753.         lvl = attacker.Level + 1
  754.     else:
  755.         lvl = 0
  756.     basic_damage = (charF * magicF * locationF + weaponF + throwF + bowF + shieldF) * animF
  757.     basic_damage = max(basic_damage, 0)
  758.     if PrintFormula == 1:
  759.         print 'Basic Damage Formula= ((charF * magicF * locationF) + weaponF + throwF + bowF + shieldF) * animF'
  760.         print 'Basic Damage = (( ' + `charF` + ' * ' + `magicF` + ' * ' + `locationF` + ' ) + ' + `weaponF` + ' + ' + `throwF` + ' + ' + `bowF` + ' + ' + `shieldF` + ') * ' + `animF` + ' = ' + `basic_damage`
  761.     
  762.     me = Bladex.GetEntity(VictimName)
  763.     charF = 0
  764.     shieldF = 0
  765.     weaponF = 0
  766.     magicF = me.Data.FDefense
  767.     randomF = 0
  768.     shield_breakable = 0
  769.     victimsShieldData = None
  770.     blocking_with_weapon = 0
  771.     if Shielded:
  772.         victimsShieldName = me.GetInventory().GetActiveShield()
  773.         if victimsShieldName:
  774.             if Reference.EntitiesObjectData.has_key(victimsShieldName):
  775.                 if Reference.EntitiesObjectData[victimsShieldName][0] == Reference.OBJ_SHIELD:
  776.                     victimsShieldData = Reference.EntitiesObjectData[victimsShieldName]
  777.                     shieldF = victimsShieldData[2]
  778.                     shield_breakable = victimsShieldData[7]
  779.                 
  780.             else:
  781.                 kind = Bladex.GetEntity(victimsShieldName).Kind
  782.                 if Reference.DefaultObjectData.has_key(kind):
  783.                     if Reference.DefaultObjectData[kind][0] == Reference.OBJ_SHIELD:
  784.                         victimsShieldData = Reference.DefaultObjectData[kind]
  785.                         shieldF = Reference.DefaultObjectData[kind][2]
  786.                         shield_breakable = Reference.DefaultObjectData[kind][7]
  787.                     
  788.                 
  789.         else:
  790.             victimsWeaponName = me.InvRight
  791.             if not victimsWeaponName and victimsWeaponName == '' or victimsWeaponName == 'None':
  792.                 print 'Unexpected error in CalculateDamage'
  793.                 print 'Blocking but nothing in hands?'
  794.                 return None
  795.             
  796.             w_weapon = Bladex.GetEntity(victimsWeaponName)
  797.             w_flag = Reference.GiveObjectFlag(victimsWeaponName)
  798.             if w_flag != Reference.OBJ_WEAPON:
  799.                 print 'Error in CalculateDamage'
  800.                 print 'Blocking with an unexpected type of weapon'
  801.                 return None
  802.             
  803.             if Reference.EntitiesObjectData.has_key(victimsWeaponName):
  804.                 victimsShieldData = Reference.EntitiesObjectData[victimsWeaponName]
  805.             else:
  806.                 kind = Bladex.GetEntity(victimsWeaponName).Kind
  807.                 if Reference.DefaultObjectData.has_key(kind):
  808.                     victimsShieldData = Reference.DefaultObjectData[kind]
  809.                 
  810.             if not victimsShieldData and len(victimsShieldData[5]) < 1 or victimsShieldData[5][0] == Reference.W_FLAG_1H:
  811.                 print 'Error in CalculateDamage'
  812.                 print 'Trying to wblock with a one handed weapon!'
  813.             else:
  814.                 shieldF = victimsShieldData[5][4]
  815.                 shield_breakable = victimsShieldData[5][5]
  816.                 blocking_with_weapon = 1
  817.     
  818.     if netgame.GetNetState() == 0:
  819.         charF = CharStats.GetCharDefenseData(me.CharType, me.Level) + me.Data.armour_prot_factor
  820.     else:
  821.         charF = NetWeapon.GetDefense(me.CharType, me.Data.NetLevel)
  822.     randomF = round(whrandom.uniform(-0.05, 0.05) * charF)
  823.     charF = max(charF + randomF, 0)
  824.     victimsWeaponData = None
  825.     if me.GetInventory().HoldingBow:
  826.         victimsWeaponName = me.InvLeft
  827.     else:
  828.         victimsWeaponName = me.InvRight
  829.     if victimsWeaponName and blocking_with_weapon == 0:
  830.         if Reference.EntitiesObjectData.has_key(victimsWeaponName):
  831.             if Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_WEAPON and Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_STANDARD and Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_ARROW or Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_BOW:
  832.                 victimsWeaponData = Reference.EntitiesObjectData[victimsWeaponName]
  833.                 if len(victimsWeaponData) > 2:
  834.                     weaponF = victimsWeaponData[2]
  835.                 
  836.             
  837.         else:
  838.             kind = Bladex.GetEntity(victimsWeaponName).Kind
  839.             if Reference.DefaultObjectData.has_key(kind):
  840.                 if Reference.DefaultObjectData[kind][0] == Reference.OBJ_WEAPON and Reference.DefaultObjectData[kind][0] == Reference.OBJ_STANDARD and Reference.DefaultObjectData[kind][0] == Reference.OBJ_ARROW or Reference.DefaultObjectData[kind][0] == Reference.OBJ_BOW:
  841.                     victimsWeaponData = Reference.DefaultObjectData[kind]
  842.                     if len(victimsWeaponData) > 2:
  843.                         weaponF = victimsWeaponData[2]
  844.                     
  845.                 
  846.             
  847.     
  848.     DEF = charF * magicF + shieldF + weaponF
  849.     effective_damage = basic_damage - DEF
  850.     effective_damage = max(effective_damage, 0)
  851.     if PrintFormula == 1:
  852.         print 'Effective Damage Formula = basic_damage - (charF * magicF) - shieldF - weaponF'
  853.         print 'Effective Damage Formula = ' + `basic_damage` + ' - ( ' + `charF` + ' * ' + `magicF` + ' ) - ' + `shieldF` + ' - ' + `weaponF` + ' = ' + `effective_damage`
  854.     
  855.     if Shielded:
  856.         damage_withstood = int(max(basic_damage - DEF - shieldF, 0))
  857.         if not blocking_with_weapon:
  858.             shield = Bladex.GetEntity(me.GetInventory().GetActiveShield())
  859.             
  860.             try:
  861.                 if shield and shield_breakable:
  862.                     if victimsShieldData:
  863.                         if not Reference.EntitiesObjectData.has_key(shield.Name):
  864.                             Reference.EntitiesObjectData[shield.Name] = copy.copy(victimsShieldData)
  865.                             victimsShieldData = Reference.EntitiesObjectData[shield.Name]
  866.                         
  867.                         victimsShieldData[2] = victimsShieldData[2] - damage_withstood
  868.                         if victimsShieldData[2] <= 0.0:
  869.                             victimsShieldData[2] = 0.0
  870.                             if shield.Data.brkobjdata:
  871.                                 BreakMyShield(me.Name)
  872.                                 Shielded = 0
  873.                             
  874.                         elif attacker and attacker.InDestructorAttack == 1 and damage_withstood > shield_breakable:
  875.                             if shield.Data.brkobjdata:
  876.                                 BreakMyShield(me.Name)
  877.                                 Shielded = 0
  878.                                 if PrintFormula == 1:
  879.                                     print 'Shield Breaking in destructor attack, took: ' + `damage_withstood` + ', max: ' + `shield_breakable`
  880.                                 
  881.                             
  882.                         elif not thrown_flag and attacker and attacker.Person and attacker.GotAnmType('sw_react'):
  883.                             attacker.Wuea = Reference.WUEA_ENDED
  884.                             attacker.LaunchAnmType('sw_react')
  885.                         
  886.                     
  887.             except AttributeError:
  888.                 pass
  889.  
  890.             
  891.             try:
  892.                 if shield and shield.Data and shield.Data.AbsorbFunc:
  893.                     shield.Data.AbsorbFunc(AttackerName, WeaponName, damage_withstood)
  894.             except AttributeError:
  895.                 pass
  896.  
  897.         else:
  898.             weapon = Bladex.GetEntity(me.GetInventory().GetActiveWeapon())
  899.             
  900.             try:
  901.                 if weapon and weapon.Data.brkobjdata:
  902.                     if victimsShieldData:
  903.                         if not Reference.EntitiesObjectData.has_key(weapon.Name):
  904.                             Reference.EntitiesObjectData[weapon.Name] = copy.copy(victimsShieldData)
  905.                             victimsShieldData = Reference.EntitiesObjectData[weapon.Name]
  906.                         
  907.                         victimsShieldData[5][4] = victimsShieldData[5][4] - damage_withstood
  908.                         if victimsShieldData[5][4] <= 0.0:
  909.                             victimsShieldData[5][4] = 0.0
  910.                             if weapon.Data.brkobjdata:
  911.                                 BreakMySword(me.Name)
  912.                                 Shielded = 0
  913.                             
  914.                         elif attacker and attacker.InDestructorAttack == 1 and damage_withstood > shield_breakable:
  915.                             if weapon.Data.brkobjdata:
  916.                                 BreakMySword(me.Name)
  917.                                 Shielded = 0
  918.                                 if PrintFormula == 1:
  919.                                     print 'Weapon Breaking in destructor attack, took: ' + `damage_withstood` + ', max: ' + `shield_breakable`
  920.                                 
  921.                             
  922.                         
  923.                     
  924.             except AttributeError:
  925.                 pass
  926.  
  927.             
  928.             try:
  929.                 if weapon and weapon.Data and weapon.Data.AbsorbFunc:
  930.                     weapon.Data.AbsorbFunc(AttackerName, WeaponName, damage_withstood)
  931.             except AttributeError:
  932.                 pass
  933.  
  934.     
  935.     damage_resistance = me.Data.GetResistance(DamageType)
  936.     if damage_resistance > 0.0:
  937.         if PrintFormula == 1:
  938.             print 'Resistance to ' + DamageType + ' at ' + `damage_resistance` + ' reduces the effective_damage to ' + `effective_damage * (1.0 - damage_resistance)`
  939.         
  940.         effective_damage = effective_damage * (1.0 - damage_resistance)
  941.     
  942.     special_damage = 0.0
  943.     if Shielded:
  944.         pass
  945.     if not (effective_damage <= 0):
  946.         effective_damage = effective_damage + special_damage
  947.     
  948.     if not Shielded:
  949.         if (DamageType == 'Impale' or DamageType == 'Slash') and Bladex.GetBloodLevel() > 0:
  950.             me.Data.TakeBleedingImpact = effective_damage
  951.         else:
  952.             me.Data.TakeBleedingImpact = 0
  953.     prevLife = me.Life
  954.     if not (me.Data.Invincibility):
  955.         me.Life = me.Life - effective_damage
  956.     
  957.     if effective_damage > 0:
  958.         if me.Life <= 0:
  959.             pass
  960.         me.Data.Mutilate = DamageType == 'Slash'
  961.     else:
  962.         me.Data.Mutilate = 0
  963.         if not Shielded:
  964.             effective_damage = 1.0
  965.         
  966.     if thrown_flag == 1:
  967.         
  968.         try:
  969.             me.Data.Respond2Thrown(me.Name, AttackerName)
  970.         except AttributeError:
  971.             pass
  972.  
  973.     
  974.     me.Data.RespondToHit(me.Name, AttackerName, effective_damage, DamageZone, Shielded)
  975.     if PlayerHitFunc != '':
  976.         PlayerHitFunc(VictimName, AttackerName, me.Life, prevLife)
  977.     
  978.     if me.Life <= 0.0:
  979.         if AttackerName:
  980.             attacker = Bladex.GetEntity(AttackerName)
  981.             if attacker and attacker.InDestructorAttack == 1 and effective_damage > 1:
  982.                 
  983.                 try:
  984.                     if victimsShieldName:
  985.                         victimsShield = Bladex.GetEntity(victimsShieldName)
  986.                         if victimsShield and victimsShield.Data.brkobjdata:
  987.                             BreakMyShield(me.Name)
  988.                         
  989.                 except:
  990.                     pass
  991.  
  992.                 
  993.                 try:
  994.                     if victimsWeaponName:
  995.                         victimsWeapon = Bladex.GetEntity(victimsWeaponName)
  996.                         if victimsWeapon and victimsWeaponName.Data.brkobjdata:
  997.                             BreakMySword(me.Name)
  998.                         
  999.                 except:
  1000.                     pass
  1001.  
  1002.             
  1003.             if prevLife > 0 and netgame.GetNetState() == 0:
  1004.                 AttackerEntity = Bladex.GetEntity(AttackerName)
  1005.                 if AttackerEntity:
  1006.                     AttackerEntity.Data.OnKilledEnemy(VictimName)
  1007.                 
  1008.             
  1009.         
  1010.     
  1011.     if thrown_flag and weapon.Arrow:
  1012.         weapon.MessageEvent(Reference.MESSAGE_STOP_WEAPON, 0, 0)
  1013.         weapon.Stop()
  1014.         if me and not (me.Data.Mutilate) and DamageNode != -1 and DamageZone != Reference.BODY_HEAD and me.Life > 0.0:
  1015.             me.LinkToNode(weapon, DamageNode)
  1016.             sticktime = 3.0 / weapon.Mass
  1017.             print 'object ' + weapon.Name + ' of kind ' + weapon.Kind + ' of mass ' + `weapon.Mass` + ' sticking for ' + `sticktime` + ' seconds'
  1018.             Bladex.AddScheduledFunc(Bladex.GetTime() + sticktime, StuckWeaponFall, (weapon.Name, VictimName), weapon.Name + '_StuckWeaponFall')
  1019.             if weapon.StickFunc:
  1020.                 weapon.StickFunc(weapon.Name, me.Name)
  1021.             
  1022.         else:
  1023.             weapon.Impulse(0.0, 1.0, 0.0)
  1024.     
  1025.     if me.Data.Mutilate:
  1026.         if PrintFormula == 1:
  1027.             print 'Mutilation'
  1028.         
  1029.     
  1030.     if Bladex.GetMutilationLevel() == 0:
  1031.         return 0
  1032.     else:
  1033.         return me.Data.Mutilate
  1034.  
  1035.