fix(skill): 修复技能升级配置查找和友方技能目标选择逻辑
修复SkillUpList中默认配置键值错误,从6001改为1001 修复技能升级属性计算中的空值保护,避免undefined导致的NaN 重构友方技能目标选择逻辑,添加随机选取和按血量排序功能 调整辅助技能数值从基于最大生命值百分比改为基于攻击力百分比
This commit is contained in:
@@ -150,7 +150,7 @@ export interface SkillConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SkillUpList = {
|
export const SkillUpList = {
|
||||||
6001:{ap:0,hit_count:0,buff_ap:0,buff_hp:0,bck:0,frz:0,crt:0,num:0}
|
1001:{ap:0,hit_count:0,buff_ap:0,buff_hp:0,bck:0,frz:0,crt:0,num:0}
|
||||||
}
|
}
|
||||||
|
|
||||||
/******
|
/******
|
||||||
@@ -256,28 +256,28 @@ export const SkillSet: Record<number, SkillConfig> = {
|
|||||||
//============================= ====== 辅助技能 ====== ==========================
|
//============================= ====== 辅助技能 ====== ==========================
|
||||||
6301:{
|
6301:{
|
||||||
uuid:6301,name:"魔法盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Self,readyAnm:"",endAnm:"",act:"atk",
|
uuid:6301,name:"魔法盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Self,readyAnm:"",endAnm:"",act:"atk",
|
||||||
DTType:DTType.single,kind:SkillKind.Shield,ap:30,hit_count:1,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
DTType:DTType.single,kind:SkillKind.Shield,ap:300,hit_count:1,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
||||||
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"获得30%最大生命值的护盾",
|
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"获得300%攻击力的护盾",
|
||||||
},
|
},
|
||||||
6302: {
|
6302: {
|
||||||
uuid:6302,name:"治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Team,readyAnm:"",endAnm:"",act:"atk",
|
uuid:6302,name:"治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Team,readyAnm:"",endAnm:"",act:"atk",
|
||||||
DTType:DTType.single,kind:SkillKind.Heal,ap:30,hit_count:1,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
DTType:DTType.single,kind:SkillKind.Heal,ap:300,hit_count:1,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
||||||
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"治疗1个友方30%最大生命值",
|
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"治疗1个友方300%攻击力的生命值",
|
||||||
},
|
},
|
||||||
6303:{
|
6303:{
|
||||||
uuid:6303,name:"护盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Self,readyAnm:"",endAnm:"",act:"atk",
|
uuid:6303,name:"护盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Self,readyAnm:"",endAnm:"",act:"atk",
|
||||||
DTType:DTType.single,kind:SkillKind.Shield,ap:30,hit_count:1,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
DTType:DTType.single,kind:SkillKind.Shield,ap:300,hit_count:1,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
||||||
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"随机1个友方获得30%最大生命值的护盾",
|
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"随机1个友方获得300%攻击力的护盾",
|
||||||
},
|
},
|
||||||
6304: {
|
6304: {
|
||||||
uuid:6304,name:"群体治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Team,readyAnm:"",endAnm:"",act:"atk",
|
uuid:6304,name:"群体治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Team,readyAnm:"",endAnm:"",act:"atk",
|
||||||
DTType:DTType.single,kind:SkillKind.Heal,ap:20,hit_count:3,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
DTType:DTType.single,kind:SkillKind.Heal,ap:200,hit_count:3,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
||||||
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"随机3个友方,回复20%最大生命值",
|
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"随机治疗3个友方200%攻击力的生命值",
|
||||||
},
|
},
|
||||||
6305:{
|
6305:{
|
||||||
uuid:6305,name:"群体护盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Team,readyAnm:"",endAnm:"",act:"atk",
|
uuid:6305,name:"群体护盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Team,readyAnm:"",endAnm:"",act:"atk",
|
||||||
DTType:DTType.single,kind:SkillKind.Shield,ap:20,hit_count:3,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
DTType:DTType.single,kind:SkillKind.Shield,ap:200,hit_count:3,hitcd:0.2,speed:720,with:0,ready:0,EAnm:0,DAnm:"",
|
||||||
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"随机3个友方获得20%最大生命值的护盾",
|
RType:RType.fixed,EType:EType.animationEnd,buffs:[],info:"随机3个友方获得200%攻击力的护盾",
|
||||||
},
|
},
|
||||||
//==========================buff 技能=====================
|
//==========================buff 技能=====================
|
||||||
6401:{
|
6401:{
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
const s_uuid = castPlan.skillId;
|
const s_uuid = castPlan.skillId;
|
||||||
const skillLv = castPlan.skillLv;
|
const skillLv = castPlan.skillLv;
|
||||||
const config = SkillSet[s_uuid];
|
const config = SkillSet[s_uuid];
|
||||||
|
const sUp=SkillUpList[s_uuid]??SkillUpList[1001]
|
||||||
|
const cNum=sUp.num
|
||||||
if (!config) return;
|
if (!config) return;
|
||||||
//播放前摇技能动画
|
//播放前摇技能动画
|
||||||
heroView.playReady(config.readyAnm);
|
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) {
|
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 kind = config.kind ?? SkillKind.Support;
|
||||||
const sUp=SkillUpList[_skillLv]
|
const sUp = SkillUpList[_s_uuid] ?? SkillUpList[1001];
|
||||||
const sAp =config.ap+sUp.ap*_skillLv;
|
const sAp =config.ap+sUp.ap*_skillLv;
|
||||||
const sHit=config.hit_count+sUp.hit_count*_skillLv
|
const sHit=config.hit_count+sUp.hit_count*_skillLv;
|
||||||
for (const target of targets) {
|
const selectedTargets = this.pickRandomFriendlyTargets(targets, sHit);
|
||||||
|
const applyTargets = kind === SkillKind.Heal ? this.sortTargetsByLowestHp(selectedTargets) : selectedTargets;
|
||||||
|
for (const target of applyTargets) {
|
||||||
if (!target.ent) continue;
|
if (!target.ent) continue;
|
||||||
const model = target.ent.get(HeroAttrsComp);
|
const model = target.ent.get(HeroAttrsComp);
|
||||||
if (!model || model.is_dead) continue;
|
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);
|
const addHp = model.add_hp(sAp*_cAttrsComp.ap);
|
||||||
target.health(addHp);
|
target.health(addHp);
|
||||||
} else if (kind === SkillKind.Shield && sAp !== 0) {
|
} 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 列表解析出有效友方视图目标 */
|
/** 根据目标 eid 列表解析出有效友方视图目标 */
|
||||||
private resolveFriendlyTargets(targetEids: number[], fac: number): HeroViewComp[] {
|
private resolveFriendlyTargets(targetEids: number[], fac: number): HeroViewComp[] {
|
||||||
const targets: HeroViewComp[] = [];
|
const targets: HeroViewComp[] = [];
|
||||||
|
|||||||
@@ -204,10 +204,10 @@ export class Skill extends ecs.Entity {
|
|||||||
sDataCom.group=caster.box_group
|
sDataCom.group=caster.box_group
|
||||||
sDataCom.casterEid=caster.ent.eid
|
sDataCom.casterEid=caster.ent.eid
|
||||||
sDataCom.Attrs = {};
|
sDataCom.Attrs = {};
|
||||||
const SUp=SkillUpList[s_uuid]
|
const SUp=SkillUpList[s_uuid]??SkillUpList[1001]
|
||||||
const sCrt = (config.crt ?? 0)+(SUp.crt??0)*skill_lv;
|
const sCrt = (config.crt ?? 0)+SUp.crt*skill_lv;
|
||||||
const sFrz = (config.frz ?? 0)+(SUp.frz??0)*skill_lv;
|
const sFrz = (config.frz ?? 0)+SUp.frz*skill_lv;
|
||||||
const sBck = (config.bck ?? 0)+(SUp.bck??0)*skill_lv;
|
const sBck = (config.bck ?? 0)+SUp.bck*skill_lv;
|
||||||
const sAp =config.ap+SUp.ap*skill_lv;
|
const sAp =config.ap+SUp.ap*skill_lv;
|
||||||
const sHit=config.hit_count+SUp.hit_count*skill_lv + cAttrsComp.puncture
|
const sHit=config.hit_count+SUp.hit_count*skill_lv + cAttrsComp.puncture
|
||||||
sDataCom.Attrs[Attrs.ap] = cAttrsComp.ap*sAp;
|
sDataCom.Attrs[Attrs.ap] = cAttrsComp.ap*sAp;
|
||||||
|
|||||||
Reference in New Issue
Block a user