Files
bl/logic/service/fight/effect/effect_4_5.go
昔念 07c08b767b feat(fight): 重构技能和受击触发逻辑,统一命名规范
- 将 `OnHit`、`AfterHit` 等方法重命名为 `AfterSkill` 和 `Attacked`,统一触发时机命名
- 调整 `BeforeSkill` 与 `PreSkill` 的职责,明确技能前处理逻辑
- 修改 `UseSkill` 为 `CanSkill`,增强语义清晰度
- 补充精灵切换时的触发方法 `OnSwitchOut` 与 `OnOwnerSwitchIn`
- 修复战斗中属性拷贝逻辑及状态持续回合计算的安全检查
- 增加捕获精灵后的日志输出,便于调试追踪
- 完善默认伤害效果节点的初始化逻辑
2025-09-25 13:07:56 +08:00

55 lines
1.3 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 {
return &EffectStat{
node.EffectNode{},
b,
}
}
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) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[1], 100)
if t {
if !e.Etype { //自身
e.Input.SetProp(e.EffectNode.SideEffectArgs[0], e.EffectNode.SideEffectArgs[2])
} else { //对方
opp.SetProp(e.EffectNode.SideEffectArgs[0], e.EffectNode.SideEffectArgs[2])
}
}
}