refactor: 重构护盾机制为数值减免型

1. 调整护盾逻辑:从单次抵挡改为按伤害量减免
2. 更新配置、注释与UI提示文本,统一术语表述
3. 修复prefab布局适配新的护盾显示样式
This commit is contained in:
pan
2026-08-13 16:53:15 +08:00
parent 695a9e2b66
commit 76082d8e1f
7 changed files with 30 additions and 31 deletions

View File

@@ -1277,7 +1277,7 @@
"__id__": 65
}
],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 73
@@ -1347,7 +1347,7 @@
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -25,
"x": -20,
"y": 0,
"z": 0
},
@@ -1388,8 +1388,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 50,
"height": 10
"width": 40,
"height": 11
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -1691,8 +1691,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 50,
"height": 10
"width": 40,
"height": 11
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -1813,7 +1813,7 @@
"__id__": 99
}
],
"_active": true,
"_active": false,
"_components": [
{
"__id__": 105

View File

@@ -44,6 +44,7 @@ export enum FightSet {
SKILL_CAST_DELAY = 0.15,
CSKILL_START_X = -340,
CSKILL_START_Y = 30,
/** 护盾数值上限数值减免型1 点护盾吸收 1 点伤害) */
SHIELD_MAX = 5,
WAVE_HEAL_RATE = 0.4, // 回合结束时所有英雄恢复最大生命值的比例(与 DDA 放水兜底分层:回血保节奏,放水防崩盘)
PUNCTURE_DOWN = 50,

View File

@@ -1185,7 +1185,8 @@ function calcSkillEffectValue(skill: SkillConfig, overrides: SkillOverrides | un
case SkillKind.Heal:
return ((config.ap || 0) / 100) * apEff * weights.W_heal;
case SkillKind.Shield:
return (config.ap || 0) * weights.expectedEnemyDmg * weights.W_shield;
// 护盾为数值减免型1 点护盾 ≈ 1 点预期伤害减免
return (config.ap || 0) * weights.W_shield;
case SkillKind.Support:
return calcSupportEffectValue(config, apEff, cd, seconds);
default:

View File

@@ -146,15 +146,15 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
}
}
mLogger.log(this.debugMode, 'HeroAtkSystem', " after crit", damage)
// 护盾吸收
// 护盾数值减免1 点护盾吸收 1 点伤害,扣完为止,溢出部分继续扣血)
const shieldResult = this.absorbShield(TAttrsComp, damage);
damage = shieldResult.remainingDamage;
if (shieldResult.absorbedDamage > 0) {
// 【评分系统 - 防御分】统计护盾成功抵挡伤害的次数
smc.vmdata.scores.shield_block_count += 1;
// 【评分系统 - 防御分】统计护盾累计吸收的伤害量
smc.vmdata.scores.shield_block_count += Math.floor(shieldResult.absorbedDamage);
}
mLogger.log(this.debugMode, 'HeroAtkSystem', " after shield", damage)
// 显示护盾格挡飘字
// 显示护盾减免飘字
if (shieldResult.absorbedDamage > 0 && targetView) {
targetView.shield_tip(shieldResult.absorbedDamage);
}
@@ -413,29 +413,26 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
/**
* 护盾吸收伤害
*
* 护盾吸收逻辑
* 1. 护盾值大于 0 时,抵挡本次伤害(免伤)
* 2. 每次抵挡消耗 1 点护盾值
* 3. 护盾归零时,重置护盾最大值属性
*
* 护盾数值减免伤害
*
* 护盾为数值减免型
* 1. 1 点护盾吸收 1 点伤害
* 2. 护盾扣减实际吸收量,溢出部分继续结算到血量
*
* @param TAttrsComp 被攻击者的属性组件(包含当前护盾值)
* @param damage 原始伤害值
* @returns {remainingDamage, absorbedDamage} 剩余伤害值和被格挡的伤害值
* @returns {remainingDamage, absorbedDamage} 剩余伤害值和被护盾减免的伤害值
*/
private absorbShield(TAttrsComp: HeroAttrsComp, damage: number): { remainingDamage: number, absorbedDamage: number } {
if (TAttrsComp.shield <= 0) {
mLogger.log(this.debugMode, 'HeroAtkSystem', " 护盾值小于等于0无法吸收伤害");
return { remainingDamage: damage, absorbedDamage: 0 };
}
TAttrsComp.shield = Math.max(0, TAttrsComp.shield - 1);
if (TAttrsComp.shield <= 0) {
TAttrsComp.shield = 0;
}
const absorbed = Math.min(TAttrsComp.shield, damage);
TAttrsComp.shield = Math.max(0, TAttrsComp.shield - absorbed);
TAttrsComp.dirty_shield = true;
mLogger.log(this.debugMode, 'HeroAtkSystem', ` 护盾抵挡1次伤害,剩余次数 ${TAttrsComp.shield}`);
return { remainingDamage: 0, absorbedDamage: damage };
mLogger.log(this.debugMode, 'HeroAtkSystem', ` 护盾减免 ${absorbed.toFixed(1)}伤害,剩余护盾 ${TAttrsComp.shield.toFixed(1)}`);
return { remainingDamage: damage - absorbed, absorbedDamage: absorbed };
}
/**

View File

@@ -153,11 +153,11 @@ export class HeroAttrsComp extends ecs.Comp {
const addValue = Math.max(0, Math.floor(value));
if (addValue <= 0) return;
this.shield += addValue;
this.shield = Math.min(this.shield, FightSet.SHIELD_MAX); // 限制护盾最大层数
this.shield = Math.min(this.shield, FightSet.SHIELD_MAX); // 限制护盾值上限(数值减免型)
if (this.shield < 0) this.shield = 0;
this.dirty_shield = true; // 标记护盾需要更新
if (this.debugMode) {
mLogger.log(this.debugMode, 'HeroAttrs', ` 护盾次数变更: ${this.hero_name}, 变化=${addValue}, ${Math.floor(oldShield)} -> ${Math.floor(this.shield)}`);
mLogger.log(this.debugMode, 'HeroAttrs', ` 护盾变更: ${this.hero_name}, 变化=${addValue}, ${Math.floor(oldShield)} -> ${Math.floor(this.shield)}`);
}
}
add_hp_max(value: number) {

View File

@@ -349,7 +349,7 @@ export class HeroViewComp extends CCComp {
Tooltip.load(pos, type, value, s_uuid, this.node.parent, 1, this.model?.fac ?? FacSet.MON);
}
/** 护盾格挡提示 */
/** 护盾减免提示 */
shield_tip(absorbed: number) {
this.hp_tip(TooltipTypes.shield, NumberFormatter.formatNumber(Math.max(0, Math.floor(absorbed))));
}

View File

@@ -146,10 +146,10 @@ export class TooltipCom extends CCComp {
this.node.setPosition(v3(this.node.position.x, currentY - 60));
this.node.setSiblingIndex(topSiblingIndex);
break;
case TooltipTypes.shield: // 护盾格挡
case TooltipTypes.shield: // 护盾减免
this.node.setPosition(v3(this.node.position.x + offsetX, currentY));
this.node.setSiblingIndex(topSiblingIndex);
this.setupLabel("add_life", "hp", "格挡");
this.setupLabel("add_life", "hp", "减免");
isHeal = true;
break;
}