feat: 添加击晕状态相关功能
1. 新增击晕概率、抗性属性配置与组件字段 2. 实现击晕判定逻辑与视图特效播放 3. 增加击晕时技能CD暂停清零的处理 4. 配置默认击晕持续时间为2秒
This commit is contained in:
@@ -184,17 +184,31 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
const freezeChance = (damageEvent.Attrs[Attrs.freeze_chance] || 0) - (TAttrsComp.freeze_res || 0);
|
||||
const isFrost = !TAttrsComp.isFrost() && this.checkChance(freezeChance);
|
||||
|
||||
// 击晕判定
|
||||
const stunChance = (damageEvent.Attrs[Attrs.stun_chance] || 0) - (TAttrsComp.stun_res || 0);
|
||||
const isStun = !TAttrsComp.isStun() && this.checkChance(stunChance);
|
||||
|
||||
// 击退判定
|
||||
const knockbackChance = (damageEvent.Attrs[Attrs.knockback_chance] || 0) - (TAttrsComp.knockback_res || 0);
|
||||
const isKnockback = this.checkChance(knockbackChance);
|
||||
|
||||
// ✅ 触发视图层表现(伤害数字、受击动画、冰冻、击退)
|
||||
// ✅ 触发视图层表现(伤害数字、受击动画、冰冻、击晕、击退)
|
||||
if (targetView) {
|
||||
targetView.do_atked(damage, isCrit, damageEvent.s_uuid, false);
|
||||
targetView.playEnd(skillConf.endAnm);
|
||||
if (isFrost) {
|
||||
TAttrsComp.toFrost();
|
||||
targetView.in_iced(TAttrsComp.frost_end_time);
|
||||
if (damageEvent.Attrs.fac === FacSet.HERO) {
|
||||
smc.vmdata.scores.freeze_count++;
|
||||
}
|
||||
}
|
||||
if (isStun) {
|
||||
TAttrsComp.toStun();
|
||||
targetView.in_stun(TAttrsComp.stun_end_time);
|
||||
if (damageEvent.Attrs.fac === FacSet.HERO) {
|
||||
smc.vmdata.scores.stun_count++;
|
||||
}
|
||||
}
|
||||
if (isKnockback) {
|
||||
targetView.back(damageEvent.Attrs[Attrs.knockback_distance] || 0);
|
||||
|
||||
@@ -49,6 +49,8 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
critical_res: number = 0; // 暴击抗性
|
||||
freeze_chance: number = 0; // 冰冻概率
|
||||
freeze_res: number = 0; // 冰冻抗性
|
||||
stun_chance: number = 0; // 击晕概率
|
||||
stun_res: number = 0; // 击晕抗性
|
||||
knockback_chance: number = 0; // 击退概率
|
||||
knockback_distance: number = 0; // 击退距离强化
|
||||
knockback_res: number = 0; // 击退抗性
|
||||
@@ -61,6 +63,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
|
||||
frost_end_time: number = 0;
|
||||
stun_end_time: number = 0;
|
||||
|
||||
boom: boolean = false; // 自爆怪
|
||||
|
||||
@@ -100,6 +103,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
*/
|
||||
initAttrs() {
|
||||
this.frost_end_time = 0;
|
||||
this.stun_end_time = 0;
|
||||
}
|
||||
/*******************基础属性管理********************/
|
||||
|
||||
@@ -162,11 +166,35 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
const frostTime = FightSet.FROST_TIME * time;
|
||||
this.frost_end_time = Math.max(this.frost_end_time, frostTime);
|
||||
}
|
||||
|
||||
toStun(time: number=1) {
|
||||
const stunTime = FightSet.STUN_TIME * time;
|
||||
this.stun_end_time = Math.max(this.stun_end_time, stunTime);
|
||||
|
||||
// 击晕时 CD 清零
|
||||
for (const key in this.skills) {
|
||||
const skill = this.skills[key];
|
||||
if (skill) {
|
||||
skill.ccd = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateCD(dt: number){
|
||||
// 如果处于冰冻状态,则技能 CD 暂停刷新
|
||||
if (this.isFrost()) return;
|
||||
|
||||
// 如果处于击晕状态,则技能 CD 暂停刷新(且保持清零状态)
|
||||
if (this.isStun()) {
|
||||
for (const key in this.skills) {
|
||||
const skill = this.skills[key];
|
||||
if (skill) {
|
||||
skill.ccd = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (const key in this.skills) {
|
||||
const skill = this.skills[key];
|
||||
if (!skill) continue;
|
||||
@@ -185,6 +213,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
isFrost(): boolean {
|
||||
return this.frost_end_time > 0
|
||||
}
|
||||
isStun(): boolean {
|
||||
return this.stun_end_time > 0
|
||||
}
|
||||
getSkillLevel(skillId: number): number {
|
||||
if (!skillId) return 0;
|
||||
return this.skills[skillId]?.lv ?? 0;
|
||||
@@ -352,6 +383,8 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.critical_res = 0;
|
||||
this.freeze_chance = 0;
|
||||
this.freeze_res = 0;
|
||||
this.stun_chance = 0;
|
||||
this.stun_res = 0;
|
||||
this.knockback_chance = 0;
|
||||
this.knockback_distance = 0;
|
||||
this.knockback_res = 0;
|
||||
@@ -363,6 +396,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.boom = false;
|
||||
|
||||
this.frost_end_time = 0;
|
||||
this.stun_end_time = 0;
|
||||
|
||||
// 重置技能距离缓存
|
||||
this.maxSkillDistance = 0;
|
||||
@@ -406,7 +440,12 @@ export class HeroBuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
||||
attrsComp.frost_end_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(attrsComp.stun_end_time > 0){
|
||||
attrsComp.stun_end_time -= 0.1;
|
||||
if(attrsComp.stun_end_time <= 0){
|
||||
attrsComp.stun_end_time = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
void e;
|
||||
}
|
||||
|
||||
@@ -308,6 +308,11 @@ export class HeroViewComp extends CCComp {
|
||||
this.spawnTimedFx("game/skill/buff/iced", this.node, t);
|
||||
}
|
||||
|
||||
/** 击晕特效 */
|
||||
in_stun(t: number = 1) {
|
||||
this.spawnTimedFx("game/skill/buff/stun", this.node, t);
|
||||
}
|
||||
|
||||
/** 技能提示 */
|
||||
private tooltip(type: number = 1, value: string = "", s_uuid: number = 1001, y: number = 50) {
|
||||
let pos = v3(0, 60);
|
||||
|
||||
@@ -110,6 +110,7 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
||||
mockAttrs.ap = highestAp;
|
||||
mockAttrs.critical = 0;
|
||||
mockAttrs.freeze_chance = 0;
|
||||
mockAttrs.stun_chance = 0;
|
||||
mockAttrs.puncture_chance = 0;
|
||||
mockAttrs.fac = FacSet.HERO;
|
||||
mockAttrs.type = HType.Long; // 假定为远程,拥有较长索敌范围
|
||||
|
||||
Reference in New Issue
Block a user