battleHelper (fixed)

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

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

QingJ © 2025

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