自陣色強調
by
cutfloss
7 hours ago [2026/05/07 18:24:18]
自陣の色が強調されて見えやすくなるぞ
@@ -8,36 +8,36 @@
if(!cvs) return;
const ctx = cvs.getContext('2d');
- /* 1. 自分とチームメイトの色をキャッシュ(負荷軽減のため) */
- const getTeamColors = () => {
- if(typeof players === 'undefined' || typeof myId === 'undefined') return [];
+ /* 状態管理変数 */
+ let myCurrentColor = null;
+
+ /* 1. 自分の色を特定・更新する関数 */
+ const updateMyColor = () => {
+ if(typeof players === 'undefined' || typeof myId === 'undefined') return;
const me = players.find(p => p.id === myId);
- if(!me) return [];
- const team = me.team;
- /* 同じチームのプレイヤーが使っている色を配列で返す */
- return players.filter(p => p.team === team).map(p => p.color.toLowerCase());
+ if(me && me.color) {
+ myCurrentColor = me.color.toLowerCase();
+ }
};
- /* 2. 描画命令の最小フック */
+ /* 定期的に色を更新(試合終了やリスポーン対策) */
+ setInterval(updateMyColor, 500);
+
+ /* 2. 描画命令(fill)に割り込む */
const originalFill = ctx.fill;
ctx.fill = function() {
- const teamColors = getTeamColors();
- /* 現在設定されている色(fillStyle)を取得 */
+ /* 現在の塗りつぶし色を取得 */
const currentStyle = this.fillStyle.toString().toLowerCase();
- /* 味方の色が含まれているか判定 */
- const isAlly = teamColors.some(c => currentStyle.includes(c));
-
- if (isAlly) {
+ /* 今塗ろうとしている色が、最新の「自分の色」と一致するか判定 */
+ if (myCurrentColor && currentStyle.includes(myCurrentColor)) {
this.save();
- this.globalAlpha = 0.8; /* 味方の陣地を濃く(通常0.3→0.8)して見えやすくする */
+ this.globalAlpha = 0.8; /* 自陣(と偶然色が被った人)を濃くする */
originalFill.apply(this, arguments);
this.restore();
} else {
- /* 敵や背景はそのまま(globalAlphaはゲーム本体の設定に従う) */
originalFill.apply(this, arguments);
}
};
- console.log('Ally Color Boost: Active (Minimal impact mode)');
})();
/*
* @title 自陣色強調
* @description 自陣の色が強調されて見えやすくなるぞ
* @private
*/
javascript:(function(){
const cvs = document.querySelector('canvas');
if(!cvs) return;
const ctx = cvs.getContext('2d');
/* 状態管理変数 */
let myCurrentColor = null;
/* 1. 自分の色を特定・更新する関数 */
const updateMyColor = () => {
if(typeof players === 'undefined' || typeof myId === 'undefined') return;
const me = players.find(p => p.id === myId);
if(me && me.color) {
myCurrentColor = me.color.toLowerCase();
}
};
/* 定期的に色を更新(試合終了やリスポーン対策) */
setInterval(updateMyColor, 500);
/* 2. 描画命令(fill)に割り込む */
const originalFill = ctx.fill;
ctx.fill = function() {
/* 現在の塗りつぶし色を取得 */
const currentStyle = this.fillStyle.toString().toLowerCase();
/* 今塗ろうとしている色が、最新の「自分の色」と一致するか判定 */
if (myCurrentColor && currentStyle.includes(myCurrentColor)) {
this.save();
this.globalAlpha = 0.8; /* 自陣(と偶然色が被った人)を濃くする */
originalFill.apply(this, arguments);
this.restore();
} else {
originalFill.apply(this, arguments);
}
};
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。