2025-09-25 20:34:33 +00:00
|
|
|
package effect
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/logic/service/fight/input"
|
|
|
|
|
"blazing/logic/service/fight/node"
|
2025-11-23 23:38:03 +00:00
|
|
|
|
|
|
|
|
"github.com/gogf/gf/v2/util/grand"
|
2025-09-25 20:34:33 +00:00
|
|
|
)
|
|
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
// -----------------------------------------------------------
|
|
|
|
|
// 威力随机效果
|
|
|
|
|
// -----------------------------------------------------------
|
|
|
|
|
// 威力将在 [Min, Max] 区间内随机取值
|
|
|
|
|
type EffectRandomPower struct {
|
2025-09-25 20:34:33 +00:00
|
|
|
node.EffectNode
|
|
|
|
|
Min int
|
|
|
|
|
Max int
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
// -----------------------------------------------------------
|
|
|
|
|
// 初始化注册
|
|
|
|
|
// -----------------------------------------------------------
|
2025-09-25 20:34:33 +00:00
|
|
|
func init() {
|
2025-11-03 03:59:59 +08:00
|
|
|
registerRandomPower(61, 50, 150)
|
2026-03-28 21:57:22 +08:00
|
|
|
registerRandomPower(70, 150, 220)
|
|
|
|
|
registerRandomPower(118, 150, 220)
|
2025-11-03 03:59:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------
|
|
|
|
|
// 工厂函数:注册不同威力范围的技能效果
|
|
|
|
|
// -----------------------------------------------------------
|
|
|
|
|
func registerRandomPower(effectID, min, max int) {
|
|
|
|
|
input.InitEffect(input.EffectType.Skill, effectID, &EffectRandomPower{
|
|
|
|
|
Min: min,
|
|
|
|
|
Max: max,
|
2025-09-25 20:34:33 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-03 03:59:59 +08:00
|
|
|
// -----------------------------------------------------------
|
|
|
|
|
// 命中时触发
|
|
|
|
|
// -----------------------------------------------------------
|
2026-01-04 22:10:34 +08:00
|
|
|
func (e *EffectRandomPower) SkillHit() bool {
|
2025-11-03 03:59:59 +08:00
|
|
|
if e.Max <= e.Min {
|
2026-03-09 18:49:51 +08:00
|
|
|
e.Ctx().SkillEntity.XML.Power = e.Min
|
2025-11-03 03:59:59 +08:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 20:05:00 +00:00
|
|
|
n := grand.N(e.Min, e.Max)
|
2026-03-09 18:49:51 +08:00
|
|
|
e.Ctx().SkillEntity.XML.Power = n
|
2025-11-03 03:59:59 +08:00
|
|
|
return true
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|