diff --git a/logic/controller/fight.go b/logic/controller/fight.go index 919898cb..ab2f8397 100644 --- a/logic/controller/fight.go +++ b/logic/controller/fight.go @@ -26,11 +26,11 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla } mo = model.GenPetInfo( - int(petid), []int{0, 31}, - []int{0, 24}, - []int{0}, //野怪没特性 - []int{int(0)}, - []int{int(2)}) + int(petid), 24, //24个体 + -1, + 0, //野怪没特性 + 0, + 2) } if c.FightC != nil { @@ -41,6 +41,8 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla return nil, -1 } + +// 战斗野怪 func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { refpet := c.OgreInfo.Data[data.Number] @@ -49,11 +51,11 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn return nil, errorcode.ErrorCodes.ErrPokemonNotExists } mo := model.GenPetInfo( - int(refpet.Id), []int{0, 31}, - []int{0, 24}, - []int{0}, //野怪没特性 - []int{int(refpet.Shiny)}, - []int{int(refpet.Lv)}) + int(refpet.Id), -1, + -1, + 0, //野怪没特性 + int(refpet.Shiny), + int(refpet.Lv)) if c.FightC != nil { return nil, errorcode.ErrorCodes.ErrOnlineOver6HoursCannotFight diff --git a/logic/controller/task.go b/logic/controller/task.go index c406d46f..aebe9ddf 100644 --- a/logic/controller/task.go +++ b/logic/controller/task.go @@ -102,7 +102,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. case 3: petid = 4 } - r := model.GenPetInfo(petid, []int{0, 31}, []int{0, 24}, []int{0, 39}, []int{0}, []int{5}) + r := model.GenPetInfo(petid, 31, -1, 0, 0, 5) result.CaptureTime = r.CatchTime result.PetTypeId = r.ID c.Service.PetAdd(*r) diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index b218cdc2..34a918d8 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -72,6 +72,7 @@ func LastFourElements[T any](s []T) []T { return s[n-4:] } +// -1是随机 // * @param petTypeId 精灵类型ID // * @param individualValue 个体值 // * @param natureId 性格ID @@ -79,33 +80,58 @@ func LastFourElements[T any](s []T) []T { // * @param isShiny 是否为闪光 // * @param level 等级 // * @return 生成的精灵实体 -func GenPetInfo(id int, dv, natureId, abilityTypeEnum, shinyid, level []int) *PetInfo { +func GenPetInfo(id int, dv, natureId, abilityTypeEnum, shinyid, level int) *PetInfo { + // 设置随机数种子,确保每次运行生成不同的随机数序列 + rand.Seed(time.Now().UnixNano()) p := &PetInfo{ID: uint32(id), - Shiny: uint32(RandomInRange(shinyid)), //闪光 - Nature: uint32(RandomInRange(natureId)), //性格 - Dv: uint32(RandomInRange(dv)), + EffectInfo: make([]PetEffectInfo, 0), CatchTime: uint32(time.Now().Unix()), - Level: uint32(RandomInRange(level))} //等级 + Level: uint32(level)} //等级 naxml := xmlres.NatureRootMap[int(p.Nature)] petxml := xmlres.PetMAP[int(id)] + if shinyid != -1 { + p.Shiny = uint32(shinyid) + } else { - if abilityTypeEnum != nil { + } + if natureId != -1 { + p.Nature = uint32(natureId) + } else { + p.Nature = uint32(rand.Intn(25)) + } + if dv != -1 { + p.Dv = uint32(dv) + } else { + p.Dv = uint32(GetGaussRandomNum(int64(0), int64(31))) + } + if abilityTypeEnum != -1 { + if abilityTypeEnum != 0 { + v := xmlres.PlayerEffectMAP[int(abilityTypeEnum)] + p.EffectInfo = append(p.EffectInfo, PetEffectInfo{ + Idx: uint16(gconv.Int16(v.Idx)), + Status: 1, + EID: uint16(gconv.Int16(v.Eid)), + Args: v.ArgsS, + }) + } + + } else { for i, v := range xmlres.PlayerEffectMAP { - if RandomInRange(abilityTypeEnum) == i { + if rand.Intn(len(xmlres.PlayerEffectMAP)) == i { p.EffectInfo = append(p.EffectInfo, PetEffectInfo{ - EID: uint16(gconv.Int16(v.Eid)), - Args: v.ArgsS, + Idx: uint16(gconv.Int16(v.Idx)), + Status: 1, + EID: uint16(gconv.Int16(v.Eid)), + Args: v.ArgsS, }) } } - //p.EffectInfo[0].Args = []int{petxml.Type, 5} //默认等级1 - } tttt := make([]uint32, 0) for _, v := range petxml.LearnableMoves.Moves { @@ -292,7 +318,8 @@ type PetInfo struct { // // type PetEffectInfo struct { - ItemID uint32 `struc:"uint32" json:"item_id"` //如果是能量珠,就显示 + ItemID uint32 `struc:"uint32" json:"item_id"` //如果是能量珠,就显示 + Idx uint16 `struc:"skip" json:"new_se_idx"` Status byte `struc:"byte" json:"status"` //特性为1,能量珠为2 LeftCount byte `struc:"byte" json:"left_count"` //剩余次数 EID uint16 `struc:"uint16" json:"effect_id"` //特效ID