From 33c3e14e8b4e5e682781f24cfed33dd360ff7147 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Sat, 27 Jul 2024 09:27:07 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E6=9C=BA=E5=99=A8=E4=BA=BA?= =?UTF-8?q?=E7=9A=AE=E8=82=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/constant.go | 13 +++++++++++++ worldsrv/player.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) 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) + } } }