battle_damage

Показывает вражеские урон всех стеков по одному своему. Выбрать существо можно здесь на этой строчке кода снизу "const CREATURE = ...". Урон не корректен, так что нужно помнить про погрешность

当前为 2023-04-10 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         battle_damage
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Показывает вражеские урон всех стеков по одному своему. Выбрать существо можно здесь на этой строчке кода снизу "const CREATURE = ...". Урон не корректен, так что нужно помнить про погрешность
// @author       You
// @license      None
// @match       https://www.heroeswm.ru/war*
// @match       https://my.lordswm.com/war*
// @match       https://www.lordswm.com/war*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
let chosen_one = "Высшие вампиры"
let outer_chat = document.getElementById("chat_format");
outer_chat.innerHTML+= '<button id = "dmg_list_refresh" style="background-color: #555; color: white; padding: 5px 10px; border: none; border-radius: 4px; font-size: 10px; cursor: pointer">Open</button><select style = "display : none; background-color: #333; color: white; margin: 10px" id = "choose_cre"></select>'
let chat = document.getElementById("chat_inside");
//chat_format
let info = "<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>";
info += "<b>Ass</b><BR>";
info+= "<div id = 'creature_dmg_list'> </div>"
let refresh_button = document.getElementById("dmg_list_refresh")
let select = document.getElementById("choose_cre")
document.getElementById("dmg_list_refresh").onclick = refresh

function get_dmg_info(cre1_id, cre2_id){
    window.stage.pole.attackmonster(cre1_id, window.stage.pole.obj[cre1_id].x, window.stage.pole.obj[cre1_id].y, window.stage.pole.obj[cre2_id].x, window.stage.pole.obj[cre2_id].y, cre2_id)
    return {min: window.PhysicalDamage, max: window.PhysicalDamage2}
}
select.addEventListener('change', function() {
    chosen_one = select.value
    refresh(this.selectedIndex)
});
let defender_obj_id = 0
function refresh(selected_id = 0){
    select.style.display = "inline"
    refresh_button.innerHTML = "Refresh"
    let cre_list = Object.values(window.stage.pole.obj);
    cre_list.sort(function(a, b) {
        return a.obj_index - b.obj_index;
    });
    [...chat.children].forEach(child=>{
        if (child.tagName == "P") child.remove()
    })
    select.innerHTML = ""
    let found_defender = false
    let option_id = 0
    cre_list.forEach(creature => {
        console.log(`${creature.obj_index}: ${creature.nametxt}`)
        if (creature.nownumber!=0 && creature.nametxt!="" && creature.side == 1 && creature.hero == undefined){
            select.innerHTML+=`<option value = "${creature.nametxt}">${creature.nametxt} [${creature.nownumber}] </option>`
            if (!found_defender) {
                if (creature.nametxt == chosen_one){
                    defender_obj_id = creature.obj_index
                    found_defender = true
                }
                else defender_obj_id = creature.obj_index
            }
        }
    })
    cre_list.forEach(creature => {
        if (creature.side == -1) {
            if (creature.nownumber == 0 || creature.nametxt == "") return
            let data = get_dmg_info(creature.obj_index, defender_obj_id)
            let hp = cre_list[defender_obj_id-1].maxhealth
            let row = `<p>${creature.nametxt} [${creature.nownumber}] --> ${cre_list[defender_obj_id-1].nametxt} [${cre_list[defender_obj_id-1].nownumber}] : <b>${Math.round(data.min/hp)}-${Math.round(data.max/hp)} существ</b> (${data.min}-${data.max}) id: ${creature.obj_index} -> ${defender_obj_id}} </p>`;
            chat.innerHTML += row;
        }
    })
    select.options.item(selected_id).selected = true
}