130 lines
2.8 KiB
Go
130 lines
2.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"
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
|
)
|
|
|
|
// Effect 1382: 命中后获得{0}层自然祝福,若造成的伤害高于{1}则额外获得{2}层自然祝福
|
|
type Effect1382 struct{ node.EffectNode }
|
|
|
|
func (e *Effect1382) Skill_Use() bool {
|
|
if len(e.Args()) < 3 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.AttackTime == 0 {
|
|
return true
|
|
}
|
|
|
|
layers := int(e.Args()[0].IntPart())
|
|
if e.Ctx().Our.SumDamage.Cmp(e.Args()[1]) > 0 {
|
|
layers += int(e.Args()[2].IntPart())
|
|
}
|
|
if layers <= 0 {
|
|
return true
|
|
}
|
|
|
|
grantNaturalBlessing(e.Ctx().Our, e.Ctx().Our, layers)
|
|
return true
|
|
}
|
|
|
|
type Effect1382Sub struct {
|
|
node.EffectNode
|
|
layers int
|
|
}
|
|
|
|
func (e *Effect1382Sub) SetArgs(t *input.Input, a ...int) {
|
|
e.EffectNode.SetArgs(t, a...)
|
|
e.Duration(-1)
|
|
e.CanStack(false)
|
|
if len(a) > 0 {
|
|
e.layers = a[0]
|
|
}
|
|
}
|
|
|
|
func (e *Effect1382Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
|
if e.layers <= 0 {
|
|
return true
|
|
}
|
|
|
|
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
|
if current == nil || current.SkillEntity == nil || current.SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
|
|
current.SkillEntity.XML.Priority += e.layers
|
|
return true
|
|
}
|
|
|
|
func (e *Effect1382Sub) DamageLockEx(zone *info.DamageZone) bool {
|
|
if zone == nil || e.layers <= 0 || zone.Damage.Cmp(alpacadecimal.Zero) <= 0 {
|
|
return true
|
|
}
|
|
|
|
rate := hundred.Sub(alpacadecimal.NewFromInt(int64(e.layers * 8)))
|
|
if rate.Cmp(alpacadecimal.Zero) < 0 {
|
|
rate = alpacadecimal.Zero
|
|
}
|
|
zone.Damage = zone.Damage.Mul(rate).Div(hundred)
|
|
return true
|
|
}
|
|
|
|
func (e *Effect1382Sub) EFFect_Befer(in *input.Input, effEffect input.Effect) bool {
|
|
if e.layers <= 0 || in != e.Ctx().Opp || !input.IS_Stat(effEffect) {
|
|
return true
|
|
}
|
|
|
|
ok, _, _ := e.Input.Player.Roll(25, 100)
|
|
if ok {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
func naturalBlessingEffect(target *input.Input) *Effect1382Sub {
|
|
if target == nil {
|
|
return nil
|
|
}
|
|
|
|
for _, effect := range target.Effects {
|
|
if sub, ok := effect.(*Effect1382Sub); ok && sub.Alive() {
|
|
return sub
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func grantNaturalBlessing(owner, target *input.Input, layers int) {
|
|
if owner == nil || target == nil || layers <= 0 {
|
|
return
|
|
}
|
|
|
|
if sub := naturalBlessingEffect(target); sub != nil {
|
|
sub.layers += layers
|
|
return
|
|
}
|
|
|
|
effect := owner.InitEffect(input.EffectType.Sub, 1382, layers)
|
|
if effect != nil {
|
|
target.AddEffect(owner, effect)
|
|
}
|
|
}
|
|
|
|
func consumeNaturalBlessing(target *input.Input) int {
|
|
sub := naturalBlessingEffect(target)
|
|
if sub == nil {
|
|
return 0
|
|
}
|
|
|
|
layers := sub.layers
|
|
sub.Alive(false)
|
|
sub.layers = 0
|
|
return layers
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 1382, &Effect1382{})
|
|
input.InitEffect(input.EffectType.Sub, 1382, &Effect1382Sub{})
|
|
}
|