Files
bl/logic/service/fight/effect/effect_4_5.go
昔念 e75ecd413d feat(fight): 重构战斗系统技能逻辑与精灵切换功能
- 优化技能执行流程,统一使用 SelectSkillAction 作为技能载体
- 移除冗余的技能 ID 字段,简化数据结构
- 调整命中判断和技能效果触发机制,提升准确性
- 修改精灵切换与捕获相关方法参数格式
- 更新技能列表结构为动态数组以支持灵活长度
- 完善睡眠等异常状态的处理逻辑
- 修复战斗中技能 PP 扣减及副本还原问题
- 清理无用代码,如多余的 FindWithIndex 函数定义
- 强化验证码缓存键命名规则,增强安全性
2025-10-26 20:56:03 +08:00

63 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package effect
import (
"blazing/logic/service/fight/info"
"blazing/logic/service/fight/input"
"blazing/logic/service/fight/node"
)
func init() {
//技能使用成功时m%自身XX等级+/-n
input.InitEffect(input.EffectType.Skill, 4, NewEffectStat(false))
//技能使用成功时m%对方XX等级+/-n
input.InitEffect(input.EffectType.Skill, 5, NewEffectStat(true))
}
func NewEffectStat(b bool) input.Effect {
ret := &EffectStat{
EffectNode: node.EffectNode{},
Etype: b,
}
return ret
}
type EffectStat struct {
node.EffectNode
Etype bool
}
// func (this *EffectStat) GetPet() {
// ff := this.EffectNode.GetOwnerPet()
// offsetC := unsafe.Offsetof(ff.Atk) // c字段的偏移量通常为4+16=20
// // 2. 将结构体指针转换为原始内存地址uintptr
// baseAddr := uintptr(unsafe.Pointer(&offsetC))
// // 3. 计算字段地址并赋值
// // 给a字段赋值通过偏移量
// addrA := unsafe.Pointer(baseAddr + 4) //根据攻击算其他字段
// *(*uint32)(addrA) = 100
// }
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 true
}
ptype := info.AbilityOpType.ADD
if e.EffectNode.SideEffectArgs[2] < 0 {
ptype = info.AbilityOpType.SUB
}
if !e.Etype { //自身
e.Input.SetProp(e.Input, int8(e.EffectNode.SideEffectArgs[0]), int8(e.EffectNode.SideEffectArgs[2]), ptype)
} else { //对方
ctx.SetProp(e.Input, int8(e.EffectNode.SideEffectArgs[0]), int8(e.EffectNode.SideEffectArgs[2]), ptype)
}
return true
}