2025-09-23 19:49:17 +00:00
|
|
|
|
package input
|
|
|
|
|
|
|
2025-09-23 23:33:15 +00:00
|
|
|
|
import (
|
|
|
|
|
|
element "blazing/common/data/Element"
|
2025-09-25 18:13:16 +00:00
|
|
|
|
"blazing/common/utils"
|
2025-11-15 22:17:43 +00:00
|
|
|
|
|
2025-09-29 02:40:35 +08:00
|
|
|
|
"blazing/logic/service/fight/action"
|
2025-09-23 23:33:15 +00:00
|
|
|
|
"blazing/logic/service/fight/info"
|
|
|
|
|
|
|
2025-12-05 00:24:02 +08:00
|
|
|
|
"github.com/alpacahq/alpacadecimal"
|
2026-01-09 08:31:30 +08:00
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
2026-03-10 00:06:02 +08:00
|
|
|
|
"github.com/gogf/gf/v2/util/grand"
|
2025-09-23 23:33:15 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
2025-11-09 02:48:32 +00:00
|
|
|
|
// 计算暴击
|
2025-11-11 05:54:24 +00:00
|
|
|
|
func (our *Input) CalculateCrit(opp *Input, skill *info.SkillEntity) {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
ourPet := our.CurrentPet()
|
|
|
|
|
|
oppPet := opp.CurrentPet()
|
|
|
|
|
|
if ourPet == nil || oppPet == nil {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-09-28 01:58:42 +08:00
|
|
|
|
|
2025-09-26 02:09:33 +00:00
|
|
|
|
skill.Crit = 0
|
|
|
|
|
|
if skill.Category() == info.Category.STATUS { //属性技能不用算暴击
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-03-09 18:49:51 +08:00
|
|
|
|
CritRate := utils.Max(skill.XML.CritRate, 1)
|
2025-09-23 19:49:17 +00:00
|
|
|
|
|
2025-09-26 02:09:33 +00:00
|
|
|
|
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
|
2026-03-09 18:49:51 +08:00
|
|
|
|
if skill.XML.CritAtkFirst != 0 && our.FightC.IsFirst(our.Player) {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
2026-03-09 18:49:51 +08:00
|
|
|
|
if skill.XML.CritAtkSecond != 0 && !our.FightC.IsFirst(our.Player) {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
2026-04-04 22:13:42 +08:00
|
|
|
|
if skill.XML.CritSelfHalfHp != 0 && (ourPet.HP < int(ourPet.Info.MaxHp)/2) {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
|
2026-04-04 22:13:42 +08:00
|
|
|
|
if skill.XML.CritSelfHalfHp != 0 && (oppPet.HP < int(oppPet.Info.MaxHp)/2) {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//todo 暴击伤害
|
2026-03-10 00:06:02 +08:00
|
|
|
|
if t := grand.Meet(CritRate, 16); t {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
skill.Crit = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-29 02:40:35 +08:00
|
|
|
|
// 恢复血量
|
2025-12-05 00:24:02 +08:00
|
|
|
|
func (our *Input) Heal(in *Input, ac action.BattleActionI, value alpacadecimal.Decimal) {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet := our.CurrentPet()
|
|
|
|
|
|
if currentPet == nil {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-03-30 00:51:18 +08:00
|
|
|
|
healValue := int(value.IntPart())
|
|
|
|
|
|
|
|
|
|
|
|
if ac != nil {
|
|
|
|
|
|
if _, ok := ac.(*action.UseItemAction); !ok {
|
2026-04-04 06:27:15 +08:00
|
|
|
|
our.ExecWithOpponent(in, func(t Effect) bool {
|
2026-03-30 00:51:18 +08:00
|
|
|
|
t.Heal_Pre(ac, &healValue)
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
2025-11-08 16:38:41 +08:00
|
|
|
|
//使用道具回血
|
2025-11-12 13:44:21 +00:00
|
|
|
|
if _, ok := ac.(*action.UseItemAction); !ok &&
|
|
|
|
|
|
ac != nil &&
|
2026-03-30 00:51:18 +08:00
|
|
|
|
in == our &&
|
|
|
|
|
|
healValue > 0 {
|
|
|
|
|
|
our.AttackValue.GainHp += int32(healValue) //道具有专门的回血包
|
2025-11-08 16:38:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-30 00:51:18 +08:00
|
|
|
|
if healValue >= 0 {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet.Info.ModelHP(int64(healValue))
|
2026-04-08 01:28:55 +08:00
|
|
|
|
if our.AttackValue != nil {
|
|
|
|
|
|
our.AttackValue.RemainHp = int32(currentPet.Info.Hp)
|
|
|
|
|
|
our.AttackValue.MaxHp = currentPet.Info.MaxHp
|
|
|
|
|
|
}
|
2026-03-30 00:51:18 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
damage := uint32(-healValue)
|
2026-04-04 22:13:42 +08:00
|
|
|
|
if damage >= currentPet.Info.Hp {
|
|
|
|
|
|
currentPet.Info.Hp = 0
|
2026-04-08 01:28:55 +08:00
|
|
|
|
if our.AttackValue != nil {
|
|
|
|
|
|
our.AttackValue.RemainHp = 0
|
|
|
|
|
|
our.AttackValue.MaxHp = currentPet.Info.MaxHp
|
|
|
|
|
|
}
|
2026-03-30 00:51:18 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet.Info.Hp -= damage
|
2026-04-08 01:28:55 +08:00
|
|
|
|
if our.AttackValue != nil {
|
|
|
|
|
|
our.AttackValue.RemainHp = int32(currentPet.Info.Hp)
|
|
|
|
|
|
our.AttackValue.MaxHp = currentPet.Info.MaxHp
|
|
|
|
|
|
}
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-11 05:54:24 +00:00
|
|
|
|
func (our *Input) HealPP(value int) {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet := our.CurrentPet()
|
|
|
|
|
|
if currentPet == nil {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet.Info.HealPP(value)
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2025-11-08 23:20:48 +08:00
|
|
|
|
}
|
2025-11-11 05:54:24 +00:00
|
|
|
|
func (our *Input) DelPP(value int) {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet := our.CurrentPet()
|
|
|
|
|
|
if currentPet == nil {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-11-08 23:20:48 +08:00
|
|
|
|
|
2026-04-04 22:13:42 +08:00
|
|
|
|
for i := 0; i < len(currentPet.Info.SkillList); i++ {
|
|
|
|
|
|
if uint32(value) > currentPet.Info.SkillList[i].PP {
|
|
|
|
|
|
currentPet.Info.SkillList[i].PP = 0
|
2025-11-08 23:20:48 +08:00
|
|
|
|
} else {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet.Info.SkillList[i].PP -= uint32(value)
|
2025-11-08 23:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-29 02:40:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-05 22:54:41 +08:00
|
|
|
|
// Damage 对方对我方造成伤害,处理伤害计算和扣减血量逻辑,包括各种增伤、减伤效果
|
2025-11-11 05:54:24 +00:00
|
|
|
|
// /红伤只允许调用一次来保持锁伤
|
2025-11-12 01:19:24 +08:00
|
|
|
|
// 这个方法是对对方造成伤害
|
2025-09-28 01:58:42 +08:00
|
|
|
|
// 伤害落实 // 血量扣减节点比如触发回神,反弹也在这里实现
|
2025-11-12 13:44:21 +00:00
|
|
|
|
func (our *Input) Damage(in *Input, sub *info.DamageZone) {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet := our.CurrentPet()
|
|
|
|
|
|
if currentPet == nil {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-04-04 06:27:15 +08:00
|
|
|
|
attacker := in
|
|
|
|
|
|
if attacker == nil {
|
|
|
|
|
|
attacker = our
|
|
|
|
|
|
}
|
2026-03-09 22:36:30 +08:00
|
|
|
|
// if sub.Type == info.DamageType.Red { //每回合计算伤害的时候重置伤害
|
|
|
|
|
|
// our.Opp.SumDamage = sub.Damage
|
2025-11-13 02:43:00 +08:00
|
|
|
|
|
2026-03-09 22:36:30 +08:00
|
|
|
|
// }
|
2025-11-12 13:44:21 +00:00
|
|
|
|
// 对方对我方造成,需要吃到对方的加成
|
|
|
|
|
|
var ok bool
|
2026-04-04 06:27:15 +08:00
|
|
|
|
if our != attacker {
|
|
|
|
|
|
ok = attacker.ExecWithOpponent(our, func(t Effect) bool {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2026-01-12 00:04:10 +08:00
|
|
|
|
t.DamageAdd(sub) //红伤落实前,我方增伤
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
|
return true
|
|
|
|
|
|
})
|
2025-11-12 13:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
//sub.BeforeMul = sub.Damage
|
|
|
|
|
|
if ok {
|
2026-04-04 06:27:15 +08:00
|
|
|
|
ok = attacker.ExecWithOpponent(our, func(t Effect) bool {
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
|
|
|
|
|
t.Damage_Mul(sub) //红伤落实前,我方增伤
|
2025-11-12 13:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
//sub.BeforeFloor = sub.Damage
|
|
|
|
|
|
if ok {
|
2026-04-04 06:27:15 +08:00
|
|
|
|
ok = attacker.ExecWithOpponent(our, func(t Effect) bool {
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
2025-12-06 15:11:42 +08:00
|
|
|
|
t.DamageFloor(sub) //红伤落实,内部有befer
|
2025-11-12 13:44:21 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-09-28 08:13:42 +00:00
|
|
|
|
}
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-11-09 02:29:21 +00:00
|
|
|
|
// sub.BeforeMul = sub.Damage
|
2025-09-28 08:13:42 +00:00
|
|
|
|
if ok {
|
2026-04-04 06:27:15 +08:00
|
|
|
|
ok = our.ExecWithOpponent(attacker, func(t Effect) bool {
|
2025-11-13 21:36:18 +08:00
|
|
|
|
|
2026-01-04 22:10:34 +08:00
|
|
|
|
t.DamageDivEx(sub) //红伤落实,内部有befer
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-11-09 02:29:21 +00:00
|
|
|
|
//sub.BeforeSUB = sub.Damage
|
2025-09-28 08:13:42 +00:00
|
|
|
|
if ok {
|
2026-04-04 06:27:15 +08:00
|
|
|
|
ok = our.ExecWithOpponent(attacker, func(t Effect) bool {
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
2026-01-04 22:10:34 +08:00
|
|
|
|
t.DamageSubEx(sub)
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2026-03-10 09:17:26 +08:00
|
|
|
|
//sub.BeforeLocked = sub.Damage
|
|
|
|
|
|
if ok {
|
2026-04-04 06:27:15 +08:00
|
|
|
|
our.ExecWithOpponent(attacker, func(t Effect) bool {
|
2026-03-10 09:17:26 +08:00
|
|
|
|
|
|
|
|
|
|
t.DamageLockEx(sub)
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
2026-03-10 09:17:26 +08:00
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-11-09 02:29:21 +00:00
|
|
|
|
// sub.BeforeLock = sub.Damage
|
2026-04-04 06:27:15 +08:00
|
|
|
|
if ok && attacker != our {
|
|
|
|
|
|
ok = attacker.ExecWithOpponent(our, func(t Effect) bool {
|
2025-11-09 02:29:21 +00:00
|
|
|
|
|
2025-12-06 15:11:42 +08:00
|
|
|
|
t.DamageLock(sub)
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-09-28 08:13:42 +00:00
|
|
|
|
if ok {
|
2026-04-04 06:27:15 +08:00
|
|
|
|
our.ExecWithOpponent(attacker, func(t Effect) bool {
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
2026-03-10 09:17:26 +08:00
|
|
|
|
t.Damage_Shield(sub)
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2026-03-29 19:00:08 +08:00
|
|
|
|
if sub.Damage.Cmp(alpacadecimal.Zero) < 0 {
|
|
|
|
|
|
sub.Damage = alpacadecimal.Zero
|
|
|
|
|
|
}
|
|
|
|
|
|
if shieldAbsorb := our.AbsorbShieldDamage(sub.Damage); shieldAbsorb.Cmp(alpacadecimal.Zero) > 0 {
|
|
|
|
|
|
sub.Damage = sub.Damage.Sub(shieldAbsorb)
|
|
|
|
|
|
}
|
|
|
|
|
|
if sub.Type == info.DamageType.Red { //红才会产生造成伤害
|
2026-04-04 06:27:15 +08:00
|
|
|
|
attacker.SumDamage = sub.Damage.Add(attacker.SumDamage) // 叠加总伤害 这里相当于记录红伤
|
2026-03-29 19:00:08 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if sub.Type == info.DamageType.Red { //红才会产生造成伤害
|
2026-04-04 06:27:15 +08:00
|
|
|
|
attacker.AttackValue.LostHp += uint32(sub.Damage.IntPart()) //红伤落实
|
2026-03-09 20:55:04 +08:00
|
|
|
|
|
2025-09-26 13:33:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-04 22:13:42 +08:00
|
|
|
|
if uint32(sub.Damage.IntPart()) > currentPet.Info.Hp {
|
2025-09-28 09:31:08 +00:00
|
|
|
|
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet.Info.Hp = 0
|
2025-09-26 02:09:33 +00:00
|
|
|
|
} else {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
currentPet.Info.Hp = currentPet.Info.Hp - uint32(sub.Damage.IntPart())
|
2025-09-26 02:09:33 +00:00
|
|
|
|
}
|
2026-04-08 01:28:55 +08:00
|
|
|
|
if our.AttackValue != nil {
|
|
|
|
|
|
our.AttackValue.RemainHp = int32(currentPet.Info.Hp)
|
|
|
|
|
|
our.AttackValue.MaxHp = currentPet.Info.MaxHp
|
|
|
|
|
|
}
|
2025-09-23 19:49:17 +00:00
|
|
|
|
|
|
|
|
|
|
//todo 待实现死亡effet
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-23 23:33:15 +00:00
|
|
|
|
// 计算技能威力
|
2025-12-05 00:24:02 +08:00
|
|
|
|
func (our *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) alpacadecimal.Decimal {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
if deftype == nil {
|
|
|
|
|
|
return alpacadecimal.Zero
|
|
|
|
|
|
}
|
|
|
|
|
|
ourPet := our.CurrentPet()
|
|
|
|
|
|
defPet := deftype.CurrentPet()
|
|
|
|
|
|
if ourPet == nil || defPet == nil {
|
|
|
|
|
|
return alpacadecimal.Zero
|
|
|
|
|
|
}
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
// 1. 计算等级因子 (level * 0.4 + 2)
|
2026-04-04 22:13:42 +08:00
|
|
|
|
levelFactor := alpacadecimal.NewFromInt(int64(ourPet.Info.Level)).
|
2025-12-05 00:24:02 +08:00
|
|
|
|
Mul(alpacadecimal.NewFromFloat(0.4)).Add(alpacadecimal.NewFromInt(2))
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
var (
|
2025-12-05 00:24:02 +08:00
|
|
|
|
attackDec alpacadecimal.Decimal //攻击值
|
|
|
|
|
|
defenseDec alpacadecimal.Decimal //防御值
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
)
|
2025-09-24 12:40:13 +08:00
|
|
|
|
|
2025-09-23 23:33:15 +00:00
|
|
|
|
switch skill.Category() { //判断技能类型
|
|
|
|
|
|
case info.Category.PHYSICAL:
|
2026-03-09 20:55:04 +08:00
|
|
|
|
attackDec = our.GetProp(0)
|
2026-03-10 00:06:02 +08:00
|
|
|
|
defenseDec = deftype.GetProp(1)
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
case info.Category.SPECIAL:
|
|
|
|
|
|
|
2026-03-09 20:55:04 +08:00
|
|
|
|
attackDec = our.GetProp(2)
|
2026-03-10 00:06:02 +08:00
|
|
|
|
defenseDec = deftype.GetProp(3)
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
default:
|
2026-01-21 20:46:05 +00:00
|
|
|
|
return alpacadecimal.Zero
|
2025-09-23 23:33:15 +00:00
|
|
|
|
}
|
2025-11-09 03:06:18 +00:00
|
|
|
|
// 8. DmgBindLv: 使对方受到的伤害值等于等级; 默认: 0
|
|
|
|
|
|
// 9. PwrBindDv: 1,威力(power)取决于潜力(个体值)*5; 2,威力(power)取决于最大体力*1/3+潜力(个体值); 默认: 0
|
|
|
|
|
|
// 10. PwrDouble: 攻击时,若对方处于异常状态, 则威力翻倍;
|
|
|
|
|
|
// 11. DmgBindHpDv: 造成的伤害等于自身剩余体力*1/2+潜力(个体值); 默认: 0
|
2026-03-09 18:49:51 +08:00
|
|
|
|
if skill.XML.DmgBindLv != 0 {
|
2026-03-23 22:00:05 +08:00
|
|
|
|
|
2026-04-04 22:13:42 +08:00
|
|
|
|
skill.XML.Power = int(defPet.Info.Level)
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
2025-11-09 03:06:18 +00:00
|
|
|
|
}
|
2026-03-09 18:49:51 +08:00
|
|
|
|
if skill.XML.PwrBindDv != 0 {
|
|
|
|
|
|
if skill.XML.PwrBindDv == 1 {
|
2025-12-05 00:24:02 +08:00
|
|
|
|
|
2026-04-04 22:13:42 +08:00
|
|
|
|
skill.XML.Power = int(ourPet.Info.Dv * 5)
|
2026-02-11 11:06:28 +08:00
|
|
|
|
|
2025-11-09 03:06:18 +00:00
|
|
|
|
}
|
2026-03-09 18:49:51 +08:00
|
|
|
|
if skill.XML.PwrBindDv == 2 {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
skill.XML.Power = int(ourPet.Info.Hp/3 + ourPet.Info.Dv)
|
2025-11-09 03:06:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-09 18:49:51 +08:00
|
|
|
|
if skill.XML.PwrDouble != 0 {
|
2025-11-09 03:06:18 +00:00
|
|
|
|
|
|
|
|
|
|
if deftype.StatEffect_Exist_all() {
|
2026-03-09 18:49:51 +08:00
|
|
|
|
skill.XML.Power = skill.XML.Power * 2
|
2025-11-09 03:06:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-09 18:49:51 +08:00
|
|
|
|
if skill.XML.DmgBindHpDv != 0 {
|
2026-04-04 22:13:42 +08:00
|
|
|
|
skill.XML.Power = int(ourPet.Info.Hp/2 + ourPet.Info.Dv)
|
2025-11-09 03:06:18 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
2026-02-11 11:06:28 +08:00
|
|
|
|
// 5. 基础伤害公式:等级因子 * 威力因子 * 攻击 / 防御 / 50 + 2
|
|
|
|
|
|
baseDamage := levelFactor.
|
|
|
|
|
|
Div(alpacadecimal.NewFromInt(50)).
|
2026-03-10 00:06:02 +08:00
|
|
|
|
Mul(alpacadecimal.NewFromInt(int64(skill.XML.Power))).
|
|
|
|
|
|
Mul(attackDec.Div(defenseDec)).
|
2026-02-11 11:06:28 +08:00
|
|
|
|
Add(alpacadecimal.NewFromInt(2))
|
|
|
|
|
|
|
|
|
|
|
|
var typeRate alpacadecimal.Decimal
|
2026-04-04 22:13:42 +08:00
|
|
|
|
//fmt.Println(skill.Type().ID, defPet.Type().ID)
|
|
|
|
|
|
t, _ := element.Calculator.GetOffensiveMultiplier(skill.GetType().ID, defPet.GetType().ID)
|
2026-02-11 11:06:28 +08:00
|
|
|
|
our.AttackValue.Offensive = gconv.Float32(t)
|
|
|
|
|
|
|
|
|
|
|
|
typeRate = alpacadecimal.NewFromFloat(t)
|
|
|
|
|
|
|
2025-09-23 23:33:15 +00:00
|
|
|
|
damage := baseDamage.
|
|
|
|
|
|
Mul(skill.CriticalsameTypeBonus()). // 同属性加成
|
|
|
|
|
|
Mul(typeRate). // 克制系数
|
|
|
|
|
|
|
|
|
|
|
|
Mul(skill.Criticalrandom()) //随机波动
|
2026-03-10 16:02:38 +08:00
|
|
|
|
//println(baseDamage.IntPart(), damage.IntPart(), attackDec.IntPart(), defenseDec.IntPart(), "技能伤害")
|
2025-09-23 23:33:15 +00:00
|
|
|
|
return damage
|
2025-09-23 20:53:47 +00:00
|
|
|
|
|
|
|
|
|
|
}
|