// ==UserScript== // @name PokeChill 战斗伤害飘字 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 战斗伤害使用醒目颜色,极慢动画。 // @author 人民当家做主 // @match https://play-pokechill.github.io/* // @match https://g1tyx.github.io/play-pokechill/* // @icon https://play-pokechill.github.io/img/icons/icon.png // @grant none // ==/UserScript== (function() { 'use strict'; console.log('[伤害飘字] 脚本已加载'); // 飘字动画样式 - 调整持续时间为2秒,使其消散更慢 const style = document.createElement('style'); style.textContent = ` @keyframes floatUp { 0% { opacity: 1; transform: translate(-50%, -50%) scale(1); text-shadow: 0 0 8px rgba(255,255,255, 0.9); /* 强烈发光效果 */ } 100% { opacity: 0; transform: translate(-50%, -120%) scale(1.1); text-shadow: none; } } `; document.head.appendChild(style); function showFloatingText(value, isPlayer, element) { if (!element || value <= 0) return; // 使用非常醒目的颜色 const color = isPlayer ? '#FF0000' : '#00FF00'; // 最亮的红色和绿色 const fontWeight = 'bold'; const rect = element.getBoundingClientRect(); const div = document.createElement('div'); div.style.cssText = ` position: fixed; left: ${rect.left + rect.width/2}px; top: ${rect.top + rect.height/2}px; transform: translate(-50%, -50%); color: ${color}; font-weight: ${fontWeight}; font-size: 24px; /* 字体稍大一些 */ text-shadow: 3px 3px 6px rgba(0,0,0, 1); /* 更厚重的阴影 */ z-index: 10001; pointer-events: none; animation: floatUp 2s ease-out forwards; /* 动画持续时间延长至2秒 */ font-family: 'Winky Sans', 'Consolas', monospace; `; div.textContent = `-${Math.round(value)}`; document.body.appendChild(div); setTimeout(() => div.remove(), 2000); // 移除元素的时间也相应延长 } // ========== HP监控逻辑 ========== let lastWildHp = null; let lastPlayerHp = null; let lastPlayerId = null; function monitor() { if (typeof saved === 'undefined' || typeof team === 'undefined' || typeof pkmn === 'undefined') { return; } if (!saved.currentArea) { lastWildHp = null; lastPlayerHp = null; lastPlayerId = null; return; } // 监控野生HP (我方攻击) if (typeof wildPkmnHp !== 'undefined') { if (lastWildHp === null) { lastWildHp = wildPkmnHp; } else { const diff = lastWildHp - wildPkmnHp; if (diff > 0.5) { const wildSprite = document.getElementById('explore-wild-sprite'); if (wildSprite) { showFloatingText(diff, false, wildSprite); // false 表示伤害敌方 } } lastWildHp = wildPkmnHp; } } // 监控玩家HP (我方受到伤害) if (typeof exploreActiveMember !== 'undefined' && team[exploreActiveMember] && team[exploreActiveMember].pkmn) { const player = pkmn[team[exploreActiveMember].pkmn.id]; if (player) { const currentHp = player.playerHp; const playerId = player.id; if (lastPlayerHp === null || lastPlayerId !== playerId) { lastPlayerHp = currentHp; lastPlayerId = playerId; } else { const diff = lastPlayerHp - currentHp; if (diff > 0.5) { const playerSprite = document.getElementById(`explore-team-member-${exploreActiveMember}-sprite`); if (playerSprite) { showFloatingText(diff, true, playerSprite); // true 表示伤害我方 } } lastPlayerHp = currentHp; } } } } // 启动监控 setInterval(monitor, 100); })();