非公開 効果音追加

    @@ -3,9 +3,7 @@ * @description キル時、ゲーム開始・終了時などに短い効果音が鳴るようになるぞっ * @private */ - javascript:(function(){ - /* 1. 音源の定義(司令官、ここにお好みのURLを入れることも可能です) */ const SOUNDS = { start: 'https://actions.google.com/sounds/v1/alarms/beep_short.ogg', kill: 'https://actions.google.com/sounds/v1/cartoon/pop.ogg', @@ -13,50 +11,51 @@ end: 'https://actions.google.com/sounds/v1/alarms/digital_watch_alarm_long.ogg' }; - /* 音を再生する共通関数 */ const play = (url) => { - const audio = new Audio(url); - audio.volume = 0.5; /* 音量は50%に設定 */ - audio.play().catch(e => console.log('音声を再生できませんでした(ブラウザの制限など):', e)); + const a = new Audio(url); + a.volume = 0.5; + a.play().catch(()=>{}); }; - /* 2. ゲームロジックへのフック(監視) */ - - /* A. 敵を倒した時 (衝撃波 spawnShockwave を利用) */ - const originalSpawnShockwave = window.spawnShockwave; - window.spawnShockwave = function(x, y) { - /* 自分に近い場所での衝撃波(自分が倒した可能性が高い)なら音を鳴らす */ - play(SOUNDS.kill); - return originalSpawnShockwave.apply(this, arguments); + /* 1. 自分が敵を「倒した時」をフック */ + /* キルフィードにメッセージが追加されるタイミングで、自分のキルかどうか判定 */ + const _origAddKill = window.addKillFeed; + window.addKillFeed = function(msg) { + if (typeof players !== 'undefined' && typeof myId !== 'undefined') { + const me = players.find(p => p.id === myId); + const myName = me ? me.name : ''; + /* メッセージの先頭が自分の名前なら、自分がキルした証拠 */ + if (myName && msg.startsWith(myName)) { + play(SOUNDS.kill); + } + } + return _origAddKill.apply(this, arguments); }; - /* B. 自分が倒されたとき / ゲームスタートの監視 */ + /* 2. スタート / 自分が「倒された時」を監視 */ let lastState = 'waiting'; - const originalLoop = window.loop; + const _origLoop = window.loop; window.loop = function() { if (typeof players !== 'undefined' && typeof myId !== 'undefined') { const me = players.find(p => p.id === myId); if (me) { - /* 状態の変化を検知 */ - if (lastState !== 'active' && me.state === 'active') { - play(SOUNDS.start); /* 復活・スタート音 */ - } else if (lastState === 'active' && me.state === 'dead') { - play(SOUNDS.dead); /* 死亡音 */ + if (lastState !== 'active' && me.state === 'active' && !me.isSpawnWait) { + play(SOUNDS.start); /* スタート・復活 */ + } else if (lastState === 'active' && (me.state === 'dead' || me.isGhost)) { + play(SOUNDS.dead); /* 死亡 */ } lastState = me.state; } } - return originalLoop.apply(this, arguments); + return _origLoop.apply(this, arguments); }; - /* C. ゲーム終了(リザルト画面表示) */ - const originalShowResult = window.showResultScreen; - if (typeof originalShowResult === 'function') { - window.showResultScreen = function() { - play(SOUNDS.end); - return originalShowResult.apply(this, arguments); - } - } + /* 3. ラウンド終了をフック */ + const _origResult = window.showResultScreen; + window.showResultScreen = function() { + play(SOUNDS.end); + return _origResult.apply(this, arguments); + }; - alert('【サウンドパッチ】適用完了!\n戦場に音が追加されました。'); -})(); + alert('【自分限定サウンドパッチ】適用!\n自分のキル・死亡・リスポーン時のみ音が鳴ります。'); +})();;
  • /*
     * @title 効果音追加
     * @description キル時、ゲーム開始・終了時などに短い効果音が鳴るようになるぞっ
     * @private
     */
    javascript:(function(){
        const SOUNDS = {
            start: 'https://actions.google.com/sounds/v1/alarms/beep_short.ogg',
            kill: 'https://actions.google.com/sounds/v1/cartoon/pop.ogg',
            dead: 'https://actions.google.com/sounds/v1/science_fiction/glitch_low_power.ogg',
            end: 'https://actions.google.com/sounds/v1/alarms/digital_watch_alarm_long.ogg'
        };
    
        const play = (url) => {
            const a = new Audio(url);
            a.volume = 0.5;
            a.play().catch(()=>{});
        };
    
        /* 1. 自分が敵を「倒した時」をフック */
        /* キルフィードにメッセージが追加されるタイミングで、自分のキルかどうか判定 */
        const _origAddKill = window.addKillFeed;
        window.addKillFeed = function(msg) {
            if (typeof players !== 'undefined' && typeof myId !== 'undefined') {
                const me = players.find(p => p.id === myId);
                const myName = me ? me.name : '';
                /* メッセージの先頭が自分の名前なら、自分がキルした証拠 */
                if (myName && msg.startsWith(myName)) {
                    play(SOUNDS.kill);
                }
            }
            return _origAddKill.apply(this, arguments);
        };
    
        /* 2. スタート / 自分が「倒された時」を監視 */
        let lastState = 'waiting';
        const _origLoop = window.loop;
        window.loop = function() {
            if (typeof players !== 'undefined' && typeof myId !== 'undefined') {
                const me = players.find(p => p.id === myId);
                if (me) {
                    if (lastState !== 'active' && me.state === 'active' && !me.isSpawnWait) {
                        play(SOUNDS.start); /* スタート・復活 */
                    } else if (lastState === 'active' && (me.state === 'dead' || me.isGhost)) {
                        play(SOUNDS.dead); /* 死亡 */
                    }
                    lastState = me.state;
                }
            }
            return _origLoop.apply(this, arguments);
        };
    
        /* 3. ラウンド終了をフック */
        const _origResult = window.showResultScreen;
        window.showResultScreen = function() {
            play(SOUNDS.end);
            return _origResult.apply(this, arguments);
        };
    
        alert('【自分限定サウンドパッチ】適用!\n自分のキル・死亡・リスポーン時のみ音が鳴ります。');
    })();;
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2026/05/07 23:23:57 - 2 hours ago
  2. 2026/05/07 23:23:28 - 2 hours ago
  3. 2026/05/07 23:17:52 - 2 hours ago
  4. 2026/05/07 23:11:10 - 2 hours ago
  5. 2026/05/07 23:08:10 - 2 hours ago
  6. 2026/05/07 22:55:07 - 3 hours ago
  7. 2026/05/07 22:53:10 - 3 hours ago
  8. 2026/05/07 22:43:36 - 3 hours ago
  9. 2026/05/07 21:54:00 - 4 hours ago
  10. 2026/05/07 14:27:35 - 11 hours ago