|
|
@@ -117,6 +117,50 @@ local function skinNetGen(human,net,id)
|
|
|
net.heroName = HeroExcel[skinCfg.heroId] and HeroExcel[skinCfg.heroId].name or ""
|
|
|
end
|
|
|
|
|
|
+-- 皮肤脱下
|
|
|
+--[[
|
|
|
+ @param2 = heroIdx -- 对应英雄存档的idx
|
|
|
+]]
|
|
|
+local function skinOff(human,heroIdx)
|
|
|
+ local heroId = HeroLogic.getHeroIdByIndex(human,heroIdx)
|
|
|
+ local heroGrid = HeroLogic.getHeroGrid(human,heroId,heroIdx)
|
|
|
+ local skinId = heroGrid.skinOn
|
|
|
+ -- 英雄不存在 或者 英雄未穿戴皮肤
|
|
|
+ if not heroGrid or not skinId then
|
|
|
+ return Broadcast.sendErr(human, heroIdx..":heroIdx:"..Lang.SKIN_PARAM_ERR)
|
|
|
+ end
|
|
|
+ local skinIdx = nil
|
|
|
+ for idx,skin in pairs(human.db.skinBag) do
|
|
|
+ if idx > 0 and skin.id == skinId then
|
|
|
+ skinIdx = idx
|
|
|
+ human.db.skinBag[idx].state = 0
|
|
|
+ break
|
|
|
+ end
|
|
|
+ end
|
|
|
+ assert(skinIdx,"param error")
|
|
|
+ -- 对所有heroId相同的英雄操作
|
|
|
+ local heroIdxList = HeroLogic.getHeroListById(human,heroId)
|
|
|
+ local heroCfg = HeroExcel[heroId]
|
|
|
+ for _,idx in ipairs(heroIdxList) do
|
|
|
+ -- 脱下皮肤 并且还原默认身体 icon和head
|
|
|
+ human.db.heroBag[idx].skinOn = nil
|
|
|
+ --local defaultHead = RoleHeadLogic.getDefaultHead(human)
|
|
|
+ RoleHeadLogic.setHead(human,heroCfg.head,RoleHeadLogic.HEAD_TYPE_1)
|
|
|
+
|
|
|
+ RoleHeadLogic.setHead(human,heroCfg.body,RoleHeadLogic.HEAD_TYPE_3)
|
|
|
+ end
|
|
|
+
|
|
|
+ -- 回复给客户端
|
|
|
+ local msgRet = Msg.gc.GC_SKIN_UPDATE
|
|
|
+ local data = msgRet.list[1].data
|
|
|
+ data.ind = skinIdx
|
|
|
+ data.isOn = 0
|
|
|
+ skinNetGen(human,data.data,skinId)
|
|
|
+ msgRet.list[1].op = 3
|
|
|
+ msgRet.list[0] = 1
|
|
|
+ Msg.send(msgRet,human.fd)
|
|
|
+end
|
|
|
+
|
|
|
-- 皮肤穿戴
|
|
|
--[[
|
|
|
@param2 = id -- 皮肤Id
|
|
|
@@ -140,7 +184,11 @@ local function skinOn(human,skinIdx,heroIdx)
|
|
|
if heroGrid.skinOn == skin.id then
|
|
|
return Broadcast.sendErr(human, Lang.SKIN_DOUBLE_ON)
|
|
|
end
|
|
|
-
|
|
|
+
|
|
|
+ if heroGrid.skinOn then
|
|
|
+ skinOff(human,heroIdx)
|
|
|
+ end
|
|
|
+
|
|
|
local skinCfg = SkinExcel[skin.id]
|
|
|
human.db.skinBag[skinIdx].state = 1
|
|
|
-- 对所有heroId相同的英雄操作
|
|
|
@@ -161,52 +209,9 @@ local function skinOn(human,skinIdx,heroIdx)
|
|
|
skinNetGen(human,data.data,skin.id)
|
|
|
msgRet.list[1].op = 3
|
|
|
msgRet.list[0] = 1
|
|
|
- Msg.send(msgRet,human.fd)
|
|
|
+ Msg.send(msgRet,human.fd)
|
|
|
end
|
|
|
|
|
|
--- 皮肤脱下
|
|
|
---[[
|
|
|
- @param2 = heroIdx -- 对应英雄存档的idx
|
|
|
-]]
|
|
|
-local function skinOff(human,heroIdx)
|
|
|
- local heroId = HeroLogic.getHeroIdByIndex(human,heroIdx)
|
|
|
- local heroGrid = HeroLogic.getHeroGrid(human,heroId,heroIdx)
|
|
|
- local skinId = heroGrid.skinOn
|
|
|
- -- 英雄不存在 或者 英雄未穿戴皮肤
|
|
|
- if not heroGrid or not skinId then
|
|
|
- return Broadcast.sendErr(human, heroIdx..":heroIdx:"..Lang.SKIN_PARAM_ERR)
|
|
|
- end
|
|
|
- local skinIdx = nil
|
|
|
- for idx,skin in pairs(human.db.skinBag) do
|
|
|
- if idx > 0 and skin.id == skinId then
|
|
|
- skinIdx = idx
|
|
|
- human.db.skinBag[idx].state = 0
|
|
|
- break
|
|
|
- end
|
|
|
- end
|
|
|
- assert(skinIdx,"param error")
|
|
|
- -- 对所有heroId相同的英雄操作
|
|
|
- local heroIdxList = HeroLogic.getHeroListById(human,heroId)
|
|
|
- local heroCfg = HeroExcel[heroId]
|
|
|
- for _,idx in ipairs(heroIdxList) do
|
|
|
- -- 脱下皮肤 并且还原默认身体 icon和head
|
|
|
- human.db.heroBag[idx].skinOn = nil
|
|
|
- --local defaultHead = RoleHeadLogic.getDefaultHead(human)
|
|
|
- RoleHeadLogic.setHead(human,heroCfg.head,RoleHeadLogic.HEAD_TYPE_1)
|
|
|
-
|
|
|
- RoleHeadLogic.setHead(human,heroCfg.body,RoleHeadLogic.HEAD_TYPE_3)
|
|
|
- end
|
|
|
-
|
|
|
- -- 回复给客户端
|
|
|
- local msgRet = Msg.gc.GC_SKIN_UPDATE
|
|
|
- local data = msgRet.list[1].data
|
|
|
- data.ind = skinIdx
|
|
|
- data.isOn = 0
|
|
|
- skinNetGen(human,data.data,skinId)
|
|
|
- msgRet.list[1].op = 3
|
|
|
- msgRet.list[0] = 1
|
|
|
- Msg.send(msgRet,human.fd)
|
|
|
-end
|
|
|
--------------------------------------------------------------
|
|
|
|
|
|
function initAfterHot()
|
|
|
@@ -216,6 +221,10 @@ function initAfterHot()
|
|
|
outConf.totalWeight = outConf.totalWeight + v[2]
|
|
|
end
|
|
|
end
|
|
|
+ SkinExcel = require("excel.skin").skin
|
|
|
+ HeroExcel = require("excel.hero").hero
|
|
|
+ SkillExcel = require("excel.skin").skill
|
|
|
+ ItemExcel = require("excel.item").item
|
|
|
end
|
|
|
|
|
|
-- 优先使用皮肤的技能,新版本没有默认返回false
|