feat:mod管理器
This commit is contained in:
@@ -4,13 +4,51 @@
|
||||
"name": "自定义法术包",
|
||||
"version": "1.0.0",
|
||||
"author": "OES-WEB",
|
||||
"description": "添加自定义法术,展示脚本化法术系统",
|
||||
"description": "添加 3 个自定义法术到游戏中,用于测试 Mod 系统",
|
||||
"priority": 300,
|
||||
"dependencies": [],
|
||||
"scripts": ["spells.js"]
|
||||
"dependencies": []
|
||||
},
|
||||
"data": {},
|
||||
"scripts": {
|
||||
"spells.js": "log('Custom spells mod loaded!');\n\nmod.registerSpell('chain_lightning', {\n name: '连锁闪电',\n school: 'destruction',\n cost: 30,\n magnitude: 25,\n range: 200,\n description: '发射闪电,可在敌人间弹跳'\n});\n\nmod.registerSpell('blood_heal', {\n name: '血疗术',\n school: 'restoration',\n cost: 20,\n magnitude: 40,\n description: '消耗自身生命值来治疗目标'\n});\n\nmod.registerSpell('shadow_clone', {\n name: '暗影分身',\n school: 'illusion',\n cost: 35,\n duration: 15000,\n description: '创造一个分身吸引敌人注意'\n});\n\ngame.on('spell:cast', (data) => {\n const { caster, spellId, target } = data;\n \n if (spellId === 'chain_lightning') {\n const nearbyEnemies = game.getNearbyEntities(\n caster.position.x,\n caster.position.y,\n 200\n );\n \n let chainTarget = target;\n let chainCount = 0;\n const maxChains = 3;\n const hitEntities = new Set();\n \n if (chainTarget) {\n chainTarget.damage(25, 'shock');\n chainTarget.say('⚡', 1000);\n hitEntities.add(chainTarget.id);\n chainCount++;\n \n while (chainCount < maxChains) {\n let closest = null;\n let closestDist = 150;\n \n for (const enemy of nearbyEnemies) {\n if (hitEntities.has(enemy.id)) continue;\n const dist = chainTarget.distanceTo(enemy);\n if (dist < closestDist) {\n closest = enemy;\n closestDist = dist;\n }\n }\n \n if (closest) {\n closest.damage(20, 'shock');\n closest.say('⚡', 1000);\n hitEntities.add(closest.id);\n chainTarget = closest;\n chainCount++;\n } else {\n break;\n }\n }\n }\n \n return true;\n }\n \n if (spellId === 'blood_heal') {\n const casterHealth = caster.health;\n if (casterHealth && casterHealth.current > 20) {\n caster.damage(20, 'unresistable');\n \n if (target) {\n target.heal(40);\n target.say('+40 HP', 2000);\n } else {\n caster.heal(40);\n caster.say('+40 HP', 2000);\n }\n return true;\n } else {\n caster.say('生命值不足!', 2000);\n return false;\n }\n }\n \n if (spellId === 'shadow_clone') {\n if (!caster.position) return false;\n \n const clone = game.createEntity('npc');\n clone.position = {\n x: caster.position.x + 50,\n y: caster.position.y\n };\n clone.addComponent({\n type: 'npcData',\n name: '暗影分身',\n dialogue: 'clone'\n });\n clone.addComponent({\n type: 'health',\n current: 1,\n max: 1\n });\n clone.addComponent({\n type: 'clone',\n owner: caster.id,\n duration: 15000,\n spawnTime: Date.now()\n });\n \n clone.say('分身出现!', 2000);\n \n game.once('game:update', () => {\n const enemies = game.getNearbyEntities(\n clone.position.x,\n clone.position.y,\n 150\n );\n for (const enemy of enemies) {\n const ai = enemy.getComponent('ai');\n if (ai) {\n ai.state = 'chase';\n }\n }\n });\n \n return true;\n }\n \n return false;\n});\n\ngame.on('game:update', (data) => {\n const clones = game.getEntitiesByType('npc');\n for (const clone of clones) {\n const cloneData = clone.getComponent('clone');\n if (cloneData) {\n const elapsed = Date.now() - cloneData.spawnTime;\n if (elapsed >= cloneData.duration) {\n clone.say('分身消失...', 1000);\n setTimeout(() => {\n game.destroyEntity(clone.id);\n }, 1000);\n }\n }\n }\n});\n\nlog('Custom spells registered: chain_lightning, blood_heal, shadow_clone');"
|
||||
"data": {
|
||||
"spells": {
|
||||
"chain_lightning": {
|
||||
"id": "chain_lightning",
|
||||
"name": "连锁闪电",
|
||||
"school": "destruction",
|
||||
"type": "target",
|
||||
"magickaCost": 35,
|
||||
"magnitude": 20,
|
||||
"duration": 0,
|
||||
"cooldown": 1200,
|
||||
"level": 5,
|
||||
"description": "发射闪电,造成电击伤害",
|
||||
"effects": [{ "type": "damage", "magnitude": 20 }]
|
||||
},
|
||||
"blood_heal": {
|
||||
"id": "blood_heal",
|
||||
"name": "血疗术",
|
||||
"school": "restoration",
|
||||
"type": "self",
|
||||
"magickaCost": 25,
|
||||
"magnitude": 40,
|
||||
"duration": 0,
|
||||
"cooldown": 2000,
|
||||
"level": 3,
|
||||
"description": "消耗少量生命值来治疗自身",
|
||||
"effects": [{ "type": "heal", "magnitude": 40 }]
|
||||
},
|
||||
"shadow_cloak": {
|
||||
"id": "shadow_cloak",
|
||||
"name": "暗影斗篷",
|
||||
"school": "illusion",
|
||||
"type": "self",
|
||||
"magickaCost": 30,
|
||||
"magnitude": 0,
|
||||
"duration": 30,
|
||||
"cooldown": 10000,
|
||||
"level": 4,
|
||||
"description": "隐入暗影,提高潜行能力",
|
||||
"effects": [{ "type": "sneak_bonus", "magnitude": 30, "duration": 30000 }]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user