fix(fight): 修正空变更导致的潜在逻辑问题

This commit is contained in:
1
2025-11-30 10:21:57 +00:00
parent 1938346e89
commit e4fd9c2e38
8 changed files with 57 additions and 23 deletions

View File

@@ -29,8 +29,8 @@ func (e *NewSel24) Skill_Hit_ex() bool {
if !ok { if !ok {
return true return true
} }
skill.SetMiss()
skill.AttackTime = 0
return true return true
} }
func init() { func init() {

View File

@@ -24,7 +24,8 @@ func (e *NewSel7) Skill_Hit_ex() bool {
} }
success, _, _ := e.Input.Player.Roll(e.Args()[0], 100) success, _, _ := e.Input.Player.Roll(e.Args()[0], 100)
if success { if success {
skill.AttackTime = 0 skill.SetMiss()
} }
return true return true

View File

@@ -18,7 +18,8 @@ func (e *NewSel84) Skill_Hit_ex() bool {
if e.Ctx().SkillEntity.Category() != info.Category.STATUS { if e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true return true
} }
e.Ctx().Opp.EffectCache = make([]input.Effect, 0) e.Ctx().SkillEntity.SetNoSide()
return true return true
} }
func init() { func init() {

View File

@@ -58,7 +58,8 @@ func (e *EffectAttackMiss) Skill_Hit_ex() bool {
// 若攻击类型匹配目标类型则强制miss设置AttackTime=0 // 若攻击类型匹配目标类型则强制miss设置AttackTime=0
if skill.Category() == e.targetCategory { if skill.Category() == e.targetCategory {
skill.AttackTime = 0 // 强制命中失效 skill.SetMiss()
} }
return true return true

View File

@@ -40,7 +40,8 @@ func (e *Effect478) Skill_Hit_ex() bool {
if e.Ctx().SkillEntity.Category() != info.Category.STATUS { if e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true return true
} }
e.Ctx().Opp.EffectCache = make([]input.Effect, 0) e.Ctx().SkillEntity.SetNoSide()
return true return true
} }
func (e *Effect478) SetArgs(t *input.Input, a ...int) { func (e *Effect478) SetArgs(t *input.Input, a ...int) {

View File

@@ -13,7 +13,7 @@ func init() {
t := &Effect52{ t := &Effect52{
EffectNode: node.EffectNode{}, EffectNode: node.EffectNode{},
} }
input.InitEffect(input.EffectType.Skill, 52, t) input.InitEffect(input.EffectType.Skill, 52, t)
} }
@@ -40,9 +40,7 @@ func (e *Effect52) Skill_Hit_ex() bool {
if !e.Input.FightC.IsFirst(e.Ctx().Our.Player) { if !e.Input.FightC.IsFirst(e.Ctx().Our.Player) {
return true return true
} }
if e.Ctx().SkillEntity.AttackTime == 1 { e.Ctx().SkillEntity.SetMiss()
e.Ctx().SkillEntity.AttackTime = 0
}
return true return true
} }

View File

@@ -19,7 +19,8 @@ import (
func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.SkillEntity) { func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.SkillEntity) {
//oldpet := f.copypet(attacker.CurrentPet) //oldpet := f.copypet(attacker.CurrentPet)
a.AttackTimeC(attacker.GetProp(5, true)) //计算命中 a.AttackTimeC(attacker.GetProp(5, true)) //计算命中
defender.Exec(func(t input.Effect) bool { //计算闪避 ,然后修改对方命中),同时相当于计算属性无效这种 defender.Exec(func(t input.Effect) bool { //计算闪避 ,然后修改对方命中),同时相当于计算属性无效这种
t.Ctx().SkillEntity = a t.Ctx().SkillEntity = a
@@ -28,7 +29,6 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.Ski
return true return true
}) })
attacker.AttackValue.AttackTime = a.AttackTime //是否命中赋值
var oldprop [2][6]int8 var oldprop [2][6]int8
oldprop[0], oldprop[1] = attacker.Prop, defender.Prop //先复制能力提升 oldprop[0], oldprop[1] = attacker.Prop, defender.Prop //先复制能力提升
attacker.Exec(func(t input.Effect) bool { attacker.Exec(func(t input.Effect) bool {
@@ -42,8 +42,11 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.Ski
//技能miss+效果生效 这里属于强制改命中效果,但是正常来说,技能miss掉后效果也应该失效 //技能miss+效果生效 这里属于强制改命中效果,但是正常来说,技能miss掉后效果也应该失效
//技能失效+效果失效 //技能失效+效果失效
// 记录技能信息 // 记录技能信息
//如果miss或者失效
attacker.AttackTime = a.AttackTime
attacker.SkillID = uint32(a.ID) //获取技能ID attacker.SkillID = uint32(a.ID) //获取技能ID
if attacker.AttackTime > 0 { //如果命中 if a.AttackTime != 0 { //如果命中
attacker.CalculateCrit(defender, a) //暴击计算 attacker.CalculateCrit(defender, a) //暴击计算
attacker.IsCritical = a.Crit attacker.IsCritical = a.Crit
@@ -52,6 +55,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.Ski
//睡眠受击消除 //睡眠受击消除
} }
attacker.Prop, defender.Prop = oldprop[0], oldprop[1] //先复制能力提升 attacker.Prop, defender.Prop = oldprop[0], oldprop[1] //先复制能力提升
if attacker.IsCritical == 1 { //命中了才有暴击 if attacker.IsCritical == 1 { //命中了才有暴击
@@ -67,10 +71,23 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *info.Ski
attacker.SumDamage = attacker.SumDamage.Mul(decimal.NewFromInt(2)) attacker.SumDamage = attacker.SumDamage.Mul(decimal.NewFromInt(2))
} }
// attacker.AddEffects(attacker.EffectCache...) //命中再添加效果
for _, e := range attacker.EffectCache { if !a.Side { //|| attacker.AttackTime == 0 {
//这里实现应该参考本地技能是否命中,然后
e.Hit(attacker.AttackTime != 0) //我方效果命中 //这时候将被覆盖的效果全部装回来enterturn
for _, e := range attacker.Effect_Lost {
if e.Duration() > 0 || e.Duration() == -1 {
e.Alive(true)
}
}
} else {
// attacker.AddEffects(attacker.EffectCache...) //命中再添加效果
for _, e := range attacker.EffectCache {
//这里实现应该参考本地技能是否命中,然后
e.Hit(true) //我方效果命中
}
} }
// 扣减防御方血量 // 扣减防御方血量
@@ -225,10 +242,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
e.Alive(true) e.Alive(true)
} }
} } else {
// 结算状态
// 然后这里还可以处理自爆类
if canuse { //可以使用技能
f.processSkillAttack(attacker, defender, currentskill) f.processSkillAttack(attacker, defender, currentskill)
currentskill = oldskill //还原技能 currentskill = oldskill //还原技能
@@ -246,6 +260,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
} }
} }
//0血不触发 //0血不触发
if defender.CurrentPet.Info.Hp > 0 { if defender.CurrentPet.Info.Hp > 0 {
//技能使用后 //技能使用后

View File

@@ -55,6 +55,7 @@ type SkillEntity struct {
//MaxValue func(ahp, bhp uint32) decimal.Decimal //MaxValue func(ahp, bhp uint32) decimal.Decimal
Crit uint32 Crit uint32
AttackTime uint32 AttackTime uint32
Side bool
} }
// CreateSkill 创建战斗技能实例可指定是否无限PP // CreateSkill 创建战斗技能实例可指定是否无限PP
@@ -96,6 +97,20 @@ func strSliceToIntSlice(strs []string) ([]int, error) {
func (s *SkillEntity) CanUse() bool { func (s *SkillEntity) CanUse() bool {
return s.Info.PP > 0 return s.Info.PP > 0
} }
func (s *SkillEntity) SetMiss() bool {
if s.AttackTime == 1 {
s.SetNoSide()
s.AttackTime = 0
return true
}
return false
}
// 无效掉附带属性
func (s *SkillEntity) SetNoSide() bool {
s.Side = false
return true
}
// 获取技能类型 // 获取技能类型
func (s *SkillEntity) Category() EnumCategory { func (s *SkillEntity) Category() EnumCategory {
@@ -149,20 +164,22 @@ func getSkillName(move *SkillEntity) string {
// } // }
// 计算是否命中 // 计算是否命中
func (s *SkillEntity) AttackTimeC(level int) { func (s *SkillEntity) AttackTimeC(level int) uint32 {
s.AttackTime = 0 //先重置上一次的 s.AttackTime = 0 //先重置上一次的
if s.MustHit != 0 { if s.MustHit != 0 {
s.AttackTime = 2 s.AttackTime = 2
return s.Side = true
return s.AttackTime
} }
a := int64(s.GetAccuracy(level)) a := int64(s.GetAccuracy(level))
r := s.Rand.Int63n(100) r := s.Rand.Int63n(100)
if a >= r { if a >= r {
s.Side = true
s.AttackTime = 1 s.AttackTime = 1
} }
return s.AttackTime
} }
func (s *SkillEntity) CriticalsameTypeBonus() decimal.Decimal { func (s *SkillEntity) CriticalsameTypeBonus() decimal.Decimal {
// 同系加成默认倍率为1.0 // 同系加成默认倍率为1.0