feat(fight): 重构战斗系统技能逻辑与精灵切换功能
- 优化技能执行流程,统一使用 SelectSkillAction 作为技能载体 - 移除冗余的技能 ID 字段,简化数据结构 - 调整命中判断和技能效果触发机制,提升准确性 - 修改精灵切换与捕获相关方法参数格式 - 更新技能列表结构为动态数组以支持灵活长度 - 完善睡眠等异常状态的处理逻辑 - 修复战斗中技能 PP 扣减及副本还原问题 - 清理无用代码,如多余的 FindWithIndex 函数定义 - 强化验证码缓存键命名规则,增强安全性
This commit is contained in:
@@ -2,7 +2,6 @@ package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
|
||||
@@ -18,16 +17,19 @@ type Effect1 struct {
|
||||
|
||||
func init() {
|
||||
ret := &Effect1{}
|
||||
ret.Effect = ret
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 1, ret)
|
||||
|
||||
}
|
||||
|
||||
// 命中之后
|
||||
func (e *Effect1) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect1) OnSkill(ctx input.Ctx) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
|
||||
e.Input.Heal(
|
||||
&action.SelectSkillAction{}, e.Input.DamageZone.Damage.Div(decimal.NewFromInt(2)),
|
||||
)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ func newp(t1 info.EnumBattleStatus) *Effect10 {
|
||||
Status: t1,
|
||||
}
|
||||
|
||||
t.Effect = t
|
||||
return t
|
||||
}
|
||||
|
||||
@@ -51,7 +50,7 @@ func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 114, newp(info.PetStatus.Flammable))
|
||||
|
||||
}
|
||||
func (e *Effect10) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect10) OnSkill(ctx input.Ctx) bool {
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100)
|
||||
if t {
|
||||
|
||||
@@ -61,11 +60,11 @@ func (e *Effect10) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
if eff.ID != 0 {
|
||||
eff.Effect.Duration(int(t1))
|
||||
|
||||
opp.AddEffect(eff)
|
||||
ctx.AddEffect(eff)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
func (e *Effect10) OnMiss(opp *input.Input, skill *info.SkillEntity) {
|
||||
|
||||
|
||||
@@ -13,16 +13,20 @@ type Effect3 struct {
|
||||
Etype info.EnumAbilityOpType
|
||||
}
|
||||
|
||||
func (e *Effect3) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect3) OnSkill(ctx input.Ctx) bool {
|
||||
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
for i := 0; i < 6; i++ {
|
||||
if e.Rev {
|
||||
opp.SetProp(e.Input, int8(i), e.Level, e.Etype)
|
||||
ctx.SetProp(e.Input, int8(i), e.Level, e.Etype)
|
||||
} else {
|
||||
e.Input.SetProp(opp, int8(i), e.Level, e.Etype)
|
||||
e.Input.SetProp(ctx.Input, int8(i), e.Level, e.Etype)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func neweffect3(rev bool, level int8, etype info.EnumAbilityOpType) *Effect3 {
|
||||
@@ -31,7 +35,7 @@ func neweffect3(rev bool, level int8, etype info.EnumAbilityOpType) *Effect3 {
|
||||
Level: level,
|
||||
Etype: etype,
|
||||
}
|
||||
ret.Effect = ret
|
||||
|
||||
return ret
|
||||
}
|
||||
func init() {
|
||||
|
||||
@@ -20,7 +20,7 @@ func NewEffectStat(b bool) input.Effect {
|
||||
EffectNode: node.EffectNode{},
|
||||
Etype: b,
|
||||
}
|
||||
ret.Effect = ret
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -40,11 +40,13 @@ type EffectStat struct {
|
||||
// addrA := unsafe.Pointer(baseAddr + 4) //根据攻击算其他字段
|
||||
// *(*uint32)(addrA) = 100
|
||||
// }
|
||||
func (e *EffectStat) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
|
||||
func (e *EffectStat) OnSkill(ctx input.Ctx) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[1], 100)
|
||||
if !t { //没触发
|
||||
return
|
||||
return true
|
||||
}
|
||||
ptype := info.AbilityOpType.ADD
|
||||
if e.EffectNode.SideEffectArgs[2] < 0 {
|
||||
@@ -54,7 +56,7 @@ func (e *EffectStat) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
e.Input.SetProp(e.Input, int8(e.EffectNode.SideEffectArgs[0]), int8(e.EffectNode.SideEffectArgs[2]), ptype)
|
||||
|
||||
} else { //对方
|
||||
opp.SetProp(e.Input, int8(e.EffectNode.SideEffectArgs[0]), int8(e.EffectNode.SideEffectArgs[2]), ptype)
|
||||
ctx.SetProp(e.Input, int8(e.EffectNode.SideEffectArgs[0]), int8(e.EffectNode.SideEffectArgs[2]), ptype)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/logic/service/fight/node"
|
||||
)
|
||||
@@ -21,12 +20,15 @@ func init() {
|
||||
Owner: true,
|
||||
},
|
||||
}
|
||||
t.Effect = t
|
||||
|
||||
input.InitEffect(input.EffectType.Skill, 62, t)
|
||||
|
||||
}
|
||||
|
||||
func (e *Effect62) OnHit(*input.Input, *info.SkillEntity) {
|
||||
func (e *Effect62) OnSkill(ctx input.Ctx) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
if e.Duration() != 1 { //说明还没到生效节点
|
||||
e.Hide = true //隐藏效果
|
||||
} else {
|
||||
@@ -42,7 +44,7 @@ func (e *Effect62) OnHit(*input.Input, *info.SkillEntity) {
|
||||
//否则触发秒杀 在对面使用技能后
|
||||
//return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// 默认添加回合
|
||||
|
||||
@@ -19,11 +19,28 @@ type StatusNotSkill struct {
|
||||
}
|
||||
|
||||
// 不能出手
|
||||
func (e *StatusNotSkill) Skill_Hit_Pre(input.Ctx) bool {
|
||||
func (e *StatusNotSkill) Skill_Hit_Pre(ctx input.Ctx) bool {
|
||||
if e.EffectStatus.Status == info.PetStatus.Sleep {
|
||||
|
||||
ctx.AddEffect(&input.EffectID{ //对对方添加出手解除效果
|
||||
ID: -1,
|
||||
Effect: &StatusSleep{},
|
||||
})
|
||||
|
||||
}
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
type StatusSleep struct { //睡眠不能出手
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *StatusSleep) Skill_Useed(input.Ctx) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 扣血类
|
||||
type DrainHP struct {
|
||||
EffectStatus
|
||||
@@ -65,9 +82,9 @@ func init() {
|
||||
}
|
||||
input.InitEffect(input.EffectType.Status, int(info.PetStatus.DrainHP), &EffectStatus{}) //寄生种子
|
||||
|
||||
tt(info.PetStatus.Paralysis, &StatusNotSkill{})
|
||||
tt(info.PetStatus.Tired, &StatusNotSkill{})
|
||||
tt(info.PetStatus.Fear, &StatusNotSkill{})
|
||||
tt(info.PetStatus.Petrified, &StatusNotSkill{})
|
||||
|
||||
tt(info.PetStatus.Paralysis, &StatusNotSkill{}) //麻痹
|
||||
tt(info.PetStatus.Tired, &StatusNotSkill{}) //疲惫
|
||||
tt(info.PetStatus.Fear, &StatusNotSkill{}) //害怕
|
||||
tt(info.PetStatus.Petrified, &StatusNotSkill{}) //石化
|
||||
input.InitEffect(input.EffectType.Status, 8, &StatusSleep{}) //睡眠
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user