近接戦闘マスター
by
cutfloss
04/29 [2026/04/29 23:30:27]
アイコンサイズを小さくして近接戦闘を非運ゲー化する
@@ -8,20 +8,20 @@
if(!cvs) return;
const ctx = cvs.getContext('2d');
- /* --- 設定値(お好みで調整してください) --- */
- const SCALE = 0.5; /* アイコン・画像・絵文字の大きさ (0.5 = 半分) */
- const LINE_SCALE = 0.4; /* 線の太さ (0.4 = 本来の40%の細さに) */
+ /* --- 設定値 --- */
+ const ICON_CHAR_SCALE = 0.4; /* アイコン内の絵文字・文字の大きさ */
+ const ICON_RADIUS_SCALE = 0.5; /* アイコンの円自体の大きさ */
+ const LINE_SCALE = 0.4; /* 線の太さ */
/* 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; /* 他の描画に影響しないよう戻す */
+ this.lineWidth = oldWidth;
return result;
};
@@ -29,34 +29,47 @@
const originalArc = ctx.arc;
ctx.arc = function(x, y, radius, sAngle, eAngle, counterclockwise) {
let r = radius;
- if (radius > 5 && radius < 100) r = radius * SCALE;
+ /* プレイヤー本体の円(だいたい10〜30px)を縮小 */
+ if (radius > 5 && radius < 40) r = radius * ICON_RADIUS_SCALE;
return originalArc.call(this, x, y, r, sAngle, eAngle, counterclockwise);
};
- /* 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 * SCALE, nDH = dh * SCALE;
+ let nDW = dw * ICON_RADIUS_SCALE, nDH = dh * ICON_RADIUS_SCALE;
let nDX = dx + (dw - nDW) / 2, nDY = dy + (dh - nDH) / 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;
- /* フォントサイズを抽出して小さく書き換える */
- this.font = oldFont.replace(/(\d+)px/, (match, size) => {
- return (parseFloat(size) * SCALE) + 'px';
- });
+
+ /* 判定ロジック:
+ 1. 文字数が2文字以内(絵文字や短いID)
+ 2. または、明らかにフォントサイズが大きい(アイコン内用)
+ これに該当する場合のみ小さくする
+ */
+ const fontSize = parseFloat(oldFont) || 0;
+ const isIconChar = text.length <= 2 || fontSize > 16;
+
+ if (isIconChar) {
+ this.font = oldFont.replace(/(\d+)px/, (match, size) => {
+ return (parseFloat(size) * ICON_CHAR_SCALE) + 'px';
+ });
+ }
+ /* 名前(3文字以上など)の場合は oldFont のまま描画される */
+
const result = originalFillText.apply(this, arguments);
- this.font = oldFont; /* 元に戻す */
+ this.font = oldFont;
return result;
};
- console.log('視界最大確保パッチ:適用完了');
- alert('【究極の視界】\nアイコン・絵文字を小さく、線を細くしました!\nこれで敵の根元が丸見えです!');
+ console.log('視界確保パッチ(名前維持版):適用完了');
+ alert('【設定完了】\n・アイコンと絵文字は小さく\n・線は細く\n・名前の大きさはそのまま\nにしました!');
})();
/*
* @title 近接戦闘マスター
* @description アイコンサイズを小さくして近接戦闘を非運ゲー化する
* @private
*/
javascript:(function(){
const cvs = document.querySelector('canvas');
if(!cvs) return;
const ctx = cvs.getContext('2d');
/* --- 設定値 --- */
const ICON_CHAR_SCALE = 0.4; /* アイコン内の絵文字・文字の大きさ */
const ICON_RADIUS_SCALE = 0.5; /* アイコンの円自体の大きさ */
const LINE_SCALE = 0.4; /* 線の太さ */
/* 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, counterclockwise) {
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);
};
/* 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 nDX = dx + (dw - nDW) / 2, nDY = dy + (dh - nDH) / 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;
/* 判定ロジック:
1. 文字数が2文字以内(絵文字や短いID)
2. または、明らかにフォントサイズが大きい(アイコン内用)
これに該当する場合のみ小さくする
*/
const fontSize = parseFloat(oldFont) || 0;
const isIconChar = text.length <= 2 || fontSize > 16;
if (isIconChar) {
this.font = oldFont.replace(/(\d+)px/, (match, size) => {
return (parseFloat(size) * ICON_CHAR_SCALE) + 'px';
});
}
/* 名前(3文字以上など)の場合は oldFont のまま描画される */
const result = originalFillText.apply(this, arguments);
this.font = oldFont;
return result;
};
console.log('視界確保パッチ(名前維持版):適用完了');
alert('【設定完了】\n・アイコンと絵文字は小さく\n・線は細く\n・名前の大きさはそのまま\nにしました!');
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。