diff --git a/logic/controller/fight_boss野怪和地图怪.go b/logic/controller/fight_boss野怪和地图怪.go index d24d4e956..ccd405485 100644 --- a/logic/controller/fight_boss野怪和地图怪.go +++ b/logic/controller/fight_boss野怪和地图怪.go @@ -161,35 +161,44 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf fight.NewFight(p, ai, func(foi info.FightOverInfo) { //p.Done.Exec(model.MilestoneMode.Moster, []uint32{p.Info.MapID, monsterInfo.PetList[0].ID, uint32(foi.Reason)}, nil) - if foi.Reason == 0 && foi.WinnerId == p.Info.UserID { + if foi.Reason == 0 && foi.WinnerId == p.Info.UserID && p.CanGet() { exp := uint32(xmlres.PetMAP[int(monster.ID)].YieldingExp) * monster.Level / 7 addlevel, poolevel := p.CanGetExp() addexp := gconv.Float32(addlevel * gconv.Float32(exp)) - if addexp != 0 { - poolexp := gconv.Float32(poolevel) * gconv.Float32((exp)) - items := &info.S2C_GET_BOSS_MONSTER{} - p.ItemAdd(3, int64(poolexp+addexp)) - items.ItemList = append(items.ItemList, data.ItemInfo{ - ItemId: 3, - ItemCnt: int64(poolexp), - }) - p.AddPetExp(foi.Winpet, int64(addexp)) - for _, v := range refPet.Item { - count := int64(grand.Intn(2) + 1) - ok := p.ItemAdd(v, count) - if ok { - items.ItemList = append(items.ItemList, data.ItemInfo{ - ItemId: v, - ItemCnt: count, - }) - } + poolexp := gconv.Float32(poolevel) * gconv.Float32((exp)) + items := &info.S2C_GET_BOSS_MONSTER{} + p.ItemAdd(3, int64(poolexp+addexp)) + items.ADDitem(3, uint32(poolexp)) + + p.AddPetExp(foi.Winpet, int64(addexp)) + + if p.CanGetXUAN() { + xuan := 400686 + int64(xmlres.PetMAP[int(refPet.GetID())].Type) + ok := p.ItemAdd(xuan, 1) + if ok { + items.ADDitem(uint32(xuan), 1) } - p.SendPackCmd(8004, items) } + if p.CanGetItem() { + mapinfo := service.NewMapService().GetData(p.Info.MapID) + + if len(mapinfo.DropItemIds) > 0 { + + item := int64(mapinfo.DropItemIds[grand.Intn(len(mapinfo.DropItemIds))]) + count := int64(grand.Intn(2) + 1) + ok := p.ItemAdd(item, count) + if ok { + items.ADDitem(uint32(item),uint32 (count)) + } + } + + } + + p.SendPackCmd(8004, items) evs := gconv.Int64s(strings.Split(xmlres.PetMAP[int(monster.ID)].YieldingEV, " ")) diff --git a/logic/service/fight/info/over.go b/logic/service/fight/info/over.go index 54fb13105..2cdd5a4ef 100644 --- a/logic/service/fight/info/over.go +++ b/logic/service/fight/info/over.go @@ -15,3 +15,10 @@ type S2C_GET_BOSS_MONSTER struct { // 2. 发放多个物品时:序列化时先写入 uint 类型的数组长度,再依次写入每个ItemInfo元素 // 3. 该List结构参考PetInfo的特性List(长度为Uint型,非int) } + +func (s *S2C_GET_BOSS_MONSTER) ADDitem(id, count uint32) { + s.ItemList = append(s.ItemList, data.ItemInfo{ + ItemId: int64(id), + ItemCnt: int64(count), + }) +} diff --git a/logic/service/player/Monster.go b/logic/service/player/Monster.go index f5db4b18b..a112be1fc 100644 --- a/logic/service/player/Monster.go +++ b/logic/service/player/Monster.go @@ -1,7 +1,6 @@ package player import ( - "blazing/cool" "blazing/modules/config/model" "blazing/modules/config/service" "sync/atomic" @@ -78,21 +77,8 @@ func (p *Player) GenMonster() { } p.Data[i].HandleNPCFightSpecial(v.IsCapture) - if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色 - p.Data[i].FixSHiny() - } else { - if p.Data[i].IsCapture != 0 && grand.Meet(1, 500) { - p.Data[i].RandomByWeightShiny() - - } - } - - if grand.Meet(3, 10) && len(mapinfo.DropItemIds) > 0 { - - p.Data[i].Item = append(p.Data[i].Item, int64(mapinfo.DropItemIds[grand.Intn(len(mapinfo.DropItemIds))])) - - } + } } diff --git a/logic/service/player/player.go b/logic/service/player/player.go index e4727356f..f12a6be68 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -34,9 +34,10 @@ type OgrePetInfo struct { ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"` ShinyInfo []data.GlowFilter `json:"ShinyInfo,omitempty"` Lv uint32 `struc:"skip"` //等级 - Item []int64 `struc:"skip"` //奖励,如果有的话 - Ext uint32 `struc:"skip"` //是否变尼尔尼奥 - IsCapture int `struc:"skip"` + //XUANCAI int64 `struc:"skip"` + //Item int64 `struc:"skip"` //奖励,如果有的话 + Ext uint32 `struc:"skip"` //是否变尼尔尼奥 + IsCapture int `struc:"skip"` } func (o *OgrePetInfo) GetID() int { @@ -53,37 +54,6 @@ func (o *OgrePetInfo) GetLevel() int { } return int(o.Lv) } -func (o *OgrePetInfo) FixSHiny() { - var co *data.GlowFilter - if o.Ext == 0 { - - co = config.NewShinyService().RandShiny(o.ID) - } - - if co != nil && len(o.ShinyInfo) == 0 { - o.ShinyInfo = append(o.ShinyInfo, *co) - if grand.Meet(1, 2) { - o.Item = append(o.Item, 400686+int64(xmlres.PetMAP[int(o.ID)].Type)) - } - - } - -} -func (o *OgrePetInfo) RandomByWeightShiny() { - var co *data.GlowFilter - if o.Ext == 0 { - - co = config.NewShinyService().RandomByWeightShiny(o.ID) - } - - if co != nil && len(o.ShinyInfo) == 0 { - o.ShinyInfo = append(o.ShinyInfo, *co) - if grand.Meet(1, 2) { - o.Item = append(o.Item, 400686+int64(xmlres.PetMAP[int(o.ID)].Type)) - } - } - -} // handleNPCFightSpecial 处理NPC战斗特殊情况 func (o *OgrePetInfo) HandleNPCFightSpecial(v int) { @@ -106,7 +76,24 @@ func (o *OgrePetInfo) HandleNPCFightSpecial(v int) { } else { o.IsCapture = gconv.Int(petCfg.CatchRate) } + if o.Ext != 0 { + return + } + var co *data.GlowFilter + if cool.Config.ServerInfo.IsVip != 0 { //测试服,百分百异色 + co = config.NewShinyService().RandShiny(o.ID) + } else { + if o.IsCapture != 0 && grand.Meet(1, 500) { + + co = config.NewShinyService().RandomByWeightShiny(o.ID) + + } + } + if co != nil && len(o.ShinyInfo) == 0 { + o.ShinyInfo = append(o.ShinyInfo, *co) + + } } type Player struct { diff --git a/logic/service/player/save.go b/logic/service/player/save.go index c0f4ea1d9..cf8b94b7a 100644 --- a/logic/service/player/save.go +++ b/logic/service/player/save.go @@ -9,6 +9,8 @@ import ( "blazing/logic/service/space" "context" "time" + + "github.com/gogf/gf/v2/util/grand" ) // Save 保存玩家数据 @@ -62,18 +64,22 @@ func (p *Player) Save() { share.ShareManager.DeleteUserOnline(p.Info.UserID) //设置用户登录服务器 } - -// 经验倍数返回 -func (p *Player) CanGetExp() (float32, float32) { +func (p *Player) CanGet() bool { if p.Info.TimeToday >= p.Info.TimeLimit { - return 0, 0 + return false } islogintime := (int64(time.Now().Unix()) - int64(p.Logintime)) if islogintime > (p.Info.TimeLimit - p.Info.TimeToday) { - return 0, 0 + return false } + return true +} + +// 经验倍数返回 +func (p *Player) CanGetExp() (float32, float32) { + var base float32 = 1 if p.Info.TwoTimes != 0 { p.Info.TwoTimes-- @@ -87,3 +93,25 @@ func (p *Player) CanGetExp() (float32, float32) { } return (base), 0.2 } +func (p *Player) CanGetXUAN() bool { + var base = 1 + if p.Info.EnergyTime != 0 { + base = 2 + p.Info.EnergyTime-- + } + if grand.Meet(base, 2) { + return true + } + return false +} +func (p *Player) CanGetItem() bool { + var base = 3 + if p.Info.EnergyTime != 0 { + base = 6 + p.Info.EnergyTime-- + } + if grand.Meet(base, 10) { + return true + } + return false +}