151 lines
3.8 KiB
Go
151 lines
3.8 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/action"
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
"blazing/logic/service/fight/node"
|
||
"math"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
)
|
||
|
||
// Effect 1248: 对手处于异常状态时{0}%令对手{1}
|
||
type Effect1248 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1248) Skill_Use() bool {
|
||
if len(e.Args()) < 2 || !e.Ctx().Opp.StatEffect_Exist_all() {
|
||
return true
|
||
}
|
||
|
||
success, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100)
|
||
if !success {
|
||
return true
|
||
}
|
||
|
||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(e.Args()[1].IntPart()))
|
||
if statusEffect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1249: 造成伤害的{0}%恢复自身体力,若对手处于异常状态则附加等量百分比伤害
|
||
type Effect1249 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1249) Skill_Use() bool {
|
||
if len(e.Args()) == 0 || e.Ctx().Our.SumDamage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
healAmount := e.Ctx().Our.SumDamage.Mul(e.Args()[0]).Div(alpacadecimal.NewFromInt(100))
|
||
if healAmount.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, healAmount)
|
||
if e.Ctx().Opp.StatEffect_Exist_all() {
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: healAmount,
|
||
})
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1250: {0}回合内自身能力提升状态消失则下回合自身必定致命一击
|
||
type Effect1250 struct {
|
||
RoundEffectArg0Base
|
||
}
|
||
|
||
func (e *Effect1250) PropBefer(source *input.Input, prop int8, level int8) bool {
|
||
if prop < 0 || int(prop) >= len(e.Ctx().Our.Prop) {
|
||
return true
|
||
}
|
||
if level != 0 || e.Ctx().Our.Prop[prop] <= 0 {
|
||
return true
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1250)
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
|
||
type Effect1250Sub struct {
|
||
FixedDuration1Base
|
||
}
|
||
|
||
func (e *Effect1250Sub) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().SkillEntity.XML.CritRate = 16
|
||
return true
|
||
}
|
||
|
||
// Effect 1251: 自身体力低于200时必定先手
|
||
type Effect1251 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1251) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if e.Ctx().Our.CurrentPet.GetHP().IntPart() >= 200 {
|
||
return true
|
||
}
|
||
|
||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||
if current == nil || current.SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
current.SkillEntity.XML.Priority = math.MaxInt
|
||
return true
|
||
}
|
||
|
||
// Effect 1252: 自身体力低于1/{0}时造成的伤害为{1}倍,低于1/{2}时伤害为{3}倍
|
||
type Effect1252 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1252) Damage_Mul(zone *info.DamageZone) bool {
|
||
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 4 {
|
||
return true
|
||
}
|
||
|
||
currentHP := e.Ctx().Our.CurrentPet.GetHP()
|
||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
|
||
if e.Args()[2].Cmp(alpacadecimal.Zero) > 0 {
|
||
threshold := maxHP.Div(e.Args()[2])
|
||
if currentHP.Cmp(threshold) < 0 {
|
||
zone.Mul(int(e.Args()[3].IntPart()))
|
||
return true
|
||
}
|
||
}
|
||
|
||
if e.Args()[0].Cmp(alpacadecimal.Zero) > 0 {
|
||
threshold := maxHP.Div(e.Args()[0])
|
||
if currentHP.Cmp(threshold) < 0 {
|
||
zone.Mul(int(e.Args()[1].IntPart()))
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1248, &Effect1248{})
|
||
input.InitEffect(input.EffectType.Skill, 1249, &Effect1249{})
|
||
input.InitEffect(input.EffectType.Skill, 1250, &Effect1250{})
|
||
input.InitEffect(input.EffectType.Sub, 1250, &Effect1250Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1251, &Effect1251{})
|
||
input.InitEffect(input.EffectType.Skill, 1252, &Effect1252{})
|
||
}
|