battleHelper (fixed)

Исправленный и рабочий battleHelper

  1. // ==UserScript==
  2. // @name battleHelper (fixed)
  3. // @author Neleus
  4. // @namespace Neleus
  5. // @description Исправленный и рабочий battleHelper
  6. // @version 0.47
  7. // @include /^https{0,1}:\/\/((www|qrator|my)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(war|warlog|leader_guild|leader_army|inventory).php(?!.?setkamarmy)/
  8. // @grant GM_xmlhttpRequest
  9. // @grant unsafeWindow
  10. // @license GNU GPLv3
  11. // ==/UserScript==
  12.  
  13. ;(function () {
  14. if (location.pathname.indexOf("leader_guild.php") >= 0) {
  15. var turnId = {
  16. amummy: { id: 933, hp: 80 },
  17. acrossbowman: { id: 1021, hp: 24 },
  18. air: { id: 153, hp: 30 },
  19. ancienent: { id: 238, hp: 181 },
  20. ancientpig: { id: 691, hp: 15 },
  21. angel: { id: 132, hp: 180 },
  22. anubis: { id: 917, hp: 160 },
  23. arcaneelf: { id: 261, hp: 12 },
  24. archer: { id: 2, hp: 7 },
  25. archlich: { id: 146, hp: 55 },
  26. archmage: { id: 104, hp: 30 },
  27. armorgnom: { id: 982, hp: 55 },
  28. assassin: { id: 56, hp: 14 },
  29. assida: { id: 847, hp: 30 },
  30. axegnom: { id: 985, hp: 10 },
  31. banditka: { id: 729, hp: 8 },
  32. banshee: { id: 515, hp: 110 },
  33. battlegriffin: { id: 36, hp: 35 },
  34. battlegriffon: { id: 493, hp: 52 },
  35. battlemage: { id: 578, hp: 29 },
  36. battlerager: { id: 960, hp: 30 },
  37. bear: { id: 172, hp: 22 },
  38. bearrider: { id: 161, hp: 25 },
  39. behemoth: { id: 131, hp: 210 },
  40. berserker: { id: 163, hp: 25 },
  41. bigspider: { id: 724, hp: 55 },
  42. blackbearrider: { id: 162, hp: 30 },
  43. blackknight: { id: 272, hp: 90 },
  44. blackwidow: { id: 661, hp: 14 },
  45. bloodsister: { id: 315, hp: 24 },
  46. boar: { id: 690, hp: 17 },
  47. boarrider: { id: 318, hp: 14 },
  48. bobbit: { id: 895, hp: 6 },
  49. bonedragon: { id: 133, hp: 150 },
  50. brawler: { id: 114, hp: 20 },
  51. brigand: { id: 725, hp: 5 },
  52. briskrider: { id: 316, hp: 50 },
  53. brute: { id: 254, hp: 8 },
  54. cavalier: { id: 90, hp: 90 },
  55. cbal: { id: 791, hp: 65 },
  56. cerberus: { id: 75, hp: 15 },
  57. champion: { id: 495, hp: 100 },
  58. chieftain: { id: 436, hp: 48 },
  59. colossus: { id: 106, hp: 175 },
  60. conscript: { id: 34, hp: 6 },
  61. cpirate: { id: 677, hp: 4 },
  62. crossman: { id: 257, hp: 8 },
  63. crusader: { id: 672, hp: 30 },
  64. cursed: { id: 522, hp: 20 },
  65. cursedent: { id: 664, hp: 215 },
  66. cyclop: { id: 89, hp: 85 },
  67. cyclopking: { id: 237, hp: 95 },
  68. cyclopod: { id: 537, hp: 100 },
  69. dancer: { id: 25, hp: 12 },
  70. darkbird: { id: 544, hp: 60 },
  71. darkrider: { id: 51, hp: 40 },
  72. ddhigh: { id: 587, hp: 34 },
  73. deephydra: { id: 149, hp: 125 },
  74. defender: { id: 157, hp: 7 },
  75. devil: { id: 82, hp: 166 },
  76. dgolem: { id: 520, hp: 350 },
  77. diamondgolem: { id: 660, hp: 60 },
  78. djinn: { id: 39, hp: 40 },
  79. djinn_sultan: { id: 105, hp: 45 },
  80. djinn_vizier: { id: 579, hp: 50 },
  81. druid: { id: 26, hp: 34 },
  82. druideld: { id: 120, hp: 38 },
  83. dryad: { id: 255, hp: 6 },
  84. eadaughter: { id: 333, hp: 35 },
  85. earth: { id: 154, hp: 75 },
  86. efreeti: { id: 280, hp: 90 },
  87. elf: { id: 19, hp: 10 },
  88. elgargoly: { id: 256, hp: 16 },
  89. enforcer: { id: 35, hp: 7 },
  90. executioner: { id: 335, hp: 40 },
  91. familiar: { id: 80, hp: 6 },
  92. fatpirate: { id: 651, hp: 100 },
  93. fatpirateup: { id: 652, hp: 120 },
  94. fcentaur: { id: 310, hp: 6 },
  95. fire: { id: 155, hp: 43 },
  96. firebird: { id: 536, hp: 65 },
  97. firedragon: { id: 168, hp: 230 },
  98. flamelord: { id: 958, hp: 120 },
  99. footman: { id: 10, hp: 16 },
  100. foulhydra: { id: 746, hp: 125 },
  101. foulwyvern: { id: 337, hp: 105 },
  102. fury: { id: 53, hp: 16 },
  103. ghost: { id: 11, hp: 8 },
  104. giant: { id: 792, hp: 100 },
  105. giantarch: { id: 817, hp: 100 },
  106. gnomon: { id: 728, hp: 9 },
  107. goblin: { id: 14, hp: 3 },
  108. goblinarcher: { id: 314, hp: 3 },
  109. goblinmag: { id: 545, hp: 3 },
  110. goblinus: { id: 329, hp: 3 },
  111. gogachi: { id: 285, hp: 13 },
  112. greendragon: { id: 103, hp: 200 },
  113. gremlin: { id: 9, hp: 5 },
  114. griffon: { id: 3, hp: 30 },
  115. grimrider: { id: 121, hp: 50 },
  116. harpooner: { id: 378, hp: 10 },
  117. harpy: { id: 200, hp: 15 },
  118. harpyhag: { id: 201, hp: 15 },
  119. hellcharger: { id: 76, hp: 50 },
  120. hellhound: { id: 74, hp: 15 },
  121. hellkon: { id: 290, hp: 66 },
  122. highwayman: { id: 730, hp: 24 },
  123. hobgoblin: { id: 33, hp: 4 },
  124. horneddemon: { id: 77, hp: 13 },
  125. hornedoverseer: { id: 79, hp: 13 },
  126. hotdog: { id: 288, hp: 15 },
  127. hydra: { id: 50, hp: 80 },
  128. hyenarider: { id: 859, hp: 14 },
  129. imp: { id: 78, hp: 4 },
  130. impergriffin: { id: 117, hp: 35 },
  131. inquisitor: { id: 145, hp: 80 },
  132. iron_golem: { id: 12, hp: 18 },
  133. jdemon: { id: 289, hp: 13 },
  134. kachok: { id: 601, hp: 50 },
  135. kamneed: { id: 202, hp: 45 },
  136. kamnegryz: { id: 203, hp: 55 },
  137. leprekon: { id: 610, hp: 7 },
  138. lich: { id: 29, hp: 50 },
  139. mage: { id: 16, hp: 18 },
  140. magneticgolem: { id: 259, hp: 28 },
  141. maiden: { id: 49, hp: 16 },
  142. manticore: { id: 754, hp: 80 },
  143. marksman: { id: 42, hp: 10 },
  144. mastergremlin: { id: 32, hp: 6 },
  145. masterhunter: { id: 72, hp: 14 },
  146. masterlich: { id: 341, hp: 55 },
  147. matriarch: { id: 239, hp: 90 },
  148. mauler: { id: 320, hp: 12 },
  149. mcentaur: { id: 309, hp: 10 },
  150. medusa: { id: 752, hp: 25 },
  151. medusaup: { id: 753, hp: 30 },
  152. megogachi: { id: 287, hp: 13 },
  153. mercarcher: { id: 20, hp: 8 },
  154. mercfootman: { id: 21, hp: 24 },
  155. minotaur: { id: 55, hp: 31 },
  156. minotaurguard: { id: 70, hp: 35 },
  157. mistress: { id: 745, hp: 100 },
  158. mountaingr: { id: 339, hp: 12 },
  159. mummy: { id: 268, hp: 50 },
  160. ncentaur: { id: 311, hp: 9 },
  161. negro: { id: 849, hp: 17 },
  162. nightmare: { id: 150, hp: 66 },
  163. nomad: { id: 897, hp: 30 },
  164. obsgargoyle: { id: 44, hp: 20 },
  165. ocean: { id: 848, hp: 30 },
  166. ogre: { id: 24, hp: 50 },
  167. ogrebrutal: { id: 535, hp: 70 },
  168. ogremagi: { id: 119, hp: 65 },
  169. ogreshaman: { id: 855, hp: 55 },
  170. orc: { id: 23, hp: 12 },
  171. orcchief: { id: 73, hp: 18 },
  172. orcrubak: { id: 534, hp: 20 },
  173. orcshaman: { id: 546, hp: 13 },
  174. outlaw: { id: 727, hp: 6 },
  175. outlawup: { id: 896, hp: 8 },
  176. peasant: { id: 4, hp: 4 },
  177. pegasus: { id: 625, hp: 30 },
  178. pikeman: { id: 1004, hp: 15 },
  179. piratemonster: { id: 644, hp: 190 },
  180. piratka: { id: 649, hp: 10 },
  181. piratkaup: { id: 650, hp: 12 },
  182. pitfiend: { id: 83, hp: 110 },
  183. pitlord: { id: 236, hp: 120 },
  184. pity: { id: 291, hp: 140 },
  185. pixel: { id: 17, hp: 5 },
  186. plaguezombie: { id: 40, hp: 17 },
  187. plant: { id: 624, hp: 60 },
  188. poltergeist: { id: 512, hp: 20 },
  189. priest: { id: 37, hp: 54 },
  190. priestess: { id: 852, hp: 35 },
  191. priestessup: { id: 853, hp: 35 },
  192. pristineunicorn: { id: 588, hp: 80 },
  193. rakshasa_kshatra: { id: 580, hp: 135 },
  194. rakshasa_raja: { id: 108, hp: 140 },
  195. rakshasa_rani: { id: 93, hp: 120 },
  196. rapukk: { id: 283, hp: 99 },
  197. reptiloid: { id: 850, hp: 80 },
  198. reptiloidup: { id: 851, hp: 90 },
  199. robber: { id: 726, hp: 5 },
  200. rocbird: { id: 30, hp: 55 },
  201. rotzombie: { id: 270, hp: 23 },
  202. runekeeper: { id: 961, hp: 65 },
  203. runepatriarch: { id: 165, hp: 70 },
  204. runepriest: { id: 164, hp: 60 },
  205. saboteurgremlin: { id: 253, hp: 6 },
  206. satyr: { id: 626, hp: 36 },
  207. savageent: { id: 589, hp: 175 },
  208. sceletonwar: { id: 267, hp: 5 },
  209. scout: { id: 52, hp: 10 },
  210. sdaughter: { id: 332, hp: 35 },
  211. seducer: { id: 485, hp: 26 },
  212. shadowdragon: { id: 102, hp: 200 },
  213. shadow_witch: { id: 94, hp: 80 },
  214. shamancyclop: { id: 860, hp: 105 },
  215. shamaness: { id: 331, hp: 30 },
  216. shieldguard: { id: 158, hp: 12 },
  217. shootpirate: { id: 646, hp: 15 },
  218. shootpirateup: { id: 647, hp: 18 },
  219. silverunicorn: { id: 147, hp: 77 },
  220. skeleton: { id: 1, hp: 4 },
  221. skeletonarcher: { id: 28, hp: 4 },
  222. skeletonpirate: { id: 604, hp: 4 },
  223. skeletonpirateup: { id: 606, hp: 4 },
  224. skirmesher: { id: 160, hp: 12 },
  225. skmarksman: { id: 340, hp: 6 },
  226. slayer: { id: 334, hp: 34 },
  227. snowwolf: { id: 942, hp: 50 },
  228. spearwielder: { id: 159, hp: 10 },
  229. spectre: { id: 68, hp: 19 },
  230. spegasus: { id: 629, hp: 30 },
  231. spider: { id: 198, hp: 9 },
  232. spiderpois: { id: 199, hp: 11 },
  233. sprite: { id: 31, hp: 6 },
  234. squire: { id: 71, hp: 26 },
  235. stalker: { id: 696, hp: 15 },
  236. steelgolem: { id: 69, hp: 24 },
  237. stone_gargoyle: { id: 8, hp: 15 },
  238. succubus: { id: 81, hp: 20 },
  239. succubusmis: { id: 122, hp: 30 },
  240. taskmaster: { id: 317, hp: 40 },
  241. tengu: { id: 793, hp: 45 },
  242. thane: { id: 166, hp: 100 },
  243. thiefarcher: { id: 124, hp: 40 },
  244. thiefmage: { id: 125, hp: 30 },
  245. thiefwarrior: { id: 123, hp: 45 },
  246. throwgnom: { id: 993, hp: 24 },
  247. thunderbird: { id: 148, hp: 65 },
  248. thunderlord: { id: 167, hp: 120 },
  249. trapper: { id: 386, hp: 7 },
  250. treant: { id: 92, hp: 175 },
  251. troglodyte: { id: 750, hp: 5 },
  252. troglodyteup: { id: 751, hp: 6 },
  253. troll: { id: 204, hp: 150 },
  254. unicorn: { id: 38, hp: 57 },
  255. vampire: { id: 15, hp: 30 },
  256. vampirelord: { id: 118, hp: 35 },
  257. vampireprince: { id: 513, hp: 40 },
  258. vermin: { id: 281, hp: 6 },
  259. vindicator: { id: 260, hp: 23 },
  260. vulture: { id: 731, hp: 40 },
  261. wardancer: { id: 41, hp: 12 },
  262. warmong: { id: 330, hp: 20 },
  263. warrior: { id: 319, hp: 12 },
  264. water: { id: 156, hp: 43 },
  265. wdancer: { id: 258, hp: 14 },
  266. whitebearrider: { id: 959, hp: 30 },
  267. wight: { id: 91, hp: 95 },
  268. wolfraider: { id: 43, hp: 12 },
  269. wolfrider: { id: 18, hp: 10 },
  270. wraith: { id: 235, hp: 100 },
  271. wyvern: { id: 336, hp: 90 },
  272. zealot: { id: 494, hp: 80 },
  273. zombie: { id: 5, hp: 17 },
  274. zpirate: { id: 679, hp: 150 },
  275. archangel: { id: 249, hp: 220 },
  276. seraph2: { id: 496, hp: 220 },
  277. spectraldragon: { id: 300, hp: 160 },
  278. ghostdragon: { id: 514, hp: 150 },
  279. titan: { id: 107, hp: 190 },
  280. stormtitan: { id: 581, hp: 190 },
  281. emeralddragon: { id: 100, hp: 200 },
  282. crystaldragon: { id: 590, hp: 200 },
  283. ancientbehemoth: { id: 301, hp: 250 },
  284. dbehemoth: { id: 538, hp: 280 },
  285. cursedbehemoth: { id: 861, hp: 250 },
  286. blackdragon: { id: 101, hp: 240 },
  287. reddragon: { id: 747, hp: 235 },
  288. archdevil: { id: 292, hp: 199 },
  289. archdemon: { id: 293, hp: 211 },
  290. magmadragon: { id: 169, hp: 280 },
  291. lavadragon: { id: 962, hp: 275 },
  292. untamedcyc: { id: 433, hp: 225 },
  293. bloodeyecyc: { id: 399, hp: 235 },
  294. cyclopus: { id: 397, hp: 220 },
  295. paladin: { id: 234, hp: 100 },
  296. efreetisultan: { id: 282, hp: 100 },
  297. naga: { id: 673, hp: 110 },
  298. golddragon: { id: 609, hp: 169 },
  299. pharaoh: { id: 269, hp: 70 },
  300. deadknight: { id: 273, hp: 100 },
  301. zhryak: { id: 284, hp: 99 },
  302. ballista: { id: 85, hp: 200 },
  303. tent: { id: 0, hp: 0 },
  304. piratemonsterup: { id: 645, hp: 200 },
  305. blacktroll: { id: 205, hp: 180 },
  306. zasad: { id: 1047, hp: 70 },
  307. magicel: { id: 662, hp: 80 },
  308. scorp: { id: 923, hp: 4 },
  309. duneraider: { id: 921, hp: 12 },
  310. scorpup: { id: 924, hp: 5 },
  311. dromad: { id: 919, hp: 40 },
  312. duneraiderup: { id: 922, hp: 12 },
  313. shakal: { id: 925, hp: 24 },
  314. slon: { id: 931, hp: 100 },
  315. priestmoon: { id: 929, hp: 50 },
  316. slonup: { id: 932, hp: 110 },
  317. shakalup: { id: 926, hp: 30 },
  318. dromadup: { id: 920, hp: 45 },
  319. priestsun: { id: 930, hp: 55 },
  320. anubisup: { id: 918, hp: 200 },
  321. scarab: { id: 927, hp: 6 },
  322. scarabup: { id: 928, hp: 6 },
  323. tenguup: { id: 937, hp: 60 },
  324. gnoll: { id: 1041, hp: 6 },
  325. brigandup: { id: 1038, hp: 6 },
  326. verblud: { id: 1060, hp: 35 },
  327. gnollum: { id: 1042, hp: 6 },
  328. krokodil: { id: 1067, hp: 70 },
  329. krokodilup: { id: 1068, hp: 80 },
  330. gnollsh: { id: 1089, hp: 6 },
  331. smaster: { id: 1095, hp: 84 },
  332. manticoreup: { id: 755, hp: 80 },
  333. apirate: { id: 612, hp: 13 },
  334. bpirate: { id: 611, hp: 16 },
  335. wendigoup: { id: 945, hp: 35 },
  336. whitetiger: { id: 631, hp: 35 },
  337. dgolemup: { id: 521, hp: 400 },
  338. exile: { id: 1040, hp: 28 },
  339. banditkaup: { id: 936, hp: 9 },
  340. nomadup: { id: 938, hp: 33 },
  341. spearthrower: { id: 1114, hp: 19 },
  342. gatekeeper: { id: 1132, hp: 120 },
  343. gnollup: { id: 1138, hp: 9 },
  344. gnollka: { id: 1139, hp: 6 },
  345. gnollboss: { id: 1140, hp: 36 },
  346. pushkar: { id: 1055, hp: 64 },
  347. robberup: { id: 1044, hp: 6 },
  348. sekhmet: { id: 1062, hp: 50 },
  349. valkyrie: { id: 1185, hp: 61 },
  350. goblinshaman: { id: 1193, hp: 5 },
  351. poukai: { id: 1194, hp: 120 },
  352. monk: { id: 1221, hp: 20 },
  353. warden: { id: 1223, hp: 39 },
  354. snowwolfup: { id: 1165, hp: 53 },
  355. necrodogup: { id: 1325, hp: 9 },
  356. necrodog: { id: 1324, hp: 8 },
  357. blackarcher: { id: 1311, hp: 13 },
  358. deadarcher: { id: 1312, hp: 16 },
  359. ork: { id: 1346, hp: 24 },
  360. grib: { id: 1187, hp: 20 },
  361. gribok: { id: 1188, hp: 16 },
  362. }
  363. var imgId = {
  364. mundus: "acrossbowman",
  365. assasin: "assassin",
  366. ocean: "assida",
  367. knight: "cavalier",
  368. crossbowman: "crossman",
  369. cursed_: "cursed",
  370. cyclopod_: "cyclopod",
  371. lizardrider: "darkrider",
  372. dd_: "druid",
  373. ddeld: "druideld",
  374. dryad_: "dryad",
  375. firebird_: "firebird",
  376. gog: "gogachi",
  377. nightmare: "hellcharger",
  378. demondog: "hellhound",
  379. hellstallion: "hellkon",
  380. hdemon: "horneddemon",
  381. fdemon: "hornedoverseer",
  382. firehound: "hotdog",
  383. golem: "iron_golem",
  384. lepr: "leprekon",
  385. hunterelf: "masterhunter",
  386. magog: "megogachi",
  387. minotaurguard_: "minotaurguard",
  388. stallion: "nightmare",
  389. obsgargoly: "obsgargoyle",
  390. assida: "ocean",
  391. paesant: "peasant",
  392. pitfiend_: "pitfiend",
  393. pitlord_: "pitlord",
  394. pitspawn: "pity",
  395. pp: "pixel",
  396. rakshas: "rakshasa_rani",
  397. roc: "rocbird",
  398. witch: "shadow_witch",
  399. cyclopshaman: "shamancyclop",
  400. sceleton: "skeleton",
  401. sceletonarcher: "skeletonarcher",
  402. dpirate: "skeletonpirate",
  403. dpirateup: "skeletonpirateup",
  404. swordman: "squire",
  405. gargoly: "stone_gargoyle",
  406. succub: "succubus",
  407. succubusm: "succubusmis",
  408. ent: "treant",
  409. bladedancer: "wardancer",
  410. winddancer: "wdancer",
  411. hobwolfrider: "wolfraider",
  412. abehemoth: "ancientbehemoth",
  413. bbehemoth: "cursedbehemoth",
  414. zhrica: "priestmoon",
  415. zhricaup: "priestsun",
  416. mmaster: "smaster",
  417. jpirate: "spearthrower",
  418. witchdoctor: "goblinshaman",
  419. paokai: "poukai",
  420. deaddog: "necrodogup",
  421. blackdog: "necrodog",
  422. }
  423. let tr = document.getElementById("gl_tasks").getElementsByTagName("tr")
  424. for (let i = 0; i < tr.length; i++) {
  425. if (tr[i].childNodes.length != 1) {
  426. continue
  427. }
  428. let cre = tr[i].getElementsByClassName("cre_creature")
  429. let checkSum = 0
  430. let hp = 0
  431. let f = true
  432. for (let j = 0; j < cre.length; j++) {
  433. let id = cre[j].innerHTML.match(/name=([^\"]+)/)[1]
  434. let count = cre[j].querySelector("#add_now_count").innerHTML
  435. checkSum += turnId[id].id * count
  436. hp += turnId[id].hp * count
  437. }
  438. if (checkSum > 0 && hp > 0) {
  439. // tr[i].querySelector("td").innerHTML += "<div style = 'margin-left:10px'><a href = 'https://daily.heroeswm.ru/leader/bandits.php?hp=" + hp + "&sum=" + checkSum + "'>Поиск боя на Daily</a></div>";
  440. }
  441. }
  442. }
  443. if (
  444. (location.pathname.indexOf("war.php") >= 0 ||
  445. location.pathname.indexOf("warlog.php") >= 0) &&
  446. location.href.indexOf("show_enemy") == -1
  447. ) {
  448. var timerIdn = setInterval(check, 100)
  449. }
  450. function check() {
  451. if (document.getElementById("play_button").style.display == "none") {
  452. unsafeWindow.gpause = false
  453. }
  454. if (
  455. typeof unsafeWindow.stage !== "undefined" &&
  456. typeof unsafeWindow.stage.pole !== "undefined" &&
  457. typeof unsafeWindow.stage.pole.onMouseMoveFlash === "function"
  458. ) {
  459. clearInterval(timerIdn)
  460. if (typeof unsafeWindow.setshadAbs !== "undefined") {
  461. return 0
  462. }
  463. unsafeWindow.spell_type = {
  464. raisedead: "1",
  465. magicfist: "1",
  466. lighting: "2",
  467. magicarrow: "2",
  468. slow: "4",
  469. fast: "3",
  470. swarm: "1",
  471. curse: "4",
  472. bless: "3",
  473. stoneskin: "3",
  474. stonespikes: "2",
  475. poison: "4",
  476. mfast: "3",
  477. mbless: "3",
  478. mstoneskin: "3",
  479. dispel: "3",
  480. dray: "4",
  481. icebolt: "2",
  482. fireball: "2",
  483. mdispel: "3",
  484. righteous_might: "3",
  485. deflect_missile: "3",
  486. suffering: "4",
  487. confusion: "4",
  488. circle_of_winter: "2",
  489. phantom_forces: "1",
  490. mslow: "4",
  491. mcurse: "4",
  492. mpoison: "4",
  493. mdray: "4",
  494. msuffering: "4",
  495. mconfusion: "4",
  496. mrighteous_might: "3",
  497. mdeflect_missile: "3",
  498. armageddon: "2",
  499. blind: "4",
  500. frenzy: "4",
  501. teleport: "3",
  502. meteor: "2",
  503. chainlighting: "2",
  504. summonel: "1",
  505. antimagic: "3",
  506. firewall: "1",
  507. earthquake: "1",
  508. summonphoenix: "1",
  509. arcanearmor: "1",
  510. resurrection2: "3",
  511. divinevengeance: "3",
  512. divinev: "3",
  513. summonel_f: "1",
  514. summonel_a: "1",
  515. summonel_w: "1",
  516. summonel_e: "1",
  517. }
  518. unsafeWindow.magicbookspells_new = []
  519. for (let i = 0; i <= 4; i++) {
  520. for (let j in magicbookspells) {
  521. let type = 0
  522. if (spell_type[magicbookspells[j]]) {
  523. type = spell_type[magicbookspells[j]]
  524. }
  525. if (type == i) {
  526. magicbookspells_new.push(magicbookspells[j])
  527. }
  528. }
  529. }
  530. stage.pole.showmagicbook = function (page, iszak, check_spell) {
  531. let actMiniSpells = hwm_set["miniSpells"]
  532. spell_per_page = actMiniSpells ? 16 : 6
  533. var cm = magicbookspells_new.length
  534. let count = 0
  535. for (i = 0; i < cm; i++) {
  536. if (hwm_set["spellsOrder"]) {
  537. s = magicbookspells_new[i]
  538. } else {
  539. s = magicbookspells[i]
  540. }
  541. if (
  542. this.obj[activeobj][s] == 1 ||
  543. (s == "gating" &&
  544. magic[activeobj]["dem"] &&
  545. magic[activeobj]["dem"]["effect"] == 1)
  546. ) {
  547. if (s == "gating" && this.obj[activeobj].alreadysummon) {
  548. continue
  549. }
  550. if (s == "firstblood") {
  551. continue
  552. }
  553. if (s == "explosion" && this.obj[activeobj].nowmanna == 0) {
  554. continue
  555. }
  556. if (s == "teleport" && this.obj[activeobj].demonic) {
  557. continue
  558. }
  559. if (s == "summonpitlords" && magic[activeobj]["pit"]) {
  560. continue
  561. }
  562. if (
  563. s == "invisibility" &&
  564. magic[activeobj]["2in"] &&
  565. magic[activeobj]["2in"]["effect"] == 1
  566. ) {
  567. continue
  568. }
  569. if (s == "seduction" && magic[activeobj]["usd"]) {
  570. continue
  571. }
  572. if (s == "manafeed" && this.obj[activeobj].nowmanna == 0) {
  573. continue
  574. }
  575. count++
  576. }
  577. if (
  578. this.obj[activeobj].darkpower &&
  579. this.obj[activeobj][s] == 1 &&
  580. magicbookchaos[magicbookspells.indexOf(s)] &&
  581. k >= page &&
  582. k < page + spell_per_page
  583. ) {
  584. count++
  585. }
  586. if (this.check_mass_day_or_night(activeobj, s)) {
  587. if (k >= page && k < page + spell_per_page) {
  588. var scut = s.substr(1)
  589. count++
  590. }
  591. }
  592. }
  593. actMiniSpells = count > 6 ? actMiniSpells : 0
  594. if (!android) {
  595. spell_per_page = actMiniSpells ? 16 : 6
  596. } else {
  597. spell_per_page = 4
  598. }
  599. var k = 0,
  600. j = 0,
  601. s = "",
  602. so = "",
  603. book_txt = "",
  604. was_spell = 0
  605. lastpage = page
  606. if (iszak != 1) zakarrow = false
  607.  
  608. function proccedinbook(so, powered, showed_cnt) {
  609. if (
  610. so == "zakarrow" &&
  611. (zakarrow == true ||
  612. (magic[activeobj]["za2"] &&
  613. magic[activeobj]["za2"]["effect"] > 0))
  614. )
  615. return 0
  616. j = k % spell_per_page
  617. var cost = stage[war_scr].obj[activeobj][s + "cost"]
  618. if (powered) {
  619. cost *= 2
  620. }
  621. kz = 1
  622. var kz2 = 1
  623. if (isperk(activeobj, 110) && stage[war_scr].obj[activeobj].hero) {
  624. kz *= 0.8
  625. }
  626. if (isperk(activeobj, 87) && !stage[war_scr].obj[activeobj].hero) {
  627. kz = 0.5
  628. }
  629. if (isperk(activeobj, 111) && stage[war_scr].obj[activeobj].hero) {
  630. kz *= 0.8
  631. }
  632. if (magic[activeobj]["dnn"]) {
  633. var sp_bonus =
  634. 1.03 + umelka[stage[war_scr].obj[activeobj]["owner"]][10] * 0.03
  635. if (is_day_or_night(activeobj, s)) {
  636. kz2 /= sp_bonus
  637. }
  638. }
  639. cost = Math.round(cost * kz)
  640. cost = Math.round(cost * eco * kz2)
  641. if (s == "manafeed") {
  642. cost = Math.min(
  643. stage[war_scr].obj[activeobj].nowmanna,
  644. stage[war_scr].obj[activeobj].nownumber
  645. )
  646. }
  647. if (s == "explosion") {
  648. cost = ""
  649. }
  650. if (s == "invisibility") {
  651. cost = ""
  652. }
  653. if (s == "channeling") {
  654. cost = ""
  655. }
  656. if (s == "siphonmana") {
  657. cost = ""
  658. }
  659. if (s == "leap") {
  660. cost = ""
  661. }
  662. if (s == "leap6") {
  663. cost = ""
  664. }
  665. if (s == "sacrificegoblin") {
  666. cost = ""
  667. }
  668. if (s == "gating") {
  669. cost = ""
  670. }
  671. if (s == "summonpitlords") {
  672. cost = ""
  673. }
  674. if (s == "seduction") {
  675. cost = ""
  676. }
  677. if (s == "teleportother") {
  678. cost = ""
  679. }
  680. if (s == "consumecorpse" || s == "benediction") {
  681. cost = ""
  682. }
  683. if (
  684. cost > stage[war_scr].obj[activeobj].nowmanna ||
  685. (cost == 0 && s == "manafeed")
  686. ) {
  687. var disabled = true
  688. } else {
  689. var disabled = false
  690. was_spell = 1
  691. }
  692. if (check_spell) {
  693. return 0
  694. }
  695. var s_name = ""
  696. if (magicbooknames[magicbookspells.indexOf(s)].includes("Mass ")) {
  697. s_name += "Mass"
  698. }
  699. if (magicbooknames[magicbookspells.indexOf(s)].includes("Массов")) {
  700. s_name += "Массовое"
  701. }
  702. var nametxt = magicbooknames[magicbookspells.indexOf(s)]
  703. if (powered || is_day_or_night(activeobj, s)) {
  704. switch (lang) {
  705. case 0:
  706. nametxt += " (усиленное)"
  707. s_name += " Усиленное"
  708. break
  709. case 1:
  710. nametxt += " (empowered)"
  711. s_name += "(emp)"
  712. break
  713. }
  714. }
  715. if (s == "angerofhorde") {
  716. eff = 0
  717. var len = stage[war_scr].obj_array.length
  718. for (var k1 = 0; k1 < len; k1++) {
  719. var k = stage[war_scr].obj_array[k1]
  720. if (
  721. stage[war_scr].obj[k]["owner"] ==
  722. stage[war_scr].obj[activeobj]["owner"] &&
  723. !stage[war_scr].obj[k]["hero"] &&
  724. !stage[war_scr].obj[k]["warmachine"]
  725. ) {
  726. eff += stage[war_scr].obj[k]["nownumber"]
  727. }
  728. }
  729. stage[war_scr].obj[activeobj][s + "effmain"] = eff
  730. }
  731. if (stage[war_scr].obj[activeobj][s + "effmain"] > 0) {
  732. if (stage[war_scr].obj[activeobj].hero) {
  733. var s1 = 0
  734. if (
  735. isperk(activeobj, 93) &&
  736. (s == "magicfist" || s == "raisedead")
  737. ) {
  738. s1 = 4
  739. }
  740. if (isperk(activeobj, 78) && (s == "poison" || s == "mpoison")) {
  741. s1 += 5
  742. }
  743. if (isperk(activeobj, 89) && (s == "poison" || s == "mpoison")) {
  744. s1 += 3
  745. }
  746. eff =
  747. stage[war_scr].obj[activeobj][s + "effmain"] +
  748. stage[war_scr].obj[activeobj][s + "effmult"] *
  749. (stage[war_scr].getspellpower(activeobj, s) + s1)
  750. if (stage[war_scr].obj[activeobj][s + "effmult"] == 1.5) {
  751. eff = Math.round(eff)
  752. }
  753. var teff = eff
  754. if (powered) {
  755. eff = Math.round(eff * 1.5)
  756. }
  757. } else {
  758. eff = Math.round(
  759. stage[war_scr].obj[activeobj][s + "effmain"] +
  760. stage[war_scr].obj[activeobj][s + "effmult"] *
  761. Math.pow(stage[war_scr].obj[activeobj]["nownumber"], 0.7)
  762. )
  763. if (s == "blind") {
  764. eff = Math.round(
  765. stage[war_scr].obj[activeobj][s + "effmain"] +
  766. stage[war_scr].obj[activeobj][s + "effmult"] *
  767. stage[war_scr].obj[activeobj]["nownumber"]
  768. )
  769. }
  770. var teff = eff
  771. }
  772. if (!powered) stage[war_scr].obj[activeobj][s + "_magiceff"] = eff
  773. if (
  774. stage[war_scr].obj[activeobj][s + "time"] > 0 &&
  775. stage[war_scr].obj[activeobj][s + "effmain"] > 15 &&
  776. s != "antimagic"
  777. ) {
  778. eff = stage[war_scr].obj[activeobj][s + "effmain"] + "%"
  779. }
  780. if (s.substr(0, s.length - 1) == "summoncreature") {
  781. if (magic[activeobj]["suc"]) {
  782. eff = Math.floor(
  783. eff * Math.pow(0.9, magic[activeobj]["suc"]["effect"])
  784. )
  785. }
  786. }
  787. efftxt = eff
  788. } else {
  789. efftxt = ""
  790. if (s == "explosion") {
  791. eff = Math.round(
  792. 9 +
  793. 9 * Math.pow(stage[war_scr].obj[activeobj]["nownumber"], 0.7)
  794. )
  795. efftxt = eff
  796. }
  797. if (s == "channeling") {
  798. eff = Math.max(
  799. 1,
  800. Math.floor(stage[war_scr].obj[activeobj]["nownumber"] * 0.5)
  801. )
  802. efftxt = eff
  803. }
  804. }
  805. if (stage[war_scr].obj[activeobj][s + "time"] > 0) {
  806. if (stage[war_scr].obj[activeobj].hero || magic[activeobj]["her"]) {
  807. eff = stage[war_scr].getspellpower(activeobj, s)
  808. if (isperk(activeobj, 89)) {
  809. eff += 3
  810. }
  811. if (isperk(activeobj, 78) && checkdark(s)) {
  812. eff += 5
  813. }
  814. } else {
  815. eff = stage[war_scr].obj[activeobj]["nownumber"]
  816. if (magic[activeobj]["bhr"]) {
  817. eff = Math.max(
  818. eff,
  819. Math.floor(stage[war_scr].obj[activeobj]["maxmanna"] / 5)
  820. )
  821. }
  822. }
  823. if (eff == 0) {
  824. eff = 0.5
  825. }
  826. durationtxt = eff
  827. } else {
  828. durationtxt = ""
  829. }
  830. var add_desktop = ""
  831. if (!android) add_desktop = "_Desktop"
  832. book_txt +=
  833. "<div" +
  834. (actMiniSpells ? "" : " title = '" + nametxt + "'") +
  835. ' class="book_skill_block' +
  836. add_desktop +
  837. '" id="spell_block' +
  838. showed_cnt +
  839. '" style="background-image:url(' +
  840. stage[war_scr].subpath +
  841. "combat/magicbook/" +
  842. so +
  843. ".png?v=" +
  844. image_ver +
  845. ");"
  846. if (disabled == false) {
  847. book_txt +=
  848. '"><div class="spell_btn' +
  849. add_desktop +
  850. '" id="spell' +
  851. showed_cnt +
  852. '" attr_disabled="0" style="cursor: pointer;" '
  853. } else {
  854. book_txt +=
  855. 'opacity: 0.3;"><div attr_disabled="1" style="cursor: auto;"'
  856. }
  857. spell_id[showed_cnt] = so
  858. spell_powered[showed_cnt] = powered
  859. let style = actMiniSpells ? "font-size: 0.8rem;line-height: 1;" : ""
  860. book_txt +=
  861. '></div><div class="book_skill_block_container"><div class="book_skill_block_amounts book_skill_block_name" style = "' +
  862. style +
  863. '">' +
  864. (actMiniSpells ? s_name : nametxt) +
  865. "</div>"
  866. if (cost != "")
  867. book_txt +=
  868. '<div class="book_skill_block_amounts book_skill_block_effects">' +
  869. cost +
  870. "</div>"
  871. if (efftxt != "")
  872. book_txt +=
  873. '<div class="book_skill_block_amounts book_skill_block_cost">' +
  874. efftxt +
  875. "</div>"
  876. if (durationtxt != "")
  877. book_txt +=
  878. '<div class="book_skill_block_amounts book_skill_block_durt">' +
  879. durationtxt +
  880. "</div>"
  881. book_txt += "</div></div>"
  882. }
  883. page = page * spell_per_page
  884. var eco = 1
  885. if (this.obj[activeobj]["hero"]) {
  886. var len = this.obj_array.length
  887. for (var k1 = 0; k1 < len; k1++) {
  888. i = this.obj_array[k1]
  889. if (
  890. this.obj[i]["energychannel"] &&
  891. this.obj[i]["nownumber"] > 0 &&
  892. this.obj[i]["owner"] == this.obj[activeobj]["owner"]
  893. ) {
  894. eco = 0.75
  895. }
  896. }
  897. for (var k1 = 0; k1 < len; k1++) {
  898. i = this.obj_array[k1]
  899. if (
  900. this.obj[i]["manaeater"] &&
  901. this.obj[i]["nownumber"] > 0 &&
  902. this.obj[i]["side"] != this.obj[activeobj]["side"]
  903. ) {
  904. eco = 1.3
  905. }
  906. }
  907. } else {
  908. var len = this.obj_array.length
  909. var max = 0
  910. for (var k1 = 0; k1 < len; k1++) {
  911. i = this.obj_array[k1]
  912. if (
  913. this.obj[i]["manacurser"] &&
  914. this.obj[i]["nownumber"] > 0 &&
  915. this.obj[i]["side"] != this.obj[activeobj]["side"]
  916. ) {
  917. max = Math.max(max, this.obj[i]["nownumber"])
  918. }
  919. }
  920. max = Math.min(40, max)
  921. eco *= 1 + max / 100
  922. }
  923. var cm = magicbookspells_new.length
  924. for (zz = 0; zz <= 1; zz++) {
  925. var showed_cnt = 0
  926. k = 0
  927. for (i = 0; i < cm; i++) {
  928. if (hwm_set["spellsOrder"]) {
  929. s = magicbookspells_new[i]
  930. } else {
  931. s = magicbookspells[i]
  932. }
  933. if (
  934. (this.obj[activeobj][s] == 1 ||
  935. (s == "gating" &&
  936. magic[activeobj]["dem"] &&
  937. magic[activeobj]["dem"]["effect"] == 1)) &&
  938. ((k >= page && k < page + spell_per_page) || check_spell)
  939. ) {
  940. if (s == "gating" && this.obj[activeobj].alreadysummon) {
  941. continue
  942. }
  943. if (s == "firstblood") {
  944. continue
  945. }
  946. if (s == "explosion" && this.obj[activeobj].nowmanna == 0) {
  947. continue
  948. }
  949. if (s == "teleport" && this.obj[activeobj].demonic) {
  950. continue
  951. }
  952. if (s == "summonpitlords" && magic[activeobj]["pit"]) {
  953. continue
  954. }
  955. if (
  956. s == "invisibility" &&
  957. magic[activeobj]["2in"] &&
  958. magic[activeobj]["2in"]["effect"] == 1
  959. ) {
  960. continue
  961. }
  962. if (s == "seduction" && magic[activeobj]["usd"]) {
  963. continue
  964. }
  965. if (s == "manafeed" && this.obj[activeobj].nowmanna == 0) {
  966. continue
  967. }
  968. showed_cnt++
  969. proccedinbook(s, 0, showed_cnt)
  970. }
  971. if (
  972. this.obj[activeobj][s] == 1 ||
  973. (s == "gating" &&
  974. magic[activeobj]["dem"] &&
  975. magic[activeobj]["dem"]["effect"] == 1)
  976. ) {
  977. k++
  978. }
  979. if (
  980. this.obj[activeobj].darkpower &&
  981. this.obj[activeobj][s] == 1 &&
  982. magicbookchaos[magicbookspells.indexOf(s)] &&
  983. k >= page &&
  984. k < page + spell_per_page
  985. ) {
  986. showed_cnt++
  987. proccedinbook(s, 1, showed_cnt)
  988. }
  989. if (
  990. this.obj[activeobj].darkpower &&
  991. this.obj[activeobj][s] == 1 &&
  992. magicbookchaos[magicbookspells.indexOf(s)]
  993. ) {
  994. k++
  995. }
  996. if (this.check_mass_day_or_night(activeobj, s)) {
  997. if (k >= page && k < page + spell_per_page) {
  998. var scut = s.substr(1)
  999. showed_cnt++
  1000. this.obj[activeobj][s + "cost"] =
  1001. this.obj[activeobj][scut + "cost"] * 2
  1002. this.obj[activeobj][s + "effmain"] =
  1003. this.obj[activeobj][scut + "effmain"]
  1004. this.obj[activeobj][s + "effmult"] =
  1005. this.obj[activeobj][scut + "effmult"]
  1006. this.obj[activeobj][s + "time"] =
  1007. this.obj[activeobj][scut + "time"]
  1008. proccedinbook(s, 0, showed_cnt)
  1009. }
  1010. k++
  1011. }
  1012. }
  1013. if (k > page || k == 0) break
  1014. else {
  1015. page = 0
  1016. bookpage = 0
  1017. }
  1018. }
  1019. if (check_spell) {
  1020. return was_spell
  1021. }
  1022. if (actMiniSpells) {
  1023. book_txt +=
  1024. "<style>.book_skill_block_amounts {font-weight:bold;}.book_skill_block_Desktop{width:25% !important;height: 17vh !important;} .book_skills_container_Desktop{margin-left: 5%;margin-right: 5%;}</style>"
  1025. }
  1026. document.getElementById("magic_book_page").innerHTML = book_txt
  1027. document.getElementById("book_mana").innerHTML =
  1028. "<div>" +
  1029. this.obj[activeobj].nowmanna +
  1030. " / " +
  1031. this.obj[activeobj].maxmanna +
  1032. "</div>"
  1033. for (i = 1; i <= spell_per_page; i++) {
  1034. if (document.getElementById("spell" + i)) {
  1035. if (magic_book_hints) {
  1036. var disabled = tointeger(
  1037. document
  1038. .getElementById("spell" + i)
  1039. .getAttribute("attr_disabled")
  1040. )
  1041. if (disabled != 1) {
  1042. show_div_arrow(
  1043. "spell_block" + i,
  1044. "",
  1045. "position: absolute; left: calc(50% - 25px); top: 90%; width: 50px; height: 50px; pointer-events: none; display: block; transform: rotate(270deg);"
  1046. )
  1047. } else {
  1048. hide_div_arrow("spell_block" + i)
  1049. }
  1050. }
  1051. document
  1052. .getElementById("spell" + i)
  1053. .addEventListener("mouseup", spell_button_release.bind(null, i))
  1054. }
  1055. }
  1056. }
  1057.  
  1058. //
  1059.  
  1060. unsafeWindow.hwm_set = {
  1061. miniSpells: false,
  1062. atbStartDisplay: false,
  1063. spellsOrder: false,
  1064. }
  1065. for (i in hwm_set) {
  1066. hwm_set[i] = localStorage.getItem(i)
  1067. if (
  1068. hwm_set[i] === null ||
  1069. hwm_set[i] === undefined ||
  1070. hwm_set[i] === "1" ||
  1071. hwm_set[i] === "0" ||
  1072. hwm_set[i] === 1 ||
  1073. hwm_set[i] === 0
  1074. ) {
  1075. hwm_set[i] = false
  1076. }
  1077. }
  1078. unsafeWindow.checkTrue = function (name) {
  1079. return hwm_set[name] === true || hwm_set[name] === "true"
  1080. }
  1081. unsafeWindow.setAtbStyle = function () {
  1082. let elems = document.getElementsByClassName("atb-info")
  1083. for (let i = 0; i < elems.length; i++) {
  1084. elems[i].style.display = checkTrue("atbStartDisplay")
  1085. ? "block"
  1086. : "none"
  1087. }
  1088. }
  1089. setAtbStyle()
  1090. unsafeWindow.checkSet = function (name) {
  1091. document.getElementById(name + "_checkbox").checked = checkTrue(name)
  1092. ? true
  1093. : false
  1094. localStorage.setItem(name, checkTrue(name) ? false : true)
  1095. hwm_set[name] = checkTrue(name) ? false : true
  1096. if (name == "atbStartDisplay") {
  1097. setAtbStyle()
  1098. }
  1099. }
  1100. unsafeWindow.chatMode = function () {
  1101. return chat.className.substring(chat.className.length - 1)
  1102. }
  1103.  
  1104. let divs = [],
  1105. divc = [],
  1106. divt = []
  1107. let backgroundColors = [
  1108. "",
  1109. "#991515",
  1110. "#4b66ff",
  1111. "#25C953",
  1112. "#BD8500",
  1113. "#B000FF",
  1114. "#005C13",
  1115. ]
  1116. for (let i = btype == 145 ? 6 : 2; i >= 1; i--) {
  1117. divs[i] = document.createElement("div")
  1118. divs[i].setAttribute("id", "hp" + i)
  1119. divs[i].classList.add("hp")
  1120.  
  1121. divc[i] = document.createElement("div")
  1122. divc[i].style.backgroundColor = backgroundColors[i]
  1123. divc[i].setAttribute("id", "hp" + i + "c")
  1124. divc[i].classList.add("hpc")
  1125.  
  1126. divt[i] = document.createElement("div")
  1127. divt[i].setAttribute("id", "hp" + i + "t")
  1128. divt[i].classList.add("hpt")
  1129.  
  1130. if (i > 1) {
  1131. divs[i].style.marginTop = "3px"
  1132. }
  1133. document.querySelector("#chat_format").prepend(divs[i])
  1134. divs[i].prepend(divc[i])
  1135. divs[i].prepend(divt[i])
  1136. }
  1137. div = document.createElement("div")
  1138. div.innerHTML =
  1139. "<div class='info_row' id='atb-start-bonus' onmouseup = 'checkSet(\"atbStartDisplay\")'><label class='checkbox_container'>Стартовый бонус АТБ<input type='checkbox'" +
  1140. (checkTrue("atbStartDisplay") ? " checked " : "") +
  1141. "id='atbStartDisplay_checkbox'><span class='checkbox_checkmark'></span></label></div><br>"
  1142. document
  1143. .getElementById("win_Settings")
  1144. .getElementsByTagName("form")[0]
  1145. .querySelector("#webgl_settings_whole")
  1146. .after(div)
  1147. global_init = 0
  1148. unsafeWindow.firsTurnShow =
  1149. tointeger(command.substr(1, command.indexOf(":") - 1)) <= 1
  1150. ? true
  1151. : false
  1152. unsafeWindow.btime = false
  1153. unsafeWindow.fireInfo = false
  1154. unsafeWindow.skillProbability = ""
  1155. unsafeWindow.luckProbability = 0
  1156. unsafeWindow.curAbil = ""
  1157. unsafeWindow.last_line3 = ""
  1158. unsafeWindow.phm = {}
  1159. unsafeWindow.psc = {}
  1160. unsafeWindow.psa = {}
  1161. unsafeWindow.sHP = [0, 0]
  1162. unsafeWindow.nHP = [0, 0]
  1163. //unsafeWindow.gate = {};
  1164. unsafeWindow.lastChain = 0
  1165. unsafeWindow.damageTable = ""
  1166. unsafeWindow.damage = [[], []]
  1167. unsafeWindow.targetMagicdamage = 0
  1168. unsafeWindow.targetMagickills = 0
  1169. unsafeWindow.test_temp = 0
  1170. unsafeWindow.addSpeedLastTurn = 0
  1171. unsafeWindow.addIniLastTurn = 0
  1172. unsafeWindow.lastRaidsCount = 0
  1173. unsafeWindow.raidsCurrentWave = 0
  1174. damageTableStyle = document.createElement("style")
  1175. damageTableStyle.innerHTML =
  1176. "#win_BattleResult{max-height:90%} #damageTable td {vertical-align: baseline; font-size:90%} #damageTable {max-height: 30vh;overflow: auto;}"
  1177. damageTableStyle.innerHTML +=
  1178. "#test table {width:100%;margin-left:3px;} #test {padding-left:5px;font-weight:bold;height:100%;width:100%;position: absolute;top:0;right: 0;background: #151313;font-size: 0.9em;z-index:101;}"
  1179. damageTableStyle.innerHTML +=
  1180. "#effectsDisplay:hover{filter: brightness(1500%) drop-shadow(0 0 10px #fff);} #effectsDisplay {display: inline-block;float: right;height: 26px;cursor: pointer;line-height: 26px;color:#979797;font-size:12px}"
  1181. damageTableStyle.innerHTML +=
  1182. "#dop-info img {filter: drop-shadow(#000 0px 0px 0.1em);margin-left:-2px;vertical-align: baseline;} #dop-info {position:absolute;font-family: Arial;position: absolute;text-align: right;text-shadow: -0 -0.03em 0.03em #000, 0 -0.03em 0.03em #000,-0 0.03em 0.03em #000, 0 0.03em 0.03em #000,-0.03em -0 0.03em #000, 0.03em -0 0.03em #000,-0.03em 0 0.03em #000, 0.03em 0 0.03em #000,-0.03em -0.03em 0.03em #000, 0.03em -0.03em 0.03em #000,-0.03em 0.03em 0.03em #000, 0.03em 0.03em 0.03em #000,-0.03em -0.03em 0.03em #000, 0.03em -0.03em 0.03em #000,-0.03em 0.03em 0.03em #000, 0.03em 0.03em 0.03em #000;color: #fff;font-size:130%}"
  1183. damageTableStyle.innerHTML +=
  1184. ".hp {width:100%; height:15px; border: 1px solid #fff; border-radius: 5px; color:#fff; position:relative;}"
  1185. damageTableStyle.innerHTML +=
  1186. ".hpt {width:100%; height:100%; text-align:center; line-height:15px; font-size:13px; font-weight:bold; color:#fff; position:absolute; z-index:1;}"
  1187. damageTableStyle.innerHTML +=
  1188. ".hpc {width:100%; height:100%; border-radius: 5px; position:absolute;}"
  1189.  
  1190. document.head.appendChild(damageTableStyle)
  1191. effectsDisplay = document.createElement("div")
  1192. effectsDisplay.setAttribute("id", "effectsDisplay")
  1193. effectsDisplay.innerHTML = "Эффекты"
  1194. effectsDisplay.setAttribute(
  1195. "title",
  1196. "Отображать в окне чата бафы и дебафы существ при наведении курсора"
  1197. )
  1198. effectsDisplay.setAttribute("onclick", "setEffectDisplay()")
  1199. document.getElementById("chat_panelPosition_btn1").before(effectsDisplay)
  1200. dopInfoPanel = document.createElement("div")
  1201. dopInfoPanel.setAttribute("id", "dop-info")
  1202. unsafeWindow.lastFire = 0
  1203. document.getElementById("timer").after(dopInfoPanel)
  1204. unsafeWindow.testBlock = function (i = 0, firewall = false) {
  1205. if (chatMode() == "V") {
  1206. return 0
  1207. }
  1208. let div = document.getElementById("test")
  1209. if (firewall == true && i != lastFire && i > 0) {
  1210. div.style.height = "100%"
  1211. div.innerHTML = "<center>Огнестенка " + i + " ход.</center>"
  1212. lastFire = i
  1213. fireInfo = true
  1214. } else if (firewall == false) {
  1215. fireInfo = false
  1216. if (
  1217. i == 0 ||
  1218. stage.pole.showmagicinfo(i, 1).indexOf("Эффекты отсутствуют") != -1
  1219. ) {
  1220. div.innerHTML = ""
  1221. div.style.height = "0"
  1222. lastFire = 0
  1223. return 0
  1224. }
  1225. div.style.height = "100%"
  1226. if (lastFire == 0) {
  1227. div.innerHTML = ""
  1228. }
  1229. div.innerHTML +=
  1230. "<center>" + stage.pole.get_name_html(i) + "</center>"
  1231. let str = stage.pole.showmagicinfo(i, 1)
  1232. div.innerHTML += str
  1233. }
  1234. }
  1235. unsafeWindow.updateBar = function (ch = 2) {
  1236. sHP = [0, 0, 0, 0, 0, 0]
  1237. nHP = [0, 0, 0, 0, 0, 0]
  1238. for (k in stage.pole.obj) {
  1239. let ow =
  1240. ch == 2
  1241. ? (stage.pole.obj[k].owner % 2) * -1 + 1
  1242. : +stage.pole.obj[k].owner - 1
  1243. if (
  1244. stage.pole.obj[k].hero != undefined ||
  1245. stage.pole.obj[k].warmachine != undefined ||
  1246. stage.pole.obj[k].building != undefined
  1247. )
  1248. continue
  1249. sHP[ow] += stage.pole.obj[k].maxnumber * stage.pole.obj[k].realhealth
  1250. nHP[ow] +=
  1251. Math.max(stage.pole.obj[k].nownumber - 1, 0) *
  1252. stage.pole.obj[k].maxhealth +
  1253. stage.pole.obj[k].nowhealth
  1254. }
  1255. for (let i = 1; i <= ch; i++) {
  1256. let percentage = (nHP[i - 1] / sHP[i - 1]) * 100
  1257. document.getElementById("hp" + i + "t").innerHTML = `${nHP[i - 1]}/${
  1258. sHP[i - 1]
  1259. } (${percentage.toFixed(2)}%)`
  1260. document.getElementById(
  1261. "hp" + i + "c"
  1262. ).style.width = `${percentage.toFixed(2)}%`
  1263. }
  1264. }
  1265. unsafeWindow.infoBlock = function (i = 0) {
  1266. let div = document.getElementById("dop-info")
  1267. if (i == 0) {
  1268. div.innerHTML = ""
  1269. return 0
  1270. }
  1271. let str = ""
  1272. let h = Math.round(
  1273. (atb_scaling *
  1274. atb_height *
  1275. stage.pole.scaling *
  1276. (1 / MainPixelRatio)) /
  1277. 3
  1278. )
  1279. if (stage.pole.luckMoraleProbability(i, "morale") > 0) {
  1280. str +=
  1281. "<div style = 'line-height:" +
  1282. (h - 2) +
  1283. "px;height:" +
  1284. h +
  1285. "px;'><img align='absmiddle' height = '" +
  1286. (h - 4) +
  1287. "px' src = 'https://dcdn.heroeswm.ru/i/icons/attr_morale.png'>&#8201;" +
  1288. stage.pole.luckMoralePerc(i, "morale") +
  1289. "</div>"
  1290. }
  1291. if (stage.pole.luckMoraleProbability(i, "luck") > 0) {
  1292. str +=
  1293. "<div style = 'line-height:" +
  1294. (h - 2) +
  1295. "px;height:" +
  1296. h +
  1297. "px;'><img align='absmiddle' height = '" +
  1298. (h - 4) +
  1299. "px' src = 'https://dcdn.heroeswm.ru/i/icons/attr_fortune.png'>&#8201;" +
  1300. stage.pole.luckMoralePerc(i, "luck") +
  1301. "</div>"
  1302. }
  1303. if (str != "" && time > 0) {
  1304. str += "<style>#timer {opacity:0.3}</style>"
  1305. }
  1306. div.innerHTML = str
  1307. }
  1308. let damageTableDisplay = localStorage.getItem("damage-table-display")
  1309. if (damageTableDisplay === null || damageTableDisplay === undefined) {
  1310. damageTableDisplay = "table"
  1311. }
  1312. let spanHTML = damageTableDisplay == "table" ? "(скрыть)" : "(показать)"
  1313. let effectDisplay = localStorage.getItem("effect-display")
  1314. if (effectDisplay === null || effectDisplay === undefined) {
  1315. effectDisplay = "block"
  1316. }
  1317. div = document.createElement("div")
  1318. div.setAttribute("id", "test")
  1319. div.style.height = "0"
  1320. div.style.display = effectDisplay
  1321. document.getElementById("effectsDisplay").style.textDecoration =
  1322. effectDisplay == "none" ? "line-through" : "none"
  1323. document.getElementById("chat_format").prepend(div)
  1324. unsafeWindow.setEffectDisplay = function () {
  1325. effectDisplay = effectDisplay == "none" ? "block" : "none"
  1326. localStorage.setItem("effect-display", effectDisplay)
  1327. document.getElementById("test").style.display = effectDisplay
  1328. document.getElementById("effectsDisplay").style.textDecoration =
  1329. effectDisplay == "none" ? "line-through" : "none"
  1330. }
  1331. unsafeWindow.setDamageTableDisplay = function () {
  1332. damageTableDisplay = damageTableDisplay == "table" ? "none" : "table"
  1333. localStorage.setItem("damage-table-display", damageTableDisplay)
  1334. document
  1335. .getElementById("win_BattleResult")
  1336. .querySelector("table").style.display = damageTableDisplay
  1337. spanHTML = damageTableDisplay == "table" ? "(скрыть)" : "(показать)"
  1338. updateDamageData()
  1339. }
  1340. unsafeWindow.updateDamageData = function () {
  1341. if (damageTable == "") {
  1342. damageTable = document.createElement("div")
  1343. damageTable.setAttribute("id", "damageTable")
  1344. document
  1345. .getElementById("win_BattleResult")
  1346. .querySelector("#btn_watch_WatchBattle")
  1347. .before(damageTable)
  1348. }
  1349. let txt =
  1350. "<B>Нанесённый урон</B> <span onclick = 'setDamageTableDisplay()' title 'скрыть/показать' style = 'font-size:80%;cursor:pointer'>" +
  1351. spanHTML +
  1352. "</span><table width = 100% style = 'display:" +
  1353. damageTableDisplay +
  1354. "'><tbody><tr>"
  1355. for (let i = 0; i < 2; i++) {
  1356. if (damage[i].length == 0) {
  1357. continue
  1358. }
  1359. txt += "<td width = 50%><table width = 95%><tbody>"
  1360. damage[i].sort((a, b) => (a.s < b.s ? 1 : -1))
  1361. for (let j = 0; j < damage[i].length; j++) {
  1362. txt +=
  1363. "<tr><td align = left>" +
  1364. stage.pole.html("name", damage[i][j]["id"]) +
  1365. "</td><td align = right>" +
  1366. damage[i][j]["s"] +
  1367. "</td></tr>"
  1368. }
  1369. txt += "</tbody></table></td>"
  1370. }
  1371. txt += "</tr></tbody></table>"
  1372. document.getElementById("damageTable").innerHTML = txt
  1373. }
  1374. stage.pole.procceddamage = unsafeWindow.procceddamage = function (i) {
  1375. realDamage = Math.min(
  1376. this.obj[i].damage,
  1377. (this.obj[i].nownumber - 1) * this.obj[i].maxhealth +
  1378. this.obj[i].nowhealth
  1379. )
  1380. if (
  1381. this.obj[this.obj[i].damaged] !== undefined ||
  1382. this.obj[i].damaged == -2 ||
  1383. this.obj[i].damaged == -1 ||
  1384. this.obj[i].damaged == -9
  1385. ) {
  1386. let id = 0
  1387. if (this.obj[i].damaged == -9 && psa[i] !== "undefined") {
  1388. // id = psa[i];
  1389. } else if (this.obj[i].damaged == -1 && psc[i] !== "undefined") {
  1390. id = psc[i]
  1391. } else if (this.obj[i].damaged == -2) {
  1392. let x = tointeger(tmp.substr(6, 2))
  1393. let y = tointeger(tmp.substr(8, 2))
  1394. id = Math.floor(firewalls[x + y * defxn] / 100)
  1395. } else {
  1396. id = this.obj[i].damaged
  1397. }
  1398. if (id > 0 && this.obj[id] && this.obj[id].owner) {
  1399. let owner = this.obj[id].owner
  1400. let side = (this.obj[id].owner % 2) * -1 + 1
  1401. let name = this.obj[id].nametxt
  1402. let f = false
  1403. for (let j = 0; j < damage[side].length; j++) {
  1404. if (
  1405. damage[side][j]["name"] == name &&
  1406. damage[side][j]["owner"] == owner
  1407. ) {
  1408. f = true
  1409. damage[side][j]["s"] += realDamage
  1410. }
  1411. }
  1412. if (f == false) {
  1413. let o = {
  1414. id: id,
  1415. s: realDamage,
  1416. name: name,
  1417. owner: owner,
  1418. }
  1419. damage[side].push(o)
  1420. }
  1421. updateDamageData()
  1422. }
  1423. }
  1424. if (this.obj[this.obj[i].damaged] !== undefined) {
  1425. if (
  1426. this.obj[this.obj[i].damaged].separhsum === null ||
  1427. this.obj[this.obj[i].damaged].separhsum === undefined
  1428. ) {
  1429. this.obj[this.obj[i].damaged].separhsum = 0
  1430. }
  1431. let s = 0
  1432. if (realDamage >= this.obj[i].nowhealth) {
  1433. s += this.obj[i].level
  1434. if (realDamage - this.obj[i].nowhealth > 0) {
  1435. s *=
  1436. Math.floor(
  1437. (realDamage - this.obj[i].nowhealth) / this.obj[i].maxhealth
  1438. ) + 1
  1439. }
  1440. this.obj[this.obj[i].damaged].separhsum += s
  1441. }
  1442. if (stage.pole.obj[this.obj[i].damaged]["hitcount"] === undefined) {
  1443. stage.pole.obj[this.obj[i].damaged]["hitcount"] = 0
  1444. stage.pole.obj[this.obj[i].damaged]["luckcount"] = 0
  1445. }
  1446. if (
  1447. this["nowhit"] != this.obj[i].damaged &&
  1448. !this.obj[i].magicdamage
  1449. ) {
  1450. let curName = curAbil.substr(0, 3)
  1451. if (
  1452. curAbil == "" ||
  1453. parseInt(curAbil.substr(3, 3)) != this.obj[i].damaged ||
  1454. (curName != "stb" &&
  1455. curName != "htc" &&
  1456. curName != "blh" &&
  1457. curName != "dwl" &&
  1458. curName != "ltn" &&
  1459. curName != "clt" &&
  1460. curName != "lep" &&
  1461. curName != "spk" &&
  1462. curName != "bdd" &&
  1463. curName != "rs2" &&
  1464. curName != "ooc" &&
  1465. curName != "fls")
  1466. ) {
  1467. if (
  1468. magic[this.obj[i].damaged] &&
  1469. magic[this.obj[i].damaged]["hyp"] &&
  1470. magic[this.obj[i].damaged]["hyp"]["nowinit"] > 0
  1471. ) {
  1472. } else {
  1473. this.obj[this.obj[i].damaged]["hitcount"] += 1
  1474. }
  1475. this["nowhit"] = this.obj[i].damaged
  1476. }
  1477. curAbil = ""
  1478. }
  1479. }
  1480. curshowmagic = ""
  1481. if (this.obj[i].damaged > 0) {
  1482. this.obj[this.obj[i].damaged].att = true
  1483. }
  1484. if (this.obj[i].damage != 0 || !this.obj[i].runaway) {
  1485. this.obj[i].donow = "b"
  1486. if (this.obj[i].incorporeal) {
  1487. if (
  1488. this.obj[i].magicdamage &&
  1489. this.obj[i].magicdamage != "Магический кулак"
  1490. ) {
  1491. this.obj[i].misscount = 0
  1492. } else {
  1493. if (this.obj[i].damage == 0) {
  1494. if (
  1495. this.obj[i].misscount === undefined ||
  1496. this.obj[i].misscount == 0
  1497. ) {
  1498. this.obj[i].misscount = -1
  1499. } else {
  1500. if (this.obj[i].misscount == -1) {
  1501. this.obj[i].misscount = -2
  1502. } else {
  1503. this.obj[i].misscount = -1
  1504. }
  1505. }
  1506. } else {
  1507. if (
  1508. this.obj[i].misscount === undefined ||
  1509. this.obj[i].misscount == 0
  1510. ) {
  1511. this.obj[i].misscount = 1
  1512. } else {
  1513. if (this.obj[i].misscount == 1) {
  1514. this.obj[i].misscount = 2
  1515. } else {
  1516. this.obj[i].misscount = 1
  1517. }
  1518. }
  1519. }
  1520. }
  1521. }
  1522. if (this.obj[i].damage == 0 && magic[i]["phm"]) {
  1523. this.obj[i].donow = ""
  1524. } else {
  1525. if (this.obj[i].damaged > 0) {
  1526. this.obj[i].destx = this.obj[this.obj[i].damaged].x
  1527. }
  1528. if (this.obj[i].damaged > 0) {
  1529. this.obj[i].desty = this.obj[this.obj[i].damaged].y
  1530. }
  1531. this.obj[i].active = true
  1532. someactive = true
  1533. }
  1534. }
  1535. this.obj[i]["needSetNumber"] = 0
  1536. this.calcdamage(i)
  1537. }
  1538. stage.pole.process_luck = unsafeWindow.process_luck = function (current) {
  1539. var lucky = command.substring(4, command.indexOf("^"))
  1540. playsound(current, lucky, 70)
  1541. if (lucky == "badmorale") {
  1542. switch (lang) {
  1543. case 0:
  1544. htmllog +=
  1545. "" +
  1546. this.html("name", current) +
  1547. " ожидают в страхе" +
  1548. this.html("end")
  1549. break
  1550. case 1:
  1551. htmllog +=
  1552. "" +
  1553. this.html("name", current) +
  1554. " freeze in fear." +
  1555. this.html("end")
  1556. break
  1557. }
  1558. showtext()
  1559. showdefwait(current, "unmorale")
  1560. }
  1561. if (lucky == "morale") {
  1562. this.incrementParam(current, "moraleCount")
  1563. switch (lang) {
  1564. case 0:
  1565. htmllog +=
  1566. "" +
  1567. this.html("name", current) +
  1568. " рвутся в бой!" +
  1569. this.html("end")
  1570. break
  1571. case 1:
  1572. htmllog +=
  1573. "" +
  1574. this.html("name", current) +
  1575. " are bursting for more action!" +
  1576. this.html("end")
  1577. break
  1578. }
  1579. showtext()
  1580. showdefwait(current, "morale")
  1581. }
  1582. if (lucky == "luck") {
  1583. if (stage.pole.obj[current]["hitcount"] === undefined) {
  1584. stage.pole.obj[current]["hitcount"] = 0
  1585. stage.pole.obj[current]["luckcount"] = 0
  1586. }
  1587. stage.pole.obj[current]["luckcount"] += 1
  1588. switch (lang) {
  1589. case 0:
  1590. htmllog +=
  1591. "" +
  1592. this.html("name", current) +
  1593. " посетила удача!" +
  1594. this.html("end")
  1595. break
  1596. case 1:
  1597. htmllog +=
  1598. "Luck befalls " +
  1599. this.html("name", current) +
  1600. "!" +
  1601. this.html("end")
  1602. break
  1603. }
  1604. showtext()
  1605. showdefwait(current, "luck")
  1606. }
  1607. if (lucky == "unluck") {
  1608. switch (lang) {
  1609. case 0:
  1610. htmllog +=
  1611. "" +
  1612. this.html("name", current) +
  1613. " посетила неудача." +
  1614. this.html("end")
  1615. break
  1616. case 1:
  1617. htmllog +=
  1618. "Bad luck befalls " +
  1619. this.html("name", current) +
  1620. "." +
  1621. this.html("end")
  1622. break
  1623. }
  1624. showtext()
  1625. showdefwait(current, "unluck")
  1626. }
  1627. if (lucky == "critical") {
  1628. switch (lang) {
  1629. case 0:
  1630. htmllog +=
  1631. "" +
  1632. this.html("name", current) +
  1633. " - критический удар по заклятому врагу." +
  1634. this.html("end")
  1635. break
  1636. case 1:
  1637. htmllog +=
  1638. "" +
  1639. this.html("name", current) +
  1640. " deal critical damage to favoured enemy." +
  1641. this.html("end")
  1642. break
  1643. }
  1644. showtext()
  1645. showdefwait(current, "crit")
  1646. }
  1647. if (lucky == "drunk") {
  1648. switch (lang) {
  1649. case 0:
  1650. htmllog +=
  1651. "" +
  1652. this.html("name", current) +
  1653. " - самоуправство." +
  1654. this.html("end")
  1655. break
  1656. case 1:
  1657. htmllog +=
  1658. "" +
  1659. this.html("name", current) +
  1660. " - independence." +
  1661. this.html("end")
  1662. break
  1663. }
  1664. showtext()
  1665. showdefwait(current, "rage", 0)
  1666. }
  1667. command = command.substr(command.indexOf("^") + 1)
  1668. }
  1669. stage.pole.luckMoraleProbability = function (i, name) {
  1670. let probability = 0
  1671. if (!firsTurnShow) {
  1672. return 0
  1673. }
  1674. let cre = stage.pole.obj[i]
  1675. if (cre === undefined) {
  1676. return 0
  1677. }
  1678. let allCount = ""
  1679. let yesCount = ""
  1680. let lastValue = ""
  1681. let luck = 0
  1682. if (name == "morale") {
  1683. allCount = "turnCount"
  1684. yesCount = "moraleCount"
  1685. lastValue = "lastMorale"
  1686. luck = stage.pole.getMoraleN(i)
  1687. } else if (name == "luck") {
  1688. allCount = "hitcount"
  1689. yesCount = "luckcount"
  1690. lastValue = "lastluck"
  1691. luck = cre["luck"] + cre["luckaddon"]
  1692. }
  1693. if (cre[allCount] === undefined) {
  1694. cre[allCount] = 0
  1695. }
  1696. if (cre[yesCount] === undefined) {
  1697. cre[yesCount] = 0
  1698. }
  1699.  
  1700. if (cre["checkMrl"] !== undefined && cre["checkMrl"] == 1) {
  1701. if (magic[i]["mrl"] === 0) {
  1702. stage.pole.clearPar(i, "morale")
  1703. cre["checkMrl"] = 0
  1704. }
  1705. }
  1706. if (cre[lastValue] !== undefined && luck != cre[lastValue]) {
  1707. stage.pole.clearPar(i, name)
  1708. }
  1709. cre[lastValue] = luck
  1710. luck = Math.max(0, Math.min(luck * 0.1, 0.5))
  1711. if (cre["hero"] != 1) {
  1712. probability = Math.min(
  1713. Math.pow(
  1714. luck,
  1715. 1 +
  1716. cre[yesCount] -
  1717. ((cre[allCount] - cre[yesCount]) * luck) / (1 - luck)
  1718. ),
  1719. 1
  1720. )
  1721. }
  1722. if (probability >= 0.1) {
  1723. return probability.toFixed(2)
  1724. } else {
  1725. return probability.toFixed(3)
  1726. }
  1727. }
  1728. stage.pole.luckMoralePerc = function (i, name) {
  1729. let prob = this.luckMoraleProbability(i, name)
  1730. if (prob >= 0.1) {
  1731. return (prob * 100).toFixed(0) + "%"
  1732. } else {
  1733. return (prob * 100).toFixed(1) + "%"
  1734. }
  1735. }
  1736. stage.pole.snaresPossible = unsafeWindow.snaresPossible = function (
  1737. attacker,
  1738. defender
  1739. ) {
  1740. let n =
  1741. Math.floor(attacker.nownumber / 25) -
  1742. (defender.level +
  1743. Math.floor(
  1744. (defender.nownumber * defender.maxhealth) /
  1745. (80 + defender.level * 20)
  1746. ))
  1747. let possible = [25, 25, 25, 25]
  1748. let b = n
  1749. if (n > 0) {
  1750. for (let i = 3; i >= 1; i--) {
  1751. while (possible[i] > 5 && n > 0) {
  1752. possible[0] += 5
  1753. possible[i] -= 5
  1754. n -= 1
  1755. }
  1756. }
  1757. }
  1758. if (n < 0) {
  1759. for (let i = 0; i <= 2; i++) {
  1760. while (possible[i] > 5 && n < 0) {
  1761. possible[3] += 5
  1762. possible[i] -= 5
  1763. n += 1
  1764. }
  1765. }
  1766. }
  1767. return possible[0] + possible[1] + possible[2] + "%"
  1768. }
  1769. stage.pole.checkProbabilitySkill = unsafeWindow.checkProbabilitySkill =
  1770. function (attacker, attackx, attacky, ax, ay, range = 0) {
  1771. unsafeWindow.skillProbability = ""
  1772. if (
  1773. !this.obj[attacker] ||
  1774. !this.obj[attacker].hasOwnProperty("nownumber")
  1775. ) {
  1776. return false
  1777. }
  1778. var defender = mapobj[ax + ay * defxn]
  1779. if (
  1780. !this.obj[defender] ||
  1781. !this.obj[defender].hasOwnProperty("nownumber")
  1782. ) {
  1783. return false
  1784. }
  1785. let hpa =
  1786. (this.obj[attacker].nownumber - 1) * this.obj[attacker].maxhealth +
  1787. this.obj[attacker].nowhealth
  1788. let hpd =
  1789. (this.obj[defender].nownumber - 1) * this.obj[defender].maxhealth +
  1790. this.obj[defender].nowhealth
  1791. let soldiersLuck = 0
  1792. if (heroes[this.obj[activeobj]["owner"]] > 0) {
  1793. let h = heroes[this.obj[activeobj]["owner"]]
  1794. if (isperk(activeobj, 33)) {
  1795. soldiersLuck = 1
  1796. }
  1797. }
  1798. if (
  1799. this.obj[attacker]["blinding_attack"] &&
  1800. this.obj[defender]["alive"] &&
  1801. !this.obj[defender]["warmachine"] &&
  1802. !this.obj[defender]["iblind"] &&
  1803. !this.obj[defender]["imind"] &&
  1804. !this.obj[defender]["twistedmind"] &&
  1805. !this.obj[defender]["absolutepurity"] &&
  1806. !this.obj[defender]["enchantedarmor"]
  1807. ) {
  1808. skillProbability = getSkillProbability(
  1809. hpa,
  1810. Math.max(1, hpd - tPhysicalDamage)
  1811. )
  1812. if (
  1813. skillProbability !=
  1814. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2))
  1815. ) {
  1816. skillProbability =
  1817. skillProbability +
  1818. "% - " +
  1819. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2))
  1820. }
  1821. }
  1822. if (
  1823. this.obj[attacker]["fearattack"] &&
  1824. this.obj[defender]["alive"] &&
  1825. !this.obj[defender]["imind"] &&
  1826. !this.obj[defender]["twistedmind"] &&
  1827. !this.obj[defender]["absolutepurity"]
  1828. ) {
  1829. skillProbability = getSkillProbability(
  1830. hpa,
  1831. Math.max(1, hpd - tPhysicalDamage)
  1832. )
  1833. if (
  1834. skillProbability !=
  1835. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2))
  1836. ) {
  1837. skillProbability =
  1838. skillProbability +
  1839. "% - " +
  1840. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2))
  1841. }
  1842. }
  1843. if (
  1844. this.obj[attacker]["flamewave"] ||
  1845. (this.obj[attacker]["shootbash"] && range == 1) ||
  1846. this.obj[attacker]["shieldbash"] ||
  1847. this.obj[attacker]["deathattack"] ||
  1848. (this.obj[attacker]["wardingarrows"] &&
  1849. !this.obj[defender]["warmachine"] &&
  1850. !this.obj[defender]["mechanical"])
  1851. ) {
  1852. skillProbability = getSkillProbability(hpa, hpd)
  1853. }
  1854. if (
  1855. this.obj[attacker]["torpor"] &&
  1856. this.obj[defender]["alive"] &&
  1857. !this.obj[defender]["warmachine"] &&
  1858. !this.obj[defender]["absolutepurity"]
  1859. ) {
  1860. skillProbability = getSkillProbability(hpa, hpd)
  1861. }
  1862. if (this.obj[attacker]["pawstrike"]) {
  1863. let len = wmap2[attacky * defxn + attackx]
  1864. let spd = Math.max(
  1865. 0,
  1866. Math.round(
  1867. (this.obj[attacker].speed +
  1868. this.obj[attacker]["ragespeed"] +
  1869. this.obj[attacker]["speedaddon"]) *
  1870. this.obj[attacker].speedmodifier
  1871. )
  1872. )
  1873. if (
  1874. magic[attacker]["ent"] &&
  1875. magic[attacker]["ent"]["nowinit"] > 0
  1876. ) {
  1877. spd = 0
  1878. }
  1879. if (
  1880. this.obj[attacker].x == attackx &&
  1881. this.obj[attacker].y == attacky
  1882. ) {
  1883. len = spd
  1884. }
  1885. let movelen = spd - len
  1886. skillProbability = getSkillProbability(
  1887. hpa,
  1888. hpd,
  1889. Math.floor(movelen)
  1890. )
  1891. }
  1892. if (
  1893. (this.obj[attacker]["bindshot"] && range == 1) ||
  1894. (this.obj[attacker]["bindingstrike"] && range == 0)
  1895. ) {
  1896. skillProbability = getSkillProbability(
  1897. hpa,
  1898. Math.max(1, hpd - tPhysicalDamage),
  1899. 2
  1900. )
  1901. if (
  1902. skillProbability !=
  1903. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2), 2)
  1904. ) {
  1905. skillProbability =
  1906. skillProbability +
  1907. "% - " +
  1908. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2), 2)
  1909. }
  1910. }
  1911. if (
  1912. this.obj[attacker]["purge"] ||
  1913. this.obj[attacker]["cripplingwound"] ||
  1914. this.obj[attacker]["assault"] ||
  1915. (this.obj[attacker]["markoffire"] && range == 1) ||
  1916. (this.obj[attacker]["powerstrike"] && !this.obj[defender]["big"]) ||
  1917. this.obj[attacker]["lighting_attack"] ||
  1918. (this.obj[attacker]["whipstrike"] && range == 0) ||
  1919. (this.obj[attacker]["forcearrow"] && range == 1) ||
  1920. (this.obj[attacker]["stoning"] && range == 0) ||
  1921. this.obj[attacker]["paralyzing"] ||
  1922. this.obj[attacker]["hexingattack"]
  1923. ) {
  1924. skillProbability = getSkillProbability(
  1925. hpa,
  1926. Math.max(1, hpd - tPhysicalDamage)
  1927. )
  1928. if (
  1929. skillProbability !=
  1930. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2))
  1931. ) {
  1932. skillProbability =
  1933. skillProbability +
  1934. "% - " +
  1935. getSkillProbability(hpa, Math.max(1, hpd - tPhysicalDamage2))
  1936. }
  1937. }
  1938. function getSkillProbability(hpa, hpd, attempt = 1) {
  1939. let skillProbability = 0
  1940. if (hpa > hpd) {
  1941. skillProbability = 25 + 3 * (hpa / hpd)
  1942. } else {
  1943. skillProbability = 25 - 3 * (hpd / hpa)
  1944. }
  1945. skillProbability = Math.min(75, Math.max(5, skillProbability))
  1946. skillProbability = Math.round(
  1947. (1 -
  1948. Math.pow(
  1949. 1 - skillProbability / 100,
  1950. attempt * (soldiersLuck + 1)
  1951. )) *
  1952. 100
  1953. )
  1954. return skillProbability
  1955. }
  1956. }
  1957. unsafeWindow.showuron = function (mag, effect = "") {
  1958. if (myuron.line3 === undefined) {
  1959. var ttext = Make_Text("", uron_data)
  1960. set_X(ttext, uron_data.x)
  1961. set_Y(ttext, uron_data.y + 69)
  1962. myuron.line3 = ttext
  1963. Make_addChild(myuron2, ttext)
  1964. option = {
  1965. offsetX: -razmetka["war_images"][24][mqc["sdx"]],
  1966. offsetY:
  1967. -razmetka["war_images"][24][mqc["sdy"]] -
  1968. (razmetka["war_images"][19][mqc["ys"]] +
  1969. razmetka["war_images"][24][mqc["y"]]),
  1970. image: stage.pole.ground["war_images"],
  1971. width: razmetka["war_images"][24][mqc["xs"]],
  1972. height: razmetka["war_images"][24][mqc["ys"]],
  1973. crop: {
  1974. x: razmetka["war_images"][24][mqc["x"]],
  1975. y: razmetka["war_images"][24][mqc["y"]],
  1976. width: razmetka["war_images"][24][mqc["xs"]],
  1977. height: razmetka["war_images"][24][mqc["ys"]],
  1978. visible: 1,
  1979. },
  1980. listening: false,
  1981. }
  1982. var img_temp = My_Image(option)
  1983. img_temp.option = option
  1984. set_visible(img_temp, 1)
  1985. Make_addChild(myuron2, img_temp)
  1986. set_scaleX(img_temp, sub_scale * 0.4)
  1987. set_scaleY(img_temp, sub_scale * 0.4)
  1988. }
  1989. var line1 = 0
  1990. var line2 = 0
  1991. var line3 = stage.pole.luckMoraleProbability(activeobj, "luck")
  1992. if (umelka[1][0] == undefined) {
  1993. return 0
  1994. }
  1995. if (effect != "") {
  1996. line1 = ""
  1997. line2 = effect
  1998. } else if (mag == 1) {
  1999. if (ctrldown && targetMagicdamage > 0) {
  2000. line2 = targetMagicdamage
  2001. line1 = targetMagickills
  2002. } else {
  2003. line2 = Totalmagicdamage
  2004. line1 = Totalmagickills
  2005. }
  2006. } else {
  2007. if (ctrldown) {
  2008. line1 = Uronkills
  2009. if (Uronkills != Uronkills2) line1 += " - " + Uronkills2
  2010. line2 = PhysicalDamage
  2011. if (PhysicalDamage != PhysicalDamage2)
  2012. line2 += " - " + PhysicalDamage2
  2013. } else {
  2014. line1 = tUronkills
  2015. if (tUronkills != tUronkills2) {
  2016. line1 += " - " + tUronkills2
  2017. }
  2018. line2 = tPhysicalDamage
  2019. if (tPhysicalDamage != tPhysicalDamage2) {
  2020. line2 += " - " + tPhysicalDamage2
  2021. }
  2022. if (skillProbability != "") {
  2023. line2 += " (" + skillProbability + "%)"
  2024. }
  2025. }
  2026. }
  2027. var scale =
  2028. Math.max(min_uron_scale, stage[war_scr].scaling_ratio) *
  2029. MainPixelRatio
  2030. set_scaleX(myuron2, scale)
  2031. set_scaleY(myuron2, scale)
  2032. if (last_line1 != line1 || last_line2 != line2 || last_line3 != line3) {
  2033. last_line1 = line1
  2034. last_line2 = line2
  2035. last_line3 = line3
  2036. set_cache(myuron, false)
  2037. set_text(myuron.line1, line1 + " ")
  2038. set_text(myuron.line2, line2 + " ")
  2039. luckProbability = stage.pole.luckMoraleProbability(activeobj, "luck")
  2040. if (
  2041. mag == 1 ||
  2042. luckProbability == 0 ||
  2043. magicuse == "leap" ||
  2044. magicuse == "leap6"
  2045. ) {
  2046. myuron2.children[4].visible = 0
  2047. myuron.line3.visible = 0
  2048. } else {
  2049. myuron2.children[4].visible = 1
  2050. myuron.line3.visible = 1
  2051. set_text(myuron.line3, stage.pole.luckMoralePerc(activeobj, "luck"))
  2052. }
  2053. set_visible(myuron, 1)
  2054. set_strokeThickness(
  2055. myuron.line1,
  2056. Math.round(uron_stroke_width * Math.min(1, scale))
  2057. )
  2058. set_strokeThickness(
  2059. myuron.line2,
  2060. Math.round(uron_stroke_width * Math.min(1, scale))
  2061. )
  2062. set_strokeThickness(
  2063. myuron.line3,
  2064. Math.round(uron_stroke_width * Math.min(1, scale))
  2065. )
  2066. // myuron.cacheAsBitmap = true;
  2067. }
  2068. set_visible(myuron, 1)
  2069. // set_cache(myuron, true);
  2070. var sc = 1
  2071. var ratio = getDevicePixelRatio()
  2072. // if (android)
  2073. // {
  2074. var sc = stage[war_scr].scaling * ratio
  2075. // }
  2076. var rect = get_clientRect(myuron)
  2077. if (currentTip == 1) {
  2078. rect.width *= scale
  2079. rect.height *= scale
  2080. }
  2081. if (
  2082. currentTip == 1 &&
  2083. (rect.x > 6000 || rect.width > 2000 || rect.height > 200)
  2084. ) {
  2085. rect.width =
  2086. Math.min(
  2087. 300,
  2088. Math.max(myuron.line1.width, myuron.line2.width) + 20
  2089. ) * stage[war_scr].scaling
  2090. rect.height =
  2091. Math.min(100, myuron.line1.height * 2 + 5) * stage[war_scr].scaling
  2092. }
  2093. var gscaling = stage[war_scr].scaling
  2094. var xx2 = scr_xmouse
  2095. var max_x = original_width
  2096. if (android && stage_width > stage_height) {
  2097. max_x = original_width - pole_left - pole_right
  2098. }
  2099. if (xx2 + get_width(myuron) > max_x * gscaling) {
  2100. xx2 = max_x * gscaling - get_width(myuron)
  2101. }
  2102. var xx = xx2
  2103. var yy = scr_ymouse
  2104. if (!android) {
  2105. xx -= cursor_width * scale
  2106. yy += cursor_height * 1.5 * scale
  2107. } else {
  2108. xx -= cursor_width * scale
  2109. yy -= cursor_height * 4 * scale
  2110. if (yy < 3) yy = 3
  2111. }
  2112. if (yy + get_height(rect) * 1.2 > atby) {
  2113. yy = atby - get_height(rect) * 1.2
  2114. }
  2115. if (xx + get_width(rect) * 1.1 > stage_width) {
  2116. xx = stage_width - get_width(rect) * 1.1
  2117. }
  2118. set_X(myuron, Math.round(xx))
  2119. set_Y(myuron, Math.round(yy))
  2120. }
  2121. stage.pole.onMouseMoveFlash = unsafeWindow.onMouseMoveFlash = function (
  2122. from_event,
  2123. xmouse,
  2124. ymouse,
  2125. force,
  2126. reset,
  2127. lastcoords
  2128. ) {
  2129. attack_xr = 0
  2130. attack_yr = 0
  2131. targetMagicdamage = 0
  2132. targetMagickills = 0
  2133. if (buttons_visible["win_dialog"]) return 0
  2134. if (buttons_visible["scroll_runes"]) return 0
  2135. if (buttons_visible["magic_book"]) return 0
  2136. if (buttons_visible["win_SeparateArmy"]) return 0
  2137. if (buttons_visible["win_Mission"]) return 0
  2138. if (buttons_visible["win_Settings"]) return 0
  2139. if (total_delta > 20) return 0
  2140. if (typeof unsafeWindow.csword === "undefined") return 0
  2141. shiftdown = false
  2142. ctrldown = false
  2143. if (!android) {
  2144. var isRightMB = false
  2145. var e = 0
  2146. if ((typeof event !== "undefined" && event) || from_event) {
  2147. var e = from_event
  2148. if (typeof event !== "undefined" && event) e = event
  2149. if (e.which) {
  2150. if (e.which == 2 || e.which == 3) {
  2151. isRightMB = 1
  2152. }
  2153. } else if (e.button) isRightMB = e.button >= 2
  2154. }
  2155. if (KeyisDown(16)) shiftdown = true
  2156. else shiftdown = false
  2157. if (KeyisDown(17) || isRightMB) ctrldown = true
  2158. else ctrldown = false
  2159. }
  2160. shiftdown = (shiftdown || shift_button) && shift_ok
  2161. ctrldown = ctrldown || info_button
  2162. if (activeobj > 0 && this.obj[activeobj]) {
  2163. if (this.obj[activeobj]["was_atb"] > 0) {
  2164. this.reset_temp_magic()
  2165. this.showatb()
  2166. this.obj[activeobj]["was_atb"] = 0
  2167. }
  2168. if (
  2169. magicuse != "" &&
  2170. this.obj[activeobj][magicuse + "elem"] == "air" &&
  2171. ((this.obj[activeobj]["hero"] && isperk(activeobj, 100)) ||
  2172. this.obj[activeobj]["master_of_storms"])
  2173. ) {
  2174. this.reset_temp_magic()
  2175. this.showatb()
  2176. }
  2177. if (
  2178. magicuse != "" &&
  2179. (magicuse == "circle_of_winter" || magicuse == "icebolt") &&
  2180. ((this.obj[activeobj]["hero"] && isperk(activeobj, 99)) ||
  2181. this.obj[activeobj]["master_of_ice"])
  2182. ) {
  2183. this.reset_temp_magic()
  2184. this.showatb()
  2185. }
  2186. }
  2187. movecounter++
  2188. var i = 0,
  2189. bigok = false,
  2190. len = 0,
  2191. xk = 0,
  2192. yk = 0,
  2193. range = 0,
  2194. xaa = 0,
  2195. yaa = 0,
  2196. x = 0,
  2197. y = 0,
  2198. xr = 0,
  2199. yr = 0,
  2200. a = 0,
  2201. ab = 0,
  2202. ac = 0,
  2203. xb = 0,
  2204. yb = 0,
  2205. res = 0,
  2206. ok = false
  2207. if (onrune) {
  2208. if (lastshad > 0) {
  2209. set_visible(shado[lastshad], 0)
  2210. set_visible(shado[lastshad + 1], 0)
  2211. set_visible(shado[lastshad + 1 + defxn], 0)
  2212. set_visible(shado[lastshad + defxn], 0)
  2213. }
  2214. lastshad = 0
  2215. return 0
  2216. }
  2217. if (itrunepanel()) {
  2218. return 0
  2219. }
  2220. attackx = 0
  2221. attacky = 0
  2222. movex = 0
  2223. movey = 0
  2224. magicx = -1
  2225. magicy = 0
  2226. scr_ymouse = ymouse
  2227. scr_xmouse = xmouse
  2228. if (lastcoords == true) {
  2229. scr_ymouse = scr_ymouselast
  2230. scr_xmouse = scr_xmouselast
  2231. }
  2232. scr_ymouselast = scr_ymouse
  2233. scr_xmouselast = scr_xmouse
  2234. var r = getxa_from(scr_xmouse, scr_ymouse)
  2235. x = r.x + 1
  2236. y = r.y + 1
  2237. xr = Math.ceil(r.x)
  2238. yr = Math.ceil(r.y)
  2239. if (interactive_obj > 0) {
  2240. if (
  2241. xr > 0 &&
  2242. yr > 0 &&
  2243. xr <= defxn - 2 &&
  2244. yr <= defyn &&
  2245. mapobj[yr * defxn + xr] == interactive_obj
  2246. ) {
  2247. } else {
  2248. xr = this.obj[interactive_obj].x
  2249. yr = this.obj[interactive_obj].y
  2250. }
  2251. }
  2252. xr_last = xr
  2253. yr_last = yr
  2254.  
  2255. xr_z = scr_xmouse
  2256. yr_z = scr_ymouse
  2257. if (reset) {
  2258. xr_z = -100
  2259. yr_z = -100
  2260. xr = -5
  2261. yr = -5
  2262. }
  2263. if (buttons_visible["win_InfoCreatureEffect"]) return 0
  2264. if (buttons_visible["win_InfoHero"]) return 0
  2265. if (buttons_visible["win_InfoHero2"]) return 0
  2266. if (buttons_visible["win_InfoCreature"]) return 0
  2267. if (xr > 0 && yr > 0 && xr <= defxn - 2 && yr <= defyn) {
  2268. show_coords(xr, yr)
  2269. if (firewalls[yr * defxn + xr] > 0) {
  2270. let lifeTime = (
  2271. magic[Math.floor(firewalls[yr * defxn + xr] / 100)][
  2272. "F" + ((firewalls[yr * defxn + xr] % 100) + "").padStart(2, "0")
  2273. ]["nowinit"] / 100
  2274. ).toFixed(2)
  2275. testBlock(lifeTime, true)
  2276. } else if (fireInfo) {
  2277. testBlock()
  2278. }
  2279. } else {
  2280. show_coords(0, 0)
  2281. }
  2282. if (
  2283. loader.loading ||
  2284. ((someactive || command != "") && !gpause) ||
  2285. buttons_visible["magic_book"] ||
  2286. buttons_visible["scroll_runes"]
  2287. ) {
  2288. return 0
  2289. }
  2290. if (!inserted && inssubmit) {
  2291. return 0
  2292. }
  2293.  
  2294. if (!inserted && !inssubmit) {
  2295. if (reset) {
  2296. xr = -5
  2297. yr = -5
  2298. }
  2299. if (activestek <= 0) {
  2300. lastshad = -1
  2301. }
  2302. if (xr + yr * defxn != lastshad) {
  2303. if (shado[lastshad]) set_visible(shado[lastshad], 0)
  2304. if (shado[lastshad + 1]) set_visible(shado[lastshad + 1], 0)
  2305. if (shado[lastshad + 1 + defxn])
  2306. set_visible(shado[lastshad + 1 + defxn], 0)
  2307. if (shado[lastshad + defxn]) set_visible(shado[lastshad + defxn], 0)
  2308. lastshad = xr + yr * defxn
  2309. if (activestek > 0) {
  2310. if (stekx[activestek] > 0) {
  2311. set_visible(
  2312. shado[stekx[activestek] + steky[activestek] * defxn],
  2313. 1
  2314. )
  2315. if (this.obj[activestek].big) {
  2316. set_visible(
  2317. shado[stekx[activestek] + steky[activestek] * defxn + 1],
  2318. 1
  2319. )
  2320. set_visible(
  2321. shado[
  2322. stekx[activestek] + steky[activestek] * defxn + 1 + defxn
  2323. ],
  2324. 1
  2325. )
  2326. set_visible(
  2327. shado[
  2328. stekx[activestek] + steky[activestek] * defxn + defxn
  2329. ],
  2330. 1
  2331. )
  2332. }
  2333. if (this.obj[activestek].bigx) {
  2334. set_visible(
  2335. shado[stekx[activestek] + steky[activestek] * defxn + 1],
  2336. 1
  2337. )
  2338. }
  2339. if (this.obj[activestek].bigy) {
  2340. set_visible(
  2341. shado[
  2342. stekx[activestek] + steky[activestek] * defxn + defxn
  2343. ],
  2344. 1
  2345. )
  2346. }
  2347. }
  2348. po = Math.floor((playero - 1) / 2)
  2349. if (getbtype(btype) == 1 || getbtype(btype) == 3) {
  2350. if (playero > 2) {
  2351. playero1 = playero + 1
  2352. } else {
  2353. playero1 = playero
  2354. }
  2355. t1 = 0
  2356. t2 = 0
  2357. t11 = 0
  2358. t21 = 0
  2359. k = playero
  2360. k1 = playero1
  2361. if (isperk(0, 12, k)) {
  2362. if (k % 2 == 0) {
  2363. t1 = -1
  2364. } else {
  2365. t2 = 1
  2366. }
  2367. if (k1 % 2 == 0) {
  2368. t11 = -1
  2369. } else {
  2370. t21 = 1
  2371. }
  2372. }
  2373. for (
  2374. x = 9 - (playero % 2) * 8 + t1;
  2375. x <= 9 - (playero % 2) * 8 + 3 + t2;
  2376. x++
  2377. ) {
  2378. for (
  2379. y = (defyn - 4) * ((playero1 + 1) % 2) + 1 + t11;
  2380. y <= (defyn - 4) * ((playero1 + 1) % 2) + 4 + t21;
  2381. y++
  2382. ) {
  2383. setmap(x, y, 250)
  2384. }
  2385. }
  2386. } else {
  2387. if (
  2388. getbtype(btype) == NEWKZS ||
  2389. btype == _PIRATE_NEW_EVENT ||
  2390. winter == "arena8" ||
  2391. btype == _VILLAGE_EVENT
  2392. ) {
  2393. setpole(btype, 250, playero, yourside, defxn - 2, defyn)
  2394. } else if (
  2395. getbtype(btype) == 4 ||
  2396. getbtype(btype, defxn - 2, defyn) == _NEWTHIEF ||
  2397. getbtype(btype) == _NECR_EVENT2 ||
  2398. btype == _ELKA_DEFENSE
  2399. ) {
  2400. setpole(btype, 250, playero, yourside, defxn - 2, defyn, po)
  2401. } else {
  2402. t1 = 0
  2403. t2 = 0
  2404. k = playero
  2405. if (isperk(0, 12, k)) {
  2406. if ((k + camp_mirror) % 2 == 0) {
  2407. t1 = -1
  2408. } else {
  2409. t2 = 1
  2410. }
  2411. }
  2412. y1 = Math.floor((po * defyn) / yourside + 1)
  2413. y2 = Math.floor(((po + 1) * defyn) / yourside)
  2414. if (fullinsert) {
  2415. y1 = 1
  2416. y2 = defyn
  2417. }
  2418. for (
  2419. x =
  2420. defxn -
  2421. 3 -
  2422. ((playero + camp_mirror) % 2) * (defxn - 4) +
  2423. t1;
  2424. x <=
  2425. defxn -
  2426. 3 -
  2427. ((playero + camp_mirror) % 2) * (defxn - 4) +
  2428. 1 +
  2429. t2;
  2430. x++
  2431. ) {
  2432. for (y = y1; y <= y2; y++) {
  2433. setmap(x, y, 250)
  2434. }
  2435. }
  2436. }
  2437. }
  2438. this.setotherobjs()
  2439. for (k = 1; k <= Math.max(7, stackcount); k++) {
  2440. if (k != activestek) {
  2441. setmap(stekx[k], steky[k], 210)
  2442. if (this.obj[k]) {
  2443. if (this.obj[k].big) {
  2444. setmap(stekx[k] + 1, steky[k], 210)
  2445. setmap(stekx[k] + 1, steky[k] + 1, 210)
  2446. setmap(stekx[k], steky[k] + 1, 210)
  2447. }
  2448. if (this.obj[k].bigx) {
  2449. setmap(stekx[k] + 1, steky[k], 210)
  2450. }
  2451. if (this.obj[k].bigy) {
  2452. setmap(stekx[k], steky[k] + 1, 210)
  2453. }
  2454. }
  2455. }
  2456. }
  2457. var bigx = this.obj[activestek]["big"]
  2458. var bigy = this.obj[activestek]["big"]
  2459. if (this.obj[activestek]["bigx"]) bigx = 1
  2460. if (this.obj[activestek]["bigy"]) bigy = 1
  2461. var cnt = 0
  2462. var xp = Array(0, -1, 0, -1)
  2463. var yp = Array(0, 0, -1, -1)
  2464. var xro = xr,
  2465. yro = yr
  2466. if (this.obj[activestek]["big"]) cnt = 3
  2467. for (k = 0; k <= cnt; k++) {
  2468. ok = true
  2469. xr = xro + xp[k]
  2470. yr = yro + yp[k]
  2471. xr_last = xr
  2472. yr_last = yr
  2473. for (x = 0; x <= bigx; x++) {
  2474. for (y = 0; y <= bigy; y++) {
  2475. if (getmap(x + xr, y + yr) != 250) {
  2476. ok = false
  2477. }
  2478. }
  2479. }
  2480. if (ok) break
  2481. }
  2482. if (ok && (xr != stekx[activestek] || yr != steky[activestek])) {
  2483. lastshad = xr + yr * defxn
  2484. setstekx = xr
  2485. setsteky = yr
  2486. set_visible(shado[xr + yr * defxn], 1)
  2487. if (this.obj[activestek].big) {
  2488. set_visible(shado[xr + yr * defxn + 1], 1)
  2489. set_visible(shado[xr + yr * defxn + 1 + defxn], 1)
  2490. set_visible(shado[xr + yr * defxn + defxn], 1)
  2491. }
  2492. if (this.obj[activestek].bigx) {
  2493. set_visible(shado[xr + yr * defxn + 1], 1)
  2494. }
  2495. if (this.obj[activestek].bigy) {
  2496. set_visible(shado[xr + yr * defxn + defxn], 1)
  2497. }
  2498. } else {
  2499. setstekx = -1
  2500. setsteky = -1
  2501. }
  2502. }
  2503. }
  2504. var i = mapobj[yr * defxn + xr]
  2505. if (i > 0) {
  2506. if (
  2507. (activeobj > 0 || someactive == false || gpause) &&
  2508. this.obj[i].doing != "walk" &&
  2509. (activeobj != i || gpause) &&
  2510. !this.obj[i].hero &&
  2511. showway
  2512. ) {
  2513. this.showposway(i, 0, activeobj)
  2514. if (!gpause) this.checkthrower(activeobj)
  2515. }
  2516. } else {
  2517. var was = 0,
  2518. m = 0
  2519. lastpole = 0
  2520. if (this.shadows)
  2521. for (x = 0; x <= defxn + 1; x++) {
  2522. if (!this.shadows.shad1[x]) continue
  2523. for (y = 1; y <= defyn; y++) {
  2524. if (!this.shadows.shad1[x][y]) continue
  2525. m = getmap(x, y)
  2526. if (m == 210) {
  2527. m = 250
  2528. }
  2529. if (m == 200 || m == 250 || mapzz[y * defxn + x] == 240) {
  2530. if (!was) set_visible(this.shadows.shadow1, 1)
  2531. was = 1
  2532. }
  2533. if (this.shadows.shad1[x][y].shadowed == 1) {
  2534. set_Alpha(this.shadows.shad1[x][y], 0.3)
  2535. }
  2536. if (mapzz[y * defxn + x] == 240) {
  2537. set_Alpha(this.shadows.shad1[x][y], 0.5)
  2538. this.shadows.shad1[x][y].shadowed = 1
  2539. }
  2540. if (m == 200 && gpause) continue
  2541. if (m == 200 || m == 250 || mapzz[y * defxn + x] == 240) {
  2542. set_visible(this.shadows.shad1[x][y], 1)
  2543. } else {
  2544. set_visible(this.shadows.shad1[x][y], 0)
  2545. }
  2546. }
  2547. }
  2548. this.shadows.shadow1.no_filter = true
  2549. if (shadow_cache) set_cache(this.shadows.shadow1, true, 1)
  2550. }
  2551. return 0
  2552. }
  2553. var cur_atb = this.get_cur_atb(scr_xmouse, scr_ymouse)
  2554. if (cur_atb > 0 && zoomed == false) {
  2555. if (combat_zoom_timeout > 0) {
  2556. clearTimeout(combat_zoom_timeout)
  2557. combat_zoom_timeout = 0
  2558. }
  2559. k = cur_atb - 1
  2560. for (var kk = 0; kk <= atb_cnt; kk++) {
  2561. if (kk != k) {
  2562. if (
  2563. typeof this.p_array === "undefined" ||
  2564. !this.portraits[this.p_array[kk]]
  2565. )
  2566. continue
  2567. showshadow(this.portraits[this.p_array[kk]].under, false)
  2568. }
  2569. }
  2570. if (
  2571. this.obj[atb[k + atbsd]] &&
  2572. !this.obj[atb[k + atbsd]].shadowed &&
  2573. !someactive
  2574. ) {
  2575. this.showmi(atb[k + atbsd])
  2576. var i = atb[k + atbsd]
  2577. showshadow(this.obj[atb[k + atbsd]], true)
  2578. lasti = atb[k + atbsd]
  2579. showshadow(this.portraits[this.p_array[k]].under, true)
  2580. if (
  2581. this.obj[atb[k + atbsd]].nownumber > 0 &&
  2582. !this.obj[atb[k + atbsd]].stone &&
  2583. !this.obj[atb[k + atbsd]].portal
  2584. ) {
  2585. this.obj[atb[k + atbsd]].ontop = 1
  2586. this.obj[atb[k + atbsd]].get_obj_z(this.obj[atb[k + atbsd]].y)
  2587. if (this.obj[atb[k + atbsd]].hero) {
  2588. set_visible(this.obj[atb[k + atbsd]].number, 1)
  2589. }
  2590. showshadow(this.obj[atb[k + atbsd]], true)
  2591. need_sort = true
  2592. }
  2593. var len = this.obj_array.length
  2594. for (var k1 = 0; k1 < len; k1++) {
  2595. i = this.obj_array[k1]
  2596. if (i != atb[k + atbsd] && this.obj[i].shadowed) {
  2597. clearpole2()
  2598. if (
  2599. this.obj[i].nownumber > 0 &&
  2600. !this.obj[i].stone &&
  2601. !this.obj[i].portal
  2602. ) {
  2603. this.obj[i].ontop = 0
  2604. this.obj[i].get_obj_z(this.obj[i].y)
  2605. if (this.obj[i].hero) {
  2606. set_visible(this.obj[i].number, 0)
  2607. }
  2608. need_sort = true
  2609. }
  2610. showshadow(this.obj[i], false)
  2611. }
  2612. }
  2613. }
  2614. if (lastk != k) re_cache_atb()
  2615. lastk = k
  2616. if (inserted) {
  2617. set_cursor(0)
  2618. if (myuron) set_visible(myuron, 0)
  2619. if (csword) set_visible(csword, 0)
  2620. clearshado()
  2621. clearshadway()
  2622. }
  2623. return 0
  2624. }
  2625. lastk = -1
  2626. if (reset) {
  2627. xr = -5
  2628. yr = -5
  2629. }
  2630. mishowed = false
  2631. var i = mapobj[yr * defxn + xr]
  2632. var nowi = 0
  2633. if (lasti > 0 && lasti != i && this.obj[lasti].shadowed) {
  2634. i = lasti
  2635. lasti = 0
  2636. for (k = 0; k <= atb_cnt; k++) {
  2637. if (atb[k + atbsd] == i) {
  2638. showshadow(this.portraits[this.p_array[k]].under, false)
  2639. }
  2640. }
  2641. if (!mishowed) {
  2642. set_visible(mini_info_panel, 0)
  2643. this.showmi(-1)
  2644. if (btype == 20 || btype == _SURVIVAL_GNOM || btype == _2SURVIVAL) {
  2645. this.showmitnv()
  2646. }
  2647. if (btype == 8) {
  2648. this.showmitnv(1)
  2649. }
  2650. if (btype == 119) {
  2651. // this.showmitnv(2);
  2652. }
  2653. clearpole2()
  2654. }
  2655. if (
  2656. this.obj[i].nownumber > 0 &&
  2657. !this.obj[i].stone &&
  2658. !this.obj[i].portal
  2659. ) {
  2660. this.obj[i].ontop = 0
  2661. this.obj[i].get_obj_z(this.obj[i].y)
  2662. if (this.obj[i].hero) {
  2663. set_visible(this.obj[i].number, 0)
  2664. }
  2665. need_sort = true
  2666. }
  2667. showshadow(this.obj[i], false)
  2668. if (!(mapobj[yr * defxn + xr] > 0)) re_cache_atb()
  2669. }
  2670. if (gpause) this.fill_mapobj()
  2671. if (i > 0) {
  2672. bigok = false
  2673. if (this.obj[i].big) {
  2674. if (
  2675. this.obj[i].x <= xr &&
  2676. this.obj[i].x + 1 >= xr &&
  2677. this.obj[i].y <= yr &&
  2678. this.obj[i].y + 1 >= yr
  2679. ) {
  2680. bigok = true
  2681. }
  2682. }
  2683. if (this.obj[i].bigx) {
  2684. if (
  2685. this.obj[i].x <= xr &&
  2686. this.obj[i].x + 1 >= xr &&
  2687. this.obj[i].y == yr
  2688. ) {
  2689. bigok = true
  2690. }
  2691. }
  2692. if (this.obj[i].bigy) {
  2693. if (
  2694. this.obj[i].y <= yr &&
  2695. this.obj[i].y + 1 >= yr &&
  2696. this.obj[i].x == xr
  2697. ) {
  2698. bigok = true
  2699. }
  2700. }
  2701. if (
  2702. !this.obj[i].rock &&
  2703. this.obj[i].nownumber > 0 &&
  2704. (!someactive || gpause) &&
  2705. ((this.obj[i].x == xr && this.obj[i].y == yr) || bigok)
  2706. ) {
  2707. nowi = i
  2708. if (!this.obj[i].shadowed && this.obj[i].inited_show) {
  2709. if (!this.obj[i].stone && !this.obj[i].portal) {
  2710. this.obj[i].ontop = 1
  2711. this.obj[i].get_obj_z(this.obj[i].y)
  2712. if (this.obj[i].hero) {
  2713. set_visible(this.obj[i].number, 1)
  2714. }
  2715. need_sort = true
  2716. }
  2717. mishowed = true
  2718. this.showmi(i)
  2719. showshadow(this.obj[i], true)
  2720. if (
  2721. (activeobj > 0 || someactive == false || gpause) &&
  2722. this.obj[i].doing != "walk" &&
  2723. (activeobj != i || gpause) &&
  2724. !this.obj[i].hero &&
  2725. showway
  2726. ) {
  2727. this.showposway(i, 0, activeobj)
  2728. if (!gpause) this.checkthrower(activeobj)
  2729. }
  2730. for (k = 0; k <= atb_cnt; k++) {
  2731. if (atb[k + atbsd] == i) {
  2732. showshadow(this.portraits[this.p_array[k]].under, true)
  2733. }
  2734. }
  2735. }
  2736. }
  2737. if (lasti != i) re_cache_atb()
  2738. }
  2739. if (i > 0) lasti = i
  2740. else lasti = 0
  2741. crun_visible2 = true
  2742. if (typeof unsafeWindow.myuron !== "undefined") set_visible(myuron, 0)
  2743. k = getmap(xr, yr)
  2744. clearshado()
  2745. if (k == 200) {
  2746. k = 250
  2747. }
  2748. if (xr > defxn - 1 || xr < 0) {
  2749. k = 0
  2750. }
  2751. if (
  2752. magicuse != "" &&
  2753. magicuse != "layhands" &&
  2754. magicuse != "orderofchief" &&
  2755. magicuse != "harmtouch" &&
  2756. magicuse != "hailstorm" &&
  2757. magicuse != "allaroundslash" &&
  2758. magicuse != "feralcharge" &&
  2759. magicuse != "slam" &&
  2760. magicuse != "unstoppablecharge" &&
  2761. magicuse != "mightyslam" &&
  2762. magicuse != "incinerate" &&
  2763. magicuse != "leap" &&
  2764. magicuse != "leap6" &&
  2765. magicuse != "harpoonstrike"
  2766. ) {
  2767. k = magicuse
  2768. }
  2769. if (magicuse == "ssh") {
  2770. if (
  2771. xr >= 1 &&
  2772. xr <= defxn - 2 &&
  2773. yr >= 1 &&
  2774. yr <= defyn &&
  2775. (Math.abs(xr - this.obj[activeobj].x) > 1 ||
  2776. Math.abs(yr - this.obj[activeobj].y) > 1)
  2777. ) {
  2778. k = "ssh"
  2779. } else {
  2780. k = 0
  2781. }
  2782. }
  2783. if (
  2784. k == "mdispel" ||
  2785. k == "mstoneskin" ||
  2786. k == "mbless" ||
  2787. k == "mrighteous_might" ||
  2788. k == "mdeflect_missile" ||
  2789. k == "mskyandearth"
  2790. ) {
  2791. k = "mfast"
  2792. }
  2793. if (
  2794. k == "mslow" ||
  2795. k == "mcurse" ||
  2796. k == "mdray" ||
  2797. k == "msuffering" ||
  2798. k == "mconfusion"
  2799. ) {
  2800. k = "mslow"
  2801. }
  2802. if (k == "knightmark" || k == "necr_soul") {
  2803. k = "knightmark"
  2804. }
  2805. if (
  2806. k == "righteous_might" ||
  2807. k == "deflect_missile" ||
  2808. k == "antimagic"
  2809. ) {
  2810. k = "fast"
  2811. }
  2812. if (k == "implosion") {
  2813. k = "lighting"
  2814. }
  2815. if (k == "divinev") {
  2816. k = "angerofhorde"
  2817. }
  2818. if (k == "suffering") {
  2819. k = "curse"
  2820. }
  2821. var enemy = 210
  2822. if (magicuse == "layhands") enemy = 211
  2823. if (magicuse == "orderofchief") enemy = 211
  2824. switch (k) {
  2825. case "magicfist":
  2826. set_cursor(6)
  2827. if (xr + yr * defxn != lastshad) {
  2828. if (lastshad > 0) {
  2829. setshad(0, 0, 0, 0, false)
  2830. }
  2831. }
  2832. if (getmap(xr, yr) != 210) {
  2833. res = 0
  2834. break
  2835. }
  2836. lastshad = xr + yr * defxn
  2837. setshad(0, 0, 0, 0, true)
  2838. res = "magicfist"
  2839. magicx = xr
  2840. magicy = yr
  2841. this.calcmagic(activeobj, xr, yr, magicuse)
  2842. break
  2843. case "lighting":
  2844. set_cursor(6)
  2845. if (xr + yr * defxn != lastshad) {
  2846. if (lastshad > 0) {
  2847. setshad(0, 0, 0, 0, false)
  2848. }
  2849. }
  2850. if (getmap(xr, yr) != 210) {
  2851. res = 0
  2852. break
  2853. }
  2854. lastshad = xr + yr * defxn
  2855. setshad(0, 0, 0, 0, true)
  2856. res = "lighting"
  2857. magicx = xr
  2858. magicy = yr
  2859. this.calcmagic(activeobj, xr, yr, magicuse)
  2860. break
  2861. case "chainlighting":
  2862. set_cursor(6)
  2863. if (xr + yr * defxn != lastshad) {
  2864. if (lastshad > 0) {
  2865. setshad(0, 0, 0, 0, false)
  2866. lastshad = -2
  2867. clearshado()
  2868. var len = this.obj_array.length
  2869. for (var k = 0; k < len; k++) {
  2870. i = this.obj_array[k]
  2871. if (
  2872. this.obj[i].inited_image == true &&
  2873. this.obj[i].inited_show
  2874. ) {
  2875. this.obj[i].set_number()
  2876. }
  2877. }
  2878. }
  2879. }
  2880. if (getmap(xr, yr) != 210) {
  2881. res = 0
  2882. break
  2883. }
  2884. lastshad = xr + yr * defxn
  2885. setshad(0, 0, 0, 0, true)
  2886. res = "chainlighting"
  2887. magicx = xr
  2888. magicy = yr
  2889. this.calcchainlighting(activeobj, xr, yr, magicuse)
  2890. lastChain = activeobj
  2891. break
  2892. case "knightmark":
  2893. set_cursor(6)
  2894. if (xr + yr * defxn != lastshad) {
  2895. if (lastshad > 0) {
  2896. setshad(0, 0, 0, 0, false)
  2897. }
  2898. }
  2899. ok = false
  2900. var len = this.obj_array.length
  2901. for (var k1 = 0; k1 < len; k1++) {
  2902. i = this.obj_array[k1]
  2903. if (
  2904. !this.obj[i].warmachine &&
  2905. !this.obj[i].hero &&
  2906. i == mapobj[xr + yr * defxn] &&
  2907. this.obj[i].owner == this.obj[activeobj].owner &&
  2908. this.obj[i].nownumber > 0 &&
  2909. !magic[i]["sum"]
  2910. ) {
  2911. ok = true
  2912. break
  2913. }
  2914. }
  2915. if (!ok) {
  2916. res = 0
  2917. break
  2918. }
  2919. lastshad = xr + yr * defxn
  2920. setshad(0, 0, 0, 0, true)
  2921. res = "fast"
  2922. magicx = xr
  2923. magicy = yr
  2924. break
  2925. case "dispel":
  2926. set_cursor(6)
  2927. if (xr + yr * defxn != lastshad) {
  2928. if (lastshad > 0) {
  2929. setshad(0, 0, 0, 0, false)
  2930. }
  2931. }
  2932. ok = false
  2933. var len = this.obj_array.length
  2934. for (var k1 = 0; k1 < len; k1++) {
  2935. i = this.obj_array[k1]
  2936. if (
  2937. i == mapobj[xr + yr * defxn] &&
  2938. this.obj[i].nownumber > 0 &&
  2939. !this.obj[i].hero
  2940. ) {
  2941. ok = true
  2942. break
  2943. }
  2944. }
  2945. if (!ok) {
  2946. res = 0
  2947. break
  2948. }
  2949. lastshad = xr + yr * defxn
  2950. setshad(0, 0, 0, 0, true)
  2951. res = "fast"
  2952. magicx = xr
  2953. magicy = yr
  2954. break
  2955. case "mfast":
  2956. set_cursor(6)
  2957. var p = 2
  2958. if (xr + yr * defxn != lastshad) {
  2959. if (lastshad > 0) {
  2960. setshad(-1, -1, p, p, false)
  2961. }
  2962. }
  2963. if (magicuse == "mfast") {
  2964. this.reset_temp_magic()
  2965. this.showatb()
  2966. }
  2967. if (xr > 0 && xr <= defxn - 2 && yr > 0 && yr <= defyn) {
  2968. } else {
  2969. return 0
  2970. }
  2971. lastshad = xr + yr * defxn
  2972. setshad(-1, -1, p, p, true)
  2973. if (magicuse == "mfast") {
  2974. this.reset_temp_magic()
  2975. for (var xrr = xr - 1; xrr <= xr + p; xrr++)
  2976. for (var yrr = yr - 1; yrr <= yr + p; yrr++) {
  2977. var i = mapobj[xrr + yrr * defxn]
  2978. if (
  2979. i > 0 &&
  2980. i < 1000 &&
  2981. !this.obj[i].warmachine &&
  2982. !this.obj[i].immunity &&
  2983. !this.obj[i].enchantedarmor &&
  2984. !this.obj[i].hero &&
  2985. this.obj[i].side == this.obj[activeobj].getside() &&
  2986. this.obj[i].nownumber > 0
  2987. ) {
  2988. setn_temp_magic(i, "fst")
  2989. }
  2990. }
  2991. this.showatb()
  2992. }
  2993. res = "mfast"
  2994. magicx = xr
  2995. magicy = yr
  2996. break
  2997. case "mslow":
  2998. set_cursor(6)
  2999. var p = 2
  3000. if (xr + yr * defxn != lastshad) {
  3001. if (lastshad > 0) {
  3002. setshad(-2, -2, p, p, false)
  3003. }
  3004. }
  3005. if (magicuse == "mslow") {
  3006. this.reset_temp_magic()
  3007. this.showatb()
  3008. }
  3009. if (xr > 0 && xr <= defxn - 2 && yr > 0 && yr <= defyn) {
  3010. } else {
  3011. return 0
  3012. }
  3013. lastshad = xr + yr * defxn
  3014. setshad(-2, -2, p, p, true)
  3015. if (magicuse == "mslow") {
  3016. this.reset_temp_magic()
  3017. for (var xrr = xr - 2; xrr <= xr + p; xrr++)
  3018. for (var yrr = yr - 2; yrr <= yr + p; yrr++) {
  3019. var i = mapobj[xrr + yrr * defxn]
  3020. if (
  3021. i > 0 &&
  3022. !this.obj[i].warmachine &&
  3023. !this.obj[i].islow &&
  3024. !this.obj[i].immunity &&
  3025. !this.obj[i].absolutepurity &&
  3026. !this.obj[i].enchantedarmor &&
  3027. !this.obj[i].hero &&
  3028. this.obj[i].side != this.obj[activeobj].getside() &&
  3029. this.obj[i].nownumber > 0
  3030. ) {
  3031. setn_temp_magic(i, "slw")
  3032. }
  3033. }
  3034. this.showatb()
  3035. }
  3036. res = "mslow"
  3037. magicx = xr
  3038. magicy = yr
  3039. break
  3040. case "mpoison":
  3041. set_cursor(6)
  3042. var p = 1
  3043. if (xr + yr * defxn != lastshad) {
  3044. if (lastshad > 0) {
  3045. setshad(-1, -1, p, p, false)
  3046. }
  3047. }
  3048. if (xr > 0 && xr <= defxn - 2 && yr > 0 && yr <= defyn) {
  3049. } else {
  3050. return 0
  3051. }
  3052. lastshad = xr + yr * defxn
  3053. setshad(-1, -1, p, p, true)
  3054. res = "mfast"
  3055. magicx = xr
  3056. magicy = yr
  3057. this.calcmagic(activeobj, xr, yr, magicuse)
  3058. break
  3059. case "phantom_forces":
  3060. set_cursor(6)
  3061. if (xr + yr * defxn != lastshad) {
  3062. if (lastshad > 0) {
  3063. setshad(0, 0, 0, 0, false)
  3064. }
  3065. }
  3066. ok = false
  3067. var len = this.obj_array.length
  3068. for (var k1 = 0; k1 < len; k1++) {
  3069. i = this.obj_array[k1]
  3070. if (
  3071. !this.obj[i].hero &&
  3072. !this.obj[i].warmachine &&
  3073. i == mapobj[xr + yr * defxn] &&
  3074. this.obj[i].owner == this.obj[activeobj].owner &&
  3075. this.obj[i].nownumber > 0 &&
  3076. !magic[i]["sum"] &&
  3077. !magic[i]["phm"] &&
  3078. !magic[i]["whp"] &&
  3079. this.obj[i].level <=
  3080. this.obj[activeobj]["phantom_forceseffmain"]
  3081. ) {
  3082. j = i
  3083. ok = true
  3084. break
  3085. }
  3086. }
  3087. if (!ok) {
  3088. res = 0
  3089. break
  3090. }
  3091. xo = this.obj[j].x
  3092. yo = this.obj[j].y
  3093. b = 0
  3094. var bigx = this.obj[j]["big"]
  3095. var bigy = this.obj[j]["big"]
  3096. if (this.obj[j]["bigx"]) bigx = 1
  3097. if (this.obj[j]["bigy"]) bigy = 1
  3098. ok = false
  3099. i = activeobj
  3100. setmap(this.obj[i].x, this.obj[i].y, 210, i)
  3101. if (this.obj[i].big) {
  3102. setmap(this.obj[i].x, this.obj[i].y + 1, 210, i)
  3103. setmap(this.obj[i].x + 1, this.obj[i].y + 1, 210, i)
  3104. setmap(this.obj[i].x + 1, this.obj[i].y, 210, i)
  3105. }
  3106. if (this.obj[i].bigx) {
  3107. setmap(this.obj[i].x + 1, this.obj[i].y, 210, i)
  3108. }
  3109. if (this.obj[i].bigy) {
  3110. setmap(this.obj[i].x, this.obj[i].y + 1, 210, i)
  3111. }
  3112. for (x = xo - 1 - bigx; x <= xo + 1 + bigx; x++) {
  3113. for (y = yo - 1 - bigy; y <= yo + 1 + bigy; y++) {
  3114. ok2 = true
  3115. for (xz = x; xz <= x + bigx; xz++) {
  3116. for (yz = y; yz <= y + bigy; yz++) {
  3117. if (
  3118. xz < 1 ||
  3119. yz < 1 ||
  3120. yz > defyn ||
  3121. xz > defxn - 2 ||
  3122. getmap(xz, yz) == 210 ||
  3123. getmap(xz, yz) == 211
  3124. ) {
  3125. ok2 = false
  3126. }
  3127. }
  3128. }
  3129. if (ok2) {
  3130. ok = true
  3131. }
  3132. }
  3133. }
  3134. i = activeobj
  3135. setmap(this.obj[i].x, this.obj[i].y, 0, i)
  3136. if (this.obj[i].big) {
  3137. setmap(this.obj[i].x, this.obj[i].y + 1, 0, i)
  3138. setmap(this.obj[i].x + 1, this.obj[i].y + 1, 0, i)
  3139. setmap(this.obj[i].x + 1, this.obj[i].y, 0, i)
  3140. }
  3141. if (this.obj[i].bigx) {
  3142. setmap(this.obj[i].x + 1, this.obj[i].y, 0, i)
  3143. }
  3144. if (this.obj[i].bigy) {
  3145. setmap(this.obj[i].x, this.obj[i].y + 1, 0, i)
  3146. }
  3147. if (!ok) {
  3148. res = 0
  3149. break
  3150. }
  3151. lastshad = xr + yr * defxn
  3152. setshad(0, 0, 0, 0, true)
  3153. res = "phantom_forces"
  3154. magicx = xr
  3155. magicy = yr
  3156. break
  3157. case "bless":
  3158. set_cursor(6)
  3159. if (xr + yr * defxn != lastshad) {
  3160. if (lastshad > 0) {
  3161. setshad(0, 0, 0, 0, false)
  3162. }
  3163. }
  3164. ok = false
  3165. var len = this.obj_array.length
  3166. for (var k1 = 0; k1 < len; k1++) {
  3167. i = this.obj_array[k1]
  3168. if (
  3169. !this.obj[i].hero &&
  3170. !this.obj[i].warmachine &&
  3171. i == mapobj[xr + yr * defxn] &&
  3172. this.obj[i].side == this.obj[activeobj].getside() &&
  3173. this.obj[i].nownumber > 0
  3174. ) {
  3175. ok = true
  3176. break
  3177. }
  3178. }
  3179. if (!ok) {
  3180. res = 0
  3181. break
  3182. }
  3183. lastshad = xr + yr * defxn
  3184. setshad(0, 0, 0, 0, true)
  3185. res = "bless"
  3186. magicx = xr
  3187. magicy = yr
  3188. break
  3189. case "divine_guidance":
  3190. set_cursor(6)
  3191. if (xr + yr * defxn != lastshad) {
  3192. if (lastshad > 0) {
  3193. setshad(0, 0, 0, 0, false)
  3194. }
  3195. }
  3196. ok = false
  3197. var len = this.obj_array.length
  3198. for (var k1 = 0; k1 < len; k1++) {
  3199. i = this.obj_array[k1]
  3200. if (
  3201. !this.obj[i].hero &&
  3202. !this.obj[i].warmachine &&
  3203. i == mapobj[xr + yr * defxn] &&
  3204. this.obj[i].side == this.obj[activeobj].getside() &&
  3205. this.obj[i].nownumber > 0
  3206. ) {
  3207. ok = true
  3208. objset = i
  3209. break
  3210. }
  3211. }
  3212. if (!ok) {
  3213. res = 0
  3214. this.reset_temp_magic()
  3215. this.showatb()
  3216. break
  3217. }
  3218. lastshad = xr + yr * defxn
  3219. setshad(0, 0, 0, 0, true)
  3220. res = "divine_guidance"
  3221. magicx = xr
  3222. magicy = yr
  3223. this.reset_temp_magic()
  3224. var init = this.obj[activeobj]["divine_guidanceeffmain"]
  3225. var init = 33
  3226. var j = mapobj[yr * defxn + xr]
  3227. if (
  3228. this.obj[j]["nowinit"] - init <
  3229. this.obj[activeobj]["nowinit"]
  3230. ) {
  3231. init = Math.floor(
  3232. this.obj[j]["nowinit"] - this.obj[activeobj]["nowinit"]
  3233. )
  3234. }
  3235. this.obj[j]["reset_init"] = -init
  3236. this.showatb()
  3237. break
  3238. case "stoneskin":
  3239. set_cursor(6)
  3240. if (xr + yr * defxn != lastshad) {
  3241. if (lastshad > 0) {
  3242. setshad(0, 0, 0, 0, false)
  3243. }
  3244. }
  3245. ok = false
  3246. var len = this.obj_array.length
  3247. for (var k1 = 0; k1 < len; k1++) {
  3248. i = this.obj_array[k1]
  3249. if (
  3250. !this.obj[i].warmachine &&
  3251. !this.obj[i].hero &&
  3252. i == mapobj[xr + yr * defxn] &&
  3253. this.obj[i].side == this.obj[activeobj].getside() &&
  3254. this.obj[i].nownumber > 0
  3255. ) {
  3256. ok = true
  3257. break
  3258. }
  3259. }
  3260. if (!ok) {
  3261. res = 0
  3262. break
  3263. }
  3264. lastshad = xr + yr * defxn
  3265. setshad(0, 0, 0, 0, true)
  3266. res = "stoneskin"
  3267. magicx = xr
  3268. magicy = yr
  3269. break
  3270. case "blind":
  3271. set_cursor(6)
  3272. if (xr + yr * defxn != lastshad) {
  3273. if (lastshad > 0) {
  3274. setshad(0, 0, 0, 0, false)
  3275. }
  3276. }
  3277. this.reset_temp_magic()
  3278. this.showatb()
  3279. if (getmap(xr, yr) != 210) {
  3280. res = 0
  3281. break
  3282. }
  3283. ok = true
  3284. var len = this.obj_array.length
  3285. for (var k1 = 0; k1 < len; k1++) {
  3286. i = this.obj_array[k1]
  3287. if (
  3288. (this.obj[i].hero ||
  3289. this.obj[i].warmachine ||
  3290. !this.obj[i].alive ||
  3291. this.obj[i].iblind ||
  3292. this.obj[i].imind ||
  3293. this.obj[i].twistedmind ||
  3294. (magic[i]["wfr"] && magic[i]["wfr"]["effect"] == 1) ||
  3295. this.obj[i].absolutepurity ||
  3296. this.obj[i].immunity ||
  3297. this.obj[i].enchantedarmor) &&
  3298. i == mapobj[xr + yr * defxn] &&
  3299. this.obj[i].nownumber > 0
  3300. ) {
  3301. ok = false
  3302. break
  3303. }
  3304. }
  3305. if (
  3306. ok &&
  3307. btype == _PVP_DIAGONAL_EVENT &&
  3308. checkwall2(
  3309. this.obj[activeobj]["x"],
  3310. this.obj[activeobj]["y"],
  3311. xr,
  3312. yr,
  3313. activeobj
  3314. )
  3315. ) {
  3316. ok = false
  3317. break
  3318. }
  3319. if (!ok) {
  3320. res = 0
  3321. break
  3322. }
  3323. this.reset_temp_magic()
  3324. var uo = mapobj[lastshad]
  3325. setn_temp_magic(uo, "bld")
  3326. this.showatb()
  3327. lastshad = xr + yr * defxn
  3328. setshad(0, 0, 0, 0, true)
  3329. res = "blind"
  3330. magicx = xr
  3331. magicy = yr
  3332. break
  3333. case "seduction":
  3334. set_cursor(6)
  3335. if (xr + yr * defxn != lastshad) {
  3336. if (lastshad > 0) {
  3337. setshad(0, 0, 0, 0, false)
  3338. }
  3339. }
  3340. if (getmap(xr, yr) != 210) {
  3341. res = 0
  3342. break
  3343. }
  3344. ok = true
  3345. if (
  3346. (this.obj[mapobj[yr * defxn + xr]].hero ||
  3347. this.obj[mapobj[yr * defxn + xr]].immunetohypnos ||
  3348. this.obj[mapobj[yr * defxn + xr]].immunity ||
  3349. this.obj[mapobj[yr * defxn + xr]].warmachine ||
  3350. !this.obj[mapobj[yr * defxn + xr]].alive ||
  3351. this.obj[mapobj[yr * defxn + xr]].imind ||
  3352. this.obj[mapobj[yr * defxn + xr]].twistedmind ||
  3353. (magic[mapobj[yr * defxn + xr]]["wfr"] &&
  3354. magic[mapobj[yr * defxn + xr]]["wfr"]["effect"] == 1) ||
  3355. this.obj[mapobj[yr * defxn + xr]].absolutepurity) &&
  3356. this.obj[mapobj[yr * defxn + xr]].nownumber > 0
  3357. ) {
  3358. ok = false
  3359. break
  3360. }
  3361. var s = "seduction"
  3362. hpa =
  3363. ((this.obj[activeobj].nownumber - 1) *
  3364. this.obj[activeobj].maxhealth +
  3365. this.obj[activeobj].nowhealth) /
  3366. ((this.obj[mapobj[yr * defxn + xr]].nownumber - 1) *
  3367. this.obj[mapobj[yr * defxn + xr]].maxhealth +
  3368. this.obj[mapobj[yr * defxn + xr]].nowhealth)
  3369. if (
  3370. hpa <= 0.25 ||
  3371. Math.floor((2 + Math.log(hpa) / Math.log(2)) * 100) <= 0
  3372. ) {
  3373. ok = false
  3374. break
  3375. }
  3376. if (
  3377. ok &&
  3378. btype == _PVP_DIAGONAL_EVENT &&
  3379. checkwall2(
  3380. this.obj[activeobj]["x"],
  3381. this.obj[activeobj]["y"],
  3382. xr,
  3383. yr,
  3384. activeobj
  3385. )
  3386. ) {
  3387. ok = false
  3388. break
  3389. }
  3390. if (!ok) {
  3391. res = 0
  3392. break
  3393. }
  3394. lastshad = xr + yr * defxn
  3395. setshad(0, 0, 0, 0, true)
  3396. res = "seduction"
  3397. magicx = xr
  3398. magicy = yr
  3399. showuron(
  3400. 1,
  3401. Math.min((2 + Math.log(hpa) / Math.log(2)).toFixed(2), 4)
  3402. )
  3403. break
  3404. case "randl":
  3405. set_cursor(6)
  3406. if (xr + yr * defxn != lastshad) {
  3407. if (lastshad > 0) {
  3408. setshad(0, 0, 0, 0, false)
  3409. }
  3410. }
  3411. ok = false
  3412. var len = this.obj_array.length
  3413. for (var k1 = 0; k1 < len; k1++) {
  3414. i = this.obj_array[k1]
  3415. if (
  3416. !this.obj[i].hero &&
  3417. !this.obj[i].warmachine &&
  3418. !this.obj[i].rock &&
  3419. i == mapobj[xr + yr * defxn] &&
  3420. this.obj[i].nownumber > 0
  3421. ) {
  3422. ok = true
  3423. break
  3424. }
  3425. }
  3426. if (!ok) {
  3427. res = 0
  3428. break
  3429. }
  3430. lastshad = xr + yr * defxn
  3431. setshad(0, 0, 0, 0, true)
  3432. res = "randl"
  3433. magicx = xr
  3434. magicy = yr
  3435. break
  3436. case "flamestrike":
  3437. set_cursor(6)
  3438. if (xr + yr * defxn != lastshad) {
  3439. if (lastshad > 0) {
  3440. setshad(0, 0, 0, 0, false)
  3441. }
  3442. }
  3443. if (getmap(xr, yr) != 210) {
  3444. res = 0
  3445. break
  3446. }
  3447. ok = true
  3448. var len = this.obj_array.length
  3449. for (var k1 = 0; k1 < len; k1++) {
  3450. i = this.obj_array[k1]
  3451. if (this.obj[i].hero && i == mapobj[xr + yr * defxn]) {
  3452. ok = false
  3453. break
  3454. }
  3455. }
  3456. if (!ok) {
  3457. res = 0
  3458. break
  3459. }
  3460. lastshad = xr + yr * defxn
  3461. setshad(0, 0, 0, 0, true)
  3462. res = "stormbolt"
  3463. magicx = xr
  3464. magicy = yr
  3465. this.calcflamestrike(activeobj, xr, yr, "flamestrike", 1.2)
  3466. break
  3467. case "stormbolt":
  3468. set_cursor(6)
  3469. if (xr + yr * defxn != lastshad) {
  3470. if (lastshad > 0) {
  3471. setshad(0, 0, 0, 0, false)
  3472. }
  3473. }
  3474. if (getmap(xr, yr) != 210) {
  3475. res = 0
  3476. break
  3477. }
  3478. ok = true
  3479. var len = this.obj_array.length
  3480. for (var k1 = 0; k1 < len; k1++) {
  3481. i = this.obj_array[k1]
  3482. if (this.obj[i].hero && i == mapobj[xr + yr * defxn]) {
  3483. ok = false
  3484. break
  3485. }
  3486. }
  3487. if (!ok) {
  3488. res = 0
  3489. break
  3490. }
  3491. lastshad = xr + yr * defxn
  3492. setshad(0, 0, 0, 0, true)
  3493. res = "stormbolt"
  3494. magicx = xr
  3495. magicy = yr
  3496. this.calcflamestrike(activeobj, xr, yr, "stormbolt", 0.5)
  3497. break
  3498. case "randd":
  3499. set_cursor(6)
  3500. if (xr + yr * defxn != lastshad) {
  3501. if (lastshad > 0) {
  3502. setshad(0, 0, 0, 0, false)
  3503. }
  3504. }
  3505. if (getmap(xr, yr) != 210) {
  3506. res = 0
  3507. break
  3508. }
  3509. ok = true
  3510. var len = this.obj_array.length
  3511. for (var k1 = 0; k1 < len; k1++) {
  3512. i = this.obj_array[k1]
  3513. if (
  3514. (this.obj[i].hero ||
  3515. this.obj[i].warmachine ||
  3516. this.obj[i].absolutepurity) &&
  3517. i == mapobj[xr + yr * defxn] &&
  3518. this.obj[i].nownumber > 0
  3519. ) {
  3520. ok = false
  3521. break
  3522. }
  3523. }
  3524. if (!ok) {
  3525. res = 0
  3526. break
  3527. }
  3528. lastshad = xr + yr * defxn
  3529. setshad(0, 0, 0, 0, true)
  3530. res = "randd"
  3531. magicx = xr
  3532. magicy = yr
  3533. break
  3534. case "poison":
  3535. set_cursor(6)
  3536. if (xr + yr * defxn != lastshad) {
  3537. if (lastshad > 0) {
  3538. setshad(0, 0, 0, 0, false)
  3539. }
  3540. }
  3541. if (getmap(xr, yr) != 210) {
  3542. res = 0
  3543. break
  3544. }
  3545. ok = true
  3546. var len = this.obj_array.length
  3547. for (var k1 = 0; k1 < len; k1++) {
  3548. i = this.obj_array[k1]
  3549. if (
  3550. i == mapobj[xr + yr * defxn] &&
  3551. this.obj[i].absolutepurity &&
  3552. this.obj[i].nownumber > 0
  3553. ) {
  3554. ok = false
  3555. break
  3556. }
  3557. }
  3558. if (!ok) {
  3559. res = 0
  3560. break
  3561. }
  3562. lastshad = xr + yr * defxn
  3563. setshad(0, 0, 0, 0, true)
  3564. res = "poison"
  3565. magicx = xr
  3566. magicy = yr
  3567. this.calcmagic(activeobj, xr, yr, magicuse)
  3568. break
  3569. case "magicarrow":
  3570. set_cursor(6)
  3571. if (xr + yr * defxn != lastshad) {
  3572. if (lastshad > 0) {
  3573. setshad(0, 0, 0, 0, false)
  3574. }
  3575. }
  3576. if (getmap(xr, yr) != 210) {
  3577. res = 0
  3578. break
  3579. }
  3580. lastshad = xr + yr * defxn
  3581. setshad(0, 0, 0, 0, true)
  3582. res = "magicarrow"
  3583. magicx = xr
  3584. magicy = yr
  3585. this.calcmagic(activeobj, xr, yr, magicuse)
  3586. break
  3587. case "firearrow":
  3588. set_cursor(6)
  3589. if (xr + yr * defxn != lastshad) {
  3590. if (lastshad > 0) {
  3591. setshad(0, 0, 0, 0, false)
  3592. }
  3593. }
  3594. if (getmap(xr, yr) != 210) {
  3595. res = 0
  3596. break
  3597. }
  3598. lastshad = xr + yr * defxn
  3599. setshad(0, 0, 0, 0, true)
  3600. res = "firearrow"
  3601. magicx = xr
  3602. magicy = yr
  3603. this.calcmagic(activeobj, xr, yr, magicuse)
  3604. break
  3605. case "icebolt":
  3606. set_cursor(6)
  3607. if (xr + yr * defxn != lastshad) {
  3608. if (lastshad > 0) {
  3609. setshad(0, 0, 0, 0, false)
  3610. }
  3611. }
  3612. if (getmap(xr, yr) != 210) {
  3613. res = 0
  3614. break
  3615. }
  3616. lastshad = xr + yr * defxn
  3617. setshad(0, 0, 0, 0, true)
  3618. res = "icebolt"
  3619. magicx = xr
  3620. magicy = yr
  3621. this.calcmagic(activeobj, xr, yr, magicuse)
  3622. break
  3623. case "dray":
  3624. set_cursor(6)
  3625. if (xr + yr * defxn != lastshad) {
  3626. if (lastshad > 0) {
  3627. setshad(0, 0, 0, 0, false)
  3628. }
  3629. }
  3630. if (getmap(xr, yr) != 210) {
  3631. res = 0
  3632. break
  3633. }
  3634. ok = true
  3635. var len = this.obj_array.length
  3636. for (var k1 = 0; k1 < len; k1++) {
  3637. i = this.obj_array[k1]
  3638. if (
  3639. (((this.obj[i].hero ||
  3640. this.obj[i].warmachine ||
  3641. this.obj[i].absolutepurity) &&
  3642. this.obj[i].nownumber > 0) ||
  3643. (mapobj[yr * defxn + xr] > 0 &&
  3644. (this.obj[mapobj[yr * defxn + xr]].armoured ||
  3645. this.obj[mapobj[yr * defxn + xr]].organicarmor))) &&
  3646. i == mapobj[xr + yr * defxn]
  3647. ) {
  3648. ok = false
  3649. break
  3650. }
  3651. }
  3652. if (!ok) {
  3653. res = 0
  3654. break
  3655. }
  3656. lastshad = xr + yr * defxn
  3657. setshad(0, 0, 0, 0, true)
  3658. res = "dray"
  3659. magicx = xr
  3660. magicy = yr
  3661. break
  3662. case "raisedead":
  3663. set_cursor(6)
  3664. if (xr + yr * defxn != lastshad) {
  3665. if (lastshad > 0) {
  3666. setshad(0, 0, 0, 0, false)
  3667. }
  3668. }
  3669. ok = false
  3670. big = false
  3671. bigf = false
  3672. var len = this.obj_array.length
  3673. for (var k1 = 0; k1 < len; k1++) {
  3674. i = this.obj_array[k1]
  3675. if (
  3676. (this.obj[i].undead || this.obj[i].alive) &&
  3677. !magic[i]["phm"] &&
  3678. !magic[i]["sum"] &&
  3679. xr >= this.obj[i].x &&
  3680. xr <= this.obj[i].x + this.obj[i].big &&
  3681. yr >= this.obj[i].y &&
  3682. yr <= this.obj[i].y + this.obj[i].big &&
  3683. this.obj[i].owner == this.obj[activeobj].owner &&
  3684. !this.obj[i].hero &&
  3685. (this.obj[i].nownumber < this.obj[i].maxnumber ||
  3686. this.obj[i].nowhealth < this.obj[i].maxhealth) &&
  3687. getmap(xr, yr) != 210 &&
  3688. (mapobj[yr * defxn + xr] == undefined ||
  3689. mapobj[yr * defxn + xr] <= 0 ||
  3690. this.obj[mapobj[yr * defxn + xr]].owner ==
  3691. this.obj[activeobj].owner)
  3692. ) {
  3693. big = false
  3694. if (this.obj[i].big && this.obj[i].nownumber == 0) {
  3695. big = true
  3696. }
  3697. bigf = false
  3698. if (this.obj[i].nownumber) {
  3699. bigf = true
  3700. }
  3701. ok2 = true
  3702. if (big && !bigf) {
  3703. var x1 = this.obj[i].x
  3704. var y1 = this.obj[i].y
  3705. if (
  3706. (mapobj[x1 + y1 * defxn] > 0 &&
  3707. mapobj[x1 + y1 * defxn] != i) ||
  3708. (mapobj[x1 + y1 * defxn + 1] > 0 &&
  3709. mapobj[x1 + y1 * defxn + 1] != i) ||
  3710. (mapobj[x1 + (y1 + 1) * defxn + 1] > 0 &&
  3711. mapobj[x1 + (y1 + 1) * defxn + 1] != i) ||
  3712. (mapobj[x1 + (y1 + 1) * defxn] > 0 &&
  3713. mapobj[x1 + (y1 + 1) * defxn] != i)
  3714. ) {
  3715. ok2 = false
  3716. }
  3717. }
  3718. if (this.obj[i].bigx && this.obj[i].nownumber == 0 && !bigf) {
  3719. if (getmap(xr + 1, yr) == 211 || getmap(xr + 1, yr) == 210) {
  3720. ok2 = false
  3721. }
  3722. }
  3723. if (this.obj[i].bigy && this.obj[i].nownumber == 0 && !bigf) {
  3724. if (getmap(xr, yr + 1) == 211 || getmap(xr, yr + 1) == 210) {
  3725. ok2 = false
  3726. }
  3727. }
  3728. if (!ok) {
  3729. ok = ok2
  3730. }
  3731. big = false
  3732. bigf = false
  3733. }
  3734. }
  3735. if (!ok) {
  3736. if (xr + yr * defxn != lastshad) this.showatb()
  3737. res = 0
  3738. break
  3739. }
  3740. lastshad = xr + yr * defxn
  3741. this.show_atb_raisedead(xr, yr)
  3742. setshad(0, 0, 0, 0, true)
  3743. res = "raisedead"
  3744. magicx = xr
  3745. magicy = yr
  3746. break
  3747. case "heal":
  3748. set_cursor(6)
  3749. if (xr + yr * defxn != lastshad) {
  3750. if (lastshad > 0) {
  3751. setshad(0, 0, 0, 0, false)
  3752. }
  3753. }
  3754. ok = false
  3755. big = false
  3756. bigf = false
  3757. var len = this.obj_array.length
  3758. for (var k1 = 0; k1 < len; k1++) {
  3759. i = this.obj_array[k1]
  3760. if (
  3761. this.obj[i].alive &&
  3762. !magic[i]["phm"] &&
  3763. i == mapobj[xr + yr * defxn] &&
  3764. this.obj[i].owner == this.obj[activeobj].owner &&
  3765. !this.obj[i].hero &&
  3766. this.obj[i].nownumber > 0 &&
  3767. (this.obj[i].nownumber < this.obj[i].maxnumber ||
  3768. this.obj[i].nowhealth < this.obj[i].maxhealth) &&
  3769. getmap(xr, yr) != 210 &&
  3770. (mapobj[yr * defxn + xr] == undefined ||
  3771. mapobj[yr * defxn + xr] <= 0 ||
  3772. this.obj[mapobj[yr * defxn + xr]].owner ==
  3773. this.obj[activeobj].owner)
  3774. ) {
  3775. if (this.obj[i].big && this.obj[i].nownumber == 0) {
  3776. big = true
  3777. }
  3778. if (this.obj[i].nownumber) {
  3779. bigf = true
  3780. }
  3781. ok2 = true
  3782. if (big && !bigf) {
  3783. if (
  3784. getmap(xr + 1, yr + 1) == 211 ||
  3785. getmap(xr + 1, yr + 1) == 210 ||
  3786. getmap(xr, yr + 1) == 211 ||
  3787. getmap(xr, yr + 1) == 210 ||
  3788. getmap(xr + 1, yr) == 211 ||
  3789. getmap(xr + 1, yr) == 210
  3790. ) {
  3791. ok2 = false
  3792. }
  3793. }
  3794. if (this.obj[i].bigx && this.obj[i].nownumber == 0 && !bigf) {
  3795. if (getmap(xr + 1, yr) == 211 || getmap(xr + 1, yr) == 210) {
  3796. ok2 = false
  3797. }
  3798. }
  3799. if (this.obj[i].bigy && this.obj[i].nownumber == 0 && !bigf) {
  3800. if (getmap(xr, yr + 1) == 211 || getmap(xr, yr + 1) == 210) {
  3801. ok2 = false
  3802. }
  3803. }
  3804. if (!ok) {
  3805. ok = ok2
  3806. }
  3807. big = false
  3808. bigf = false
  3809. }
  3810. }
  3811. if (!ok) {
  3812. res = 0
  3813. break
  3814. }
  3815. lastshad = xr + yr * defxn
  3816. setshad(0, 0, 0, 0, true)
  3817. res = "heal"
  3818. magicx = xr
  3819. magicy = yr
  3820. break
  3821. case "summonpit":
  3822. set_cursor(6)
  3823. if (xr + yr * defxn != lastshad) {
  3824. if (lastshad > 0) {
  3825. setshad(0, 0, 0, 0, false)
  3826. }
  3827. }
  3828. ok = false
  3829. big = false
  3830. bigf = false
  3831. var len = this.obj_array.length
  3832. for (var k1 = 0; k1 < len; k1++) {
  3833. i = this.obj_array[k1]
  3834. if (
  3835. this.obj[i].alive &&
  3836. !magic[i]["phm"] &&
  3837. !magic[i]["sum"] &&
  3838. this.obj[i].x == xr &&
  3839. this.obj[i].y == yr &&
  3840. this.obj[i].owner == this.obj[activeobj].owner &&
  3841. !this.obj[i].hero &&
  3842. this.obj[i].nownumber <= 0 &&
  3843. getmap(xr, yr) != 210 &&
  3844. (mapobj[yr * defxn + xr] == undefined ||
  3845. mapobj[yr * defxn + xr] <= 0 ||
  3846. this.obj[mapobj[yr * defxn + xr]].owner ==
  3847. this.obj[activeobj].owner)
  3848. ) {
  3849. if (this.obj[i].big && this.obj[i].nownumber == 0) {
  3850. big = true
  3851. }
  3852. ok2 = true
  3853. if (big && !bigf) {
  3854. if (
  3855. getmap(xr + 1, yr + 1) == 211 ||
  3856. getmap(xr + 1, yr + 1) == 210 ||
  3857. getmap(xr, yr + 1) == 211 ||
  3858. getmap(xr, yr + 1) == 210 ||
  3859. getmap(xr + 1, yr) == 211 ||
  3860. getmap(xr + 1, yr) == 210
  3861. ) {
  3862. ok2 = false
  3863. }
  3864. }
  3865. if (this.obj[i].bigx && this.obj[i].nownumber == 0 && !bigf) {
  3866. if (getmap(xr + 1, yr) == 211 || getmap(xr + 1, yr) == 210) {
  3867. ok2 = false
  3868. }
  3869. }
  3870. if (this.obj[i].bigy && this.obj[i].nownumber == 0 && !bigf) {
  3871. if (getmap(xr, yr + 1) == 211 || getmap(xr, yr + 1) == 210) {
  3872. ok2 = false
  3873. }
  3874. }
  3875. if (
  3876. Math.min(this.obj[i]["maxhealth"], 120) *
  3877. this.obj[i]["maxnumber"] <
  3878. 120
  3879. )
  3880. ok2 = false
  3881. if (!ok) {
  3882. ok = ok2
  3883. }
  3884. big = false
  3885. bigf = false
  3886. }
  3887. }
  3888. if (!ok) {
  3889. res = 0
  3890. break
  3891. }
  3892. lastshad = xr + yr * defxn
  3893. setshad(0, 0, 0, 0, true)
  3894. res = "summonpit"
  3895. magicx = xr
  3896. magicy = yr
  3897. break
  3898. case "gating":
  3899. set_cursor(6)
  3900. var bigx = this.obj[activeobj]["big"]
  3901. var bigy = this.obj[activeobj]["big"]
  3902. if (this.obj[activeobj]["bigx"]) bigx = 1
  3903. if (this.obj[activeobj]["bigy"]) bigy = 1
  3904. if (xr + yr * defxn != lastshad) {
  3905. if (lastshad > 0) {
  3906. setshad(0, 0, bigx, bigy, false)
  3907. }
  3908. }
  3909. ok = false
  3910. ok = true
  3911. for (x = 0; x <= bigx; x++) {
  3912. for (y = 0; y <= bigy; y++) {
  3913. if (mapg[xr + x + (yr + y) * defxn] != 0) {
  3914. ok = false
  3915. }
  3916. }
  3917. }
  3918. if (!ok) {
  3919. res = 0
  3920. break
  3921. }
  3922. lastshad = xr + yr * defxn
  3923. setshad(0, 0, bigx, bigy, true)
  3924. res = "gating"
  3925. magicx = xr
  3926. magicy = yr
  3927. break
  3928. case "repair":
  3929. set_cursor(6)
  3930. if (xr + yr * defxn != lastshad) {
  3931. if (lastshad > 0) {
  3932. setshad(0, 0, 0, 0, false)
  3933. }
  3934. }
  3935. ok = false
  3936. var len = this.obj_array.length
  3937. for (var k1 = 0; k1 < len; k1++) {
  3938. i = this.obj_array[k1]
  3939. if (
  3940. this.obj[i].mechanical &&
  3941. this.obj[i].x == xr &&
  3942. this.obj[i].y == yr &&
  3943. this.obj[i].side == this.obj[activeobj].getside() &&
  3944. !this.obj[i].hero &&
  3945. (this.obj[i].nownumber < this.obj[i].maxnumber ||
  3946. this.obj[i].nowhealth < this.obj[i].maxhealth) &&
  3947. getmap(xr, yr) != 210 &&
  3948. ((this.obj[i].nownumber == 0 && getmap(xr, yr) != 211) ||
  3949. (this.obj[i].nownumber > 0 && getmap(xr, yr) == 211))
  3950. ) {
  3951. ok = true
  3952. }
  3953. }
  3954. if (!ok) {
  3955. res = 0
  3956. break
  3957. }
  3958. lastshad = xr + yr * defxn
  3959. setshad(0, 0, 0, 0, true)
  3960. res = "repair"
  3961. magicx = xr
  3962. magicy = yr
  3963. break
  3964. case "firstaid":
  3965. set_cursor(6)
  3966. if (xr + yr * defxn != lastshad) {
  3967. if (lastshad > 0) {
  3968. setshad(0, 0, 0, 0, false)
  3969. }
  3970. }
  3971. ok = false
  3972. var len = this.obj_array.length
  3973. for (var k1 = 0; k1 < len; k1++) {
  3974. i = this.obj_array[k1]
  3975. if (
  3976. !this.obj[i].warmachine &&
  3977. i == mapobj[xr + yr * defxn] &&
  3978. this.obj[i].owner == this.obj[activeobj].owner &&
  3979. !this.obj[i].hero &&
  3980. (this.obj[i].nownumber < this.obj[i].maxnumber ||
  3981. this.obj[i].nowhealth < this.obj[i].maxhealth) &&
  3982. getmap(xr, yr) != 210 &&
  3983. this.obj[i].nownumber > 0 &&
  3984. getmap(xr, yr) == 211
  3985. ) {
  3986. ok = true
  3987. }
  3988. }
  3989. if (!ok) {
  3990. res = 0
  3991. break
  3992. }
  3993. lastshad = xr + yr * defxn
  3994. setshad(0, 0, 0, 0, true)
  3995. res = "firstaid"
  3996. magicx = xr
  3997. magicy = yr
  3998. break
  3999. case "teleport":
  4000. if (carryo == -1) {
  4001. var s = "teleport"
  4002. if (xr <= 0 || yr <= 0 || xr > defxn - 2 || yr > defyn) {
  4003. res = 0
  4004. break
  4005. }
  4006. var len = this.obj_array.length
  4007. for (var k1 = 0; k1 < len; k1++) {
  4008. i = this.obj_array[k1]
  4009. if (
  4010. !this.obj[i].warmachine &&
  4011. !magic[i]["ent"] &&
  4012. i == mapobj[xr + yr * defxn] &&
  4013. !this.obj[i].hero &&
  4014. this.obj[i]["nownumber"] > 0 &&
  4015. this.obj[i].side == this.obj[activeobj].getside() &&
  4016. Math.floor(
  4017. (10 *
  4018. (this.obj[activeobj][s + "effmain"] +
  4019. this.obj[activeobj].maxnumber *
  4020. this.obj[activeobj][s + "effmult"])) /
  4021. ((this.obj[i].nownumber - 1) * this.obj[i].maxhealth +
  4022. this.obj[i].nowhealth)
  4023. ) > 0
  4024. ) {
  4025. set_cursor(6)
  4026. res = "teleport"
  4027. }
  4028. }
  4029. } else {
  4030. var b = 0
  4031. if (carryo > 0) {
  4032. if (this.obj[carryo].big) {
  4033. setmap(this.obj[carryo].x + 1, this.obj[carryo].y + 1, 0)
  4034. setmap(this.obj[carryo].x + 1, this.obj[carryo].y, 0)
  4035. setmap(this.obj[carryo].x, this.obj[carryo].y + 1, 0)
  4036. }
  4037. if (this.obj[carryo].bigx) {
  4038. setmap(this.obj[carryo].x + 1, this.obj[carryo].y, 0)
  4039. }
  4040. if (this.obj[carryo].bigy) {
  4041. setmap(this.obj[carryo].x, this.obj[carryo].y + 1, 0)
  4042. }
  4043. }
  4044. var bigx = this.obj[carryo]["big"]
  4045. var bigy = this.obj[carryo]["big"]
  4046. if (this.obj[carryo]["bigx"]) bigx = 1
  4047. if (this.obj[carryo]["bigy"]) bigy = 1
  4048. ok = true
  4049. for (var xrr = xr; xrr <= xr + bigx; xrr++) {
  4050. for (var yrr = yr; yrr <= yr + bigy; yrr++) {
  4051. if (
  4052. carryo > 0 &&
  4053. (xr != this.obj[carryo].x || yr != this.obj[carryo].y) &&
  4054. getmap(xrr, yrr) != 200 &&
  4055. getmap(xrr, yrr) != 210 &&
  4056. (getmap(xrr, yrr) != 211 ||
  4057. mapobj[xrr + yrr * defxn] == carryo) &&
  4058. xr > 0 &&
  4059. yr > 0 &&
  4060. xr <= defxn - 2 - bigx &&
  4061. yr <= defyn - bigy
  4062. ) {
  4063. } else {
  4064. ok = false
  4065. break
  4066. }
  4067. }
  4068. }
  4069. var s = "teleport"
  4070. if (carryo <= 0) {
  4071. var r = 0
  4072. var r1 = 1
  4073. } else {
  4074. var r = Math.floor(
  4075. (10 *
  4076. (this.obj[activeobj][s + "effmain"] +
  4077. (this.getspellpower(activeobj, s) +
  4078. isperk(activeobj, 89) * 3) *
  4079. this.obj[activeobj][s + "effmult"])) /
  4080. ((this.obj[carryo].nownumber - 1) *
  4081. this.obj[carryo].maxhealth +
  4082. this.obj[carryo].nowhealth)
  4083. )
  4084. var r1 =
  4085. (xr - this.obj[carryo].x) * (xr - this.obj[carryo].x) +
  4086. (yr - this.obj[carryo].y) * (yr - this.obj[carryo].y)
  4087. }
  4088. if (r1 > r * r) {
  4089. ok = false
  4090. }
  4091. if (ok) {
  4092. set_cursor(6)
  4093. if (xr + yr * defxn != lastshad) {
  4094. if (lastshad > 0) {
  4095. setshad(0, 0, bigx, bigy, false)
  4096. }
  4097. lastshad = xr + yr * defxn
  4098. setshad(0, 0, bigx, bigy, true)
  4099. }
  4100. magicx = xr
  4101. magicy = yr
  4102. res = "teleport"
  4103. } else {
  4104. res = 0
  4105. if (lastshad > 0) {
  4106. setshad(0, 0, bigx, bigy, false)
  4107. }
  4108. lastshad = -1
  4109. }
  4110. var lastshadt = lastshad
  4111. if (carryo > 0) {
  4112. lastshad = this.obj[carryo].x + this.obj[carryo].y * defxn
  4113. setshad(0, 0, bigx, bigy, true)
  4114. lastshad = lastshadt
  4115. if (bigx == 1 && bigy == 1) {
  4116. setmap(this.obj[carryo].x + 1, this.obj[carryo].y + 1, 211)
  4117. setmap(this.obj[carryo].x + 1, this.obj[carryo].y, 211)
  4118. setmap(this.obj[carryo].x, this.obj[carryo].y + 1, 211)
  4119. }
  4120. if (bigx == 1) {
  4121. setmap(this.obj[carryo].x + 1, this.obj[carryo].y, 211)
  4122. }
  4123. if (bigy == 1) {
  4124. setmap(this.obj[carryo].x, this.obj[carryo].y + 1, 211)
  4125. }
  4126. }
  4127. }
  4128. break
  4129. case "carry":
  4130. spd = Math.max(
  4131. 0,
  4132. Math.round(
  4133. (this.obj[activeobj].speed +
  4134. this.obj[activeobj]["ragespeed"] +
  4135. this.obj[activeobj]["speedaddon"]) *
  4136. this.obj[activeobj].speedmodifier
  4137. )
  4138. )
  4139. if (magic[activeobj]["ent"]) {
  4140. spd = 0
  4141. }
  4142. xr1 = xr
  4143. yr1 = yr
  4144. if (xr1 > this.obj[activeobj]["x"]) {
  4145. xr1--
  4146. }
  4147. if (yr1 > this.obj[activeobj]["y"]) {
  4148. yr1--
  4149. }
  4150. if (
  4151. Math.abs(
  4152. Math.abs(this.obj[activeobj]["x"] - xr1) -
  4153. Math.abs(this.obj[activeobj]["y"] - yr1)
  4154. ) +
  4155. 1.5 *
  4156. (Math.max(
  4157. Math.abs(this.obj[activeobj]["x"] - xr1),
  4158. Math.abs(this.obj[activeobj]["y"] - yr1)
  4159. ) -
  4160. Math.abs(
  4161. Math.abs(this.obj[activeobj]["x"] - xr1) -
  4162. Math.abs(this.obj[activeobj]["y"] - yr1)
  4163. )) <=
  4164. spd
  4165. ) {
  4166. } else {
  4167. res = 0
  4168. break
  4169. }
  4170. if (carryo == -1) {
  4171. if (xr <= 0 || yr <= 0 || xr > defxn - 2 || yr > defyn) {
  4172. res = 0
  4173. break
  4174. }
  4175. var len = this.obj_array.length
  4176. for (var k1 = 0; k1 < len; k1++) {
  4177. i = this.obj_array[k1]
  4178. if (
  4179. !this.obj[i].warmachine &&
  4180. (!magic[i]["inv"] || magic[i]["inv"]["effect"] != 1) &&
  4181. !magic[i]["ent"] &&
  4182. i == mapobj[xr + yr * defxn] &&
  4183. !this.obj[i].big &&
  4184. !this.obj[i].bigx &&
  4185. !this.obj[i].bigy &&
  4186. !this.obj[i].hero &&
  4187. this.obj[activeobj]["nownumber"] * 2 >=
  4188. this.obj[i]["nownumber"] &&
  4189. this.obj[i]["nownumber"] > 0 &&
  4190. this.obj[i].side == this.obj[activeobj].getside()
  4191. ) {
  4192. set_cursor(6)
  4193. res = "carry"
  4194. }
  4195. }
  4196. } else {
  4197. if (
  4198. getmap(xr, yr) != 200 &&
  4199. getmap(xr, yr) != 210 &&
  4200. getmap(xr, yr) != 211
  4201. ) {
  4202. set_cursor(6)
  4203. if (xr + yr * defxn != lastshad) {
  4204. if (lastshad > 0) {
  4205. setshad(0, 0, 0, 0, false)
  4206. }
  4207. lastshad = xr + yr * defxn
  4208. setshad(0, 0, 0, 0, true)
  4209. }
  4210. magicx = xr
  4211. magicy = yr
  4212. res = "carry"
  4213. }
  4214. }
  4215. break
  4216. case "fireball":
  4217. set_cursor(6)
  4218. if (xr + yr * defxn != lastshad) {
  4219. if (lastshad > 0) {
  4220. setshad(-1, -1, 1, 1, false)
  4221. }
  4222. if (xr <= 0 || yr <= 0 || xr > defxn - 2 || yr > defyn) {
  4223. res = 0
  4224. break
  4225. }
  4226. lastshad = xr + yr * defxn
  4227. setshad(-1, -1, 1, 1, true)
  4228. }
  4229. magicx = xr
  4230. magicy = yr
  4231. res = "fireball"
  4232. this.calcmagic(activeobj, xr, yr, magicuse)
  4233. break
  4234. }
  4235. if (k == 250) {
  4236. ok = true
  4237. if (
  4238. activeobj > 0 &&
  4239. this.obj[activeobj].x == xr &&
  4240. this.obj[activeobj].y == yr &&
  4241. (!android ||
  4242. !android_submit ||
  4243. this.obj[activeobj].hero ||
  4244. this.obj[activeobj].warmachine)
  4245. ) {
  4246. ok = false
  4247. } else {
  4248. xrr = -1
  4249. yrr = -1
  4250. len = 100
  4251. movex = xr
  4252. movey = yr
  4253. if (activeobj > 0 && this.obj[activeobj].big) {
  4254. if (wmap2[xr + yr * defxn] >= 0 && !this.obj[activeobj].flyer) {
  4255. } else {
  4256. if (this.obj[activeobj].flyer) {
  4257. i = activeobj
  4258. setmap(this.obj[i].x, this.obj[i].y, 250)
  4259. setmap(this.obj[i].x, this.obj[i].y + 1, 250)
  4260. setmap(this.obj[i].x + 1, this.obj[i].y + 1, 250)
  4261. setmap(this.obj[i].x + 1, this.obj[i].y, 250)
  4262. }
  4263. for (xk = xr - 1; xk <= xr; xk++) {
  4264. for (yk = yr - 1; yk <= yr; yk++) {
  4265. if (wmap2[xk + yk * defxn] >= 0) {
  4266. if ((xr - xk) * (xr - xk) + (yr - yk) * (yr - yk) < len) {
  4267. xrr = xk
  4268. yrr = yk
  4269. len = (xr - xk) * (xr - xk) + (yr - yk) * (yr - yk)
  4270. }
  4271. }
  4272. }
  4273. }
  4274. if (xrr != -1) {
  4275. xr = xrr
  4276. yr = yrr
  4277. xr_last = xr
  4278. yr_last = yr
  4279. movex = xr
  4280. movey = yr
  4281. if (
  4282. this.obj[activeobj].x == xr &&
  4283. this.obj[activeobj].y == yr &&
  4284. !android
  4285. ) {
  4286. movex = 0
  4287. movey = 0
  4288. res = 0
  4289. ok = false
  4290. }
  4291. } else {
  4292. movex = 0
  4293. movey = 0
  4294. res = 0
  4295. ok = false
  4296. }
  4297. }
  4298. }
  4299. if (activeobj > 0 && this.obj[activeobj].bigx && ok) {
  4300. if (wmap2[xr + yr * defxn] >= 0 && !this.obj[activeobj].flyer) {
  4301. } else {
  4302. if (this.obj[activeobj].flyer) {
  4303. i = activeobj
  4304. setmap(this.obj[i].x, this.obj[i].y, 250)
  4305. setmap(this.obj[i].x + 1, this.obj[i].y, 250)
  4306. }
  4307. for (xk = xr - 1; xk <= xr + 1; xk++) {
  4308. for (yk = yr - 1; yk <= yr + 1; yk++) {
  4309. if (wmap2[xk + yk * defxn] >= 0) {
  4310. if ((xr - xk) * (xr - xk) + (yr - yk) * (yr - yk) < len) {
  4311. if (this.obj[activeobj].flyer) {
  4312. if (
  4313. getmap(xk, yk) != 250 ||
  4314. getmap(xk + 1, yk) != 250
  4315. ) {
  4316. continue
  4317. }
  4318. xrr = xk
  4319. yrr = yk
  4320. len = (xr - xk) * (xr - xk) + (yr - yk) * (yr - yk)
  4321. }
  4322. }
  4323. }
  4324. }
  4325. }
  4326. if (xrr != -1) {
  4327. xr = xrr
  4328. yr = yrr
  4329. xr_last = xr
  4330. yr_last = yr
  4331. movex = xr
  4332. movey = yr
  4333. if (
  4334. this.obj[activeobj].x == xr &&
  4335. this.obj[activeobj].y == yr
  4336. ) {
  4337. movex = 0
  4338. movey = 0
  4339. res = 0
  4340. ok = false
  4341. }
  4342. } else {
  4343. movex = 0
  4344. movey = 0
  4345. res = 0
  4346. ok = false
  4347. }
  4348. }
  4349. }
  4350. if (activeobj > 0 && this.obj[activeobj].bigy && ok) {
  4351. if (wmap2[xr + yr * defxn] >= 0 && !this.obj[activeobj].flyer) {
  4352. } else {
  4353. if (this.obj[activeobj].flyer) {
  4354. i = activeobj
  4355. setmap(this.obj[i].x, this.obj[i].y, 250)
  4356. setmap(this.obj[i].x, this.obj[i].y + 1, 250)
  4357. }
  4358. for (xk = xr - 1; xk <= xr + 1; xk++) {
  4359. for (yk = yr - 1; yk <= yr + 1; yk++) {
  4360. if (wmap2[xk + yk * defxn] >= 0) {
  4361. if ((xr - xk) * (xr - xk) + (yr - yk) * (yr - yk) < len) {
  4362. if (this.obj[activeobj].flyer) {
  4363. if (
  4364. getmap(xk, yk) != 250 ||
  4365. getmap(xk, yk + 1) != 250
  4366. ) {
  4367. continue
  4368. }
  4369. xrr = xk
  4370. yrr = yk
  4371. len = (xr - xk) * (xr - xk) + (yr - yk) * (yr - yk)
  4372. }
  4373. }
  4374. }
  4375. }
  4376. }
  4377. if (xrr != -1) {
  4378. xr = xrr
  4379. yr = yrr
  4380. xr_last = xr
  4381. yr_last = yr
  4382. movex = xr
  4383. movey = yr
  4384. if (
  4385. this.obj[activeobj].x == xr &&
  4386. this.obj[activeobj].y == yr
  4387. ) {
  4388. movex = 0
  4389. movey = 0
  4390. res = 0
  4391. ok = false
  4392. }
  4393. } else {
  4394. movex = 0
  4395. movey = 0
  4396. res = 0
  4397. ok = false
  4398. }
  4399. }
  4400. }
  4401. }
  4402. if (ok && activeobj > 0) {
  4403. if (magicuse == "leap" || magicuse == "leap6") {
  4404. res = 0
  4405. ok = false
  4406. }
  4407. if (ok) {
  4408. set_cursor(1)
  4409. xr_go = xr
  4410. yr_go = yr
  4411. if (xr + yr * defxn != lastshad) {
  4412. if (lastshad > 0 && shado[lastshad]) {
  4413. set_visible(shado[lastshad], 0)
  4414. if (this.obj[activeobj].big) {
  4415. if (shado[lastshad + 1 + defxn]) {
  4416. set_visible(shado[lastshad + 1], 0)
  4417. set_visible(shado[lastshad + 1 + defxn], 0)
  4418. set_visible(shado[lastshad + defxn], 0)
  4419. }
  4420. }
  4421. if (this.obj[activeobj].bigx) {
  4422. set_visible(shado[lastshad + 1], 0)
  4423. }
  4424. if (this.obj[activeobj].bigy) {
  4425. set_visible(shado[lastshad + defxn], 0)
  4426. }
  4427. }
  4428. lastshad = xr + yr * defxn
  4429. set_visible(shado[xr + yr * defxn], 1)
  4430. if (this.obj[activeobj].big) {
  4431. set_visible(shado[xr + yr * defxn + 1], 1)
  4432. set_visible(shado[xr + yr * defxn + 1 + defxn], 1)
  4433. set_visible(shado[xr + yr * defxn + defxn], 1)
  4434. }
  4435. if (this.obj[activeobj].bigx) {
  4436. set_visible(shado[xr + yr * defxn + 1], 1)
  4437. }
  4438. if (this.obj[activeobj].bigy) {
  4439. set_visible(shado[xr + yr * defxn + defxn], 1)
  4440. }
  4441. }
  4442. res = 250
  4443. }
  4444. }
  4445. }
  4446. resa = this.in_mousemove(xr, yr, k, magicuse)
  4447. if (resa["res"] != 0) {
  4448. res = resa["res"]
  4449. magicx = resa["magicx"]
  4450. magicy = resa["magicy"]
  4451. }
  4452. if (k == "frenzy") {
  4453. ok = true
  4454. set_cursor(6)
  4455. if (xr + yr * defxn != lastshad) {
  4456. if (lastshad > 0) {
  4457. setshad(0, 0, 0, 0, false)
  4458. }
  4459. }
  4460. if (getmap(xr, yr) != 210) {
  4461. res = 0
  4462. ok = false
  4463. }
  4464. if (ok) {
  4465. if (
  4466. (this.obj[mapobj[yr * defxn + xr]].hero ||
  4467. this.obj[mapobj[yr * defxn + xr]].warmachine ||
  4468. !this.obj[mapobj[yr * defxn + xr]].alive ||
  4469. this.obj[mapobj[yr * defxn + xr]].imind ||
  4470. this.obj[mapobj[yr * defxn + xr]].twistedmind ||
  4471. (magic[mapobj[yr * defxn + xr]]["wfr"] &&
  4472. magic[mapobj[yr * defxn + xr]]["wfr"]["effect"] == 1) ||
  4473. this.obj[mapobj[yr * defxn + xr]].absolutepurity ||
  4474. this.obj[mapobj[yr * defxn + xr]].ifrenzy) &&
  4475. this.obj[mapobj[yr * defxn + xr]].nownumber > 0
  4476. ) {
  4477. ok = false
  4478. }
  4479. if (
  4480. ok &&
  4481. btype == _PVP_DIAGONAL_EVENT &&
  4482. checkwall2(
  4483. this.obj[activeobj]["x"],
  4484. this.obj[activeobj]["y"],
  4485. xr,
  4486. yr,
  4487. activeobj
  4488. )
  4489. ) {
  4490. ok = false
  4491. }
  4492. if (ok) {
  4493. var s = "frenzy"
  4494. var addeff = 0
  4495. if (this.obj[activeobj].hero) {
  4496. if (isperk(activeobj, 78)) {
  4497. addeff += 5
  4498. }
  4499. if (isperk(activeobj, 89)) {
  4500. addeff += 3
  4501. }
  4502. }
  4503. var th =
  4504. (this.obj[mapobj[yr * defxn + xr]].nownumber - 1) *
  4505. this.obj[mapobj[yr * defxn + xr]].maxhealth +
  4506. this.obj[mapobj[yr * defxn + xr]].nowhealth
  4507. var pff =
  4508. getimmune2(activeobj, mapobj[yr * defxn + xr]) *
  4509. (this.obj[activeobj][s + "effmain"] +
  4510. (this.getspellpower(activeobj, magicuse) + addeff) *
  4511. this.obj[activeobj][s + "effmult"])
  4512. if (th > pff) ok = false
  4513. if (!ok) {
  4514. res = 0
  4515. } else {
  4516. lastshad = xr + yr * defxn
  4517. setshad(0, 0, 0, 0, true)
  4518. res = "frenzy"
  4519. magicx = xr
  4520. magicy = yr
  4521. }
  4522. }
  4523. }
  4524. if (!ok) res = 0
  4525. }
  4526. if (k == "battledive") {
  4527. set_cursor(8)
  4528. ok = true
  4529. if (xr + yr * defxn != lastshad) {
  4530. if (lastshad > 0) {
  4531. setshad(0, 0, 0, 0, false)
  4532. }
  4533. if (xr <= 0 || yr <= 0 || xr > defxn - 2 || yr > defyn) {
  4534. res = 0
  4535. ok = false
  4536. }
  4537. if (ok) {
  4538. lastshad = xr + yr * defxn
  4539. setshad(0, 0, 0, 0, true)
  4540. }
  4541. }
  4542. if (ok) {
  4543. magicx = xr
  4544. magicy = yr
  4545. res = "battledive"
  4546. defender = mapobj[yr * defxn + xr]
  4547. if (defender > 0 && defender < 1000)
  4548. this.attackmonster(activeobj, xr, yr, xr, yr, defender)
  4549. }
  4550. }
  4551. if (k == "circle_of_winter") {
  4552. set_cursor(6)
  4553. ok = true
  4554. if (xr + yr * defxn != lastshad) {
  4555. if (lastshad > 0) {
  4556. setshad(-1, -1, 1, 1, false)
  4557. }
  4558. if (xr <= 0 || yr <= 0 || xr > defxn - 2 || yr > defyn) {
  4559. res = 0
  4560. ok = false
  4561. }
  4562. if (ok) {
  4563. lastshad = xr + yr * defxn
  4564. setshad(-1, -1, 1, 1, true)
  4565. setshad(0, 0, 0, 0, false)
  4566. }
  4567. }
  4568. if (ok) {
  4569. magicx = xr
  4570. magicy = yr
  4571. res = "circle_of_winter"
  4572. this.calcmagic(activeobj, xr, yr, magicuse)
  4573. }
  4574. }
  4575. if (k == "stonespikes") {
  4576. set_cursor(6)
  4577. ok = true
  4578. if (xr + yr * defxn != lastshad) {
  4579. if (lastshad > 0) {
  4580. setshad(0, 0, 0, 0, false)
  4581. lastshad--
  4582. setshad(0, 0, 0, 0, false)
  4583. lastshad += 2
  4584. setshad(0, 0, 0, 0, false)
  4585. lastshad--
  4586. lastshad -= defxn
  4587. setshad(0, 0, 0, 0, false)
  4588. lastshad += 2 * defxn
  4589. setshad(0, 0, 0, 0, false)
  4590. lastshad -= defxn
  4591. }
  4592. if (xr <= 0 || yr <= 0 || xr > defxn - 2 || yr > defyn) {
  4593. res = 0
  4594. ok = false
  4595. }
  4596. lastshad = xr + yr * defxn
  4597. setshad(0, 0, 0, 0, true)
  4598. lastshad--
  4599. setshad(0, 0, 0, 0, true)
  4600. lastshad += 2
  4601. setshad(0, 0, 0, 0, true)
  4602. lastshad--
  4603. lastshad -= defxn
  4604. setshad(0, 0, 0, 0, true)
  4605. lastshad += 2 * defxn
  4606. setshad(0, 0, 0, 0, true)
  4607. lastshad -= defxn
  4608. }
  4609. if (ok) {
  4610. magicx = xr
  4611. magicy = yr
  4612. res = "stonespikes"
  4613. this.calcmagic(activeobj, xr, yr, magicuse)
  4614. }
  4615. }
  4616. if (k == "wordofchief") {
  4617. set_cursor(6)
  4618. if (xr + yr * defxn != lastshad) {
  4619. if (lastshad > 0) {
  4620. setshad(0, 0, 0, 0, false)
  4621. }
  4622. }
  4623. ok = false
  4624. var len = this.obj_array.length
  4625. for (var k1 = 0; k1 < len; k1++) {
  4626. i = this.obj_array[k1]
  4627. if (
  4628. !this.obj[i].warmachine &&
  4629. !this.obj[i].hero &&
  4630. i == mapobj[xr + yr * defxn] &&
  4631. this.obj[i].side == this.obj[activeobj].getside() &&
  4632. this.obj[i].nownumber > 0
  4633. ) {
  4634. ok = true
  4635. break
  4636. }
  4637. }
  4638. if (!ok) {
  4639. res = 0
  4640. this.reset_temp_magic()
  4641. this.showatb()
  4642. } else {
  4643. lastshad = xr + yr * defxn
  4644. setshad(0, 0, 0, 0, true)
  4645. res = "wordofchief"
  4646. magicx = xr
  4647. magicy = yr
  4648. var eff = this.obj[activeobj][magicuse + "effmain"]
  4649. var init = eff * 100
  4650. var j = mapobj[lastshad]
  4651. if (
  4652. this.obj[j]["nowinit"] - init <
  4653. this.obj[activeobj]["nowinit"]
  4654. ) {
  4655. init = Math.floor(
  4656. this.obj[j]["nowinit"] - this.obj[activeobj]["nowinit"]
  4657. )
  4658. }
  4659. this.reset_temp_magic()
  4660. this.obj[mapobj[yr * defxn + xr]]["reset_init"] = -init
  4661. this.showatb()
  4662. }
  4663. }
  4664. if (k == "wheeloffortune") {
  4665. set_cursor(6)
  4666. if (xr + yr * defxn != lastshad) {
  4667. if (lastshad > 0) {
  4668. setshad(0, 0, 0, 0, false)
  4669. }
  4670. }
  4671. ok = false
  4672. var len = this.obj_array.length
  4673. for (var k1 = 0; k1 < len; k1++) {
  4674. i = this.obj_array[k1]
  4675. if (
  4676. i == mapobj[xr + yr * defxn] &&
  4677. this.obj[i].nownumber > 0 &&
  4678. !this.obj[i].hero &&
  4679. i != activeobj
  4680. ) {
  4681. ok = true
  4682. }
  4683. }
  4684. if (!ok) {
  4685. res = 0
  4686. } else {
  4687. lastshad = xr + yr * defxn
  4688. setshad(0, 0, 0, 0, true)
  4689. res = "wheeloffortune"
  4690. magicx = xr
  4691. magicy = yr
  4692. }
  4693. }
  4694. if (k == "corpseeater") {
  4695. set_cursor(6)
  4696. if (xr + yr * defxn != lastshad) {
  4697. if (lastshad > 0) {
  4698. setshad(0, 0, 0, 0, false)
  4699. }
  4700. }
  4701. var maxh =
  4702. this.obj[activeobj]["maxnumber"] * this.obj[activeobj]["maxhealth"]
  4703. var nowh =
  4704. (this.obj[activeobj]["nownumber"] - 1) *
  4705. this.obj[activeobj]["maxhealth"] +
  4706. this.obj[activeobj]["nowhealth"]
  4707. big2 = 0
  4708. if (this.obj[activeobj].big) big2 = 1
  4709. var ok1 = false
  4710. if (nowh < maxh) {
  4711. var len = this.obj_array.length
  4712. for (var k1 = 0; k1 < len; k1++) {
  4713. var k = this.obj_array[k1]
  4714. var big = 0
  4715. if (this.obj[k]["big"]) big = 1
  4716. if (
  4717. this.obj[k]["nownumber"] == 0 &&
  4718. this.obj[k]["alive"] &&
  4719. !this.obj[k]["warmachine"] &&
  4720. !this.obj[k]["hsm"] &&
  4721. this.obj[k].x >= xr &&
  4722. this.obj[k].x <= xr + big &&
  4723. this.obj[k].y >= yr &&
  4724. this.obj[k].y <= yr + big
  4725. ) {
  4726. var ok = false
  4727. for (
  4728. var x1 = this.obj[k]["x"] - 1 - big2;
  4729. x1 <= this.obj[k]["x"] + 1 + big;
  4730. x1++
  4731. ) {
  4732. for (
  4733. var y1 = this.obj[k]["y"] - 1 - big2;
  4734. y1 <= this.obj[k]["y"] + 1 + big;
  4735. y1++
  4736. ) {
  4737. if (wmap2[x1 + y1 * defxn] >= 0) {
  4738. ok = true
  4739. break
  4740. }
  4741. }
  4742. if (ok) break
  4743. }
  4744. if (!ok) continue
  4745. var ok1 = true
  4746. for (
  4747. var x1 = this.obj[k]["x"];
  4748. x1 <= this.obj[k]["x"] + big;
  4749. x1++
  4750. ) {
  4751. for (
  4752. var y1 = this.obj[k]["y"];
  4753. y1 <= this.obj[k]["y"] + big;
  4754. y1++
  4755. ) {
  4756. if (mapobj[yr * defxn + xr] > 0) ok1 = false
  4757. }
  4758. }
  4759. if (ok1) break
  4760. }
  4761. }
  4762. }
  4763. if (!ok1) {
  4764. res = 0
  4765. } else {
  4766. lastshad = xr + yr * defxn
  4767. setshad(0, 0, 0, 0, true)
  4768. res = "corpseeater"
  4769. magicx = xr
  4770. magicy = yr
  4771. }
  4772. }
  4773. if (k == "wavesofrenewal") {
  4774. set_cursor(6)
  4775. if (xr + yr * defxn != lastshad) {
  4776. if (lastshad > 0) {
  4777. setshad(0, 0, 0, 0, false)
  4778. }
  4779. }
  4780. ok = false
  4781. var len = this.obj_array.length
  4782. for (var k1 = 0; k1 < len; k1++) {
  4783. i = this.obj_array[k1]
  4784. if (
  4785. i == mapobj[xr + yr * defxn] &&
  4786. this.obj[i].nownumber > 0 &&
  4787. !this.obj[i].hero &&
  4788. this.obj[i].side == this.obj[activeobj].getside()
  4789. ) {
  4790. ok = true
  4791. }
  4792. }
  4793. if (!ok) {
  4794. res = 0
  4795. } else {
  4796. lastshad = xr + yr * defxn
  4797. setshad(0, 0, 0, 0, true)
  4798. res = "wavesofrenewal"
  4799. magicx = xr
  4800. magicy = yr
  4801. }
  4802. }
  4803. if (k == "angerofhorde") {
  4804. set_cursor(6)
  4805. if (xr + yr * defxn != lastshad) {
  4806. if (lastshad > 0) {
  4807. setshad(0, 0, 0, 0, false)
  4808. }
  4809. }
  4810. if (getmap(xr, yr) != 210) {
  4811. res = 0
  4812. } else {
  4813. lastshad = xr + yr * defxn
  4814. setshad(0, 0, 0, 0, true)
  4815. res = "angerofhorde"
  4816. magicx = xr
  4817. magicy = yr
  4818. if (stage.pole.obj[activeobj]["divinev"]) {
  4819. this.calcdivinev(activeobj, xr, yr)
  4820. } else {
  4821. this.calcmagic(activeobj, xr, yr, magicuse)
  4822. }
  4823. }
  4824. }
  4825. if (k == "spiritlink") {
  4826. set_cursor(6)
  4827. if (xr + yr * defxn != lastshad) {
  4828. if (lastshad > 0) {
  4829. setshad(0, 0, 0, 0, false)
  4830. }
  4831. }
  4832. ok = false
  4833. var len = this.obj_array.length
  4834. for (var k1 = 0; k1 < len; k1++) {
  4835. i = this.obj_array[k1]
  4836. if (
  4837. !this.obj[i].warmachine &&
  4838. !this.obj[i].immunity &&
  4839. !this.obj[i].enchantedarmor &&
  4840. !this.obj[i].hero &&
  4841. i == mapobj[xr + yr * defxn] &&
  4842. i != activeobj &&
  4843. this.obj[i].side == this.obj[activeobj].getside() &&
  4844. this.obj[i].nownumber > 0
  4845. ) {
  4846. ok = true
  4847. break
  4848. }
  4849. }
  4850. if (!ok) {
  4851. res = 0
  4852. } else {
  4853. lastshad = xr + yr * defxn
  4854. setshad(0, 0, 0, 0, true)
  4855. res = "spiritlink"
  4856. magicx = xr
  4857. magicy = yr
  4858. }
  4859. }
  4860. if (k == "setsnares") {
  4861. set_cursor(6)
  4862. ok = true
  4863. if (xr + yr * defxn != lastshad) {
  4864. if (lastshad > 0) {
  4865. setshad(0, 0, 0, 0, false)
  4866. }
  4867. if (
  4868. xr <= 0 ||
  4869. yr <= 0 ||
  4870. xr > defxn - 2 ||
  4871. yr > defyn ||
  4872. (getmap(xr, yr) != 250 && getmap(xr, yr) != 0)
  4873. ) {
  4874. res = 0
  4875. ok = false
  4876. if (getmap(xr, yr) == 210) {
  4877. showuron(
  4878. 1,
  4879. snaresPossible(
  4880. this.obj[activeobj],
  4881. this.obj[mapobj[yr * defxn + xr]]
  4882. )
  4883. )
  4884. }
  4885. } else {
  4886. lastshad = xr + yr * defxn
  4887. setshad(0, 0, 0, 0, true)
  4888. }
  4889. }
  4890. if (ok) {
  4891. magicx = xr
  4892. magicy = yr
  4893. res = "setsnares"
  4894. }
  4895. }
  4896. if (k == "setmagicmine") {
  4897. set_cursor(6)
  4898. ok = true
  4899. if (xr + yr * defxn != lastshad) {
  4900. if (lastshad > 0) {
  4901. setshad(0, 0, 0, 0, false)
  4902. }
  4903. if (
  4904. xr <= 0 ||
  4905. yr <= 0 ||
  4906. xr > defxn - 2 ||
  4907. yr > defyn ||
  4908. (getmap(xr, yr) != 250 && getmap(xr, yr) != 0)
  4909. ) {
  4910. res = 0
  4911. ok = false
  4912. } else {
  4913. lastshad = xr + yr * defxn
  4914. setshad(0, 0, 0, 0, true)
  4915. }
  4916. }
  4917. if (ok) {
  4918. magicx = xr
  4919. magicy = yr
  4920. res = "setmagicmine"
  4921. }
  4922. }
  4923. if (k == "fearmyroar") {
  4924. set_cursor(6)
  4925. if (xr + yr * defxn != lastshad) {
  4926. if (lastshad > 0) {
  4927. setshad(0, 0, 0, 0, false)
  4928. }
  4929. }
  4930. this.reset_temp_magic()
  4931. this.showatb()
  4932. if (getmap(xr, yr) != 210) {
  4933. res = 0
  4934. } else {
  4935. ok = true
  4936. var len = this.obj_array.length
  4937. for (var k1 = 0; k1 < len; k1++) {
  4938. i = this.obj_array[k1]
  4939. if (
  4940. (this.obj[i].hero ||
  4941. this.obj[i].warmachine ||
  4942. this.obj[i].absolutepurity ||
  4943. !this.obj[i].alive ||
  4944. this.obj[i].imind ||
  4945. this.obj[i].twistedmind ||
  4946. (magic[i]["wfr"] && magic[i]["wfr"]["effect"] == 1)) &&
  4947. mapobj[yr * defxn + xr] == i &&
  4948. this.obj[i].nownumber > 0
  4949. ) {
  4950. ok = false
  4951. break
  4952. }
  4953. if (
  4954. (this.obj[i].nownumber - 1) * this.obj[i].maxhealth +
  4955. this.obj[i].nowhealth >
  4956. this.obj[activeobj]["fearmyroar" + "effmain"] &&
  4957. this.obj[i].nownumber > 0 &&
  4958. mapobj[yr * defxn + xr] == i
  4959. ) {
  4960. ok = false
  4961. break
  4962. }
  4963. }
  4964. if (!ok) {
  4965. res = 0
  4966. } else {
  4967. lastshad = xr + yr * defxn
  4968. var defender = mapobj[lastshad]
  4969. if (this.obj[defender]["nowinit"] < 100) {
  4970. var init = 100
  4971. if (
  4972. this.obj[defender]["nowinit"] -
  4973. this.obj[activeobj]["nowinit"] +
  4974. init >
  4975. 100
  4976. ) {
  4977. init = Math.max(
  4978. 0,
  4979. Math.floor(
  4980. 100 +
  4981. this.obj[activeobj]["nowinit"] -
  4982. this.obj[defender]["nowinit"]
  4983. )
  4984. )
  4985. }
  4986. this.reset_temp_magic()
  4987. this.obj[defender]["reset_init"] = init
  4988. this.showatb()
  4989. }
  4990. setshad(0, 0, 0, 0, true)
  4991. res = "curse"
  4992. magicx = xr
  4993. magicy = yr
  4994. }
  4995. }
  4996. }
  4997. tUronkills = 0
  4998. tUronkills2 = 0
  4999. tPhysicalDamage = 0
  5000. tPhysicalDamage2 = 0
  5001. res = this.checkcast(k, res, xr, yr)
  5002. if (
  5003. magicuse != "" &&
  5004. this.obj[activeobj]["hero"] &&
  5005. magicuse != "raisedead" &&
  5006. magicuse != "resurrection"
  5007. ) {
  5008. var plus = 100
  5009. if (isperk(activeobj, 105)) plus = 90
  5010. if (isperk(activeobj, 106)) plus = 80
  5011. if (isperk(activeobj, 107)) plus = 70
  5012. if (
  5013. isperk(activeobj, 85) &&
  5014. (magicuse == "mbless" || magicuse == "mdispel")
  5015. ) {
  5016. plus = 50
  5017. }
  5018. if (
  5019. isperk(activeobj, 84) &&
  5020. (magicuse == "mstoneskin" || magicuse == "mdeflect_missile")
  5021. ) {
  5022. plus = 50
  5023. }
  5024. if (
  5025. isperk(activeobj, 86) &&
  5026. (magicuse == "mfast" || magicuse == "mrighteous_might")
  5027. ) {
  5028. plus = 50
  5029. }
  5030. if (
  5031. isperk(activeobj, 75) &&
  5032. (magicuse == "mcurse" || magicuse == "msuffering")
  5033. ) {
  5034. plus = 50
  5035. }
  5036. if (
  5037. isperk(activeobj, 76) &&
  5038. (magicuse == "mslow" || magicuse == "mconfusion")
  5039. ) {
  5040. plus = 50
  5041. }
  5042. if (isperk(activeobj, 77) && magicuse == "mdray") {
  5043. plus = 50
  5044. }
  5045. if (
  5046. magicuse == "raisedead" &&
  5047. umelka[this.obj[activeobj]["owner"]][0] == 2 &&
  5048. !magic[activeobj]["nps"] &&
  5049. this.obj[activeobj]["hero"] &&
  5050. magic[activeobj]["cls"] &&
  5051. magic[activeobj]["cls"]["effect"] == 1
  5052. ) {
  5053. kk = 1 - 0.03 * umelka[this.obj[activeobj]["owner"]][2]
  5054. plus = Math.round(plus * kk)
  5055. }
  5056. if (plus != 100) {
  5057. this.obj[activeobj]["reset_init"] = 0
  5058. this.obj[activeobj]["plus_init"] = plus
  5059. this.showatb(activeobj)
  5060. this.obj[activeobj]["was_atb"] = 1
  5061. }
  5062. }
  5063. var a = 1
  5064. switch (a) {
  5065. case 1:
  5066. if (k == enemy) {
  5067. if (
  5068. activeobj > 0 &&
  5069. magic[activeobj]["noa"] &&
  5070. magic[activeobj]["noa"]["nowinit"] > 0
  5071. ) {
  5072. clearshadway()
  5073. set_visible(csword, 0)
  5074. set_cursor(5)
  5075. res = 200
  5076. return 0
  5077. }
  5078. if (
  5079. activeobj > 0 &&
  5080. this.obj[activeobj].shooter &&
  5081. this.obj[activeobj].shots > 0 &&
  5082. ((!shiftdown && likeshift <= shiftcount) ||
  5083. this.obj[activeobj].hero)
  5084. ) {
  5085. xaa = this.obj[activeobj].x
  5086. yaa = this.obj[activeobj].y
  5087. xaa1 = xaa
  5088. yaa1 = yaa
  5089. b = 0
  5090. if (this.obj[activeobj].big) {
  5091. if (xaa < xr) {
  5092. xaa++
  5093. }
  5094. if (yaa < yr) {
  5095. yaa++
  5096. }
  5097. }
  5098. if (this.obj[activeobj].bigx) {
  5099. if (xaa < xr) {
  5100. xaa++
  5101. }
  5102. }
  5103. if (this.obj[activeobj].bigy) {
  5104. if (yaa < yr) {
  5105. yaa++
  5106. }
  5107. }
  5108. var bigx = this.obj[activeobj]["big"]
  5109. var bigy = this.obj[activeobj]["big"]
  5110. if (this.obj[activeobj]["bigx"]) bigx = 1
  5111. if (this.obj[activeobj]["bigy"]) bigy = 1
  5112. range = (xaa - xr) * (xaa - xr) + (yaa - yr) * (yaa - yr)
  5113. ok = true
  5114. for (xb = -1; xb <= 1 + bigx; xb++) {
  5115. for (yb = -1; yb <= 1 + bigy; yb++) {
  5116. if (
  5117. yb + yaa1 >= 1 &&
  5118. yb + yaa1 <= defyn &&
  5119. xaa1 + xb >= 0 &&
  5120. xaa1 + xb <= defxn - 1 &&
  5121. getmap(xaa1 + xb, yaa1 + yb) == 210 &&
  5122. mapobj[xaa1 + xb + (yaa1 + yb) * defxn] > 0 &&
  5123. this.obj[mapobj[xaa1 + xb + (yaa1 + yb) * defxn]]
  5124. .statix != 1
  5125. ) {
  5126. ok = false
  5127. }
  5128. }
  5129. }
  5130. if (
  5131. (range > 2 && ok) ||
  5132. this.obj[activeobj].hero ||
  5133. this.obj[activeobj].ballista ||
  5134. this.obj[activeobj].warmachine
  5135. ) {
  5136. if (!this.obj[activeobj].hero) {
  5137. if (
  5138. (Math.sqrt(range) > this.obj[activeobj].range &&
  5139. !this.obj[activeobj].shadowattack) ||
  5140. (iswalls &&
  5141. !this.obj[activeobj].hero &&
  5142. checkwall(xaa, yaa, xr, yr)) ||
  5143. ((!this.obj[activeobj].siegewalls ||
  5144. btype == 118 ||
  5145. !this.obj[mapobj[yr * defxn + xr]].stone) &&
  5146. iswalls2 &&
  5147. !this.obj[activeobj].hero &&
  5148. checkwall2(xaa, yaa, xr, yr, activeobj))
  5149. ) {
  5150. set_cursor(4)
  5151. } else {
  5152. set_cursor(3)
  5153. }
  5154. }
  5155. if (this.obj[activeobj].hero) {
  5156. set_cursor(2)
  5157. if (
  5158. this.obj[activeobj].id == 59 ||
  5159. this.obj[activeobj].id == 54 ||
  5160. this.obj[activeobj].id == 48
  5161. ) {
  5162. set_cursor(3)
  5163. }
  5164. }
  5165. if (
  5166. this.obj[activeobj].magicattack ||
  5167. this.obj[activeobj].piercingbolt
  5168. ) {
  5169. lastmag = xr + yr * defxn
  5170. lastshad = -2
  5171. this.magshot(xr, yr)
  5172. }
  5173. attackx = xaa1
  5174. attacky = yaa1
  5175. res = 210.5
  5176. if (magicuse == "harpoonstrike") {
  5177. set_cursor(8)
  5178. magicx = attackx
  5179. magicy = attacky
  5180. }
  5181. if (cur_cursor == 2 || cur_cursor == 4 || cur_cursor == 3) {
  5182. if (
  5183. this.obj[activeobj]["hero"] &&
  5184. magic[activeobj]["brb"]
  5185. ) {
  5186. var init = 20
  5187. var defender = mapobj[xr + yr * defxn]
  5188. if (
  5189. this.obj[defender]["nowinit"] -
  5190. this.obj[activeobj]["nowinit"] +
  5191. init >
  5192. 100
  5193. ) {
  5194. init = Math.max(
  5195. 0,
  5196. Math.floor(
  5197. 100 +
  5198. this.obj[activeobj]["nowinit"] -
  5199. this.obj[defender]["nowinit"]
  5200. )
  5201. )
  5202. }
  5203. this.reset_temp_magic()
  5204. this.obj[defender]["reset_init"] = init
  5205. this.showatb()
  5206. this.obj[activeobj]["was_atb"] = 1
  5207. }
  5208. this.check_shoot_abilities(
  5209. activeobj,
  5210. this.obj[activeobj].x,
  5211. this.obj[activeobj].y,
  5212. xr,
  5213. yr
  5214. )
  5215. this.attackmonster(
  5216. activeobj,
  5217. xr,
  5218. yr,
  5219. this.obj[activeobj].x,
  5220. this.obj[activeobj].y,
  5221. mapobj[yr * defxn + xr],
  5222. 1
  5223. )
  5224. this.checkProbabilitySkill(
  5225. activeobj,
  5226. attackx,
  5227. attacky,
  5228. xr,
  5229. yr,
  5230. 1
  5231. )
  5232. showuron()
  5233. }
  5234. break
  5235. }
  5236. }
  5237. var def = mapobj[yr * defxn + xr]
  5238. if (range <= 2 && magicuse == "harpoonstrike") return 0
  5239. if (def <= 0 || !this.obj[def]) return 0
  5240. if (activeobj > 0 && this.obj[activeobj].shootonly) {
  5241. set_visible(csword, 0)
  5242. set_cursor(5)
  5243. res = 200
  5244. return 0
  5245. }
  5246. if (
  5247. (magicuse == "harmtouch" &&
  5248. (this.obj[def].warmachine ||
  5249. this.obj[def].stone ||
  5250. this.obj[def].portal ||
  5251. this.obj[def].maxhealth >= 400)) ||
  5252. (magicuse == "layhands" &&
  5253. (!this.obj[def].alive || def == activeobj)) ||
  5254. (magicuse == "orderofchief" && def == activeobj)
  5255. ) {
  5256. set_cursor(0)
  5257. crun_visible2 = false
  5258. clearshadway()
  5259. return 0
  5260. }
  5261. set_cursor(2)
  5262. if (
  5263. activeobj > 0 &&
  5264. this.obj[activeobj].strikeandreturn &&
  5265. (shiftdown || likeshift > shiftcount)
  5266. ) {
  5267. set_cursor(7)
  5268. }
  5269. var xo = this.obj[def].x
  5270. var yo = this.obj[def].y
  5271. var xp = 0,
  5272. yp = 0,
  5273. xpp = 0,
  5274. ypp = 0,
  5275. dd = 0,
  5276. bdd = 100000,
  5277. bxp = 0,
  5278. byp = 0
  5279. var bigx = 0,
  5280. bigy = 0,
  5281. bxr = 0,
  5282. byr = 0
  5283. if (this.obj[def].bigx || this.obj[def].big) bigx = 1
  5284. if (this.obj[def].bigy || this.obj[def].big) bigy = 1
  5285. var one_place = 0
  5286. if (xr_go > 0) {
  5287. for (var xt = xo; xt <= xo + bigx; xt++)
  5288. for (var yt = yo; yt <= yo + bigy; yt++)
  5289. for (
  5290. xp = -1 - this.obj[activeobj].big + xt;
  5291. xp <= xt + 1;
  5292. xp++
  5293. )
  5294. for (
  5295. yp = -1 - this.obj[activeobj].big + yt;
  5296. yp <= yt + 1;
  5297. yp++
  5298. )
  5299. if (xr_go == xp && yr_go == yp) one_place = 1
  5300. }
  5301. if (one_place == 0) {
  5302. xr_go = -1
  5303. yr_go = -1
  5304. }
  5305. if (activeobj > 0) {
  5306. for (var xt = xo; xt <= xo + bigx; xt++)
  5307. for (var yt = yo; yt <= yo + bigy; yt++)
  5308. for (
  5309. xp = -1 - this.obj[activeobj].big + xt;
  5310. xp <= xt + 1;
  5311. xp++
  5312. )
  5313. for (
  5314. yp = -1 - this.obj[activeobj].big + yt;
  5315. yp <= yt + 1;
  5316. yp++
  5317. ) {
  5318. if (wmap_a[yp * defxn + xp] >= 0) {
  5319. if (
  5320. magicuse == "incinerate" &&
  5321. (xp != this.obj[activeobj].x ||
  5322. yp != this.obj[activeobj].y)
  5323. )
  5324. continue
  5325. xpp =
  5326. (xp - xt + 1 + this.obj[activeobj].big + 0.5) /
  5327. (3 + this.obj[activeobj].big)
  5328. ypp =
  5329. (yp - yt + 1 + this.obj[activeobj].big + 0.5) /
  5330. (3 + this.obj[activeobj].big)
  5331. dd =
  5332. (xt - 1 + xpp - r.x) * (xt - 1 + xpp - r.x) +
  5333. (yt - 1 + ypp - r.y) * (yt - 1 + ypp - r.y)
  5334. if (
  5335. android &&
  5336. one_place &&
  5337. (xr_go != xp || yr_go != yp)
  5338. )
  5339. continue
  5340. if (dd < bdd) {
  5341. bdd = dd
  5342. bxp = xp
  5343. byp = yp
  5344. bxr = xt + xpp
  5345. byr = yt + ypp
  5346. }
  5347. }
  5348. }
  5349. } else {
  5350. break
  5351. }
  5352. ac = 200
  5353. set_visible(csword, 1)
  5354. if (bdd < 100000) {
  5355. ac = 0
  5356. xr = Math.floor(bxr)
  5357. yr = Math.floor(byr)
  5358. xr_last = xr
  5359. yr_last = yr
  5360. xb = bxp - xr
  5361. yb = byp - yr
  5362. xt = xr
  5363. yt = yr
  5364. xt2 = r.x + 1
  5365. yt2 = r.y + 1
  5366. xt2 = bxr
  5367. yt2 = byr
  5368. ac =
  5369. (Math.atan((yt + 0.5 - yt2) / (xt + 0.5 - xt2)) * 180) /
  5370. Math.PI
  5371. if (xt + 0.5 - xt2 >= 0) ac = 180 + ac
  5372. }
  5373. if (ac == 200) {
  5374. set_visible(csword, 0)
  5375. set_cursor(5)
  5376. res = 200
  5377. break
  5378. }
  5379. a = ac
  5380. if (xr + xb + (yr + yb) * defxn != lastshad) {
  5381. if (lastshad > 0) {
  5382. set_visible(shado[lastshad], 0)
  5383. if (this.obj[activeobj].big) {
  5384. if (shado[lastshad + 1]) set_visible(shado[lastshad + 1], 0)
  5385. if (shado[lastshad + 1 + defxn])
  5386. set_visible(shado[lastshad + 1 + defxn], 0)
  5387. if (shado[lastshad + defxn])
  5388. set_visible(shado[lastshad + defxn], 0)
  5389. }
  5390. if (this.obj[activeobj].bigx) {
  5391. set_visible(shado[lastshad + 1], 0)
  5392. }
  5393. if (this.obj[activeobj].bigy) {
  5394. set_visible(shado[lastshad + defxn], 0)
  5395. }
  5396. }
  5397. lastshad = xr + xb + (yr + yb) * defxn
  5398. set_visible(shado[xr + xb + (yr + yb) * defxn], 1)
  5399. if (this.obj[activeobj].big) {
  5400. set_visible(shado[xr + xb + (yr + yb) * defxn + 1], 1)
  5401. set_visible(shado[xr + xb + (yr + yb) * defxn + 1 + defxn], 1)
  5402. set_visible(shado[xr + xb + (yr + yb) * defxn + defxn], 1)
  5403. }
  5404. if (this.obj[activeobj].bigx) {
  5405. set_visible(shado[xr + xb + (yr + yb) * defxn + 1], 1)
  5406. }
  5407. if (this.obj[activeobj].bigy) {
  5408. set_visible(shado[xr + xb + (yr + yb) * defxn + defxn], 1)
  5409. }
  5410. }
  5411. attack_xr = xr
  5412. attack_yr = yr
  5413. xr_last = xr
  5414. yr_last = yr
  5415. attackx = xr + xb
  5416. attacky = yr + yb
  5417. if (
  5418. magicuse == "harmtouch" ||
  5419. magicuse == "feralcharge" ||
  5420. magicuse == "unstoppablecharge" ||
  5421. magicuse == "allaroundslash" ||
  5422. magicuse == "slam" ||
  5423. magicuse == "mightyslam" ||
  5424. magicuse == "layhands" ||
  5425. magicuse == "orderofchief" ||
  5426. magicuse == "leap" ||
  5427. magicuse == "leap6" ||
  5428. magicuse == "incinerate"
  5429. ) {
  5430. if (
  5431. magicuse == "leap" ||
  5432. magicuse == "leap6" ||
  5433. magicuse == "feralcharge" ||
  5434. magicuse == "unstoppablecharge" ||
  5435. magicuse == "allaroundslash" ||
  5436. magicuse == "slam" ||
  5437. magicuse == "mightyslam" ||
  5438. magicuse == "harpoonstrike" ||
  5439. magicuse == "incinerate"
  5440. ) {
  5441. set_cursor(8)
  5442. } else {
  5443. set_cursor(6)
  5444. }
  5445. magicx = attackx
  5446. magicy = attacky
  5447. set_visible(csword, 0)
  5448. }
  5449. if (magicuse == "hailstorm") {
  5450. magicx = attackx
  5451. magicy = attacky
  5452. }
  5453. this.check_abilities(activeobj, attackx, attacky, xr, yr)
  5454. if (cur_cursor == 2 || cur_cursor == 7) {
  5455. this.attackmonster(activeobj, xr, yr, attackx, attacky, def, 0)
  5456. this.checkProbabilitySkill(activeobj, attackx, attacky, xr, yr)
  5457. showuron()
  5458. }
  5459. if (magicuse == "leap") {
  5460. tUronkills = 0
  5461. tUronkills2 = 0
  5462. tPhysicalDamage = 0
  5463. tPhysicalDamage2 = 0
  5464. var dx = Math.abs(this.obj[activeobj]["x"] - attackx)
  5465. var dy = Math.abs(this.obj[activeobj]["y"] - attacky)
  5466. var diag =
  5467. Math.abs(dx - dy) +
  5468. 1.5 * (Math.max(dx, dy) - Math.abs(dx - dy))
  5469. var monatt = Math.floor(
  5470. (this.obj[activeobj]["attack"] +
  5471. this.obj[activeobj]["attackaddon"] +
  5472. this.obj[activeobj]["rageattack"]) *
  5473. diag *
  5474. 0.1
  5475. )
  5476. this.obj[activeobj]["attackaddon"] += monatt
  5477. setmap(this.obj[activeobj].x, this.obj[activeobj].y, 1, false)
  5478. this.attackmonster(activeobj, xr, yr, attackx, attacky, def, 0)
  5479. this.obj[activeobj]["attackaddon"] -= monatt
  5480. showuron()
  5481. }
  5482. if (magicuse == "leap6") {
  5483. tUronkills = 0
  5484. tUronkills2 = 0
  5485. tPhysicalDamage = 0
  5486. tPhysicalDamage2 = 0
  5487. var dx = Math.abs(this.obj[activeobj]["x"] - attackx)
  5488. var dy = Math.abs(this.obj[activeobj]["y"] - attacky)
  5489. var diag =
  5490. Math.abs(dx - dy) +
  5491. 1.5 * (Math.max(dx, dy) - Math.abs(dx - dy))
  5492. var koef = 1 + diag * 0.05
  5493. setmap(this.obj[activeobj].x, this.obj[activeobj].y, 1, false)
  5494. this.attackmonster(
  5495. activeobj,
  5496. xr,
  5497. yr,
  5498. attackx,
  5499. attacky,
  5500. def,
  5501. 0,
  5502. koef,
  5503. "lep"
  5504. )
  5505. showuron()
  5506. }
  5507. set_angle(csword, Math.round(a))
  5508. var b = getxa(xr, yr)
  5509. xsize2 = b.x[2] - b.x[3]
  5510. var scale = this.scaling
  5511. set_scaleX(csword, scale)
  5512. set_scaleY(csword, scale)
  5513. set_X(
  5514. csword,
  5515. (b.x[3] + b.x[2]) / 2 +
  5516. (Math.cos((a / 180) * Math.PI) * xsize2) / 2
  5517. )
  5518. set_Y(
  5519. csword,
  5520. (b.y[3] + b.y[1]) / 2 +
  5521. (Math.sin((a / 180) * Math.PI) * (b.y[1] - b.y[3])) / 2
  5522. )
  5523. res = 210
  5524. }
  5525. break
  5526. }
  5527. if (res == 0) {
  5528. crun_visible2 = false
  5529. xr_go = -1
  5530. yr_go = -1
  5531. set_cursor(0)
  5532. }
  5533. if (res != 210) {
  5534. set_visible(csword, 0)
  5535. }
  5536. if (res == 0 || res == 210.5 || res == 200) {
  5537. clearshadway()
  5538. }
  5539. if (res == 200 && cancelway) {
  5540. this.getnearpos(xr, yr)
  5541. }
  5542. this.check_uron_abil(res, xr, yr)
  5543. if (crun_visible2) {
  5544. } else {
  5545. set_cursor(0)
  5546. }
  5547. draw_ground()
  5548. }
  5549. stage.pole.commandsproc = unsafeWindow.commandsproc = function () {
  5550. ccounter++
  5551. if (!android && inserted && ccounter % 4 == 0) {
  5552. ccounter = 0
  5553. if (KeyisDown(16)) shiftdown = true
  5554. else shiftdown = false
  5555. if (KeyisDown(17)) {
  5556. ctrldown = true
  5557. this.onMouseMoveFlash(false, mousePos.x, mousePos.y, 1)
  5558. } else {
  5559. ctrldown = false
  5560. }
  5561. if (lastshiftdown != shiftdown) {
  5562. lastshiftdown = shiftdown
  5563. movecounter = 0
  5564. }
  5565. }
  5566. movecounter++
  5567. if (activeobj && this.obj[activeobj] && this.obj[activeobj].firstaid) {
  5568. magicuse = "firstaid"
  5569. }
  5570. if (!loading) {
  5571. if (btype == 86 || btype == 87) {
  5572. soundon = false
  5573. }
  5574. if (soundeff == -1 && btype != 86 && btype != 87 && btype != 82) {
  5575. mousevisible = true
  5576. }
  5577. }
  5578. if (!initialized) {
  5579. return 0
  5580. }
  5581. if (soundeff == -1 && btype != 86 && btype != 87 && btype != 82) {
  5582. if (
  5583. typeof unsafeWindow.cordova_client != "undefined" &&
  5584. cordova_client
  5585. ) {
  5586. soundeff = 1
  5587. } else {
  5588. show_sound_dialog()
  5589. }
  5590. }
  5591. if (firstbattle && !buttons_visible["win_dialog"]) {
  5592. if (firstbattle == 2 && btype == 87) {
  5593. if (
  5594. !buttons_visible["win_Mission"] &&
  5595. !finished &&
  5596. showed_hint[2] == 0 &&
  5597. activeobj > 0 &&
  5598. inserted
  5599. ) {
  5600. fastloadmy(
  5601. "battle.php?reg_loaded=2&pl_id=" +
  5602. player +
  5603. "&warid=" +
  5604. warid +
  5605. "&rand=" +
  5606. mathrandom()
  5607. )
  5608. showed_hint[2] = 1
  5609. hide_button("info_on")
  5610. hide_war_buttons(1)
  5611. show_button("win_Mission")
  5612. if (lang == 0) {
  5613. document.getElementById("mission_header").innerHTML =
  5614. "Задание: захватить шахту"
  5615. document.getElementById("win_Mission_txt").innerHTML =
  5616. "Теперь в вашем распоряжении целая армия, состоящая из различных отрядов. Текущая задача - разгромить пограничников и захватить шахту. \n\nВы можете сами наносить удары на расстоянии, а так же давать любые указания своим отрядам.\nВаш союзник-эльфийка поможет победить!"
  5617. }
  5618. if (lang == 1) {
  5619. document.getElementById("mission_header").innerHTML =
  5620. "Mission: Break through the security"
  5621. document.getElementById("win_Mission_txt").innerHTML =
  5622. "You have an army of several different units at your disposal.\n\nCurrent mission - Defeat the Imperial border guards and occupy the sawmill. Your hero can strike them from a safe distance and order the units under your command. Your partner, the she-elf, will help you in your mission."
  5623. }
  5624. }
  5625. } else if (firstbattle == 2) {
  5626. if (
  5627. !buttons_visible["win_Mission"] &&
  5628. !finished &&
  5629. showed_hint[2] == 0 &&
  5630. activeobj > 0 &&
  5631. inserted
  5632. ) {
  5633. if (!no_reg_stat) {
  5634. fastloadmy(
  5635. "battle.php?reg_anim_finish=1&pl_id=" +
  5636. player +
  5637. "&warid=" +
  5638. warid +
  5639. "&rand=" +
  5640. mathrandom()
  5641. )
  5642. }
  5643. showed_hint[2] = 1
  5644. hide_button("info_on")
  5645. hide_war_buttons(1)
  5646. show_button("win_Mission")
  5647. if (lang == 0) {
  5648. document.getElementById("mission_header").innerHTML =
  5649. "Добро пожаловать в мир Героев!"
  5650. var txts =
  5651. "Это увлекательная игра с разнообразными боями, гильдиями, квестами и кампаниями. В неё можно играть на любом устройстве - компьютере и телефоне.<br><br><b>Преимущество перед другими онлайн-играми:<br>1. Регулярно проходят боевые ивенты;<br>2. Не нужно быть топ-игроком или высоким уровнем, чтобы показывать отличные результаты в ивенте;<br>3. Разнообразный игровой мир (бои, квесты, карты, рулетка, экономика и т.п.)<br>4. Не требует реальных денег.</b><br><br>А пока вам необходимо подойти и разгромить вражескую нежить."
  5652. document.getElementById("win_Mission_txt").innerHTML = txts
  5653. }
  5654. if (lang == 1) {
  5655. document.getElementById("mission_header").innerHTML =
  5656. "Welcome to the world of heroes!"
  5657. var txts =
  5658. "This is a fascinating game with various battles, guilds, quests and campaigns. You may enjoy it on your phone or computer. Whichever suits you best.<br><br><b>Advantages over other online games:<br>1. Scheduled regular combat events;<br>2. No need to be among the top players to demonstrate great results in event battles;<br>3. Diverse gaming experience (PVP battles, quests, campaigns, card game, economy and many more);<br>4) Free to play. You can be top player without donations!</b><br><br>Will you join now and annihilate this army of the undead?"
  5659. document.getElementById("win_Mission_txt").innerHTML = txts
  5660. }
  5661. if (
  5662. document.getElementById("win_Mission_txt").offsetHeight >
  5663. document.getElementById("MissionItem_txt").offsetHeight * 1.22
  5664. ) {
  5665. document.getElementById("win_Mission_txt").style["font-size"] =
  5666. "65%"
  5667. }
  5668. }
  5669. } else {
  5670. if (initialized && showed_hint[1] == 0 && !inserted) {
  5671. showhint(1)
  5672. } else if (
  5673. !buttons_visible["win_Mission"] &&
  5674. showed_hint[2] == 0 &&
  5675. activeobj > 0 &&
  5676. inserted
  5677. ) {
  5678. if (demomode && lang == 0) {
  5679. document.getElementById("mission_header").innerHTML =
  5680. "Пробный бой"
  5681. texts[2] =
  5682. "Вы находитесь в новой игре Герои Войны и Денег. Это тактическая стратегия с элементами RPG и экономики. Здесь вы сможете реализовать все свои способности, постоянно развиваясь и улучшая свои навыки. � егулярные обновления сохранят ваш интерес к игре надолго.\n\nПобеди в бою и начинай играть!"
  5683. }
  5684. if (demomode && lang == 1) {
  5685. document.getElementById("mission_header").innerHTML =
  5686. "Demo combat"
  5687. texts[2] =
  5688. "You have embarked on a new journey with this game - Lords of War and Money. This is a tactical strategy game with RPG elements and a world with well-developed self-sustaining economy. Here, you can realize all your fantasies, constantly developing and improving your skills. Regular updates will keep you interested forever. Wait no longer and into battle!"
  5689. }
  5690. showhint(2)
  5691. } else if (
  5692. !buttons_visible["win_Mission"] &&
  5693. demomode != 1 &&
  5694. showed_hint[3] == 0 &&
  5695. showed_hint[2] == 1 &&
  5696. activeobj > 0 &&
  5697. inserted
  5698. ) {
  5699. showhint(3)
  5700. } else if (
  5701. !buttons_visible["win_Mission"] &&
  5702. demomode != 1 &&
  5703. showed_hint[4] == 0 &&
  5704. showed_hint[3] == 1 &&
  5705. activeobj > 0 &&
  5706. inserted &&
  5707. this.obj[activeobj].hero != 1 &&
  5708. this.obj[activeobj].shooter != 1
  5709. ) {
  5710. showhint(4)
  5711. } else if (
  5712. !buttons_visible["win_Mission"] &&
  5713. showed_hint[5] == 0 &&
  5714. (showed_hint[3] == 1 || demomode) &&
  5715. activeobj > 0 &&
  5716. inserted &&
  5717. this.obj[activeobj].hero == 1
  5718. ) {
  5719. showhint(5)
  5720. } else if (
  5721. !buttons_visible["win_Mission"] &&
  5722. showed_hint[6] == 0 &&
  5723. (showed_hint[3] == 1 || demomode) &&
  5724. activeobj > 0 &&
  5725. inserted &&
  5726. this.obj[activeobj].hero != 1 &&
  5727. this.obj[activeobj].shooter == 1
  5728. ) {
  5729. showhint(6)
  5730. }
  5731. }
  5732. }
  5733. if (gpause) {
  5734. return 0
  5735. }
  5736. if (someactive) {
  5737. ok = false
  5738. for (i = 1; i <= magicscount; i++) {
  5739. if (
  5740. ((magics[i].doing != "" && magics[i].doing != undefined) ||
  5741. (magics[i].cmd != "" && magics[i].cmd != undefined)) &&
  5742. magics[i] != undefined
  5743. ) {
  5744. ok = true
  5745. break
  5746. }
  5747. }
  5748. var len = this.obj_array.length
  5749. for (var k1 = 0; k1 < len; k1++) {
  5750. i = this.obj_array[k1]
  5751. if (
  5752. this.obj[i].active ||
  5753. (this.obj[i].doing != "" && this.obj[i].doing != undefined) ||
  5754. this.obj[i].donow2 == 1
  5755. ) {
  5756. if (this.obj[i].bomb) continue
  5757. ok = true
  5758. break
  5759. }
  5760. }
  5761. someactive = ok
  5762. }
  5763. if (!someactive) {
  5764. this["nowhit"] = -1
  5765. }
  5766. if (command != "") {
  5767. k = tointeger(command.substr(1, 3))
  5768. current = k
  5769. cmd = command.substr(0, 1)
  5770. if (cmd == "S" && !someactive) {
  5771. tmp = command.substr(1, 18)
  5772. curAbil = tmp
  5773. }
  5774. }
  5775. let command_copy = command
  5776. if (command_copy.indexOf("psc") != -1 && !someactive) {
  5777. let phmCommand = command_copy.substr(command_copy.indexOf("psc"), 18)
  5778. let a = tointeger(phmCommand.substr(3, 3))
  5779. let d = tointeger(phmCommand.substr(6, 3))
  5780. psc[d] = a
  5781. }
  5782. if (command_copy.indexOf("psa") != -1 && !someactive) {
  5783. let phmCommand = command_copy.substr(command_copy.indexOf("psa"), 18)
  5784. let a = tointeger(phmCommand.substr(3, 3))
  5785. let d = tointeger(phmCommand.substr(6, 3))
  5786. psa[d] = a
  5787. }
  5788. if (command_copy.indexOf("Sphm") != -1 && !someactive) {
  5789. let phmCommand = command_copy.substr(command_copy.indexOf("Sphm"), 18)
  5790. let source = Number(phmCommand.substr(12, 3))
  5791. let phantom = Number(phmCommand.substr(7, 3))
  5792. if (phm[phantom] === undefined) {
  5793. phm[phantom] = source
  5794. }
  5795. }
  5796. while (command_copy.substr(0, 1) == "S" && !someactive) {
  5797. if (command_copy.substr(1, 3) == "lzb") {
  5798. stage.pole.incrementParam(
  5799. Number(command_copy.substr(4, 3)),
  5800. "hitcount",
  5801. -1
  5802. )
  5803. }
  5804. command_copy = command_copy.substr(19)
  5805. }
  5806.  
  5807. for (i in this.obj) {
  5808. if (
  5809. this.obj[phm[i]] !== undefined &&
  5810. this.obj[i].data_string !== undefined &&
  5811. this.obj[i].data_string.indexOf("phm100000000001") != -1 &&
  5812. this.obj[i]["phm"] === undefined
  5813. ) {
  5814. this.obj[i]["luckcount"] =
  5815. this.obj[phm[i]]["luckcount"] === undefined
  5816. ? 0
  5817. : this.obj[phm[i]]["luckcount"]
  5818. this.obj[i]["hitcount"] =
  5819. this.obj[phm[i]]["hitcount"] === undefined
  5820. ? 0
  5821. : this.obj[phm[i]]["hitcount"]
  5822. this.obj[i]["turnCount"] =
  5823. this.obj[phm[i]]["turnCount"] === undefined
  5824. ? 0
  5825. : this.obj[phm[i]]["turnCount"]
  5826. this.obj[i]["moraleCount"] =
  5827. this.obj[phm[i]]["moraleCount"] === undefined
  5828. ? 0
  5829. : this.obj[phm[i]]["moraleCount"]
  5830. this.obj[i]["phm"] = 1
  5831. }
  5832. // if ((this.obj[gate[i]] !== undefined) && (magic[i]) && (magic[i]['sum']) && (magic[i]['sum']['effect'] == 2) && (this.obj[i]["gate"] === undefined)) {
  5833. // this.obj[i]["luckcount"] = this.obj[gate[i]]["luckcount"] === undefined ? 0 : this.obj[gate[i]]["luckcount"];
  5834. // this.obj[i]["hitcount"] = this.obj[gate[i]]["hitcount"] === undefined ? 0 : this.obj[gate[i]]["hitcount"];
  5835. // this.obj[i]["gate"] = 1;
  5836. // }
  5837. }
  5838. this.calcComs_new()
  5839. this.calcComs()
  5840. if (srcafterload != undefined && srcafterload != "") {
  5841. srcafterload = ""
  5842. }
  5843. }
  5844. stage.pole.addself = unsafeWindow.addself = function (
  5845. i,
  5846. mname,
  5847. init,
  5848. eff,
  5849. caster
  5850. ) {
  5851. if (mname == "lcr" || mname == "wof") {
  5852. let cre = stage.pole.obj[i]
  5853. cre["hitcount"] = 0
  5854. cre["luckcount"] = 0
  5855. }
  5856. if (mname == "mrl") {
  5857. stage.pole.clearPar(i, "morale")
  5858. if (
  5859. stage.pole.obj[i]["checkMrl"] === undefined ||
  5860. stage.pole.obj[i]["checkMrl"] == 0
  5861. ) {
  5862. stage.pole.obj[i]["checkMrl"] = 1
  5863. }
  5864. }
  5865. if (mname == "usd" && stage.pole.obj[i].id != 579) {
  5866. //djinn_vizier ?
  5867. console.log("1")
  5868. stage.pole.incrementParam(i, "turnCount", -1)
  5869. }
  5870. var s = "",
  5871. mn = "",
  5872. meffect = ""
  5873. if (!magic[i]) return false
  5874. if (magic[i][mname]) {
  5875. if (mname != "brf") {
  5876. stage[war_scr].dispelmagic(i, mname, magic[i][mname]["effect"])
  5877. }
  5878. }
  5879. magic[i][mname] = Array()
  5880. magic[i][mname]["nowinit"] = init
  5881. magic[i][mname]["effect"] = eff
  5882. if (caster) {
  5883. magic[i][mname]["caster"] = caster
  5884. }
  5885. if (init <= 0) {
  5886. magic[i][mname] = 0
  5887. }
  5888. stage[war_scr].convertfromselfmagic(i, 1)
  5889. }
  5890. stage.pole.showmagicinfo = unsafeWindow.showmagicinfo = function (
  5891. i,
  5892. t = 0
  5893. ) {
  5894. var k = 0,
  5895. bit = 0
  5896. mcount = -1
  5897. ;(mname = []),
  5898. (minit = []),
  5899. (meffect = []),
  5900. (mcast = []),
  5901. (mdo = []),
  5902. (mtype = []),
  5903. (mperc = []),
  5904. (out = "")
  5905. var showeff = 1
  5906. mcount = -1
  5907. var tmp = i
  5908. convertfromselfmagic2(i)
  5909. var len = this.obj_array.length
  5910. if (!this.obj[i].hero)
  5911. for (var k1 = 0; k1 < len; k1++) {
  5912. k = this.obj_array[k1]
  5913. if (this.obj[k].owner == this.obj[i].owner && this.obj[k].hero) {
  5914. i = k
  5915. convertfromselfmagic2(i)
  5916. break
  5917. }
  5918. }
  5919. var plus = "",
  5920. color = 0
  5921. var dat = "<table>"
  5922. i = tmp
  5923. var enter = false
  5924. if (!enter) {
  5925. if (lang == 0) {
  5926. dat +=
  5927. "<tr><td>Тип</td><td width=10></td><td>Эффект</td><td width=10></td><td>Время</td></tr>"
  5928. }
  5929. if (lang == 1) {
  5930. dat +=
  5931. "<tr><td>Type</td><td width=10></td><td>Effect</td><td width=10></td><td>Time</td></tr>"
  5932. }
  5933. }
  5934. if (this.obj[tmp].hero) {
  5935. make_perks_html(this.obj[i].owner, stage[war_scr].subpath)
  5936. } else {
  5937. if (document.getElementById("hero_info_perks")) {
  5938. document.getElementById("hero_info_perks").innerHTML = ""
  5939. document.getElementById("hero_info_perks").style.display = "none"
  5940. }
  5941. }
  5942. combat_was_vrag = Array()
  5943. for (k = 0; k <= mcount; k++) {
  5944. this.detectmagic(mname[k], k, tmp)
  5945. if (minit[k] == 100000 && t == 1) {
  5946. continue
  5947. }
  5948. if (
  5949. minit[k] > 0 &&
  5950. mdo[k] != "" &&
  5951. (meffect[k] > 0 || meffect[k] == " " || mname[k] == "hyp")
  5952. ) {
  5953. enter = true
  5954. plus = ""
  5955. if (mtype[k] == 0) {
  5956. color = "#0105b4"
  5957. }
  5958. if (mtype[k] == -1) {
  5959. color = t ? "#ef312c" : "#b40501"
  5960. }
  5961. if (mtype[k] == 1) {
  5962. color = t ? "#649615" : "#3f5b13"
  5963. }
  5964. if (mtype[k] == 1) {
  5965. plus = "+"
  5966. }
  5967. if (mtype[k] == -1 && mname[k] != "mmn") {
  5968. plus = "-"
  5969. }
  5970. if (mname[k] == "frd") {
  5971. mcast[k] = lang ? "Defense" : "Защита"
  5972. }
  5973. dat +=
  5974. '<tr style="color: ' +
  5975. color +
  5976. ';"><td>' +
  5977. mcast[k] +
  5978. "</td><td></td>"
  5979. dat += "<td>"
  5980. if (mtype[k] == 0) {
  5981. } else {
  5982. if (meffect[k] == " ") {
  5983. meffect[k] = ""
  5984. plus = ""
  5985. mperc[k] = ""
  5986. }
  5987. let d = t
  5988. if (mname[k] == "wof") {
  5989. d = 0
  5990. }
  5991. dat +=
  5992. (d != 1 ? mdo[k] : "") + "&nbsp;" + plus + meffect[k] + mperc[k]
  5993. }
  5994. dat += "</td><td> </td>"
  5995. if (minit[k] == 100000) {
  5996. dat += "<td>-</td></tr>"
  5997. } else {
  5998. dat += "<td>" + (minit[k] / 100).toFixed(2) + "</td></tr>"
  5999. }
  6000. }
  6001. }
  6002. if (!enter) {
  6003. if (lang == 0) {
  6004. dat = "<tr><td>Эффекты отсутствуют</td></tr>"
  6005. }
  6006. if (lang == 1) {
  6007. dat = "<tr><td>No effects</td></tr>"
  6008. }
  6009. }
  6010. dat += "</table>"
  6011. document.getElementById("effects_list").innerHTML = dat
  6012. document.getElementById("effects_info_head").innerHTML =
  6013. this.get_name_html(i)
  6014. return dat
  6015. }
  6016. stage.pole.calcdivinev = unsafeWindow.calcdivinev = function (i, xr, yr) {
  6017. Totalmagicdamage = 0
  6018. Totalmagickills = 0
  6019. var ok = false
  6020. var xx = 0,
  6021. yy = 0,
  6022. xp = 0,
  6023. yp = 0
  6024. mul = 1
  6025. var len = this.obj_array.length
  6026. for (var k1 = 0; k1 < len; k1++) {
  6027. var j = this.obj_array[k1]
  6028. this.obj[j]["attacked"] = 1
  6029. this.obj[j]["attacked2"] = 1
  6030. }
  6031. var separhsum = this.obj[mapobj[xr + yr * defxn]].separhsum ?? 0
  6032. var eff =
  6033. (this.obj[i]["divineveffmain"] +
  6034. Math.round(
  6035. this.obj[i]["divineveffmult"] *
  6036. Math.pow(this.obj[i]["nownumber"], 0.7)
  6037. )) *
  6038. Math.sqrt(separhsum)
  6039. this.attackmagic(
  6040. i,
  6041. mapobj[xr + yr * defxn],
  6042. eff,
  6043. "other",
  6044. "divinev",
  6045. 0,
  6046. 0,
  6047. 0
  6048. )
  6049. showuron(1)
  6050. }
  6051. stage.pole.calcflamestrike = unsafeWindow.calcflamestrike = function (
  6052. i,
  6053. xr,
  6054. yr,
  6055. magicuse,
  6056. koef
  6057. ) {
  6058. Totalmagicdamage = 0
  6059. Totalmagickills = 0
  6060. var ok = false
  6061. var xx = 0,
  6062. yy = 0,
  6063. xp = 0,
  6064. yp = 0
  6065. mul = 1
  6066. var len = this.obj_array.length
  6067. for (var k1 = 0; k1 < len; k1++) {
  6068. var j = this.obj_array[k1]
  6069. this.obj[j]["attacked"] = 1
  6070. this.obj[j]["attacked2"] = 1
  6071. }
  6072. var herd = 0
  6073. var hera = 0
  6074. for (var k1 = 0; k1 < len; k1++) {
  6075. k = this.obj_array[k1]
  6076. if (
  6077. this.obj[k].hero &&
  6078. this.obj[k].owner == this.obj[mapobj[xr + yr * defxn]].owner
  6079. )
  6080. herd = k
  6081. if (this.obj[k].hero && this.obj[k].owner == this.obj[i].owner)
  6082. hera = k
  6083. }
  6084. let b = 0
  6085. if (magic[hera] && magic[hera]["mle"]) {
  6086. b = magic[hera]["mle"]["effect"]
  6087. magic[hera]["mle"]["effect"] = 0
  6088. }
  6089. if (magic[herd] && magic[herd]["msk"]) {
  6090. if (magic[herd]["mld"]) {
  6091. let b = magic[herd]["mld"]["effect"]
  6092. magic[herd]["mld"]["effect"] = magic[herd]["msk"]["effect"]
  6093. this.attackmonster(
  6094. i,
  6095. xr,
  6096. yr,
  6097. xr,
  6098. yr,
  6099. mapobj[xr + yr * defxn],
  6100. 0,
  6101. koef
  6102. )
  6103. magic[herd]["mld"]["effect"] = b
  6104. } else {
  6105. magic[herd]["mld"] = []
  6106. magic[herd]["mld"]["effect"] = magic[herd]["msk"]["effect"]
  6107. this.attackmonster(
  6108. i,
  6109. xr,
  6110. yr,
  6111. xr,
  6112. yr,
  6113. mapobj[xr + yr * defxn],
  6114. 0,
  6115. koef
  6116. )
  6117. delete magic[herd]["mld"]
  6118. }
  6119. } else {
  6120. this.attackmonster(
  6121. i,
  6122. xr,
  6123. yr,
  6124. xr,
  6125. yr,
  6126. mapobj[xr + yr * defxn],
  6127. 0,
  6128. koef
  6129. )
  6130. }
  6131. if (b != 0) {
  6132. magic[hera]["mle"]["effect"] = b
  6133. }
  6134. showuron()
  6135. }
  6136. stage.pole.walk = unsafeWindow.walk = function (x, y) {
  6137. loadmy(
  6138. "battle.php?warid=" +
  6139. warid +
  6140. "&move=1&pl_id=" +
  6141. player +
  6142. "&my_monster=" +
  6143. activeobj +
  6144. "&x=" +
  6145. x +
  6146. "&y=" +
  6147. y +
  6148. "&lastturn=" +
  6149. lastturn +
  6150. "&lastmess=" +
  6151. lastmess +
  6152. "&lastmess2=" +
  6153. lastmess2 +
  6154. "&rand=" +
  6155. mathrandom()
  6156. )
  6157. }
  6158. stage.pole.calcchainlighting = unsafeWindow.calcchainlighting = function (
  6159. i,
  6160. xr,
  6161. yr,
  6162. magicuse
  6163. ) {
  6164. Totalmagicdamage = 0
  6165. Totalmagickills = 0
  6166. var ok = false
  6167. var xx = 0,
  6168. yy = 0,
  6169. xp = 0,
  6170. yp = 0
  6171. mul = 1
  6172. if (magicpower == true) mul = 1.5
  6173. var len = this.obj_array.length
  6174. for (var k1 = 0; k1 < len; k1++) {
  6175. var j = this.obj_array[k1]
  6176. this.obj[j]["attacked"] = 1
  6177. this.obj[j]["attacked2"] = 1
  6178. }
  6179. var xx = 0,
  6180. yy = 0,
  6181. xp = 0,
  6182. yp = 0
  6183. if (magicuse == "chainlighting") {
  6184. var lasto = mapobj[xr + yr * defxn]
  6185. var j = lasto
  6186. this.obj[j]["attacked2"] = 0
  6187. var eff = this.obj[activeobj][magicuse + "_magiceff"]
  6188. if (this.obj[activeobj]["spmult"] > 1) {
  6189. eff = Math.round(
  6190. this.obj[activeobj]["spmult"] *
  6191. (this.obj[activeobj]["chainlightingeffmain"] +
  6192. this.obj[activeobj]["chainlightingeffmult"] *
  6193. Math.pow(this.obj[activeobj]["nownumber"], 0.7))
  6194. )
  6195. }
  6196. this.attackmagic(
  6197. i,
  6198. mapobj[xr + yr * defxn],
  6199. Math.round(eff * mul),
  6200. "air",
  6201. "lighting",
  6202. 0,
  6203. 0,
  6204. 0
  6205. )
  6206. let b = this.obj[j]["nownumber"]
  6207. this.obj[j]["nownumber"] = this.obj[j]["nownumber"] + "\n#" + 1
  6208. this.obj[j].set_number()
  6209. this.obj[j]["nownumber"] = b
  6210. let bDamage = Totalmagicdamage
  6211. targetMagicdamage = Totalmagicdamage
  6212. let totalh =
  6213. (this.obj[j]["nownumber"] - 1) * this.obj[j]["maxhealth"] +
  6214. this.obj[j]["nowhealth"]
  6215. targetMagickills = Math.floor(
  6216. Math.min(targetMagicdamage, totalh) / this.obj[j]["maxhealth"]
  6217. )
  6218. let nowhealth =
  6219. this.obj[j]["nowhealth"] -
  6220. (Math.min(targetMagicdamage, totalh) -
  6221. targetMagickills * this.obj[j]["maxhealth"])
  6222. if (nowhealth <= 0) targetMagickills++
  6223. this.obj[j]["nownumber"] = b
  6224. var penalty = Array(1, 0.5, 0.25, 0.125)
  6225. let ambiguity = []
  6226. let f = true
  6227. for (var zz = 1; zz <= 3; zz++) {
  6228. this.obj[lasto]["attacked"] = 0
  6229. br = 0
  6230. bj = 0
  6231. var len = this.obj_array.length
  6232. for (var k1 = 0; k1 < len; k1++) {
  6233. j = this.obj_array[k1]
  6234. rr =
  6235. (this.obj[lasto]["x"] - this.obj[j]["x"]) *
  6236. (this.obj[lasto]["x"] - this.obj[j]["x"]) +
  6237. (this.obj[lasto]["y"] - this.obj[j]["y"]) *
  6238. (this.obj[lasto]["y"] - this.obj[j]["y"])
  6239. if (
  6240. (rr <= br || br == 0) &&
  6241. this.obj[j]["nownumber"] > 0 &&
  6242. this.obj[j]["x"] < 20 &&
  6243. !this.obj[j]["hero"] &&
  6244. !this.obj[j]["stone"] &&
  6245. this.obj[j]["y"] >= 0 &&
  6246. !this.obj[j]["rock"] &&
  6247. this.obj[j]["attacked2"] == 1
  6248. ) {
  6249. if (rr == br) {
  6250. ambiguity.push(j)
  6251. } else {
  6252. ambiguity = [j]
  6253. }
  6254. br = rr
  6255. bj = j
  6256. }
  6257. }
  6258. if (zz == 1) {
  6259. console.log(ambiguity)
  6260. console.log(br)
  6261. }
  6262. if (bj > 0) {
  6263. lasto = bj
  6264. x1 = this.obj[bj]["x"]
  6265. y1 = this.obj[bj]["y"]
  6266. j = bj
  6267. this.obj[j]["attacked2"] = 0
  6268. this.attackmagic(
  6269. i,
  6270. j,
  6271. Math.floor(Math.round(eff * mul) * penalty[zz]),
  6272. "air",
  6273. "lighting",
  6274. 0,
  6275. 0,
  6276. 0
  6277. )
  6278. let b = this.obj[j]["nownumber"]
  6279. bDamage = Totalmagicdamage
  6280. if (!f) {
  6281. continue
  6282. }
  6283. if (ambiguity.length > 1) {
  6284. f = false
  6285. for (let i in ambiguity) {
  6286. let b1 = this.obj[ambiguity[i]]["nownumber"]
  6287. this.obj[ambiguity[i]]["nownumber"] =
  6288. this.obj[ambiguity[i]]["nownumber"] +
  6289. "\n#" +
  6290. (zz + 1) +
  6291. " ???"
  6292. this.obj[ambiguity[i]].set_number()
  6293. this.obj[ambiguity[i]]["nownumber"] = b1
  6294. setshadAbs(
  6295. this.obj[ambiguity[i]]["x"],
  6296. this.obj[ambiguity[i]]["y"],
  6297. 1
  6298. )
  6299. this.obj[ambiguity[i]]["needSetNumber"] = 1
  6300. }
  6301. } else {
  6302. this.obj[j]["nownumber"] =
  6303. this.obj[j]["nownumber"] + "\n#" + (zz + 1)
  6304. setshadAbs(x1, y1, 1)
  6305. this.obj[j].set_number()
  6306. this.obj[j]["nownumber"] = b
  6307. }
  6308. }
  6309. }
  6310. ok = true
  6311. }
  6312. if (
  6313. ok &&
  6314. magicuse != "" &&
  6315. (magicuse == "circle_of_winter" || magicuse == "icebolt") &&
  6316. ((this.obj[activeobj]["hero"] && isperk(activeobj, 99)) ||
  6317. this.obj[activeobj]["master_of_ice"])
  6318. ) {
  6319. this.showatb()
  6320. }
  6321. if (
  6322. ok &&
  6323. magicuse != "" &&
  6324. this.obj[activeobj][magicuse + "elem"] == "air" &&
  6325. ((this.obj[activeobj]["hero"] && isperk(activeobj, 100)) ||
  6326. this.obj[activeobj]["master_of_storms"])
  6327. ) {
  6328. this.showatb()
  6329. }
  6330. if (ok) showuron(1)
  6331. }
  6332. unsafeWindow.setshadAbs = function (x, y, vis) {
  6333. if (!initialized) return 0
  6334. if (shado[y * defxn + x]) {
  6335. set_visible(shado[y * defxn + x], vis)
  6336. }
  6337. }
  6338. unsafeWindow.oneskill_button_release_test = function () {
  6339. if (
  6340. is_visible_element("magic_book") ||
  6341. buttons_visible["scroll_runes"]
  6342. ) {
  6343. return 0
  6344. }
  6345. if (someactive || !inserted) {
  6346. return 0
  6347. }
  6348. if (activeobj == 0) {
  6349. return 0
  6350. }
  6351. if (
  6352. activeobj > 0 &&
  6353. stage.pole.obj[activeobj]["dash"] &&
  6354. (magic[activeobj]["dsh"] === "undefined" ||
  6355. magic[activeobj]["dsh"] === 0)
  6356. ) {
  6357. stage.pole.obj[activeobj].maxinit *= 2
  6358. stage[war_scr].showatb(activeobj, 100)
  6359. stage.pole.obj[activeobj].maxinit /= 2
  6360. }
  6361. }
  6362. stage.pole.calcComs_new = function () {
  6363. command_new = command
  6364. var b = 0,
  6365. i = 0,
  6366. j = 0,
  6367. x = 0,
  6368. y = 0,
  6369. k = 0,
  6370. ok = false,
  6371. time = 0,
  6372. ii = false
  6373. var cmd = ""
  6374. if (Date.now() < waittimer && !finished) return 0
  6375. if (!initialized) return 0
  6376. if (someactive) {
  6377. ok = false
  6378. for (i = 1; i <= magicscount; i++) {
  6379. if (
  6380. ((magics[i].doing != "" && magics[i].doing != undefined) ||
  6381. (magics[i].cmd != "" && magics[i].cmd != undefined)) &&
  6382. magics[i] != undefined
  6383. ) {
  6384. ok = true
  6385. break
  6386. }
  6387. }
  6388. var len = this.obj_array.length
  6389. for (var k1 = 0; k1 < len; k1++) {
  6390. i = this.obj_array[k1]
  6391. if (
  6392. this.obj[i].active ||
  6393. (this.obj[i].doing != "" && this.obj[i].doing != undefined) ||
  6394. this.obj[i].donow2 == 1
  6395. ) {
  6396. if (this.obj[i].donow2 == 1) {
  6397. this.obj[i].donow2c++
  6398. if (this.obj[i].donow2 == 1 && this.obj[i].donow2c > 30) {
  6399. this.obj[i].x = Math.round(this.obj[i].destxx)
  6400. this.obj[i].y = Math.round(this.obj[i].destyy)
  6401. this.obj[i].donow2 = 0
  6402. this.obj[i].donow2c = 0
  6403. this.obj[i].set_pole_pos(this.obj[i].x, this.obj[i].y)
  6404. }
  6405. }
  6406. if (this.obj[i].bomb) continue
  6407. ok = true
  6408. break
  6409. }
  6410. }
  6411. someactive = ok
  6412. }
  6413. if (command_new == "") return 0
  6414. k = tointeger(command_new.substr(1, 3))
  6415. current = k
  6416. cmd = command_new.substr(0, 1)
  6417. if (loading) return 0
  6418. while (
  6419. cmd == "S" &&
  6420. (command_new.substr(1, 3) == "at3" ||
  6421. command_new.substr(1, 4) == "dsp-" ||
  6422. command_new.substr(1, 4) == "ds2-" ||
  6423. ((lastmagic == "rag" ||
  6424. lastmagic == "ral" ||
  6425. lastmagic == "raa" ||
  6426. lastmagic == "ra2") &&
  6427. command_new.substr(1, 3) == prelastmagic &&
  6428. prelastmagic != "rgl") ||
  6429. command_new.substr(1, 3) == "sld" ||
  6430. command_new.substr(1, 3) == "aci" ||
  6431. command_new.substr(1, 3) == "prt" ||
  6432. command_new.substr(1, 3) == "scd" ||
  6433. command_new.substr(1, 3) == "rnm" ||
  6434. command_new.substr(1, 3) == "spc" ||
  6435. command_new.substr(1, 3) == "wnd" ||
  6436. command_new.substr(1, 3) == "bsh" ||
  6437. command_new.substr(1, 3) == "net" ||
  6438. command_new.substr(1, 3) == "rn4" ||
  6439. command_new.substr(1, 3) == "enr" ||
  6440. command_new.substr(1, 3) == "ass" ||
  6441. command_new.substr(1, 3) == "btt" ||
  6442. command_new.substr(1, 3) == "aim" ||
  6443. command_new.substr(1, 3) == "mfc" ||
  6444. command_new.substr(1, 3) == "zat" ||
  6445. command_new.substr(1, 3) == "prp" ||
  6446. command_new.substr(1, 3) == "eye" ||
  6447. command_new.substr(1, 3) == "raa" ||
  6448. command_new.substr(1, 3) == "fbd" ||
  6449. command_new.substr(1, 3) == "wfr" ||
  6450. command_new.substr(1, 3) == "rag" ||
  6451. command_new.substr(1, 3) == "ral" ||
  6452. command_new.substr(1, 3) == "ra2" ||
  6453. command_new.substr(1, 3) == "mga" ||
  6454. command_new.substr(1, 3) == "enc" ||
  6455. command_new.substr(1, 3) == "rg2" ||
  6456. command_new.substr(1, 3) == "mof" ||
  6457. command_new.substr(1, 3) == "blt" ||
  6458. command_new.substr(1, 3) == "ent" ||
  6459. command_new.substr(1, 3) == "nmc" ||
  6460. command_new.substr(1, 3) == "hfr" ||
  6461. command_new.substr(1, 3) == "tob" ||
  6462. command_new.substr(1, 3) == "cha" ||
  6463. command_new.substr(1, 3) == "frz" ||
  6464. command_new.substr(1, 3) == "wfr" ||
  6465. command_new.substr(1, 3) == "blb" ||
  6466. command_new.substr(1, 3) == "msl" ||
  6467. command_new.substr(1, 3) == "slm" ||
  6468. command_new.substr(1, 3) == "hsa" ||
  6469. command_new.substr(1, 3) == "mlg" ||
  6470. command_new.substr(1, 3) == "mvd" ||
  6471. command_new.substr(1, 3) == "spi" ||
  6472. command_new.substr(1, 3) == "mnl" ||
  6473. command_new.substr(1, 3) == "eod" ||
  6474. command_new.substr(1, 3) == "fod" ||
  6475. command_new.substr(1, 3) == "fo2" ||
  6476. command_new.substr(1, 3) == "wss" ||
  6477. command_new.substr(1, 3) == "dtd" ||
  6478. command_new.substr(1, 3) == "inv" ||
  6479. command_new.substr(1, 3) == "irr" ||
  6480. command_new.substr(1, 3) == "btr" ||
  6481. command_new.substr(1, 3) == "flw" ||
  6482. command_new.substr(1, 3) == "brf" ||
  6483. command_new.substr(1, 3) == "chm" ||
  6484. command_new.substr(1, 3) == "ard" ||
  6485. command_new.substr(1, 3) == "rn9" ||
  6486. command_new.substr(1, 3) == "def" ||
  6487. command_new.substr(1, 3) == "dat" ||
  6488. command_new.substr(1, 3) == "mrb" ||
  6489. command_new.substr(1, 3) == "abs" ||
  6490. command_new.substr(1, 3) == "cut" ||
  6491. command_new.substr(1, 3) == "add" ||
  6492. (lastmagic != "rgl" &&
  6493. (lastmagic == command_new.substr(1, 3) ||
  6494. (lastmagic.substr(0, 2) == "ds" &&
  6495. command_new.substr(1, 2) == "ds")) &&
  6496. lastcaster == command_new.substr(4, 3) &&
  6497. command_new.substr(1, 3) != "pss" &&
  6498. command_new.substr(1, 3) != "paa"))
  6499. ) {
  6500. var obj_id = tointeger(command_new.substr(4, 3))
  6501. if (command_new.substr(1, 3) == "def") {
  6502. console.log("2")
  6503. this.incrementParam(obj_id, "turnCount", -1)
  6504. }
  6505. command_new = command_new.substr(19)
  6506. cmd = command_new.substr(0, 1)
  6507. k = tointeger(command_new.substr(1, 3))
  6508. current = k
  6509. }
  6510.  
  6511. if (
  6512. (!someactive || cmd == "P") &&
  6513. (!spellactive || flamewave_active) &&
  6514. command_new.length > 1 &&
  6515. loadcommand == "" &&
  6516. (!loading || cmd == "P") &&
  6517. initialized &&
  6518. waitingcounter > 10
  6519. ) {
  6520. if (cmd == "S") {
  6521. if (
  6522. command_new.substr(1, 3) == "sac" &&
  6523. tointeger(command_new.substr(13, 1)) == 1
  6524. ) {
  6525. let objId = tointeger(command_new.substr(4, 3))
  6526. if (
  6527. stage.pole.obj[objId]["checkTurn"] === undefined ||
  6528. stage.pole.obj[objId]["checkTurn"] == 0
  6529. ) {
  6530. //stage.pole.obj[objId]["checkTurn"] = 1;
  6531. }
  6532. }
  6533. }
  6534.  
  6535. if (cmd == "r") {
  6536. if (lastRaidsCount != stage.pole.obj[current]["nownumber"]) {
  6537. raidsCurrentWave++
  6538. stage.pole.showmitnv(1)
  6539. lastRaidsCount = stage.pole.obj[current]["nownumber"]
  6540. }
  6541. }
  6542. if (cmd == "w") {
  6543. this.incrementParam(current, "turnCount", -1)
  6544. }
  6545. if (cmd == "u" && !stage.pole.obj[current]["endurance"]) {
  6546. let u = new Date(Date.now())
  6547. let time =
  6548. u.getHours() +
  6549. ":" +
  6550. ("0" + u.getMinutes()).substr(-2) +
  6551. ":" +
  6552. ("0" + u.getSeconds()).substr(-2)
  6553. let new_content = "[" + time + "] Скорость мобов +1"
  6554. let chat_id = classic_chat ? "chat_classic_inside" : "chat_inside"
  6555. if (addSpeedLastTurn != nowturn) {
  6556. add_newtext(chat_id, new_content)
  6557. addSpeedLastTurn = nowturn
  6558. }
  6559. }
  6560. if (command_new.substr(0, 4) == "Sini") {
  6561. let u = new Date(Date.now())
  6562. let time =
  6563. u.getHours() +
  6564. ":" +
  6565. ("0" + u.getMinutes()).substr(-2) +
  6566. ":" +
  6567. ("0" + u.getSeconds()).substr(-2)
  6568. let new_content = "[" + time + "] Иня мобов +1"
  6569. let chat_id = classic_chat ? "chat_classic_inside" : "chat_inside"
  6570. if (addIniLastTurn != nowturn) {
  6571. add_newtext(chat_id, new_content)
  6572. addIniLastTurn = nowturn
  6573. }
  6574. }
  6575. if (cmd == "i") {
  6576. j = tointeger(command_new.substr(4, 4))
  6577. if (current != -1 && current > 0) {
  6578. if (
  6579. this.obj[current].nowinit <= 0 &&
  6580. this.obj[current].nowinit + j > 0
  6581. ) {
  6582. if (
  6583. magic[current] &&
  6584. magic[current]["hyp"] &&
  6585. magic[current]["hyp"]["nowinit"] > 0
  6586. ) {
  6587. return 0
  6588. }
  6589. this.incrementParam(current, "turnCount")
  6590. }
  6591. }
  6592. }
  6593. if (cmd == "s" && !someactive && !loading) {
  6594. //gating
  6595. if (this.obj[current].x >= 100) {
  6596. //gate[current] = activeobj;
  6597. this.incrementParam(activeobj, "turnCount", -1)
  6598. } else {
  6599. k = tointeger(command_new.substr(8, 5))
  6600. if (
  6601. this.obj[current].id != 347 &&
  6602. this.obj[current].id != 349 &&
  6603. !this.obj[current].bonus
  6604. ) {
  6605. if (k == 0) {
  6606. this.incrementParam(activeobj, "turnCount", -1)
  6607. return 0
  6608. }
  6609. this.incrementParam(current, "turnCount", -1)
  6610. }
  6611. }
  6612. }
  6613. }
  6614. }
  6615. stage.pole.incrementParam = function (i, name, value = 1) {
  6616. let cre = this.obj[i]
  6617. if (cre === undefined) {
  6618. return 0
  6619. }
  6620. if (cre[name] === undefined) {
  6621. cre[name] = 0
  6622. }
  6623. cre[name] += value
  6624. }
  6625. stage.pole.setParam = function (i, name, value = 0) {
  6626. let cre = this.obj[i]
  6627. if (cre === undefined) {
  6628. return 0
  6629. }
  6630. cre[name] = value
  6631. }
  6632. stage.pole.atb_scale = function (anyway) {
  6633. document.getElementById("effectsDisplay").style.display =
  6634. chatMode() == "V" ? "none" : ""
  6635. cur_scaling = 1
  6636. atby = Math.round(
  6637. scr_top + pole_top_now + pole_height + atb_top * this.scaling
  6638. )
  6639. atbx = Math.round(
  6640. (stage_width - scr_left - scr_right) / 2 +
  6641. scr_left -
  6642. ((atb_width * atb_scaling * atb_count) / 2) * this.scaling
  6643. )
  6644. if (!this.setted_atb) return 0
  6645. if (!this.showed_atb) return 0
  6646. this.atbg.x1 = Math.floor(atbx)
  6647. this.atbg.y1 = Math.floor(atby)
  6648. var sc = atb_cnt
  6649. if (!inserted) {
  6650. sc = stackcount - 1
  6651. atb_n_x =
  6652. atbx +
  6653. (((atb_count - stackcount) * atb_width * atb_scaling) / 2) *
  6654. cur_scaling *
  6655. this.scaling
  6656. this.atbg.x1 = Math.floor(atb_n_x)
  6657. }
  6658. set_scaleX(this.atbg2, this.scaling)
  6659. set_scaleY(this.atbg2, this.scaling)
  6660. set_X(this.atbg, Math.floor(this.atbg.x1))
  6661. set_Y(this.atbg, Math.floor(this.atbg.y1))
  6662. var k = cur_scaling * 90
  6663. if (k < 20) {
  6664. k = 20
  6665. }
  6666. if (atbsd > 0) {
  6667. set_fontSize(this.ochered, k * atb_scaling)
  6668. set_strokeThickness(
  6669. this.ochered,
  6670. (k / atb_font_size) * atb_stroke_width * atb_scaling
  6671. )
  6672. set_X(
  6673. this.ochered,
  6674. Math.floor(10 * cur_scaling * atb_scaling) +
  6675. Math.round(atb_scroll_x * cur_scaling)
  6676. )
  6677. set_Y(this.ochered, Math.round(1 * cur_scaling))
  6678. }
  6679. let flag = true
  6680. let dop = 40
  6681. for (var j = 0; j <= atb_count; j++) {
  6682. i = this.p_array[j]
  6683. if (j > sc) {
  6684. set_visible(this.ntext[j], 0)
  6685. set_visible(this.portraits[j], 0)
  6686. continue
  6687. } else {
  6688. set_visible(this.portraits[j], 1)
  6689. }
  6690. if (this.ntext[i]) {
  6691. var ntext_vis = get_visible(this.ntext[i])
  6692. if (ntext_vis) {
  6693. var k = cur_scaling * 50 * atb_scaling
  6694. if (k < 14) {
  6695. k = 14
  6696. }
  6697. set_fontSize(this.ntext[i], k)
  6698. while (
  6699. get_width(this.ntext[i]) >
  6700. (atb_width * atb_scaling - 16) * cur_scaling &&
  6701. k > 5
  6702. ) {
  6703. k--
  6704. set_fontSize(this.ntext[i], k)
  6705. }
  6706. set_strokeThickness(
  6707. this.ntext[i],
  6708. (k / atb_font_size) * atb_stroke_width
  6709. )
  6710. if (this.ntext[i].need_cache || anyway) {
  6711. this.ntext[i].need_cache = 0
  6712. }
  6713. set_X(
  6714. this.ntext[i],
  6715. Math.round(
  6716. atb_width * atb_scaling * (j + 1) * cur_scaling -
  6717. get_width(this.ntext[i]) -
  6718. 8 * cur_scaling * atb_scaling
  6719. )
  6720. )
  6721. set_Y(
  6722. this.ntext[i],
  6723. Math.round(
  6724. atb_height * atb_scaling * cur_scaling -
  6725. get_height(this.ntext[i]) * 0.98
  6726. )
  6727. )
  6728. if (flag === true) {
  6729. flag = false
  6730. //dop = Math.round(atb_width * atb_scaling * cur_scaling - get_width(this.ntext[i]) - 8 * cur_scaling * atb_scaling)/2;
  6731. }
  6732. }
  6733. }
  6734. if (!this.portraits[i]) {
  6735. continue
  6736. }
  6737. set_X(
  6738. this.portraits[i],
  6739. Math.round(j * atb_width * atb_scaling * cur_scaling)
  6740. )
  6741. set_visible(this.portraits[i], 1)
  6742. if (this.portraits[i].img.show_it)
  6743. set_visible(this.portraits[i].img, 1)
  6744. }
  6745. document.getElementById("dop-info").style.top =
  6746. this.atbg.y1 * (1 / MainPixelRatio) + "px"
  6747. document.getElementById("dop-info").style.width =
  6748. stage.pole.atbg.x1 * (1 / MainPixelRatio) + "px"
  6749. document.getElementById("dop-info").style.fontSize =
  6750. Math.round(
  6751. (atb_scaling *
  6752. atb_height *
  6753. stage.pole.scaling *
  6754. (1 / MainPixelRatio)) /
  6755. 3 +
  6756. 1
  6757. ) + "px"
  6758. document.getElementById("dop-info").style.left = "0px"
  6759. re_cache_atb()
  6760. }
  6761. stage.pole.getMoraleN = function (i) {
  6762. if (!this.obj[i].hasOwnProperty("nametxt")) return 0
  6763. var festering = false
  6764. var deathstare = false
  6765. let mimmune = false
  6766. if (inserted) {
  6767. mimmune = false
  6768. if (magic[i] && magic[i]["wfr"] && magic[i]["wfr"]["effect"] == 1)
  6769. mimmune = true
  6770. if (this.obj[i]["twistedmind"] == 1) mimmune = true
  6771. var k = 0
  6772. var x = 0,
  6773. y = 0,
  6774. b = 0,
  6775. x2 = 0,
  6776. y2 = 0,
  6777. b2 = 0
  6778. var len = this.obj_array.length
  6779. for (var k1 = 0; k1 < len; k1++) {
  6780. k = this.obj_array[k1]
  6781. if (
  6782. this.obj[k].festeringaura &&
  6783. !this.obj[i].undead &&
  6784. this.obj[k].nownumber > 0 &&
  6785. this.obj[i].side != this.obj[k].side
  6786. ) {
  6787. var bigx = this.obj[i]["big"]
  6788. var bigy = this.obj[i]["big"]
  6789. if (this.obj[i]["bigx"]) bigx = 1
  6790. if (this.obj[i]["bigy"]) bigy = 1
  6791. var bigkx = this.obj[k]["big"]
  6792. var bigky = this.obj[k]["big"]
  6793. if (this.obj[k]["bigx"]) bigkx = 1
  6794. if (this.obj[k]["bigy"]) bigky = 1
  6795. for (x = this.obj[i].x; x <= this.obj[i].x + bigx; x++) {
  6796. for (y = this.obj[i].y; y <= this.obj[i].y + bigy; y++) {
  6797. for (x2 = this.obj[k].x; x2 <= this.obj[k].x + bigkx; x2++) {
  6798. for (
  6799. y2 = this.obj[k].y;
  6800. y2 <= this.obj[k].y + bigky;
  6801. y2++
  6802. ) {
  6803. if (Math.abs(x - x2) <= 1 && Math.abs(y - y2) <= 1) {
  6804. festering = true
  6805. }
  6806. }
  6807. }
  6808. }
  6809. }
  6810. }
  6811. }
  6812. }
  6813. if (inserted) {
  6814. mimmune = false
  6815. if (magic[i] && magic[i]["wfr"] && magic[i]["wfr"]["effect"] == 1)
  6816. mimmune = true
  6817. if (this.obj[i]["twistedmind"] == 1) mimmune = true
  6818. }
  6819. var morale = 0
  6820. var day = 0
  6821. if (
  6822. heroes[this.obj[i].owner] &&
  6823. magic[heroes[this.obj[i].owner]]["day"]
  6824. ) {
  6825. day = magic[heroes[this.obj[i].owner]]["day"]["effect"]
  6826. }
  6827. if (
  6828. this.obj[i].stone ||
  6829. this.obj[i].statix ||
  6830. this.obj[i].portal ||
  6831. (day != 1 &&
  6832. (this.obj[i].undead ||
  6833. this.obj[i].elemental ||
  6834. this.obj[i].mechanical ||
  6835. this.obj[i].warmachine ||
  6836. magic[i]["und"]))
  6837. ) {
  6838. morale = 0
  6839. } else {
  6840. ma = 0
  6841. if (this.obj[i].moraleaddon) ma = this.obj[i].moraleaddon
  6842. var m = ma
  6843. if (this.obj[i].packpower) {
  6844. var len = this.obj_array.length
  6845. for (var k1 = 0; k1 < len; k1++) {
  6846. k = this.obj_array[k1]
  6847. if (
  6848. k != i &&
  6849. this.obj[k].packpower &&
  6850. this.obj[k].nownumber > 0 &&
  6851. this.obj[k].side == this.obj[i].side &&
  6852. this.obj[k].x <= defxn
  6853. ) {
  6854. m++
  6855. if (this.obj[k].packboss) m++
  6856. }
  6857. }
  6858. }
  6859. if (inserted) {
  6860. var k = 0
  6861. var x = 0,
  6862. y = 0,
  6863. b = 0,
  6864. x2 = 0,
  6865. y2 = 0,
  6866. b2 = 0
  6867. var frig = false
  6868. var brave = false
  6869. var deathstare = false
  6870. var set_zero_morale = false
  6871. var len = this.obj_array.length
  6872. for (var k1 = 0; k1 < len; k1++) {
  6873. k = this.obj_array[k1]
  6874. if (
  6875. this.obj[k].deathstare &&
  6876. this.obj[k].side != this.obj[i].side &&
  6877. this.obj[k].nownumber > 0 &&
  6878. !mimmune
  6879. )
  6880. deathstare = true
  6881. if (
  6882. this.obj[k].frightful_aura &&
  6883. this.obj[k].side != this.obj[i].side &&
  6884. this.obj[k].nownumber > 0 &&
  6885. !mimmune
  6886. ) {
  6887. var bigx = this.obj[i]["big"]
  6888. var bigy = this.obj[i]["big"]
  6889. if (this.obj[i]["bigx"]) bigx = 1
  6890. if (this.obj[i]["bigy"]) bigy = 1
  6891. var bigkx = this.obj[k]["big"]
  6892. var bigky = this.obj[k]["big"]
  6893. if (this.obj[k]["bigx"]) bigkx = 1
  6894. if (this.obj[k]["bigy"]) bigky = 1
  6895. for (x = this.obj[i].x; x <= this.obj[i].x + bigx; x++) {
  6896. for (y = this.obj[i].y; y <= this.obj[i].y + bigy; y++) {
  6897. for (
  6898. x2 = this.obj[k].x;
  6899. x2 <= this.obj[k].x + bigkx;
  6900. x2++
  6901. ) {
  6902. for (
  6903. y2 = this.obj[k].y;
  6904. y2 <= this.obj[k].y + bigky;
  6905. y2++
  6906. ) {
  6907. if (Math.abs(x - x2) <= 1 && Math.abs(y - y2) <= 1) {
  6908. frig = true
  6909. }
  6910. }
  6911. }
  6912. }
  6913. }
  6914. }
  6915. if (
  6916. this.obj[k].auraofbravery &&
  6917. this.obj[k].side == this.obj[i].side &&
  6918. this.obj[k].nownumber > 0
  6919. ) {
  6920. var bigx = this.obj[i]["big"]
  6921. var bigy = this.obj[i]["big"]
  6922. if (this.obj[i]["bigx"]) bigx = 1
  6923. if (this.obj[i]["bigy"]) bigy = 1
  6924. var bigkx = this.obj[k]["big"]
  6925. var bigky = this.obj[k]["big"]
  6926. if (this.obj[k]["bigx"]) bigkx = 1
  6927. if (this.obj[k]["bigy"]) bigky = 1
  6928. for (x = this.obj[i].x; x <= this.obj[i].x + bigx; x++) {
  6929. for (y = this.obj[i].y; y <= this.obj[i].y + bigy; y++) {
  6930. for (
  6931. x2 = this.obj[k].x;
  6932. x2 <= this.obj[k].x + bigkx;
  6933. x2++
  6934. ) {
  6935. for (
  6936. y2 = this.obj[k].y;
  6937. y2 <= this.obj[k].y + bigky;
  6938. y2++
  6939. ) {
  6940. if (Math.abs(x - x2) <= 1 && Math.abs(y - y2) <= 1) {
  6941. brave = true
  6942. }
  6943. }
  6944. }
  6945. }
  6946. }
  6947. }
  6948. if (
  6949. (this.obj[i].morale > 0 || m > 0) &&
  6950. !this.obj[i].bravery &&
  6951. !mimmune &&
  6952. this.obj[k].menacinglook &&
  6953. this.obj[k].side != this.obj[i].side &&
  6954. this.obj[k].nownumber > 0
  6955. ) {
  6956. var bigx = this.obj[i]["big"]
  6957. var bigy = this.obj[i]["big"]
  6958. if (this.obj[i]["bigx"]) bigx = 1
  6959. if (this.obj[i]["bigy"]) bigy = 1
  6960. var bigkx = this.obj[k]["big"]
  6961. var bigky = this.obj[k]["big"]
  6962. if (this.obj[k]["bigx"]) bigkx = 1
  6963. if (this.obj[k]["bigy"]) bigky = 1
  6964. for (x = this.obj[i].x; x <= this.obj[i].x + bigx; x++) {
  6965. for (y = this.obj[i].y; y <= this.obj[i].y + bigy; y++) {
  6966. for (
  6967. x2 = this.obj[k].x;
  6968. x2 <= this.obj[k].x + bigkx;
  6969. x2++
  6970. ) {
  6971. for (
  6972. y2 = this.obj[k].y;
  6973. y2 <= this.obj[k].y + bigky;
  6974. y2++
  6975. ) {
  6976. if (Math.abs(x - x2) <= 1 && Math.abs(y - y2) <= 1) {
  6977. m = 0
  6978. set_zero_morale = true
  6979. }
  6980. }
  6981. }
  6982. }
  6983. }
  6984. }
  6985. }
  6986. if (frig) {
  6987. m -= 3
  6988. this.clearPar(i, "morale")
  6989. }
  6990. }
  6991. if (!mimmune && festering) {
  6992. //+
  6993. m -= 2
  6994. this.clearPar(i, "morale")
  6995. }
  6996. if (!mimmune && deathstare) {
  6997. m -= 1
  6998. }
  6999. morale = this.obj[i].morale + m
  7000. if (set_zero_morale) {
  7001. morale = 0
  7002. brave = false
  7003. }
  7004. if (this.obj[i].morale + m < 3 && this.obj[i].bravery) {
  7005. morale = 3
  7006. }
  7007. if (this.obj[i].morale + m < 3 && brave) {
  7008. if (!this.obj[i].bravery && !this.obj[i].auraofbravery) {
  7009. this.clearPar(i, "morale")
  7010. }
  7011. morale = 3
  7012. }
  7013. }
  7014. if (magic[i] && magic[i]["hyp"] && magic[i]["hyp"]["nowinit"] > 0) {
  7015. morale = Math.min(0, morale)
  7016. }
  7017. return morale
  7018. }
  7019. stage.pole.clearPar = function (i, name) {
  7020. if (this.obj[i] === "undefined") {
  7021. return 0
  7022. }
  7023. if (name == "morale") {
  7024. this.obj[i].moraleCount = 0
  7025. this.obj[i].turnCount = 0
  7026. }
  7027. if (name == "luck") {
  7028. this.obj[i].luckcount = 0
  7029. this.obj[i].hitcount = 0
  7030. }
  7031. }
  7032. stage.pole.showmi = unsafeWindow.showmi = function (i) {
  7033. if (typeof unsafeWindow.mini_info_panel === "undefined") return 0
  7034. if (i > 0) {
  7035. testBlock(i)
  7036. infoBlock(i)
  7037. } else {
  7038. testBlock()
  7039. infoBlock()
  7040. }
  7041. if (i == -1) {
  7042. return 0
  7043. }
  7044. if (typeof unsafeWindow.mini_info_panel.miss === "undefined") {
  7045. var stat = "miss"
  7046. var temp = Make_Sprite()
  7047. temp.inited_show = true
  7048. temp.r = 0
  7049. temp.aaa = "miss"
  7050. set_visible(temp, 0)
  7051. var img_temp = My_Image({
  7052. offsetX: -razmetka["war_images"][17][mqc["sdx"]],
  7053. offsetY: -razmetka["war_images"][17][mqc["sdy"]],
  7054. image: stage.pole.ground["war_images"],
  7055. width: razmetka["war_images"][19][mqc["xs"]],
  7056. height: razmetka["war_images"][19][mqc["ys"]] / 2,
  7057. crop: {
  7058. x: razmetka["war_images"][19][mqc["x"]],
  7059. y:
  7060. razmetka["war_images"][19][mqc["y"]] +
  7061. razmetka["war_images"][19][mqc["ys"]] / 2,
  7062. width: razmetka["war_images"][19][mqc["xs"]],
  7063. height: razmetka["war_images"][19][mqc["ys"]] / 2,
  7064. visible: 1,
  7065. },
  7066. listening: false,
  7067. })
  7068. Make_addChild(temp, img_temp)
  7069. mini_info_panel[stat] = temp
  7070. var ttext = Make_Text("", {
  7071. x: 55,
  7072. y: 0,
  7073. fontFamily: "Arial",
  7074. fontStyle_konva: "Bold",
  7075. fontSize: mini_info_font_size,
  7076. fill: 0xffffff,
  7077. stroke: 0x000000,
  7078. strokeThickness: miniinfo_stroke_width,
  7079. // strokeThickness: 0.5,
  7080. shadowForStrokeEnabled: false,
  7081. // textBaseline: 'middle',
  7082. dropShadowColor: 0x000000,
  7083. dropShadowAlpha: 1,
  7084. dropShadowBlur: 2,
  7085. dropShadow: true,
  7086. dropShadowDistance: 0,
  7087. dropShadowAngle: 0,
  7088. })
  7089. set_X(ttext, 55)
  7090. set_Y(ttext, 0)
  7091. temp.line = ttext
  7092. Make_addChild(temp, ttext)
  7093. Make_addChild(mini_info_panel, temp)
  7094. }
  7095. var y = Array(-7.45, 0.5, 9.05, 18.5)
  7096. var k = 0
  7097. if (
  7098. !this.obj[i].mvisible ||
  7099. this.obj[i].nownumber <= 0 /*||(this.obj[i]._x<0)*/
  7100. )
  7101. return 0
  7102. var stats = ["tnv", "wave", "health", "blood", "mana", "arrow", "miss"]
  7103. this.mini_info_panel_scale()
  7104. var s_stats = Array()
  7105. for (var j = 0; j < stats.length; j++) {
  7106. if (mini_info_panel[stats[j]]) {
  7107. set_visible(mini_info_panel[stats[j]], 0)
  7108. }
  7109. s_stats[stats[j]] = ""
  7110. }
  7111. set_visible(mini_info_panel, 1)
  7112. var ntxt = ""
  7113. if (this.obj[i].hero) {
  7114. switch (lang) {
  7115. case 0:
  7116. ntxt =
  7117. this.obj[i].nametxt + " [" + this.obj[i].maxhealth + " ур.]"
  7118. break
  7119. case 1:
  7120. ntxt =
  7121. this.obj[i].nametxt + " [" + this.obj[i].maxhealth + " lev.]"
  7122. break
  7123. }
  7124. if (this.obj[i].maxmanna > 0 || this.obj[i].nowmanna > 0) {
  7125. s_stats["mana"] = this.obj[i].nowmanna + "/" + this.obj[i].maxmanna
  7126. }
  7127. if (magic[i]["tur"]) {
  7128. s_stats["tnv"] = magic[i]["tur"]["effect"] + "%"
  7129. }
  7130. } else {
  7131. if (this.obj[i].boss > 0) {
  7132. switch (lang) {
  7133. case 0:
  7134. ntxt = this.obj[i].nametxt + " [" + this.obj[i].boss + " ур.]"
  7135. break
  7136. case 1:
  7137. ntxt = this.obj[i].nametxt + " [" + this.obj[i].boss + " lev.]"
  7138. break
  7139. }
  7140. } else {
  7141. ntxt = this.obj[i].nametxt
  7142. if (this.obj[i].nownumber > 0) {
  7143. var addinf = " [" + this.obj[i].nownumber + "]"
  7144. if (
  7145. this.obj[i].stone ||
  7146. this.obj[i].statix ||
  7147. this.obj[i].warmachine ||
  7148. this.obj[i].portal ||
  7149. magic[i]["nnm"] ||
  7150. magic[i]["BLD"]
  7151. ) {
  7152. addinf = ""
  7153. }
  7154. ntxt = this.obj[i].nametxt + addinf
  7155. } else {
  7156. ntxt = this.obj[i].nametxt + " [" + this.obj[i].maxnumber + "]"
  7157. }
  7158. if (magic[i]["lev"]) {
  7159. switch (lang) {
  7160. case 0:
  7161. ntxt += "(" + magic[i]["lev"]["effect"] + " ур)"
  7162. break
  7163. case 1:
  7164. ntxt += "(" + magic[i]["lev"]["effect"] + " lev)"
  7165. break
  7166. }
  7167. }
  7168. }
  7169. s_stats["health"] =
  7170. this.obj[i].nowhealth + "/" + this.obj[i].maxhealth
  7171. if (this.obj[i].shooter && !this.obj[i].shadowattack) {
  7172. s_stats["arrow"] = this.obj[i].shots
  7173. }
  7174. if (
  7175. this.obj[i].caster &&
  7176. this.obj[i].caster != "" &&
  7177. !this.obj[i].randomcasterd &&
  7178. !this.obj[i].crystal
  7179. ) {
  7180. s_stats["mana"] = this.obj[i].nowmanna + "/" + this.obj[i].maxmanna
  7181. }
  7182. if (magic[i]["rag"] && this.obj[i]["ragingblood"]) {
  7183. var rlevel = Array(-10000, 200, 500, 1000)
  7184. var lev = 1
  7185. for (var z = 1; z <= 2; z++) {
  7186. if (rlevel[z] <= magic[i]["rag"]["effect"]) lev = z + 1
  7187. }
  7188. var her = 0,
  7189. herolevel = 0
  7190. var len = this.obj_array.length
  7191. for (var k1 = 0; k1 < len; k1++) {
  7192. var z = this.obj_array[k1]
  7193. if (this.obj[z].hero && this.obj[z].owner == this.obj[i].owner)
  7194. her = z
  7195. }
  7196. if (her > 0) herolevel = this.obj[her].maxhealth
  7197. s_stats["blood"] = magic[i]["rag"]["effect"] + " / " + rlevel[lev]
  7198. k++
  7199. }
  7200. s_stats["miss"] = ""
  7201. if (this.obj[i].incorporeal) {
  7202. if (this.obj[i].misscount == 1) {
  7203. s_stats["miss"] = "50% +"
  7204. } else if (this.obj[i].misscount == 2) {
  7205. s_stats["miss"] = "0%"
  7206. } else if (this.obj[i].misscount == -1) {
  7207. s_stats["miss"] = "50% -"
  7208. } else if (this.obj[i].misscount == -2) {
  7209. s_stats["miss"] = "100%"
  7210. } else {
  7211. s_stats["miss"] = "50%"
  7212. }
  7213. }
  7214. }
  7215. ntxt = ""
  7216. set_text(mini_info_panel.name_text, ntxt)
  7217. var y = 0
  7218. for (var j = 0; j < stats.length; j++) {
  7219. if (s_stats[stats[j]] != "") {
  7220. set_visible(mini_info_panel[stats[j]], 1)
  7221. set_Y(mini_info_panel[stats[j]], y - 5)
  7222. set_Y(mini_info_panel[stats[j]].line, 5)
  7223. set_text(mini_info_panel[stats[j]].line, s_stats[stats[j]])
  7224. set_fontSize(mini_info_panel[stats[j]].line, mini_info_font_size)
  7225. var k = mini_info_font_size
  7226. var p_height = get_height(mini_info_panel[stats[j]].line)
  7227. while (get_width(mini_info_panel[stats[j]].line) > 180 && k > 3) {
  7228. k--
  7229. set_fontSize(mini_info_panel[stats[j]].line, k)
  7230. }
  7231. p_height -= get_height(mini_info_panel[stats[j]].line)
  7232. set_Y(mini_info_panel[stats[j]].line, 5 + Math.floor(p_height / 2))
  7233. set_strokeThickness(
  7234. mini_info_panel[stats[j]].line,
  7235. (k / mini_info_font_size) * miniinfo_stroke_width
  7236. )
  7237. yplus = 40
  7238. y += yplus
  7239. if (y >= yplus * 3) break
  7240. }
  7241. }
  7242. }
  7243. unsafeWindow.raidsCountWaves = 0
  7244. if (btype == 8) {
  7245. let lastCount = 0
  7246. for (i in stage.pole.obj) {
  7247. if (
  7248. stage.pole.obj[i].owner == 2 &&
  7249. lastCount != stage.pole.obj[i].nownumber
  7250. ) {
  7251. raidsCountWaves++
  7252. lastCount = stage.pole.obj[i].nownumber
  7253. }
  7254. }
  7255. }
  7256. stage.pole.showmitnv = function (raids = 0) {
  7257. if (typeof unsafeWindow.mini_info_panel === "undefined") return 0
  7258. if (tnvscore == 0 && raids == 0) return 0
  7259. var y = Array(-7.45, 0.5, 9.05, 18.5)
  7260. var k = 0
  7261. this.mini_info_panel_scale()
  7262. var s_stats = Array()
  7263. var stats = ["tnv", "health", "blood", "mana", "arrow"]
  7264. for (var j = 0; j < stats.length; j++) {
  7265. set_visible(mini_info_panel[stats[j]], 0)
  7266. s_stats[stats[j]] = ""
  7267. }
  7268. set_visible(mini_info_panel, 1)
  7269. var stats = ["tnv", "wave"]
  7270. var y = 10
  7271. var txt = Array()
  7272. txt[0] = tnvscore
  7273. if (raids == 1) {
  7274. txt[1] = raidsCurrentWave + "/" + raidsCountWaves
  7275. } else if (raids == 2) {
  7276. txt[1] = global_init / 100 + " time"
  7277. } else {
  7278. txt[1] = tnvwave
  7279. }
  7280. set_text(mini_info_panel.name_text, "")
  7281. for (var j = Math.ceil(raids / 10); j <= 1; j++) {
  7282. set_visible(mini_info_panel[stats[j]], 1)
  7283. set_X(mini_info_panel[stats[j]], 5)
  7284. set_Y(mini_info_panel[stats[j]], y - 5)
  7285. set_Y(mini_info_panel[stats[j]].line, 5)
  7286. set_text(mini_info_panel[stats[j]].line, " " + txt[j])
  7287. set_fontSize(mini_info_panel[stats[j]].line, mini_info_font_size)
  7288. var k = mini_info_font_size
  7289. while (get_width(mini_info_panel[stats[j]].line) > 175 && k > 3) {
  7290. k--
  7291. set_fontSize(mini_info_panel[stats[j]].line, k)
  7292. }
  7293. set_strokeThickness(
  7294. mini_info_panel[stats[j]].line,
  7295. (k / mini_info_font_size) * miniinfo_stroke_width
  7296. )
  7297. yplus = 60
  7298. y += yplus
  7299. }
  7300. }
  7301. document
  7302. .getElementById("oneskill_button")
  7303. .addEventListener("mouseover", oneskill_button_release_test)
  7304. document
  7305. .getElementById("oneskill_button")
  7306. .addEventListener("mouseout", waitbutton_onRollOut)
  7307. document
  7308. .getElementById("oneskill_button2")
  7309. .addEventListener("mouseover", oneskill_button_release_test)
  7310. document
  7311. .getElementById("oneskill_button2")
  7312. .addEventListener("mouseout", waitbutton_onRollOut)
  7313. stage.pole.atb_scale()
  7314. unsafeWindow.timer_show_army = function () {
  7315. nframe++
  7316. var time_now = Date.now()
  7317. if (last_timer_in == 0) last_timer_in = time_now
  7318. var skip_frame = Math.min(
  7319. 1,
  7320. Math.max(
  7321. 0,
  7322. Math.floor((time_now - last_timer_in) / timer_interval) - 1
  7323. )
  7324. )
  7325. var fps_l = 1000 / (time_now - last_timer_in)
  7326. if (fps_long == 0) {
  7327. fps_long = fps_l
  7328. } else {
  7329. fps_long = Math.min(fps_l, fps_long)
  7330. }
  7331. if (war_scr == "") return 0
  7332. if (!was_benchmark) return 0
  7333. if (animspeed_def < 1 && nframe % 2 == 0 && skip_frame == 0) {
  7334. next_timer()
  7335. return 0
  7336. }
  7337. animspeed = Math.max(1, animspeed_def) * (skip_frame + 1)
  7338. last_timer_in = time_now
  7339. if (skip_frame) {
  7340. total_skips++
  7341. total_skips2++
  7342. } else {
  7343. total_skips = 0
  7344. }
  7345. if (total_skips > 1) {
  7346. skip_frame = 0
  7347. total_skips = 0
  7348. }
  7349. was_skip_frame = skip_frame
  7350. try {
  7351. if (typeof unsafeWindow.stage[war_scr].animate_army === "function") {
  7352. stage[war_scr].animate_army(nframe, skip_frame)
  7353. updateBar(btype == 145 ? 6 : 2)
  7354. if (
  7355. typeof unsafeWindow.mini_info_panel !== "undefined" &&
  7356. !mini_info_panel.visible
  7357. ) {
  7358. testBlock()
  7359. infoBlock()
  7360. }
  7361. for (k in stage.pole.obj) {
  7362. if (stage.pole.obj[k].hero != undefined) continue
  7363. stage.pole.luckMoraleProbability(k, "morale")
  7364. if (
  7365. ((stage.pole.obj[k].nownumber == 0 &&
  7366. stage.pole.obj[k].gate != 1) ||
  7367. (stage.pole.obj[k].nowhealth == 0 &&
  7368. stage.pole.obj[k].last_dead != 1 &&
  7369. stage.pole.obj[k].gate == 1)) &&
  7370. (inserted ||
  7371. stage.pole.obj[k].owner == 2 ||
  7372. btype == _QUESTWAR ||
  7373. btype == _VILLAGE_EVENT) &&
  7374. !stage.pole.obj[k].rock
  7375. ) {
  7376. if (magic[k].def !== undefined) {
  7377. delete magic[k].def
  7378. }
  7379. }
  7380. }
  7381. if (magicuse != "chainlighting") {
  7382. for (let i in stage.pole.obj) {
  7383. if (
  7384. lastChain != 0 &&
  7385. stage.pole.obj[lastChain].chain &&
  7386. stage.pole.obj[i].needSetNumber == 1 &&
  7387. stage.pole.obj[lastChain].chain.indexOf(parseInt(i)) == -1
  7388. ) {
  7389. stage.pole.obj[i].set_number()
  7390. stage.pole.obj[i].needSetNumber = 0
  7391. }
  7392. }
  7393. }
  7394. if (btime != global_init && btype == 119) {
  7395. // stage.pole.showmitnv(2);
  7396. btime = global_init
  7397. }
  7398. }
  7399. } catch (e) {
  7400. my_alert(e.stack + " " + war_scr)
  7401. }
  7402. }
  7403. stage.pole.getmorale = stage.pole.getMoraleN
  7404. }
  7405. }
  7406.  
  7407. if (location.pathname.indexOf("inventory.php") >= 0) {
  7408. var inp = ""
  7409. var bt = ""
  7410. function inv_art_search_show() {
  7411. let info = document.getElementById("inv_art_amount")
  7412. for (let i = 0; i < info.children.length; i++) {
  7413. info.children[i].style.display = "none"
  7414. }
  7415. if (inp == "") {
  7416. inp = document.createElement("input")
  7417. inp.setAttribute("placeholder", "Поиск по названию")
  7418. inp.setAttribute("type", "text")
  7419. inp.setAttribute("id", "inp_search")
  7420. info.append(inp)
  7421. inp.addEventListener("input", search)
  7422. inp.style.display = "inline-block"
  7423. bt = document.createElement("button")
  7424. bt.innerHTML = "Скрыть поиск"
  7425. bt.setAttribute("id", "bt_search")
  7426. info.append(bt)
  7427. bt.addEventListener("click", hide_search)
  7428. bt.style.display = "inline-block"
  7429. } else {
  7430. bt.style.display = "inline-block"
  7431. inp.style.display = "inline-block"
  7432. }
  7433. start_hide_hwm_hint()
  7434. }
  7435. function hide_search() {
  7436. let info = document.getElementById("inv_art_amount")
  7437. for (let i = 0; i < info.children.length; i++) {
  7438. info.children[i].style.display =
  7439. info.children[i].tagName == "DIV" ? "inline-block" : "none"
  7440. }
  7441. }
  7442. function search() {
  7443. let s = document.getElementById("inp_search").value
  7444. let el = document.getElementById("inventory_block")
  7445. for (let i = 0; i < el.children.length; i++) {
  7446. let id = el.children[i].getAttribute("art_idx")
  7447. if (id == null) {
  7448. continue
  7449. }
  7450. el.children[i].style.display = arts[id].name
  7451. .toLowerCase()
  7452. .includes(s.toLowerCase())
  7453. ? "block"
  7454. : "none"
  7455. }
  7456. }
  7457. let sDiv = document.createElement("div")
  7458. let sImg = document.createElement("img")
  7459. sImg.setAttribute("src", "https://daily.heroeswm.ru/i/search_logo.png")
  7460. sImg.setAttribute("class", "inv_100mwmh")
  7461. sDiv.append(sImg)
  7462. sDiv.classList.add("divs_inline_right_24")
  7463. sDiv.classList.add("btn_hover")
  7464. sDiv.classList.add("show_hint")
  7465. sDiv.style.right = "28px"
  7466. document.getElementById("inv_art_amount").append(sDiv)
  7467. sDiv.setAttribute("hint", "Поиск по названию")
  7468. sDiv.setAttribute("hwm_hint_added", 1)
  7469. sDiv.addEventListener("mousemove", show_hwm_hint)
  7470. sDiv.addEventListener("touchstart", show_hwm_hint)
  7471. sDiv.addEventListener("mouseout", hide_hwm_hint)
  7472. sDiv.addEventListener("touchend", hide_hwm_hint)
  7473. sDiv.addEventListener("click", inv_art_search_show)
  7474. }
  7475. if (
  7476. location.pathname.indexOf("war.php") >= 0 ||
  7477. location.pathname.indexOf("warlog.php") >= 0
  7478. ) {
  7479. let timer = setInterval(check_start, 10)
  7480. function check_start() {
  7481. if (unsafeWindow.gpause == false) {
  7482. unsafeWindow.gpause = true
  7483. clearInterval(timer)
  7484. }
  7485. }
  7486. var warid = location.search.match(/warid=([0-9]+)/)?.[1]
  7487. var key =
  7488. location.search.match(/show_for_all=([0-9a-zA-Z]+)/)?.[1] ||
  7489. location.search.match(/show=([0-9a-zA-Z]+)/)?.[1] ||
  7490. ""
  7491. var att = 0
  7492. var unit = Array(8).fill("")
  7493. getAtb(0)
  7494. document.getElementById("confirm_ins").addEventListener(
  7495. "click",
  7496. function () {
  7497. setTimeout(getAtb(1), 4000)
  7498. },
  7499. false
  7500. )
  7501. function getAtb(r) {
  7502. GM_xmlhttpRequest({
  7503. method: "GET",
  7504. url: "/battle.php?lastturn=-3&warid=" + warid + "&show_for_all=" + key,
  7505. onload: function (res) {
  7506. let info =
  7507. "<style>.cont{position:relative;display:inline-block}.count {position: absolute;right: 0;bottom: 0;color: #f5c140;text-shadow: 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000, 0px 0px 3px #000;font-size: 1rem;font-weight: bold;}</style>"
  7508. info += "<b>Стартовый бонус АТБ</b><BR>"
  7509. if (res.responseText == "t=950turns=") {
  7510. if (r == 1) {
  7511. info += "Ошибка загрузки, начните бой и обновите страницу!"
  7512. } else {
  7513. return false
  7514. }
  7515. }
  7516. let data = res.responseText
  7517. .substring(res.responseText.indexOf(";/") + 2)
  7518. .split(";")
  7519. for (let i = 0; i < data.length - 1; i++) {
  7520. if (data[i].indexOf("|rock|") != -1) {
  7521. continue
  7522. }
  7523. let unitNum = Number(data[i].substring(1, 3))
  7524. let armyNum = Number(data[i].substring(5 + 0 * 6, 5 + 1 * 6)) - 1
  7525. let count = Number(data[i].substring(5 + 12 * 6, 5 + 13 * 6))
  7526. let startAtb =
  7527. 100 - Number(data[i].substring(5 + 9 * 6, 5 + 10 * 6))
  7528. let img
  7529. if (data[i].indexOf("|hero|") == -1) {
  7530. img = data[i].substring(5 + 24 * 6, data[i].indexOf("|"))
  7531. } else {
  7532. img = data[i].split("|")[8].substring(1)
  7533. }
  7534. img = img.substring(0, img.length - 3)
  7535. unit[armyNum] +=
  7536. "<div class = 'cont'><img width = '40px' src='/i/portraits/" +
  7537. img +
  7538. "anip40.png'><div class = 'count'>" +
  7539. startAtb +
  7540. "</div></div>"
  7541. }
  7542. for (let i = 0; i < unit.length; i++) {
  7543. if (unit[i] != "") {
  7544. info += "Команда №" + (i + 1) + "<BR>" + unit[i] + "<BR>"
  7545. }
  7546. }
  7547. let elem = []
  7548. elem[0] = document.querySelector("#chat_format")
  7549. elem[1] = document.querySelector("#chat_format_classic")
  7550. //elem[0].innerHTML = info + elem[0].innerHTML;
  7551. //elem[1].innerHTML = info + elem[1].innerHTML;
  7552. elem[0].innerHTML =
  7553. "<div class = 'atb-info' style = 'display:none'>" +
  7554. info +
  7555. "</div>" +
  7556. elem[0].innerHTML
  7557. elem[1].innerHTML =
  7558. "<div class = 'atb-info' style = 'display:none'>" +
  7559. info +
  7560. "</div>" +
  7561. elem[1].innerHTML
  7562. },
  7563. })
  7564. }
  7565. }
  7566. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址