- 新增 AI_player 结构体的 CanCapture 字段,用于判断是否可捕捉 - 优化 BattlePetEntity 的 Accuracy 方法,增加对负强化等级的处理 - 修改 BattleSkillEntity 的 AttackTime 方法,增加必中判断 - 更新 FightC 中的捕捉逻辑,支持 AI 玩家的捕捉判断 - 重构战斗流程中的技能攻击逻辑,优化命中率计算和效果执行
255 lines
9.4 KiB
Go
255 lines
9.4 KiB
Go
package info
|
||
|
||
import (
|
||
"blazing/modules/blazing/model"
|
||
"fmt"
|
||
)
|
||
|
||
type ChangePetInfo struct {
|
||
// UserId 米米号,野怪为0
|
||
UserId uint32 `json:"userId"`
|
||
// PetId 切换上场的精灵编号
|
||
ID uint32 `fieldDesc:"当前对战精灵ID" `
|
||
// PetName 精灵名字,固定16字节长度
|
||
Name string `struc:"[16]byte"`
|
||
// Level 切换上场的精灵等级
|
||
Level uint32 `json:"level"`
|
||
// Hp 切换上场的精灵当前生命值
|
||
Hp uint32 `json:"hp"`
|
||
// MaxHp 切换上场的精灵最大生命值
|
||
MaxHp uint32 `json:"maxHp"`
|
||
CatchTime uint32 `fieldDesc:"捕捉时间" `
|
||
}
|
||
|
||
// FightPetInfo 战斗精灵信息结构体,FightPetInfo类
|
||
type FightPetInfo struct {
|
||
// 用户ID(野怪为0),@UInt long
|
||
UserID uint32 `fieldDesc:"用户ID 野怪为0" `
|
||
|
||
// 当前对战精灵ID,@UInt long
|
||
ID uint32 `fieldDesc:"当前对战精灵ID" `
|
||
|
||
Name string `struc:"[16]byte"`
|
||
// 精灵的捕获时间,@UInt long
|
||
CatchTime uint32 `fieldDesc:"精灵的捕获时间" `
|
||
|
||
// 当前HP,@UInt long
|
||
Hp uint32 `fieldDesc:"当前HP" `
|
||
|
||
// 最大HP,@UInt long
|
||
MaxHp uint32 `fieldDesc:"最大HP" `
|
||
|
||
// 当前等级,@UInt long
|
||
Level uint32 `fieldDesc:"当前等级" `
|
||
|
||
// 精灵是否能捕捉(1为能捕捉,0为不能捕捉),
|
||
Catchable uint32 `fieldDesc:"精灵是否能捕捉. 1为能捕捉 0为不能捕捉" `
|
||
//能力提升属性
|
||
Prop PropDict
|
||
}
|
||
type AttackValueS struct {
|
||
FAttack AttackValue
|
||
SAttack AttackValue
|
||
}
|
||
|
||
func NewAttackValue(userid uint32) *AttackValue {
|
||
return &AttackValue{
|
||
userid,
|
||
0,
|
||
0,
|
||
0,
|
||
0,
|
||
0,
|
||
0,
|
||
0,
|
||
0,
|
||
[]model.SkillInfo{},
|
||
0,
|
||
StatusDict{},
|
||
PropDict{},
|
||
}
|
||
}
|
||
|
||
// AttackValue 战斗中的攻击数值信息
|
||
type AttackValue struct {
|
||
UserID uint32 `json:"userId" fieldDescription:"玩家的米米号 与野怪对战userid = 0"`
|
||
SkillID uint32 `json:"skillId" fieldDescription:"使用技能的id"`
|
||
AttackTime uint32 `json:"attackTime" fieldDescription:"是否击中 如果为0 则miss 如果为1 则击中"`
|
||
LostHp uint32 `json:"lostHp" fieldDescription:"我方造成的伤害"`
|
||
GainHp int32 `json:"gainHp" fieldDescription:"我方获得血量"`
|
||
RemainHp int32 `json:"remainHp" fieldDescription:"我方剩余血量"`
|
||
MaxHp uint32 `json:"maxHp" fieldDescription:"我方最大血量"`
|
||
State uint32 `json:"state" fieldDescription:"固定值0 需要后续测试"`
|
||
SkillListLen uint32 `struc:"sizeof=SkillList"`
|
||
SkillList []model.SkillInfo `json:"skillList" fieldDescription:"根据精灵的数据插入技能 最多4条 不定长"`
|
||
IsCritical uint32 `json:"isCritical" fieldDescription:"是否暴击"`
|
||
Status StatusDict //精灵的状态
|
||
//能力提升属性
|
||
Prop PropDict
|
||
// OwnerMaxShield uint32 `json:"ownerMaxShield" fieldDescription:"我方最大护盾"`
|
||
// OwnerCurrentShield uint32 `json:"ownerCurrentShield" fieldDescription:"我方当前护盾"`
|
||
}
|
||
|
||
type WeakenedS struct {
|
||
Stack int8 `struc:"skip"`
|
||
Round int8
|
||
}
|
||
type StatusDict struct {
|
||
Paralysis_0 int8 // 0: 麻痹
|
||
Poisoned_1 int8 // 1: 中毒
|
||
Burned_2 int8 // 2: 烧伤
|
||
DrainHP_3 int8 // 3: 吸取对方的体力
|
||
DrainedHP_4 int8 // 4: 被对方吸取体力
|
||
Frozen_5 int8 // 5: 冻伤
|
||
Fear_6 int8 // 6: 害怕
|
||
Tired_7 int8 // 7: 疲惫
|
||
Sleep_8 int8 // 8: 睡眠
|
||
Petrified_9 int8 // 9: 石化
|
||
Confused_10 int8 // 10: 混乱
|
||
Weakened_11 WeakenedS // 11: 衰弱
|
||
MountainGodGuard_12 int8 // 12: 山神守护
|
||
Flammable_13 int8 // 13: 易燃
|
||
Berserk_14 int8 // 14: 狂暴
|
||
IceBound_15 int8 // 15: 冰封
|
||
Bleeding_16 int8 // 16: 流血
|
||
ImmuneToStatDrop_17 int8 // 17: 免疫能力下降
|
||
ImmuneToAbnormal_18 int8 // 18: 免疫异常状态
|
||
Paralyzed_19 int8 // 19: 瘫痪
|
||
//Blind_20 byte // 20: 失明
|
||
}
|
||
|
||
// 精灵的能力提升
|
||
type PropDict struct {
|
||
// 攻击(@UInt long → uint32)
|
||
Attack int8
|
||
// 防御(@UInt long → uint32)
|
||
Defence int8
|
||
// 特攻(@UInt long → uint32)
|
||
SpecialAttack int8
|
||
// 特防(@UInt long → uint32)
|
||
SpecialDefence int8
|
||
|
||
// 速度(@UInt long → uint32)
|
||
Speed int8
|
||
// 命中(@UInt long → uint32)
|
||
Accuracy int8
|
||
}
|
||
|
||
// BattleLevels 战斗属性等级结构体,对应原6字节数组
|
||
|
||
// NoteUseSkillOutboundInfo 战斗技能使用通知的出站信息结构体
|
||
type NoteUseSkillOutboundInfo struct {
|
||
FirstAttackInfo AttackValue // 本轮先手的精灵在释放技能结束后的状态
|
||
SecondAttackInfo AttackValue // 本轮后手的精灵在释放技能结束后的状态
|
||
}
|
||
|
||
type FightStartOutboundInfo struct {
|
||
// @UInt long类型
|
||
IsCanAuto uint32 `fieldDesc:"是否自动 默认给0 怀疑是自动战斗器使用的" `
|
||
|
||
// 当前战斗精灵信息1(前端通过userid判断是否为我方)
|
||
Info1 FightPetInfo `fieldDesc:"当前战斗精灵的信息 可能不准.看前端代码是以userid来判断哪个结构体是我方的" serialize:"struct"`
|
||
|
||
// 当前战斗精灵信息2(前端通过userid判断是否为我方)
|
||
Info2 FightPetInfo `fieldDesc:"当前战斗精灵的信息 可能不准.看前端代码是以userid来判断哪个结构体是我方的" serialize:"struct"`
|
||
}
|
||
|
||
type FightUserInfo struct {
|
||
// 用户ID(野怪为0),@UInt long
|
||
UserID uint32 `fieldDesc:"userID 如果为野怪则为0" `
|
||
|
||
// 玩家名称(野怪为UTF-8的'-',固定16字节)
|
||
// 使用[16]byte存储固定长度的字节数组
|
||
Nick string `struc:"[16]byte"`
|
||
}
|
||
|
||
// NoteReadyToFightInfo 战斗准备就绪消息结构体,NoteReadyToFightInfo
|
||
type NoteReadyToFightInfo struct {
|
||
MAXPET uint32 `struc:"skip"` // 最大精灵数 struc:"skip"`
|
||
// 战斗类型ID(与野怪战斗为3,与人战斗为1,前端似乎未使用)
|
||
// @UInt long
|
||
FightId EnumBattleMode `fieldDesc:"战斗类型ID 但前端好像没有用到 与野怪战斗为3,与人战斗似乎是1" `
|
||
|
||
// 我方信息
|
||
OurInfo FightUserInfo `fieldDesc:"我方信息" serialize:"struct"`
|
||
// Our *socket.Player `struc:"skip"`
|
||
OurPetListLen uint32 `struc:"sizeof=OurPetList"`
|
||
// 我方携带精灵的信息
|
||
// ArrayList<ReadyFightPetInfo>,使用切片模拟动态列表
|
||
OurPetList []ReadyFightPetInfo `fieldDesc:"我方携带精灵的信息" serialize:"lengthFirst,lengthType=uint16,type=structArray"`
|
||
|
||
// 对方信息
|
||
OpponentInfo FightUserInfo `fieldDesc:"对方信息" serialize:"struct"`
|
||
//Opp *socket.Player `struc:"skip"`
|
||
OpponentPetListLen uint32 `struc:"sizeof=OpponentPetList"`
|
||
// 敌方的精灵信息
|
||
// 野怪战斗时:客户端接收此包前已生成精灵PetInfo,将部分信息写入该列表
|
||
OpponentPetList []ReadyFightPetInfo `fieldDesc:"敌方的精灵信息 如果是野怪 那么再给客户端发送这个包体时就提前生成好了这只精灵的PetInfo,然后把从PetInfo中把部分信息写入到这个敌方的精灵信息中再发送这个包结构体" serialize:"lengthFirst,lengthType=uint16,type=structArray"`
|
||
}
|
||
|
||
// 当A和B都 这时候给双方回复开始战斗包
|
||
func (t *NoteReadyToFightInfo) onBothFinished() {
|
||
fmt.Println("A和B都已完成,触发onBothFinished")
|
||
}
|
||
|
||
// ReadyFightPetInfo 准备战斗的精灵信息结构体,ReadyFightPetInfo类
|
||
type ReadyFightPetInfo struct {
|
||
// 精灵ID,@UInt long
|
||
ID uint32 `fieldDesc:"精灵ID" `
|
||
NotAlive bool `struc:"skip"`
|
||
|
||
// 精灵等级,@UInt long
|
||
Level uint32 `fieldDesc:"精灵等级" `
|
||
|
||
// 精灵当前HP,@UInt long
|
||
Hp uint32 `fieldDesc:"精灵HP" `
|
||
|
||
// 精灵最大HP,@UInt long
|
||
MaxHp uint32 `fieldDesc:"最大HP" `
|
||
SkillListLen uint32
|
||
// 技能信息列表(固定4个元素,技能ID和剩余PP,无技能则为0)
|
||
// List<SkillInfo>,初始化容量为4
|
||
SkillList [4]model.SkillInfo `fieldDesc:"技能信息 技能ID跟剩余PP 固定32字节 没有给0" serialize:"fixedLength=4,type=structArray"`
|
||
|
||
// 精灵捕获时间,@UInt long
|
||
CatchTime uint32 `fieldDesc:"精灵捕获时间" `
|
||
|
||
// 捕捉地图(固定给0),@UInt long
|
||
CatchMap uint32 `fieldDesc:"捕捉地图 给0" `
|
||
|
||
// 固定给0,@UInt long
|
||
CatchRect uint32 `fieldDesc:"给0" `
|
||
|
||
// 固定给0,@UInt long
|
||
CatchLevel uint32 `fieldDesc:"给0" `
|
||
SkinID uint32 `fieldDesc:"精灵皮肤ID" `
|
||
Shiny uint32 `fieldDesc:"精灵是否闪" `
|
||
}
|
||
|
||
// FightOverInfo 战斗结束信息结构体 2506
|
||
type FightOverInfo struct {
|
||
//1=isPlayerLost 对方玩家退出
|
||
// 2=isOvertime 正常对战结束?有质疑
|
||
// 3=isDraw 双方平手
|
||
// 4=isSysError 系统错误
|
||
// 5=isNpcEscape 精灵主动逃跑
|
||
Reason uint32 // 固定值0
|
||
WinnerId uint32 // 胜者的米米号 野怪为0
|
||
TwoTimes uint32 // 双倍经验剩余次数
|
||
ThreeTimes uint32 // 三倍经验剩余次数
|
||
AutoFightTimes uint32 // 自动战斗剩余次数
|
||
EnergyTimes uint32 // 能量吸收器剩余次数
|
||
LearnTimes uint32 // 双倍学习器剩余次数
|
||
}
|
||
|
||
// CatchMonsterOutboundInfo 捕捉怪物的出站消息结构体
|
||
// 对应Java的CatchMonsterOutboundInfo类
|
||
type CatchMonsterOutboundInfo struct {
|
||
// CatchTime 捕捉时间
|
||
// 对应Java的@UInt long类型,映射为uint64
|
||
CatchTime uint32 `json:"catchTime" fieldDescription:"捕捉时间" uint:"true"`
|
||
// PetId 宠物编号
|
||
// 对应Java的@UInt long类型,映射为uint64
|
||
PetId uint32 `json:"petId" fieldDescription:"宠物编号" uint:"true"`
|
||
}
|