diff --git a/logic/controller/fight_boss.go b/logic/controller/fight_boss.go index b13be918e..2b6e25a15 100644 --- a/logic/controller/fight_boss.go +++ b/logic/controller/fight_boss.go @@ -162,6 +162,9 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn return nil, errorcode.ErrorCodes.ErrPokemonNotExists } + if refpet.Ext != 0 { + refpet.Id = refpet.Ext + } mo := model.GenPetInfo( int(refpet.Id), -1, -1, diff --git a/logic/service/player/Monster.go b/logic/service/player/Monster.go new file mode 100644 index 000000000..28d778b51 --- /dev/null +++ b/logic/service/player/Monster.go @@ -0,0 +1,143 @@ +package player + +import ( + "blazing/common/data/xmlres" + "blazing/logic/service/common" + "strings" + "sync/atomic" + + "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/grand" +) + +// 2. 从 string 类型 slice 随机选一个元素 +func RandomStringFromSlice(s []string) string { + + randomIdx := grand.Intn(len(s)) + return s[randomIdx] +} + +// 刷怪具体实现 +func (p *Player) SpawnMonsters() { + // 获取当前地图的怪物配置 + + // 创建数据包 + tt := common.NewTomeeHeader(2004, p.Info.UserID) + + p.genMonster() //生成野怪 + + p.SendPack(tt.Pack(&p.OgreInfo)) + +} + +// 应该根据怪物信息决定后端生成 +func (p *Player) genMonster() { + var oldnum, newNum int + p.monsters, oldnum, newNum = replaceOneNumber(p.monsters) + // 设置怪物信息 + t1 := OgreInfo{} + mapss, ok := xmlres.MonsterMap[gconv.Int(p.Info.MapID)] + + if ok && mapss.Monsters != nil { + ok, _, _ := p.PlayerCaptureContext.Roll(mapss.Monsters.WildBonusProb, mapss.Monsters.WildBonusTotalProb) + for i, m := range mapss.Monsters.Monsters { //这里是9个 + id := strings.Split(m.ID, " ") + lv := strings.Split(m.Lv, " ") + + ttt := OgrePetInfo{} + ttt.Id = gconv.Uint32(RandomStringFromSlice(id)) + + if ttt.Id != 0 { + ttt.Shiny = 0 //待确认是否刷新异色 + ttt.Lv = gconv.Uint32(RandomStringFromSlice(lv)) + + if len(id) == 1 { //说明这里只固定刷一个,概率变尼尔尼奥 + + // nier, _, _ := p.Roll(10, 1000) + // if nier { + // ttt.Ext = 77 + + // } + + nieo, _, _ := p.Roll(20, 1000) + if nieo { + ttt.Ext = 77 + if grand.Meet(1, 2) { + ttt.Ext = 416 + } + + ttt.Lv = 16 + } + + } + if ok { + + ttt.Item = uint32(mapss.Monsters.ItemBonusID) + + } + } + + t1.Data[i] = ttt + + } + + } + + if atomic.CompareAndSwapUint32(&p.Canmon, 2, 1) { + p.OgreInfo = OgreInfo{} //切地图清空 + for i := 0; i < 3; i++ { + + p.OgreInfo.Data[p.monsters[i]] = t1.Data[p.monsters[i]] + } + } + p.OgreInfo.Data[oldnum] = OgrePetInfo{} + p.OgreInfo.Data[newNum] = t1.Data[newNum] + +} + +// 生成0-9之间三个不重复的随机数 进地图5s +func generateThreeUniqueNumbers() [3]int { + + selected := make(map[int]bool) + var result [3]int + index := 0 + + for index < 3 { + num := grand.Intn(9) + if !selected[num] { + selected[num] = true + result[index] = num + index++ + } + } + return result +} + +// 从三个数字中移除一个,并从剩余6个数字中选一个补充 10s +func replaceOneNumber(original [3]int) ([3]int, int, int) { + // 随机选择要移除的索引(0-2) + removeIndex := grand.Intn(3) + removedNum := original[removeIndex] + + // 找出所有不在原始数组中的数字(候选数字) + candidates := []int{} + originalMap := make(map[int]bool) + for _, num := range original { + originalMap[num] = true + } + + for i := 0; i < 8; i++ { + if !originalMap[i] { + candidates = append(candidates, i) + } + } + + // 从候选数字中随机选择一个 + newNum := candidates[grand.Intn(len(candidates))] + + // 创建新数组并替换数字 + newNumbers := original + newNumbers[removeIndex] = newNum + + return newNumbers, removedNum, newNum +} diff --git a/logic/service/player/player.go b/logic/service/player/player.go index f4d80e2be..241341805 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -8,7 +8,6 @@ import ( "blazing/logic/service/common" "blazing/logic/service/fight/info" "blazing/logic/service/space" - "strings" "sync/atomic" "blazing/modules/base/service" @@ -18,8 +17,6 @@ import ( "github.com/antlabs/timer" "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/util/grand" "github.com/panjf2000/gnet/v2" ) @@ -44,6 +41,7 @@ type OgrePetInfo struct { Shiny uint32 Lv uint32 `struc:"skip"` //等级 Item uint32 `struc:"skip"` //奖励,如果有的话 + Ext uint32 `struc:"skip"` //是否变尼尔尼奥 } type Player struct { @@ -155,18 +153,6 @@ func (p *Player) CanFight() bool { } -// 刷怪具体实现 -func (p *Player) SpawnMonsters() { - // 获取当前地图的怪物配置 - - // 创建数据包 - tt := common.NewTomeeHeader(2004, p.Info.UserID) - - p.genMonster(p.Info.MapID) //生成野怪 - - p.SendPack(tt.Pack(&p.OgreInfo)) - -} func (p *Player) SendPack(b []byte) error { if p.MainConn == nil { return nil @@ -181,105 +167,6 @@ func (p *Player) SendPack(b []byte) error { } -// 2. 从 string 类型 slice 随机选一个元素 -func RandomStringFromSlice(s []string) string { - - randomIdx := grand.Intn(len(s)) - return s[randomIdx] -} - -// 应该根据怪物信息决定后端生成 -func (p *Player) genMonster(mapid uint32) { - var oldnum, newNum int - p.monsters, oldnum, newNum = replaceOneNumber(p.monsters) - // 设置怪物信息 - t1 := OgreInfo{} - mapss, ok := xmlres.MonsterMap[gconv.Int(mapid)] - - if ok && mapss.Monsters != nil { - ok, _, _ := p.PlayerCaptureContext.Roll(mapss.Monsters.WildBonusProb, mapss.Monsters.WildBonusTotalProb) - for i, m := range mapss.Monsters.Monsters { //这里是9个 - id := strings.Split(m.ID, " ") - lv := strings.Split(m.Lv, " ") - - ttt := OgrePetInfo{ - Id: gconv.Uint32(RandomStringFromSlice(id)), - } - if ok { - - ttt.Item = uint32(mapss.Monsters.ItemBonusID) - - } - if ttt.Id != 0 { - ttt.Shiny = 0 //待确认是否刷新异色 - ttt.Lv = gconv.Uint32(RandomStringFromSlice(lv)) - } - - t1.Data[i] = ttt - - } - - } - - if atomic.CompareAndSwapUint32(&p.Canmon, 2, 1) { - p.OgreInfo = OgreInfo{} //切地图清空 - for i := 0; i < 3; i++ { - - p.OgreInfo.Data[p.monsters[i]] = t1.Data[p.monsters[i]] - } - } - p.OgreInfo.Data[oldnum] = OgrePetInfo{} - p.OgreInfo.Data[newNum] = t1.Data[newNum] - -} - -// 生成0-9之间三个不重复的随机数 进地图5s -func generateThreeUniqueNumbers() [3]int { - - selected := make(map[int]bool) - var result [3]int - index := 0 - - for index < 3 { - num := grand.Intn(9) - if !selected[num] { - selected[num] = true - result[index] = num - index++ - } - } - return result -} - -// 从三个数字中移除一个,并从剩余6个数字中选一个补充 10s -func replaceOneNumber(original [3]int) ([3]int, int, int) { - // 随机选择要移除的索引(0-2) - removeIndex := grand.Intn(3) - removedNum := original[removeIndex] - - // 找出所有不在原始数组中的数字(候选数字) - candidates := []int{} - originalMap := make(map[int]bool) - for _, num := range original { - originalMap[num] = true - } - - for i := 0; i < 8; i++ { - if !originalMap[i] { - candidates = append(candidates, i) - } - } - - // 从候选数字中随机选择一个 - newNum := candidates[grand.Intn(len(candidates))] - - // 创建新数组并替换数字 - newNumbers := original - newNumbers[removeIndex] = newNum - - return newNumbers, removedNum, newNum -} - // 添加物品 返回成功添加的物品 func (p *Player) ItemAdd(ItemId, ItemCnt uint32) (result bool) { diff --git a/logic/service/space/fixboos.go b/logic/service/space/fixboos.go index 7436d92b7..5e54deca2 100644 --- a/logic/service/space/fixboos.go +++ b/logic/service/space/fixboos.go @@ -35,29 +35,6 @@ func (s *Space) getfixboss(mapid uint32) { }) - case 32: - - atomic.StoreUint32(&s.CanWeather, 1) - - s.MapBossInfo = info.MapBossInfo{ - Id: 70, - } - - cool.Cron.ScheduleFunc(10*time.Second, func() { - var t info.MapBossSInfo - - if s.Weather == 1 { - s.MapBossInfo.Id = 70 - - } else { - s.MapBossInfo.Id = 0 - s.MapBossInfo.Pos = 200 - - } - t.INFO = append(t.INFO, s.MapBossInfo) - s.Broadcast(nil, 2021, &t) - }) - case 108: s.MapBossInfo = info.MapBossInfo{ Id: 219, diff --git a/logic/service/space/in_out.go b/logic/service/space/in_out.go index aa1f6237b..4a6bfd1c2 100644 --- a/logic/service/space/in_out.go +++ b/logic/service/space/in_out.go @@ -5,9 +5,7 @@ import ( "blazing/logic/service/maps/info" maps "blazing/logic/service/maps/info" "sync/atomic" - "time" - "github.com/gogf/gf/v2/util/grand" "github.com/jinzhu/copier" "github.com/panjf2000/ants/v2" "golang.org/x/time/rate" @@ -104,22 +102,3 @@ func (s *Space) Walk(c common.PlayerI, info *info.WalkOutInfo) { s.Broadcast(c, 2101, info) } - -func (t *Space) Next(time.Time) time.Time { - if t.CanWeather == 1 { - var neww uint32 = 0 - - if grand.Meet(1, 10) { - neww = uint32(grand.N(1, 2)) - - } - - if neww != t.Weather { - t.Broadcast(nil, 50004, &info.S2C_50004{Id: uint32(neww)}) - t.Weather = neww - } - - } - return time.Now().Add(time.Duration(grand.N(6, 30)) * time.Second) - -} diff --git a/logic/service/space/wer_boss.go b/logic/service/space/wer_boss.go new file mode 100644 index 000000000..db776adcc --- /dev/null +++ b/logic/service/space/wer_boss.go @@ -0,0 +1,60 @@ +package space + +import ( + "blazing/logic/service/maps/info" + "sync/atomic" + "time" + + "github.com/gogf/gf/v2/util/grand" +) + +func (s *Space) getwerboss() { + + switch s.ID { + case 12: + + case 32: + + atomic.StoreUint32(&s.CanWeather, 1) + + s.MapBossInfo = info.MapBossInfo{ + Id: 70, + } + + var t info.MapBossSInfo + + if s.Weather == 1 { + s.MapBossInfo.Id = 70 + + } else { + s.MapBossInfo.Id = 0 + s.MapBossInfo.Pos = 200 + + } + t.INFO = append(t.INFO, s.MapBossInfo) + s.Broadcast(nil, 2021, &t) + + } + +} + +func (t *Space) Next(time.Time) time.Time { + if t.CanWeather == 1 { + var neww uint32 = 0 + + if grand.Meet(1, 10) { + neww = uint32(grand.N(1, 2)) + + } + + if neww != t.Weather { + t.Broadcast(nil, 50004, &info.S2C_50004{Id: uint32(neww)}) + t.Weather = neww + t.getwerboss() + } + + } + + return time.Now().Add(grand.D(6*time.Second, 30*time.Second)) + +} diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index 14b09d069..465bc22cd 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -517,3 +517,60 @@ func CalculateIndividualValue() int { a := grand.Intn(40001) return CalculateIndividual(a) } + +// 1. 质量枚举常量(保持不变) +const ( + BitmapFilterQualityLow = 1 // LOW:应用1次滤镜 + BitmapFilterQualityMedium = 2 // MEDIUM:应用2次滤镜 + BitmapFilterQualityHigh = 3 // HIGH:应用3次滤镜(最大值) +) + +// 2. 调整取值范围常量为 uint8 类型(贴合 0-255 范围) +const ( + alphaMin = 0.0 + alphaMax = 1.0 + blurMin uint8 = 0 // BlurX/BlurY 最小值 + blurMax uint8 = 255 // BlurX/BlurY 最大值(uint8上限) + strengthMin uint8 = 0 // Strength 最小值 + strengthMax uint8 = 255 // Strength 最大值(uint8上限) + qualityMin = BitmapFilterQualityLow + qualityMax = BitmapFilterQualityHigh + colorMax = 0xFFFFFF // 颜色值最大值(0xRRGGBB) +) + +// 精灵加shinylen字段 +// 3. 核心结构体:BlurX/BlurY/Strength 改为 uint8 +type GlowFilter struct { + // Color 光晕颜色,十六进制格式 0xRRGGBB,默认值 0xFF0000(红色) + Color uint32 `json:"color,omitempty"` + + // Alpha 透明度,0.0~1.0(浮点型,无法用uint8,保留float64) + Alpha float64 `json:"alpha,omitempty"` + + // BlurX 水平模糊量,0~255(uint8),默认值 6 + BlurX uint8 `json:"blurX,omitempty"` + + // BlurY 垂直模糊量,0~255(uint8),默认值 6 + BlurY uint8 `json:"blurY,omitempty"` + + // Strength 发光强度,0~255(uint8),默认值 2 + Strength uint8 `json:"strength,omitempty"` + + // Quality 滤镜应用次数,1~3,默认值 1 + Quality int `json:"quality,omitempty"` + + // Inner 是否内侧发光,默认 false + Inner bool `json:"inner,omitempty"` + + // Knockout 是否挖空,默认 false + Knockout bool `json:"knockout,omitempty"` +} +type ColorMatrixFilter struct { + // Matrix 4×5 颜色变换矩阵,固定长度20的int8数组(不可变长度,避免越界) + // 矩阵格式(行优先): + // [ Rr, Rg, Rb, Ra, Ro, // 输出R = Rr*输入R + Rg*输入G + Rb*输入B + Ra*输入A + Ro + // Gr, Gg, Gb, Ga, Go, // 输出G = Gr*输入R + Gg*输入G + Gb*输入B + Ga*输入A + Go + // Br, Bg, Bb, Ba, Bo, // 输出B = Br*输入R + Bg*输入G + Bb*输入B + Ba*输入A + Bo + // Ar, Ag, Ab, Aa, Ao ] // 输出A = Ar*输入R + Ag*输入G + Ab*输入B + Aa*输入A + Ao + Matrix [20]uint8 `json:"matrix,omitempty"` +}