home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Damage.py < prev    next >
Encoding:
Text File  |  2000-10-27  |  43.9 KB  |  1,272 lines

  1. import Reference
  2. import Bladex
  3. import copy
  4. import pdb
  5. import Blood
  6. import CharStats
  7. import Breakings
  8. import whrandom
  9. import Actions
  10. import netgame
  11. import Auras
  12.  
  13. if netgame.GetNetState() != 0:
  14.     import NetWeapon
  15.  
  16. PlayerHitFunc = ""
  17. PrintFormula=0
  18. PrintFatigue=0
  19.  
  20. # Attacking Anim Table   (Damage Factor)
  21. AnimationData={}         #############
  22.  
  23. ###############
  24. #   BARBARO   #
  25. ###############
  26. #inicio
  27. AnimationData['Bar_g2h_08']=   1.0
  28.  
  29. #combos arriba
  30. AnimationData['Bar_g2h_b6kata']=  1.25
  31. AnimationData['Bar_g2h_b7']=  1.4
  32.  
  33. #combos derecha
  34. AnimationData['Bar_g2h_s7']=  1.0
  35. AnimationData['Bar_g2h_02kata']=  1.3
  36. AnimationData['Bar_g2h_b6']=  1.5
  37.  
  38. #combos izquierda
  39. AnimationData['Bar_g2h_11']=   1.0
  40. AnimationData['Bar_g2h_01']=   1.4
  41. AnimationData['Bar_g2h_b29']=   1.5
  42.  
  43. #combos bajo
  44. AnimationData['Bar_g2h_12low']=   1.0
  45. AnimationData['Bar_g2h_02low']=   1.5
  46. AnimationData['Bar_g2h_b6low']=   8.0
  47.  
  48. #bigsword
  49. AnimationData['Bar_g2h_s7']=   1.0
  50. AnimationData['Bar_g2h_19']=  10.0
  51.  
  52. #alfanje
  53. AnimationData['Bar_g2h_13']=    6.0
  54. AnimationData['Bar_g2h_26']=   10.0
  55.  
  56. #flatsword
  57. AnimationData['Bar_g2h_17']=   10.0
  58. AnimationData['Bar_g2h_b7']=   10.0
  59.  
  60. #sawsword
  61. #AnimationData['Bar_g2h_b6kata']=   70.0
  62.  
  63. #firebigsword
  64. AnimationData['Bar_g2h_21_2']=   21.0
  65. AnimationData['Bar_g2h_earthpow']=   60.0
  66.  
  67. #comborapidoextra
  68. AnimationData['Bar_g2h_21_6kata']=   4.0
  69. AnimationData['Bar_g2h_26_b6']=   6.0
  70.  
  71. #comboextra
  72. AnimationData['Bar_g2h_21_7']=   8.7
  73.  
  74. #sin utilizar
  75. AnimationData['Bar_g2h_02']=   10.0
  76.  
  77.  
  78. # HACHAS #
  79. #inicio
  80. AnimationData['Bar_g_axe08']=   1.0
  81.  
  82. #arriba
  83. AnimationData['Bar_g_axe21']=   1.0
  84. AnimationData['Bar_g_axe18']=  10.0
  85. AnimationData['Bar_g_axe08strong']= 30.0
  86.  
  87. #derecha
  88. AnimationData['Bar_g_axe02']=   1.0
  89. AnimationData['Bar_g_axe12']=  10.0
  90. AnimationData['Bar_g_axe34']=  30.0
  91.  
  92. #izquierda
  93. AnimationData['Bar_g_axe13']=   1.0
  94. AnimationData['Bar_g_axe01']=  10.0
  95. AnimationData['Bar_g_axe32']=  30.0
  96.  
  97. #abajo
  98. AnimationData['Bar_g_axe111']=   1.0
  99. AnimationData['Bar_g_axe211']=  10.0
  100. AnimationData['Bar_g_axe_2katab6low']=  30.0
  101.  
  102. #comboaleatorioextra
  103. AnimationData['Bar_g_axe31']=   1.0
  104.  
  105. #hacharrajada
  106. AnimationData['Bar_g_axe_26kata']=   9.0
  107. AnimationData['Bar_g_axe_3s2']=   9.0
  108.  
  109. #eclipse
  110. AnimationData['Bar_g_axe_b2kata']=   8.0
  111.  
  112. #hacha2hojas
  113. AnimationData['Bar_g_axe_32kata_b2']=   8.0
  114.  
  115. #iceaxe
  116. AnimationData['Bar_g_axe30']=   34.0
  117.  
  118. #sin utilizar
  119. AnimationData['Bar_g_axe28']=   1.0
  120.  
  121. #esquivas y ataque 180
  122. AnimationData['Bar_g2h_d_r']=   2.0
  123. AnimationData['Bar_g2h_d_l']=   2.0
  124. AnimationData['Bar_g_d_r_axe']=   2.0
  125. AnimationData['Bar_g_d_l_axe']=   2.0
  126. AnimationData['Bar_g2h_back']=   2.0
  127.  
  128. #golpes sin armas
  129. AnimationData['Bar_g_punch1']=   2.0
  130. AnimationData['Bar_g_punch2']=   2.0
  131. AnimationData['Bar_g_punch3']=   2.0
  132. AnimationData['Bar_g_punch4']=   2.0
  133. AnimationData['Bar_g_kick']=   2.0
  134.  
  135. #armas no afines
  136. AnimationData['Bar_g_07']=   1.0
  137. AnimationData['Bar_g_11']=   1.3
  138. AnimationData['Bar_g_16']=   1.4
  139. AnimationData['Bar_g_17']=   1.2
  140. AnimationData['Bar_g_18']=   1.2
  141. AnimationData['Bar_g_06lowkata_new']=   8.0
  142.  
  143. ###############
  144. #  CABALLERO  #
  145. ###############
  146. AnimationData['Kgt_g_08_new']=  1.0
  147. AnimationData['Kgt_g_01_7_new']=   1.5
  148. AnimationData['Kgt_g_18_11_22_new']=  1.0
  149. AnimationData['Kgt_g_07_new']=  1.0
  150. AnimationData['Kgt_g_s3_new']=   1.0
  151. AnimationData['Kgt_g_12_new']=  1.0
  152. AnimationData['Kgt_g_02_new']=   1.0
  153. AnimationData['Kgt_g_12_7_s1new']=   1.0
  154. AnimationData['Kgt_g_sb25_new']=   1.0
  155. AnimationData['Kgt_g_b06_new']=  1.0
  156. AnimationData['Kgt_g_19_bs1_new']=   1.0
  157. AnimationData['Kgt_g_01low_new']=  1.0
  158. AnimationData['Kgt_g_22lowkata_new']=   1.0
  159. AnimationData['Kgt_g_s28kata_new']=   1.0
  160. AnimationData['Kgt_g_06lowkata_new']=   1.0
  161. AnimationData['Kgt_g_09_07_s6low_new']=  1.0
  162. AnimationData['Kgt_g_28new']=   4.0
  163. AnimationData['Kgt_g_b32kata_new']=  1.0
  164. AnimationData['Kgt_g_3s9_6new']=  1.0
  165. AnimationData['Kgt_g_s19_new']=   1.0
  166. AnimationData['Kgt_g_29_3new']=   1.0
  167. AnimationData['Kgt_g_21_6_s8new']=   1.0
  168. AnimationData['Kgt_g_32_5_3new']=   1.0
  169. AnimationData['Kgt_g_27kata_new']=   1.0
  170. AnimationData['Kgt_g_back']=   1.0
  171.  
  172. AnimationData['Kgt_g_bad_axe']=   1.6
  173. AnimationData['Kgt_g_bad_sword']=   1.0
  174. AnimationData['Kgt_g_bad_sword2']=   1.3
  175. AnimationData['Kgt_g_bad_sword3']=   1.5
  176. AnimationData['Kgt_g_bad_spear']=   1.9
  177. AnimationData['Kgt_g_bad_spear2']=   1.9
  178.  
  179. AnimationData['Kgt_g_punch1']=   1.2
  180. AnimationData['Kgt_g_punch2']=   1.2
  181. AnimationData['Kgt_g_kick']=   1.2
  182.  
  183. AnimationData['Kgt_g_d_r']=   3.5
  184. AnimationData['Kgt_g_d_l']=   3.5
  185.  
  186. AnimationData['Kgt_g_magic']=   35.0
  187. AnimationData['Kgt_g_magic2']=  15.0
  188. AnimationData['Kgt_g_08']=   1.0
  189. AnimationData['Kgt_g_06']=   1.3
  190. AnimationData['Kgt_g_02']=   1.2
  191. AnimationData['Kgt_g_07']=   1.3
  192. AnimationData['Kgt_g_05']=   1.2
  193.  
  194. #############
  195. #  AMAZONA  #
  196. #############
  197. #inicio
  198. AnimationData['Amz_g_spears1']=  1.0
  199.  
  200. #arriba
  201. AnimationData['Amz_g_spear08']=  1.0
  202.  
  203. #derecha
  204. AnimationData['Amz_g_spear12']=  1.0
  205.  
  206. #izquierda
  207. AnimationData['Amz_g_spears6']=  1.5
  208.  
  209. #abajo
  210. AnimationData['Amz_g_spear16low']=  1.0
  211.  
  212.  
  213. #EXRA ARMAS
  214. #BO
  215. AnimationData['Amz_g_spears8']=  5.0
  216. #BICHERO
  217. AnimationData['Amz_g_spear_2katab6low']= 1.0
  218. #LANZA
  219. AnimationData['Amz_g_spear19']= 1.0
  220. #NAGINATA
  221. AnimationData['Amz_g_spear22']=  1.0
  222. #TRIDENTE
  223. AnimationData['Amz_g_spear09']=  1.0
  224. #AXPEAR
  225. AnimationData['Amz_g_spear32kata']= 1.0
  226. #DEATHBO
  227. AnimationData['Amz_g_spear_kata23']=   1.0
  228. #CROSSPEAR
  229. AnimationData['Amz_g_spear13']=  1.0
  230. #HACHACUCHILLA
  231. AnimationData['Amz_g_spear3s2']= 1.0
  232. #CRUSHBO
  233. AnimationData['Amz_g_spear_21']=   1.0
  234. #ARPON
  235. AnimationData['Amz_g_spear_b29']= 1.0
  236. #NAGINATA2
  237. AnimationData['Amz_g_spear33']=  1.0
  238. #LANZAHANCHA
  239. AnimationData['Amz_g_spear_sb11']=   1.0
  240. #FIREBO
  241. AnimationData['Amz_g_spear_b6_26']= 1.0
  242. #STEELFEATHER
  243. AnimationData['Amz_g_spear19_bs1']=   1.0
  244. #ICEWAND
  245. AnimationData['Amz_g_spear16']=   1.0
  246.  
  247. #QUEENSWORD
  248. AnimationData['Amz_g_06lowkata_new']=  1.0
  249.  
  250. #extragolpe
  251. AnimationData['Amz_g_spear26kata']= 1.4
  252.  
  253. #golpes torpes
  254. AnimationData['Amz_g_bad_axe']=  1.0
  255. AnimationData['Amz_g_bad_sword']=  1.0
  256. AnimationData['Amz_g_bad_sword2']=  1.0
  257. AnimationData['Amz_g_bad_sword3']= 1.0
  258.  
  259. #golpes arma 1 mano
  260. AnimationData['Amz_g_09']=   1.0
  261. AnimationData['Amz_g_05']=   1.2
  262. AnimationData['Amz_g_02']=   1.2
  263. AnimationData['Amz_g_06']=   1.2
  264. AnimationData['Amz_g_07']=   1.2
  265.  
  266.  
  267. #golpes sin armas
  268. AnimationData['Amz_g_punch2']=   1.0
  269. AnimationData['Amz_g_kick1']=   1.5
  270. AnimationData['Amz_g_kick2']=   1.0
  271.  
  272. #sin utilizar
  273. AnimationData['Amz_g_spear111']=   1.0
  274. AnimationData['Amz_g_spear17']=   1.0
  275. AnimationData['Amz_g_spear19_13']=   1.0
  276. AnimationData['Amz_g_spear_b06']=   1.0
  277. AnimationData['Amz_g_spear_bs21']=   1.0
  278. AnimationData['Amz_g_spear02']=   1.0
  279.  
  280.  
  281. ###########
  282. #  ENANO  #
  283. ###########
  284. AnimationData['Dwf_g_08']=   1.5
  285. AnimationData['Dwf_g_01']=   1.0
  286. AnimationData['Dwf_g_01low_new']=   1.0
  287. AnimationData['Dwf_g_02']=   1.0
  288. AnimationData['Dwf_g_05']=   1.0
  289. AnimationData['Dwf_g_06']=   1.0
  290. AnimationData['Dwf_g_07']=   1.0
  291. AnimationData['Dwf_g_09']=   1.0
  292. AnimationData['Dwf_g_01a']=   1.0
  293. AnimationData['Dwf_g_02a']=   1.0
  294. AnimationData['Dwf_g_05a']=   1.0
  295. AnimationData['Dwf_g_06a']=   1.0
  296. AnimationData['Dwf_g_07a']=   1.0
  297. AnimationData['Dwf_g_09a']=   1.0
  298. AnimationData['Dwf_g_18']=   1.0
  299. AnimationData['Dwf_g_15']=   1.0
  300. AnimationData['Dwf_g_14']=   1.0
  301. AnimationData['Dwf_g_13']=   1.0
  302. AnimationData['Dwf_g_16']=   1.0
  303. AnimationData['Dwf_g_11']=   1.0
  304. AnimationData['Dwf_g_12']=   1.0
  305. AnimationData['Dwf_g_17']=   1.0
  306. AnimationData['Dwf_g_21']=   1.5
  307. AnimationData['Dwf_g_22']=   1.5
  308. AnimationData['Dwf_g_23']=   1.5
  309. AnimationData['Dwf_g_26']=   1.5
  310. AnimationData['Dwf_g_27']=   1.5
  311. AnimationData['Dwf_g_31']=   1.0
  312.  
  313. AnimationData['Dwf_g_back']=   1.0
  314. AnimationData['Dwf_g_s18_2h']=   1.0
  315. AnimationData['Dwf_g_32_5_3new']=   1.0
  316. AnimationData['Dwf_g_27kata']=   1.0
  317. AnimationData['Dwf_g_12low']=   1.0
  318. AnimationData['Dwf_g_s11']=   1.0
  319.  
  320. #Golpes Torpes
  321. AnimationData['Dwf_g_bad_axe']=   1.0
  322. AnimationData['Dwf_g_bad_spear']=   1.0
  323. AnimationData['Dwf_g_bad_spear2']=   1.0
  324. AnimationData['Dwf_g_bad_sword']=   1.0
  325. AnimationData['Dwf_g_bad_sword1']=   1.0
  326. AnimationData['Dwf_g_bad_sword2']=   1.0
  327. AnimationData['Dwf_g_bad_sword3']=   1.0
  328. AnimationData['Dwf_g_bad_no']=   1.0
  329. AnimationData['Dwf_g_bad_1h']=   1.0
  330.  
  331. #Ataques instantaneos
  332. AnimationData['Dwf_g_draw_rlx']=   1.0
  333. AnimationData['Dwf_g_draw_run']=   1.0
  334.  
  335. #Esquivas
  336. AnimationData['Dwf_g_d_r']=   2.0
  337. AnimationData['Dwf_g_d_l']=   2.0
  338.  
  339. #golpes sin armas
  340. AnimationData['Dwf_g_punch1']=   1.0
  341. AnimationData['Dwf_g_punch2']=   1.0
  342. AnimationData['Dwf_g_kick']=   1.0
  343.  
  344.  
  345. ##########
  346. #  ORCO  #
  347. ##########
  348. AnimationData['Ork_g_01']=   1.0
  349. AnimationData['Ork_g_02']=   1.0
  350. AnimationData['Ork_g_06']=   1.0
  351. AnimationData['Ork_g_15']=   1.2
  352. AnimationData['Ork_g_16']=   1.5
  353. AnimationData['Ork_g_18']=   1.8
  354. ###############
  355. #  GRAN ORCO  #
  356. ###############
  357. AnimationData['Gok_g_01']=   1.0
  358. AnimationData['Gok_g_02']=   1.2
  359. AnimationData['Gok_g_06']=   1.3
  360. AnimationData['Gok_g_15']=   2.0
  361. AnimationData['Gok_g_16']=   2.5
  362. AnimationData['Gok_g_18']=   3.0
  363.  
  364. ###############
  365. #  ESQUELETO  #
  366. ###############
  367. AnimationData['Skl_g_01']=    1.0
  368. AnimationData['Skl_g_02']=    1.2
  369. AnimationData['Skl_g_07']=    1.3
  370. AnimationData['Skl_g_09']=    1.5
  371. AnimationData['Skl_g_16']=    2.1
  372. AnimationData['Skl_g_18']=    1.8
  373. AnimationData['Skl_g_22']=    2.0
  374.  
  375. ##########
  376. #  LICH  #
  377. ##########
  378. AnimationData['Lch_g_12']=    1.8
  379. AnimationData['Lch_g_13']=    1.8
  380. AnimationData['Lch_g_16']=    1.8
  381. AnimationData['Lch_g_18']=    1.8
  382.  
  383. ###########
  384. #  ZOMBI  #
  385. ###########
  386. AnimationData['Zkn_g_12']=    2.6
  387. AnimationData['Zkn_g_13']=    2.8
  388. AnimationData['Zkn_g_16']=    2.6
  389. AnimationData['Zkn_g_18']=    2.7
  390.  
  391. #######################
  392. #  Caballero Traidor  #
  393. #######################
  394. AnimationData['Tkn_g_01']=    1.0
  395. AnimationData['Tkn_g_02']=    1.2
  396. AnimationData['Tkn_g_07']=    1.3
  397. AnimationData['Tkn_g_08']=    1.4
  398. AnimationData['Tkn_g_13']=    1.6
  399. AnimationData['Tkn_g_14']=    2.3
  400. AnimationData['Tkn_g_16']=    2.5
  401. AnimationData['Tkn_g_18']=    2.6
  402.  
  403. #####################
  404. #  Caballero Negro  #
  405. #####################
  406. AnimationData['Dkn_g_01']=    1.0
  407. AnimationData['Dkn_g_02']=    1.2
  408. AnimationData['Dkn_g_07']=    1.2
  409. AnimationData['Dkn_g_08']=    1.3
  410. AnimationData['Dkn_g_13']=    1.5
  411. AnimationData['Dkn_g_14']=    1.6
  412. AnimationData['Dkn_g_16']=    1.8
  413. AnimationData['Dkn_g_18']=    1.95
  414.  
  415. ############
  416. #  RAGNAR  #
  417. ############
  418. AnimationData['Rgn_g_01']=    1.0
  419. AnimationData['Rgn_g_02']=    1.0
  420. AnimationData['Rgn_g_03']=    1.0
  421. AnimationData['Rgn_g_07']=    1.0
  422. AnimationData['Rgn_g_d_r']=   1.5
  423. AnimationData['Rgn_g_d_l']=   1.5
  424. AnimationData['Rgn_g_escape']=   2.5
  425. AnimationData['Rgn_g_17']=    1.6
  426. AnimationData['Rgn_g_21']=    1.5
  427.  
  428. #################
  429. #  TROLL NEGRO  #
  430. #################
  431. AnimationData['Trl_g_01']=    1.0
  432. AnimationData['Trl_g_02']=    1.2
  433. AnimationData['Trl_g_04']=    1.4
  434. AnimationData['Trl_g_06']=    1.6
  435. AnimationData['Trl_g_12']=    2.8
  436. AnimationData['Trl_g_18']=    3.4
  437. AnimationData['Trl_g_19']=    1.8
  438. AnimationData['Trl_g_31']=    4.8
  439.  
  440. ###############
  441. #  MINOTAURO  #
  442. ###############
  443. AnimationData['Min_g_01']=    1.0
  444. AnimationData['Min_g_07']=    1.2
  445. AnimationData['Min_g_08']=    1.5
  446. AnimationData['Min_g_12']=    3.0
  447. AnimationData['Min_g_31']=    2.8
  448.  
  449. ####################
  450. #  Caballero CAOS  #
  451. ####################
  452. AnimationData['Chk_g_magic']=    15.0
  453. AnimationData['Chk_g_01']=    1.0
  454. AnimationData['Chk_g_02']=    1.2
  455. AnimationData['Chk_g_07']=    1.3
  456. AnimationData['Chk_g_08']=    1.2
  457. AnimationData['Chk_g_12']=    20.0
  458. AnimationData['Chk_g_18']=    20.0
  459. AnimationData['Chk_g_31']=    30.0
  460.  
  461. ##################
  462. #  GOLEM PIEDRA  #
  463. ##################
  464. AnimationData['Glm_g_01']=    25.0
  465. AnimationData['Glm_g_114']=    40.0
  466. AnimationData['Glm_g_12']=    40.0
  467. AnimationData['Glm_g_21']=    20.0
  468. AnimationData['Glm_g_21_27']=    15.0
  469. AnimationData['Glm_g_31']=    60.0
  470. AnimationData['Glm_g_spit']=    20.0
  471. AnimationData['Glm_g_1tw']=    20.0
  472.  
  473. ###################
  474. #  DEMONIO MENOR  #
  475. ###################
  476. AnimationData['Ldm_g_spit']=    3.5
  477. AnimationData['Ldm_g_03']=    1.0
  478. AnimationData['Ldm_g_06']=    1.2
  479. AnimationData['Ldm_g_07']=    1.3
  480. AnimationData['Ldm_g_22']=   3.0
  481. AnimationData['Ldm_g_27']=   2.5
  482. AnimationData['Ldm_g_jumpl']=    1.3
  483. AnimationData['Ldm_g_jumpr']=    1.3
  484.  
  485.  
  486. ######
  487. #AnimationData['g_01']=   0.3
  488. #AnimationData['g_02']=   0.3
  489. AnimationData['g_03']=   0.3
  490. AnimationData['g_04']=   0.3
  491. AnimationData['g_05']=   0.3
  492. AnimationData['g_06']=   0.3
  493. #AnimationData['g_07']=   0.3
  494. #AnimationData['g_08']=   0.3
  495. AnimationData['g_09']=   0.3
  496. AnimationData['g_10']=   1.0
  497. AnimationData['g_11']=   1.0
  498. AnimationData['g_12']=   1.0
  499. #AnimationData['g_13']=   1.0
  500. #AnimationData['g_14']=   1.0
  501. AnimationData['g_15']=   1.0
  502. #AnimationData['g_16']=   1.5
  503. AnimationData['g_17']=   1.0
  504. #AnimationData['g_18']=   1.0
  505. AnimationData['g_19']=   1.0
  506. AnimationData['g_21']=   2.5
  507. AnimationData['g_22']=   2.5
  508. AnimationData['g_23']=   2.5
  509. AnimationData['g_24']=   2.5
  510. AnimationData['g_25']=   2.5
  511. AnimationData['g_26']=   2.5
  512. AnimationData['g_27']=   2.5
  513. AnimationData['g_31']=   3.5
  514.  
  515. #AnimationData['g_magic']=   5.3
  516. #AnimationData['g_magic2']=   5.3
  517.  
  518. ################################################################################
  519. # Special Damage Functions
  520. # takes:  special damage data, victim resistance, effective normal damage, standard CalcDamage args
  521. # returns: damage points to inflict now.
  522.  
  523. def InflictFireDamage (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):    
  524.     # Do nothing if not activated by combo
  525.     fire_activated=1
  526.  
  527.     if fire_activated:
  528.  
  529.         # Yellow/Red halo effect on victim
  530.         time=Bladex.GetTime()
  531.         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))
  532.         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))
  533.         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))
  534.         prtl=Bladex.CreateEntity(aura.Name+"Particles", "Entity Particle System Dperson", 0, 0, 0)
  535.         prtl.PersonName=VictimName
  536.         prtl.ParticleType="Llamita2"
  537.         prtl.PPS=400
  538.         prtl.Velocity=0.0, 0.0, 0.0
  539.         prtl.NormalVelocity=2.0
  540.         prtl.RandomVelocity=0.0
  541.         prtl.YGravity=-200.0
  542.         prtl.Friction=0.02
  543.         prtl.FollowFactor=0.0
  544.         prtl.Time2Live=21
  545.         prtl.DeathTime=Bladex.GetTime()+0.2
  546.  
  547.         return special[1]*(1.0-special_resistance)
  548.  
  549.     return 0.0
  550.  
  551. def InflictIceDamage (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  552.     # Do nothing if not activated by combo
  553.     ice_activated=1
  554.  
  555.     if ice_activated:
  556.  
  557.         # Blue/White halo effect on victim
  558.         time=Bladex.GetTime()
  559.         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))
  560.         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))
  561.         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))
  562.  
  563.         return special[1]*(1.0-special_resistance)
  564.  
  565.     return 0.0
  566.  
  567. def InflictVenomDamage (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  568.     if not (Shielded and effective_damage<=0.0):
  569.         victim= Bladex.GetEntity(VictimName)
  570.         if victim and victim.Person and victim.Data:
  571.             # Effects in Basic_Funcs.py        
  572.             venom_damage= special[1]
  573.             victim.Data.EnVenom (VictimName, venom_damage, AttackerName)
  574.     
  575.     return 0         # Does not inflict immediate damage
  576.  
  577. def InflictDrainDamage (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  578.     weapon= Bladex.GetEntity(WeaponName)
  579.     victim= Bladex.GetEntity(VictimName)
  580.     holder= Bladex.GetEntity(AttackerName)        
  581.     LastDamage= min (effective_damage, victim.Life)
  582.     if weapon and victim and holder and LastDamage>0:
  583.         # weapon gives life to user
  584.         holder.Life= min(holder.Life+LastDamage, CharStats.GetCharMaxLife(holder.Kind, holder.Level))
  585.         
  586.         # Red halo effect on weapon
  587.         # ...
  588.         
  589.         # Can we do a streaming blood effect
  590.         # ...        
  591.         time=Bladex.GetTime()
  592.         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))    
  593.         # expand the blood through the skin    
  594.         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))    
  595.         # disperse the blood through the air
  596.         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))
  597.         
  598.         # more aura effects on holder in ItemTypes.py:VampWeapon
  599.         
  600.     return 0         # Does not inflict extra damage, just gives the life drained to the user
  601.  
  602. def InflictElectricDamage (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):    
  603.     # halo effect on victim, must be switched off on death
  604.     return special[1]*(1.0-special_resistance)
  605.  
  606. def InflictBladeDamage (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  607.     # Do nothing if not activated by combo
  608.     blade_activated=1
  609.  
  610.     if blade_activated:
  611.  
  612.         time=Bladex.GetTime()
  613.         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))
  614.         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))
  615.         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))
  616.         prtl=Bladex.CreateEntity(aura.Name+"Particles", "Entity Particle System Dperson", 0, 0, 0)
  617.         prtl.PersonName=VictimName
  618.         prtl.ParticleType="BrillosBladeSword"
  619.         prtl.PPS=200
  620.         prtl.Velocity=0.0, 0.0, 0.0
  621.         prtl.NormalVelocity=5.0
  622.         prtl.RandomVelocity=0.0
  623.         prtl.YGravity=0.0
  624.         prtl.Friction=0.01
  625.         prtl.FollowFactor=0.0
  626.         prtl.Time2Live=8
  627.         prtl.DeathTime=Bladex.GetTime()+0.4
  628.  
  629.         return special[1]*(1.0-special_resistance)
  630.  
  631.     return 0.0
  632.  
  633.  
  634. SpecialDamageFuncs={}
  635. SpecialDamageFuncs['Fire']    = InflictFireDamage
  636. SpecialDamageFuncs['Ice']     = InflictIceDamage
  637. SpecialDamageFuncs['Venom']   = InflictVenomDamage
  638. SpecialDamageFuncs['Drain']   = InflictDrainDamage
  639. SpecialDamageFuncs['Electric']= InflictElectricDamage
  640. SpecialDamageFuncs['Blade']   = InflictBladeDamage
  641.  
  642.  
  643. def DropInvalidObjectsOnImpact(EntityName):
  644.     me=Bladex.GetEntity(EntityName)
  645.     if me:
  646.         Actions.UnGraspString (EntityName,"UnGraspString")
  647.         Actions.Stop_Weapon (EntityName,"Stop_Weapon")
  648.         if me.InvRight:
  649.             right_type= Reference.GiveObjectFlag(me.InvRight)
  650.             if right_type==Reference.OBJ_ITEM \
  651.             or right_type==Reference.OBJ_SHIELD \
  652.             or right_type==Reference.OBJ_QUIVER \
  653.             or right_type==Reference.OBJ_BOW \
  654.             or right_type==Reference.OBJ_KEY \
  655.             or right_type==Reference.OBJ_SPECIALKEY \
  656.             or right_type==Reference.OBJ_USEME \
  657.             or right_type==Reference.OBJ_SPECIALKEY \
  658.             or right_type==Reference.OBJ_TABLET:
  659.                 Actions.DropReleaseEventHandler (EntityName, "DropRightEvent")
  660.         if me.InvLeft:
  661.             left_type= Reference.GiveObjectFlag(me.InvLeft)
  662.             if left_type==Reference.OBJ_ITEM \
  663.             or (left_type==Reference.OBJ_WEAPON and me.InvRight != me.InvLeft) \
  664.             or (left_type==Reference.OBJ_STANDARD and me.InvRight != me.InvLeft) \
  665.             or left_type==Reference.OBJ_QUIVER \
  666.             or left_type==Reference.OBJ_KEY \
  667.             or left_type==Reference.OBJ_SPECIALKEY \
  668.             or left_type==Reference.OBJ_USEME \
  669.             or left_type==Reference.OBJ_SPECIALKEY \
  670.             or left_type==Reference.OBJ_TABLET:
  671.                 Actions.DropReleaseEventHandler (EntityName, "DropLeftEvent")
  672.  
  673.  
  674. def BreakMyShield(EntityName):
  675.     me=Bladex.GetEntity(EntityName)
  676.     if me.InvLeft<>"":        
  677.         if Breakings.ExplodeSpecialObject ( me.InvLeft , 24000.0)==1:
  678.             if Reference.EntitiesObjectData.has_key(me.InvLeft):
  679.                 del Reference.EntitiesObjectData[me.InvLeft]
  680.             DropInvalidObjectsOnImpact (EntityName)
  681.             me.Wuea=Reference.WUEA_ENDED
  682.             me.LaunchAnmType("df_s_broken")
  683.             inv=me.GetInventory()
  684.             inv.RemoveShield(me.InvLeft)
  685.             inv.LinkLeftHand("None")
  686.             if me.Data.NPC:
  687.                 me.Data.ResetCombat (EntityName)
  688.  
  689.  
  690. def BreakMySword(EntityName):
  691.     me=Bladex.GetEntity(EntityName)
  692.     if me.InvRight<>"":        
  693.         Actions.Stop_Weapon (EntityName,"Stop_Weapon")
  694.         if Breakings.ExplodeSpecialObject ( me.InvRight , 24000.0)==1:
  695.             if Reference.EntitiesObjectData.has_key(me.InvRight):
  696.                 del Reference.EntitiesObjectData[me.InvRight]
  697.             DropInvalidObjectsOnImpact (EntityName)
  698.             me.Wuea=Reference.WUEA_ENDED
  699.             me.LaunchAnmType("sword_broken")
  700.             inv=me.GetInventory()
  701.             inv.RemoveWeapon(me.InvRight)
  702.             inv.LinkRightHand("None")
  703.             if me.Data.NPC:
  704.                 me.Data.ResetCombat (EntityName)
  705.  
  706. def StuckWeaponFall (WeaponName, TargetName):
  707.     weapon= Bladex.GetEntity(WeaponName)
  708.     if weapon:        
  709.         if weapon.Parent==TargetName:
  710.             target= Bladex.GetEntity(TargetName)
  711.             if target:
  712.                 target.Unlink(weapon)
  713.                 if target.Person:
  714.                     weapon.ExcludeHitFor(target)
  715.                 elif target.Parent:
  716.                     parent= Bladex.GetEntity(target.Parent)
  717.                     if parent and parent.Person:
  718.                         weapon.ExcludeHitFor(parent)
  719.                 weapon.Impulse(0.0, 1.0, 0.0)
  720.  
  721. def CalculateFatigue(EntityName, AnimName):
  722.     me= Bladex.GetEntity(EntityName)    
  723.  
  724.     if me:
  725.         current_energy= me.Energy
  726.         if current_energy > 0.0:
  727.             
  728.             charF = 0
  729.             animF = 1.0
  730.             weaponF = 0
  731.             
  732.             #
  733.             # The ATTACK....
  734.             #
  735.             
  736.             ######################################################################################    
  737.             # We start with the weapon component #
  738.             ######################################################################################    
  739.             weaponData= None
  740.             WeaponName= me.GetInventory().GetActiveWeapon()
  741.             if not WeaponName or WeaponName==EntityName and AnimName=='g_draw_rlx' or AnimName=='g_draw_run':
  742.                 WeaponName= me.InvRightBack
  743.             
  744.             if WeaponName:    
  745.                 if Reference.EntitiesObjectData.has_key(WeaponName):
  746.                     if Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_WEAPON or Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_STANDARD:
  747.                         weaponData = Reference.EntitiesObjectData[WeaponName]
  748.                         if len (weaponData) > 1:                    
  749.                             weaponF = weaponData[1]
  750.                 else:
  751.                     weapon= Bladex.GetEntity(WeaponName)
  752.                     if weapon:
  753.                         kind = weapon.Kind    
  754.                         if Reference.DefaultObjectData.has_key(kind):
  755.                             if Reference.DefaultObjectData[kind][0] == Reference.OBJ_WEAPON or Reference.DefaultObjectData[kind][0] == Reference.OBJ_STANDARD:
  756.                                 weaponData = Reference.DefaultObjectData[kind]
  757.                                 if len (weaponData) > 1:
  758.                                     weaponF = weaponData[1]    
  759.             
  760.             ######################################################################################
  761.             
  762.             ######################################################################################
  763.             # character type components #
  764.             ######################################################################################
  765.             if netgame.GetNetState() == 0:
  766.                 charF=CharStats.GetCharDamageData(me.CharType,me.Level)
  767.             else:
  768.                 charF=NetWeapon.GetDamage(me.CharType,me.Data.NetLevel)
  769.             
  770.             ######################################################################################
  771.             # Animation component #
  772.             ######################################################################################
  773.             me.LaunchAnimation(AnimName)
  774.             # Animation component #
  775.             if AnimationData.has_key(me.AnimFullName):
  776.                 animF = AnimationData[me.AnimFullName]
  777.             elif AnimationData.has_key(me.AnimName):
  778.                 animF = AnimationData[me.AnimName]
  779.             
  780.             ######################################################################################
  781.             
  782.             lvl= me.Level+1
  783.             energy_cost= max((charF + weaponF) * animF, 0.0)+me.Data.Energy2Lose
  784.             max_energy= CharStats.GetCharMaxEnergy(me.Kind, me.Level)
  785.             me.Data.LoseEnergyRate=0.0
  786.             if PrintFatigue:
  787.                 print "energy_cost= (charF("+`charF`+") + weaponF("+`weaponF`+")) * (animF("+me.AnimFullName+"="+`animF`+") + prev_energy2lose("+`me.Data.Energy2Lose`+")= "+`energy_cost`
  788.                 print "max_energy= "+`max_energy`+", current_energy= "+`me.Energy`
  789.             if energy_cost<max_energy:
  790.                 me.Data.Energy2Lose= energy_cost
  791.                 
  792.                 if energy_cost>me.Energy:
  793.                     # Launch a clumsy animation instead
  794.                     weapon= Bladex.GetEntity(me.GetInventory().GetActiveWeapon())
  795.                     if weapon and not weapon.Person:
  796.                         weapon_flag= Reference.GiveWeaponFlag(WeaponName)
  797.                         if weapon_flag==Reference.W_FLAG_2W: clumsy_anm= "g_bad_sword"
  798.                         elif weapon_flag==Reference.W_FLAG_AXE: clumsy_anm= "g_bad_axe"
  799.                         elif weapon_flag==Reference.W_FLAG_SP: clumsy_anm= "g_bad_spear"
  800.                         else: clumsy_anm= "g_bad_1h"
  801.                     else: clumsy_anm= "g_bad_no"
  802.                     me.Wuea=Reference.WUEA_ENDED                    
  803.                     me.LaunchAnmType(clumsy_anm)
  804.                     Actions.ReportMsg ("You need more energy for this attack")
  805.                 
  806.                 try: anim_duration= Bladex.GetAnimationDuration(me.AnimFullName)
  807.                 except RuntimeError:
  808.                     print me.AnimFullName + " has not been defined for character "+ me.Kind
  809.                     anim_duration= 0.3
  810.  
  811.                 if anim_duration>0.0: me.Data.LoseEnergyRate= energy_cost / anim_duration
  812.                 else: me.Data.LoseEnergyRate= 0.0                
  813.                 
  814.                 return 1
  815.             else: 
  816.                 Actions.ReportMsg ("You need more energy for this attack")
  817.                 me.Wuea=Reference.WUEA_ENDED
  818.         me.InterruptCombat()
  819.         me.RaiseEvent("Interrupt")
  820.         return 1
  821.     return 0
  822.  
  823.  
  824.  
  825. def CheckRightHandToDrop(EntityName):
  826.     me= Bladex.GetEntity(EntityName)
  827.     if not me.InvRight:
  828.         return
  829.  
  830.     two_handed_on_right=0
  831.     if Actions.IsRightHandWeaponObject(EntityName):
  832.         w_flag=Reference.GiveWeaponFlag(me.InvRight)
  833.         if w_flag<>Reference.W_FLAG_1H:
  834.             two_handed_on_right=1
  835.  
  836.     special_to_drop=0
  837.     flag=Reference.GiveObjectFlag(me.InvRight)
  838.     if flag==Reference.OBJ_KEY or flag==Reference.OBJ_SPECIALKEY or flag==Reference.OBJ_USEME:
  839.         print "right 2 drop"
  840.         special_to_drop=1
  841.  
  842.     if special_to_drop==1 or (two_handed_on_right and me.InvLeft and me.InvRight<>me.InvLeft):
  843.         if Actions.TryDropRight(EntityName):
  844.             Actions.DropReleaseEventHandler(EntityName, "DropRightEvent")
  845.             if me.InvRight:
  846.                 #print "...but did not work"
  847.                 return FALSE
  848.  
  849.  
  850.  
  851.  
  852. def CalculateDamage(VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded):
  853.     #pdb.set_trace()
  854.  
  855.  
  856.     CheckRightHandToDrop(VictimName)
  857.  
  858.     # Additive vars set to 0
  859.     charF = 0
  860.     animF = 1.0
  861.     weaponF = 0    
  862.     randomF = 0
  863.     throwF = 0
  864.     shieldF = 0
  865.     bowF = 0
  866.     
  867.     # Multiplicative vars set to 1.0
  868.     locationF = 1.0
  869.     magicF = 1.0        
  870.     thrown_flag= 0    
  871.     
  872.     #
  873.     # The ATTACK....
  874.     #
  875.     
  876.     ######################################################################################    
  877.     # We start with the weapon component, there is always a weapon... #
  878.     ######################################################################################    
  879.     weaponData= None
  880.     if WeaponName:    
  881.         if Reference.EntitiesObjectData.has_key(WeaponName):
  882.             if Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_WEAPON or Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_STANDARD or Reference.EntitiesObjectData[WeaponName][0] == Reference.OBJ_ARROW:
  883.                 weaponData = Reference.EntitiesObjectData[WeaponName]
  884.                 if len (weaponData) > 1:
  885.                     weaponF = weaponData[1]
  886.         else:
  887.             kind = Bladex.GetEntity(WeaponName).Kind
  888.             if Reference.DefaultObjectData.has_key(kind):
  889.                 if Reference.DefaultObjectData[kind][0] == Reference.OBJ_WEAPON or Reference.DefaultObjectData[kind][0] == Reference.OBJ_STANDARD or Reference.DefaultObjectData[kind][0] == Reference.OBJ_ARROW:
  890.                     weaponData = Reference.DefaultObjectData[kind]
  891.                     if len (weaponData) > 1:
  892.                         weaponF = weaponData[1]
  893.         
  894.         if (not AttackerName) and weaponData and len (weaponData) > 2:
  895.             if PrintFormula==1:
  896.                 print "Possible thrown weapon" # get thowF from weapon
  897.             
  898.             weapon= Bladex.GetEntity(WeaponName)
  899.             if weapon:                    
  900.                 try:
  901.                     if weapon.Data and weapon.Data.ThrownBy:
  902.                         AttackerName= weapon.Data.ThrownBy.Name
  903.                         thrown_flag= 1
  904.                         if len (weaponData) > 3:
  905.                             throwF = weaponData[3]
  906.                 except AttributeError:    # No ThrownBy set, could be an arrow thrown by a trap
  907.                     if weapon.Arrow:
  908.                         thrown_flag= 1
  909.                         if len (weaponData) > 3:
  910.                             throwF = weaponData[3]
  911.                 try:
  912.                     if weapon.Person:
  913.                         AttackerName=WeaponName
  914.                 except: pass
  915.                     
  916.  
  917.     ######################################################################################
  918.  
  919.     ######################################################################################
  920.     # Animation component, character type, level and magical components #
  921.     ######################################################################################
  922.     attacker= None
  923.     if AttackerName:        
  924.         attacker=Bladex.GetEntity(AttackerName)
  925.         
  926.         if attacker and attacker.Person:     
  927.             magicF = attacker.Data.FAttack
  928.             if DamageType=="Impale" or DamageType=="Slash" or DamageType=="Crush":
  929.                 if netgame.GetNetState() == 0:
  930.                     charF=CharStats.GetCharDamageData(attacker.CharType,attacker.Level)
  931.                 else:
  932.                     charF=NetWeapon.GetDamage(attacker.CharType,attacker.Data.NetLevel)
  933.  
  934.             # Animation component #
  935.             if not thrown_flag:
  936.                 if AnimationData.has_key(attacker.AnimFullName):
  937.                     animF = AnimationData[attacker.AnimFullName]
  938.                 elif AnimationData.has_key(attacker.AnimName):    
  939.                     animF = AnimationData[attacker.AnimName]
  940.         
  941.     randomF= round(whrandom.uniform(-0.05, 0.05)*charF)
  942.     charF= max (charF + randomF, 0)
  943.     ######################################################################################
  944.  
  945.     ######################################################################################
  946.     # Damage Zone Multipliers #
  947.     ######################################################################################
  948.     if DamageZone==Reference.BODY_HEAD and DamageType=="Impale" and thrown_flag and weaponData[0]==Reference.OBJ_ARROW:
  949.         locationF= 4.0
  950.     ######################################################################################
  951.     
  952.     ######################################################################################
  953.     # Shield component #        
  954.     ######################################################################################
  955.     if AttackerName:
  956.         shieldName= attacker.GetInventory().GetActiveShield()
  957.         if shieldName and not thrown_flag:             
  958.             if Reference.EntitiesObjectData.has_key(shieldName):
  959.                 if Reference.EntitiesObjectData[shieldName][0] ==  Reference.OBJ_SHIELD:
  960.                     shieldF = Reference.EntitiesObjectData[shieldName][1]
  961.             else:
  962.                 kind = Bladex.GetEntity(shieldName).Kind    
  963.                 if Reference.DefaultObjectData.has_key(kind):
  964.                     if Reference.DefaultObjectData[kind][0] ==  Reference.OBJ_SHIELD:
  965.                         shieldF = Reference.DefaultObjectData[kind][1]        
  966.     ######################################################################################    
  967.     
  968.     ######################################################################################
  969.     # Bow component #
  970.     ######################################################################################
  971.     if AttackerName and attacker and attacker.GetInventory().HoldingBow and thrown_flag:        
  972.         if Reference.EntitiesObjectData.has_key(attacker.InvLeft):
  973.             if Reference.EntitiesObjectData[attacker.InvLeft][0] ==  Reference.OBJ_BOW:
  974.                 bowF = Reference.EntitiesObjectData[attacker.InvLeft][1]
  975.         else:
  976.             kind = Bladex.GetEntity(attacker.InvLeft).Kind    
  977.             if Reference.DefaultObjectData.has_key(kind):
  978.                 if Reference.DefaultObjectData[kind][0] ==  Reference.OBJ_BOW:
  979.                     bowF = Reference.DefaultObjectData[kind][1]        
  980.     ######################################################################################    
  981.     
  982.     if AttackerName and attacker and attacker.Person:
  983.         lvl= attacker.Level+1
  984.     else:
  985.         lvl=0
  986.         
  987.     basic_damage = ((charF * magicF * locationF) + weaponF + throwF + bowF + shieldF) * animF
  988.     basic_damage = max( basic_damage, 0 )
  989.     
  990.     if PrintFormula==1:
  991.         print "Basic Damage Formula= ((charF * magicF * locationF) + weaponF + throwF + bowF + shieldF) * animF"
  992.         print "Basic Damage = (( "+`charF`+" * "+`magicF`+" * "+`locationF`+" ) + "+`weaponF`+" + "+`throwF`+" + "+`bowF`+" + "+`shieldF`+") * "+`animF`+" = "+`basic_damage`
  993.  
  994.     
  995.     
  996.     #
  997.     # The DEFENSE....
  998.     #
  999.                         
  1000.     
  1001.     # target defence #
  1002.     me=Bladex.GetEntity(VictimName)
  1003.     charF = 0
  1004.     shieldF = 0    
  1005.     weaponF = 0
  1006.     magicF = me.Data.FDefense    
  1007.     randomF = 0
  1008.     shield_breakable=0    
  1009.     victimsShieldData=None
  1010.         
  1011.     ######################################################################################
  1012.     # Shield component OR block with 2H weapon #
  1013.     ######################################################################################    
  1014.     blocking_with_weapon=0
  1015.     if Shielded:
  1016.         victimsShieldName = me.GetInventory().GetActiveShield()
  1017.         # Based on the characteristics of whatever you are carrying in the left hand
  1018.         if victimsShieldName:
  1019.             if Reference.EntitiesObjectData.has_key( victimsShieldName):
  1020.                 if Reference.EntitiesObjectData[victimsShieldName][0] ==  Reference.OBJ_SHIELD:
  1021.                     victimsShieldData= Reference.EntitiesObjectData[victimsShieldName]
  1022.                     shieldF = victimsShieldData[2]
  1023.                     shield_breakable= victimsShieldData[7]
  1024.                     
  1025.             else:
  1026.                 kind = Bladex.GetEntity(victimsShieldName).Kind
  1027.                 if Reference.DefaultObjectData.has_key(kind):
  1028.                     if Reference.DefaultObjectData[kind][0] ==  Reference.OBJ_SHIELD:
  1029.                         victimsShieldData= Reference.DefaultObjectData[kind]
  1030.                         shieldF = Reference.DefaultObjectData[kind][2]
  1031.                         shield_breakable=Reference.DefaultObjectData[kind][7]
  1032.             
  1033.         else:
  1034.             # Blocking with a weapon
  1035.             victimsWeaponName = me.InvRight
  1036.             if not victimsWeaponName or victimsWeaponName=="" or victimsWeaponName=="None":
  1037.                 print "Unexpected error in CalculateDamage"
  1038.                 print "Blocking but nothing in hands?"
  1039.                 return
  1040.             w_weapon=Bladex.GetEntity(victimsWeaponName)
  1041.             w_flag=Reference.GiveObjectFlag(victimsWeaponName)
  1042.             if w_flag<>Reference.OBJ_WEAPON:
  1043.                 print "Error in CalculateDamage"
  1044.                 print "Blocking with an unexpected type of weapon"
  1045.                 return
  1046.              
  1047.             if Reference.EntitiesObjectData.has_key( victimsWeaponName):
  1048.                 victimsShieldData=Reference.EntitiesObjectData[victimsWeaponName]
  1049.             else:
  1050.                 kind = Bladex.GetEntity(victimsWeaponName).Kind
  1051.                 if Reference.DefaultObjectData.has_key(kind):
  1052.                     victimsShieldData=Reference.DefaultObjectData[kind]
  1053.  
  1054.             if not victimsShieldData or len(victimsShieldData[5])<1 or victimsShieldData[5][0]==Reference.W_FLAG_1H:
  1055.                 print "Error in CalculateDamage"
  1056.                 print "Trying to wblock with a one handed weapon!"
  1057.             else:                
  1058.                 shieldF = victimsShieldData[5][4]
  1059.                 shield_breakable=victimsShieldData[5][5]
  1060.                 blocking_with_weapon=1
  1061.  
  1062.     ######################################################################################    
  1063.     
  1064.     ######################################################################################
  1065.     # Character Type component #
  1066.     ######################################################################################
  1067.  
  1068.     if netgame.GetNetState() == 0:
  1069.         charF= CharStats.GetCharDefenseData(me.CharType,me.Level) + me.Data.armour_prot_factor
  1070.     else:
  1071.         charF=NetWeapon.GetDefense(me.CharType,me.Data.NetLevel)
  1072.     
  1073.     randomF= round(whrandom.uniform(-0.05, 0.05)*charF)
  1074.     charF=  max(charF+randomF, 0)
  1075.     ######################################################################################
  1076.     
  1077.     ######################################################################################
  1078.     # Weapon component #
  1079.     ######################################################################################
  1080.     victimsWeaponData= None
  1081.     if me.GetInventory().HoldingBow:
  1082.         victimsWeaponName = me.InvLeft
  1083.     else:
  1084.         victimsWeaponName = me.InvRight
  1085.     if victimsWeaponName and blocking_with_weapon==0:    
  1086.         if Reference.EntitiesObjectData.has_key(victimsWeaponName):
  1087.             if Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_WEAPON or Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_STANDARD or Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_ARROW or Reference.EntitiesObjectData[victimsWeaponName][0] == Reference.OBJ_BOW:
  1088.                 victimsWeaponData = Reference.EntitiesObjectData[victimsWeaponName]
  1089.                 if len (victimsWeaponData) > 2:                    
  1090.                     weaponF = victimsWeaponData[2]
  1091.         else:
  1092.             kind = Bladex.GetEntity(victimsWeaponName).Kind    
  1093.             if Reference.DefaultObjectData.has_key(kind):
  1094.                 if Reference.DefaultObjectData[kind][0] == Reference.OBJ_WEAPON or Reference.DefaultObjectData[kind][0] == Reference.OBJ_STANDARD or Reference.DefaultObjectData[kind][0] == Reference.OBJ_ARROW  or Reference.DefaultObjectData[kind][0] == Reference.OBJ_BOW:
  1095.                     victimsWeaponData = Reference.DefaultObjectData[kind]
  1096.                     if len (victimsWeaponData) > 2:
  1097.                         weaponF = victimsWeaponData[2]
  1098.     ######################################################################################
  1099.     
  1100.     DEF= (charF * magicF) + shieldF + weaponF    
  1101.     effective_damage = basic_damage - DEF
  1102.     effective_damage = max( effective_damage, 0 )
  1103.  
  1104.  
  1105.     if PrintFormula==1:
  1106.         print "Effective Damage Formula = basic_damage - (charF * magicF) - shieldF - weaponF"
  1107.         print "Effective Damage Formula = "+`basic_damage`+" - ( "+`charF`+" * "+`magicF`+" ) - "+`shieldF`+" - "+`weaponF`+" = "+`effective_damage`
  1108.  
  1109.     if Shielded:
  1110.         damage_withstood= int (max (basic_damage - (DEF-shieldF), 0))
  1111.         if not blocking_with_weapon:
  1112.             shield= Bladex.GetEntity(me.GetInventory().GetActiveShield())
  1113.             try:
  1114.                 if shield and shield_breakable:
  1115.                     # Lower the resistance of the shield
  1116.                     if victimsShieldData:
  1117.                         if not Reference.EntitiesObjectData.has_key(shield.Name):
  1118.                             Reference.EntitiesObjectData[shield.Name]= copy.copy(victimsShieldData)
  1119.                             victimsShieldData= Reference.EntitiesObjectData[shield.Name]
  1120.                         victimsShieldData[2]= victimsShieldData[2]-damage_withstood
  1121.                         
  1122.                         # Break the shield if 0 resistance
  1123.                         if victimsShieldData[2] <= 0.0:
  1124.                             victimsShieldData[2]=0.0
  1125.                             if shield.Data.brkobjdata:
  1126.                                 BreakMyShield(me.Name)
  1127.                                 Shielded=0
  1128.                         elif attacker and attacker.InDestructorAttack==1 and damage_withstood > shield_breakable:
  1129.                             if shield.Data.brkobjdata:
  1130.                                 BreakMyShield(me.Name)
  1131.                                 Shielded=0
  1132.                                 if PrintFormula==1:
  1133.                                     print "Shield Breaking in destructor attack, took: "+`damage_withstood`+", max: "+`shield_breakable`
  1134.                         else:
  1135.                             if (not thrown_flag) and attacker and attacker.Person and attacker.GotAnmType("sw_react"):
  1136.                                 attacker.Wuea=Reference.WUEA_ENDED
  1137.                                 attacker.LaunchAnmType("sw_react")
  1138.  
  1139.             except AttributeError: pass
  1140.             try:
  1141.                 if shield and shield.Data and shield.Data.AbsorbFunc:
  1142.                     shield.Data.AbsorbFunc (AttackerName, WeaponName, damage_withstood)
  1143.             except AttributeError: pass
  1144.         else:                        
  1145.             weapon= Bladex.GetEntity(me.GetInventory().GetActiveWeapon())
  1146.             try:
  1147.                  if weapon and weapon.Data.brkobjdata:
  1148.                      # Lower the resistance of the shield
  1149.                      if victimsShieldData:
  1150.                          if not Reference.EntitiesObjectData.has_key(weapon.Name):
  1151.                              Reference.EntitiesObjectData[weapon.Name]= copy.copy(victimsShieldData)
  1152.                              victimsShieldData= Reference.EntitiesObjectData[weapon.Name]
  1153.                          victimsShieldData[5][4]= victimsShieldData[5][4]-damage_withstood
  1154.                          
  1155.                          # Break the shield if 0 resistance
  1156.                          if victimsShieldData[5][4] <= 0.0:
  1157.                              victimsShieldData[5][4]=0.0
  1158.                              if weapon.Data.brkobjdata:
  1159.                                 BreakMySword(me.Name)
  1160.                                 Shielded=0
  1161.                         elif attacker and attacker.InDestructorAttack==1 and damage_withstood > shield_breakable:
  1162.                             if weapon.Data.brkobjdata:
  1163.                                 BreakMySword(me.Name)
  1164.                                 Shielded=0
  1165.                                 if PrintFormula==1:
  1166.                                     print "Weapon Breaking in destructor attack, took: "+`damage_withstood`+", max: "+`shield_breakable`
  1167.             except AttributeError: pass            
  1168.             try:
  1169.                 if weapon and weapon.Data and weapon.Data.AbsorbFunc:
  1170.                     weapon.Data.AbsorbFunc (AttackerName, WeaponName, damage_withstood)
  1171.             except AttributeError: pass
  1172.  
  1173.  
  1174.     # personal magical resistance can reduce this damage
  1175.     damage_resistance= me.Data.GetResistance(DamageType)
  1176.     if damage_resistance > 0.0:
  1177.         if PrintFormula==1:
  1178.             print "Resistance to "+DamageType+" at "+`damage_resistance`+" reduces the effective_damage to "+`effective_damage*(1.0-damage_resistance)`
  1179.         effective_damage= effective_damage*(1.0-damage_resistance)
  1180.     
  1181.     # special damage e.g. Fire, poison,
  1182.     special_damage= 0.0    
  1183.     if not (Shielded and effective_damage<=0):
  1184.         if weaponData and len (weaponData) > 6:
  1185.             for special in weaponData[6:]:
  1186.                 special_resistance= me.Data.GetResistance(special[0])
  1187.                 
  1188.                 if SpecialDamageFuncs.has_key(special[0]):                
  1189.                     special_damage_func= SpecialDamageFuncs[special[0]]
  1190.                     special_damage= special_damage + special_damage_func (special, special_resistance, effective_damage, VictimName, AttackerName, WeaponName, DamageType, DamageZone, DamageNode, x, y, z, Shielded)
  1191.                     if PrintFormula==1:
  1192.                         print "Special damage type "+`special[0]`+" (resisted at "+`special_resistance`+") adds "+`special_damage`+" to effective damage."
  1193.                 else:
  1194.                     if PrintFormula==1:
  1195.                         print "Special damage type "+`special[0]`+" (resisted at "+`special_resistance`+") adds "+`special[1]`+" to effective damage."
  1196.                     special_damage= special_damage + special[1]*(1.0-special_resistance)
  1197.             
  1198.         effective_damage= effective_damage + special_damage
  1199.             
  1200.     if(not Shielded) and (DamageType=="Impale" or DamageType=="Slash") and Bladex.GetBloodLevel()>0:
  1201.         me.Data.TakeBleedingImpact= effective_damage
  1202.     else:
  1203.         me.Data.TakeBleedingImpact= 0
  1204.                 
  1205.     prevLife=me.Life
  1206.     
  1207.     if not me.Data.Invincibility:
  1208.         me.Life= me.Life - effective_damage
  1209.     
  1210.     if effective_damage>0:
  1211.         me.Data.Mutilate= me.Life <= 0 and DamageType=="Slash"
  1212.     else:
  1213.         me.Data.Mutilate= 0
  1214.         if not Shielded:
  1215.             effective_damage=1.0        
  1216.             
  1217.     if thrown_flag==1:
  1218.         try: me.Data.Respond2Thrown(me.Name,AttackerName)
  1219.         except AttributeError: pass
  1220.     
  1221.     me.Data.RespondToHit(me.Name, AttackerName, effective_damage, DamageZone, Shielded)
  1222.     
  1223.     if PlayerHitFunc !="":
  1224.         PlayerHitFunc( VictimName, AttackerName, me.Life, prevLife)
  1225.  
  1226.     if me.Life <= 0.0:
  1227.         if (AttackerName):
  1228.             attacker=Bladex.GetEntity(AttackerName)
  1229.             if attacker and attacker.InDestructorAttack==1 and effective_damage>1:
  1230.                 try:
  1231.                     if victimsShieldName:
  1232.                         victimsShield= Bladex.GetEntity(victimsShieldName)
  1233.                         if victimsShield and victimsShield.Data.brkobjdata:
  1234.                             BreakMyShield(me.Name)
  1235.                 except:
  1236.                     pass
  1237.                 try:
  1238.                     if victimsWeaponName:
  1239.                         victimsWeapon= Bladex.GetEntity(victimsWeaponName)
  1240.                         if victimsWeapon and victimsWeaponName.Data.brkobjdata:
  1241.                             BreakMySword(me.Name)
  1242.                 except:
  1243.                     pass
  1244.             if (prevLife>0) and (netgame.GetNetState() == 0):
  1245.                 AttackerEntity=Bladex.GetEntity(AttackerName)
  1246.                 if AttackerEntity:
  1247.                     AttackerEntity.Data.OnKilledEnemy(VictimName)
  1248.  
  1249.     # Sticking to player
  1250.     # Check type of weapon
  1251.     if thrown_flag and weapon.Arrow:
  1252.         weapon.MessageEvent(Reference.MESSAGE_STOP_WEAPON,0,0)
  1253.         weapon.Stop()
  1254.         # Check type of damage
  1255.         if me and (not me.Data.Mutilate) and DamageNode!=-1 and DamageZone!=Reference.BODY_HEAD and me.Life>0.0:
  1256.             me.LinkToNode(weapon, DamageNode)
  1257.             sticktime= (3.0)/weapon.Mass
  1258.             print "object "+weapon.Name+" of kind "+weapon.Kind+" of mass "+`weapon.Mass`+" sticking for "+`sticktime`+" seconds"
  1259.             Bladex.AddScheduledFunc (Bladex.GetTime()+sticktime, StuckWeaponFall, (weapon.Name, VictimName), weapon.Name+"_StuckWeaponFall")
  1260.             if weapon.StickFunc:
  1261.                 weapon.StickFunc (weapon.Name, me.Name)
  1262.         else:
  1263.             weapon.Impulse (0.0,1.0,0.0)
  1264.             
  1265.     if me.Data.Mutilate:
  1266.         if PrintFormula==1:
  1267.             print "Mutilation"
  1268.     if Bladex.GetMutilationLevel()==0:
  1269.         return 0
  1270.     else:
  1271.         return me.Data.Mutilate    
  1272.