Files
bl/logic/service/fight/effect/1448_1472.go
xinian 78a68148ce
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
chore: update fight logic and effect implementations
2026-04-05 02:25:44 +08:00

615 lines
20 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"
)
const petStatusRage info.EnumPetStatus = 31
func addStatusByID(owner, target *input.Input, statusID int) bool {
if owner == nil || target == nil {
return false
}
eff := owner.InitEffect(input.EffectType.Status, statusID)
if eff == nil {
return false
}
target.AddEffect(owner, eff)
return true
}
func damageByPercent(owner, target *input.Input, percent int64) {
if owner == nil || target == nil || percent <= 0 {
return
}
target.Damage(owner, &info.DamageZone{Type: info.DamageType.Percent, Damage: alpacadecimal.NewFromInt(percent)})
}
func damageByFixed(owner, target *input.Input, dmg int64) {
if owner == nil || target == nil || dmg <= 0 {
return
}
target.Damage(owner, &info.DamageZone{Type: info.DamageType.Fixed, Damage: alpacadecimal.NewFromInt(dmg)})
}
func randomSkillPPZero(target *input.Input, count int) {
zeroRandomSkillPP(target, count)
}
// Effect 1448: 自身体力低于最大体力的1/{0}时造成的伤害提升{1}%
type Effect1448 struct{ node.EffectNode }
func (e *Effect1448) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 || e.CarrierInput().CurPet[0] == nil {
return true
}
maxHP := e.CarrierInput().CurPet[0].GetMaxHP()
curHP := e.CarrierInput().CurPet[0].GetHP()
if curHP.Mul(e.Args()[0]).Cmp(maxHP) >= 0 {
return true
}
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[1])).Div(hundred)
return true
}
// Effect 1449: {0}回合内对手无法通过自身技能恢复体力且受到原本恢复量1/{1}的百分比伤害
type Effect1449 struct{ node.EffectNode }
func (e *Effect1449) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1449, e.SideEffectArgs...)
if eff != nil {
e.TargetInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1449Sub struct {
RoundEffectArg0Base
}
func (e *Effect1449Sub) Heal_Pre(_ action.BattleActionI, amount *int) bool {
if amount == nil || len(e.Args()) < 2 {
return true
}
damage := alpacadecimal.NewFromInt(int64(*amount)).Div(e.Args()[1])
if damage.Cmp(alpacadecimal.Zero) > 0 {
e.CarrierInput().Damage(e.CarrierInput(), &info.DamageZone{Type: info.DamageType.Percent, Damage: damage})
}
*amount = 0
return true
}
// Effect 1450: 吸取对手{0}点体力若对手任意1项技能PP值小于{1}点则吸取效果翻倍
type Effect1450 struct{ node.EffectNode }
func (e *Effect1450) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
drain := e.Args()[0]
for _, s := range e.TargetInput().CurPet[0].Info.SkillList {
if s.PP < uint32(e.Args()[1].IntPart()) {
drain = drain.Mul(alpacadecimal.NewFromInt(2))
break
}
}
e.TargetInput().Damage(e.CarrierInput(), &info.DamageZone{Type: info.DamageType.Fixed, Damage: drain})
e.CarrierInput().Heal(e.CarrierInput(), &action.SelectSkillAction{}, drain)
return true
}
// Effect 1451: 若自身体力高于对手则获得{0}点护盾若自身体力低于对手则恢复自身最大体力的1/{1}
type Effect1451 struct{ node.EffectNode }
func (e *Effect1451) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
if e.CarrierInput().CurPet[0].GetHP().Cmp(e.TargetInput().CurPet[0].GetHP()) > 0 {
e.CarrierInput().AddShield(e.Args()[0])
return true
}
heal := e.CarrierInput().CurPet[0].GetMaxHP().Div(e.Args()[1])
e.CarrierInput().Heal(e.CarrierInput(), &action.SelectSkillAction{}, heal)
return true
}
// Effect 1452: 召唤龙神,使自身下{0}回合获得战之龙魂效果
type Effect1452 struct{ node.EffectNode }
func (e *Effect1452) Skill_Use() bool {
if len(e.Args()) == 0 {
return true
}
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1452, e.SideEffectArgs...)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1452Sub struct{ RoundEffectArg0Base }
func (e *Effect1452Sub) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(125)).Div(hundred)
return true
}
// Effect 1453: 召唤龙神,使自身下{0}回合获得御之龙魂效果
type Effect1453 struct{ node.EffectNode }
func (e *Effect1453) Skill_Use() bool {
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1453, e.SideEffectArgs...)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1453Sub struct{ RoundEffectArg0Base }
func (e *Effect1453Sub) DamageDivEx(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red {
return true
}
zone.Damage = zone.Damage.Mul(hundred).Div(alpacadecimal.NewFromInt(80))
return true
}
// Effect 1454: 1回合做{0}-{1}次攻击,每次攻击有{2}%的概率附加{3}点固定伤害
type Effect1454 struct{ node.EffectNode }
func (e *Effect1454) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 4 {
return true
}
hits := int(e.Args()[0].IntPart())
if maxHits := int(e.Args()[1].IntPart()); maxHits > hits {
hits += grand.Intn(maxHits - hits + 1)
}
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(int64(hits)))
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100); ok {
zone.Damage = zone.Damage.Add(e.Args()[3])
}
return true
}
// Effect 1455: 1回合做{0}-{1}次攻击,若本回合攻击次数达到最大则八岐大蛇进入暴怒,必定秒杀对手
type Effect1455 struct{ node.EffectNode }
func (e *Effect1455) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) < 2 {
return true
}
maxHits := int(e.Args()[1].IntPart())
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(int64(maxHits)))
if maxHits > 0 {
e.OpponentInput().Damage(e.CarrierInput(), &info.DamageZone{Type: info.DamageType.Fixed, Damage: e.OpponentInput().CurPet[0].GetHP()})
}
return true
}
// Effect 1456: 消耗自身全部体力使对手受到自身最大体力1/{0}的百分比伤害,同时使自身下只出场精灵前{1}回合免疫受到的攻击伤害
type Effect1456 struct{ node.EffectNode }
func (e *Effect1456) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
maxHP := e.CarrierInput().CurPet[0].GetMaxHP()
e.CarrierInput().Damage(e.CarrierInput(), &info.DamageZone{Type: info.DamageType.Fixed, Damage: e.CarrierInput().CurPet[0].GetHP()})
e.TargetInput().Damage(e.CarrierInput(), &info.DamageZone{Type: info.DamageType.Percent, Damage: maxHP.Div(e.Args()[0])})
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1456, e.SideEffectArgs...)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1456Sub struct{ RoundEffectArg0Base }
func (e *Effect1456Sub) DamageLockEx(zone *info.DamageZone) bool {
if zone != nil && zone.Type == info.DamageType.Red {
zone.Damage = alpacadecimal.Zero
}
return true
}
// Effect 1457: {0}回合内攻击技能{1}%令对手{2},未触发则使对手随机{3}项技能PP值归零
type Effect1457 struct{ node.EffectNode }
func (e *Effect1457) OnSkill() bool {
if len(e.Args()) < 4 || e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
if success {
addStatusByID(e.CarrierInput(), e.TargetInput(), int(e.Args()[2].IntPart()))
return true
}
randomSkillPPZero(e.TargetInput(), int(e.Args()[3].IntPart()))
return true
}
// Effect 1458: {0}回合内每回合{1}%对手属性技能无效,未触发则{2}%令对手{3}
type Effect1458 struct{ node.EffectNode }
func (e *Effect1458) Skill_Use() bool {
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1458, e.SideEffectArgs...)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1458Sub struct{ RoundEffectArg0Base }
func (e *Effect1458Sub) SkillHit_ex() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() != info.Category.STATUS {
return true
}
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
if success {
e.Ctx().SkillEntity.XML.MustHit = 1
return true
}
if len(e.Args()) >= 4 {
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[2].IntPart()), 100); ok {
addStatusByID(e.CarrierInput(), e.TargetInput(), int(e.Args()[3].IntPart()))
}
}
return true
}
// Effect 1459: 先出手时{0}%令对手{1},未触发则对手{2}回合属性技能无效
type Effect1459 struct{ node.EffectNode }
func (e *Effect1459) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.IsFirst() || len(e.Args()) < 3 {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
addStatusByID(e.CarrierInput(), e.TargetInput(), int(e.Args()[1].IntPart()))
return true
}
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1459, e.SideEffectArgs...)
if eff != nil {
e.TargetInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1459Sub struct{ RoundEffectArg0Base }
func (e *Effect1459Sub) SkillHit_ex() bool {
if e.Ctx().SkillEntity != nil && e.Ctx().SkillEntity.Category() == info.Category.STATUS {
e.Ctx().SkillEntity.XML.MustHit = 1
}
return true
}
// Effect 1460: 附加{0}值{1}的{2}%的百分比伤害,先出手时附加效果翻倍
type Effect1460 struct{ node.EffectNode }
func (e *Effect1460) DamageAdd(zone *info.DamageZone) bool {
if zone == nil || len(e.Args()) < 3 {
return true
}
bonus := e.Args()[1].Mul(e.Args()[2]).Div(hundred)
if e.IsFirst() {
bonus = bonus.Mul(alpacadecimal.NewFromInt(2))
}
zone.Damage = zone.Damage.Add(bonus)
return true
}
// Effect 1461: 恢复自身最大体力的1/{0},体力低于对手时附加等量百分比伤害
type Effect1461 struct{ node.EffectNode }
func (e *Effect1461) Skill_Use() bool {
if len(e.Args()) == 0 {
return true
}
heal := e.CarrierInput().CurPet[0].GetMaxHP().Div(e.Args()[0])
e.CarrierInput().Heal(e.CarrierInput(), &action.SelectSkillAction{}, heal)
if e.CarrierInput().CurPet[0].GetHP().Cmp(e.TargetInput().CurPet[0].GetHP()) < 0 {
e.TargetInput().Damage(e.CarrierInput(), &info.DamageZone{Type: info.DamageType.Percent, Damage: heal})
}
return true
}
// Effect 1462: {0}回合内每回合使用技能附加{1}点固定伤害,附加时若自身不处于能力提升状态则固定伤害翻倍
type Effect1462 struct{ node.EffectNode }
func (e *Effect1462) Skill_Use() bool {
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1462, e.SideEffectArgs...)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1462Sub struct{ RoundEffectArg0Base }
func (e *Effect1462Sub) DamageAdd(zone *info.DamageZone) bool {
if zone == nil || len(e.Args()) < 2 {
return true
}
bonus := e.Args()[1]
boosted := false
for _, v := range e.CarrierInput().Prop[:] {
if v > 0 {
boosted = true
break
}
}
if !boosted {
bonus = bonus.Mul(alpacadecimal.NewFromInt(2))
}
zone.Damage = zone.Damage.Add(bonus)
return true
}
// Effect 1463: 先出手时本回合自身下次死亡时恢复全部体力并解除自身的异常状态和能力下降状态
type Effect1463 struct{ node.EffectNode }
func (e *Effect1463) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.IsFirst() {
return true
}
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1463)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1463Sub struct{ FixedDuration1Base }
func (e *Effect1463Sub) DamageLock(zone *info.DamageZone) bool {
if zone == nil || zone.Damage.Cmp(alpacadecimal.Zero) <= 0 {
return true
}
if e.CarrierInput().CurPet[0].GetHP().Cmp(zone.Damage) > 0 {
return true
}
zone.Damage = alpacadecimal.Zero
e.CarrierInput().Heal(e.CarrierInput(), &action.SelectSkillAction{}, e.CarrierInput().CurPet[0].GetMaxHP())
return true
}
// Effect 1464: 当回合攻击击败对手时,若对手处于{0}状态则{1}%的概率令对手下1只出场精灵进入{2}状态
type Effect1464 struct{ node.EffectNode }
func (e *Effect1464) OnSkill() bool {
if e.TargetInput().CurPet[0].Info.Hp > 0 || len(e.Args()) < 3 {
return true
}
if !e.TargetInput().StatEffect_Exist(info.EnumPetStatus(e.Args()[0].IntPart())) {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
addStatusByID(e.CarrierInput(), e.TargetInput(), int(e.Args()[2].IntPart()))
}
return true
}
// Effect 1465: 先出手时50%的概率打出致命一击,未触发则令对手全属性-{0}
type Effect1465 struct{ node.EffectNode }
func (e *Effect1465) ActionStart(a, b *action.SelectSkillAction) bool {
if !e.IsFirst() || len(e.Args()) == 0 {
return true
}
if ok, _, _ := e.Input.Player.Roll(50, 100); ok {
if e.Ctx().SkillEntity != nil {
e.Ctx().SkillEntity.XML.CritRate = 16
}
return true
}
for i := range e.TargetInput().Prop[:] {
e.TargetInput().SetProp(e.CarrierInput(), int8(i), int8(-e.Args()[0].IntPart()))
}
return true
}
// Effect 1466: {0}回合内若对手攻击技能未命中则{1}%令对手{2}
type Effect1466 struct{ node.EffectNode }
func (e *Effect1466) Skill_Use() bool {
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1466, e.SideEffectArgs...)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1466Sub struct{ RoundEffectArg0Base }
func (e *Effect1466Sub) SkillHit_ex() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.AttackTime == 0 || len(e.Args()) < 3 {
return true
}
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100); ok {
addStatusByID(e.CarrierInput(), e.TargetInput(), int(e.Args()[2].IntPart()))
}
return true
}
// Effect 1467: 随机使自身{0}项能力值+{1},先出手时提升效果翻倍
type Effect1467 struct{ node.EffectNode }
func (e *Effect1467) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
boost := int(e.Args()[1].IntPart())
if e.IsFirst() {
boost *= 2
}
count := int(e.Args()[0].IntPart())
if count <= 0 {
return true
}
indexes := grand.Perm(6)
for i := 0; i < count && i < len(indexes); i++ {
e.CarrierInput().SetProp(e.CarrierInput(), int8(indexes[i]), int8(boost))
}
return true
}
// Effect 1468: 消除双方能力提升状态、能力下降状态和护盾效果,消除任意一项成功则附加{0}点固定伤害且令对手随机{1}个技能PP值归零
type Effect1468 struct{ node.EffectNode }
func (e *Effect1468) Skill_Use() bool {
if len(e.Args()) < 2 {
return true
}
triggered := false
for _, target := range []*input.Input{e.CarrierInput(), e.TargetInput()} {
for _, eff := range target.Effects {
if eff != nil && eff.Alive() {
eff.Alive(false)
triggered = true
}
}
}
if triggered {
damageByFixed(e.CarrierInput(), e.TargetInput(), e.Args()[0].IntPart())
randomSkillPPZero(e.TargetInput(), int(e.Args()[1].IntPart()))
}
return true
}
// Effect 1469: {0}回合内自身造成的固定伤害、百分比伤害提升{1}%
type Effect1469 struct{ node.EffectNode }
func (e *Effect1469) Skill_Use() bool {
eff := e.CarrierInput().InitEffect(input.EffectType.Sub, 1469, e.SideEffectArgs...)
if eff != nil {
e.CarrierInput().AddEffect(e.CarrierInput(), eff)
}
return true
}
type Effect1469Sub struct{ RoundEffectArg0Base }
func (e *Effect1469Sub) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || len(e.Args()) < 2 || (zone.Type != info.DamageType.Fixed && zone.Type != info.DamageType.Percent) {
return true
}
zone.Damage = zone.Damage.Mul(hundred.Add(e.Args()[1])).Div(hundred)
return true
}
// Effect 1470: 自身天赋值越高则技能威力越大
type Effect1470 struct{ node.EffectNode }
func (e *Effect1470) SkillHit() bool {
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
return true
}
e.Ctx().SkillEntity.XML.Power += int(e.CarrierInput().CurPet[0].Info.Dv)
return true
}
// Effect 1471: 消除对手能力提升状态,消除成功则{0}%令对手{1}未触发则恢复自身最大体力的1/{2}
type Effect1471 struct{ node.EffectNode }
func (e *Effect1471) Skill_Use() bool {
if len(e.Args()) < 3 {
return true
}
removed := false
for _, eff := range e.TargetInput().Effects {
if eff != nil && eff.Alive() {
eff.Alive(false)
removed = true
}
}
if removed {
if ok, _, _ := e.Input.Player.Roll(int(e.Args()[0].IntPart()), 100); ok {
addStatusByID(e.CarrierInput(), e.TargetInput(), int(e.Args()[1].IntPart()))
}
return true
}
heal := e.CarrierInput().CurPet[0].GetMaxHP().Div(e.Args()[2])
e.CarrierInput().Heal(e.CarrierInput(), &action.SelectSkillAction{}, heal)
return true
}
// Effect 1472: 自身处于能力提升状态时造成的伤害提升{0}%,先出手时效果翻倍
type Effect1472 struct{ node.EffectNode }
func (e *Effect1472) Damage_Mul(zone *info.DamageZone) bool {
if zone == nil || zone.Type != info.DamageType.Red || len(e.Args()) == 0 {
return true
}
boosted := false
for _, v := range e.CarrierInput().Prop[:] {
if v > 0 {
boosted = true
break
}
}
if !boosted {
return true
}
percent := e.Args()[0]
if e.IsFirst() {
percent = percent.Mul(alpacadecimal.NewFromInt(2))
}
zone.Damage = zone.Damage.Mul(hundred.Add(percent)).Div(hundred)
return true
}
func init() {
input.InitEffect(input.EffectType.Skill, 1448, &Effect1448{})
input.InitEffect(input.EffectType.Skill, 1449, &Effect1449{})
input.InitEffect(input.EffectType.Sub, 1449, &Effect1449Sub{})
input.InitEffect(input.EffectType.Skill, 1450, &Effect1450{})
input.InitEffect(input.EffectType.Skill, 1451, &Effect1451{})
input.InitEffect(input.EffectType.Skill, 1452, &Effect1452{})
input.InitEffect(input.EffectType.Sub, 1452, &Effect1452Sub{})
input.InitEffect(input.EffectType.Skill, 1453, &Effect1453{})
input.InitEffect(input.EffectType.Sub, 1453, &Effect1453Sub{})
input.InitEffect(input.EffectType.Skill, 1454, &Effect1454{})
input.InitEffect(input.EffectType.Skill, 1455, &Effect1455{})
input.InitEffect(input.EffectType.Skill, 1456, &Effect1456{})
input.InitEffect(input.EffectType.Sub, 1456, &Effect1456Sub{})
input.InitEffect(input.EffectType.Skill, 1457, &Effect1457{})
input.InitEffect(input.EffectType.Skill, 1458, &Effect1458{})
input.InitEffect(input.EffectType.Sub, 1458, &Effect1458Sub{})
input.InitEffect(input.EffectType.Skill, 1459, &Effect1459{})
input.InitEffect(input.EffectType.Sub, 1459, &Effect1459Sub{})
input.InitEffect(input.EffectType.Skill, 1460, &Effect1460{})
input.InitEffect(input.EffectType.Skill, 1461, &Effect1461{})
input.InitEffect(input.EffectType.Skill, 1462, &Effect1462{})
input.InitEffect(input.EffectType.Sub, 1462, &Effect1462Sub{})
input.InitEffect(input.EffectType.Skill, 1463, &Effect1463{})
input.InitEffect(input.EffectType.Sub, 1463, &Effect1463Sub{})
input.InitEffect(input.EffectType.Skill, 1464, &Effect1464{})
input.InitEffect(input.EffectType.Skill, 1465, &Effect1465{})
input.InitEffect(input.EffectType.Skill, 1466, &Effect1466{})
input.InitEffect(input.EffectType.Sub, 1466, &Effect1466Sub{})
input.InitEffect(input.EffectType.Skill, 1467, &Effect1467{})
input.InitEffect(input.EffectType.Skill, 1468, &Effect1468{})
input.InitEffect(input.EffectType.Skill, 1469, &Effect1469{})
input.InitEffect(input.EffectType.Sub, 1469, &Effect1469Sub{})
input.InitEffect(input.EffectType.Skill, 1470, &Effect1470{})
input.InitEffect(input.EffectType.Skill, 1471, &Effect1471{})
input.InitEffect(input.EffectType.Skill, 1472, &Effect1472{})
}