166 lines
4.1 KiB
Go
166 lines
4.1 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"
|
||
"github.com/gogf/gf/v2/util/grand"
|
||
)
|
||
|
||
// Effect 851: 使对手随机进入害怕、失明、烧伤、冻伤、中毒其中{0}种异常状态
|
||
type Effect851 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect851) OnSkill() bool {
|
||
count := int(e.Args()[0].IntPart())
|
||
statusTypes := []int{
|
||
int(info.PetStatus.Fear),
|
||
int(info.PetStatus.Blind),
|
||
int(info.PetStatus.Burned),
|
||
int(info.PetStatus.Frozen),
|
||
int(info.PetStatus.Poisoned),
|
||
}
|
||
if count <= 0 {
|
||
return true
|
||
}
|
||
if count > len(statusTypes) {
|
||
count = len(statusTypes)
|
||
}
|
||
|
||
indices := grand.Perm(len(statusTypes))
|
||
for _, idx := range indices[:count] {
|
||
statusEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, statusTypes[idx])
|
||
if statusEffect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, statusEffect)
|
||
}
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 852: 附加自身最大体力{0}%的百分比伤害并恢复等量体力,恢复体力时若自身体力低于最大体力的1/{1}则恢复效果和百分比伤害翻倍
|
||
type Effect852 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect852) Skill_Use() bool {
|
||
maxHP := e.Ctx().Our.CurrentPet.GetMaxHP()
|
||
amount := maxHP.Mul(e.Args()[0]).Div(alpacadecimal.NewFromInt(100))
|
||
thresholdDivisor := e.Args()[1]
|
||
if thresholdDivisor.Cmp(alpacadecimal.Zero) > 0 {
|
||
threshold := maxHP.Div(thresholdDivisor)
|
||
if e.Ctx().Our.CurrentPet.GetHP().Cmp(threshold) < 0 {
|
||
amount = amount.Mul(alpacadecimal.NewFromInt(2))
|
||
}
|
||
}
|
||
if amount.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: amount,
|
||
})
|
||
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, amount)
|
||
return true
|
||
}
|
||
|
||
// Effect 853: 附加自身最大体力值与速度值总和{0}%的百分比伤害,每次使用增加{1}%,最高{2}%
|
||
type Effect853 struct {
|
||
AddLvelEffect
|
||
}
|
||
|
||
func (e *Effect853) Skill_Use() bool {
|
||
percent := e.GetADD(e.Args()[0], e.Args()[1], e.Args()[2])
|
||
base := e.Ctx().Our.CurrentPet.GetMaxHP().Add(e.Ctx().Our.GetProp(4))
|
||
damage := base.Mul(percent).Div(alpacadecimal.NewFromInt(100))
|
||
if damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: damage,
|
||
})
|
||
return true
|
||
}
|
||
|
||
// Effect 854: 令对手下1次使用的威力高于{0}的攻击技能无效
|
||
type Effect854 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect854) Skill_Use() bool {
|
||
addSubEffect(e.Ctx().Our, e.Ctx().Opp, &e.EffectNode, &Effect854Sub{}, -1)
|
||
return true
|
||
}
|
||
|
||
type Effect854Sub struct {
|
||
FixedDuration1Base
|
||
}
|
||
|
||
func (e *Effect854Sub) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.XML.Power <= int(e.Args()[0].IntPart()) {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().SkillEntity.SetMiss()
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
|
||
// Effect 855: 将下次受到的伤害{0}%反馈给对手
|
||
type Effect855 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect855) Skill_Use() bool {
|
||
addSubEffect(e.Ctx().Our, e.Ctx().Our, &e.EffectNode, &Effect855Sub{}, -1)
|
||
return true
|
||
}
|
||
|
||
type Effect855Sub struct {
|
||
FixedDuration1Base
|
||
}
|
||
|
||
func (e *Effect855Sub) DamageSubEx(zone *info.DamageZone) bool {
|
||
if zone == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if zone.Damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
reflectDamage := zone.Damage.Mul(e.Args()[0]).Div(alpacadecimal.NewFromInt(100))
|
||
if reflectDamage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: reflectDamage,
|
||
})
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 851, &Effect851{})
|
||
input.InitEffect(input.EffectType.Skill, 852, &Effect852{})
|
||
input.InitEffect(input.EffectType.Skill, 853, &Effect853{})
|
||
input.InitEffect(input.EffectType.Skill, 854, &Effect854{})
|
||
input.InitEffect(input.EffectType.Skill, 855, &Effect855{})
|
||
}
|