diff --git a/common/constant.go b/common/constant.go index 8e09429..cd0ef39 100644 --- a/common/constant.go +++ b/common/constant.go @@ -824,3 +824,16 @@ const ( SkillIdTask = 30005 // 每日任务金币奖励提升百分比 SkillIdDiamondLottery = 30007 // 每次钻石抽奖幸运值提升百分比 ) + +var ( + SkinRandom = []int32{300001, 300002, 300007, 300006, 300005, 300004, 300003} + SkinWeightMap = map[int32]int{ + 300001: 20, + 300002: 40, + 300007: 40, + 300006: 50, + 300005: 40, + 300004: 60, + 300003: 70, + } +) diff --git a/worldsrv/player.go b/worldsrv/player.go index 0c7bd29..4e3388c 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -3174,6 +3174,41 @@ func (this *Player) RobRandVip() { this.Head = rand.Int31n(common.HeadRange) //0:男 1:女 this.Sex = (this.Head%2 + 1) % 2 + // 随机皮肤 + skinFunc := func(i int) { + total := 0 + for _, v := range common.SkinRandom[:i] { + total += common.SkinWeightMap[v] + } + r := common.RandInt(total) + n := common.SkinWeightMap[common.SkinRandom[0]] + for k, v := range common.SkinRandom[:i] { + if r < n { + this.Skin.ModId = v + if this.Skin.ModUnlock[v] == 0 { + this.Skin.ModUnlock[v] = 1 + if this.Skin.Mod[v] == nil { + this.Skin.Mod[v] = &model.ModEx{} + } + this.Skin.Mod[v].Ts = time.Now().Unix() + } + break + } + if k+1 < len(common.SkinRandom) { + n += common.SkinWeightMap[common.SkinRandom[k+1]] + } + } + } + switch { + case this.VIP >= 1: + skinFunc(5) + case this.VIP >= 2: + skinFunc(6) + case this.VIP >= 5: + skinFunc(7) + default: + skinFunc(4) + } } }