410 lines
11 KiB
Go
410 lines
11 KiB
Go
package effect
|
||
|
||
import (
|
||
"blazing/logic/service/fight/action"
|
||
"blazing/logic/service/fight/info"
|
||
"blazing/logic/service/fight/input"
|
||
|
||
"github.com/alpacahq/alpacadecimal"
|
||
"github.com/gogf/gf/v2/util/grand"
|
||
)
|
||
|
||
func bossJsonTransferPositive(from, to *input.Input) bool {
|
||
changed := false
|
||
for i := 0; i < 6; i++ {
|
||
if from.AttackValue.Prop[i] <= 0 {
|
||
continue
|
||
}
|
||
changed = true
|
||
stage := from.AttackValue.Prop[i]
|
||
from.AttackValue.Prop[i] = 0
|
||
to.AttackValue.Prop[i] += stage
|
||
if to.AttackValue.Prop[i] > 6 {
|
||
to.AttackValue.Prop[i] = 6
|
||
}
|
||
}
|
||
return changed
|
||
}
|
||
|
||
func bossJsonActionMatches(skill *info.SkillEntity, act *action.SelectSkillAction, userID uint32) bool {
|
||
if skill == nil || act == nil || act.SkillEntity == nil || act.PlayerID != userID {
|
||
return false
|
||
}
|
||
return act.SkillEntity.XML.ID == skill.XML.ID
|
||
}
|
||
|
||
// 41: 每回合恢复固定体力
|
||
type BossJsonEid41 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid41) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
heal := bossJsonFirstPositiveArg(e.Args(), 0)
|
||
if heal > 0 {
|
||
e.Ctx().Our.Heal(e.Ctx().Our, nil, alpacadecimal.NewFromInt(int64(heal)))
|
||
}
|
||
}
|
||
|
||
// 42: 迅捷,所有技能先制+n
|
||
type BossJsonEid42 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid42) ComparePre(fattack, sattack *action.SelectSkillAction) bool {
|
||
if !e.ownerActive() {
|
||
return true
|
||
}
|
||
priority := bossJsonIntArg(e.Args(), 0, 0)
|
||
if priority == 0 {
|
||
return true
|
||
}
|
||
userID := e.Ctx().Our.Player.GetInfo().UserID
|
||
if fattack != nil && fattack.PlayerID == userID && fattack.SkillEntity != nil {
|
||
fattack.SkillEntity.XML.Priority += priority
|
||
}
|
||
if sattack != nil && sattack.PlayerID == userID && sattack.SkillEntity != nil {
|
||
sattack.SkillEntity.XML.Priority += priority
|
||
}
|
||
return true
|
||
}
|
||
|
||
// 7: 致盲,闪避率提升n%
|
||
type BossJsonEid7 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid7) SkillHit_ex() bool {
|
||
if !e.ownerActive() || e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if e.Ctx().SkillEntity.AttackTime == 2 {
|
||
return true
|
||
}
|
||
hit, _, _ := e.Input.Player.Roll(bossJsonFirstPositiveArg(e.Args(), 0), 100)
|
||
if hit {
|
||
e.Ctx().SkillEntity.SetMiss()
|
||
}
|
||
return true
|
||
}
|
||
|
||
// 8: 锁定,n%打出致命一击
|
||
type BossJsonEid8 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid8) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
if !e.ownerActive() || !bossJsonIsAttackSkill(e.Ctx().SkillEntity) {
|
||
return true
|
||
}
|
||
e.Ctx().SkillEntity.XML.CritRate += bossJsonIntArg(e.Args(), 0, 0)
|
||
return true
|
||
}
|
||
|
||
// 45: 锁定,n%打出致命一击
|
||
type BossJsonEid45 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid45) ActionStart(a, b *action.SelectSkillAction) bool {
|
||
if !e.ownerActive() || !bossJsonIsAttackSkill(e.Ctx().SkillEntity) {
|
||
return true
|
||
}
|
||
e.Ctx().SkillEntity.XML.CritRate = bossJsonIntArg(e.Args(), 0, 0)
|
||
return true
|
||
}
|
||
|
||
// 77: 锋锐,每回合附加n点固定伤害
|
||
type BossJsonEid77 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid77) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
damage := bossJsonIntArg(e.Args(), 0, 0)
|
||
if damage <= 0 {
|
||
return
|
||
}
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{
|
||
Type: info.DamageType.Fixed,
|
||
Damage: alpacadecimal.NewFromInt(int64(damage)),
|
||
})
|
||
}
|
||
|
||
// 113: 对手使用技能后全属性-1
|
||
type BossJsonEid113 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid113) Action_end_ex() bool {
|
||
if !e.ownerActive() || e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
stage := int8(bossJsonFirstPositiveArg(e.Args(), 1))
|
||
bossJsonBoostAll(e.Ctx().Opp, e.Ctx().Our, -stage)
|
||
return true
|
||
}
|
||
|
||
// 144: 对手技能结束时,消除对手的能力提升
|
||
type BossJsonEid144 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid144) Action_end_ex() bool {
|
||
if !e.ownerActive() || e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
bossJsonClearPositive(e.Ctx().Opp)
|
||
return true
|
||
}
|
||
|
||
// 224: 首次死亡后恢复全部体力,并使全能力等级等于指定值
|
||
type BossJsonEid224 struct {
|
||
BossJsonEid0
|
||
used bool
|
||
}
|
||
|
||
func (e *BossJsonEid224) revive() bool {
|
||
if !e.ownerActive() || e.used || e.Ctx().Our.CurPet[0].Info.Hp != 0 {
|
||
return true
|
||
}
|
||
e.used = true
|
||
e.Ctx().Our.CurPet[0].Info.Hp = e.Ctx().Our.CurPet[0].Info.MaxHp
|
||
e.Ctx().Our.HealPP(-1)
|
||
stageSeed := bossJsonIntArg(e.Args(), len(e.Args())-1, 6)
|
||
stage := int8(stageSeed - 6)
|
||
if stage < 0 {
|
||
stage = 0
|
||
}
|
||
if stage > 6 {
|
||
stage = 6
|
||
}
|
||
bossJsonSetAll(e.Ctx().Our, stage)
|
||
return true
|
||
}
|
||
|
||
func (e *BossJsonEid224) Action_end() bool { return e.revive() }
|
||
func (e *BossJsonEid224) Action_end_ex() bool { return e.revive() }
|
||
|
||
// 2095: 对手存在能力提升或回合类效果时伤害提升
|
||
type BossJsonEid2095 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid2095) Damage_Mul(zone *info.DamageZone) bool {
|
||
if !e.ownerActive() || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
if !bossJsonHasPositive(e.Ctx().Opp) && !bossJsonAnyTurnEffect(e.Ctx().Opp) {
|
||
return true
|
||
}
|
||
bonus := bossJsonFirstPositiveArg(e.Args(), 0)
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(int64(100 + bonus))).Div(alpacadecimal.NewFromInt(100))
|
||
return true
|
||
}
|
||
|
||
// 2104: 回合开始提升体力上限;回合结束恢复已损失体力的一定比例
|
||
type BossJsonEid2104 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid2104) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
growPercent := bossJsonIntArg(e.Args(), 1, 0)
|
||
if growPercent <= 0 {
|
||
return
|
||
}
|
||
add := int(e.Ctx().Our.CurPet[0].Info.MaxHp) * growPercent / 100
|
||
if add <= 0 {
|
||
return
|
||
}
|
||
e.Ctx().Our.CurPet[0].Info.MaxHp += uint32(add)
|
||
e.Ctx().Our.CurPet[0].Info.Hp += uint32(add)
|
||
}
|
||
|
||
func (e *BossJsonEid2104) TurnEnd() {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
recoverPercent := bossJsonIntArg(e.Args(), 0, 0)
|
||
if recoverPercent <= 0 || e.Ctx().Our.CurPet[0].Info.MaxHp <= e.Ctx().Our.CurPet[0].Info.Hp {
|
||
return
|
||
}
|
||
missing := int(e.Ctx().Our.CurPet[0].Info.MaxHp - e.Ctx().Our.CurPet[0].Info.Hp)
|
||
heal := missing * recoverPercent / 100
|
||
if heal > 0 {
|
||
e.Ctx().Our.Heal(e.Ctx().Our, nil, alpacadecimal.NewFromInt(int64(heal)))
|
||
}
|
||
}
|
||
|
||
// 2103: 吸取对手能力提升,否则随机削弱并附加给自身;回合结束吸取固定体力
|
||
type BossJsonEid2103 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid2103) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
if bossJsonTransferPositive(e.Ctx().Opp, e.Ctx().Our) {
|
||
return
|
||
}
|
||
count := bossJsonIntArg(e.Args(), 0, 0)
|
||
stage := int8(bossJsonIntArg(e.Args(), 1, 0))
|
||
if count <= 0 || stage <= 0 {
|
||
return
|
||
}
|
||
used := map[int]struct{}{}
|
||
for len(used) < count && len(used) < 6 {
|
||
used[grand.Intn(6)] = struct{}{}
|
||
}
|
||
for idx := range used {
|
||
e.Ctx().Opp.SetProp(e.Ctx().Our, int8(idx), -stage)
|
||
e.Ctx().Our.SetProp(e.Ctx().Our, int8(idx), stage)
|
||
}
|
||
}
|
||
|
||
func (e *BossJsonEid2103) TurnEnd() {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
value := bossJsonIntArg(e.Args(), 2, 0)
|
||
if value <= 0 {
|
||
return
|
||
}
|
||
damage := alpacadecimal.NewFromInt(int64(value))
|
||
e.Ctx().Opp.Damage(e.Ctx().Our, &info.DamageZone{Type: info.DamageType.Fixed, Damage: damage})
|
||
e.Ctx().Our.Heal(e.Ctx().Our, nil, damage)
|
||
}
|
||
|
||
// 2105: 低血量时获得若干回合力量(这里按伤害翻倍处理)
|
||
type BossJsonEid2105 struct {
|
||
BossJsonEid0
|
||
rounds int
|
||
}
|
||
|
||
func (e *BossJsonEid2105) Damage_Mul(zone *info.DamageZone) bool {
|
||
if !e.ownerActive() || e.rounds <= 0 || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(2))
|
||
return true
|
||
}
|
||
|
||
func (e *BossJsonEid2105) TurnEnd() {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
if e.rounds > 0 {
|
||
e.rounds--
|
||
}
|
||
threshold := bossJsonIntArg(e.Args(), 0, 0)
|
||
grant := bossJsonIntArg(e.Args(), 1, 0)
|
||
if threshold <= 0 || grant <= 0 || e.Ctx().Our.CurPet[0].Info.MaxHp == 0 {
|
||
return
|
||
}
|
||
if int(e.Ctx().Our.CurPet[0].Info.Hp)*100 < int(e.Ctx().Our.CurPet[0].Info.MaxHp)*threshold && e.rounds < grant {
|
||
e.rounds = grant
|
||
}
|
||
}
|
||
|
||
// 2137: 恢复效果逐回合衰减,衰减前自身增伤并附加固伤
|
||
type BossJsonEid2137 struct {
|
||
BossJsonEid0
|
||
healRate int
|
||
}
|
||
|
||
func (e *BossJsonEid2137) TurnStart(fattack, sattack *action.SelectSkillAction) {
|
||
if !e.ownerActive() {
|
||
return
|
||
}
|
||
if e.healRate == 0 {
|
||
e.healRate = 100
|
||
}
|
||
dec := bossJsonIntArg(e.Args(), 0, 0)
|
||
if dec > 0 {
|
||
e.healRate -= dec
|
||
if e.healRate < 0 {
|
||
e.healRate = 0
|
||
}
|
||
}
|
||
}
|
||
|
||
func (e *BossJsonEid2137) Heal_Pre(_ action.BattleActionI, amount *int) bool {
|
||
if !e.ownerActive() || e.healRate >= 100 {
|
||
return true
|
||
}
|
||
*amount = *amount * e.healRate / 100
|
||
return true
|
||
}
|
||
|
||
func (e *BossJsonEid2137) DamageAdd(zone *info.DamageZone) bool {
|
||
if !e.ownerActive() || e.healRate <= 0 || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
fixed := bossJsonIntArg(e.Args(), 2, 0)
|
||
if fixed > 0 {
|
||
zone.Damage = zone.Damage.Add(alpacadecimal.NewFromInt(int64(fixed)))
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *BossJsonEid2137) Damage_Mul(zone *info.DamageZone) bool {
|
||
if !e.ownerActive() || e.healRate <= 0 || zone.Type != info.DamageType.Red {
|
||
return true
|
||
}
|
||
bonus := bossJsonIntArg(e.Args(), 1, 0)
|
||
zone.Damage = zone.Damage.Mul(alpacadecimal.NewFromInt(int64(100 + bonus))).Div(alpacadecimal.NewFromInt(100))
|
||
return true
|
||
}
|
||
|
||
// 1621: 对手攻击技能后出手则无效
|
||
type BossJsonEid1621 struct{ BossJsonEid0 }
|
||
|
||
func (e *BossJsonEid1621) ActionStart(firstAttack, secondAttack *action.SelectSkillAction) bool {
|
||
if !e.ownerActive() || !bossJsonIsAttackSkill(e.Ctx().SkillEntity) {
|
||
return true
|
||
}
|
||
userID := e.Ctx().Our.Player.GetInfo().UserID
|
||
if !bossJsonActionMatches(e.Ctx().SkillEntity, secondAttack, userID) {
|
||
return true
|
||
}
|
||
if firstAttack == nil || !bossJsonIsAttackSkill(firstAttack.SkillEntity) {
|
||
return true
|
||
}
|
||
return false
|
||
}
|
||
|
||
// 1254: 先出手则当回合免疫受到的攻击伤害
|
||
type BossJsonEid1254 struct {
|
||
BossJsonEid0
|
||
immuneThisTurn bool
|
||
}
|
||
|
||
func (e *BossJsonEid1254) ActionStart(firstAttack, secondAttack *action.SelectSkillAction) bool {
|
||
e.immuneThisTurn = false
|
||
if !e.ownerActive() || !bossJsonIsAttackSkill(e.Ctx().SkillEntity) {
|
||
return true
|
||
}
|
||
userID := e.Ctx().Our.Player.GetInfo().UserID
|
||
e.immuneThisTurn = bossJsonActionMatches(e.Ctx().SkillEntity, firstAttack, userID)
|
||
return true
|
||
}
|
||
|
||
func (e *BossJsonEid1254) DamageLockEx(zone *info.DamageZone) bool {
|
||
if !e.ownerActive() || !e.immuneThisTurn || zone.Type != info.DamageType.Red || e.Ctx().SkillEntity == nil {
|
||
return true
|
||
}
|
||
if bossJsonIsAttackSkill(e.Ctx().SkillEntity) {
|
||
zone.Damage = alpacadecimal.Zero
|
||
}
|
||
return true
|
||
}
|
||
|
||
func (e *BossJsonEid1254) TurnEnd() {
|
||
e.immuneThisTurn = false
|
||
}
|
||
|
||
func init() {
|
||
input.InitEffect(input.EffectType.NewSel, 41, &BossJsonEid41{})
|
||
input.InitEffect(input.EffectType.NewSel, 42, &BossJsonEid42{})
|
||
input.InitEffect(input.EffectType.NewSel, 7, &BossJsonEid7{})
|
||
input.InitEffect(input.EffectType.NewSel, 8, &BossJsonEid8{})
|
||
input.InitEffect(input.EffectType.NewSel, 45, &BossJsonEid45{})
|
||
input.InitEffect(input.EffectType.NewSel, 77, &BossJsonEid77{})
|
||
input.InitEffect(input.EffectType.NewSel, 113, &BossJsonEid113{})
|
||
input.InitEffect(input.EffectType.NewSel, 144, &BossJsonEid144{})
|
||
input.InitEffect(input.EffectType.NewSel, 224, &BossJsonEid224{})
|
||
input.InitEffect(input.EffectType.NewSel, 2095, &BossJsonEid2095{})
|
||
input.InitEffect(input.EffectType.NewSel, 2104, &BossJsonEid2104{})
|
||
input.InitEffect(input.EffectType.NewSel, 2103, &BossJsonEid2103{})
|
||
input.InitEffect(input.EffectType.NewSel, 2105, &BossJsonEid2105{})
|
||
input.InitEffect(input.EffectType.NewSel, 2137, &BossJsonEid2137{})
|
||
input.InitEffect(input.EffectType.NewSel, 1621, &BossJsonEid1621{})
|
||
input.InitEffect(input.EffectType.NewSel, 1254, &BossJsonEid1254{})
|
||
}
|