FlatMMO+ HP Viewer

Shows the enemy hp while fighting

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         FlatMMO+ HP Viewer
// @namespace    com.dounford.flatmmo.hp
// @version      1.0.2
// @description  Shows the enemy hp while fighting
// @author       Dounford
// @license      MIT
// @match        *://flatmmo.com/play.php*
// @grant        none
// @require      https://update.greasyfork.org/scripts/544062/FlatMMOPlus.js
// ==/UserScript==
 
(function() {
    'use strict';
 
    class hpViewerPlugin extends FlatMMOPlusPlugin {
        constructor() {
            super("hpViewer", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },
            });
        }
        
        onLogin() {

        }
        
        onPaint() {
            for (let uuid in npcs) {
                if (npcs.hasOwnProperty(uuid)) {
                    if(npcs[uuid].in_combat && npcs[uuid].is_hidden === false) {
                        let max_hp = npcs[uuid].max_hp;
                        let hp = npcs[uuid].hp;
                        ctx.fillStyle = "white";
                        ctx.font = "20px serif";
                        ctx.fillText(hp + "/" + max_hp, npcs[uuid].client_x + 4, npcs[uuid].client_y - (npcs[uuid].height - 1) * TILE_SIZE - TILE_SIZE/8 - 3);
                        ctx.font = "16px serif"
                    }
                }
            }
        }
    }
 
    const plugin = new hpViewerPlugin();
    FlatMMOPlus.registerPlugin(plugin);
 
})();