[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name CQ176自定义生成怪物
// @namespace [url=http://tampermonkey.net/]http://tampermonkey.net/[/url]
// @version 2026-03-03
// @description HOOK怪物生成函数重置怪物属性、掉落、爆率
// @AuThor leeairw
// @match [url=http://119.91.123.78/cq/]http://119.91.123.78/cq/[/url]*
// @require [url=https://code.jquery.com/jquery-3.6.0.min.js]https://code.jquery.com/jquery-3.6.0.min.js[/url]
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function() {
'use strict';
// 使用 unsafeWindow 访问页面上的全局变量和函数
const win = unsafeWindow;
// 怪物掉落物品,type:special 特殊(经验卷、祝福油);skillBook 技能书;equipment 装备{category:部位};potion 药水
// chance 爆率 count 掉落数量 tier 装备等级(和地图对应)
const dropRatesNew = [
{
"type": "special",
"name": "special101",
"chance": 25,
"count": 1
},
{
"type": "special",
"name": "special301",
"chance": 1,
"count": 1
},
{
"type": "special",
"name": "special302",
"chance": 50,
"count": 1
},
{
"type": "skillBook",
"skill": "bookhalfMoon",
"chance": 0
},
{
"type": "skillBook",
"skill": "bookstab",
"chance": 0
},
{
"type": "skillBook",
"skill": "bookfire",
"chance": 0
},
{
"type": "equipment",
"category": "helmets",
"tier": 8,
"chance": 20
},
{
"type": "equipment",
"category": "armors",
"tier": 8,
"chance": 20
},
{
"type": "equipment",
"category": "handAccessories",
"tier": 8,
"chance": 20
},
{
"type": "equipment",
"category": "necklaces",
"tier": 8,
"chance": 20
},
{
"type": "equipment",
"category": "rings",
"tier": 8,
"chance": 20
},
{
"type": "equipment",
"category": "weapons",
"tier": 8,
"chance": 30
},
{
"type": "potion",
"itemId": "shop101",
"chance": 60,
"count": 1
},
{
"type": "potion",
"itemId": "shop201",
"chance": 60,
"count": 1
},
{
"type": "potion",
"itemId": "shop102",
"chance": 60,
"count": 1
},
{
"type": "potion",
"itemId": "shop202",
"chance": 60,
"count": 1
},
{
"type": "potion",
"itemId": "shop103",
"chance": 60,
"count": 1
},
{
"type": "potion",
"itemId": "shop203",
"chance": 60,
"count": 1
}
];
function initialize() {
console.log('怪物修改器: 游戏核心功能已加载,开始Hook...');
// 物品掉落率
gameData.dropRate = 10;
// 极品装备属性倍率
gameData.supremeRate = 100;
// 普通属性倍数
gameData.dropRate = 10;
// 暴击率(因为怪物血量降低了.所以改成0了,因为有的怪一下秒不给结算)
gameData.critRate = 0;
// 1. 保存原始的 spawnMonster 函数
const originalSpawnMonster = win.spawnMonster;
//const currentMap = maps.find(map => map.id === gameData.player.currentMap);
// 2. 创建我们自己的“增强版”函数
const customSpawnMonster = function(...args) {
// 首先,必须调用原始函数,让游戏正常生成一个怪物并设置好所有数据
originalSpawnMonster.apply(this, args);
// 然后,在怪物生成后(即 gameData.currentMonster 被赋值后),我们再来修改它的属性
if (gameData.currentMonster && gameData.currentMonster.hp > 0) {
const monster = gameData.currentMonster;
console.log('name:' + monster.name);
// 将核心战斗属性设置为 1
monster.hp = 250;
monster.maxHp = 250;
monster.attack = 1;
monster.defense = 1;
monster.magicDefense = 1;
// (可选) 如果您也想修改经验和金币,可以取消下面两行的注释
monster.exp = 500000;
monster.gold = 500000;
// 替换为修改后的掉落物
monster.dropRates = dropRatesNew;
// 在游戏日志中添加一条消息,增加趣味性
if (typeof win.addLog === 'function') {
// 使用一个微小的延迟,确保我们的日志出现在游戏默认日志之后
setTimeout(() => {
win.addLog(`【${monster.id}:${monster.name}】被神秘力量削弱了!`, 'system');
}, 50);
}
}
};
// 3. 用我们的版本替换游戏中的原始函数
win.spawnMonster = customSpawnMonster;
console.log('怪物修改器: Hook成功!所有新生成的怪物都将被削弱。');
}
function loopWithDelay() {
if (gameData.player.name != '')
{
console.log('name:' + gameData.player.name);
initialize();
return;
}
setTimeout(loopWithDelay, 100); // 递归调用
}
loopWithDelay();
})();