151 lines
3.6 KiB
Go
151 lines
3.6 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/gogf/gf/v2/util/grand"
|
|
)
|
|
|
|
var randomMajorAbnormalStatuses = []int{
|
|
int(info.PetStatus.Burned),
|
|
int(info.PetStatus.Frozen),
|
|
int(info.PetStatus.Poisoned),
|
|
int(info.PetStatus.Paralysis),
|
|
int(info.PetStatus.Fear),
|
|
int(info.PetStatus.Sleep),
|
|
}
|
|
|
|
func addRandomMajorAbnormalStatus(owner, target *input.Input) {
|
|
if owner == nil || target == nil || len(randomMajorAbnormalStatuses) == 0 {
|
|
return
|
|
}
|
|
|
|
statusID := randomMajorAbnormalStatuses[grand.Intn(len(randomMajorAbnormalStatuses))]
|
|
statusEffect := owner.InitEffect(input.EffectType.Status, statusID)
|
|
if statusEffect != nil {
|
|
target.AddEffect(owner, statusEffect)
|
|
}
|
|
}
|
|
|
|
// Effect 769: 若对手不处于异常状态则造成的攻击伤害额外提升{0}%
|
|
type Effect769 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect769) SkillHit() bool {
|
|
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
if e.Ctx().Opp.StatEffect_Exist_all() {
|
|
return true
|
|
}
|
|
|
|
addSkillPowerPercent(e.Ctx().SkillEntity, e.Args()[0])
|
|
return true
|
|
}
|
|
|
|
// Effect 770: 若对手处于异常状态,则恢复自身全部体力
|
|
type Effect770 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect770) Skill_Use() bool {
|
|
if !e.Ctx().Opp.StatEffect_Exist_all() {
|
|
return true
|
|
}
|
|
|
|
e.Ctx().Our.Heal(e.Ctx().Our, &action.SelectSkillAction{}, e.Ctx().Our.CurrentPet.GetMaxHP())
|
|
return true
|
|
}
|
|
|
|
// Effect 771: {0}回合内每次使用攻击技能都有{1}%概率使对手进入任意一种异常状态
|
|
type Effect771 struct {
|
|
RoundEffectArg0Base
|
|
}
|
|
|
|
func (e *Effect771) OnSkill() bool {
|
|
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
if len(e.Args()) < 2 {
|
|
return true
|
|
}
|
|
|
|
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
|
|
if !success {
|
|
return true
|
|
}
|
|
|
|
addRandomMajorAbnormalStatus(e.Ctx().Our, e.Ctx().Opp)
|
|
return true
|
|
}
|
|
|
|
// Effect 772: {0}回合内若对手使用攻击技能则有{1}%概率随机进入烧伤、冻伤、中毒、麻痹、害怕、睡眠中的一种异常状态
|
|
type Effect772 struct {
|
|
RoundEffectArg0Base
|
|
}
|
|
|
|
func (e *Effect772) Skill_Use_ex() bool {
|
|
if e.Ctx().SkillEntity == nil || e.Ctx().SkillEntity.Category() == info.Category.STATUS {
|
|
return true
|
|
}
|
|
if len(e.Args()) < 2 {
|
|
return true
|
|
}
|
|
|
|
success, _, _ := e.Input.Player.Roll(int(e.Args()[1].IntPart()), 100)
|
|
if !success {
|
|
return true
|
|
}
|
|
|
|
addRandomMajorAbnormalStatus(e.Ctx().Our, e.Ctx().Opp)
|
|
return true
|
|
}
|
|
|
|
// Effect 773: 若自身体力低于对手则与对手互换体力
|
|
type Effect773 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect773) OnSkill() bool {
|
|
ourHP := e.Ctx().Our.CurrentPet.GetHP().IntPart()
|
|
oppHP := e.Ctx().Opp.CurrentPet.GetHP().IntPart()
|
|
if ourHP >= oppHP {
|
|
return true
|
|
}
|
|
|
|
ourMaxHP := e.Ctx().Our.CurrentPet.GetMaxHP().IntPart()
|
|
oppMaxHP := e.Ctx().Opp.CurrentPet.GetMaxHP().IntPart()
|
|
|
|
newOurHP := oppHP
|
|
if newOurHP > ourMaxHP {
|
|
newOurHP = ourMaxHP
|
|
}
|
|
if newOurHP < 0 {
|
|
newOurHP = 0
|
|
}
|
|
|
|
newOppHP := ourHP
|
|
if newOppHP > oppMaxHP {
|
|
newOppHP = oppMaxHP
|
|
}
|
|
if newOppHP < 0 {
|
|
newOppHP = 0
|
|
}
|
|
|
|
e.Ctx().Our.CurrentPet.Info.Hp = uint32(newOurHP)
|
|
e.Ctx().Opp.CurrentPet.Info.Hp = uint32(newOppHP)
|
|
return true
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 769, &Effect769{})
|
|
input.InitEffect(input.EffectType.Skill, 770, &Effect770{})
|
|
input.InitEffect(input.EffectType.Skill, 771, &Effect771{})
|
|
input.InitEffect(input.EffectType.Skill, 772, &Effect772{})
|
|
input.InitEffect(input.EffectType.Skill, 773, &Effect773{})
|
|
}
|