diff --git a/logic/controller/action_egg.go b/logic/controller/action_egg.go index 75852103..211c503d 100644 --- a/logic/controller/action_egg.go +++ b/logic/controller/action_egg.go @@ -8,7 +8,7 @@ import ( ) func (h Controller) EGG(data *egg.C2S_EGG_GAME_PLAY, c *player.Player) (result *egg.S2C_EGG_GAME_PLAY, err errorcode.ErrorCode) { - r := model.GenPetInfo(1, -1, -1, -1, 0, 1) + r := model.GenPetInfo(1, -1, -1, -1, 0, nil) c.Service.Pet.PetAdd(r) result = &egg.S2C_EGG_GAME_PLAY{HadTime: r.CatchTime, ListInfo: []model.ItemInfo{}, PetID: r.ID} diff --git a/logic/controller/fight_boss.go b/logic/controller/fight_boss.go index 2b6e25a1..b5420231 100644 --- a/logic/controller/fight_boss.go +++ b/logic/controller/fight_boss.go @@ -81,8 +81,8 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla gconv.Int(processMonID(bm.MonID)), 24, //24个体 -1, 0, //野怪没特性 - 0, - bm.Lv) + + bm.Lv, nil) mo.CatchTime = uint32(i) if bm.Hp != 0 { mo.Hp = uint32(bm.Hp) @@ -132,7 +132,7 @@ func (h Controller) PlayerFightBoss(data *fight.ChallengeBossInboundInfo, c *pla moinfo.PetList[0].Downgrade(1) PetID := moinfo.PetList[0].ID - newm1 := model.GenPetInfo(int(PetID), -1, -1, 0, 0, 1) + newm1 := model.GenPetInfo(int(PetID), -1, -1, 0, 1, nil) c.Service.Pet.PetAdd(newm1) c.SendPackCmd(8004, &info.S2C_GET_BOSS_MONSTER{ @@ -169,8 +169,9 @@ func (h Controller) OnPlayerFightNpcMonster(data *fight.FightNpcMonsterInboundIn int(refpet.Id), -1, -1, 0, //野怪没特性 - int(refpet.Shiny), - int(refpet.Lv)) + + int(refpet.Lv), + refpet.ShinyInfo) moinfo := &model.PlayerInfo{} moinfo.Nick = xmlres.PetMAP[int(mo.ID)].DefName diff --git a/logic/controller/pet_fusion.go b/logic/controller/pet_fusion.go index b3a66fcb..35f014f8 100644 --- a/logic/controller/pet_fusion.go +++ b/logic/controller/pet_fusion.go @@ -56,7 +56,7 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result dv1 := alpacadecimal.NewFromInt(2).Div(alpacadecimal.NewFromInt(3)).Mul(alpacadecimal.NewFromInt(int64(Mcatchpetinfo.Dv))) dv2 := alpacadecimal.NewFromInt(1).Div(alpacadecimal.NewFromInt(3)).Mul(alpacadecimal.NewFromInt(int64(Auxpetinfo.Dv))) dv := dv1.Add(dv2).Add(alpacadecimal.NewFromInt(1)).IntPart() - r := model.GenPetInfo(resid, int(dv), int(natureId), effect, -1, 1) + r := model.GenPetInfo(resid, int(dv), int(natureId), effect, 1, nil) r.OldCatchTime = Mcatchpetinfo.CatchTime c.Service.Pet.PetAdd(r) println(len(c.Info.PetList), data.Mcatchtime, data.Auxcatchtime, Mcatchpetinfo.CatchTime, Auxpetinfo.CatchTime) diff --git a/logic/controller/user_task.go b/logic/controller/user_task.go index 563f3ffa..16c886a8 100644 --- a/logic/controller/user_task.go +++ b/logic/controller/user_task.go @@ -74,7 +74,7 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player. } if tt.PetTypeId != 0 { - r := model.GenPetInfo(int(tt.PetTypeId), 31, -1, 0, 0, 50) + r := model.GenPetInfo(int(tt.PetTypeId), 31, -1, 0, 50, nil) result.PetTypeId = r.ID c.Service.Pet.PetAdd(r) diff --git a/logic/service/fight/input.go b/logic/service/fight/input.go index ab3e3bac..868f96b1 100644 --- a/logic/service/fight/input.go +++ b/logic/service/fight/input.go @@ -141,7 +141,7 @@ func initmeetpet() { continue } - r := model.GenPetInfo(int(v.ID), 24, -1, -1, -1, 100) + r := model.GenPetInfo(int(v.ID), 24, -1, -1, 100, nil) meetpet[i] = *r diff --git a/logic/service/player/Monster.go b/logic/service/player/Monster.go index 28d778b5..d7ebafaf 100644 --- a/logic/service/player/Monster.go +++ b/logic/service/player/Monster.go @@ -3,8 +3,10 @@ package player import ( "blazing/common/data/xmlres" "blazing/logic/service/common" + "blazing/modules/blazing/model" "strings" "sync/atomic" + "time" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/grand" @@ -48,7 +50,31 @@ func (p *Player) genMonster() { ttt.Id = gconv.Uint32(RandomStringFromSlice(id)) if ttt.Id != 0 { - ttt.Shiny = 0 //待确认是否刷新异色 + ttt.ShinyInfo = make([]model.GlowFilter, 1) + // 假设 t 是包含 ShinyInfo 字段的结构体,ShinyInfo 是 GlowFilter 类型的切片 + ttt.ShinyInfo[0] = model.GlowFilter{ + // 光晕颜色:白色(十六进制 0xFFFFFF),符合 uint32 类型 + Color: 65535, + // 透明度:0.8(0.0~1.0 范围内的合理值,float64 类型) + Alpha: 0.8, + // 水平模糊量:10(0~255 范围内,uint8 类型,略高于默认值6) + BlurX: 20, + // 垂直模糊量:10(与 BlurX 对称,uint8 类型) + BlurY: 20, + // 发光强度:8(0~255 范围内,uint8 类型,略高于默认值2) + Strength: 1, + // 滤镜应用次数:2(1~3 范围内,int 类型,非默认值1) + Quality: 2, + // 内侧发光:true(bool 类型,模拟开启内侧发光) + Inner: true, + // 挖空:false(bool 类型,保持默认逻辑) + Knockout: false, + // 颜色矩阵:标准 RGBA 矩阵(20个uint8,符合 [20]uint8 数组类型) + // 矩阵含义:R=100%、G=100%、B=100%、A=100%,无颜色偏移 + ColorMatrixFilter: RandomControlledMatrix_IdentityAlpha(time.Now().UnixNano() + int64(ttt.Id)), + } + // g.Dump(ttt.ShinyInfo) + // ttt.Shiny = 0 //待确认是否刷新异色 ttt.Lv = gconv.Uint32(RandomStringFromSlice(lv)) if len(id) == 1 { //说明这里只固定刷一个,概率变尼尔尼奥 @@ -141,3 +167,43 @@ func replaceOneNumber(original [3]int) ([3]int, int, int) { return newNumbers, removedNum, newNum } + +func GenerateNormalizedColorMatrix() [20]uint8 { + var matrix [20]uint8 + + // ---------- R/G/B 通道:仅用 grand.N 生成整数(归一化映射) ---------- + // 生成权重(0~51):对应归一化系数 0.0~0.2(不会溢出) + genWeight := func() uint8 { return uint8(grand.N(0, 2)) } + // 生成偏移(0~25):对应归一化系数 0.0~0.1(不会溢出) + genOffset := func() uint8 { return uint8(grand.N(0, 2)) } + + // R 通道(索引0-4) + matrix[0] = genWeight() + matrix[1] = genWeight() + matrix[2] = genWeight() + matrix[3] = genWeight() + matrix[4] = genOffset() + + // G 通道(索引5-9) + matrix[5] = genWeight() + matrix[6] = genWeight() + matrix[7] = genWeight() + matrix[8] = genWeight() + matrix[9] = genOffset() + + // B 通道(索引10-14) + matrix[10] = genWeight() + matrix[11] = genWeight() + matrix[12] = genWeight() + matrix[13] = genWeight() + matrix[14] = genOffset() + + // ---------- A 通道:固定归一化值(无随机) ---------- + matrix[15] = 0 // 归一化系数 0.0 + matrix[16] = 0 // 归一化系数 0.0 + matrix[17] = 0 // 归一化系数 0.0 + matrix[18] = 1 // 归一化系数 1.0(透明度权重不变) + matrix[19] = 0 // 归一化系数 0.0 + + return matrix +} diff --git a/logic/service/player/color.go b/logic/service/player/color.go new file mode 100644 index 00000000..98f3c5dd --- /dev/null +++ b/logic/service/player/color.go @@ -0,0 +1,65 @@ +package player + +import ( + grand "math/rand" +) + +// 生成 [20]uint8,最后 5 个字节固定为 [0,0,0,1,0] +// 适用于“byte 直接作为系数(1 表示 1.0)”的场景。 +// 其它值在接近单位矩阵的范围内随机,尽量避免白化。 +func RandomControlledMatrix_IdentityAlpha(seed int64) [20]uint8 { + var out [20]uint8 + grand.Seed(seed) + + // 更保守范围(在直接 uint8 当系数时,1 表示 1.0) + diagMin, diagMax := 0.95, 1.05 // 对角线乘数(接近 1) + crossMin, crossMax := -1.0, 1.0 // 跨通道系数(小整数,可能为负,下面做 signed->uint8 映射) + offsetMin, offsetMax := -8.0, 8.0 // 偏移(以整数为单位) + + idx := 0 + for row := 0; row < 3; row++ { // 只生成前三行,最后一行固定 + for col := 0; col < 5; col++ { + var b uint8 + if col < 4 { + // multiplier (float around 1.0) -> round to nearest int (since direct uint8 coeff) + var v float64 + if col == row { + v = diagMin + grand.Float64()*(diagMax-diagMin) + } else { + v = crossMin + grand.Float64()*(crossMax-crossMin) + } + // 四舍五入到最近整数并允许负数:用 int8 再转为 uint8(保持二进制两补表示) + iv := int(v + 0.5) + // clamp to int8 range + if iv < -128 { + iv = -128 + } + if iv > 127 { + iv = 127 + } + b = uint8(int8(iv)) + } else { + // offset 也用 int8 存(-128..127),转为 uint8 的二进制表示 + off := offsetMin + grand.Float64()*(offsetMax-offsetMin) + ioff := int(off + 0.5) + if ioff < -128 { + ioff = -128 + } + if ioff > 127 { + ioff = 127 + } + b = uint8(int8(ioff)) + } + out[idx] = b + idx++ + } + } + + // 明确设置 alpha 行为 [0,0,0,1,0](直接 uint8 值) + out[15] = uint8(0) // a00 + out[16] = uint8(0) // a01 + out[17] = uint8(0) // a02 + out[18] = uint8(1) // a03 (alpha multiplier = 1) + out[19] = uint8(0) // a04 (alpha offset = 0) + return out +} diff --git a/logic/service/player/player.go b/logic/service/player/player.go index 24134180..17644100 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -12,6 +12,7 @@ import ( "blazing/modules/base/service" + "blazing/modules/blazing/model" blservice "blazing/modules/blazing/service" "context" @@ -37,11 +38,12 @@ type OgreInfo struct { } type OgrePetInfo struct { - Id uint32 - Shiny uint32 - Lv uint32 `struc:"skip"` //等级 - Item uint32 `struc:"skip"` //奖励,如果有的话 - Ext uint32 `struc:"skip"` //是否变尼尔尼奥 + Id uint32 + ShinyLen uint32 `json:"-" struc:"sizeof=ShinyInfo"` + ShinyInfo []model.GlowFilter `json:"ShinyInfo,omitempty"` + Lv uint32 `struc:"skip"` //等级 + Item uint32 `struc:"skip"` //奖励,如果有的话 + Ext uint32 `struc:"skip"` //是否变尼尔尼奥 } type Player struct { diff --git a/modules/blazing/model/pet.go b/modules/blazing/model/pet.go index a98219f0..775620ce 100644 --- a/modules/blazing/model/pet.go +++ b/modules/blazing/model/pet.go @@ -392,7 +392,7 @@ func init() { // * @return 生成的精灵实体 func GenPetInfo( id int, - dv, natureId, abilityTypeEnum, shinyid, level int, + dv, natureId, abilityTypeEnum, level int, shinyid []GlowFilter, ) *PetInfo { // 创建随机源 //rng := rand.New(rand.NewSource(time.Now().UnixNano())) @@ -406,8 +406,9 @@ func GenPetInfo( } // ---- 处理闪光 ---- - if shinyid != -1 { + if shinyid != nil { //todo 待实现异色字段 + p.ShinyInfo = shinyid // p.Shiny = uint32(shinyid) }