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-11-08 18:37:11 +08:00
|
|
|
|
"blazing/common/data/xmlres"
|
2025-09-25 18:13:16 +00:00
|
|
|
|
"blazing/common/utils"
|
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-09-25 18:13:16 +00:00
|
|
|
|
"fmt"
|
2025-11-06 20:21:43 +00:00
|
|
|
|
"math/rand"
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
"github.com/shopspring/decimal"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
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) {
|
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
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if skill.CritAtkFirst != 0 && our.FightC.IsFirst(our.Player) {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
//CritAtkSecond: 后出手时必定致命一击; 默认: 0
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if skill.CritAtkSecond != 0 && !our.FightC.IsFirst(our.Player) {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
// CritSelfHalfHp: 自身体力低于一半时必定致命一击; 默认: 0
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if skill.CritSelfHalfHp != 0 && (our.CurrentPet.HP < int(our.CurrentPet.Info.MaxHp)/2) {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
// CritFoeHalfHp: 对方体力低于一半时必定致命一击; 默认: 0
|
|
|
|
|
|
if skill.CritSelfHalfHp != 0 && (opp.CurrentPet.HP < int(opp.CurrentPet.Info.MaxHp)/2) {
|
|
|
|
|
|
CritRate = 16
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//todo 暴击伤害
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if t, _, _ := our.Player.Roll(625*CritRate, 10000); t {
|
2025-09-26 02:09:33 +00:00
|
|
|
|
skill.Crit = 1
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-29 02:40:35 +08:00
|
|
|
|
// 恢复血量
|
2025-11-12 13:44:21 +00:00
|
|
|
|
func (our *Input) Heal(in *Input, ac action.BattleActionI, value decimal.Decimal) {
|
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 &&
|
|
|
|
|
|
in == our {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.AttackValue.GainHp = int32(value.IntPart()) //道具有专门的回血包
|
2025-11-08 16:38:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if value.IsPositive() {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.CurrentPet.Info.Hp += uint32(value.IntPart())
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.CurrentPet.Info.Hp = utils.Min(our.CurrentPet.Info.Hp, our.CurrentPet.Info.MaxHp)
|
2025-11-08 16:38:41 +08:00
|
|
|
|
} else {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if uint32(value.Abs().IntPart()) > our.CurrentPet.Info.Hp {
|
|
|
|
|
|
our.CurrentPet.Info.Hp = 0
|
2025-11-08 16:38:41 +08:00
|
|
|
|
} else {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.CurrentPet.Info.Hp += uint32(value.IntPart())
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-11 05:54:24 +00:00
|
|
|
|
func (our *Input) HealPP(value int) {
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
for i := 0; i < len(our.CurrentPet.Info.SkillList); i++ {
|
2025-11-08 16:38:41 +08:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.CurrentPet.Info.SkillList[i].PP += uint32(value)
|
|
|
|
|
|
our.CurrentPet.Info.SkillList[i].PP = utils.Min(our.CurrentPet.Info.SkillList[i].PP, uint32(xmlres.SkillMap[int(our.CurrentPet.Info.SkillList[i].ID)].MaxPP))
|
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) {
|
2025-11-08 23:20:48 +08:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
for i := 0; i < len(our.CurrentPet.Info.SkillList); i++ {
|
|
|
|
|
|
if uint32(value) > our.CurrentPet.Info.SkillList[i].PP {
|
|
|
|
|
|
our.CurrentPet.Info.SkillList[i].PP = 0
|
2025-11-08 23:20:48 +08:00
|
|
|
|
} else {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.CurrentPet.Info.SkillList[i].PP -= uint32(value)
|
2025-11-08 23:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-29 02:40:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
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) {
|
2025-11-13 02:43:00 +08:00
|
|
|
|
if sub.Type == info.DamageType.Red { //每回合计算伤害的时候重置伤害
|
|
|
|
|
|
our.Opp.DamageZone.Damage = sub.Damage
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-12 13:44:21 +00:00
|
|
|
|
// 对方对我方造成,需要吃到对方的加成
|
|
|
|
|
|
var ok bool
|
|
|
|
|
|
if our != in {
|
|
|
|
|
|
ok = our.Opp.Exec(func(t Effect) bool {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Ctx().DamageZone = sub
|
2025-09-26 02:09:33 +00:00
|
|
|
|
|
2025-11-12 13:44:21 +00:00
|
|
|
|
t.Damage_ADD() //红伤落实前,我方增伤
|
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 {
|
|
|
|
|
|
ok = our.Opp.Exec(func(t Effect) bool {
|
|
|
|
|
|
t.Ctx().DamageZone = sub
|
|
|
|
|
|
t.Damage_Mul() //红伤落实前,我方增伤
|
|
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
//sub.BeforeFloor = sub.Damage
|
|
|
|
|
|
if ok {
|
|
|
|
|
|
ok = our.Opp.Exec(func(t Effect) bool {
|
|
|
|
|
|
t.Ctx().DamageZone = sub
|
|
|
|
|
|
t.Damage_Floor() //红伤落实,内部有befer
|
|
|
|
|
|
|
|
|
|
|
|
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 {
|
2025-11-12 13:44:21 +00:00
|
|
|
|
ok = our.Exec(func(t Effect) bool {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Ctx().DamageZone = sub
|
|
|
|
|
|
t.Damage_DIV_ex() //红伤落实,内部有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 {
|
2025-11-12 13:44:21 +00:00
|
|
|
|
ok = our.Exec(func(t Effect) bool {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Ctx().DamageZone = sub
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Damage_SUB_ex()
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-09 02:29:21 +00:00
|
|
|
|
// sub.BeforeLock = sub.Damage
|
2025-11-12 13:44:21 +00:00
|
|
|
|
if ok && in != our {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
ok = our.Opp.Exec(func(t Effect) bool {
|
2025-11-09 02:29:21 +00:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Damage_Lock()
|
2025-09-29 02:40:35 +08:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-11-09 02:29:21 +00:00
|
|
|
|
//sub.BeforeLocked = sub.Damage
|
2025-09-28 08:13:42 +00:00
|
|
|
|
if ok {
|
2025-11-12 13:44:21 +00:00
|
|
|
|
our.Exec(func(t Effect) bool {
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
t.Damage_Lock_ex()
|
2025-09-28 08:13:42 +00:00
|
|
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if sub.Type == info.DamageType.Red { //红才会产生造成伤害
|
2025-11-13 02:43:00 +08:00
|
|
|
|
our.Opp.DamageZone.Damage = sub.Damage // 叠加总伤害 这里相当于记录红伤
|
2025-11-12 13:44:21 +00:00
|
|
|
|
our.Opp.AttackValue.LostHp = uint32(our.Opp.DamageZone.Damage.IntPart()) //红伤落实
|
2025-09-26 13:33:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-13 02:43:00 +08:00
|
|
|
|
if uint32(sub.Damage.IntPart()) > our.CurrentPet.Info.Hp {
|
2025-09-28 09:31:08 +00:00
|
|
|
|
|
2025-11-12 13:44:21 +00:00
|
|
|
|
our.CurrentPet.Info.Hp = 0
|
2025-09-26 02:09:33 +00:00
|
|
|
|
} else {
|
2025-11-13 02:43:00 +08:00
|
|
|
|
our.CurrentPet.Info.Hp = our.CurrentPet.Info.Hp - uint32(sub.Damage.IntPart())
|
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
|
|
|
|
// 施加方,类型,等级,操作类别,是否成功
|
2025-11-11 05:54:24 +00:00
|
|
|
|
func (our *Input) SetProp(in *Input, prop, level int8, ptype info.EnumAbilityOpType) (ret bool) {
|
|
|
|
|
|
//in.Our = our //设置属性的角色是我方
|
|
|
|
|
|
canuseskill := our.Exec(func(t Effect) bool { //这个是能否使用技能
|
2025-09-25 17:15:06 +00:00
|
|
|
|
//结算状态
|
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:
|
2025-11-11 05:54:24 +00:00
|
|
|
|
newValue = utils.Min(our.AttackValue.Prop[prop]+int8(level), 6)
|
2025-09-25 18:13:16 +00:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if newValue > our.AttackValue.Prop[prop] {
|
2025-09-25 18:13:16 +00:00
|
|
|
|
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:
|
2025-11-11 05:54:24 +00:00
|
|
|
|
newValue = utils.Max(our.AttackValue.Prop[prop]+int8(level), -6)
|
|
|
|
|
|
if newValue < our.AttackValue.Prop[prop] {
|
2025-09-26 18:39:59 +00:00
|
|
|
|
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-11-11 05:54:24 +00:00
|
|
|
|
if level > 0 && our.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-11-11 05:54:24 +00:00
|
|
|
|
if level < 0 && our.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:
|
|
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
temp := our.Opp.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) { //把对面的强化等级添加自身
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.AttackValue.Prop[prop] = newValue //成功把 强化更新
|
|
|
|
|
|
our.Opp.SetProp(our, 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:
|
2025-11-11 05:54:24 +00:00
|
|
|
|
temp := our.AttackValue.Prop[prop]
|
2025-09-26 18:39:59 +00:00
|
|
|
|
|
|
|
|
|
|
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) {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.AttackValue.Prop[prop] = newValue
|
|
|
|
|
|
if temp == -our.AttackValue.Prop[prop] { //成功到对应弱化
|
2025-09-26 18:39:59 +00:00
|
|
|
|
|
|
|
|
|
|
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) {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.AttackValue.Prop[prop] = newValue
|
|
|
|
|
|
if temp == -our.AttackValue.Prop[prop] { //成功到对应强化
|
2025-09-26 18:39:59 +00:00
|
|
|
|
|
|
|
|
|
|
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:
|
2025-11-11 05:54:24 +00:00
|
|
|
|
temp := our.AttackValue.Prop[prop]
|
2025-09-26 18:39:59 +00:00
|
|
|
|
if temp >= 0 { //没有弱化
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
if our.Opp.SetProp(our, prop, temp, info.AbilityOpType.SUB) {
|
2025-09-26 18:39:59 +00:00
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.SetProp(our, prop, -1, info.AbilityOpType.RESET) //消除自身弱化
|
2025-09-26 18:39:59 +00:00
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
default: //增加减少重置
|
|
|
|
|
|
|
|
|
|
|
|
if abfunc(prop, level, ptype) {
|
|
|
|
|
|
// 执行赋值
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.AttackValue.Prop[prop] = newValue
|
2025-09-26 18:39:59 +00:00
|
|
|
|
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-11-11 05:54:24 +00:00
|
|
|
|
func (our *Input) GetAction(opp *Input) {
|
2025-11-06 20:21:43 +00:00
|
|
|
|
// 获取己方当前宠物和对方当前宠物
|
2025-11-11 05:54:24 +00:00
|
|
|
|
selfPet := our.FightC.GetCurrPET(our.Player)
|
2025-11-10 08:25:40 +00:00
|
|
|
|
//没血就切换精灵
|
|
|
|
|
|
if selfPet.Info.Hp <= 0 {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
for _, v := range our.AllPet {
|
|
|
|
|
|
if v.Info.Hp > 0 {
|
|
|
|
|
|
our.FightC.ChangePet(our.Player, v.Info.CatchTime)
|
2025-11-10 08:25:40 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-11-11 05:54:24 +00:00
|
|
|
|
|
2025-11-10 08:25:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-11-06 20:21:43 +00:00
|
|
|
|
//oppPet := opp.FightC.GetCurrPET(opp.Player)
|
|
|
|
|
|
skills := selfPet.Skills
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
2025-11-06 20:21:43 +00:00
|
|
|
|
// 空技能列表直接返回,避免错误
|
|
|
|
|
|
if len(skills) == 0 {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 步骤1:计算所有技能的伤害,并筛选出能秒杀对方的技能
|
|
|
|
|
|
var killableSkills []struct {
|
|
|
|
|
|
*info.SkillEntity // 技能对象(假设原技能类型为skill)
|
|
|
|
|
|
damage decimal.Decimal // 技能实际伤害
|
|
|
|
|
|
}
|
|
|
|
|
|
// 存储所有技能及伤害(用于后续筛选)
|
|
|
|
|
|
type skillWithDamage struct {
|
|
|
|
|
|
*info.SkillEntity
|
|
|
|
|
|
damage decimal.Decimal
|
|
|
|
|
|
}
|
|
|
|
|
|
allSkills := make([]skillWithDamage, 0, len(skills))
|
|
|
|
|
|
|
|
|
|
|
|
for _, s := range skills {
|
2025-11-07 22:50:34 +08:00
|
|
|
|
if s == nil {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
2025-11-06 20:21:43 +00:00
|
|
|
|
// 计算技能对对方的伤害(假设CalculatePower返回伤害值,或需从技能中获取)
|
2025-11-11 05:54:24 +00:00
|
|
|
|
damage := our.CalculatePower(opp, s)
|
2025-11-06 20:21:43 +00:00
|
|
|
|
|
|
|
|
|
|
if !s.CanUse() {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
|
|
|
|
|
allSkills = append(allSkills, skillWithDamage{SkillEntity: s, damage: damage})
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否能秒杀(伤害 >= 对方当前生命值)
|
|
|
|
|
|
if uint32(damage.IntPart()) >= opp.CurrentPet.Info.Hp { // 假设oppPet.HP为对方当前剩余生命值
|
|
|
|
|
|
killableSkills = append(killableSkills, struct {
|
|
|
|
|
|
*info.SkillEntity
|
|
|
|
|
|
damage decimal.Decimal
|
|
|
|
|
|
}{s, damage})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 若存在能秒杀的技能,优先使用(选权重最高的,避免浪费高伤害技能)
|
|
|
|
|
|
if len(killableSkills) > 0 {
|
|
|
|
|
|
bestKillSkill := killableSkills[0].SkillEntity
|
|
|
|
|
|
// maxWeight := killableSkills[0].SkillEntity.Weight // 假设技能有Weight字段表示权重
|
|
|
|
|
|
// for _, ks := range killableSkills[1:] {
|
|
|
|
|
|
// if ks.skill.Weight > maxWeight {
|
|
|
|
|
|
// maxWeight = ks.skill.Weight
|
|
|
|
|
|
// bestKillSkill = ks.skill
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.FightC.UseSkill(our.Player, int32(bestKillSkill.ID))
|
2025-11-06 20:21:43 +00:00
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
randomIdx := rand.Intn(len(allSkills))
|
|
|
|
|
|
chosenSkill := skills[randomIdx]
|
2025-11-11 05:54:24 +00:00
|
|
|
|
our.FightC.UseSkill(our.Player, int32(chosenSkill.ID))
|
2025-11-06 20:21:43 +00:00
|
|
|
|
// i.FightC.UseSkill(i.Player, int32(bestSkill.skill.ID))
|
2025-09-23 23:33:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 计算技能威力
|
2025-11-11 05:54:24 +00:00
|
|
|
|
func (our *Input) CalculatePower(deftype *Input, skill *info.SkillEntity) decimal.Decimal {
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
// 1. 计算等级因子 (level * 0.4 + 2)
|
2025-11-11 05:54:24 +00:00
|
|
|
|
levelFactor := decimal.NewFromInt(int64(our.CurrentPet.Info.Level)).
|
2025-09-23 23:33:15 +00:00
|
|
|
|
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-11-11 05:54:24 +00:00
|
|
|
|
attackDec = decimal.NewFromInt(int64(our.GetProp(0, false)))
|
2025-09-26 13:33:55 +08:00
|
|
|
|
defenseDec = decimal.NewFromInt(int64(deftype.GetProp(1, false)))
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
|
|
|
|
|
case info.Category.SPECIAL:
|
|
|
|
|
|
|
2025-11-11 05:54:24 +00:00
|
|
|
|
attackDec = decimal.NewFromInt(int64(our.GetProp(2, false)))
|
2025-09-26 13:33:55 +08:00
|
|
|
|
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-11-04 14:01:17 +00:00
|
|
|
|
//fmt.Println(skill.Type().ID, deftype.CurrentPet.Type().ID)
|
2025-11-06 17:25:16 +00:00
|
|
|
|
t, _ := element.Calculator.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-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
|
|
|
|
|
|
if skill.DmgBindLv != 0 {
|
|
|
|
|
|
baseDamage = decimal.NewFromInt(int64(deftype.CurrentPet.Info.Level))
|
2025-09-23 23:33:15 +00:00
|
|
|
|
|
2025-11-09 03:06:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
if skill.PwrBindDv != 0 {
|
|
|
|
|
|
if skill.PwrBindDv == 1 {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
baseDamage = decimal.NewFromInt(int64(our.CurrentPet.Info.Dv * 5))
|
2025-11-09 03:06:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
if skill.PwrBindDv == 2 {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
baseDamage = decimal.NewFromInt(int64(our.CurrentPet.Info.Hp/3 + our.CurrentPet.Info.Dv))
|
2025-11-09 03:06:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if skill.PwrDouble != 0 {
|
|
|
|
|
|
|
|
|
|
|
|
if deftype.StatEffect_Exist_all() {
|
|
|
|
|
|
baseDamage = baseDamage.Mul(decimal.NewFromInt(2))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if skill.DmgBindHpDv != 0 {
|
2025-11-11 05:54:24 +00:00
|
|
|
|
baseDamage = decimal.NewFromInt(int64(our.CurrentPet.Info.Hp/2 + our.CurrentPet.Info.Dv))
|
2025-11-09 03:06:18 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
|
}
|