fix(fight): 修复睡眠,修改战斗伤害叠加逻辑
This commit is contained in:
@@ -57,15 +57,9 @@ func (e *Effect21) Skill_Use(ctx input.Ctx) bool {
|
||||
if e.Input.CurrentPet.Info.Hp <= 0 {
|
||||
return true
|
||||
}
|
||||
eff := input.Ctx{
|
||||
Input: e.Input,
|
||||
|
||||
SelectSkillAction: nil,
|
||||
DamageZone: &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: decimal.NewFromInt(int64(ctx.DamageZone.Damage.IntPart())).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))),
|
||||
},
|
||||
}
|
||||
ctx.Input.Damage(eff)
|
||||
ctx.DamageZone.Type = info.DamageType.Fixed
|
||||
ctx.DamageZone.Damage = decimal.NewFromInt(int64(ctx.DamageZone.Damage.IntPart())).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0])))
|
||||
ctx.Input.Damage(ctx)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -27,16 +27,9 @@ func (e *Effect28) OnSkill(ctx input.Ctx) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
eff := input.Ctx{
|
||||
Input: e.Input,
|
||||
|
||||
SelectSkillAction: nil,
|
||||
DamageZone: &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: decimal.NewFromInt(int64(ctx.CurrentPet.Info.Hp)).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0]))),
|
||||
},
|
||||
}
|
||||
|
||||
ctx.Input.Damage(eff)
|
||||
ctx.DamageZone.Type = info.DamageType.Fixed
|
||||
ctx.DamageZone.Damage = decimal.NewFromInt(int64(ctx.CurrentPet.Info.Hp)).Div(decimal.NewFromInt(int64(e.SideEffectArgs[0])))
|
||||
ctx.Input.Damage(ctx)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -27,16 +27,9 @@ func (e *Effect29) OnSkill(ctx input.Ctx) bool {
|
||||
if !e.Hit() {
|
||||
return true
|
||||
}
|
||||
eff := input.Ctx{
|
||||
Input: e.Input,
|
||||
|
||||
SelectSkillAction: nil,
|
||||
DamageZone: &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: decimal.NewFromInt(int64(e.SideEffectArgs[0])),
|
||||
},
|
||||
}
|
||||
|
||||
ctx.Input.Damage(eff)
|
||||
|
||||
ctx.DamageZone.Type = info.DamageType.Fixed
|
||||
ctx.DamageZone.Damage = decimal.NewFromInt(int64(e.SideEffectArgs[0]))
|
||||
ctx.Input.Damage(ctx)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ type Effect6 struct {
|
||||
}
|
||||
|
||||
func (e *Effect6) Skill_Useed(ctx input.Ctx) bool {
|
||||
//eff := deep.MustCopy(ctx)
|
||||
|
||||
ctx.DamageZone.Damage = ctx.DamageZone.Damage.Div(decimal.NewFromInt(int64(e.SideEffectArgs[0])))
|
||||
e.Input.Damage(ctx)
|
||||
|
||||
|
||||
@@ -15,32 +15,26 @@ type Effect62 struct {
|
||||
node.EffectNode
|
||||
Hide bool // 是否隐藏 正常是命中就可用,镇魂歌是回合数到才可用
|
||||
opp *input.Input
|
||||
e *Effect62_1
|
||||
e *Effect62_sub
|
||||
}
|
||||
type Effect62_1 struct {
|
||||
type Effect62_sub struct {
|
||||
node.EffectNode
|
||||
bindpet *info.BattlePetEntity
|
||||
opp *input.Input
|
||||
bind *input.Input
|
||||
|
||||
// Hide bool // 是否隐藏 正常是命中就可用,镇魂歌是回合数到才可用
|
||||
|
||||
}
|
||||
|
||||
func (e *Effect62_1) OnSkill(ctx input.Ctx) bool {
|
||||
// 这个实际上在对方回合执行的
|
||||
func (e *Effect62_sub) OnSkill(ctx input.Ctx) bool {
|
||||
defer e.Alive(false)
|
||||
if e.bindpet == e.opp.CurrentPet { //说明对方没有切换精灵
|
||||
if e.bindpet == e.bind.CurrentPet { //说明对方没有切换精灵
|
||||
//直接扣除所有血量OnSkill
|
||||
eff := input.Ctx{
|
||||
Input: e.Input,
|
||||
|
||||
SelectSkillAction: nil,
|
||||
DamageZone: &info.DamageZone{
|
||||
Type: info.DamageType.Fixed,
|
||||
Damage: decimal.NewFromInt(int64(e.Input.CurrentPet.Info.MaxHp)),
|
||||
},
|
||||
}
|
||||
|
||||
e.opp.Damage(eff)
|
||||
ctx.DamageZone.Type = info.DamageType.Fixed
|
||||
ctx.DamageZone.Damage = decimal.NewFromInt(int64(e.bind.CurrentPet.Info.MaxHp))
|
||||
e.bind.Damage(ctx)
|
||||
|
||||
}
|
||||
return true
|
||||
@@ -81,11 +75,12 @@ func (e *Effect62) OnSkill(ctx input.Ctx) bool {
|
||||
return true
|
||||
}
|
||||
e.opp = ctx.Input
|
||||
e.e = &Effect62_1{
|
||||
e.e = &Effect62_sub{
|
||||
EffectNode: node.EffectNode{},
|
||||
bindpet: ctx.CurrentPet,
|
||||
opp: ctx.Input,
|
||||
bind: ctx.Input,
|
||||
}
|
||||
e.e.ID(e.ID() + int(input.EffectType.Sub)) //子效果ID
|
||||
//给对方添加我方施加的buff
|
||||
e.e.SetArgs(e.Input, e.SideEffectArgs...)
|
||||
return true
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
type Effect69 struct {
|
||||
node.EffectNode
|
||||
}
|
||||
type Effect69_1 struct {
|
||||
type Effect69_sub struct {
|
||||
node.EffectNode
|
||||
}
|
||||
|
||||
@@ -28,9 +28,10 @@ func init() {
|
||||
|
||||
func (e *Effect69) OnSkill(ctx input.Ctx) bool {
|
||||
|
||||
t := &Effect69_1{
|
||||
t := &Effect69_sub{
|
||||
EffectNode: node.EffectNode{},
|
||||
}
|
||||
t.ID(e.ID() + int(input.EffectType.Sub)) //子效果ID
|
||||
t.SetArgs(e.Input, e.SideEffectArgs...)
|
||||
t.Duration(e.SideEffectArgs[0])
|
||||
ctx.AddEffect(t)
|
||||
@@ -38,7 +39,7 @@ func (e *Effect69) OnSkill(ctx input.Ctx) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Effect69_1) Heal_Pre(f action.BattleActionI, t *int) bool {
|
||||
func (e *Effect69_sub) Heal_Pre(f action.BattleActionI, t *int) bool {
|
||||
if _, ok := f.(*action.UseItemAction); ok {
|
||||
*t = -*t // 把t指向的值取反,直接作用于外部变量
|
||||
|
||||
|
||||
@@ -28,9 +28,19 @@ func (e *StatusNotSkill) Skill_Hit_Pre(ctx input.Ctx) bool {
|
||||
|
||||
type StatusSleep struct { //睡眠不能出手 ,这个挂载到对面来实现对方攻击后解除睡眠效果
|
||||
StatusNotSkill
|
||||
can bool
|
||||
}
|
||||
|
||||
func (e *StatusSleep) Skill_Hit_Pre(ctx input.Ctx) bool {
|
||||
e.StatusNotSkill.Skill_Hit_Pre(ctx)
|
||||
e.can = true
|
||||
return false
|
||||
|
||||
}
|
||||
func (e *StatusSleep) Skill_Use(ctx input.Ctx) bool {
|
||||
if !e.can {
|
||||
return true
|
||||
}
|
||||
if ctx.SkillEntity == nil {
|
||||
return true
|
||||
}
|
||||
@@ -53,11 +63,9 @@ type DrainHP struct {
|
||||
func (e *DrainHP) Skill_Hit_Pre(input input.Ctx) bool {
|
||||
e.damage = decimal.NewFromUint64(uint64(e.Input.CurrentPet.Info.MaxHp)).
|
||||
Div(decimal.NewFromInt(8))
|
||||
input.DamageZone = &info.DamageZone{
|
||||
input.DamageZone.Type = info.DamageType.True
|
||||
input.DamageZone.Damage = e.damage
|
||||
|
||||
Type: info.DamageType.True, //状态类扣除无法被减伤
|
||||
Damage: e.damage,
|
||||
}
|
||||
e.Input.Damage(input)
|
||||
|
||||
return true
|
||||
|
||||
@@ -315,6 +315,7 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *action.S
|
||||
t.OnSkill(input.Ctx{
|
||||
Input: defender,
|
||||
SelectSkillAction: a,
|
||||
DamageZone: &info.DamageZone{}, //给个空的,方便传递
|
||||
}) //调用伤害计算
|
||||
|
||||
return true
|
||||
@@ -457,6 +458,7 @@ func (f *FightC) enterturn(fattack, sattack *action.SelectSkillAction) {
|
||||
return t.Skill_Hit_Pre(input.Ctx{
|
||||
Input: defender,
|
||||
SelectSkillAction: currentskill,
|
||||
DamageZone: &info.DamageZone{},
|
||||
}) //返回本身结算,如果false,说明不能使用技能了
|
||||
|
||||
})
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"github.com/brunoga/deep"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
@@ -92,37 +93,40 @@ func (u *Input) DelPP(value int) {
|
||||
|
||||
// 伤害落实 // 血量扣减节点比如触发回神,反弹也在这里实现
|
||||
func (u *Input) Damage(ctx Ctx) {
|
||||
ctx.Input.DamageZone.BeforeADD = ctx.DamageZone.Damage
|
||||
sub := deep.MustCopy(ctx.DamageZone) //拷贝伤害,避免直接上下文传递,便于附加伤害
|
||||
tctx := Ctx{
|
||||
DamageZone: sub,
|
||||
Input: u,
|
||||
}
|
||||
// sub := ctx.DamageZone
|
||||
//sub.BeforeADD = sub.Damage
|
||||
ok := ctx.Input.Exec(func(t Effect) bool {
|
||||
tctx := ctx
|
||||
tctx.Input = u
|
||||
|
||||
t.Damage_ADD(tctx) //红伤落实前,我方增伤
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
ctx.Input.DamageZone.BeforeMul = ctx.DamageZone.Damage
|
||||
//sub.BeforeMul = sub.Damage
|
||||
if ok {
|
||||
ok = ctx.Input.Exec(func(t Effect) bool {
|
||||
tctx := ctx
|
||||
tctx.Input = u
|
||||
|
||||
t.Damage_Mul(tctx) //红伤落实前,我方增伤
|
||||
|
||||
return true
|
||||
})
|
||||
}
|
||||
ctx.Input.DamageZone.BeforeFloor = ctx.DamageZone.Damage
|
||||
//sub.BeforeFloor = sub.Damage
|
||||
if ok {
|
||||
ok = ctx.Exec(func(t Effect) bool {
|
||||
tctx := ctx
|
||||
tctx.Input = u
|
||||
|
||||
t.Damage_Floor(tctx) //红伤落实,内部有befer
|
||||
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
ctx.Input.DamageZone.BeforeMul = ctx.DamageZone.Damage
|
||||
// sub.BeforeMul = sub.Damage
|
||||
if ok {
|
||||
ok = u.Exec(func(t Effect) bool {
|
||||
|
||||
@@ -132,7 +136,7 @@ func (u *Input) Damage(ctx Ctx) {
|
||||
})
|
||||
}
|
||||
|
||||
ctx.Input.DamageZone.BeforeSUB = ctx.DamageZone.Damage
|
||||
//sub.BeforeSUB = sub.Damage
|
||||
if ok {
|
||||
ok = u.Exec(func(t Effect) bool {
|
||||
|
||||
@@ -142,17 +146,16 @@ func (u *Input) Damage(ctx Ctx) {
|
||||
})
|
||||
}
|
||||
|
||||
ctx.Input.DamageZone.BeforeLock = ctx.DamageZone.Damage
|
||||
// sub.BeforeLock = sub.Damage
|
||||
if ok {
|
||||
ok = ctx.Input.Exec(func(t Effect) bool {
|
||||
tctx := ctx
|
||||
tctx.Input = u
|
||||
|
||||
t.Damage_Lock(tctx)
|
||||
|
||||
return true
|
||||
})
|
||||
}
|
||||
ctx.Input.DamageZone.BeforeLocked = ctx.DamageZone.Damage
|
||||
//sub.BeforeLocked = sub.Damage
|
||||
if ok {
|
||||
u.Exec(func(t Effect) bool {
|
||||
|
||||
@@ -163,7 +166,7 @@ func (u *Input) Damage(ctx Ctx) {
|
||||
}
|
||||
|
||||
if ctx.DamageZone.Type == info.DamageType.Red { //红才会产生造成伤害
|
||||
ctx.Input.DamageZone.Damage = ctx.DamageZone.Damage
|
||||
ctx.Input.DamageZone.Damage.Add(sub.Damage) // 叠加总伤害
|
||||
ctx.AttackValue.LostHp = uint32(ctx.DamageZone.Damage.IntPart()) //红伤落实
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ type Input struct {
|
||||
*info.AttackValue
|
||||
FightC common.FightI
|
||||
// info.BattleActionI
|
||||
Effects []Effect //effects 实际上全局就是effect无限回合 //effects容器 技能的
|
||||
Effects []Effect //effects 实际上全局就是effect无限回合 //effects容器 技能的
|
||||
DamageZone struct {
|
||||
Damage decimal.Decimal //伤害
|
||||
BeforeADD decimal.Decimal //攻击伤害
|
||||
|
||||
@@ -17,6 +17,7 @@ var EffectType = enum.New[struct {
|
||||
Skill EnumEffectType `enum:"1000000"` //技能
|
||||
NewSel EnumEffectType `enum:"2000000"` //特性
|
||||
Status EnumEffectType `enum:"3000000"` //状态
|
||||
Sub EnumEffectType `enum:"4000000"` //子效果
|
||||
|
||||
}]()
|
||||
var NodeM = make(map[int]Effect, 0)
|
||||
@@ -175,7 +176,7 @@ func (c *Input) Exec(fn func(Effect) bool) bool {
|
||||
}
|
||||
|
||||
// 消除回合类效果 efftype 输入是消对方的还是自己的,false是自己,true是对方
|
||||
func (c *Input) CancelTurn(efftype bool) {
|
||||
func (c *Input) CancelTurn() {
|
||||
for _, value := range c.Effects {
|
||||
if value.Duration() > 0 { //false是自身,true是对方,反转后为真就是自己的
|
||||
//slice = append(slice[:i], slice[i+1:]...)
|
||||
@@ -185,3 +186,20 @@ func (c *Input) CancelTurn(efftype bool) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 消除全部
|
||||
func (c *Input) CancelAll(in *Input) {
|
||||
if in == c { //消除自身
|
||||
c.Effects = make([]Effect, 0)
|
||||
return
|
||||
}
|
||||
|
||||
for _, value := range c.Effects {
|
||||
if value.GetInput() == in { //false是自身,true是对方,反转后为真就是自己的
|
||||
//slice = append(slice[:i], slice[i+1:]...)
|
||||
value.Alive(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,8 +52,9 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
|
||||
return true
|
||||
})
|
||||
f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)
|
||||
f.GetInputByPlayer(c, false).Effects = make([]input.Effect, 0) //清除效果类
|
||||
f.Broadcast(func(ff *input.Input) { //先给自身广播
|
||||
f.GetInputByPlayer(c, false).CancelAll(f.GetInputByPlayer(c, false)) //清除效果类
|
||||
f.GetInputByPlayer(c, true).CancelAll(f.GetInputByPlayer(c, false)) //清除自身对对方施加的效果类
|
||||
f.Broadcast(func(ff *input.Input) { //先给自身广播
|
||||
if ff.Player.GetInfo().UserID == c.GetInfo().UserID {
|
||||
ff.Player.SendChangePet(ret.Reason)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user