82 lines
2.1 KiB
Go
82 lines
2.1 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/common/utils"
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
)
|
|
|
|
// 施加一个基类effect
|
|
type Effect0 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect0) TurnEnd(opp *input.Input) {
|
|
e.Input.AttackValue.RemainHp = int32(e.Input.CurrentPet.Info.Hp)
|
|
|
|
}
|
|
|
|
// 使用技能时
|
|
func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
|
|
|
|
//变威力作用
|
|
e.Stack(int(e.Input.CalculatePower(opp, skill).IntPart()))
|
|
|
|
e.Input.Exec(func(t input.Effect) bool { //计算暴击率加成
|
|
|
|
e.Input.AttackValue.IsCritical = skill.Crit
|
|
return e.Input.AttackValue.IsCritical == 0
|
|
})
|
|
if e.Input.AttackValue.IsCritical == 1 {
|
|
|
|
e.Stack(e.Stack() * 2)
|
|
}
|
|
|
|
}
|
|
func (this *Effect0) BeforHit(opp *input.Input, skill *info.SkillEntity) {
|
|
skill.AttackTimeC(int(opp.GetProp(5, true))) //计算命中
|
|
skill.Crit = 0
|
|
CritRate := utils.Max(skill.CritRate, 1)
|
|
CritRateR := this.Input.FightC.GetRand().Int31n(16)
|
|
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
|
|
if skill.CritAtkFirst != 0 && this.Input.First {
|
|
CritRate = 16
|
|
}
|
|
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
|
if skill.CritAtkSecond != 0 && !this.Input.First {
|
|
CritRate = 16
|
|
}
|
|
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
|
if skill.CritSelfHalfHp != 0 && (this.Input.CurrentPet.HP < int(this.Input.CurrentPet.Info.MaxHp)/2) {
|
|
CritRate = 16
|
|
}
|
|
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
|
|
if skill.CritSelfHalfHp != 0 && (opp.CurrentPet.HP < int(opp.CurrentPet.Info.MaxHp)/2) {
|
|
CritRate = 16
|
|
}
|
|
|
|
//todo 暴击伤害
|
|
if CritRateR <= int32(CritRate) {
|
|
skill.Crit = 1
|
|
}
|
|
|
|
}
|
|
|
|
// 受击触发
|
|
func (e *Effect0) AfterAttacked(opp *input.Input, skill *info.SkillEntity) {
|
|
//在这里修改伤害
|
|
|
|
if uint32(opp.AttackValue.LostHp) > e.Input.CurrentPet.Info.Hp {
|
|
//这里其实是受到致死伤害
|
|
e.Input.CurrentPet.Info.Hp = 0
|
|
} else {
|
|
e.Input.CurrentPet.Info.Hp = e.Input.CurrentPet.Info.Hp - opp.AttackValue.LostHp
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Damage, 0, &Effect0{})
|
|
|
|
}
|