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-09-23 23:33:15 +00:00
|
|
|
"blazing/logic/service/fight/info"
|
2025-09-25 18:13:16 +00:00
|
|
|
"fmt"
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
"github.com/shopspring/decimal"
|
|
|
|
|
)
|
|
|
|
|
|
2025-09-26 21:15:58 +00:00
|
|
|
func (u *Input) UseSkill(opp *Input, skill *info.SkillEntity) {
|
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
|
|
|
|
|
}
|
|
|
|
|
CritRate := utils.Max(skill.CritRate, 1)
|
2025-09-23 19:49:17 +00:00
|
|
|
|
2025-09-26 02:09:33 +00:00
|
|
|
//CritAtkFirst: 先出手时必定致命一击; 默认: 0
|
|
|
|
|
if skill.CritAtkFirst != 0 && u.First {
|
|
|
|
|
CritRate = 16
|
|
|
|
|
}
|
|
|
|
|
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
|
|
|
|
if skill.CritAtkSecond != 0 && !u.First {
|
|
|
|
|
CritRate = 16
|
|
|
|
|
}
|
|
|
|
|
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
|
|
|
|
if skill.CritSelfHalfHp != 0 && (u.CurrentPet.HP < int(u.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 t, _, _ := u.Player.Roll(625*CritRate, 10000); t {
|
|
|
|
|
skill.Crit = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-28 01:58:42 +08:00
|
|
|
// 伤害落实 // 血量扣减节点比如触发回神,反弹也在这里实现
|
2025-09-28 08:13:42 +00:00
|
|
|
func (u *Input) Damage(ctx Ctx) {
|
|
|
|
|
ctx.Input.DamageZone.BeforeADD = ctx.DamageZone.Damage
|
|
|
|
|
ok := ctx.Input.Exec(func(t Effect) bool {
|
2025-09-28 01:58:42 +08:00
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
t.Damage_ADD(ctx) //红伤落实前,我方增伤
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
})
|
|
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
ctx.Input.DamageZone.BeforeMul = ctx.DamageZone.Damage
|
|
|
|
|
if ok {
|
|
|
|
|
ok = ctx.Input.Exec(func(t Effect) bool {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
t.Damage_Mul(ctx) //红伤落实前,我方增伤
|
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-09-28 08:13:42 +00:00
|
|
|
ctx.Input.DamageZone.BeforeMul = ctx.DamageZone.Damage //反弹伤害记录
|
|
|
|
|
if ok {
|
|
|
|
|
ok = u.Exec(func(t Effect) bool {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
t.Damage_DIV(ctx) //红伤落实,内部有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-09-28 08:13:42 +00:00
|
|
|
ctx.Input.DamageZone.BeforeSUB = ctx.DamageZone.Damage
|
|
|
|
|
if ok {
|
|
|
|
|
ok = u.Exec(func(t Effect) bool {
|
|
|
|
|
|
|
|
|
|
t.Damage_SUB(ctx)
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx.Input.DamageZone.BeforeLock = ctx.DamageZone.Damage
|
|
|
|
|
if ok {
|
|
|
|
|
ok = u.Exec(func(t Effect) bool {
|
|
|
|
|
|
|
|
|
|
t.Damage_Lock(ctx)
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ctx.DamageZone.Type == info.DamageType.Red {
|
|
|
|
|
ctx.AttackValue.LostHp = uint32(ctx.DamageZone.Damage.IntPart()) //红伤落实
|
2025-09-26 13:33:55 +08:00
|
|
|
}
|
|
|
|
|
|
2025-09-28 08:13:42 +00:00
|
|
|
if uint32(ctx.DamageZone.Damage.IntPart()) > u.CurrentPet.Info.Hp {
|
2025-09-28 09:31:08 +00:00
|
|
|
|
2025-09-26 02:09:33 +00:00
|
|
|
u.CurrentPet.Info.Hp = 0
|
|
|
|
|
} else {
|
2025-09-28 08:13:42 +00:00
|
|
|
u.CurrentPet.Info.Hp = u.CurrentPet.Info.Hp - ctx.AttackValue.LostHp
|
2025-09-26 02:09:33 +00:00
|
|
|
}
|
2025-09-23 19:49:17 +00:00
|
|
|
|
|
|
|
|
//todo 待实现死亡effet
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-25 18:13:16 +00:00
|
|
|
// 施加方,类型,等级,操作类别,是否成功
|
|
|
|
|
func (u *Input) SetProp(in *Input, prop, level int8, ptype info.EnumAbilityOpType) (ret bool) {
|
2025-09-25 17:15:06 +00:00
|
|
|
canuseskill := u.Exec(func(t Effect) bool { //这个是能否使用技能
|
|
|
|
|
//结算状态
|
2025-09-28 08:13:42 +00:00
|
|
|
return t.Prop_Befer(in, prop, level, ptype) //返回本身结算,如果false,说明不能使用技能了
|
2025-09-23 22:34:02 +00:00
|
|
|
|
2025-09-25 17:15:06 +00:00
|
|
|
})
|
2025-09-26 18:39:59 +00:00
|
|
|
if !canuseskill {
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
var newValue int8
|
|
|
|
|
abfunc := func(prop, level int8, ptype info.EnumAbilityOpType) (ret bool) {
|
|
|
|
|
|
2025-09-25 18:13:16 +00:00
|
|
|
switch ptype {
|
2025-09-26 18:39:59 +00:00
|
|
|
case info.AbilityOpType.ADD:
|
|
|
|
|
newValue = utils.Min(u.AttackValue.Prop[prop]+int8(level), 6)
|
2025-09-25 18:13:16 +00:00
|
|
|
|
|
|
|
|
if newValue > u.AttackValue.Prop[prop] {
|
|
|
|
|
fmt.Println("属性值会增加")
|
2025-09-26 18:39:59 +00:00
|
|
|
return true
|
2025-09-25 18:13:16 +00:00
|
|
|
} else {
|
|
|
|
|
fmt.Println("属性值不会增加")
|
2025-09-26 18:39:59 +00:00
|
|
|
return false
|
2025-09-25 18:13:16 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
case info.AbilityOpType.SUB:
|
|
|
|
|
newValue = utils.Max(u.AttackValue.Prop[prop]+int8(level), -6)
|
|
|
|
|
if newValue < u.AttackValue.Prop[prop] {
|
|
|
|
|
fmt.Println("属性值会减少")
|
|
|
|
|
return true
|
|
|
|
|
} else {
|
|
|
|
|
fmt.Println("属性值不会增加")
|
|
|
|
|
return false
|
|
|
|
|
}
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
case info.AbilityOpType.RESET:
|
2025-09-25 20:34:33 +00:00
|
|
|
if level > 0 && u.AttackValue.Prop[prop] > 0 { //消强
|
2025-09-26 18:39:59 +00:00
|
|
|
newValue = 0
|
|
|
|
|
return true
|
|
|
|
|
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|
|
|
|
|
if level < 0 && u.AttackValue.Prop[prop] < 0 { //解弱
|
2025-09-26 18:39:59 +00:00
|
|
|
newValue = 0
|
|
|
|
|
return true
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
switch ptype {
|
|
|
|
|
|
|
|
|
|
case info.AbilityOpType.AbilityOpStealStrengthen:
|
|
|
|
|
|
|
|
|
|
temp := in.AttackValue.Prop[prop]
|
2025-09-25 18:13:16 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
if temp <= 0 { //对方没有强化
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
if abfunc(prop, temp, info.AbilityOpType.ADD) { //把对面的强化等级添加自身
|
|
|
|
|
u.AttackValue.Prop[prop] = newValue //成功把 强化更新
|
|
|
|
|
in.SetProp(u, prop, 1, info.AbilityOpType.RESET) //吸取后消除对面强化
|
2025-09-23 19:49:17 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case info.AbilityOpType.AbilityOpReverse:
|
|
|
|
|
temp := u.AttackValue.Prop[prop]
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
|
|
|
|
|
|
case level > 0: //反转强化
|
|
|
|
|
if temp <= 0 { //没有强化
|
|
|
|
|
return false
|
2025-09-25 18:13:16 +00:00
|
|
|
}
|
2025-09-26 18:39:59 +00:00
|
|
|
if abfunc(prop, temp*2, info.AbilityOpType.SUB) {
|
|
|
|
|
u.AttackValue.Prop[prop] = newValue
|
|
|
|
|
if temp == -u.AttackValue.Prop[prop] { //成功到对应弱化
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
} else {
|
|
|
|
|
return true
|
2025-09-25 18:13:16 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
}
|
2025-09-25 18:13:16 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
} else { //自身免弱或已到-6
|
|
|
|
|
|
|
|
|
|
return false
|
2025-09-25 18:13:16 +00:00
|
|
|
}
|
2025-09-26 18:39:59 +00:00
|
|
|
default: //反转弱化
|
|
|
|
|
if temp >= 0 { //没有弱化
|
|
|
|
|
return false
|
2025-09-25 18:13:16 +00:00
|
|
|
}
|
2025-09-26 18:39:59 +00:00
|
|
|
if abfunc(prop, -temp*2, info.AbilityOpType.ADD) {
|
|
|
|
|
u.AttackValue.Prop[prop] = newValue
|
|
|
|
|
if temp == -u.AttackValue.Prop[prop] { //成功到对应强化
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
} else {
|
|
|
|
|
return true
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
}
|
2025-09-25 20:34:33 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
} else { //自身免弱或已到-6
|
|
|
|
|
|
|
|
|
|
return false
|
2025-09-25 20:34:33 +00:00
|
|
|
}
|
2025-09-26 18:39:59 +00:00
|
|
|
}
|
2025-09-25 18:13:16 +00:00
|
|
|
|
2025-09-26 18:39:59 +00:00
|
|
|
case info.AbilityOpType.AbilityOpBounceWeaken:
|
|
|
|
|
temp := u.AttackValue.Prop[prop]
|
|
|
|
|
if temp >= 0 { //没有弱化
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if in.SetProp(u, prop, temp, info.AbilityOpType.SUB) {
|
|
|
|
|
|
|
|
|
|
u.SetProp(u, prop, -1, info.AbilityOpType.RESET) //消除自身弱化
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
default: //增加减少重置
|
|
|
|
|
|
|
|
|
|
if abfunc(prop, level, ptype) {
|
|
|
|
|
// 执行赋值
|
|
|
|
|
u.AttackValue.Prop[prop] = newValue
|
|
|
|
|
return true
|
2025-09-25 18:13:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2025-09-26 18:39:59 +00:00
|
|
|
|
|
|
|
|
return false
|
2025-09-23 19:49:17 +00:00
|
|
|
}
|
2025-09-23 23:33:15 +00:00
|
|
|
func (i *Input) GetAction(opp *Input) {
|
2025-09-23 22:34:02 +00:00
|
|
|
//使用1#技能,实际上要按照四个技能权重去使用
|
2025-09-23 23:33:15 +00:00
|
|
|
i.FightC.UseSkill(i.Player, int32(i.FightC.GetCurrPET(i.Player).Skills[0].ID))
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算技能威力
|
2025-09-24 12:40:13 +08:00
|
|
|
func (i *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) decimal.Decimal {
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
// 1. 计算等级因子 (level * 0.4 + 2)
|
|
|
|
|
levelFactor := decimal.NewFromInt(int64(i.CurrentPet.Info.Level)).
|
|
|
|
|
Mul(decimal.NewFromFloat(0.4)).Add(decimal.NewFromInt(2))
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
attackDec decimal.Decimal //攻击值
|
|
|
|
|
defenseDec decimal.Decimal //防御值
|
|
|
|
|
|
|
|
|
|
)
|
2025-09-24 12:40:13 +08:00
|
|
|
|
2025-09-23 23:33:15 +00:00
|
|
|
switch skill.Category() { //判断技能类型
|
|
|
|
|
case info.Category.PHYSICAL:
|
2025-09-26 13:33:55 +08:00
|
|
|
attackDec = decimal.NewFromInt(int64(i.GetProp(0, false)))
|
|
|
|
|
defenseDec = decimal.NewFromInt(int64(deftype.GetProp(1, false)))
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
case info.Category.SPECIAL:
|
|
|
|
|
|
2025-09-26 13:33:55 +08:00
|
|
|
attackDec = decimal.NewFromInt(int64(i.GetProp(2, false)))
|
|
|
|
|
defenseDec = decimal.NewFromInt(int64(deftype.GetProp(3, false)))
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return decimal.NewFromInt(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 5. 基础伤害公式:等级因子 * 威力因子 * 攻击 / 防御 / 50 + 2
|
|
|
|
|
baseDamage := levelFactor.
|
|
|
|
|
Mul(decimal.NewFromInt(int64(skill.Power))).
|
|
|
|
|
Mul(attackDec).
|
|
|
|
|
Div(defenseDec).
|
|
|
|
|
Div(decimal.NewFromInt(50)).
|
|
|
|
|
Add(decimal.NewFromInt(2))
|
|
|
|
|
|
2025-09-24 12:40:13 +08:00
|
|
|
var typeRate decimal.Decimal
|
2025-09-26 13:33:55 +08:00
|
|
|
t, _ := element.NewElementCalculator().GetOffensiveMultiplier(skill.Type().ID, deftype.CurrentPet.Type().ID)
|
2025-09-24 12:40:13 +08:00
|
|
|
|
2025-09-26 13:33:55 +08:00
|
|
|
typeRate = decimal.NewFromFloat(t)
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
damage := baseDamage.
|
|
|
|
|
Mul(skill.CriticalsameTypeBonus()). // 同属性加成
|
|
|
|
|
Mul(typeRate). // 克制系数
|
|
|
|
|
|
|
|
|
|
Mul(skill.Criticalrandom()) //随机波动
|
|
|
|
|
|
|
|
|
|
return damage
|
2025-09-23 20:53:47 +00:00
|
|
|
|
|
|
|
|
}
|