263 lines
6.1 KiB
Go
263 lines
6.1 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
"blazing/logic/service/fight/node"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// Effect 1238: 全属性+{0},对手不为{1}系时强化效果翻倍
|
||
type Effect1238 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1238) OnSkill() bool {
|
||
if len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
|
||
boostValue := int8(e.Args()[0].IntPart())
|
||
if e.Ctx().Opp.CurrentPet.PetInfo.Type != int(e.Args()[1].IntPart()) {
|
||
boostValue *= 2
|
||
}
|
||
|
||
for i := 0; i < 6; i++ {
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(i), boostValue)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1239: 恢复自身最大体力的1/{0},自身体力低于1/{1}时造成等量百分比伤害
|
||
type Effect1239 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1239) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
healAmount := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[0])
|
||
if healAmount.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
lowHP := false
|
||
if e.Args()[1].Cmp(alpacadecimal.Zero) > 0 {
|
||
threshold := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[1])
|
||
lowHP = e.Ctx().Our.CurrentPet.GetHP().Cmp(threshold) < 0
|
||
}
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, nil, healAmount)
|
||
if lowHP {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: healAmount,
|
||
})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1240: 当回合未击败对手则下{0}次自身技能附加自身最大体力1/{1}的百分比伤害
|
||
type Effect1240 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1240) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || e.Ctx().Opp.CurrentPet.Info.Hp == 0 {
|
||
return true
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1240, int(e.Args()[0].IntPart()), int(e.Args()[1].IntPart()))
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1240Sub struct {
|
||
node.EffectNode
|
||
remaining int
|
||
divisor int
|
||
}
|
||
|
||
func (e *Effect1240Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
if len(a) > 0 {
|
||
e.remaining = a[0]
|
||
}
|
||
if len(a) > 1 {
|
||
e.divisor = a[1]
|
||
}
|
||
}
|
||
|
||
func (e *Effect1240Sub) OnSkill() bool {
|
||
if e.remaining <= 0 || e.divisor <= 0 {
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
|
||
damage := e.Ctx().Our.CurrentPet.GetMaxHP().Div(alpacadecimal.NewFromInt(int64(e.divisor)))
|
||
if damage.Cmp(alpacadecimal.Zero) > 0 {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: damage,
|
||
})
|
||
}
|
||
|
||
e.remaining--
|
||
if e.remaining <= 0 {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1241: 吸取对手{0}点固定体力,自身体力低于1/{1}时吸取效果翻倍
|
||
type Effect1241 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1241) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
drain := e.Args()[0]
|
||
if e.Args()[1].Cmp(alpacadecimal.Zero) > 0 {
|
||
threshold := e.Ctx().Our.CurrentPet.GetMaxHP().Div(e.Args()[1])
|
||
if e.Ctx().Our.CurrentPet.GetHP().Cmp(threshold) < 0 {
|
||
drain = drain.Mul(alpacadecimal.NewFromInt(2))
|
||
}
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: drain,
|
||
})
|
||
e.Ctx().Our.Heal(e.Ctx().Our, nil, drain)
|
||
return true
|
||
}
|
||
|
||
// Effect 1242: {0}%的概率伤害为{1}倍,未触发则下次翻倍概率额外提升{2}%且伤害提升变为{3}倍
|
||
type Effect1242 struct {
|
||
node.EffectNode
|
||
triggered bool
|
||
nextBonus int
|
||
boostedMode bool
|
||
}
|
||
|
||
func (e *Effect1242) SkillHit() bool {
|
||
skill := e.Ctx().SkillEntity
|
||
if skill == nil || skill.Category() == info.Category.STATUS || skill.AttackTime == 0 || len(e.Args()) < 4 {
|
||
return true
|
||
}
|
||
|
||
bonus := 0
|
||
if state := findEffect1242State(e.Ctx().Our, skill.XML.ID); state != nil {
|
||
bonus = state.bonusChance
|
||
e.boostedMode = true
|
||
}
|
||
|
||
chance := int(e.Args()[0].IntPart()) + bonus
|
||
if chance > 100 {
|
||
chance = 100
|
||
}
|
||
|
||
e.triggered, _, _ = e.Input.Player.Roll(chance, 100)
|
||
e.nextBonus = bonus + int(e.Args()[2].IntPart())
|
||
if e.triggered {
|
||
if state := findEffect1242State(e.Ctx().Our, skill.XML.ID); state != nil {
|
||
state.Alive(false)
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1242) Damage_Mul(zone *info.DamageZone) bool {
|
||
if !e.triggered || zone == nil || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
multiplier := int(e.Args()[1].IntPart())
|
||
if e.boostedMode {
|
||
multiplier = int(e.Args()[3].IntPart())
|
||
}
|
||
if multiplier > 1 {
|
||
zone.Mul(multiplier)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1242) Skill_Use() bool {
|
||
skill := e.Ctx().SkillEntity
|
||
if skill == nil || skill.Category() == info.Category.STATUS || skill.AttackTime == 0 || len(e.Args()) < 4 || e.triggered {
|
||
return true
|
||
}
|
||
|
||
if state := findEffect1242State(e.Ctx().Our, skill.XML.ID); state != nil {
|
||
state.bonusChance = e.nextBonus
|
||
return true
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1242, skill.XML.ID, e.nextBonus)
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1242Sub struct {
|
||
node.EffectNode
|
||
skillID int
|
||
bonusChance int
|
||
}
|
||
|
||
func (e *Effect1242Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
if len(a) > 0 {
|
||
e.skillID = a[0]
|
||
}
|
||
if len(a) > 1 {
|
||
e.bonusChance = a[1]
|
||
}
|
||
}
|
||
|
||
func (e *Effect1242Sub) SwitchOut(in *input.Input) bool {
|
||
if in == e.Ctx().Our {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func findEffect1242State(in *input.Input, skillID int) *Effect1242Sub {
|
||
if in == nil {
|
||
return nil
|
||
}
|
||
|
||
for i := len(in.Effects) - 1; i >= 0; i-- {
|
||
effect, ok := in.Effects[i].(*Effect1242Sub)
|
||
if !ok || !effect.Alive() || effect.skillID != skillID {
|
||
continue
|
||
}
|
||
return effect
|
||
}
|
||
return nil
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1238, &Effect1238{})
|
||
input.InitEffect(input.EffectType.Skill, 1239, &Effect1239{})
|
||
input.InitEffect(input.EffectType.Skill, 1240, &Effect1240{})
|
||
input.InitEffect(input.EffectType.Sub, 1240, &Effect1240Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1241, &Effect1241{})
|
||
input.InitEffect(input.EffectType.Skill, 1242, &Effect1242{})
|
||
input.InitEffect(input.EffectType.Sub, 1242, &Effect1242Sub{})
|
||
}
|