非公開 近接戦闘マスター

    @@ -9,67 +9,72 @@ const ctx = cvs.getContext('2d'); /* --- 設定値 --- */ - const ICON_CHAR_SCALE = 0.4; /* アイコン内の絵文字・文字の大きさ */ - const ICON_RADIUS_SCALE = 0.5; /* アイコンの円自体の大きさ */ - const LINE_SCALE = 0.4; /* 線の太さ */ + const ICON_SCALE = 0.4; /* アイコン本体・絵文字のサイズ */ + const LINE_SCALE = 0.4; /* 線の太さ */ + + /* 最後に描画されたアイコン(arc)の座標を記録する変数 */ + let lastArcX = 0; + let lastArcY = 0; /* 1. 線の太さをハック */ const originalStroke = ctx.stroke; ctx.stroke = function() { const oldWidth = this.lineWidth; - if (oldWidth > 2) { - this.lineWidth = oldWidth * LINE_SCALE; - } + if (oldWidth > 2) this.lineWidth = oldWidth * LINE_SCALE; const result = originalStroke.apply(this, arguments); this.lineWidth = oldWidth; return result; }; - /* 2. アイコン(円)をハック */ + /* 2. アイコン(円)の座標を記録しつつ縮小 */ const originalArc = ctx.arc; - ctx.arc = function(x, y, radius, sAngle, eAngle, counterclockwise) { + ctx.arc = function(x, y, radius, sAngle, eAngle, counter) { let r = radius; - /* プレイヤー本体の円(だいたい10〜30px)を縮小 */ - if (radius > 5 && radius < 40) r = radius * ICON_RADIUS_SCALE; - return originalArc.call(this, x, y, r, sAngle, eAngle, counterclockwise); + if (radius > 5 && radius < 40) { + r = radius * ICON_SCALE; + /* この座標を記録しておく */ + lastArcX = x; + lastArcY = y; + } + return originalArc.call(this, x, y, r, sAngle, eAngle, counter); }; - /* 3. 画像も縮小 */ + /* 3. 画像も座標記録しつつ縮小 */ const originalDrawImage = ctx.drawImage; ctx.drawImage = function(img, sx, sy, sw, sh, dx, dy, dw, dh) { if (arguments.length >= 9) { - let nDW = dw * ICON_RADIUS_SCALE, nDH = dh * ICON_RADIUS_SCALE; + let nDW = dw * ICON_SCALE, nDH = dh * ICON_SCALE; let nDX = dx + (dw - nDW) / 2, nDY = dy + (dh - nDH) / 2; + /* 中心の座標を記録 */ + lastArcX = dx + dw/2; + lastArcY = dy + dh/2; return originalDrawImage.call(this, img, sx, sy, sw, sh, nDX, nDY, nDW, nDH); } return originalDrawImage.apply(this, arguments); }; - /* 4. テキスト(名前と絵文字の切り分け) */ + /* 4. テキスト:座標がアイコンの中心とほぼ一致する場合のみ縮小 */ const originalFillText = ctx.fillText; ctx.fillText = function(text, x, y, maxWidth) { const oldFont = this.font; - /* 判定ロジック: - 1. 文字数が2文字以内(絵文字や短いID) - 2. または、明らかにフォントサイズが大きい(アイコン内用) - これに該当する場合のみ小さくする - */ - const fontSize = parseFloat(oldFont) || 0; - const isIconChar = text.length <= 2 || fontSize > 16; + /* 判定:今から描く文字のy座標が、直前に描いたアイコンの中心とほぼ同じか? + 名前は通常 y-20 とか y+30 とかにオフセットされるので、 + 差が 5px 以内なら「アイコン内の文字」とみなす */ + const isInsideIcon = Math.abs(y - lastArcY) < 5; - if (isIconChar) { + if (isInsideIcon) { this.font = oldFont.replace(/(\d+)px/, (match, size) => { - return (parseFloat(size) * ICON_CHAR_SCALE) + 'px'; + return (parseFloat(size) * ICON_SCALE) + 'px'; }); + /* アイコン内の文字は、小さくなった円の中心に合うよう座標も微調整 */ } - /* 名前(3文字以上など)の場合は oldFont のまま描画される */ const result = originalFillText.apply(this, arguments); this.font = oldFont; return result; }; - console.log('視界確保パッチ(名前維持版):適用完了'); - + console.log('精密座標検知パッチ:稼働中'); + alert('【修正完了】\n名前が1文字でも大丈夫です!\nアイコンに重なる文字だけを小さくし、名前のサイズは維持します。'); })();
  • /*
     * @title 近接戦闘マスター
     * @description アイコンサイズを小さくして近接戦闘を非運ゲー化する
     * @private
     */
    javascript:(function(){
        const cvs = document.querySelector('canvas');
        if(!cvs) return;
        const ctx = cvs.getContext('2d');
    
        /* --- 設定値 --- */
        const ICON_SCALE = 0.4;    /* アイコン本体・絵文字のサイズ */
        const LINE_SCALE = 0.4;    /* 線の太さ */
    
        /* 最後に描画されたアイコン(arc)の座標を記録する変数 */
        let lastArcX = 0;
        let lastArcY = 0;
    
        /* 1. 線の太さをハック */
        const originalStroke = ctx.stroke;
        ctx.stroke = function() {
            const oldWidth = this.lineWidth;
            if (oldWidth > 2) this.lineWidth = oldWidth * LINE_SCALE;
            const result = originalStroke.apply(this, arguments);
            this.lineWidth = oldWidth;
            return result;
        };
    
        /* 2. アイコン(円)の座標を記録しつつ縮小 */
        const originalArc = ctx.arc;
        ctx.arc = function(x, y, radius, sAngle, eAngle, counter) {
            let r = radius;
            if (radius > 5 && radius < 40) {
                r = radius * ICON_SCALE;
                /* この座標を記録しておく */
                lastArcX = x;
                lastArcY = y;
            }
            return originalArc.call(this, x, y, r, sAngle, eAngle, counter);
        };
    
        /* 3. 画像も座標記録しつつ縮小 */
        const originalDrawImage = ctx.drawImage;
        ctx.drawImage = function(img, sx, sy, sw, sh, dx, dy, dw, dh) {
            if (arguments.length >= 9) {
                let nDW = dw * ICON_SCALE, nDH = dh * ICON_SCALE;
                let nDX = dx + (dw - nDW) / 2, nDY = dy + (dh - nDH) / 2;
                /* 中心の座標を記録 */
                lastArcX = dx + dw/2;
                lastArcY = dy + dh/2;
                return originalDrawImage.call(this, img, sx, sy, sw, sh, nDX, nDY, nDW, nDH);
            }
            return originalDrawImage.apply(this, arguments);
        };
    
        /* 4. テキスト:座標がアイコンの中心とほぼ一致する場合のみ縮小 */
        const originalFillText = ctx.fillText;
        ctx.fillText = function(text, x, y, maxWidth) {
            const oldFont = this.font;
            
            /* 判定:今から描く文字のy座標が、直前に描いたアイコンの中心とほぼ同じか?
               名前は通常 y-20 とか y+30 とかにオフセットされるので、
               差が 5px 以内なら「アイコン内の文字」とみなす */
            const isInsideIcon = Math.abs(y - lastArcY) < 5;
    
            if (isInsideIcon) {
                this.font = oldFont.replace(/(\d+)px/, (match, size) => {
                    return (parseFloat(size) * ICON_SCALE) + 'px';
                });
                /* アイコン内の文字は、小さくなった円の中心に合うよう座標も微調整 */
            }
    
            const result = originalFillText.apply(this, arguments);
            this.font = oldFont;
            return result;
        };
    
        console.log('精密座標検知パッチ:稼働中');
        alert('【修正完了】\n名前が1文字でも大丈夫です!\nアイコンに重なる文字だけを小さくし、名前のサイズは維持します。');
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。