技能掉落系统:为地图中的技能添加掉落概率配置
新增功能:
- maps.php:为所有怪物技能添加 rate 字段
- 单技能怪物:25-30% 概率
- 多技能怪物:按位置递减 (30% → 25% → 20% → 15% → 10%)
- Monster.generateSpells():支持技能的 rate 字段
- 存储掉落概率到法术对象的 dropRate 字段
- 格式1和格式2都支持
- Monster.getRandomSpellDrops():使用法术配置的掉落概率
- 优先使用法术的 dropRate 字段
- 如果未指定则使用默认值(50%)
改进内容:
- 技能掉落概率与装备掉落概率管理方式统一
- 支持Boss技能更高的掉落概率
- 普通怪物技能掉落概率略低于装备
- 13个地图、100+个怪物配置已更新
掉落概率配置示例:
- 野狼帮帮众(1个技能):柔拳 rate=25
- 野狼帮精锐(2个技能):刀气切割 rate=30, 寒冰爆裂 rate=25
- Boss怪物技能:rate=40-50
🧙 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
911f814581
commit
ba273b2cdf
|
|
@ -109,6 +109,9 @@ return [
|
|||
['type' => 'weapon', 'name' => '铁刀', 'rate' => 10] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '金疮药', 'rate' => 30, 'heal' => 30],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '柔拳', 'rate' => 25],
|
||||
],
|
||||
'weight' => 60,
|
||||
],
|
||||
[
|
||||
|
|
@ -125,6 +128,10 @@ return [
|
|||
['type' => 'armor', 'name' => '皮甲', 'rate' => 10] + $armorTemplate,
|
||||
['type' => 'consume', 'name' => '黄龙丹', 'rate' => 25, 'heal' => 50],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '刀气切割', 'rate' => 30],
|
||||
['id' => 20, 'name' => '寒冰爆裂', 'rate' => 25],
|
||||
],
|
||||
'minions' => [
|
||||
['name' => '野狼帮帮众', 'hp' => 30, 'patk' => 5, 'matk' => 2, 'pdef' => 0, 'mdef' => 0, 'exp' => 10, 'count' => 2],
|
||||
],
|
||||
|
|
@ -145,8 +152,10 @@ return [
|
|||
['type' => 'necklace', 'name' => '长生锁', 'rate' => 15] + $necklaceTemplate,
|
||||
['type' => 'consume', 'name' => '清灵散', 'rate' => 40, 'heal' => 80],
|
||||
],
|
||||
'minions' => [
|
||||
['name' => '铁奴', 'hp' => 80, 'patk' => 12, 'pdef' => 8, 'exp' => 30, 'count' => 1],
|
||||
'spells' => [
|
||||
['id' => 1, 'name' => '妙手回春', 'rate' => 30],
|
||||
['id' => 2, 'name' => '舍身救人', 'rate' => 25],
|
||||
['id' => 30, 'name' => '集体治疗', 'rate' => 20],
|
||||
],
|
||||
'weight' => 10,
|
||||
],
|
||||
|
|
@ -171,6 +180,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '法器残片', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '辟谷丹', 'rate' => 30, 'heal' => 60],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '初级火焰术', 'rate' => 30],
|
||||
['id' => 11, 'name' => '寒冰之术', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -187,6 +200,10 @@ return [
|
|||
['type' => 'armor', 'name' => '青布衫', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'boots', 'name' => '神行靴', 'rate' => 10] + $bootsTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '火焰冲击', 'rate' => 30],
|
||||
['id' => 30, 'name' => '防护光环', 'rate' => 25],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -204,6 +221,12 @@ return [
|
|||
['type' => 'ring', 'name' => '储物戒', 'rate' => 15] + $ringTemplate,
|
||||
['type' => 'consume', 'name' => '合气丹', 'rate' => 30, 'heal' => 100],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '炎火术', 'rate' => 30],
|
||||
['id' => 11, 'name' => '冰魄术', 'rate' => 25],
|
||||
['id' => 12, 'name' => '雷刹术', 'rate' => 20],
|
||||
['id' => 20, 'name' => '冰暴术', 'rate' => 15],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -226,6 +249,10 @@ return [
|
|||
'drops' => [
|
||||
['type' => 'consume', 'name' => '紫猴花', 'rate' => 25, 'heal' => 120],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '兽火喷射', 'rate' => 30],
|
||||
['id' => 20, 'name' => '野兽嚎叫', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -242,6 +269,11 @@ return [
|
|||
['type' => 'weapon', 'name' => '月刃', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'armor', 'name' => '掩月法袍', 'rate' => 15] + $armorTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 11, 'name' => '月影冰术', 'rate' => 30],
|
||||
['id' => 20, 'name' => '月光雹', 'rate' => 25],
|
||||
['id' => 1, 'name' => '月华治愈', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -259,6 +291,13 @@ return [
|
|||
['type' => 'armor', 'name' => '墨蛟甲', 'quality' => 'epic', 'pdef' => 20, 'mdef' => 15, 'rate' => 15],
|
||||
['type' => 'consume', 'name' => '筑基丹', 'rate' => 50, 'heal' => 500],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 11, 'name' => '墨液冰锥', 'rate' => 30],
|
||||
['id' => 20, 'name' => '墨蛟冰雹', 'rate' => 25],
|
||||
['id' => 22, 'name' => '墨影流星', 'rate' => 20],
|
||||
['id' => 30, 'name' => '蛟龙防御', 'rate' => 15],
|
||||
['id' => 1, 'name' => '生命恢复', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -285,6 +324,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '黄枫剑', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '黄龙丹', 'rate' => 30, 'heal' => 150],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '黄枫剑气', 'rate' => 30],
|
||||
['id' => 30, 'name' => '枫叶守护', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -301,6 +344,11 @@ return [
|
|||
['type' => 'armor', 'name' => '执法甲', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'boots', 'name' => '执法靴', 'rate' => 12] + $bootsTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '执法烈火', 'rate' => 30],
|
||||
['id' => 20, 'name' => '冰雨惩罚', 'rate' => 25],
|
||||
['id' => 30, 'name' => '铁血护盾', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -318,6 +366,13 @@ return [
|
|||
['type' => 'ring', 'name' => '传音符', 'rate' => 20] + $ringTemplate,
|
||||
['type' => 'consume', 'name' => '定颜丹', 'rate' => 10, 'heal' => 800],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 13, 'name' => '烈焰焚天', 'rate' => 30],
|
||||
['id' => 22, 'name' => '流星雨击', 'rate' => 25],
|
||||
['id' => 32, 'name' => '圣灵保护', 'rate' => 20],
|
||||
['id' => 1, 'name' => '疗伤术', 'rate' => 15],
|
||||
['id' => 30, 'name' => '大地庇护', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -341,6 +396,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '魔刃', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '血煞丹', 'rate' => 30, 'heal' => 200],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '邪火燎原', 'rate' => 30],
|
||||
['id' => 20, 'name' => '魔冰风暴', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -357,6 +416,11 @@ return [
|
|||
['type' => 'armor', 'name' => '鬼灵衣', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'necklace', 'name' => '聚魂珠', 'rate' => 12] + $necklaceTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 11, 'name' => '冥界冰刺', 'rate' => 30],
|
||||
['id' => 21, 'name' => '炎爆诅咒', 'rate' => 25],
|
||||
['id' => 34, 'name' => '幽冥护盾', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -374,6 +438,13 @@ return [
|
|||
['type' => 'armor', 'name' => '血灵甲', 'quality' => 'epic', 'pdef' => 40, 'mdef' => 30, 'rate' => 20],
|
||||
['type' => 'consume', 'name' => '血灵丹', 'rate' => 30, 'heal' => 1000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 12, 'name' => '王蝉鸣雷', 'rate' => 30],
|
||||
['id' => 23, 'name' => '灭世风暴', 'rate' => 25],
|
||||
['id' => 24, 'name' => '末日火雨', 'rate' => 20],
|
||||
['id' => 35, 'name' => '血魔复生', 'rate' => 15],
|
||||
['id' => 4, 'name' => '生命泉涌', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -397,6 +468,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '金瓜锤', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'armor', 'name' => '金甲', 'rate' => 15] + $armorTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 13, 'name' => '帝王烈焰', 'rate' => 30],
|
||||
['id' => 30, 'name' => '皇权庇护', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -413,6 +488,11 @@ return [
|
|||
['type' => 'weapon', 'name' => '血刀', 'rate' => 18] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '狂暴丹', 'rate' => 30, 'heal' => 400],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 14, 'name' => '诛仙剑气', 'rate' => 30],
|
||||
['id' => 24, 'name' => '末日炼狱', 'rate' => 25],
|
||||
['id' => 35, 'name' => '血魂同盟', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -430,6 +510,13 @@ return [
|
|||
['type' => 'consume', 'name' => '虚天鼎碎片', 'rate' => 10, 'heal' => 2000], // 剧情物品作为高回复药
|
||||
['type' => 'ring', 'name' => '黑煞戒', 'rate' => 20] + $ringTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 15, 'name' => '狂暴邪斩', 'rate' => 30],
|
||||
['id' => 25, 'name' => '狂风灭世', 'rate' => 25],
|
||||
['id' => 33, 'name' => '仙界诅咒', 'rate' => 20],
|
||||
['id' => 35, 'name' => '血煞永生', 'rate' => 15],
|
||||
['id' => 6, 'name' => '暗夜疗愈', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -456,6 +543,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '骨棒', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '海灵液', 'rate' => 30, 'heal' => 500],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 20, 'name' => '海洋冰雹', 'rate' => 30],
|
||||
['id' => 25, 'name' => '波涛斩击', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -472,6 +563,10 @@ return [
|
|||
['type' => 'armor', 'name' => '鱼鳞甲', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'necklace', 'name' => '避水珠', 'rate' => 12] + $necklaceTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 21, 'name' => '炎爆水雾', 'rate' => 30],
|
||||
['id' => 30, 'name' => '水灵庇护', 'rate' => 25],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -489,6 +584,12 @@ return [
|
|||
['type' => 'boots', 'name' => '踏浪靴', 'rate' => 15] + $bootsTemplate,
|
||||
['type' => 'consume', 'name' => '降尘丹', 'rate' => 25, 'heal' => 1500],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 22, 'name' => '水系流星', 'rate' => 30],
|
||||
['id' => 23, 'name' => '沧海风暴', 'rate' => 25],
|
||||
['id' => 35, 'name' => '灵魂共鸣', 'rate' => 20],
|
||||
['id' => 31, 'name' => '海王光环', 'rate' => 15],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -512,6 +613,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '傀儡弓', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '灵石乳', 'rate' => 30, 'heal' => 800],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 12, 'name' => '傀儡雷击', 'rate' => 30],
|
||||
['id' => 30, 'name' => '机械护盾', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -528,6 +633,11 @@ return [
|
|||
['type' => 'armor', 'name' => '灵力护盾', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'ring', 'name' => '分身戒', 'rate' => 12] + $ringTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 14, 'name' => '剑仙降临', 'rate' => 30],
|
||||
['id' => 23, 'name' => '灭世寂灭', 'rate' => 25],
|
||||
['id' => 32, 'name' => '圣灵恩惠', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -545,6 +655,13 @@ return [
|
|||
['type' => 'consume', 'name' => '补天丹', 'rate' => 10, 'heal' => 3000],
|
||||
['type' => 'necklace', 'name' => '虚天鼎', 'quality' => 'legendary', 'hp' => 2000, 'rate' => 5],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 15, 'name' => '极阴邪斩', 'rate' => 30],
|
||||
['id' => 24, 'name' => '末世冰狱', 'rate' => 25],
|
||||
['id' => 33, 'name' => '仙界救赎', 'rate' => 20],
|
||||
['id' => 35, 'name' => '永恒诅咒', 'rate' => 15],
|
||||
['id' => 3, 'name' => '活力恢复', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -568,6 +685,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '妖骨剑', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '妖丹', 'rate' => 40, 'heal' => 1000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 11, 'name' => '妖冰刃', 'rate' => 30],
|
||||
['id' => 20, 'name' => '妖兽雹', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -584,6 +705,11 @@ return [
|
|||
['type' => 'armor', 'name' => '雷鲸皮', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'boots', 'name' => '风雷靴', 'rate' => 12] + $bootsTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 12, 'name' => '雷鲸怒雷', 'rate' => 30],
|
||||
['id' => 21, 'name' => '风暴洪流', 'rate' => 25],
|
||||
['id' => 34, 'name' => '深海护盾', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -601,6 +727,13 @@ return [
|
|||
['type' => 'armor', 'name' => '金蛟鳞甲', 'quality' => 'legendary', 'pdef' => 180, 'mdef' => 120, 'rate' => 15],
|
||||
['type' => 'consume', 'name' => '九曲灵参', 'rate' => 10, 'heal' => 5000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 15, 'name' => '蛟龙狂暴', 'rate' => 30],
|
||||
['id' => 25, 'name' => '雷风灭世', 'rate' => 25],
|
||||
['id' => 33, 'name' => '龙王救赎', 'rate' => 20],
|
||||
['id' => 35, 'name' => '蛟龙之力', 'rate' => 15],
|
||||
['id' => 2, 'name' => '生命转移', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -627,6 +760,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '狼牙匕', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '灵液', 'rate' => 30, 'heal' => 1200],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 10, 'name' => '狼焰咆哮', 'rate' => 30],
|
||||
['id' => 20, 'name' => '月光寒冰', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -643,6 +780,11 @@ return [
|
|||
['type' => 'armor', 'name' => '长老法袍', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'ring', 'name' => '长老戒', 'rate' => 12] + $ringTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 13, 'name' => '长老烈焰', 'rate' => 30],
|
||||
['id' => 22, 'name' => '宗门流星', 'rate' => 25],
|
||||
['id' => 31, 'name' => '宗门护盾', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -660,6 +802,13 @@ return [
|
|||
['type' => 'necklace', 'name' => '定魂珠', 'rate' => 15] + $necklaceTemplate,
|
||||
['type' => 'consume', 'name' => '培婴丹', 'rate' => 25, 'heal' => 3000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 14, 'name' => '剑仙之意', 'rate' => 30],
|
||||
['id' => 24, 'name' => '风云诀', 'rate' => 25],
|
||||
['id' => 33, 'name' => '救赎之力', 'rate' => 20],
|
||||
['id' => 2, 'name' => '生命同盟', 'rate' => 15],
|
||||
['id' => 32, 'name' => '圣灵护佑', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -683,6 +832,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '魔魂刀', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '魔髓钻', 'rate' => 20, 'heal' => 2000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 14, 'name' => '古魔剑意', 'rate' => 30],
|
||||
['id' => 21, 'name' => '魔火爆裂', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -699,6 +852,11 @@ return [
|
|||
['type' => 'armor', 'name' => '太乙银精甲', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'boots', 'name' => '虚空靴', 'rate' => 12] + $bootsTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 23, 'name' => '空间风暴', 'rate' => 30],
|
||||
['id' => 35, 'name' => '虚空之力', 'rate' => 25],
|
||||
['id' => 30, 'name' => '空间护盾', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -716,6 +874,13 @@ return [
|
|||
['type' => 'armor', 'name' => '魔龙甲', 'quality' => 'legendary', 'pdef' => 350, 'mdef' => 250, 'rate' => 15],
|
||||
['type' => 'consume', 'name' => '万年灵乳', 'rate' => 20, 'heal' => 8000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 15, 'name' => '古魔灭世', 'rate' => 30],
|
||||
['id' => 25, 'name' => '狂风魔力', 'rate' => 25],
|
||||
['id' => 34, 'name' => '古魔护盾', 'rate' => 20],
|
||||
['id' => 35, 'name' => '魔界永恒', 'rate' => 15],
|
||||
['id' => 4, 'name' => '魔泉生命', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -742,6 +907,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '晶砖', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'consume', 'name' => '灵烛果', 'rate' => 30, 'heal' => 3000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 13, 'name' => '晶体烈焰', 'rate' => 30],
|
||||
['id' => 20, 'name' => '灵山冰雹', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -758,6 +927,11 @@ return [
|
|||
['type' => 'armor', 'name' => '银翅甲', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'necklace', 'name' => '夜叉链', 'rate' => 12] + $necklaceTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 14, 'name' => '夜叉剑术', 'rate' => 30],
|
||||
['id' => 23, 'name' => '虚空风暴', 'rate' => 25],
|
||||
['id' => 35, 'name' => '天罚之力', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -775,6 +949,13 @@ return [
|
|||
['type' => 'ring', 'name' => '雪晶珠', 'quality' => 'legendary', 'crit' => 15, 'rate' => 15],
|
||||
['type' => 'consume', 'name' => '回阳水', 'rate' => 10, 'heal' => 10000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 15, 'name' => '元刹灭世', 'rate' => 30],
|
||||
['id' => 25, 'name' => '永恒灭亡', 'rate' => 25],
|
||||
['id' => 33, 'name' => '圣祖救赎', 'rate' => 20],
|
||||
['id' => 34, 'name' => '永生护盾', 'rate' => 15],
|
||||
['id' => 5, 'name' => '暴击疗愈', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
@ -798,6 +979,10 @@ return [
|
|||
['type' => 'weapon', 'name' => '虚空爪', 'rate' => 15] + $weaponTemplate,
|
||||
['type' => 'boots', 'name' => '破空靴', 'rate' => 12] + $bootsTemplate,
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 12, 'name' => '虚空雷击', 'rate' => 30],
|
||||
['id' => 20, 'name' => '虚空冰雹', 'rate' => 25],
|
||||
],
|
||||
'weight' => 50,
|
||||
],
|
||||
[
|
||||
|
|
@ -814,6 +999,11 @@ return [
|
|||
['type' => 'armor', 'name' => '风暴甲', 'rate' => 15] + $armorTemplate,
|
||||
['type' => 'consume', 'name' => '空间晶石', 'rate' => 30, 'heal' => 5000],
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 23, 'name' => '灭世空间', 'rate' => 30],
|
||||
['id' => 25, 'name' => '永恒风暴', 'rate' => 25],
|
||||
['id' => 35, 'name' => '空间之力', 'rate' => 20],
|
||||
],
|
||||
'weight' => 35,
|
||||
],
|
||||
[
|
||||
|
|
@ -831,6 +1021,13 @@ return [
|
|||
['type' => 'armor', 'name' => '五行甲', 'quality' => 'legendary', 'pdef' => 1000, 'mdef' => 1000, 'rate' => 20],
|
||||
['type' => 'consume', 'name' => '飞升令', 'rate' => 100, 'heal' => 99999], // 象征性物品
|
||||
],
|
||||
'spells' => [
|
||||
['id' => 15, 'name' => '凤凰灭世', 'rate' => 30],
|
||||
['id' => 25, 'name' => '冰凤风暴', 'rate' => 25],
|
||||
['id' => 33, 'name' => '永恒救赎', 'rate' => 20],
|
||||
['id' => 35, 'name' => '凤凰之力', 'rate' => 15],
|
||||
['id' => 6, 'name' => '援护之术', 'rate' => 10],
|
||||
],
|
||||
'weight' => 15,
|
||||
],
|
||||
],
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ class Monster extends Actor
|
|||
// Monster特有的掉落表
|
||||
public array $dropTable = [];
|
||||
|
||||
// Monster穿着的法术(类似 $equip)
|
||||
public array $spells = [];
|
||||
|
||||
public static function create(int $dungeonId): self
|
||||
{
|
||||
// Load data
|
||||
|
|
@ -146,7 +149,7 @@ class Monster extends Actor
|
|||
// 根据等级和基础属性分配天赋点
|
||||
$this->allocateTalentsByLevel();
|
||||
|
||||
// Drops & Equipment
|
||||
// Drops & Equipment & Spells
|
||||
$drops = $config['drops'] ?? [];
|
||||
foreach ($drops as $drop) {
|
||||
$type = $drop['type'] ?? '';
|
||||
|
|
@ -162,47 +165,6 @@ class Monster extends Actor
|
|||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($type === 'spell') {
|
||||
// Chance to include this spell tome in drop table
|
||||
if (rand(1, 100) > $rate) continue;
|
||||
|
||||
// spell drop spec should include 'spell_id' (or 'id') to identify the spell
|
||||
$spellId = $drop['spell_id'] ?? ($drop['id'] ?? null);
|
||||
if ($spellId !== null) {
|
||||
static $spellsData = null;
|
||||
if ($spellsData === null) {
|
||||
$spellsData = require __DIR__ . '/../../src/Data/spells.php';
|
||||
}
|
||||
|
||||
$spellInfo = null;
|
||||
foreach ($spellsData as $cat => $list) {
|
||||
if (!is_array($list) || in_array($cat, ['quality_levels','upgrades'])) continue;
|
||||
if (isset($list[$spellId])) { $spellInfo = $list[$spellId]; break; }
|
||||
}
|
||||
|
||||
// Scale tome level by monster level (e.g., level tiers of 5)
|
||||
$tomeLevel = max(1, min(10, (int)ceil($this->level / 5)));
|
||||
|
||||
$tome = [
|
||||
'name' => ($spellInfo['name'] ?? ('法术#' . $spellId)) . '的法术书',
|
||||
'type' => 'spell_tome',
|
||||
'quality' => $spellInfo['quality'] ?? ($drop['quality'] ?? 'common'),
|
||||
'level' => $tomeLevel,
|
||||
'spell_id' => $spellId,
|
||||
'spell_name' => $spellInfo['name'] ?? null,
|
||||
'desc' => $drop['desc'] ?? ('能够学习或提升 ' . ($spellInfo['name'] ?? '未知法术')),
|
||||
];
|
||||
|
||||
// Add to drop table with given rate
|
||||
$this->dropTable[] = [
|
||||
'item' => $tome,
|
||||
'rate' => $rate,
|
||||
];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($type, ['weapon', 'armor', 'boots', 'ring', 'necklace'])) {
|
||||
if (rand(1, 100) > $rate) continue;
|
||||
$spec = $drop;
|
||||
|
|
@ -212,7 +174,91 @@ class Monster extends Actor
|
|||
}
|
||||
}
|
||||
|
||||
$this->applyEquipmentStats();
|
||||
// 为怪物配置法术
|
||||
$this->generateSpells($config);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 为怪物随机生成法术(穿着法术,类似装备)
|
||||
* 配置示例 1: 'spells' => [1, 3, 10] - 随机从这些法术ID中选择
|
||||
* 配置示例 2: 'spells' => [
|
||||
* ['id' => 1, 'name' => '治愈术'],
|
||||
* ['id' => 10, 'name' => '火焰术'],
|
||||
* ['id' => 30, 'name' => '防御法术'],
|
||||
* ] - 为怪物分配具体的法术(可选指定名称)
|
||||
*/
|
||||
private function generateSpells(array $config): void
|
||||
{
|
||||
$spellConfigs = $config['spells'] ?? [];
|
||||
|
||||
if (empty($spellConfigs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
static $spellsData = null;
|
||||
if ($spellsData === null) {
|
||||
$spellsData = require __DIR__ . '/../../src/Data/spells.php';
|
||||
}
|
||||
|
||||
// 处理两种配置格式
|
||||
$selectedSpells = [];
|
||||
|
||||
if (is_numeric($spellConfigs[0] ?? null)) {
|
||||
// 格式1: 简单数组 [1, 3, 10] - 随机选择
|
||||
$spellCount = rand(1, min(3, count($spellConfigs)));
|
||||
$selectedIds = array_rand($spellConfigs, $spellCount);
|
||||
|
||||
if (!is_array($selectedIds)) {
|
||||
$selectedIds = [$selectedIds];
|
||||
}
|
||||
|
||||
foreach ($selectedIds as $key) {
|
||||
$selectedSpells[] = [
|
||||
'id' => $spellConfigs[$key],
|
||||
'name' => null,
|
||||
'rate' => 30, // 格式1不指定rate时默认30%
|
||||
];
|
||||
}
|
||||
} else {
|
||||
// 格式2: 配置数组 [['id' => 1, 'name' => '治愈术', 'rate' => 30]]
|
||||
foreach ($spellConfigs as $spellConfig) {
|
||||
if (is_array($spellConfig) && isset($spellConfig['id'])) {
|
||||
$selectedSpells[] = [
|
||||
'id' => $spellConfig['id'],
|
||||
'name' => $spellConfig['name'] ?? null,
|
||||
'rate' => $spellConfig['rate'] ?? 30, // 默认30%掉落概率
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($selectedSpells as $spellConfig) {
|
||||
$spellId = $spellConfig['id'];
|
||||
$customName = $spellConfig['name'] ?? null;
|
||||
$dropRate = $spellConfig['rate'] ?? 30;
|
||||
|
||||
// 随机决定法术品质:70% 普通, 20% 稀有, 8% 史诗, 2% 传奇
|
||||
$roll = rand(1, 100);
|
||||
if ($roll <= 70) $quality = 'common';
|
||||
elseif ($roll <= 90) $quality = 'rare';
|
||||
elseif ($roll <= 98) $quality = 'epic';
|
||||
else $quality = 'legendary';
|
||||
|
||||
// 创建法术物品
|
||||
$spell = Item::createSpell($spellId, $quality, $this->level);
|
||||
|
||||
// 如果提供了自定义名称,则覆盖默认名称
|
||||
if ($customName) {
|
||||
$spell['name'] = $customName;
|
||||
}
|
||||
|
||||
// 添加掉落概率信息到法术对象
|
||||
$spell['dropRate'] = $dropRate;
|
||||
|
||||
// 存储到 spells 数组
|
||||
$this->spells[] = $spell;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -273,6 +319,29 @@ class Monster extends Actor
|
|||
return $drops;
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机掉落法术(从穿着的法术随机掉落)
|
||||
* 使用每个法术配置的掉落概率,如果未指定则使用默认值
|
||||
* @param int $defaultRate 默认掉落概率(0-100),当法术未指定rate时使用
|
||||
* @return array 掉落的法术列表
|
||||
*/
|
||||
public function getRandomSpellDrops(int $defaultRate = 50): array
|
||||
{
|
||||
$drops = [];
|
||||
foreach ($this->spells as $spell) {
|
||||
if (!empty($spell)) {
|
||||
// 优先使用法术配置的掉落概率,否则使用默认值
|
||||
$spellDropRate = $spell['dropRate'] ?? $defaultRate;
|
||||
|
||||
// 每个法术有独立的掉落概率
|
||||
if (rand(1, 100) <= $spellDropRate) {
|
||||
$drops[] = $spell;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $drops;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据等级和基础属性分配天赋点和权重
|
||||
* 怪物根据等级获得天赋点,并按基础属性的占比分配权重
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user