chore:首次提交

This commit is contained in:
Evilom
2026-05-11 17:39:31 +08:00
parent 906f1cf468
commit 83e99a7ef8
109 changed files with 19558 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
{
"manifest": {
"id": "base-scripts",
"name": "基础实体脚本",
"version": "1.0.0",
"author": "OES-WEB",
"description": "为游戏实体提供默认行为脚本:守卫巡逻、狼群AI、亡灵守卫、蜘蛛毒液等",
"priority": 50,
"dependencies": []
},
"data": {},
"scripts": {
"guard_patrol": {
"properties": {
"homeX": 0,
"homeY": 0,
"alertLevel": 0,
"patrolAngle": 0,
"idleTimer": 0,
"state": "idle"
},
"handlers": {
"OnLoad": "var pos = ctx.entity.getPosition(); ctx.prop('homeX', pos.x); ctx.prop('homeY', pos.y); ctx.log('守卫部署完毕,位置: ' + pos.x + ',' + pos.y);",
"OnUpdate": "if (ctx.prop('state') === 'idle') { var t = ctx.prop('idleTimer') + delta; ctx.prop('idleTimer', t); if (t > 3000) { ctx.prop('state', 'patrol'); ctx.prop('idleTimer', 0); } } else if (ctx.prop('state') === 'patrol') { var a = ctx.prop('patrolAngle') + 0.02; ctx.prop('patrolAngle', a); var hx = ctx.prop('homeX'); var hy = ctx.prop('homeY'); var tx = hx + Math.cos(a) * 48; var ty = hy + Math.sin(a) * 48; ctx.entity.setPosition(tx, ty); var t2 = ctx.prop('idleTimer') + delta; ctx.prop('idleTimer', t2); if (t2 > 4000) { ctx.prop('state', 'idle'); ctx.prop('idleTimer', 0); } }",
"OnHit": "var al = ctx.prop('alertLevel') + 1; ctx.prop('alertLevel', al); ctx.prop('state', 'idle'); ctx.prop('idleTimer', 0); ctx.log('守卫受到攻击! 警戒等级: ' + al); if (al >= 5) { ctx.effects.apply({ id: 'guard_rage', type: 'buff', attribute: 'damage', magnitude: 10, durationMs: 10000 }); ctx.log('守卫进入狂暴状态!'); }",
"OnDeath": "ctx.log('守卫阵亡'); ctx.events.emit('guard:down', { x: ctx.entity.getPosition().x, y: ctx.entity.getPosition().y });"
}
},
"pack_wolf": {
"properties": {
"homeX": 0,
"homeY": 0,
"packSize": 2,
"aggroRange": 120,
"fleeHealthPct": 0.2,
"huntTarget": null
},
"handlers": {
"OnLoad": "var pos = ctx.entity.getPosition(); ctx.prop('homeX', pos.x); ctx.prop('homeY', pos.y); ctx.log('狼已生成,巢穴: ' + pos.x + ',' + pos.y);",
"OnUpdate": "var hp = ctx.entity.getHealth(); var maxHp = 100; if (hp / maxHp < ctx.prop('fleeHealthPct')) { var hx = ctx.prop('homeX'); var hy = ctx.prop('homeY'); var pos = ctx.entity.getPosition(); var dx = pos.x - hx; var dy = pos.y - hy; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 10) { var nx = dx / dist; var ny = dy / dist; ctx.entity.setPosition(pos.x + nx * 2, pos.y + ny * 2); } }",
"OnHit": "var hp = ctx.entity.getHealth(); var maxHp = 100; ctx.log('狼被攻击! 生命: ' + hp + '/' + maxHp); if (hp / maxHp < ctx.prop('fleeHealthPct')) { ctx.log('狼因伤势过重逃跑'); } else { ctx.events.emit('wolf:aggro', { x: ctx.entity.getPosition().x, y: ctx.entity.getPosition().y }); }",
"OnDeath": "ctx.log('狼被击杀'); ctx.events.emit('wolf:killed', { x: ctx.entity.getPosition().x, y: ctx.entity.getPosition().y });"
}
},
"draugr_guard": {
"properties": {
"dormant": true,
"wakeRange": 80,
"homeX": 0,
"homeY": 0,
"deathCount": 0
},
"handlers": {
"OnLoad": "var pos = ctx.entity.getPosition(); ctx.prop('homeX', pos.x); ctx.prop('homeY', pos.y); ctx.log('亡灵守卫沉睡中...');",
"OnUpdate": "if (ctx.prop('dormant')) { var pos = ctx.entity.getPosition(); var nearby = ctx.entities.getNearby(ctx.prop('wakeRange')); for (var i = 0; i < nearby.length; i++) { if (nearby[i].type === 'player') { ctx.prop('dormant', false); ctx.log('亡灵守卫苏醒!'); ctx.effects.apply({ id: 'draugr_awaken', type: 'buff', attribute: 'damage', magnitude: 5, durationMs: 30000 }); break; } } }",
"OnHit": "if (ctx.prop('dormant')) { ctx.prop('dormant', false); ctx.log('亡灵守卫被惊醒!'); }",
"OnDeath": "var dc = ctx.prop('deathCount') + 1; ctx.prop('deathCount', dc); ctx.log('亡灵倒下 (第 ' + dc + ' 次)'); if (dc < 3) { ctx.prop('dormant', true); ctx.entity.setHealth(ctx.entity.getHealth() + 50); ctx.log('亡灵再次站起!'); } else { ctx.log('亡灵最终被消灭'); }"
}
},
"frost_spider": {
"properties": {
"homeX": 0,
"homeY": 0,
"webCooldown": 0,
"poisonStacks": 0
},
"handlers": {
"OnLoad": "var pos = ctx.entity.getPosition(); ctx.prop('homeX', pos.x); ctx.prop('homeY', pos.y); ctx.log('冰霜蜘蛛在巢穴待命');",
"OnHit": "var stacks = ctx.prop('poisonStacks') + 1; ctx.prop('poisonStacks', stacks); if (stacks >= 3) { ctx.log('蜘蛛毒液叠满3层! 施加冰冻效果'); ctx.effects.apply({ id: 'frost_venom', type: 'debuff', attribute: 'speed', magnitude: -0.3, durationMs: 5000, source: 'frost_spider' }); ctx.effects.apply({ id: 'frost_dot', type: 'debuff', attribute: 'health', magnitude: -3, durationMs: 5000, source: 'frost_spider' }); ctx.prop('poisonStacks', 0); } else { ctx.log('蜘蛛毒液层数: ' + stacks); }",
"OnUpdate": "var cd = ctx.prop('webCooldown'); if (cd > 0) { ctx.prop('webCooldown', cd - delta); }",
"OnDeath": "ctx.log('冰霜蜘蛛被击杀'); ctx.prop('poisonStacks', 0);"
}
},
"town_elder": {
"properties": {
"greeted": false,
"hintGiven": false
},
"handlers": {
"OnLoad": "ctx.log('镇长就位');",
"OnZoneEnter": "if (!ctx.prop('greeted')) { ctx.prop('greeted', true); ctx.log('镇长: 欢迎来到这片土地。'); }",
"OnActivate": "if (!ctx.prop('hintGiven')) { ctx.prop('hintGiven', true); ctx.log('镇长: 北方的古坟里藏着宝物,但要小心亡灵。'); ctx.events.emit('elder:hint', { hint: '北方古坟有宝藏' }); } else { ctx.log('镇长: 祝你旅途平安。'); }",
"OnDeath": "ctx.log('镇长遇害! 村庄失去领导者'); ctx.events.emit('elder:killed', {});"
}
}
}
}
+16
View File
@@ -0,0 +1,16 @@
{
"manifest": {
"id": "example-patrol",
"name": "敌人巡逻系统",
"version": "1.0.0",
"author": "OES-WEB",
"description": "让敌人在闲置时巡逻,增加游戏真实感",
"priority": 200,
"dependencies": [],
"scripts": ["patrol.js"]
},
"data": {},
"scripts": {
"patrol.js": "log('Patrol mod loaded!');\n\nconst patrolData = new Map();\nconst PATROL_SPEED = 40;\nconst PATROL_RANGE = 100;\nconst IDLE_TIME = 2000;\n\ngame.on('entity:created', (data) => {\n const entity = data.entity;\n if (entity.type === 'enemy') {\n const pos = entity.position;\n if (pos) {\n patrolData.set(entity.id, {\n originX: pos.x,\n originY: pos.y,\n targetX: pos.x,\n targetY: pos.y,\n state: 'idle',\n idleTimer: 0,\n waitTime: utils.random(1000, 3000)\n });\n }\n }\n});\n\ngame.on('entity:destroyed', (data) => {\n patrolData.delete(data.entity.id);\n});\n\ngame.on('game:update', (data) => {\n const delta = data.delta;\n \n for (const [entityId, patrol] of patrolData) {\n const entity = game.getEntity(entityId);\n if (!entity || !entity.position) continue;\n \n const ai = entity.getComponent('ai');\n if (ai && ai.state === 'chase') continue;\n \n if (patrol.state === 'idle') {\n patrol.idleTimer += delta;\n if (patrol.idleTimer >= patrol.waitTime) {\n patrol.state = 'patrol';\n patrol.waitTime = utils.random(1500, 4000);\n const angle = utils.random(0, Math.PI * 2);\n const dist = utils.random(30, PATROL_RANGE);\n patrol.targetX = patrol.originX + Math.cos(angle) * dist;\n patrol.targetY = patrol.originY + Math.sin(angle) * dist;\n }\n } else if (patrol.state === 'patrol') {\n const dx = patrol.targetX - entity.position.x;\n const dy = patrol.targetY - entity.position.y;\n const dist = Math.sqrt(dx * dx + dy * dy);\n \n if (dist < 5) {\n patrol.state = 'idle';\n patrol.idleTimer = 0;\n } else {\n const nx = dx / dist;\n const ny = dy / dist;\n entity.position = {\n x: entity.position.x + nx * PATROL_SPEED * (delta / 1000),\n y: entity.position.y + ny * PATROL_SPEED * (delta / 1000)\n };\n entity.faceToward(patrol.targetX, patrol.targetY);\n }\n }\n }\n});\n\nlog('Patrol behavior registered for all enemies');"
}
}
+106
View File
@@ -0,0 +1,106 @@
{
"manifest": {
"id": "example-quest",
"name": "示例任务包",
"version": "1.0.0",
"author": "OES-WEB",
"description": "添加一个新任务线到游戏中",
"priority": 200,
"dependencies": []
},
"data": {
"quests": {
"lost_sword": {
"id": "lost_sword",
"name": "失落的圣剑",
"type": "side",
"description": "一位铁匠的祖传圣剑在附近的洞穴中丢失了",
"objectives": [
{ "id": "talk_to_blacksmith", "description": "与铁匠对话", "type": "talk", "target": "blacksmith_01" },
{ "id": "find_cave", "description": "找到洞穴", "type": "explore", "target": "cave_01" },
{ "id": "kill_bandits", "description": "消灭洞穴中的强盗", "type": "kill", "target": "bandit", "count": 5 },
{ "id": "find_sword", "description": "找到失落的圣剑", "type": "collect", "target": "legendary_sword", "count": 1 },
{ "id": "return_sword", "description": "将圣剑归还给铁匠", "type": "talk", "target": "blacksmith_01" }
],
"rewards": {
"gold": 500,
"items": ["legendary_sword"],
"xp": 200,
"faction": "companions",
"factionRep": 10
},
"prerequisites": [],
"levelRequired": 5
},
"mysterious_artifact": {
"id": "mysterious_artifact",
"name": "神秘文物",
"type": "daedric",
"description": "一件古老的文物在废弃的神殿中被发现",
"objectives": [
{ "id": "investigate_rumors", "description": "调查传言", "type": "talk", "target": "innkeeper_01" },
{ "id": "find_temple", "description": "找到废弃神殿", "type": "explore", "target": "temple_01" },
{ "id": "solve_puzzle", "description": "解开神殿谜题", "type": "interact", "target": "puzzle_01" },
{ "id": "defeat_guardian", "description": "击败守护者", "type": "kill", "target": "temple_guardian", "count": 1 },
{ "id": "take_artifact", "description": "取走文物", "type": "collect", "target": "mysterious_artifact", "count": 1 },
{ "id": "choose_fate", "description": "决定文物的命运", "type": "choice", "options": ["keep", "destroy", "give_to_mage"] }
],
"rewards": {
"gold": 1000,
"items": ["mysterious_artifact"],
"xp": 500
},
"prerequisites": ["lost_sword"],
"levelRequired": 15
}
},
"items": {
"legendary_sword": {
"id": "legendary_sword",
"name": "铁匠的祖传圣剑",
"type": "weapon",
"subtype": "one_handed_sword",
"material": "steel",
"tier": 2,
"damage": 15,
"speed": 1.0,
"weight": 10,
"value": 200,
"enchantmentSlots": 1,
"enchantment": {
"type": "smite",
"magnitude": 5,
"duration": 0
},
"keywords": ["metal", "slashing", "unique"],
"description": "铁匠家族世代相传的宝剑",
"questItem": true
},
"mysterious_artifact": {
"id": "mysterious_artifact",
"name": "神秘文物",
"type": "misc",
"subtype": "artifact",
"weight": 5,
"value": 0,
"keywords": ["unique", "quest", "daedric"],
"description": "一件来自远古的神秘物品,散发着不祥的气息",
"questItem": true
}
},
"npcs": {
"blacksmith_01": {
"id": "blacksmith_01",
"name": "铁匠哈蒙",
"race": "nord",
"level": 10,
"faction": "blacksmiths",
"dialogue": {
"greeting": "欢迎来到我的铁匠铺。你需要什么?",
"quest_start": "你来得正好!我的祖传圣剑在附近的洞穴被强盗抢走了。如果你能帮我找回来,我一定会重重报答你!",
"quest_complete": "太感谢了!这把剑对我们家族意义重大。这是你的报酬,还有,请随时回来打造装备。"
}
}
}
}
}
+16
View File
@@ -0,0 +1,16 @@
{
"manifest": {
"id": "example-spells",
"name": "自定义法术包",
"version": "1.0.0",
"author": "OES-WEB",
"description": "添加自定义法术,展示脚本化法术系统",
"priority": 300,
"dependencies": [],
"scripts": ["spells.js"]
},
"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');"
}
}
+115
View File
@@ -0,0 +1,115 @@
{
"manifest": {
"id": "example-weapons",
"name": "示例武器包",
"version": "1.0.0",
"author": "OES-WEB",
"description": "添加 5 把新武器到游戏中",
"priority": 100,
"dependencies": []
},
"data": {
"items": {
"flame_sword": {
"id": "flame_sword",
"name": "烈焰之剑",
"type": "weapon",
"subtype": "one_handed_sword",
"material": "steel",
"tier": 2,
"damage": 12,
"speed": 1.0,
"weight": 12,
"value": 150,
"enchantmentSlots": 1,
"enchantment": {
"type": "fire_damage",
"magnitude": 10,
"duration": 0
},
"keywords": ["metal", "slashing", "fire"],
"description": "一把燃烧着永恒火焰的魔法剑"
},
"frost_staff": {
"id": "frost_staff",
"name": "冰霜法杖",
"type": "weapon",
"subtype": "staff",
"material": "crystal",
"tier": 3,
"damage": 8,
"speed": 0.8,
"weight": 8,
"value": 300,
"enchantmentSlots": 1,
"enchantment": {
"type": "frost_damage",
"magnitude": 15,
"duration": 0
},
"keywords": ["magic", "frost", "staff"],
"description": "散发寒气的水晶法杖"
},
"shadow_dagger": {
"id": "shadow_dagger",
"name": "暗影匕首",
"type": "weapon",
"subtype": "dagger",
"material": "ebony",
"tier": 5,
"damage": 15,
"speed": 1.5,
"weight": 3,
"value": 500,
"enchantmentSlots": 1,
"enchantment": {
"type": "silent_damage",
"magnitude": 20,
"duration": 0
},
"keywords": ["metal", "piercing", "shadow"],
"description": "来自暗影界的匕首,攻击无声"
},
"thunder_hammer": {
"id": "thunder_hammer",
"name": "雷霆战锤",
"type": "weapon",
"subtype": "warhammer",
"material": "daedric",
"tier": 6,
"damage": 30,
"speed": 0.6,
"weight": 25,
"value": 1000,
"enchantmentSlots": 1,
"enchantment": {
"type": "shock_damage",
"magnitude": 25,
"duration": 0
},
"keywords": ["metal", "blunt", "lightning"],
"description": "蕴含雷电之力的魔族战锤"
},
"dragon_bow": {
"id": "dragon_bow",
"name": "龙骨弓",
"type": "weapon",
"subtype": "bow",
"material": "dragon",
"tier": 7,
"damage": 22,
"speed": 0.7,
"weight": 14,
"value": 1500,
"enchantmentSlots": 1,
"enchantment": {
"type": "absorb_health",
"magnitude": 5,
"duration": 0
},
"keywords": ["ranged", "dragon", "piercing"],
"description": "用龙骨打造的强大弓"
}
}
}
}
@@ -0,0 +1,115 @@
{
"manifest": {
"id": "example-weapons",
"name": "示例武器包",
"version": "1.0.0",
"author": "OES-WEB",
"description": "添加 5 把新武器到游戏中",
"priority": 100,
"dependencies": []
},
"data": {
"items": {
"flame_sword": {
"id": "flame_sword",
"name": "烈焰之剑",
"type": "weapon",
"subtype": "one_handed_sword",
"material": "steel",
"tier": 2,
"damage": 12,
"speed": 1.0,
"weight": 12,
"value": 150,
"enchantmentSlots": 1,
"enchantment": {
"type": "fire_damage",
"magnitude": 10,
"duration": 0
},
"keywords": ["metal", "slashing", "fire"],
"description": "一把燃烧着永恒火焰的魔法剑"
},
"frost_staff": {
"id": "frost_staff",
"name": "冰霜法杖",
"type": "weapon",
"subtype": "staff",
"material": "crystal",
"tier": 3,
"damage": 8,
"speed": 0.8,
"weight": 8,
"value": 300,
"enchantmentSlots": 1,
"enchantment": {
"type": "frost_damage",
"magnitude": 15,
"duration": 0
},
"keywords": ["magic", "frost", "staff"],
"description": "散发寒气的水晶法杖"
},
"shadow_dagger": {
"id": "shadow_dagger",
"name": "暗影匕首",
"type": "weapon",
"subtype": "dagger",
"material": "ebony",
"tier": 5,
"damage": 15,
"speed": 1.5,
"weight": 3,
"value": 500,
"enchantmentSlots": 1,
"enchantment": {
"type": "silent_damage",
"magnitude": 20,
"duration": 0
},
"keywords": ["metal", "piercing", "shadow"],
"description": "来自暗影界的匕首,攻击无声"
},
"thunder_hammer": {
"id": "thunder_hammer",
"name": "雷霆战锤",
"type": "weapon",
"subtype": "warhammer",
"material": "daedric",
"tier": 6,
"damage": 30,
"speed": 0.6,
"weight": 25,
"value": 1000,
"enchantmentSlots": 1,
"enchantment": {
"type": "shock_damage",
"magnitude": 25,
"duration": 0
},
"keywords": ["metal", "blunt", "lightning"],
"description": "蕴含雷电之力的魔族战锤"
},
"dragon_bow": {
"id": "dragon_bow",
"name": "龙骨弓",
"type": "weapon",
"subtype": "bow",
"material": "dragon",
"tier": 7,
"damage": 22,
"speed": 0.7,
"weight": 14,
"value": 1500,
"enchantmentSlots": 1,
"enchantment": {
"type": "absorb_health",
"magnitude": 5,
"duration": 0
},
"keywords": ["ranged", "dragon", "piercing"],
"description": "用龙骨打造的强大弓"
}
}
}
}