feat(fight): 重构技能和受击触发逻辑,统一命名规范
- 将 `OnHit`、`AfterHit` 等方法重命名为 `AfterSkill` 和 `Attacked`,统一触发时机命名 - 调整 `BeforeSkill` 与 `PreSkill` 的职责,明确技能前处理逻辑 - 修改 `UseSkill` 为 `CanSkill`,增强语义清晰度 - 补充精灵切换时的触发方法 `OnSwitchOut` 与 `OnOwnerSwitchIn` - 修复战斗中属性拷贝逻辑及状态持续回合计算的安全检查 - 增加捕获精灵后的日志输出,便于调试追踪 - 完善默认伤害效果节点的初始化逻辑
This commit is contained in:
@@ -17,7 +17,7 @@ func init() {
|
||||
input.InitEffect(input.EffectType.Skill, 1, &Effect1{})
|
||||
|
||||
}
|
||||
func (e *Effect1) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect1) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
t := e.Input.GetEffect(input.EffectType.Damage, 0).Stack()
|
||||
e.Input.CurrentPet.Info.Hp += uint32(t / 2)
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ func init() {
|
||||
})
|
||||
|
||||
}
|
||||
func (e *Effect10) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect10) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
if e.Hit() {
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[0], 100)
|
||||
if t {
|
||||
|
||||
@@ -21,7 +21,7 @@ type Effect2 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect2) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect2) PreSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
opp.Prop(e.Input, func() { //我方取敌方防御
|
||||
if opp.CurrentPet.Info.Hp < (opp.CurrentPet.Info.MaxHp / 2) {
|
||||
skill.Power *= 2
|
||||
|
||||
@@ -39,7 +39,7 @@ type EffectStat struct {
|
||||
// addrA := unsafe.Pointer(baseAddr + 4) //根据攻击算其他字段
|
||||
// *(*uint32)(addrA) = 100
|
||||
// }
|
||||
func (e *EffectStat) OnHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *EffectStat) AfterSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
|
||||
t, _, _ := e.Input.Player.Roll(e.EffectNode.SideEffectArgs[1], 100)
|
||||
if t {
|
||||
|
||||
@@ -24,7 +24,7 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
func (e *Effect62) AfterHit(*input.Input, *info.SkillEntity) {
|
||||
func (e *Effect62) AfterSkill(*input.Input, *info.SkillEntity) {
|
||||
if e.Duration() != 1 { //说明还没到生效节点
|
||||
e.Hide = true //隐藏效果
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ type Effect9 struct {
|
||||
UseSkillCount int //技能使用了多少次,切换后置0
|
||||
}
|
||||
|
||||
func (e *Effect9) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect9) PreSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
if e.Skillid != 0 && skill.ID != e.Skillid {
|
||||
e.NotALive()
|
||||
e.UseSkillCount = 0
|
||||
|
||||
@@ -12,6 +12,15 @@ type Effect0 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
func (e *Effect0) OnSwitchOut() bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect0) OnOwnerSwitchIn() bool {
|
||||
|
||||
return true
|
||||
}
|
||||
func (e *Effect0) TurnEnd(opp *input.Input) {
|
||||
e.Input.AttackValue.RemainHp = int32(e.Input.CurrentPet.Info.Hp)
|
||||
|
||||
@@ -29,46 +38,50 @@ func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
e.Input.AttackValue.IsCritical = skill.Crit
|
||||
return e.Input.AttackValue.IsCritical == 0
|
||||
})
|
||||
e.Input.Exec(func(t input.Effect) bool { //加伤
|
||||
|
||||
t.AddZone(e.Input, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
e.Input.Exec(func(t input.Effect) bool { //乘伤
|
||||
|
||||
t.MulZone(e.Input, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
if e.Input.AttackValue.IsCritical == 1 {
|
||||
e.Input.Exec(func(t input.Effect) bool { //加伤
|
||||
|
||||
t.AddZone(e.Input, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
e.Input.Exec(func(t input.Effect) bool { //乘伤
|
||||
|
||||
t.MulZone(e.Input, &input.EffectID{
|
||||
ID: 1,
|
||||
Effect: e,
|
||||
})
|
||||
return true
|
||||
})
|
||||
|
||||
e.Stack(e.Stack() * 2)
|
||||
if e.MaxStack != 0 && e.Stack() > e.MaxStack { //限制最大伤害
|
||||
e.Stack(e.MaxStack)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if e.MaxStack != 0 && e.Stack() > e.MaxStack { //限制最大伤害
|
||||
e.Stack(e.MaxStack)
|
||||
}
|
||||
e.Input.AttackValue.LostHp = uint32(e.Stack())
|
||||
}
|
||||
func (this *Effect0) BeforHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect0) BeforeSkill(opp *input.Input, skill *info.SkillEntity) {
|
||||
skill.AttackTimeC(int(opp.GetProp(5, true))) //计算命中
|
||||
skill.Crit = 0
|
||||
if skill.Category() == info.Category.STATUS { //属性技能不用算暴击
|
||||
return
|
||||
}
|
||||
CritRate := utils.Max(skill.CritRate, 1)
|
||||
|
||||
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
|
||||
if skill.CritAtkFirst != 0 && this.Input.First {
|
||||
if skill.CritAtkFirst != 0 && e.Input.First {
|
||||
CritRate = 16
|
||||
}
|
||||
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
||||
if skill.CritAtkSecond != 0 && !this.Input.First {
|
||||
if skill.CritAtkSecond != 0 && !e.Input.First {
|
||||
CritRate = 16
|
||||
}
|
||||
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
||||
if skill.CritSelfHalfHp != 0 && (this.Input.CurrentPet.HP < int(this.Input.CurrentPet.Info.MaxHp)/2) {
|
||||
if skill.CritSelfHalfHp != 0 && (e.Input.CurrentPet.HP < int(e.Input.CurrentPet.Info.MaxHp)/2) {
|
||||
CritRate = 16
|
||||
}
|
||||
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
|
||||
@@ -77,14 +90,14 @@ func (this *Effect0) BeforHit(opp *input.Input, skill *info.SkillEntity) {
|
||||
}
|
||||
|
||||
//todo 暴击伤害
|
||||
if t, _, _ := this.Input.Player.Roll(625*CritRate, 10000); t {
|
||||
if t, _, _ := e.Input.Player.Roll(625*CritRate, 10000); t {
|
||||
skill.Crit = 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 受击触发
|
||||
func (e *Effect0) AfterAttacked(opp *input.Input, skill *info.SkillEntity) {
|
||||
func (e *Effect0) Attacked(opp *input.Input, skill *info.SkillEntity) {
|
||||
|
||||
e.Input.Exec(func(t input.Effect) bool { //加伤
|
||||
|
||||
@@ -113,6 +126,7 @@ func (e *Effect0) AfterAttacked(opp *input.Input, skill *info.SkillEntity) {
|
||||
} else {
|
||||
e.Input.CurrentPet.Info.Hp = e.Input.CurrentPet.Info.Hp - opp.AttackValue.LostHp
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -16,7 +16,7 @@ type EffectStatusNotSkill struct {
|
||||
EffectStatus
|
||||
}
|
||||
|
||||
func (e *EffectStatusNotSkill) UseSkill(opp *input.Input) bool {
|
||||
func (e *EffectStatusNotSkill) CanSkill(opp *input.Input) bool {
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user