feat: 添加宠物天敌属性及相关战斗效果
为宠物添加NaturalEnemy属性,并在战斗中实现遇到天敌时的特殊效果: 1. 战斗开始时连续害怕n回合 2. 对天敌的伤害减少n%
This commit is contained in:
@@ -44,6 +44,7 @@ type PetInfo struct {
|
||||
AddSeParam int `xml:"AddSeParam,attr"` // 附加状态参数
|
||||
Recycle int `xml:"Recycle,attr"` // 是否可回收
|
||||
LearnableMoves LearnableMoves `xml:"LearnableMoves"` // 可学习的技能
|
||||
NaturalEnemy string `xml:"NaturalEnemy,attr"` //天敌
|
||||
}
|
||||
|
||||
func (basic *PetInfo) GetBasic() uint32 {
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/logic/service/fight/action"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// 14. 若遇到天敌, 则战斗开始时连续害怕 n 回合;(a1: n)
|
||||
@@ -17,8 +23,19 @@ func (e *NewSel14) TurnStart(fattack *action.SelectSkillAction, sattack *action.
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return
|
||||
}
|
||||
evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(e.Ctx().Our.CurrentPet.ID)].NaturalEnemy, " "))
|
||||
_, ok := lo.Find(evs, func(t uint32) bool {
|
||||
return t == uint32(e.Ctx().Opp.CurrentPet.ID)
|
||||
})
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
// 5. 获取状态效果实例并设置参数
|
||||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Fear))
|
||||
|
||||
//xmlres.PetMAP[e.Ctx().Our.CurrentPet.ID].SpAtk
|
||||
// 6. 给对手添加状态
|
||||
//然后这里是被动添加,所以对方不能消除
|
||||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.NewSel, 14, &NewSel14{})
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
package effect
|
||||
|
||||
import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/logic/service/fight/info"
|
||||
"blazing/logic/service/fight/input"
|
||||
"strings"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// 15. 若遇到天敌, 则整个战斗中对天敌的伤害减少 n%;(a1: 0-100 百分比)
|
||||
@@ -10,6 +17,26 @@ type NewSel15 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel15) Damage_Mul(t *info.DamageZone) bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
evs := gconv.Uint32s(strings.Split(xmlres.PetMAP[int(e.Ctx().Our.CurrentPet.ID)].NaturalEnemy, " "))
|
||||
_, ok := lo.Find(evs, func(t uint32) bool {
|
||||
return t == uint32(e.Ctx().Opp.CurrentPet.ID)
|
||||
})
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
|
||||
if t.Type == info.DamageType.Red {
|
||||
reduceRatio := alpacadecimal.NewFromInt(100).Sub(e.Args()[0]).Div(alpacadecimal.NewFromInt(100))
|
||||
t.Damage = t.Damage.Mul(reduceRatio)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
func init() {
|
||||
input.InitEffect(input.EffectType.NewSel, 15, &NewSel15{})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user