40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package effect
|
|
|
|
import (
|
|
"blazing/logic/service/fight/info"
|
|
"blazing/logic/service/fight/input"
|
|
"blazing/logic/service/fight/node"
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
|
)
|
|
|
|
// Effect 517: {0}%概率使对手害怕,每损失{1}%体力,害怕概率提升{2}%
|
|
type Effect517 struct {
|
|
node.EffectNode
|
|
}
|
|
|
|
func (e *Effect517) OnSkill() bool {
|
|
|
|
baseChance := e.Args()[0].IntPart()
|
|
lostHpPercent := (e.Ctx().Opp.CurPet[0].GetMaxHP().Sub(e.Ctx().Opp.CurPet[0].GetHP())).Div(e.Ctx().Opp.CurPet[0].GetMaxHP()).Mul(alpacadecimal.NewFromInt(100)).IntPart()
|
|
|
|
// 计算额外几率
|
|
additionalStacks := lostHpPercent / e.Args()[1].IntPart()
|
|
extraChance := additionalStacks * e.Args()[2].IntPart()
|
|
|
|
totalChance := baseChance + extraChance
|
|
success, _, _ := e.Input.Player.Roll(int(totalChance), 100)
|
|
if success {
|
|
fearEffect := e.Ctx().Our.InitEffect(input.EffectType.Status, int(info.PetStatus.Fear))
|
|
if fearEffect != nil {
|
|
e.Ctx().Opp.AddEffect(e.Ctx().Our, fearEffect)
|
|
}
|
|
}
|
|
|
|
return true
|
|
}
|
|
|
|
func init() {
|
|
input.InitEffect(input.EffectType.Skill, 517, &Effect517{})
|
|
}
|