fix(skill): 修复技能升级配置查找和友方技能目标选择逻辑
修复SkillUpList中默认配置键值错误,从6001改为1001 修复技能升级属性计算中的空值保护,避免undefined导致的NaN 重构友方技能目标选择逻辑,添加随机选取和按血量排序功能 调整辅助技能数值从基于最大生命值百分比改为基于攻击力百分比
This commit is contained in:
@@ -110,6 +110,8 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
const s_uuid = castPlan.skillId;
|
||||
const skillLv = castPlan.skillLv;
|
||||
const config = SkillSet[s_uuid];
|
||||
const sUp=SkillUpList[s_uuid]??SkillUpList[1001]
|
||||
const cNum=sUp.num
|
||||
if (!config) return;
|
||||
//播放前摇技能动画
|
||||
heroView.playReady(config.readyAnm);
|
||||
@@ -174,14 +176,16 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
*/
|
||||
private applyFriendlySkillEffects(_s_uuid: number, _skillLv: number, config: SkillConfig, _heroView: HeroViewComp, _cAttrsComp: HeroAttrsComp, targets: HeroViewComp[], _targetPos: Vec3 | null) {
|
||||
const kind = config.kind ?? SkillKind.Support;
|
||||
const sUp=SkillUpList[_skillLv]
|
||||
const sUp = SkillUpList[_s_uuid] ?? SkillUpList[1001];
|
||||
const sAp =config.ap+sUp.ap*_skillLv;
|
||||
const sHit=config.hit_count+sUp.hit_count*_skillLv
|
||||
for (const target of targets) {
|
||||
const sHit=config.hit_count+sUp.hit_count*_skillLv;
|
||||
const selectedTargets = this.pickRandomFriendlyTargets(targets, sHit);
|
||||
const applyTargets = kind === SkillKind.Heal ? this.sortTargetsByLowestHp(selectedTargets) : selectedTargets;
|
||||
for (const target of applyTargets) {
|
||||
if (!target.ent) continue;
|
||||
const model = target.ent.get(HeroAttrsComp);
|
||||
if (!model || model.is_dead) continue;
|
||||
if (kind === SkillKind.Heal && config.ap !== 0) {
|
||||
if (kind === SkillKind.Heal && sAp !== 0) {
|
||||
const addHp = model.add_hp(sAp*_cAttrsComp.ap);
|
||||
target.health(addHp);
|
||||
} else if (kind === SkillKind.Shield && sAp !== 0) {
|
||||
@@ -204,6 +208,34 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
}
|
||||
}
|
||||
|
||||
private pickRandomFriendlyTargets(targets: HeroViewComp[], hitCount: number): HeroViewComp[] {
|
||||
if (!targets || targets.length === 0) return [];
|
||||
const validHitCount = Math.max(1, Math.floor(hitCount));
|
||||
if (validHitCount >= targets.length) return [...targets];
|
||||
const pool = [...targets];
|
||||
const selected: HeroViewComp[] = [];
|
||||
while (selected.length < validHitCount && pool.length > 0) {
|
||||
const index = Math.floor(Math.random() * pool.length);
|
||||
const [target] = pool.splice(index, 1);
|
||||
if (!target) continue;
|
||||
selected.push(target);
|
||||
}
|
||||
return selected;
|
||||
}
|
||||
|
||||
private sortTargetsByLowestHp(targets: HeroViewComp[]): HeroViewComp[] {
|
||||
return [...targets].sort((a, b) => {
|
||||
const aModel = a.ent?.get(HeroAttrsComp);
|
||||
const bModel = b.ent?.get(HeroAttrsComp);
|
||||
const aRatio = aModel && aModel.hp_max > 0 ? aModel.hp / aModel.hp_max : 1;
|
||||
const bRatio = bModel && bModel.hp_max > 0 ? bModel.hp / bModel.hp_max : 1;
|
||||
if (aRatio !== bRatio) return aRatio - bRatio;
|
||||
const aHp = aModel?.hp ?? Number.MAX_SAFE_INTEGER;
|
||||
const bHp = bModel?.hp ?? Number.MAX_SAFE_INTEGER;
|
||||
return aHp - bHp;
|
||||
});
|
||||
}
|
||||
|
||||
/** 根据目标 eid 列表解析出有效友方视图目标 */
|
||||
private resolveFriendlyTargets(targetEids: number[], fac: number): HeroViewComp[] {
|
||||
const targets: HeroViewComp[] = [];
|
||||
|
||||
Reference in New Issue
Block a user