278 lines
6.4 KiB
Go
278 lines
6.4 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"
|
||
)
|
||
|
||
var effect1508IgnoredImmunityIDs = map[int]struct{}{
|
||
170: {},
|
||
525: {},
|
||
570: {},
|
||
850: {},
|
||
1011: {},
|
||
1511: {},
|
||
}
|
||
|
||
func applyRandomStatuses1510(owner, target *input.Input, count int) bool {
|
||
if owner == nil || target == nil || count <= 0 {
|
||
return false
|
||
}
|
||
if count > len(effect1507Statuses) {
|
||
count = len(effect1507Statuses)
|
||
}
|
||
|
||
triggered := false
|
||
indexes := grand.Perm(len(effect1507Statuses))
|
||
for _, idx := range indexes[:count] {
|
||
statusEffect := owner.InitEffect(input.EffectType.Status, effect1507Statuses[idx])
|
||
if statusEffect == nil {
|
||
continue
|
||
}
|
||
before := len(target.Effects)
|
||
target.AddEffect(owner, statusEffect)
|
||
if len(target.Effects) > before {
|
||
triggered = true
|
||
}
|
||
}
|
||
return triggered
|
||
}
|
||
|
||
// Effect 1508: 先出手时无视攻击免疫效果
|
||
type Effect1508 struct {
|
||
node.EffectNode
|
||
disabled []input.Effect
|
||
}
|
||
|
||
func (e *Effect1508) SkillHit() bool {
|
||
if !e.IsFirst() || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
e.disabled = e.disabled[:0]
|
||
for _, eff := range e.Ctx().Opp.Effects {
|
||
if eff == nil || !eff.Alive() {
|
||
continue
|
||
}
|
||
if _, ok := effect1508IgnoredImmunityIDs[int(eff.ID().Suffix())]; !ok {
|
||
continue
|
||
}
|
||
|
||
eff.Alive(false)
|
||
e.disabled = append(e.disabled, eff)
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1508) restoreDisabled() {
|
||
for _, eff := range e.disabled {
|
||
if eff == nil {
|
||
continue
|
||
}
|
||
eff.Alive(true)
|
||
}
|
||
e.disabled = e.disabled[:0]
|
||
}
|
||
|
||
func (e *Effect1508) Skill_Use() bool {
|
||
e.restoreDisabled()
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1508) Action_end() bool {
|
||
e.restoreDisabled()
|
||
return true
|
||
}
|
||
|
||
// Effect 1509: 令对手全属性-{0}且随机{1}个技能PP值归零,技能无效时消耗自身全部体力并令对手全属性-1,然后对手下3次使用技能消耗的PP值为3倍
|
||
type Effect1509 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1509) Skill_Use() bool {
|
||
if len(e.Args()) < 2 {
|
||
return true
|
||
}
|
||
|
||
skill := e.Ctx().SkillEntity
|
||
if skill != nil && skill.AttackTime == 0 {
|
||
e.Ctx().Our.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: e.Ctx().Our.CurrentPet.GetMaxHP(),
|
||
})
|
||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, 1)
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1509)
|
||
if effect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
applyAllPropDown(e.Ctx().Our, e.Ctx().Opp, int8(e.Args()[0].IntPart()))
|
||
zeroRandomSkillPP(e.Ctx().Opp, int(e.Args()[1].IntPart()))
|
||
return true
|
||
}
|
||
|
||
type Effect1509Sub struct {
|
||
node.EffectNode
|
||
remaining int
|
||
}
|
||
|
||
func (e *Effect1509Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.Duration(-1)
|
||
e.remaining = 3
|
||
}
|
||
|
||
func (e *Effect1509Sub) HookPP(count *int) bool {
|
||
if e.remaining <= 0 {
|
||
e.Alive(false)
|
||
return true
|
||
}
|
||
|
||
*count *= 3
|
||
e.remaining--
|
||
if e.remaining <= 0 {
|
||
e.Alive(false)
|
||
}
|
||
return true
|
||
}
|
||
|
||
// Effect 1510: {0}回合内对手主动切换精灵则登场精灵{1}%随机进入{2}种异常状态
|
||
type Effect1510 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1510) Skill_Use() bool {
|
||
if len(e.Args()) < 3 {
|
||
return true
|
||
}
|
||
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1510, e.SideEffectArgs...)
|
||
if effect != nil {
|
||
e.Ctx().Opp.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1510Sub struct {
|
||
node.EffectNode
|
||
pending bool
|
||
}
|
||
|
||
func (e *Effect1510Sub) SetArgs(t *input.Input, a ...int) {
|
||
e.EffectNode.SetArgs(t, a...)
|
||
e.CanStack(false)
|
||
if len(a) > 0 {
|
||
e.Duration(a[0])
|
||
}
|
||
}
|
||
|
||
func (e *Effect1510Sub) SwitchOut(in *input.Input) bool {
|
||
if in != e.Ctx().Our || e.Ctx().Our.CurrentPet == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().Our.CurrentPet.Info.Hp > 0 {
|
||
e.pending = true
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1510Sub) SwitchIn(in *input.Input) bool {
|
||
if !e.pending || in != e.Ctx().Our || len(e.Args()) < 3 {
|
||
return true
|
||
}
|
||
|
||
e.pending = false
|
||
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
|
||
if !success {
|
||
return true
|
||
}
|
||
|
||
applyRandomStatuses1510(e.Ctx().Opp, e.Ctx().Our, int(e.Args()[2].IntPart()))
|
||
return true
|
||
}
|
||
|
||
// Effect 1511: 先出手时免疫当回合受到的攻击伤害,若对手为自身天敌则免疫并反弹给对手造成伤害值{0}%的百分比伤害
|
||
type Effect1511 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1511) DamageLockEx(zone *info.DamageZone) bool {
|
||
if !e.IsFirst() || zone == nil || zone.Type != info.DamageType.Red || zone.Damage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
damage := zone.Damage
|
||
zone.Damage = alpacadecimal.Zero
|
||
|
||
if !e.ISNaturalEnemy() || len(e.Args()) == 0 || e.Args()[0].Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
reflectDamage := damage.Mul(e.Args()[0]).Div(hundred)
|
||
if reflectDamage.Cmp(alpacadecimal.Zero) <= 0 {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Percent,
|
||
Damage: reflectDamage,
|
||
})
|
||
return true
|
||
}
|
||
|
||
// Effect 1512: 集结天幕四龙之神力,使自身下2回合先制+3且攻击必定命中、必定致命
|
||
type Effect1512 struct {
|
||
node.EffectNode
|
||
}
|
||
|
||
func (e *Effect1512) Skill_Use() bool {
|
||
effect := e.Ctx().Our.InitEffect(input.EffectType.Sub, 1512)
|
||
if effect != nil {
|
||
e.Ctx().Our.AddEffect(e.Ctx().Our, effect)
|
||
}
|
||
return true
|
||
}
|
||
|
||
type Effect1512Sub struct {
|
||
FixedDuration2Base
|
||
}
|
||
|
||
func (e *Effect1512Sub) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
current := actionByPlayer(fattack, sattack, e.Ctx().Our.UserID)
|
||
if current == nil || current.SkillEntity == nil {
|
||
return true
|
||
}
|
||
|
||
current.SkillEntity.XML.Priority += 3
|
||
return true
|
||
}
|
||
|
||
func (e *Effect1512Sub) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
||
return true
|
||
}
|
||
|
||
e.Ctx().SkillEntity.XML.MustHit = 1
|
||
e.Ctx().SkillEntity.XML.CritRate = 16
|
||
return true
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.Skill, 1508, &Effect1508{})
|
||
input.InitEffect(input.EffectType.Skill, 1509, &Effect1509{})
|
||
input.InitEffect(input.EffectType.Sub, 1509, &Effect1509Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1510, &Effect1510{})
|
||
input.InitEffect(input.EffectType.Sub, 1510, &Effect1510Sub{})
|
||
input.InitEffect(input.EffectType.Skill, 1511, &Effect1511{})
|
||
input.InitEffect(input.EffectType.Skill, 1512, &Effect1512{})
|
||
input.InitEffect(input.EffectType.Sub, 1512, &Effect1512Sub{})
|
||
}
|