init
This commit is contained in:
@@ -0,0 +1,183 @@
|
||||
-- module("ActivityLuckyTree", package.seeall)
|
||||
math.randomseed(System.getCurrMiniTime())
|
||||
--[[
|
||||
|
||||
摇钱树
|
||||
|
||||
个人数据:treedata
|
||||
{
|
||||
dailyTimes --每日要钱次数
|
||||
lastLoginTime --登录时间
|
||||
nowVip --当前vip
|
||||
}
|
||||
]]--
|
||||
TreeConstConfig = MoneytreeconstConfig
|
||||
MoneytreeRewardConfig = MoneytreeRewardConfig
|
||||
--对应的活动配置
|
||||
function getLuckyTreeData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.treeData== nil then
|
||||
var.treeData = {}
|
||||
end
|
||||
return var.treeData
|
||||
end
|
||||
|
||||
function SendLuckyTreeData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sLuckyTree)
|
||||
if npack then
|
||||
local data = getLuckyTreeData(pActor)
|
||||
DataPack.writeUInt(npack, (data.dailyTimes or 0))--礼包的领取标记 32 位
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
-------------------------------------------------------------------
|
||||
function OnLuckyTreeLogin(pActor)
|
||||
--print("[ActivityLuckyTree:OnLuckyTreeLogin-----------1------------874--------------------2213----------------23------------ ")
|
||||
local data = getLuckyTreeData(pActor);
|
||||
if data.lastLoginTime == nil then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
if TreeConstConfig and TreeConstConfig.times then
|
||||
local vip = Actor.GetMaxColorCardLevel(pActor);
|
||||
data.dailyTimes = TreeConstConfig.times[vip+1];
|
||||
data.nowVip = vip+1;
|
||||
end
|
||||
|
||||
--print("第一天")
|
||||
end
|
||||
SendLuckyTreeData(pActor);
|
||||
end
|
||||
|
||||
function getMoneyTreeAward()
|
||||
local openDay = System.getDaysSinceOpenServer()
|
||||
local awardCfgs = {};
|
||||
local nMinDay = 0;
|
||||
if MoneytreeRewardConfig == nil then
|
||||
return nil
|
||||
end
|
||||
for _, awardCfg in pairs(MoneytreeRewardConfig) do
|
||||
if awardCfg.Opendaylimit <= openDay and awardCfg.Opendaylimit > nMinDay then
|
||||
nMinDay = awardCfg.Opendaylimit
|
||||
end
|
||||
end
|
||||
|
||||
local nMaxRand = 0;
|
||||
for _, awardCfg in pairs(MoneytreeRewardConfig) do
|
||||
if awardCfg.Opendaylimit == nMinDay then
|
||||
nMaxRand = nMaxRand + awardCfg.rate;
|
||||
table.insert(awardCfgs, awardCfg)
|
||||
end
|
||||
end
|
||||
|
||||
local value = math.random(nMaxRand);
|
||||
local nRandValue = 0;
|
||||
for _, cfg in pairs(awardCfgs) do
|
||||
nRandValue = nRandValue + cfg.rate
|
||||
if value <= nRandValue then
|
||||
return cfg
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function OnRockLuckyTree(pActor, packet)
|
||||
--print("[ActivityLuckyTree:OnRockLuckyTree----------3253------------23274--------------------123213---------------123------------ ")
|
||||
local data = getLuckyTreeData(pActor)
|
||||
if data == nil then
|
||||
return
|
||||
end
|
||||
if (not data.dailyTimes) or (data.dailyTimes <= 0) then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmMoneyTreeNoTimes, tstUI);
|
||||
return;
|
||||
end
|
||||
|
||||
if TreeConstConfig.limit then
|
||||
if Actor.checkCommonLimit(pActor,
|
||||
(TreeConstConfig.limit.level or 0),
|
||||
(TreeConstConfig.limit.zsLevel or 0),
|
||||
(TreeConstConfig.limit.vip or 0),
|
||||
(TreeConstConfig.limit.office or 0) ) == false then
|
||||
|
||||
return;
|
||||
end
|
||||
end
|
||||
local costYb = 0;
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, TreeConstConfig.cost1, 0) ~= true then
|
||||
--print("[ActivityLuckyTree:return--------&&&&&&&&&&&&&&&&&----------- costYb:"..tostring(costYb))
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, TreeConstConfig.cost2, tstUI) ~= true then
|
||||
return;
|
||||
end
|
||||
costYb = 1;
|
||||
end
|
||||
--print("[ActivityLuckyTree:return--------&&&&&&&&&&&&&&&&&1111-------------------- costYb:"..tostring(costYb))
|
||||
--return;
|
||||
-- if CommonFunc.Awards.CheckBagIsEnough(pActor,8,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
-- print("4444")
|
||||
-- return
|
||||
-- end
|
||||
|
||||
if costYb == 1 then
|
||||
CommonFunc.Consumes.Remove(pActor, TreeConstConfig.cost2, GameLog.Log_MoneyTree, "摇钱树")
|
||||
else
|
||||
CommonFunc.Consumes.Remove(pActor, TreeConstConfig.cost1, GameLog.Log_MoneyTree, "摇钱树")
|
||||
end
|
||||
local AwardCfg = getMoneyTreeAward();
|
||||
if AwardCfg then
|
||||
if AwardCfg.tips then
|
||||
local name = Actor.getName(pActor);
|
||||
System.broadTipmsgWithParams(AwardCfg.tips ,tstKillDrop, name)
|
||||
System.broadTipmsgWithParams(AwardCfg.tips ,tstChatSystem, name)
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, AwardCfg.reward, GameLog.Log_MoneyTree)
|
||||
if AwardCfg.Uitips then
|
||||
Actor.sendTipmsg(pActor, AwardCfg.Uitips, tstUI);
|
||||
end
|
||||
|
||||
end
|
||||
data.dailyTimes = data.dailyTimes - 1;
|
||||
SendLuckyTreeData(pActor)
|
||||
end
|
||||
|
||||
|
||||
function UpdateTreeTimes(pActor)
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getLuckyTreeData(pActor)
|
||||
local vip = Actor.GetMaxColorCardLevel(pActor);
|
||||
local times = TreeConstConfig.times[vip+1];
|
||||
if data.nowVip then
|
||||
times = times - (TreeConstConfig.times[data.nowVip] or 0)
|
||||
end
|
||||
data.dailyTimes = (data.dailyTimes or 0) + times;
|
||||
data.nowVip = vip+1
|
||||
|
||||
SendLuckyTreeData(pActor)
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getLuckyTreeData(pActor)
|
||||
if data.lastLoginTime then
|
||||
if not System.isSameDay(data.lastLoginTime, System.getCurrMiniTime()) then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
if TreeConstConfig and TreeConstConfig.times then
|
||||
local vip = Actor.GetMaxColorCardLevel(pActor);
|
||||
data.dailyTimes = TreeConstConfig.times[vip+1];
|
||||
data.nowVip = vip+1
|
||||
end
|
||||
end
|
||||
|
||||
SendLuckyTreeData(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityLuckyTree.lua")
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enMiscSystemID, cLuckyTree, OnLuckyTreeLogin)
|
||||
NetmsgDispatcher.Reg(enMiscSystemID, cGetLuckyMoney, OnRockLuckyTree)
|
||||
@@ -0,0 +1,135 @@
|
||||
-- module("ActivityOnlineMin", package.seeall)
|
||||
--[[
|
||||
|
||||
累计在线
|
||||
|
||||
个人数据:onlinedata
|
||||
{
|
||||
onlineTime --累计在线时间
|
||||
lastLoginTime --登录时间
|
||||
loginday--登录天数
|
||||
bitState --bit位
|
||||
}
|
||||
]]--
|
||||
OnlineCfg = OnlineTimeRewardConfig
|
||||
OnlineTimeconst = OnlineTimeconstConfig
|
||||
|
||||
--对应的活动配置
|
||||
function getOnlineData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.onlinedata== nil then
|
||||
var.onlinedata = {}
|
||||
end
|
||||
return var.onlinedata
|
||||
end
|
||||
|
||||
function SendOnlineData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sGetOnlineTime)
|
||||
if npack then
|
||||
local data = getOnlineData(pActor)
|
||||
if data.onlineTime == nil then
|
||||
data.onlineTime = 0;
|
||||
end
|
||||
data.onlineTime = (data.onlineTime or 0) + Actor.getTotalOnlineTime(pActor);
|
||||
-- print("SendOnlineData.."..data.onlineTime);
|
||||
-- local totalTime = data.onlineTime + Actor.getTotalOnlineTime(pActor);
|
||||
DataPack.writeUInt(npack, (data.onlineTime or 0))--累计登录时间
|
||||
DataPack.writeUInt(npack, (data.loginday or 0))--累计天数
|
||||
DataPack.writeInt(npack, (data.bitState or 0))--礼包的领取标记 32 位
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
-------------------------------------------------------------------
|
||||
function OnOnlineLogin(pActor)
|
||||
local data = getOnlineData(pActor);
|
||||
if data.lastLoginTime == nil then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginday =1
|
||||
end
|
||||
SendOnlineData(pActor);
|
||||
end
|
||||
|
||||
function OnGetOlineTimeAward(pActor, packet)
|
||||
local ntype = DataPack.readByte(packet);
|
||||
local nIndex = DataPack.readInt(packet);
|
||||
local data = getOnlineData(pActor)
|
||||
if data == nil then
|
||||
return
|
||||
end
|
||||
-- print("ntype.."..ntype.."..nIndex.."..nIndex)
|
||||
local Cfg= OnlineCfg[ntype]
|
||||
if not Cfg or not Cfg[nIndex] then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:无此奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
local flag = System.getIntBit(data.bitState, nIndex-1)
|
||||
--print("loginGift="..data.levelGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:奖励已领取|", tstUI)
|
||||
return
|
||||
end
|
||||
if ntype == 1 then
|
||||
local totalTime = data.onlineTime + Actor.getTotalOnlineTime(pActor);
|
||||
if totalTime < Cfg[nIndex].onlineTimes then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:累计在线时间未到|", tstUI)
|
||||
return;
|
||||
end
|
||||
elseif ntype == 2 then
|
||||
if data.loginday < Cfg[nIndex].onlineTimes then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:累计登录未到|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,8,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
data.bitState = System.setIntBit((data.bitState or 0), nIndex-1, true)
|
||||
-- print("nIndex.."..nIndex);
|
||||
CommonFunc.Awards.Give(pActor, Cfg[nIndex].reward, GameLog.Log_TotalOnlineTime)
|
||||
SendOnlineData(pActor)
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getOnlineData(pActor)
|
||||
if data.lastLoginTime then
|
||||
if not System.isSameDay(data.lastLoginTime, System.getCurrMiniTime()) then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginday = data.loginday + 1
|
||||
end
|
||||
SendOnlineData(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
function UpdateOnlineTime(pActor,totalTime)
|
||||
-- local currMiniTime = System.getCurrMiniTime()
|
||||
|
||||
if OnlineTimeconst.limit then
|
||||
if Actor.checkCommonLimit(pActor,
|
||||
(OnlineTimeconst.limit.level or 0),
|
||||
(OnlineTimeconst.limit.zsLevel or 0),
|
||||
(OnlineTimeconst.limit.vip or 0),
|
||||
(OnlineTimeconst.limit.office or 0) ) == false then
|
||||
|
||||
return;
|
||||
end
|
||||
end
|
||||
local data = getOnlineData(pActor)
|
||||
data.onlineTime = (data.onlineTime or 0) + totalTime;
|
||||
-- print("UpdateOnlineTime.."..data.onlineTime.."..totalTime.."..totalTime);
|
||||
-- SendOnlineData(pActor);
|
||||
end
|
||||
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityOnlineMin.lua")
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enMiscSystemID, cGetOnlineTime, OnOnlineLogin)
|
||||
NetmsgDispatcher.Reg(enMiscSystemID, cGetOnlineAward, OnGetOlineTimeAward)
|
||||
@@ -0,0 +1,442 @@
|
||||
module("ActivityQQHall", package.seeall)
|
||||
|
||||
--[[
|
||||
|
||||
QQ大厅特权
|
||||
|
||||
个人数据:qqHallData
|
||||
{
|
||||
activeGift = 0/1 是否领取活跃礼包(0否,1是)
|
||||
registerGift = 0/1 是否领取注册礼包(0否,1是)
|
||||
lastLoginTime = 0 上一次通过YY大厅登录的时间戳
|
||||
loginDay = 1 通过YY大厅登录的累计天数
|
||||
levelGift = 00000000 32位 是否领取某天的登录礼包
|
||||
|
||||
--蓝钻
|
||||
newPlayerGift //新手礼包
|
||||
growupgift //成长礼包
|
||||
dailyGift //每日礼包
|
||||
blueDimandGift //蓝钻等级
|
||||
BlueLv //蓝钻等级
|
||||
Blue //蓝钻
|
||||
BlueYear //年费
|
||||
}
|
||||
]]--
|
||||
PlatformConfig = PlatformQQConfig
|
||||
LoginConfig = LoginQQConfig
|
||||
|
||||
local PfId = System.getPfId()
|
||||
--对应的活动配置
|
||||
function getQQHallData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.qqHallData== nil then
|
||||
var.qqHallData = {}
|
||||
end
|
||||
return var.qqHallData
|
||||
end
|
||||
|
||||
function SendQQHallData(pActor)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] SendQQHallData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sGetQQhallInfos)
|
||||
if npack then
|
||||
-- print("1111")
|
||||
local data = getQQHallData(pActor)
|
||||
DataPack.writeByte(npack, (data.activeGift or 0)) --是否领取活跃礼包(0否,1是)
|
||||
DataPack.writeByte(npack, (data.registerGift or 0)) --是否领取认证礼包(0否,1是)
|
||||
DataPack.writeUInt(npack, (data.levelGift or 0))--礼包的领取标记 32 位
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- CPP回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function OnQQHallLogin(pActor)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] OnQQHallLogin ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
-- 当天初始化
|
||||
local data = getQQHallData(pActor)
|
||||
if data.lastLoginTime == nil then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
--print("第一天")
|
||||
end
|
||||
-- print("1111")
|
||||
SendQQHallData(pActor);
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
-------------------------------------------------------------------
|
||||
--登录
|
||||
function OnReqQQHallLevelGift(pActor, packet)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] OnReqQQHallLevelGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #LoginConfig then
|
||||
return
|
||||
end
|
||||
local conf = PlatformConfig
|
||||
local Cfg = LoginQQConfig[idx]
|
||||
idx = idx - 1
|
||||
local data = getQQHallData(pActor)
|
||||
if Cfg then
|
||||
-- 领取检查data.levelGift
|
||||
if not data.levelGift then
|
||||
data.levelGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.levelGift, idx)
|
||||
--print("loginGift="..data.levelGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
|
||||
if Cfg.level and ( lv < Cfg.level ) then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
-- 天数检查
|
||||
data.levelGift = System.setIntBit(data.levelGift, idx, true)
|
||||
CommonFunc.Awards.Give(pActor, Cfg.reward, GameLog.Log_QQhallLevel)
|
||||
SendQQHallData(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
end
|
||||
|
||||
--注册
|
||||
function OnReqQQHallRegisteGift(pActor, packet)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] OnReqQQHallRegisteGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local data = getQQHallData(pActor)
|
||||
if data.registerGift then
|
||||
return
|
||||
end
|
||||
local conf = PlatformConfig
|
||||
local awards = conf.reward1
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_QQhallRegiste)
|
||||
data.registerGift = 1;
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
SendQQHallData(pActor)
|
||||
end
|
||||
--认证
|
||||
function OnReqQQHallIdActiveGift(pActor, packet)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] OnReqQQHallIdActiveGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local conf = PlatformConfig
|
||||
local awards = conf.reward2
|
||||
local data = getQQHallData(pActor)
|
||||
if data.activeGift == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:重复领取|", tstUI)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_QQhallActive)
|
||||
data.activeGift = 1;
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
SendQQHallData(pActor)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGetQQHallInfos, OnQQHallLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGetQQqHallLevelAward, OnReqQQHallLevelGift)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGetQQHallRegisteAward, OnReqQQHallRegisteGift)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGetQQqHallActiveAward, OnReqQQHallIdActiveGift)
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] OnNewDayArrive ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
print("[ActivityTypeQQHall:OnNewDayArrive-001--")
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getQQHallData(pActor)
|
||||
--print("[ActivityTypeQQHall:OnNewDayArrive-101--".. tostring(data.lastLoginTime))
|
||||
print("[ActivityTypeQQHall:OnNewDayArrive-123--".. tostring(data.dailyGift))
|
||||
print("[ActivityTypeQQHall:OnNewDayArrive-111--".. tostring(data.activeGift))
|
||||
--if data.lastLoginTime then
|
||||
print("[ActivityTypeQQHall:OnNewDayArrive-002--")
|
||||
if not System.isSameDay(data.lastLoginTime, System.getCurrMiniTime()) then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
-- data.loginDay = data.loginDay + 1
|
||||
data.activeGift = 0
|
||||
data.dailyGift = 0;
|
||||
|
||||
print("[ActivityTypeQQHall:OnNewDayArrive-9123--".. tostring(data.dailyGift))
|
||||
print("[ActivityTypeQQHall:OnNewDayArrive-9111--".. tostring(data.activeGift))
|
||||
end
|
||||
|
||||
SendQQHallData(pActor)
|
||||
--end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityQQHall.lua")
|
||||
|
||||
|
||||
-----------
|
||||
--蓝钻
|
||||
-----------
|
||||
function OnSetQQBlueDiamond(pActor, packet)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] OnSetQQBlueDiamond ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local data = getQQHallData(pActor)
|
||||
local nBlue =DataPack.readByte(packet);
|
||||
local nBlueYear =DataPack.readByte(packet);
|
||||
local nBluelv =DataPack.readByte(packet);
|
||||
local nVip = 0;
|
||||
nVip = System.getValueMAKELONG(nBluelv, nBlueYear, nBlue);
|
||||
data.Blue = nBlue;
|
||||
data.BlueLv = nBluelv;
|
||||
data.BlueYear = nBlueYear;
|
||||
Actor.setUIntProperty(pActor,PROP_ACTOR_SUPPER_PLAY_LVL,nVip)
|
||||
end
|
||||
|
||||
|
||||
function SendQQBlueDiamondData(pActor)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] SendQQBlueDiamondData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enMiscSystemID, sGetQQBlueDiamond)
|
||||
if npack then
|
||||
local data = getQQHallData(pActor)
|
||||
DataPack.writeByte(npack, (data.newPlayerGift or 0)) --
|
||||
DataPack.writeUInt(npack, (data.growupgift or 0)) --
|
||||
DataPack.writeUInt(npack, (data.dailyGift or 0))--
|
||||
DataPack.writeUInt(npack, (data.blueDimandGift or 0))--
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function GetQQBlueDiamonGift(pActor, packet)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] GetQQBlueDiamonGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local type = DataPack.readByte(packet)
|
||||
local idx = DataPack.readByte(packet)
|
||||
if type == 1 then --新手礼包
|
||||
GetQQBlueNewPlayerGift(pActor, idx)
|
||||
elseif type == 2 then --成长礼包
|
||||
GetQQBlueGrowUpGift(pActor, idx)
|
||||
elseif type == 3 then --每日礼包
|
||||
GetQQblueDailyGift(pActor, idx)
|
||||
elseif type == 4 then --蓝砖战神
|
||||
GetQQBlueFightGift(pActor, idx)
|
||||
end
|
||||
end
|
||||
|
||||
function GetQQBlueNewPlayerGift(pActor, idx)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] GetQQBlueNewPlayerGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local conf = PlatformConfig
|
||||
local awards = conf.reward3
|
||||
local data = getQQHallData(pActor)
|
||||
if data.newPlayerGift then
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_QQBlueNewPlayer)
|
||||
data.newPlayerGift = 1;
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
SendQQBlueDiamondData(pActor)
|
||||
end
|
||||
|
||||
function GetQQBlueGrowUpGift(pActor, idx)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] GetQQBlueGrowUpGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if idx > #LoginConfig then
|
||||
return
|
||||
end
|
||||
local conf = PlatformConfig
|
||||
local Cfg = LevelBlueDiamondConfig[idx]
|
||||
idx = idx - 1
|
||||
local data = getQQHallData(pActor)
|
||||
if Cfg then
|
||||
-- 领取检查data.levelGift
|
||||
if not data.growupgift then
|
||||
data.growupgift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.growupgift, idx)
|
||||
--print("loginGift="..data.levelGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
|
||||
if Cfg.level and ( lv < Cfg.level ) then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
-- 天数检查
|
||||
data.growupgift = System.setIntBit(data.growupgift, idx, true)
|
||||
CommonFunc.Awards.Give(pActor, Cfg.reward, GameLog.Log_QQBlueGrowUp)
|
||||
SendQQBlueDiamondData(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
end
|
||||
|
||||
function GetQQblueDailyGift(pActor, idx)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [PlatformQQ] GetQQblueDailyGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [PlatformQQ] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local conf = PlatformConfig
|
||||
idx = idx - 1
|
||||
local data = getQQHallData(pActor)
|
||||
if not data.dailyGift then
|
||||
data.dailyGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.dailyGift, idx)
|
||||
--print("loginGift="..data.levelGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if data.Blue == nil then
|
||||
data.Blue = 0;
|
||||
end
|
||||
if data.BlueYear == nil then
|
||||
data.BlueYear = 0;
|
||||
end
|
||||
local Cfg = BlueDiamondDailyConfig[data.BlueLv]
|
||||
if Cfg then
|
||||
local awards = nil;
|
||||
if idx == 0 then
|
||||
awards = Cfg.reward1
|
||||
elseif idx == 1 then
|
||||
if data.Blue == 2 then
|
||||
awards = Cfg.reward2
|
||||
end
|
||||
elseif idx == 2 then
|
||||
if data.BlueYear == 1 then
|
||||
awards = Cfg.reward3
|
||||
end
|
||||
else
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:不满足条件|", tstUI)
|
||||
return
|
||||
end
|
||||
if awards then
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
-- 天数检查
|
||||
data.dailyGift = System.setIntBit(data.dailyGift, idx, true)
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_QQBlueGrowUp)
|
||||
SendQQBlueDiamondData(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function GetQQBlueFightGift(pActor, idx)
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enMiscSystemID, CSetQQBlueDiamond, OnSetQQBlueDiamond)
|
||||
NetmsgDispatcher.Reg(enMiscSystemID, CGetQQBlueDiamond, SendQQBlueDiamondData)
|
||||
NetmsgDispatcher.Reg(enMiscSystemID, CGetQQBlueDiamondGift, GetQQBlueDiamonGift)
|
||||
@@ -0,0 +1,228 @@
|
||||
module("ActivityType1", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动,打副本刷怪的活动
|
||||
通关才扣取进入消耗及次数;
|
||||
次数每天叠加不清空;
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 当前的可进入次数
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 1
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity1Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId, Conf, inPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if Conf.enterExpends then
|
||||
consumes = Conf.enterExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if data.count == nil then
|
||||
data.count = Conf.count
|
||||
else
|
||||
if data.count <= 0 then
|
||||
--Actor.sendTipmsg(pActor, "次数没了!", tstUI)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)--次数不足
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--进入副本
|
||||
ActivityDispatcher.EnterFuben(atvId, pActor, Conf.fbId)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--初始化活动个人数据
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local multi = 1
|
||||
if ActivityConfig[atvId].isFromOpenSrv then
|
||||
multi = System.getDaysSinceOpenServer()
|
||||
end
|
||||
data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
DataPack.writeInt(outPack, (data.count or 0))
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
print("[PActivity 1] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben, pOwner)
|
||||
-- 通关后才消耗门票跟次数
|
||||
if FubenDispatcher.GetReault(pFuben) == 1 then
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Conf = ActivityConfig[atvId]
|
||||
|
||||
-- 补充退出结算
|
||||
OnReqFubenAward(atvId, pFuben, pActor, pActor)
|
||||
|
||||
-- 消耗次数
|
||||
data.count = data.count - 1
|
||||
|
||||
-- 消耗门票
|
||||
local consumes = Conf.enterExpends
|
||||
if consumes then
|
||||
CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity1, "刷怪副本类活动|"..atvId)
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
--活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result, pOwner)
|
||||
--发送成功失败的旗帜
|
||||
if pOwner then
|
||||
if result == 1 then
|
||||
--完成副本任务
|
||||
Actor.ExOnQuestEvent(pOwner, CQuestData.qtFuben, 1);
|
||||
Actor.triggerAchieveEvent(pOwner, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pOwner, nAchieveCompleteActivity,1 ,atvId);
|
||||
end
|
||||
local npack = ActivityDispatcher.AllocResultPack(pOwner, atvId, result)
|
||||
if npack then
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动请求结算
|
||||
function OnReqFubenAward(atvId, pFuben, pActor, pOwner)
|
||||
-- 单人副本活动,所有者必须为自己
|
||||
if pOwner == pActor then
|
||||
if FubenDispatcher.GetReault(pFuben) == 1 then
|
||||
local fbcache = FubenDispatcher.GetCacheData(pFuben)
|
||||
if not fbcache.hasGetAward then
|
||||
local awards = ActivityConfig[atvId].Persongift
|
||||
-- if CommonFunc.Awards.CheckBagGridCount(pActor,awards) ~= true then
|
||||
-- return
|
||||
-- end
|
||||
if CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity1, "Activity1|"..atvId, -1 ) == true then
|
||||
Actor.sendTipmsg(pActor, "成功领取奖励!", tstGetItem)
|
||||
fbcache.hasGetAward = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local ret = 0
|
||||
if data.count and (data.count > 0) then ret = 1 end
|
||||
local limitLv = 0;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
if lv < limitLv then ret = 0 end
|
||||
return ret
|
||||
end
|
||||
|
||||
function OnCombineSrv(atvId, ndiffDay, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
|
||||
data.count = data.count + (2 * ndiffDay)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnCombineSrv, ActivityType, OnCombineSrv, "ActivityType1.lua")
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqFubenAward, ActivityType, OnReqFubenAward, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType1.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
print("[PActivity 1] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
print("[PActivity 1] "..Actor.getName(pActor).." 跨天加活动次数,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
if ActivityConfig[atvId].IsAdd then
|
||||
data.count = data.count + ((ActivityConfig[atvId].count or 1) * ndiffday)
|
||||
else
|
||||
data.count = (ActivityConfig[atvId].count or 1)
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType1.lua")
|
||||
@@ -0,0 +1,302 @@
|
||||
module("ActivityType10", package.seeall)
|
||||
|
||||
--[[
|
||||
沙巴克
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
sbkArea[sceneid] //sceneid 场景id
|
||||
{
|
||||
state //状态
|
||||
}
|
||||
needDealarea
|
||||
{
|
||||
area
|
||||
{
|
||||
sceneid, //场景id
|
||||
x, x坐标
|
||||
y, y坐标
|
||||
}
|
||||
}
|
||||
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
paodianTime,
|
||||
warNotice,--沙巴克皇宫可以开始占领!公告
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
sbkGuild sbk领主id
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
local SbkState = 0;
|
||||
-- 活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
PreEnter = 1, --活动前5分钟(走马灯全服公告,不给进入)
|
||||
Start = 2, --开始
|
||||
Sbk = 3, --沙巴克时间
|
||||
End = 4, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
local PaodianTime = 0;
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 10] 沙巴克 活动数据加载,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 10] 沙巴克 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
setSbkAwardFlag(nil);
|
||||
print("[GActivity 10] 沙巴克 活动开始了,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg then
|
||||
-- System.broadcastTipmsgLimitLev(Cfg.endsbk, tstBigRevolving)
|
||||
-- System.broadcastTipmsgLimitLev(Cfg.endsbk, tstChatSystem)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData.sbkGuild then
|
||||
local guildName = Guild.getGuildName(globalData.sbkGuild)
|
||||
if guildName then
|
||||
local str = string.format(Cfg.endsbk, guildName)
|
||||
System.broadcastTipmsgLimitLev(str, tstBigRevolving)
|
||||
-- print("..on")
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
end
|
||||
if cacheData.sbkArea then
|
||||
for _, sceneid in Ipairs(cacheData.sbkArea) do
|
||||
-- print("vvvv.."..sceneid)
|
||||
Fuben.ResetFubenSceneConfig(sceneid);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
SbkState = AtvStatus.End
|
||||
ActivityDispatcher.ClearCacheData(atvId);
|
||||
print("[GActivity 10] 沙巴克 活动结束了,id:"..atvId)
|
||||
end
|
||||
|
||||
|
||||
--公告
|
||||
function SendNotice(avtId, curTime)
|
||||
local cfg = ActivityConfig
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cfg == nil then
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
-- function OnReqData(atvId, pActor)
|
||||
|
||||
-- end
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
SendNotice(atvId, curTime);
|
||||
DealSbkAreaAttr(atvId, curTime);
|
||||
dealGuildSbk(atvId,curTime);
|
||||
dealPaodianExp(atvId,curTime)
|
||||
end
|
||||
|
||||
|
||||
--p泡点
|
||||
function dealPaodianExp(atvId, curTime)
|
||||
--检测沙巴克占领是否开启
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if Cfg then
|
||||
if Cfg.starttime then
|
||||
-- local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if curTime < (startTime + Cfg.starttime) then
|
||||
return
|
||||
end
|
||||
end
|
||||
if cacheData.paodianTime == nil then
|
||||
cacheData.paodianTime = 0
|
||||
end
|
||||
if curTime >= cacheData.paodianTime then
|
||||
cacheData.paodianTime = curTime + 5
|
||||
if Cfg.idx then
|
||||
addPaodianExp(cacheData.actors, Cfg.idx,atvId);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--沙巴克行为
|
||||
function dealGuildSbk(atvId, curTime)
|
||||
--检测沙巴克占领是否开启
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
-- print("dealGuild.."..startTime)
|
||||
if Cfg then
|
||||
if Cfg.wartime then
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if curTime < (startTime + Cfg.wartime) then
|
||||
return
|
||||
end
|
||||
|
||||
if not cacheData.warNotice and Cfg.wartimestr then
|
||||
cacheData.warNotice = 1
|
||||
System.broadcastTipmsgLimitLev(Cfg.wartimestr, tstRevolving)
|
||||
System.broadcastTipmsgLimitLev(Cfg.wartimestr, tstChatSystem)
|
||||
end
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData.sbkGuild == nil then
|
||||
globalData.sbkGuild = 0
|
||||
end
|
||||
-- print("dealGuildSbk.."..cacheData.sbkGuild)
|
||||
if Cfg.winmap then
|
||||
local guildId = Fuben.GetNowSceneGuildList(Cfg.winmap);
|
||||
if guildId > 0 and globalData.sbkGuild ~= guildId then
|
||||
globalData.sbkGuild = guildId
|
||||
Guild.setSbkGuildId(guildId);
|
||||
local guildName = Guild.getGuildName(guildId)
|
||||
if guildName then
|
||||
local str = string.format(Cfg.sbknotic, guildName)
|
||||
-- print("..dealGuildSbk"..str)
|
||||
System.broadcastTipmsgLimitLev(str, tstRevolving)
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 处理活动开始 设置sbk区域为战斗区域
|
||||
function DealSbkAreaAttr(atvId, curTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if Cfg and Cfg.starttime then
|
||||
if curTime > (startTime + Cfg.starttime) then
|
||||
-- SbkState = AtvStatus.Sbk
|
||||
if SbkState ~= AtvStatus.Sbk then
|
||||
SbkState = AtvStatus.Sbk
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
ActivityDispatcher.BroadPopup(atvId);
|
||||
end
|
||||
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
|
||||
if cacheData.sbkArea == nil then
|
||||
cacheData.sbkArea = {}
|
||||
end
|
||||
-- 已经设置OK
|
||||
for _, area in Ipairs(cacheData.needDealarea) do
|
||||
if Cfg.areaattr and Cfg.areaattr.attri then
|
||||
for _, attr in pairs(Cfg.areaattr.attri) do
|
||||
local index = Fuben.GetAreaListIndex(area.sceneid, area.x, area.y)
|
||||
local hScene = Fuben.getSceneHandleById(area.sceneid, 0)
|
||||
if index > 0 then
|
||||
Fuben.setSceneAreaAttri(hScene, index, attr.type, attr.value, NULL, (Cfg.areaattr.notips or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
-- print("西门吹雪 .."..area.sceneid)
|
||||
cacheData.sbkArea[area.sceneid] = area.sceneid
|
||||
end
|
||||
cacheData.needDealarea = nil;
|
||||
--设置战斗区域
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
end
|
||||
|
||||
-- 活动区域需要处理新增区域属性
|
||||
function OnEnterArea(atvId, pActor)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local sceneId = Actor.getSceneId(pActor);
|
||||
if cacheData.areaAttr == nil then
|
||||
cacheData.areaAttr = {}
|
||||
end
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
local x,y = Actor.getEntityPosition(pActor,0,0)
|
||||
-- 已经初始化完成
|
||||
if cacheData.areaAttr[sceneId] then
|
||||
return;
|
||||
end
|
||||
-- print("来了吗.."..sceneId)
|
||||
cacheData.areaAttr[sceneId] = 1;
|
||||
local area = {};
|
||||
area.sceneid = sceneId;
|
||||
area.x = x
|
||||
area.y = y
|
||||
-- -- print("OnEnterArea x.."..x.." y.."..y);
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
cacheData.needDealarea[sceneId] = area
|
||||
-- table.insert(cacheData.needDealarea, area);
|
||||
end
|
||||
|
||||
|
||||
-- 离开活动区域
|
||||
function OnExitArea(atvId, pActor)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
cacheData.actors[actorId] = 0
|
||||
end
|
||||
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
if SbkState == AtvStatus.Sbk then ret = 1 end
|
||||
return ret
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType10.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType10.lua")
|
||||
-- ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterArea, ActivityType, OnEnterArea, "ActivityType10.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitArea, ActivityType, OnExitArea, "ActivityType10.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10.lua")
|
||||
@@ -0,0 +1,161 @@
|
||||
module("ActivityType10001", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
累计充值活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
LeftgetgiftTimes[i] = 1 当前档奖励位领取标志位
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10001
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10001Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--客户端请求角色剩余次数数据
|
||||
function reqActorTimesData(pActor,atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendActorDataTimes)
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
|
||||
if outPack then
|
||||
DataPack.writeUInt(npack, currentYuanBaoCount)
|
||||
DataPack.writeByte(outPack, ActivityConfig[atvId].LevelNum)
|
||||
for i = 1, ActivityConfig[atvId].LevelNum do
|
||||
DataPack.writeByte(outPack, i )
|
||||
DataPack.writeByte(outPack, actorData.LeftgetgiftTimes[i])
|
||||
end
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--玩家请求奖励
|
||||
function reqGetAward(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
local awards = ActivityConfig[atvId].GiftTable[indexId].awards
|
||||
if ActivityConfig[atvId].GiftTable ~=nil then
|
||||
--if indexId ~= ActivityConfig[atvId].GiftTable[indexId].level then return end
|
||||
if nil == awards then return end
|
||||
if currentYuanBaoCount == nil then return end
|
||||
if actorData.LeftgetgiftTimes[indexId] ==nil then return end
|
||||
-- if CommonFunc.Awards.CheckBagGridCount(pActor,awards) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmLeftBagNumNotEnough, tstUI)
|
||||
-- return
|
||||
-- end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
local levelYuanbao = ActivityConfig[atvId].GiftTable[indexId].value
|
||||
if (levelYuanbao ~=nil )and (currentYuanBaoCount >=levelYuanbao) and (actorData.LeftgetgiftTimes[indexId] == 1 ) then
|
||||
--CommonFunc.GiveCommonAward(pActor, awards, GameLog.Log_Activity10001, "累计充值活动|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity10001, "累计充值活动|"..atvId)
|
||||
|
||||
actorData.LeftgetgiftTimes[indexId] = 0
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-----------------------------------------------我是分界线----------------------------------------------------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
--print("[GActivity 10001] 累计充值 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--print("[activitytype10001] 累计充值---onstart atvId:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.LeftgetgiftTimes == nil then
|
||||
actorData.LeftgetgiftTimes = {}
|
||||
for i = 1, ActivityConfig[atvId].LevelNum do
|
||||
actorData.LeftgetgiftTimes[i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
--print("-------operatro:"..operaCode)
|
||||
if operaCode == ActivityOperate.cReqLeijichongzhiGift then --请求获取阶段奖励
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
--print("-------indexId:"..indexId)
|
||||
reqGetAward(pActor, atvId , indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
|
||||
if actorData.LeftgetgiftTimes == nil then
|
||||
actorData.LeftgetgiftTimes = {}
|
||||
for i = 1, ActivityConfig[atvId].LevelNum do
|
||||
actorData.LeftgetgiftTimes[i] = 1
|
||||
end
|
||||
end
|
||||
|
||||
if outPack then
|
||||
DataPack.writeUInt(outPack, currentYuanBaoCount)
|
||||
DataPack.writeByte(outPack, ActivityConfig[atvId].LevelNum)
|
||||
for i = 1, ActivityConfig[atvId].LevelNum do
|
||||
DataPack.writeByte(outPack, i )
|
||||
DataPack.writeByte(outPack, actorData.LeftgetgiftTimes[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
--local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
--actorData.LeftgetgiftTimes = nil
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10001.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10001.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10001.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10001.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10001.lua")
|
||||
@@ -0,0 +1,201 @@
|
||||
module("ActivityType10002", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
礼包活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
buy {index:num } --已购买的次数
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10002
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10002Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--玩家请求购买礼包
|
||||
function reqPurchaseGiftBox(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
if actorData.buy == nil then
|
||||
actorData.buy = {}
|
||||
end
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if Cfg == nil then
|
||||
return;
|
||||
end
|
||||
local ThisCfg = Cfg[indexId]
|
||||
if ThisCfg then
|
||||
local atvOpenDay = System.getPActivityOpenDay(atvId);
|
||||
--检测开放购买天数
|
||||
if ThisCfg.BuyDayLmt then
|
||||
if (atvOpenDay + ThisCfg.BuyDayLmt -1) > System.getDaysSinceOpenServer() then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:未开放购买 请耐心等待|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if ThisCfg.timeLimit then
|
||||
if (atvOpenDay + ThisCfg.timeLimit -1) < System.getDaysSinceOpenServer() then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:购买时间已结束|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--提示没有购买次数
|
||||
if ThisCfg.BuyLimit then
|
||||
local leftNum = ThisCfg.BuyLimit - (actorData.buy[indexId] or 0)
|
||||
if leftNum <= 0 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已无购买次数|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检查消耗是否满足条件
|
||||
if ThisCfg.price then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, ThisCfg.price ,tstUI) ~= true then
|
||||
--Actor.sendTipmsgWithId(pActor, tmNomoreYubao, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检查格子够不够
|
||||
-- if CommonFunc.Awards.CheckBagIsEnough(pActor,10) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmLeftBagNumNotEnough, tstUI)
|
||||
-- return
|
||||
-- end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--扣除消耗
|
||||
if CommonFunc.Consumes.Remove(pActor, ThisCfg.price, GameLog.Log_Activity10002, "礼包活动|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
if ThisCfg.award then
|
||||
--CommonFunc.GiveCommonAward(pActor, ThisCfg.award, GameLog.Log_Activity10002, "礼包活动|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, ThisCfg.award, GameLog.Log_Activity10002, "礼包活动|"..atvId)
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmConsiBuySuccAddToBag, tstUI)
|
||||
if ThisCfg.BuyLimit then
|
||||
actorData.buy[indexId] = (actorData.buy[indexId] or 0) + 1;
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 10002] 特惠礼包"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId);
|
||||
-- local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
-- local Cfg = ActivityConfig[atvId]
|
||||
-- if actorData.LeftPurchaseGiftBoxTimes == nil then
|
||||
-- actorData.LeftPurchaseGiftBoxTimes = {}
|
||||
-- for i = 1, Cfg.GiftBoxNum do
|
||||
-- if Cfg.GiftTable[i] and (Cfg.GiftTable[i].timesLimit ~= nil ) then
|
||||
-- --if i == Cfg.GiftTable[i].id then
|
||||
-- actorData.LeftPurchaseGiftBoxTimes[i] = Cfg.GiftTable[i].timesLimit
|
||||
-- --end
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
print("[activitytype10002] ---onstart atvId:"..atvId)
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqPurchaseGiftbag then --请求购买特惠礼包
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
reqPurchaseGiftBox(pActor, atvId , indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
|
||||
if outPack then
|
||||
local len = 0
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if Cfg then
|
||||
len = #Cfg;
|
||||
end
|
||||
DataPack.writeByte(outPack, (len or 0));
|
||||
local openDay = System.getDaysSinceOpenServer();
|
||||
if len > 0 then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end;
|
||||
|
||||
if actorData.buy == nil then
|
||||
actorData.buy = { }
|
||||
end
|
||||
for _, cfg in pairs(Cfg) do
|
||||
DataPack.writeByte(outPack, (cfg.GiftBoxNum or 0))
|
||||
local leftNum = -1;
|
||||
if cfg.BuyLimit then
|
||||
leftNum = cfg.BuyLimit - (actorData.buy[cfg.GiftBoxNum] or 0)
|
||||
if leftNum < 0 then
|
||||
leftNum = 0;
|
||||
end
|
||||
end
|
||||
DataPack.writeByte(outPack, (leftNum or 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10002.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10002.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10002.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10002.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10002.lua")
|
||||
@@ -0,0 +1,280 @@
|
||||
module("ActivityType10003", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
首冲
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
LeftTimes = 1111 当前档奖励位领取标志位
|
||||
nGetFlag //领取标志
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10003
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10003Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--玩家请求领取礼包
|
||||
function reqGetGiftBox(pActor, atvId , indexId,inerIndex)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if nil == actorData or nil == actorData.nGetFlag or nil == actorData.LeftTimes or nil == inerIndex then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:无可领取的礼包|", tstUI)
|
||||
return;
|
||||
end
|
||||
|
||||
if Cfg[1][1].Count == nil then
|
||||
--print("配置错误")
|
||||
end
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
if currentYuanBaoCount < Cfg[1][1].Count then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:未达到最低充值额度|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--print("indexId: "..indexId.." InnerIndex : "..inerIndex)
|
||||
if Cfg ~=nil and Cfg[indexId]~=nil and Cfg[indexId][inerIndex] ~=nil then
|
||||
--配置检查
|
||||
--if indexId ~= Cfg.GiftTable[indexId].value then return end
|
||||
if nil == Cfg[indexId][inerIndex].GiftTable then return end
|
||||
if indexId ~= Cfg[indexId][inerIndex].jobs then return end
|
||||
local Award = Cfg[indexId][inerIndex].GiftTable
|
||||
|
||||
|
||||
--提示没有购买次数
|
||||
if System.getIntBit((actorData.LeftTimes or 0),inerIndex-1) == 1 then
|
||||
--Actor.sendTipmsgWithId(pActor, tmNomoreYubao, tstUI)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- if actorData.GetTime == nil then
|
||||
-- actorData.nextIndex =1
|
||||
-- if inerIndex ~= 1 then
|
||||
-- if inerIndex == 2 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第二天才可领取|", tstUI)
|
||||
-- elseif inerIndex == 3 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第三天才可领取|", tstUI)
|
||||
-- end
|
||||
-- return
|
||||
-- end
|
||||
-- else
|
||||
-- if actorData.GetTime == System.getDaysSinceOpenServer() then
|
||||
-- --if actorData.nextIndex ~= inerIndex then
|
||||
-- if inerIndex == 2 and System.getIntBit((actorData.LeftTimes or 0),inerIndex-1) ==1 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第二天才可领取|", tstUI)
|
||||
-- elseif inerIndex == 3 and System.getIntBit((actorData.LeftTimes or 0),inerIndex-1) ==1 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第三天才可领取|", tstUI)
|
||||
-- end
|
||||
|
||||
-- --end
|
||||
-- return
|
||||
-- end
|
||||
|
||||
-- end
|
||||
|
||||
--检查格子够不够
|
||||
-- if CommonFunc.Awards.CheckBagGridCount(pActor,Award) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmLeftBagNumNotEnough, tstUI)
|
||||
-- return
|
||||
-- end
|
||||
|
||||
if inerIndex > actorData.nGetFlag then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:该礼包领取时间未到|", tstUI)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,17) ~= true then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:背包不足,药品、装备、材料包裹都必须剩余2格|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--if actorData.LeftTimes == 1 then
|
||||
--CommonFunc.GiveCommonAward(pActor, Award, GameLog.Log_Activity10003, "首冲领取礼包|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, Award, GameLog.Log_Activity10003, "首冲领取礼包|"..atvId)
|
||||
--print("req---> LeftTimes : "..(actorData.LeftTimes or 0 ).." GetTime : "..(actorData.GetTime or 0 ).." nextIndex : "..(actorData.nextIndex or 0 ))
|
||||
actorData.LeftTimes = System.setIntBit(actorData.LeftTimes, inerIndex-1, true)
|
||||
-- print("inerIndex..."..actorData.LeftTimes)
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
---策划fw
|
||||
local strName = Actor.getName(pActor)
|
||||
if inerIndex == 1 and Cfg[1][1].tips then
|
||||
local strTips = string.format(Cfg[1][1].tips,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips, tstKillDrop)
|
||||
end
|
||||
|
||||
if inerIndex == 1 and Cfg[1][1].tips2 then
|
||||
local strTips2 = string.format(Cfg[1][1].tips2,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips2, tstChatSystem)
|
||||
end
|
||||
--end
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
--print("[GActivity 10003] 首冲"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
--print("[activitytype 10003] ---onstart atvId:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.LeftTimes == nil then
|
||||
actorData.LeftTimes = 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
local InnerIndex = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqPurchaseGiftbag then --请求领取首冲奖励
|
||||
local myjob = Actor.getIntProperty(pActor, PROP_ACTOR_VOCATION)
|
||||
--print("-------myjob:"..myjob)
|
||||
reqGetGiftBox(pActor, atvId , myjob,InnerIndex)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
--local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendActorDataTimes)
|
||||
|
||||
if actorData.LeftTimes == nil then
|
||||
actorData.LeftTimes = 0
|
||||
end
|
||||
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
|
||||
if outPack then
|
||||
DataPack.writeUInt(outPack, currentYuanBaoCount or 0 )
|
||||
DataPack.writeByte(outPack, actorData.LeftTimes or 0)
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if actorData.nGetFlag == nil then
|
||||
return ret
|
||||
end
|
||||
|
||||
if actorData.LeftTimes == nil then
|
||||
actorData.LeftTimes = 0
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
if currentYuanBaoCount >= Cfg[1][1].Count then
|
||||
for i = 1, actorData.nGetFlag,1 do
|
||||
if System.getIntBit((actorData.LeftTimes or 0),i-1) == 0 then
|
||||
ret = System.setIntBit(ret, i-1, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10003.lua")
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
---更新活动数据
|
||||
function OnUpdateActivity(atvId, pActor, nValue)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if actorData.LeftTimes == nil then
|
||||
actorData.LeftTimes = 0
|
||||
end
|
||||
if actorData.nGetFlag then
|
||||
return;
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if nValue >= Cfg[1][1].Count then
|
||||
if actorData.nGetFlag == nil then
|
||||
actorData.nGetFlag = 0;
|
||||
end
|
||||
actorData.nGetFlag = actorData.nGetFlag +1;
|
||||
Actor.setRechargeStatus(pActor, 1)
|
||||
else
|
||||
Actor.setRechargeStatus(pActor, 0)
|
||||
end
|
||||
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType10003.lua")
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10003.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10003.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10003.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10003.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10003.lua")
|
||||
|
||||
|
||||
-- 跨天,
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[ActivityType10004 ] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
if runAtvIdList then
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
if currentYuanBaoCount >= Cfg[1][1].Count then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.nGetFlag then
|
||||
actorData.nGetFlag = actorData.nGetFlag + ndiffday;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10003.lua")
|
||||
@@ -0,0 +1,254 @@
|
||||
module("ActivityType10004", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
七天登录
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
AwardBitMap = 1 当前档奖励位图 二进制的从右到左为从1到32天,1表示已领取
|
||||
LoginInDays = 5 登录天数
|
||||
|
||||
LastLoginIsNo_OfOpenday = 5, 记录上次签到是开服的第几号
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10004
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10004Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
|
||||
]]
|
||||
|
||||
|
||||
|
||||
--玩家请求领取礼包
|
||||
function reqGetGiftBox(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if ActivityConfig[atvId][indexId] == nil then
|
||||
--print("index 参数错误")
|
||||
return
|
||||
end
|
||||
local Cfg = ActivityConfig[atvId][indexId]
|
||||
local awards = Cfg.GiftTable
|
||||
|
||||
|
||||
|
||||
--提示已领取无法多次领取
|
||||
if System.getIntBit(actorData.AwardBitMap,indexId) == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取该奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
--登录天数不足
|
||||
if actorData.LoginInDays <indexId then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:登录天数不足|", tstUI)
|
||||
return
|
||||
end
|
||||
--检查格子够不够
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--CommonFunc.GiveCommonAward(pActor, awards, GameLog.Log_Activity10004, "七天登录领取礼包|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity10004, "七天登录领取礼包|"..atvId)
|
||||
|
||||
--print("------------bitmap: "..actorData.AwardBitMap.."indexId: "..indexId)
|
||||
actorData.AwardBitMap = System.setIntBit(actorData.AwardBitMap, indexId, 1) --将indexId位置置为1
|
||||
--print("------------bitmap: "..actorData.AwardBitMap)
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
--ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
--print("[GActivity 10004] 七天登录"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
-- local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
-- if actorData.AwardBitMap == nil then
|
||||
-- actorData.AwardBitMap = 0
|
||||
-- end
|
||||
-- if actorData.LoginInDays == nil then
|
||||
-- actorData.LoginInDays = 0
|
||||
-- end
|
||||
-- if actorData.LastLoginIsNo_OfOpenday == nil then
|
||||
-- actorData.LastLoginIsNo_OfOpenday = 0
|
||||
-- end
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
--print("[activitytype 10004] 七天登录活动---onstart atvId:"..atvId)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfOpenday == nil then
|
||||
actorData.LastLoginIsNo_OfOpenday = 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqPurchaseGiftbag then --请求领取七天奖励
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
--print("---------operator : "..operaCode.."-------indexId : "..indexId)
|
||||
reqGetGiftBox(pActor, atvId , indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfOpenday == nil then
|
||||
actorData.LastLoginIsNo_OfOpenday = 0
|
||||
end
|
||||
|
||||
if outPack then
|
||||
DataPack.writeUInt(outPack, actorData.AwardBitMap)
|
||||
--print("atvId : 10004 awardBitMap: "..actorData.AwardBitMap)
|
||||
DataPack.writeByte(outPack, actorData.LoginInDays)
|
||||
--print("atvId : 10004 loginDays: "..actorData.LoginInDays)
|
||||
end
|
||||
end
|
||||
|
||||
function OnLoginGame(atvId,pActor)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfOpenday == nil then
|
||||
actorData.LastLoginIsNo_OfOpenday = 0
|
||||
end
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
--print("call func ___ onLoginGame()")
|
||||
if actorData.LastLoginIsNo_OfOpenday ~= openday then
|
||||
actorData.LoginInDays = actorData.LoginInDays +1
|
||||
actorData.LastLoginIsNo_OfOpenday = openday
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
|
||||
--local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
--actorData.AwardBitMap = nil --当前档奖励位图 二进制的从右到左为从1到32天,1表示已领取
|
||||
--actorData.LoginInDays = nil --登录天数
|
||||
--actorData.LastLoginIsNo_OfOpenday = nil --记录上次签到是开服的第几号
|
||||
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
|
||||
if Cfg ~=nil then
|
||||
for i = 1 , #Cfg do
|
||||
--print("----------------------actorData.LoginDays: "..actorData.LoginInDays)
|
||||
--print("----------------------actorData.AwardBitMap: "..actorData.AwardBitMap)
|
||||
if (actorData.LoginInDays >= i) and (System.getIntBit(actorData.AwardBitMap,i) == 0) then
|
||||
ret = System.setIntBit(ret, i, 1) --对应位为1表示该奖励可领取
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10004.lua")
|
||||
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
--print("------------------10004-------------------curTime: "..curTime)
|
||||
--print("------------------10004-------------------today LinchenTime: "..System.getToday())
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType10004.lua")
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10004.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10004.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10004.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10004.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10004.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType10004.lua")
|
||||
|
||||
|
||||
|
||||
------------------------------我是分割线------------------------
|
||||
|
||||
-- 跨天,
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[ActivityType10004 ] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
if runAtvIdList then
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
OnLoginGame(atvId,pActor)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10004.lua")
|
||||
@@ -0,0 +1,343 @@
|
||||
module("ActivityType10005", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
每日签到
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
MonthBitFlag = 11110011, 本月签到地图 二进制的从右到左为从1到32天,1表示该日期已签到
|
||||
AwardBitMap = 10011 当前档奖励位图 二进制的从右到左为从1到32天,1表示已领取
|
||||
LoginInDays = 5 签到天数
|
||||
|
||||
LastLoginMonthofYear = 1 , 上次签到的月份
|
||||
LastLoginIsNo_OfMonth = 31, 上次签到是当月的第几号
|
||||
LastLogingLinchengSec = .. 上次签到当天凌晨的绝对时间
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10005
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10005Config
|
||||
SignPrizeCfg= SignPrizeConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--local Lingchengsec = System.getToday() --获取今日凌晨unsigned int 时间
|
||||
|
||||
--local dayNo_ = System.getDayOfMonth(); --今天是当月的第几号
|
||||
|
||||
--local MonthNo_ = System.getMonthOfNow(); --当前月份
|
||||
|
||||
|
||||
function nextMonthClear(pActor,atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local dayofMonth = System.getDayOfMonth()
|
||||
--local LinChengSec = System.getToday()
|
||||
local MonthofYear = System.getMonthOfNow();
|
||||
|
||||
if actorData.LastLoginMonthofYear ==nil then
|
||||
actorData.LastLoginMonthofYear = 0 ;
|
||||
end
|
||||
|
||||
--跨月了,数据清空
|
||||
if actorData.LastLoginMonthofYear ~= MonthofYear then
|
||||
actorData.MonthBitFlag = 0
|
||||
actorData.AwardBitMap = 0
|
||||
actorData.LoginInDays = 0
|
||||
actorData.LastLoginIsNo_OfMonth = 0
|
||||
actorData.LastLogingLinchengSec = 0
|
||||
actorData.LastLoginMonthofYear = 0
|
||||
end
|
||||
end
|
||||
|
||||
--特权后台打卡不需要提示
|
||||
function backStageQiandao(pActor, atvId)
|
||||
nextMonthClear(pActor,atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local dayofMonth = System.getDayOfMonth()
|
||||
local LinChengSec = System.getToday()
|
||||
|
||||
--今日已经打卡
|
||||
if (actorData.LastLogingLinchengSec == LinChengSec) and ( System.getIntBit(actorData.MonthBitFlag,dayofMonth) == 1) then
|
||||
--Actor.sendTipmsg(pActor, "您已打卡成功 无需多次打卡", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
actorData.MonthBitFlag = System.setIntBit(actorData.MonthBitFlag, dayofMonth, 1) --将本月的第n天位置置为1
|
||||
actorData.LastLoginIsNo_OfMonth = dayofMonth
|
||||
actorData.LastLogingLinchengSec = LinChengSec
|
||||
actorData.LoginInDays = actorData.LoginInDays +1 --可以在某个位置设置校验MonthBitFlag 是否有问题, 先不处理
|
||||
|
||||
local MonthofYear = System.getMonthOfNow();
|
||||
actorData.LastLoginMonthofYear = MonthofYear
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
--请求打卡
|
||||
function reqQiandao(pActor, atvId)
|
||||
nextMonthClear(pActor,atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local dayofMonth = System.getDayOfMonth()
|
||||
local LinChengSec = System.getToday()
|
||||
|
||||
--今日已经打卡
|
||||
if (actorData.LastLogingLinchengSec == LinChengSec) and ( System.getIntBit(actorData.MonthBitFlag,dayofMonth) == 1) then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:今日已签到成功,无需重复签到|", tstUI)
|
||||
return
|
||||
end
|
||||
--检查格子够不够
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,1,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
actorData.MonthBitFlag = System.setIntBit(actorData.MonthBitFlag, dayofMonth, 1) --将本月的第n天位置置为1
|
||||
actorData.LastLoginIsNo_OfMonth = dayofMonth
|
||||
actorData.LastLogingLinchengSec = LinChengSec
|
||||
actorData.LoginInDays = actorData.LoginInDays +1 --可以在某个位置设置校验MonthBitFlag 是否有问题, 先不处理
|
||||
|
||||
local MonthofYear = System.getMonthOfNow();
|
||||
actorData.LastLoginMonthofYear = MonthofYear
|
||||
|
||||
if SignPrizeCfg[dayofMonth] and SignPrizeCfg[dayofMonth].prz then
|
||||
CommonFunc.Awards.Give(pActor, SignPrizeCfg[dayofMonth].prz, GameLog.Log_Activity10005, "每日签到|"..atvId)
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
--玩家请求领取礼包
|
||||
function reqGetGiftBox(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if Cfg ~=nil then
|
||||
--检查indexId参数是否合法
|
||||
for i= 1 , #Cfg do
|
||||
if (Cfg[i].GiftNums ==indexId) then
|
||||
if nil == Cfg[i].GiftTable then return end
|
||||
break
|
||||
end
|
||||
if i == #Cfg and Cfg[i].GiftNums ~=indexId then
|
||||
--print("请求index参数错误")
|
||||
return --没有找到该天数对应的奖励
|
||||
end
|
||||
end
|
||||
--配置检查
|
||||
|
||||
--登录天数不足
|
||||
if actorData.LoginInDays <indexId then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:打卡天数不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--提示已领取无法多次领取
|
||||
if System.getIntBit(actorData.AwardBitMap,indexId) == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取该奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--检查格子够不够
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
for i= 1 , #Cfg do
|
||||
if (Cfg[i].GiftNums ==indexId) then
|
||||
--CommonFunc.GiveCommonAward(pActor, Cfg[i].GiftTable, GameLog.Log_Activity10005, "每日签到领取礼包|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, Cfg[i].GiftTable, GameLog.Log_Activity10005, "每日签到领取礼包|"..atvId)
|
||||
|
||||
actorData.AwardBitMap = System.setIntBit(actorData.AwardBitMap, indexId, 1) --将indexId位置置为1
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId , pActor)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
nextMonthClear(pActor,atvId)
|
||||
|
||||
if actorData.MonthBitFlag == nil then
|
||||
actorData.MonthBitFlag = 0
|
||||
end
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfMonth == nil then
|
||||
actorData.LastLoginIsNo_OfMonth = 0
|
||||
end
|
||||
if actorData.LastLogingLinchengSec == nil then
|
||||
actorData.LastLogingLinchengSec = 0
|
||||
end
|
||||
if actorData.LastLoginMonthofYear == nil then
|
||||
actorData.LastLoginMonthofYear = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqPurchaseGiftbag then --请求领取签到奖励
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
--print("---------operator : "..operaCode.."-------indexId : "..indexId)
|
||||
reqGetGiftBox(pActor, atvId , indexId)
|
||||
elseif operaCode == ActivityOperate.cReqAtvQianDao then --请求签到
|
||||
--print("---------operator : "..operaCode)
|
||||
reqQiandao(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
nextMonthClear(pActor,atvId)
|
||||
|
||||
if actorData.MonthBitFlag == nil then
|
||||
actorData.MonthBitFlag = 0
|
||||
end
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfMonth == nil then
|
||||
actorData.LastLoginIsNo_OfMonth = 0
|
||||
end
|
||||
if actorData.LastLogingLinchengSec == nil then
|
||||
actorData.LastLogingLinchengSec = 0
|
||||
end
|
||||
if actorData.LastLoginMonthofYear == nil then
|
||||
actorData.LastLoginMonthofYear = 0
|
||||
end
|
||||
|
||||
if outPack then
|
||||
DataPack.writeUInt(outPack, (actorData.MonthBitFlag or 0)) --签到地图
|
||||
--print("monthbitMap: "..actorData.MonthBitFlag)
|
||||
DataPack.writeUInt(outPack, (actorData.AwardBitMap or 0)) --领取地图
|
||||
--print("awardbitMap: "..actorData.AwardBitMap)
|
||||
DataPack.writeByte(outPack, (actorData.LoginInDays or 0 )) --签到天数
|
||||
--print("days: "..actorData.LoginInDays)
|
||||
end
|
||||
end
|
||||
|
||||
function OnLoginGame(atvId,pActor)
|
||||
-- if Actor.IsHasFreePrivilege(pActor) then
|
||||
-- backStageQiandao(pActor, atvId)
|
||||
-- end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.MonthBitFlag == nil then
|
||||
actorData.MonthBitFlag = 0
|
||||
end
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfMonth == nil then
|
||||
actorData.LastLoginIsNo_OfMonth = 0
|
||||
end
|
||||
if actorData.LastLogingLinchengSec == nil then
|
||||
actorData.LastLogingLinchengSec = 0
|
||||
end
|
||||
if actorData.LastLoginMonthofYear == nil then
|
||||
actorData.LastLoginMonthofYear = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local dayofMonth = System.getDayOfMonth()
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if System.getIntBit(actorData.MonthBitFlag,dayofMonth) == 0 then
|
||||
ret = 1 --最低位1表示当天未签到
|
||||
end
|
||||
|
||||
if Cfg ~= nil then
|
||||
for i = 1, #Cfg do
|
||||
--print("---------------------- actorData.LoginDays: "..(actorData.LoginInDays or -1))
|
||||
--print("---------------------- actorData.AwardBitMap: "..actorData.AwardBitMap)
|
||||
if ((actorData.LoginInDays or 0) >= Cfg[i].GiftNums) and (System.getIntBit(actorData.AwardBitMap, Cfg[i].GiftNums) == 0) then
|
||||
ret = System.setIntBit(ret, i, 1) --对应位为1表示该奖励可领取
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10005.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType10005.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10005.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10005.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10005.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10005.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10005.lua")
|
||||
|
||||
------------------------------我是分割线------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[ActivityType10005 ] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
if runAtvIdList then
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
nextMonthClear(pActor,atvId)
|
||||
OnLoginGame(atvId,pActor)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10005.lua")
|
||||
@@ -0,0 +1,339 @@
|
||||
module("ActivityType10006", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
登录基金
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
AwardBitMap = 1 当前档奖励位图 二进制的从右到左为从1到32天,1表示已领取
|
||||
LoginInDays = 5 登录天数
|
||||
|
||||
LastLoginIsNo_OfOpenday = 5, 记录上次签到是开服的第几号
|
||||
PURCHASEFLAG = 0 购买标志,0 未购买,1 已购买
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10006
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10006Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
|
||||
|
||||
|
||||
]]
|
||||
|
||||
|
||||
--玩家请求购买基金
|
||||
function reqPurchaseJiJing(pActor, atvId )
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId][1]
|
||||
|
||||
if Cfg.consume ~=nil then
|
||||
|
||||
if Cfg.buyDayLmt >= System.getDaysSinceOpenServer() then
|
||||
--检查消耗是否满足条件
|
||||
local consumes = Cfg.consume
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, consumes,tstUI) ~= true then
|
||||
--Actor.sendTipmsgWithId(pActor, tmNomoreYubao, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--扣除消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity10006, "登录基金购买 | " .. atvId) == true then
|
||||
actorData.PURCHASEFLAG = 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
--print("--------------------purchaseFlag : "..actorData.PURCHASEFLAG)
|
||||
--触发当日登录
|
||||
OnLoginGame(atvId,pActor)
|
||||
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--玩家请求领取奖励
|
||||
function reqGetGift(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if Cfg ~=nil then
|
||||
|
||||
|
||||
--检查indexId参数是否合法
|
||||
for i= 1 , #Cfg do
|
||||
if (Cfg[i].needDays ==indexId) then
|
||||
break
|
||||
end
|
||||
if i == #Cfg and Cfg[i].needDays ~=indexId then
|
||||
--print("请求index参数错误")
|
||||
return --没有找到该天数对应的奖励
|
||||
end
|
||||
end
|
||||
|
||||
--提示已领取无法多次领取
|
||||
if System.getIntBit(actorData.AwardBitMap,indexId) == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取该奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--登录天数不够
|
||||
if actorData.LoginInDays <indexId then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:登录天数不够|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--检查格子够不够
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmGiftNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for i= 1 , #Cfg do
|
||||
if (Cfg[i].needDays ==indexId) then
|
||||
if Cfg[i].GiftTable == nil then return end
|
||||
local award = Cfg[i].GiftTable
|
||||
--CommonFunc.GiveCommonAward(pActor, award, GameLog.Log_Activity10006, "登录基金领取 | " .. atvId)
|
||||
CommonFunc.Awards.Give(pActor, award, GameLog.Log_Activity10006, "登录基金领取 | " .. atvId)
|
||||
|
||||
--print("------------bitmap: "..actorData.AwardBitMap.."indexId: "..indexId)
|
||||
actorData.AwardBitMap = System.setIntBit(actorData.AwardBitMap, indexId, 1) --将indexId位置置为1
|
||||
--print("------------bitmap: "..actorData.AwardBitMap)
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnLoad(atvId, pActor)
|
||||
--print("[GActivity 10006] 登录基金"..Actor.getName(pActor).." OnLoad id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfOpenday == nil then
|
||||
actorData.LastLoginIsNo_OfOpenday = 0
|
||||
end
|
||||
if actorData.PURCHASEFLAG == nil then
|
||||
actorData.PURCHASEFLAG = 0
|
||||
end
|
||||
local Cfg = ActivityConfig[atvId][1]
|
||||
if Cfg.buyDayLmt < System.getDaysSinceOpenServer() and actorData.PURCHASEFLAG == 0 then
|
||||
--print("------------------------------------before close one activity 100006")
|
||||
Actor.closeOneActivity(pActor,atvId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
--print("[activitytype 10006] 登录基金---onstart atvId:"..atvId)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfOpenday == nil then
|
||||
actorData.LastLoginIsNo_OfOpenday = 0
|
||||
end
|
||||
if actorData.PURCHASEFLAG == nil then
|
||||
actorData.PURCHASEFLAG = 0
|
||||
end
|
||||
local Cfg = ActivityConfig[atvId][1]
|
||||
if Cfg.buyDayLmt < System.getDaysSinceOpenServer() and actorData.PURCHASEFLAG == 0 then
|
||||
--print("------------------------------------before close one activity 100006")
|
||||
Actor.closeOneActivity(pActor,atvId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
--print("---------operator : "..operaCode)
|
||||
if operaCode == ActivityOperate.cReqPurchaseJiJin then --请求购买基金
|
||||
reqPurchaseJiJing(pActor, atvId )
|
||||
elseif operaCode == ActivityOperate.cReqGetJiJinAward then --请求领取基金奖励
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
--print("---------operator : "..operaCode.."-------indexId : "..indexId)
|
||||
reqGetGift(pActor, atvId , indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId][1]
|
||||
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
if actorData.LastLoginIsNo_OfOpenday == nil then
|
||||
actorData.LastLoginIsNo_OfOpenday = 0
|
||||
end
|
||||
if actorData.PURCHASEFLAG == nil then
|
||||
actorData.PURCHASEFLAG = 0
|
||||
end
|
||||
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
|
||||
local EndMiniTime = System.getToday() + (Cfg.buyDayLmt-openday +1)*86400
|
||||
|
||||
local LeftTime = EndMiniTime - System.getCurrMiniTime()
|
||||
if LeftTime <= 0 then LeftTime = 0 end
|
||||
|
||||
--print("-----------------------actorData.AwardBitMap: "..actorData.AwardBitMap.."-----------------------------")
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, actorData.PURCHASEFLAG)
|
||||
DataPack.writeUInt(outPack, actorData.AwardBitMap)
|
||||
DataPack.writeByte(outPack, actorData.LoginInDays)
|
||||
DataPack.writeUInt(outPack, LeftTime)
|
||||
end
|
||||
end
|
||||
|
||||
function OnLoginGame(atvId,pActor)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
|
||||
if actorData.PURCHASEFLAG == 1 then
|
||||
if actorData.LastLoginIsNo_OfOpenday ~= openday then
|
||||
actorData.LoginInDays = actorData.LoginInDays +1
|
||||
actorData.LastLoginIsNo_OfOpenday = openday
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
--print(Actor.getName(pActor).."------------------------activityType10006.OnEnd------")
|
||||
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
--local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
--actorData.AwardBitMap = nil --当前档奖励位图 二进制的从右到左为从1到32天,1表示已领取
|
||||
--actorData.LoginInDays = nil --登录天数
|
||||
--actorData.LastLoginIsNo_OfOpenday = nil --记录上次签到是开服的第几号
|
||||
--actorData.PURCHASEFLAG = nil --购买标志
|
||||
|
||||
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if actorData.AwardBitMap == nil then
|
||||
actorData.AwardBitMap = 0
|
||||
end
|
||||
if actorData.LoginInDays == nil then
|
||||
actorData.LoginInDays = 0
|
||||
end
|
||||
|
||||
if Cfg ~=nil then
|
||||
for i = 1 , #Cfg do
|
||||
--print("----------------------actorData.LoginDays: "..actorData.LoginInDays)
|
||||
--print("----------------------actorData.AwardBitMap: "..actorData.AwardBitMap)
|
||||
if (actorData.LoginInDays >= i) and (System.getIntBit(actorData.AwardBitMap,Cfg[i].needDays) == 0) then
|
||||
ret = System.setIntBit(ret, i, 1) --对应位为1表示该奖励可领取
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10006.lua")
|
||||
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
--print("------------------10006-------------------curTime: "..curTime)
|
||||
--print("------------------10006-------------------today LinchenTime: "..System.getToday())
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType10006.lua")
|
||||
|
||||
|
||||
--ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10006.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType10006.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10006.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10006.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10006.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10006.lua")
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[ActivityType10006 ] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
if runAtvIdList then
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.PURCHASEFLAG == nil then actorData.PURCHASEFLAG = 0 end
|
||||
|
||||
local Cfg = ActivityConfig[atvId][1]
|
||||
if Cfg.buyDayLmt < System.getDaysSinceOpenServer() and actorData.PURCHASEFLAG == 0 then
|
||||
Actor.closeOneActivity(pActor,atvId)
|
||||
end
|
||||
|
||||
OnLoginGame(atvId,pActor)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10006.lua")
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
module("ActivityType10009", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动
|
||||
达标类
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
int nFlag // 标志
|
||||
int nValue //进度
|
||||
int endtime
|
||||
nNewFlag[]
|
||||
{
|
||||
nNewFlag
|
||||
}
|
||||
firstTips
|
||||
{}
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10009
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10009Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--玩家请求领取奖励
|
||||
function reqGetAward(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
return
|
||||
end
|
||||
local Cfg = getIndexCfg(atvId, indexId);
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local data = actorData[Cfg.subtype]
|
||||
if data == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件未达成|", tstUI)
|
||||
return
|
||||
end
|
||||
--提示已领取无法多次领取
|
||||
local res = GetBitData(atvId, pActor,indexId);
|
||||
-- if System.getIntBit((actorData.nFlag or 0),indexId) == 1 then
|
||||
if res == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取该奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if (data.nValue == nil) or (data.nValue < Cfg.value) then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件未达成|", tstUI)
|
||||
return
|
||||
end
|
||||
--检查格子够不够
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmGiftNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
if Cfg.GiftTable then
|
||||
local decstr = "达标类活动";
|
||||
if ActivitiesConf[atvId] and ActivitiesConf[atvId].ActivityName then
|
||||
decstr = ActivitiesConf[atvId].ActivityName
|
||||
end
|
||||
-- print("decstr.."..decstr);
|
||||
--CommonFunc.GiveCommonAward(pActor, Cfg.GiftTable, GameLog.Log_Activity10009, "达标类活动 | " .. atvId)
|
||||
CommonFunc.Awards.Give(pActor, Cfg.GiftTable, GameLog.Log_Activity10009, decstr)
|
||||
end
|
||||
|
||||
-- actorData.nFlag = System.setIntBit(actorData.nFlag, indexId, 1) --将indexId位置置为1
|
||||
-- print("indexId..."..indexId)
|
||||
SetBitData(atvId, pActor, indexId);
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
if Cfg.tips then
|
||||
local name = Actor.getName(pActor);
|
||||
local str = string.format(Cfg.tips,name)
|
||||
System.broadcastTipmsgLimitLev(str, tstKillDrop)
|
||||
end
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
Actor.SendJoinActivityLog(pActor,atvId,indexId);--领奖
|
||||
end
|
||||
|
||||
--
|
||||
function getIndexCfg(atvId, indexId)
|
||||
if ActivityConfig then
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.level == indexId then
|
||||
return cfg;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
|
||||
|
||||
function getTypeCfg(atvId, nType, nSubType)
|
||||
if ActivityConfig then
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.type == nType and cfg.subtype == nSubType then
|
||||
return cfg;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
--------------------------我是分界线----------------------------
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 10006] 达标类活动"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
print("[activitytype 10009] 达标类活动---onstart atvId:"..atvId)
|
||||
-- ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqGetAchieveAward then --请求领取基金奖励
|
||||
local indexId = DataPack.readInt(inPack)
|
||||
reqGetAward(pActor, atvId , indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function GetBitData(atvId, pActor, level)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
local nFlag = 0;
|
||||
if level < 32 then
|
||||
nFlag = System.getIntBit((actorData.nFlag or 0), level)
|
||||
else
|
||||
if actorData.nNewFlag == nil then
|
||||
actorData.nNewFlag = {}
|
||||
end
|
||||
if actorData.nNewFlag[level] == nil then
|
||||
actorData.nNewFlag[level] = 0
|
||||
end
|
||||
|
||||
nFlag =actorData.nNewFlag[level] or 0;
|
||||
end
|
||||
return nFlag;
|
||||
end
|
||||
|
||||
function SetBitData(atvId, pActor, level)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
if level < 32 then
|
||||
actorData.nFlag = System.setIntBit(actorData.nFlag, level, 1) --将indexId位置置为1
|
||||
else
|
||||
if actorData.nNewFlag == nil then
|
||||
actorData.nNewFlag = {}
|
||||
end
|
||||
if actorData.nNewFlag[level] == nil then
|
||||
actorData.nNewFlag[level] = 0
|
||||
end
|
||||
actorData.nNewFlag[level] = 1;
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
-- print("[PActivity10009 达标类活动 id:.."..atvId.."请求数据]")
|
||||
|
||||
if outPack == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
local len = 0;
|
||||
|
||||
if Cfg then
|
||||
len = #Cfg;
|
||||
end
|
||||
|
||||
--长度
|
||||
-- print("len.."..(len or 0));
|
||||
DataPack.writeInt(outPack, (len or 0))
|
||||
if Cfg then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
for _, cfg in pairs(Cfg) do
|
||||
local value = 0;
|
||||
local data = actorData[cfg.subtype]
|
||||
if data then
|
||||
value = data.nValue or 0
|
||||
end
|
||||
local res =GetBitData(atvId, pActor, cfg.level);
|
||||
-- local res = System.getIntBit((actorData.nFlag or 0), cfg.level)
|
||||
|
||||
if res == 1 then res = 2; end
|
||||
if res == 0 and value >= cfg.value then res = 1; end
|
||||
DataPack.writeByte(outPack, res)
|
||||
DataPack.writeInt(outPack, cfg.level)
|
||||
DataPack.writeInt(outPack, value)
|
||||
-- print("cfg.level.."..(cfg.level or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
print("[PActivity 10009] 活动id.."..atvId.."..结束")
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
end
|
||||
|
||||
--活动红点
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg) do
|
||||
local data = actorData[cfg.subtype]
|
||||
if data and data.nValue then
|
||||
if data.nValue >= cfg.value then
|
||||
local res =GetBitData(atvId, pActor, cfg.level);
|
||||
-- local res = System.getIntBit((actorData.nFlag or 0), cfg.level) --对应位为1表示该奖励可领取
|
||||
if res == 0 then ret = 1 break end;
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
function nextActivityClear(pActor,atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local atvendTime = System.getActivityEndMiniSecond(atvId);
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
if actorData.endtime ==nil then
|
||||
actorData.endtime = 0 ;
|
||||
end
|
||||
|
||||
--跨月了,数据清空
|
||||
if actorData.endtime ~= atvendTime then
|
||||
ActivityDispatcher.ClearActorData(pActor,atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
print("nextActivityClear endtime.."..(actorData.endtime or 0).."..atvendTime.."..(atvendTime or 0))
|
||||
actorData.endtime = atvendTime;
|
||||
end
|
||||
end
|
||||
|
||||
function OnLoginGame(atvId,pActor)
|
||||
-- nextActivityClear(pActor, atvId)
|
||||
end
|
||||
|
||||
function UpdateData(atvId, pActor, nType, nSubType,nValue)
|
||||
local Cfg = getTypeCfg(atvId, nType,nSubType);
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
-- print("OnUpdateActivity.."..atvId.."..nType.."..nType..".nSubType.."..nSubType.."..nValue.."..nValue)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
if actorData[nSubType] == nil then
|
||||
actorData[nSubType] = {};
|
||||
end
|
||||
if actorData[nSubType].nValue == nil then
|
||||
actorData[nSubType].nValue = 0;
|
||||
end
|
||||
if Cfg.ValueType == 1 then
|
||||
actorData[nSubType].nValue = actorData[nSubType].nValue + nValue;
|
||||
else
|
||||
if actorData[nSubType].nValue < nValue then
|
||||
actorData[nSubType].nValue = nValue;
|
||||
end
|
||||
end
|
||||
if Cfg.firsttips then
|
||||
local res = GetBitData(atvId, pActor, Cfg.level);
|
||||
if actorData.firstTips == nil then
|
||||
actorData.firstTips = {}
|
||||
end
|
||||
if (actorData[nSubType].nValue >= Cfg.value) and (res == 0) then
|
||||
if actorData.firstTips[Cfg.level] == nil then
|
||||
local dropType = 1;
|
||||
if nType == nAchieveDropItem then
|
||||
dropType = 2;
|
||||
end
|
||||
local msg = "";
|
||||
msg = msg..dropType.."\\"..Cfg.firsttips
|
||||
-- print("msg.."..msg)
|
||||
Actor.sendTipmsg(pActor,msg, tstFirstKillDrop);
|
||||
actorData.firstTips[Cfg.level] = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
---更新活动数据
|
||||
function OnUpdateActivity(atvId, pActor, nType, nSubType, nValue)
|
||||
-- local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if nAchieveEquipment == nType then
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.type == nType and cfg.subtype <= nSubType then
|
||||
UpdateData(atvId, pActor, nType, cfg.subtype, nValue);
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
UpdateData(atvId, pActor, nType, nSubType,nValue);
|
||||
end
|
||||
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType10009.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10009.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10009.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10009.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10009.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10009.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10009.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType10009.lua")
|
||||
@@ -0,0 +1,219 @@
|
||||
module("ActivityType10010", package.seeall)
|
||||
--[[
|
||||
个人活动————开服特定寻宝
|
||||
抽奖活动!
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 已抽奖次数
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10010
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10010Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
--请求抽奖
|
||||
function reqXunBao(pActor, atvId, Conf)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
local Config = Conf[openday]
|
||||
--消耗检查
|
||||
-- local consumes = Config.DrawPrice
|
||||
-- if consumes then
|
||||
-- if CommonFunc.Consumes.CheckActorSources(pActor, consumes,tstUI) ~= true then
|
||||
-- --Actor.sendTipmsgWithId(pActor, tmNomoreYubao, tstUI)
|
||||
-- return
|
||||
-- end
|
||||
-- end
|
||||
if not Config then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:数据有误|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--第N次免费抽奖
|
||||
local isFree = false
|
||||
local nTimes = 0
|
||||
if data.count == nil then
|
||||
nTimes = 1
|
||||
else
|
||||
nTimes = data.count + 1
|
||||
end
|
||||
for i, num in pairs(Config.freeNum) do
|
||||
if nTimes == num then
|
||||
isFree = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local consumes = Config.FirstCost
|
||||
if not isFree then
|
||||
if Config.FirstCost then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, Config.FirstCost) ~= true then
|
||||
consumes = nil
|
||||
end
|
||||
end
|
||||
if consumes == nil then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, Config.DrawPrice,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
consumes = Config.DrawPrice
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
else
|
||||
if data.count >= Config.Maxcount then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)--次数不足
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--背包检查,需要1格
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,12) ~= true then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:背包不足,装备、材料包裹必须剩余1格|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--local awards = ActivityConfig[atvId].Persongift
|
||||
local groupID = Config.NormalDropId
|
||||
for i , specialId in pairs(Config.SpecialCount) do
|
||||
if data.count == (specialId-1) then
|
||||
groupID = Config.SpecialDropId
|
||||
end
|
||||
end
|
||||
--print("------------------11111111111111111111:groutID :"..groupID)
|
||||
--执行掉落组抽奖
|
||||
local strName = Actor.getName(pActor)
|
||||
local RetTabel = Actor.ChouJiangByGroupId(pActor, groupID ,GameLog.Log_Activity10010,"抽奖活动| "..atvId )
|
||||
--print("retTabel Type: "..type(RetTabel)..#RetTabel)
|
||||
if RetTabel then
|
||||
for _, wupin in pairs(RetTabel) do
|
||||
if wupin ~=nil then
|
||||
if Config.tips and Config.tips[wupin.Id] then
|
||||
local strTips = string.format(Config.tips[wupin.Id].tips,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips, tstKillDrop)
|
||||
strTips = string.format(Config.tips[wupin.Id].tips_,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips, tstChatSystem)
|
||||
end
|
||||
end
|
||||
end
|
||||
--协议发送抽奖结果
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendChouJiangResult)
|
||||
if outPack then
|
||||
|
||||
DataPack.writeByte(outPack, #RetTabel)
|
||||
for _, wupin in pairs(RetTabel) do
|
||||
if wupin ~=nil then
|
||||
DataPack.writeUInt(outPack, wupin.Type)
|
||||
DataPack.writeUInt(outPack, wupin.Id)
|
||||
DataPack.writeUInt(outPack, wupin.Count)
|
||||
end
|
||||
end
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
else
|
||||
--print("------------------11111111111111111111")
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 扣取次数
|
||||
data.count = data.count + 1
|
||||
|
||||
-- 扣取消耗
|
||||
if consumes and not isFree then
|
||||
CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity10010, "抽奖活动 | " .. atvId)
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--初始化活动个人数据
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count ==nil then data.count = 0 end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count ==nil then data.count = 0 end
|
||||
|
||||
DataPack.writeWord(outPack, (data.count or 0))
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
--print("[PActivity 10010] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqXunBao then -- 请求寻宝抽奖
|
||||
reqXunBao(pActor,atvId,Conf)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10010.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10010.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10010.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10010.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[PActivity 10010] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
--print("[PActivity 10010] "..Actor.getName(pActor).." 跨天活动次数归零,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
data.count = 0
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10010.lua")
|
||||
@@ -0,0 +1,274 @@
|
||||
module("ActivityType10011", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动(玩法),YY大厅特权
|
||||
|
||||
个人数据:YYHallAtv
|
||||
{
|
||||
yydata = 0 YY大厅身份 1平民2贵族3王室
|
||||
freshmanGift = 0/1 是否领取YY大厅新手礼包(0否,1是)
|
||||
lastLoginTime = 0 上一次通过YY大厅登录的时间戳
|
||||
loginDay = 1 通过YY大厅登录的累计天数
|
||||
loginGift = 00000000 32位 是否领取某天的登录礼包
|
||||
levelGift = 00000000 32位 是否领取第n个等级礼包
|
||||
nobleGift = 00000000 32位 是否领取贵族礼包 1平民 2贵族 3王室
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10011
|
||||
--对应的活动配置
|
||||
ActivityConfig = YYMemberConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
local HttpStatus = {
|
||||
Success = "200", -- 成功
|
||||
ArgError = "302", -- 参数错误
|
||||
SignError = "304", -- 签名错误
|
||||
LinkLost = "305", -- 链接失效
|
||||
IpLimit = "306", -- IP受限
|
||||
AccountNotExits = "600", -- 账号不存在
|
||||
UnKnownedError = "299" -- 未知错误
|
||||
}
|
||||
|
||||
-- 服务接口
|
||||
Host = ActivityConfig.host or "proxy.udblogin.game.yy.com"
|
||||
Port = ActivityConfig.port or "80"
|
||||
Api = ActivityConfig.api or "/yy/lobbygift/query/queryInfo.do"
|
||||
|
||||
function getData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.YYHallAtv== nil then
|
||||
var.YYHallAtv = {}
|
||||
end
|
||||
return var.YYHallAtv
|
||||
end
|
||||
|
||||
function SendData(pActor,lvldata)
|
||||
|
||||
--对于lvldata不是 1 2 3 这三个指定数值的直接返回
|
||||
-- if not (lvldata and (lvldata ==1 or lvldata == 2 or lvldata == 3 )) then
|
||||
-- return
|
||||
-- end
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enActivityID, sYYHallData)
|
||||
if npack then
|
||||
local data = getData(pActor)
|
||||
data.yydata = lvldata
|
||||
DataPack.writeByte(npack, lvldata) --YY身份 1平民 2贵族 3王室
|
||||
DataPack.writeByte(npack, (data.freshmanGift or 0)) --是否已领取YY大厅新手礼包 0否1是
|
||||
DataPack.writeShort(npack, (data.loginDay or 1))--通过YY大厅登录的天数
|
||||
DataPack.writeUInt(npack, (data.loginGift or 0))--登录礼包的领取标记 32 位
|
||||
DataPack.writeUInt(npack, (data.levelGift or 0))--等级礼包的领取标记 32 位
|
||||
DataPack.writeUInt(npack, (data.nobleGift or 0))--贵族礼包的领取标记 32 位
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
function AfterCheckYYHall(paramPack,content,result)
|
||||
local aid = paramPack[1]
|
||||
local pActor = Actor.getActorById(aid)
|
||||
if not pActor then
|
||||
print("[AfterCheckYYHall][" .. aid .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[AfterCheckYYHall][" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[AfterCheckYYHall]result:"..result)
|
||||
|
||||
if result == 0 then
|
||||
local data = string.match(content,"\"data\":(%d+)")
|
||||
local status = string.match(content,"\"status\":(%d+)")
|
||||
if status == HttpStatus.Success then
|
||||
SendData(pActor,tonumber(data))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- CPP回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function OnYYHallLogin(pActor)
|
||||
local account = Actor.getAccount(pActor)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local now = os.time()
|
||||
local gameflag = System.getGameFlag() or "DDCQ"
|
||||
local key = System.getYYKey()
|
||||
local sign = System.MD5(gameflag,account,"1001",now,key)
|
||||
local req = Api..'?account='..account..'&game='..gameflag..'&taskId=1001&time='..now.."&sign="..string.upper(sign)
|
||||
print("Require YYHallLogin[" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
AfterCheckYYHall,
|
||||
{aid}
|
||||
)
|
||||
|
||||
-- 当天初始化
|
||||
local data = getData(pActor)
|
||||
if data.lastLoginTime == nil then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginDay = 1
|
||||
--print("第一天")
|
||||
else
|
||||
if not System.isSameDay(data.lastLoginTime, System.getCurrMiniTime()) then
|
||||
--print("跨一天")
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginDay = data.loginDay + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function OnReqYYHallFreshManGift(pActor, packet)
|
||||
local idx = DataPack.readByte(packet)
|
||||
local awards = ActivityConfig.freshmanGift
|
||||
local data = getData(pActor)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
if data.lastLoginTime then
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
if (data.freshmanGift == nil) or (data.freshmanGift == 0) then
|
||||
data.freshmanGift = 1
|
||||
SendMail(aid, ActivityConfig.fgTitle or "YY大厅新手礼包", ActivityConfig.fgContent or "恭喜你领取了YY大厅新手礼包!", ActivityConfig.freshmanGift)
|
||||
SendData(pActor,data.yydata)
|
||||
end
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
end
|
||||
end
|
||||
|
||||
function OnReqYYHallLoginGift(pActor, packet)
|
||||
local idx = DataPack.readByte(packet)
|
||||
if (idx > 30) or (idx == 0) then
|
||||
return
|
||||
end
|
||||
if idx > #ActivityConfig.loginGift then
|
||||
return
|
||||
end
|
||||
local awards = ActivityConfig.loginGift[idx]
|
||||
idx = idx - 1
|
||||
local data = getData(pActor)
|
||||
if awards and data.lastLoginTime then
|
||||
-- 领取检查
|
||||
if not data.loginGift then
|
||||
data.loginGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.loginGift, idx)
|
||||
--print("loginGift="..data.loginGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
-- 天数检查
|
||||
if data.loginDay and (data.loginDay > idx )then
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
data.loginGift = System.setIntBit(data.loginGift, idx, true)
|
||||
local mailcontent = string.format( ActivityConfig.logContent or "你已通过YY大厅登录超过了%d天,领取了YY大厅登录礼包!" , data.loginDay)
|
||||
SendMail(aid, ActivityConfig.logTitle or "YY大厅登录礼包", mailcontent, awards)
|
||||
SendData(pActor,data.yydata)
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function OnReqYYHallLevelGift(pActor, packet)
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #ActivityConfig.levelGift then
|
||||
return
|
||||
end
|
||||
local conf = ActivityConfig.levelGift[idx]
|
||||
local awards = conf.awards
|
||||
idx = idx - 1
|
||||
local data = getData(pActor)
|
||||
if conf and data.lastLoginTime then
|
||||
-- 领取检查
|
||||
if not data.levelGift then
|
||||
data.levelGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.levelGift, idx)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
-- 等级检查
|
||||
local lvl = Actor.getIntProperty(pActor,PROP_CREATURE_LEVEL)
|
||||
if lvl >= conf.lvl then
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
data.levelGift = System.setIntBit(data.levelGift, idx, true)
|
||||
local mailcontent = string.format( ActivityConfig.lvgContent or "你的等级已达到了%d级,领取了YY大厅等级礼包!" , conf.lvl)
|
||||
SendMail(aid, ActivityConfig.lvgTitle or "YY大厅等级礼包", mailcontent, awards)
|
||||
SendData(pActor,data.yydata)
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
YYIdentity = {[1]="平民",[2]="贵族",[3]="王室"}
|
||||
|
||||
function OnReqYYHallNobleGift(pActor, packet)
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #ActivityConfig.nobleGift then
|
||||
return
|
||||
end
|
||||
if idx > #YYIdentity then
|
||||
return
|
||||
end
|
||||
local awards = ActivityConfig.nobleGift[idx]
|
||||
idx = idx - 1
|
||||
local data = getData(pActor)
|
||||
if awards and data.lastLoginTime then
|
||||
-- 领取检查
|
||||
if not data.nobleGift then
|
||||
data.nobleGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.nobleGift, idx)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
-- 身份检查
|
||||
if data.yydata > idx then
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
data.nobleGift = System.setIntBit(data.nobleGift, idx, true)
|
||||
local mailcontent = string.format( ActivityConfig.ngContent or "你的身份为%s,领取了YY大厅贵族礼包!" , YYIdentity[idx+1])
|
||||
SendMail(aid, ActivityConfig.ngTitle or "YY大厅等级礼包", mailcontent, awards)
|
||||
SendData(pActor,data.yydata)
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqYYHallFreshManGift, OnReqYYHallFreshManGift)
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqYYHallLoginGift, OnReqYYHallLoginGift)
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqYYHallLevelGift, OnReqYYHallLevelGift)
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqYYHallNobleGift, OnReqYYHallNobleGift)
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getData(pActor)
|
||||
if data.lastLoginTime then
|
||||
if not System.isSameDay(data.lastLoginTime, System.getCurrMiniTime()) then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginDay = data.loginDay + 1
|
||||
end
|
||||
|
||||
SendData(pActor,data.yydata)
|
||||
end
|
||||
end
|
||||
|
||||
function OnUserLogout(pActor,actorId)
|
||||
if pActor ==nil then return end
|
||||
local data = getData(pActor)
|
||||
data.yydata =nil
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10011.lua")
|
||||
ActorEventDispatcher.Reg(aeUserLogout, OnUserLogout, "ActivityType10011.lua")
|
||||
@@ -0,0 +1,384 @@
|
||||
module("ActivityType10012", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动(玩法),YY会员
|
||||
|
||||
个人数据:YYVIPeople
|
||||
{
|
||||
isVip = true/false, 是否为YY会员
|
||||
grade = 0, vip等级
|
||||
endTime = 0, vip过期时间戳
|
||||
lastTime = 0 上一次初始化的时间戳
|
||||
newServerGift = 00000000 32位 是否领取第n个新服豪礼
|
||||
dailyGift = 00000000 32位 是否领取第n个每日礼包
|
||||
weeklyGift = 00000000 32位 是否领取第n个每周礼包
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10012
|
||||
--对应的活动配置
|
||||
ActivityConfig = YYVIPConfig
|
||||
PlatformConfig = YYVIPConfig
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
local HttpStatus = {
|
||||
Success = "200", -- 成功
|
||||
ArgError = "302", -- 参数错误
|
||||
SignError = "304", -- 签名错误
|
||||
LinkLost = "305", -- 链接失效
|
||||
IpLimit = "306", -- IP受限
|
||||
AccountNotExits = "600", -- 账号不存在
|
||||
UnKnownedError = "299" -- 未知错误
|
||||
}
|
||||
|
||||
-- 服务接口
|
||||
Host = ActivityConfig.host or "proxy.udblogin.game.yy.com"
|
||||
Port = ActivityConfig.port or "80"
|
||||
Api = ActivityConfig.api or "/query/yyVipInfo.do"
|
||||
|
||||
function getData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.YYVIPeople== nil then
|
||||
var.YYVIPeople = {}
|
||||
end
|
||||
return var.YYVIPeople
|
||||
end
|
||||
|
||||
function SendData(pActor)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [YYVIP] SendData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [YYVIP] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local npack = DataPack.allocPacket(pActor, enActivityID, sYYVipData)
|
||||
if npack then
|
||||
local data = getData(pActor)
|
||||
DataPack.writeByte(npack, (data.isVip or 0)) -- 是否为VIP 0否1是
|
||||
DataPack.writeByte(npack, (data.grade or 1)) -- vip等级
|
||||
DataPack.writeInt64(npack, (data.endTime or 0)) -- 过期时间戳
|
||||
DataPack.writeUInt(npack, (data.newServerGift or 0))-- 32位 是否领取第n个新服豪礼
|
||||
DataPack.writeUInt(npack, (data.dailyGift or 0)) -- 32位 是否领取第n个每日礼包
|
||||
DataPack.writeUInt(npack, (data.weeklyGift or 0)) -- 32位 是否领取第n个每周礼包
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
function AfterCheckYYLogin(paramPack,content,result)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [YYVIP] SendData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [YYVIP] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local aid = paramPack[1]
|
||||
local pActor = Actor.getActorById(aid)
|
||||
if not pActor then
|
||||
print("[AfterCheckYYLogin][" .. aid .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[AfterCheckYYLogin][" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[AfterCheckYYLogin]result:"..result)
|
||||
|
||||
if result == 0 then
|
||||
local status = string.match(content,"\"status\":(%d+)")
|
||||
if (status == HttpStatus.Success) then
|
||||
local isvip = string.match(content,"\"isVip\":(%a+)")
|
||||
local grade = string.match(content,"\"grade\":(%d+)")
|
||||
local endTime = string.match(content,"\"endTime\":(%a+)")
|
||||
if isvip == "true" then
|
||||
isvip = 1
|
||||
else
|
||||
isvip = 0
|
||||
end
|
||||
grade = tonumber(grade)
|
||||
if endTime ~= "null" then
|
||||
endTime = tonumber(endTime)
|
||||
else
|
||||
endTime = 0
|
||||
end
|
||||
local data = getData(pActor)
|
||||
data.isVip = isvip
|
||||
data.grade = grade
|
||||
data.endTime = endTime
|
||||
SendData(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- CPP回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function OnYYLogin(pActor)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [YYVIP] SendData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [YYVIP] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local account = Actor.getAccount(pActor)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local now = os.time()
|
||||
local gameflag = System.getGameFlag() or "DDCQ"
|
||||
local key = System.getYYKey()
|
||||
local sign = System.MD5(gameflag,account,now,key)
|
||||
local req = Api..'?game='..gameflag..'&account='..account..'&ts='..now.."&sign="..string.upper(sign)
|
||||
print("Require OnYYLogin[" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
AfterCheckYYLogin,
|
||||
{aid}
|
||||
)
|
||||
|
||||
-- 当天初始化
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getData(pActor)
|
||||
if data.lastTime == nil then
|
||||
data.lastTime = currMiniTime
|
||||
data.newServerGift = 0
|
||||
data.dailyGift = 0
|
||||
data.weeklyGift = 0
|
||||
--print("第一天")
|
||||
else
|
||||
if not System.isSameDay(data.lastTime, currMiniTime) then
|
||||
--print("跨一天")
|
||||
if System.isSameWeek(data.lastTime, currMiniTime) then
|
||||
--print("跨一周")
|
||||
data.weeklyGift = 0
|
||||
end
|
||||
data.lastTime = currMiniTime
|
||||
data.dailyGift = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function OnReqYYVIPNewSrvGift(pActor, packet)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [YYVIP] SendData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [YYVIP] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > (2 * #ActivityConfig.newServerGift) then
|
||||
return
|
||||
end
|
||||
local confid = math.ceil(idx/2)
|
||||
local conf = ActivityConfig.newServerGift[confid]
|
||||
|
||||
local istitle = (idx%2 == 1)
|
||||
|
||||
idx = idx - 1
|
||||
local data = getData(pActor)
|
||||
|
||||
if conf and data.lastTime then
|
||||
|
||||
-- 领取检查
|
||||
if not data.newServerGift then
|
||||
data.newServerGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.newServerGift, idx)
|
||||
print("newServerGift="..data.newServerGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
-- 等级检查
|
||||
if data.grade < conf.viplvl then
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
data.newServerGift = System.setIntBit(data.newServerGift, idx, true)
|
||||
SendData(pActor)
|
||||
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
if istitle then
|
||||
local awards = {conf.title}
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity10012, "YYVIP NewSrvGift")
|
||||
else
|
||||
--获取
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local awards = {conf.gift}
|
||||
SendMail(aid, ActivityConfig.nsTitle, ActivityConfig.nsContent, awards)
|
||||
end
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
end
|
||||
end
|
||||
|
||||
function OnReqYYVIPDailyGift(pActor, packet)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [YYVIP] SendData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [YYVIP] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #ActivityConfig.dailyGift then
|
||||
return
|
||||
end
|
||||
local conf = ActivityConfig.dailyGift[idx]
|
||||
idx = idx - 1
|
||||
local data = getData(pActor)
|
||||
if conf and data.lastTime then
|
||||
-- 领取检查
|
||||
if not data.dailyGift then
|
||||
data.dailyGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.dailyGift, idx)
|
||||
--print("dailyGift="..data.dailyGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
-- 等级检查
|
||||
if data.grade < conf.viplvl then
|
||||
return
|
||||
end
|
||||
|
||||
-- 元宝检查
|
||||
local consumes = {{type=4,id=4,count=conf.yb}}
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, consumes, tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--消耗
|
||||
CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity10012, "YYVIP dailyGift | " .. ActivityType)
|
||||
|
||||
-- 设置标志
|
||||
data.dailyGift = System.setIntBit(data.dailyGift, idx, true)
|
||||
SendData(pActor)
|
||||
|
||||
--获取
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local awards = {conf.item}
|
||||
SendMail(aid, ActivityConfig.dgTitle, ActivityConfig.dgContent, awards)
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
end
|
||||
end
|
||||
|
||||
function OnReqYYVIPWeeklyGift(pActor, packet)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [YYVIP] SendData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [YYVIP] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #ActivityConfig.weeklyGift then
|
||||
return
|
||||
end
|
||||
local conf = ActivityConfig.weeklyGift[idx]
|
||||
idx = idx - 1
|
||||
local data = getData(pActor)
|
||||
if conf and data.lastTime then
|
||||
-- 领取检查
|
||||
if not data.weeklyGift then
|
||||
data.weeklyGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.weeklyGift, idx)
|
||||
--print("weeklyGift="..data.weeklyGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
-- 等级检查
|
||||
if data.grade < conf.viplvl then
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- 元宝检查
|
||||
local consumes = {{type=4,id=4,count=conf.yb}}
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, consumes, tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--消耗
|
||||
CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity10012, "YYVIP WeeklyGift | " .. ActivityType)
|
||||
|
||||
-- 设置标志
|
||||
data.weeklyGift = System.setIntBit(data.weeklyGift, idx, true)
|
||||
SendData(pActor)
|
||||
|
||||
--获取
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity10012, "YYVIP WeeklyGift | " .. ActivityType)
|
||||
|
||||
--获取
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local awards = {conf.gift}
|
||||
SendMail(aid, ActivityConfig.wgTitle, ActivityConfig.wgContent, awards)
|
||||
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqYYVIPNewSrvGift, OnReqYYVIPNewSrvGift)
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqYYVIPDailyGift, OnReqYYVIPDailyGift)
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqYYVIPWeeklyGift, OnReqYYVIPWeeklyGift)
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [YYVIP] SendData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [YYVIP] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getData(pActor)
|
||||
if data.lastTime then
|
||||
if not System.isSameDay(data.lastTime, currMiniTime) then
|
||||
--print("跨一天")
|
||||
if not System.isSameWeek(data.lastTime, currMiniTime) then
|
||||
--print("跨一周")
|
||||
data.weeklyGift = 0
|
||||
end
|
||||
data.lastTime = currMiniTime
|
||||
data.dailyGift = 0
|
||||
end
|
||||
SendData(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10012.lua")
|
||||
@@ -0,0 +1,289 @@
|
||||
module("ActivityType10013", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动(玩法),超玩会员
|
||||
|
||||
个人数据:SupperVIPeople
|
||||
{
|
||||
isVip = true/false 是否是会员
|
||||
lastTime = 0 上一次初始化的时间戳
|
||||
v1_v3Gift = 00000000 32位 是否领取第n个v1-v3礼包
|
||||
dailyGift = 00000000 32位 是否领取第n个每日礼包
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10013
|
||||
--对应的活动配置
|
||||
ActivityConfig = GameVIPConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
local HttpStatus =
|
||||
{
|
||||
Success = "200", -- 成功
|
||||
ArgError = "302", -- 参数错误
|
||||
SignError = "304", -- 签名错误
|
||||
LinkLost = "305", -- 链接失效
|
||||
IpLimit = "306", -- IP受限
|
||||
AccountNotExits = "600", -- 账号不存在
|
||||
UnKnownedError = "299", -- 未知错误
|
||||
}
|
||||
|
||||
-- 服务接口
|
||||
Host = ActivityConfig.host or "proxy.udblogin.game.yy.com"
|
||||
Port = ActivityConfig.port or "80"
|
||||
Api = ActivityConfig.api or "/query/cwVipInfo.do"
|
||||
|
||||
function getData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.SupperVIPeople== nil then
|
||||
var.SupperVIPeople = {}
|
||||
end
|
||||
return var.SupperVIPeople
|
||||
end
|
||||
|
||||
function SendData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enActivityID, sSupperVipData)
|
||||
if npack then
|
||||
local data = getData(pActor)
|
||||
DataPack.writeUInt(npack, (data.v1_v3Gift or 0))
|
||||
--print("v1-v3 giftbit : "..(data.v1_v3Gift or 0 ) )
|
||||
DataPack.writeUInt(npack, (data.dailyGift or 0))
|
||||
--print("daily giftbit : "..(data.dailyGift or 0))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
function AfterCheckSupperLogin(paramPack,content,result)
|
||||
local aid = paramPack[1]
|
||||
local pActor = Actor.getActorById(aid)
|
||||
if not pActor then
|
||||
--print("[AfterCheckSupperLogin][" .. aid .. "] 已离线")
|
||||
return
|
||||
end
|
||||
--print("[AfterCheckSupperLogin][" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
--print("[AfterCheckSupperLogin]result:"..result)
|
||||
|
||||
if Actor.getEntityType(pActor) ~= enActor then
|
||||
return
|
||||
end
|
||||
|
||||
--先清buff
|
||||
for i = 1 , #ActivityConfig.GameVIPbuff do
|
||||
Actor.delBuffById(pActor, (ActivityConfig.GameVIPbuff[i].buffid or 0))
|
||||
end
|
||||
|
||||
local data = getData(pActor)
|
||||
|
||||
if result == 0 then
|
||||
local status = string.match(content,"\"status\":(%d+)")
|
||||
if status == HttpStatus.Success then
|
||||
local vipLevel = string.match(content,"\"vipLevel\":(%d+)")
|
||||
vipLevel = tonumber(vipLevel)
|
||||
Actor.setUIntProperty(pActor,PROP_ACTOR_SUPPER_PLAY_LVL,vipLevel)
|
||||
Actor.updateActorEntityProp(pActor)
|
||||
--local grade = string.match(content,"\"grade\":(%d+)")
|
||||
--local endTime = string.match(content,"\"endTime\":(%a+)")
|
||||
data.isVip = 1
|
||||
|
||||
--加超玩特权buff
|
||||
if(vipLevel >= 9) then
|
||||
Actor.addBuffById(pActor, (ActivityConfig.GameVIPbuff[3].buffid or 0))
|
||||
elseif (vipLevel >= 6) then
|
||||
Actor.addBuffById(pActor, (ActivityConfig.GameVIPbuff[2].buffid or 0))
|
||||
elseif (vipLevel >= 2) then
|
||||
Actor.addBuffById(pActor, (ActivityConfig.GameVIPbuff[1].buffid or 0))
|
||||
end
|
||||
|
||||
else
|
||||
data.isVip = 0
|
||||
Actor.setUIntProperty(pActor,PROP_ACTOR_SUPPER_PLAY_LVL,0)
|
||||
Actor.updateActorEntityProp(pActor)
|
||||
end
|
||||
|
||||
end
|
||||
SendData(pActor)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- CPP回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function OnSupperLogin(pActor)
|
||||
local account = Actor.getAccount(pActor)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local now_milli = os.time()*1000
|
||||
local gameflag = System.getGameFlag() or "DDCQ"
|
||||
local key = System.getYYKey()
|
||||
local sign = System.MD5(gameflag,account,now_milli,key)
|
||||
local req = Api..'?game='..gameflag..'&account='..account..'&ts='..now_milli.."&sign="..string.upper(sign)
|
||||
--print("Require OnSupperLogin[" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
AfterCheckSupperLogin,
|
||||
{aid}
|
||||
)
|
||||
|
||||
-- 当天初始化
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getData(pActor)
|
||||
if data.lastTime == nil then
|
||||
data.lastTime = currMiniTime
|
||||
--print("第一天")
|
||||
else
|
||||
if not System.isSameDay(data.lastTime, currMiniTime) then
|
||||
data.lastTime = currMiniTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--v1-v3等级礼包
|
||||
function OnReqSuperVipV1_V3(pActor, packet)
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #ActivityConfig.vipGift or idx <= 0 then
|
||||
return
|
||||
end
|
||||
local conf = ActivityConfig.vipGift[idx]
|
||||
local myLevel = Actor.getIntProperty(pActor, PROP_ACTOR_SUPPER_PLAY_LVL)
|
||||
|
||||
--一级玩家增加领取范围
|
||||
if myLevel ==1 then
|
||||
myLevel = 2
|
||||
end
|
||||
|
||||
local data = getData(pActor)
|
||||
|
||||
if data.isVip == 0 then
|
||||
return
|
||||
end
|
||||
if conf and data.lastTime then
|
||||
-- 领取检查
|
||||
if not data.v1_v3Gift then
|
||||
data.v1_v3Gift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.v1_v3Gift, idx-1)
|
||||
if flag == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:奖励已领取|", tstUI)
|
||||
return
|
||||
end
|
||||
-- 等级检查
|
||||
if myLevel < idx then
|
||||
return
|
||||
end
|
||||
|
||||
--消耗
|
||||
--CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity10013, "super Player v1-v3")
|
||||
|
||||
--记录日志
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
|
||||
--获取
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local awards = conf
|
||||
SendMail(aid, ActivityConfig.VIPTitle, ActivityConfig.VIPContent, awards)
|
||||
|
||||
--记录日志
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
-- 设置标志
|
||||
data.v1_v3Gift = System.setIntBit(data.v1_v3Gift, idx-1, true)
|
||||
SendData(pActor)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 每日礼包,初中高级
|
||||
function OnReqSuperVipDaily(pActor, packet)
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #ActivityConfig.dailyGift or idx <= 0 then
|
||||
return
|
||||
end
|
||||
local conf = ActivityConfig.dailyGift[idx]
|
||||
|
||||
local myLevel = Actor.getIntProperty(pActor, PROP_ACTOR_SUPPER_PLAY_LVL)
|
||||
|
||||
local data = getData(pActor)
|
||||
|
||||
if data.isVip == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if conf and data.lastTime then
|
||||
-- 领取检查
|
||||
if not data.dailyGift then
|
||||
data.dailyGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.dailyGift, idx-1)
|
||||
if flag == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:奖励已领取|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 等级检查
|
||||
if myLevel < ActivityConfig.vipMap[idx] then
|
||||
return
|
||||
end
|
||||
|
||||
--记录日志
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
|
||||
--获取
|
||||
local aid = Actor.getActorId(pActor)
|
||||
local awards = conf
|
||||
SendMail(aid, ActivityConfig.VIPDailyTitle, ActivityConfig.VIPDailyContent, awards)
|
||||
|
||||
--记录日志
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
|
||||
-- 设置标志
|
||||
data.dailyGift = System.setIntBit(data.dailyGift, idx-1, true)
|
||||
|
||||
SendData(pActor)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqSuperVipV1_V3, OnReqSuperVipV1_V3)
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqSuperVipDaily, OnReqSuperVipDaily)
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = getData(pActor)
|
||||
if data.lastTime then
|
||||
if not System.isSameDay(data.lastTime, currMiniTime) then
|
||||
--print("跨一天")
|
||||
data.lastTime = currMiniTime
|
||||
data.dailyGift = 0
|
||||
end
|
||||
SendData(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
function OnUserLogout(pActor,actorId)
|
||||
--local pActor = Actor.getActorById(actorId)
|
||||
|
||||
--离线就删除buff
|
||||
--没有对会员时间处理,上线是超玩就加buff,离线就删buff
|
||||
for i = 1 , #ActivityConfig.GameVIPbuff do
|
||||
Actor.delBuffById(pActor, (ActivityConfig.GameVIPbuff[i].buffid or 0))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10013.lua")
|
||||
ActorEventDispatcher.Reg(aeUserLogout, OnUserLogout, "ActivityType10013.lua")
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
module("ActivityType10014", package.seeall)
|
||||
--[[
|
||||
|
||||
微信礼包
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10014
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10014Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
-- local Cfg = ActivityConfig[atvId];
|
||||
-- if Cfg == nil then
|
||||
-- return;
|
||||
-- end
|
||||
-- local data = getActorCdkData(pActor)
|
||||
-- if data then
|
||||
-- if data.codeTypeTimes then
|
||||
-- if data.codeTypeTimes[Cfg.cdktype] then
|
||||
-- Actor.closeOneActivity(pActor,atvId)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
-- local Cfg = ActivityConfig[atvId];
|
||||
-- if Cfg == nil then
|
||||
-- return;
|
||||
-- end
|
||||
-- local data =getActorCdkData(pActor)
|
||||
-- if data then
|
||||
-- if data.codeTypeTimes then
|
||||
-- if data.codeTypeTimes[Cfg.cdktype] then
|
||||
-- Actor.closeOneActivity(pActor,atvId)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
-- local Cfg = ActivityConfig[atvId];
|
||||
-- if Cfg == nil then
|
||||
-- return;
|
||||
-- end
|
||||
-- local data = getActorCdkData(pActor)
|
||||
-- if data then
|
||||
-- if data.codeTypeTimes then
|
||||
-- if data.codeTypeTimes[Cfg.cdktype] then
|
||||
-- Actor.closeOneActivity(pActor,atvId)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnUpdate(atvId, curTime, pActor)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg == nil then
|
||||
return;
|
||||
end
|
||||
local data = getActorCdkData(pActor)
|
||||
if data then
|
||||
if data.codeTypeTimes then
|
||||
if data.codeTypeTimes[Cfg.cdktype] then
|
||||
Actor.closeOneActivity(pActor,atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10014.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10014.lua")
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10014.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType10014.lua")
|
||||
@@ -0,0 +1,286 @@
|
||||
module("ActivityType10015", package.seeall)
|
||||
|
||||
--[[
|
||||
全局个人活动
|
||||
礼包活动,每周固定时间
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
buy {index:num } --已购买的次数
|
||||
EndTime --活动结束时间,在GPStart里维护
|
||||
dailyBuy --每日
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10015
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10015Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
--玩家请求购买礼包
|
||||
function reqPurchaseGiftBox(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
-- print("------------ActivityType : "..ActivityType)
|
||||
-- print("------------atvId : "..atvId)
|
||||
-- print("------------indexId : "..indexId)
|
||||
-- print("------------actorName : "..Actor.getName(pActor))
|
||||
|
||||
|
||||
if actorData.buy == nil then
|
||||
actorData.buy = {}
|
||||
end
|
||||
if actorData.dailyBuy == nil then
|
||||
actorData.dailyBuy = {}
|
||||
end
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if Cfg == nil then
|
||||
return;
|
||||
end
|
||||
local ThisCfg = Cfg[indexId]
|
||||
if ThisCfg then
|
||||
|
||||
--提示没有购买次数
|
||||
if ThisCfg.BuyLimit then
|
||||
local leftNum = ThisCfg.BuyLimit - (actorData.buy[indexId] or 0)
|
||||
if leftNum <= 0 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已无购买次数|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
if ThisCfg.Dailylimit then
|
||||
local leftNum = ThisCfg.Dailylimit - (actorData.dailyBuy[indexId] or 0)
|
||||
if leftNum <= 0 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已无购买次数|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检查消耗是否满足条件
|
||||
if ThisCfg.price then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, ThisCfg.price ,tstUI) ~= true then
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检查背包
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--扣除消耗
|
||||
if CommonFunc.Consumes.Remove(pActor, ThisCfg.price, GameLog.Log_Activity10015, "每周礼包活动|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
--print("-----------11111")
|
||||
--发放奖励
|
||||
if ThisCfg.award then
|
||||
local decstr = "每周礼包活动";
|
||||
if ActivitiesConf[atvId] and ActivitiesConf[atvId].ActivityName then
|
||||
decstr = ActivitiesConf[atvId].ActivityName
|
||||
end
|
||||
--print("-----------2222")
|
||||
CommonFunc.Awards.Give(pActor, ThisCfg.award, GameLog.Log_Activity10015, decstr)
|
||||
end
|
||||
--print("-----------3333")
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmConsiBuySuccAddToBag, tstUI)
|
||||
if ThisCfg.BuyLimit then
|
||||
actorData.buy[indexId] = (actorData.buy[indexId] or 0) + 1;
|
||||
end
|
||||
if ThisCfg.Dailylimit then
|
||||
actorData.dailyBuy[indexId] = (actorData.dailyBuy[indexId] or 0) + 1;
|
||||
end
|
||||
if ThisCfg.tips then
|
||||
local name = Actor.getName(pActor);
|
||||
local str = string.format(ThisCfg.tips,name)
|
||||
System.broadcastTipmsgLimitLev(str, tstKillDrop)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 全局个人开始
|
||||
function OnGPStart(atvId, pActor)
|
||||
--print("-------测试type类型 : 全局个人OnGPStart ---")
|
||||
--初始化活动个人数据
|
||||
|
||||
--重置数据,重新开始
|
||||
--actorData.timesCount = 0
|
||||
|
||||
end
|
||||
|
||||
--全局个人结束
|
||||
function OnGPEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId);
|
||||
--print("-------测试type类型 : 全局个人OnGPEnd ---")
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
|
||||
if outPack then
|
||||
local len = 0
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if Cfg then
|
||||
len = #Cfg;
|
||||
end
|
||||
DataPack.writeByte(outPack, (len or 0));
|
||||
local openDay = System.getDaysSinceOpenServer();
|
||||
if len > 0 then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end;
|
||||
|
||||
if actorData.buy == nil then
|
||||
actorData.buy = { }
|
||||
end
|
||||
if actorData.dailyBuy == nil then
|
||||
actorData.dailyBuy = {}
|
||||
end
|
||||
for _, cfg in pairs(Cfg) do
|
||||
DataPack.writeByte(outPack, (cfg.GiftBoxNum or 0))
|
||||
local leftNum = -1;
|
||||
if cfg.BuyLimit then
|
||||
leftNum = cfg.BuyLimit - (actorData.buy[cfg.GiftBoxNum] or 0)
|
||||
if leftNum < 0 then
|
||||
leftNum = 0;
|
||||
end
|
||||
end
|
||||
if cfg.Dailylimit then
|
||||
leftNum = cfg.Dailylimit - (actorData.dailyBuy[cfg.GiftBoxNum] or 0)
|
||||
if leftNum < 0 then
|
||||
leftNum = 0;
|
||||
end
|
||||
end
|
||||
DataPack.writeShort(outPack, (leftNum or 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqPurchaseGiftbag then --请求购买每周礼包
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
reqPurchaseGiftBox(pActor, atvId , indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data == nil then
|
||||
data = {}
|
||||
end
|
||||
|
||||
if data.buy == nil then
|
||||
data.buy = { }
|
||||
end
|
||||
if data.dailyBuy == nil then
|
||||
data.dailyBuy = {}
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.redType then
|
||||
local leftNum = -1;
|
||||
if cfg.BuyLimit then
|
||||
leftNum = cfg.BuyLimit - (data.buy[cfg.GiftBoxNum] or 0)
|
||||
if leftNum < 0 then
|
||||
leftNum = 0;
|
||||
end
|
||||
end
|
||||
if cfg.Dailylimit then
|
||||
leftNum = cfg.Dailylimit - (data.dailyBuy[cfg.GiftBoxNum] or 0)
|
||||
if leftNum < 0 then
|
||||
leftNum = 0;
|
||||
end
|
||||
end
|
||||
-- print("leftNum.."..leftNum.."..times.."..(data.dailyBuy[cfg.GiftBoxNum] or 0))
|
||||
if leftNum ~= 0 then
|
||||
ret = System.setIntBit(ret, cfg.GiftBoxNum -1, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
--使用GPStart和GPEnd 这里需要在登陆时将结束时间传入,检查开始结束事件
|
||||
function OnLoginGame(atvId,pActor)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.EndTime == nil then
|
||||
actorData.EndTime = 0
|
||||
end
|
||||
System.CheckGPActivityStartEnd(pActor,atvId,actorData.EndTime)
|
||||
|
||||
end
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 10015] 礼包活动"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.EndTime = System.getActivityEndMiniSecond(atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10015.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGPStart, ActivityType, OnGPStart, "ActivityType10015.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGPEnd, ActivityType, OnGPEnd, "ActivityType10015.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType10015.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10015.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10015.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10015.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
print("[PActivity 10015] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then return end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
data.dailyBuy = nil
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10015.lua")
|
||||
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
module("ActivityType10016", package.seeall)
|
||||
|
||||
--[[
|
||||
YY4366大厅特权
|
||||
|
||||
个人数据:YYHallAtv
|
||||
{
|
||||
phoneGift = 0/1 是否领取手机礼包(0否,1是)
|
||||
idCardGift = 0/1 是否领取认证礼包(0否,1是)
|
||||
lastLoginTime = 0 上一次通过YY大厅登录的时间戳
|
||||
loginDay = 1 通过YY大厅登录的累计天数
|
||||
loginGift = 00000000 32位 是否领取某天的登录礼包
|
||||
loginTypeGift
|
||||
loginType;//登录问题
|
||||
}
|
||||
]]--
|
||||
PlatformConfig = Platform4366Config
|
||||
LoginConfig = Login4366Config
|
||||
local PfId = System.getPfId()
|
||||
--对应的活动配置
|
||||
function get4366Data(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.YY4366HallAtv== nil then
|
||||
var.YY4366HallAtv = {}
|
||||
end
|
||||
return var.YY4366HallAtv
|
||||
end
|
||||
|
||||
function Send4366Data(pActor)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] Send4366Data ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sGet4366Infos)
|
||||
if npack then
|
||||
-- print("1111")
|
||||
local data = get4366Data(pActor)
|
||||
local cdkFlag = 0;
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[PlatformConfig.type] then
|
||||
cdkFlag = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
DataPack.writeByte(npack, (cdkFlag or 0)) --是否领取cdk礼包(0否,1是)
|
||||
DataPack.writeByte(npack, (data.phoneGift or 0)) --是否领取手机礼包(0否,1是)
|
||||
DataPack.writeByte(npack, (data.idCardGift or 0)) --是否领取认证礼包(0否,1是)
|
||||
DataPack.writeShort(npack, (data.loginDay or 1))--登录的天数
|
||||
DataPack.writeUInt(npack, (data.loginGift or 0))--礼包的领取标记 32 位
|
||||
DataPack.writeByte(npack, (data.loginTypeGift or 0)) --
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- CPP回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function OnYY4366HallLogin(pActor)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] OnYY4366HallLogin ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
-- 当天初始化
|
||||
local data = get4366Data(pActor)
|
||||
if data.lastLoginTime == nil then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginDay = 1
|
||||
--print("第一天")
|
||||
else
|
||||
if not System.isSameDay(data.lastLoginTime, System.getCurrMiniTime()) then
|
||||
--print("跨一天")
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginDay = data.loginDay + 1
|
||||
end
|
||||
end
|
||||
-- print("1111")
|
||||
Send4366Data(pActor);
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
-------------------------------------------------------------------
|
||||
--登录
|
||||
function OnReqYY4366HallLoginGift(pActor, packet)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] OnReqYY4366HallLoginGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local idx = DataPack.readByte(packet)
|
||||
if idx > #LoginConfig then
|
||||
return
|
||||
end
|
||||
local conf = PlatformConfig
|
||||
local awards = LoginConfig[idx].reward
|
||||
idx = idx - 1
|
||||
local data = get4366Data(pActor)
|
||||
if awards and data.lastLoginTime then
|
||||
-- 领取检查
|
||||
if not data.loginGift then
|
||||
data.loginGift = 0
|
||||
end
|
||||
local flag = System.getIntBit(data.loginGift, idx)
|
||||
--print("loginGift="..data.loginGift.." flag="..flag)
|
||||
if flag == 1 then
|
||||
return
|
||||
end
|
||||
if (data.loginDay == nil) or (data.loginDay < idx ) then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:登录天数不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
-- 天数检查
|
||||
if data.loginDay and (data.loginDay > idx )then
|
||||
data.loginGift = System.setIntBit(data.loginGift, idx, true)
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_4366Login)
|
||||
Send4366Data(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--认证
|
||||
function OnReqYY4366HallPhoneGift(pActor, packet)
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] OnReqYY4366HallPhoneGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local conf = PlatformConfig
|
||||
local awards = conf.reward2
|
||||
local data = get4366Data(pActor)
|
||||
if data.phoneGift then
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_4366Phone)
|
||||
data.phoneGift = 1;
|
||||
Send4366Data(pActor)
|
||||
end
|
||||
--认证
|
||||
function OnReqYY4366HallIdCardGift(pActor, packet)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] OnReqYY4366HallIdCardGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local conf = PlatformConfig
|
||||
local awards = conf.reward3
|
||||
local data = get4366Data(pActor)
|
||||
if data.idCardGift then
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_4366IdCard)
|
||||
data.idCardGift = 1;
|
||||
Send4366Data(pActor)
|
||||
end
|
||||
|
||||
function OnReqYY4366Login(pActor, packet)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] OnReqYY4366Login ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local idx = DataPack.readByte(packet)
|
||||
local data = get4366Data(pActor)
|
||||
data.loginType = idx;
|
||||
end
|
||||
|
||||
function OnReqYY4366LoginTypeGift(pActor, packet)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] OnReqYY4366LoginTypeGift ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
local conf = PlatformConfig
|
||||
local awards = conf.rewardClient
|
||||
local data = get4366Data(pActor)
|
||||
if data.loginTypeGift then
|
||||
return
|
||||
end
|
||||
if data.loginType == nil or data.loginType == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,conf.bagtype,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_4366ExeLogin)
|
||||
data.loginTypeGift = 1;
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
Send4366Data(pActor)
|
||||
Actor.setStaticCount(pActor, 10005, 1);
|
||||
|
||||
local strName = Actor.getName(pActor)
|
||||
if conf and conf.tips then
|
||||
local strTips = string.format(conf.tips,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips, tstKillDrop)
|
||||
end
|
||||
|
||||
if conf and conf.tips2 then
|
||||
local strTips2 = string.format(conf.tips2,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips2, tstChatSystem)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGet4366Infos, OnYY4366HallLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGet4366LoginAward, OnReqYY4366HallLoginGift)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGet4366PhoneAward, OnReqYY4366HallPhoneGift)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cGet4366IdCardAward, OnReqYY4366HallIdCardGift)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, c4366LoginType, OnReqYY4366Login)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, c4366LoginTypeGift, OnReqYY4366LoginTypeGift)
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
|
||||
if PfId ~= nil and PlatformConfig.SPID ~= nil then
|
||||
--print("[Tip] [Platform4366] OnNewDayArrive ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
|
||||
if tostring(PfId) ~= tostring(PlatformConfig.SPID) then
|
||||
|
||||
print("[Tip] [Platform4366] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
end
|
||||
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = get4366Data(pActor)
|
||||
if data.lastLoginTime then
|
||||
if not System.isSameDay(data.lastLoginTime, System.getCurrMiniTime()) then
|
||||
data.lastLoginTime = System.getCurrMiniTime()
|
||||
data.loginDay = data.loginDay + 1
|
||||
end
|
||||
|
||||
Send4366Data(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10016.lua")
|
||||
@@ -0,0 +1,207 @@
|
||||
module("ActivityType17", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动
|
||||
兑换活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
ActorDaily {} //每日限次
|
||||
Limits {} //总现在
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
GlobalDaily {} //每日限次
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10017
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10017Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--兑换
|
||||
function reqExChange(pActor, atvId , idx)
|
||||
local AtvCfg = ActivityConfig[atvId]
|
||||
if AtvCfg and AtvCfg[idx] then
|
||||
-- print("111idx..."..idx)
|
||||
local Cfg = AtvCfg[idx]
|
||||
local nOpenDay = System.getDaysSinceOpenServer();
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData.ActorDaily == nil then
|
||||
actorData.ActorDaily = {}
|
||||
end
|
||||
if actorData.Limits == nil then
|
||||
actorData.Limits = {}
|
||||
end
|
||||
if Cfg.table then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, Cfg.table ,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
-- print("222idx..."..idx)
|
||||
local usetimes = getUseTimes(pActor, atvId, Cfg);
|
||||
if Cfg.times and usetimes >= Cfg.times then
|
||||
Actor.sendTipmsgWithParams(pActor, tmActivity10017LimitTimes,tstUI);
|
||||
return
|
||||
end
|
||||
-- print("333idx..."..idx)
|
||||
if Cfg.mergelimit then
|
||||
if Actor.checkCommonLimit(pActor,(Cfg.mergelimit.level or 0), (Cfg.mergelimit.zsLevel or 0),
|
||||
(Cfg.mergelimit.vip or 0), (Cfg.mergelimit.office or 0)) == false then
|
||||
Actor.sendTipmsgWithParams(pActor, tmActivity10017Limit,tstUI);
|
||||
return;
|
||||
end
|
||||
if (Cfg.mergelimit.openday or 0) > nOpenDay then
|
||||
Actor.sendTipmsgWithParams(pActor, tmActivity10017Limit,tstUI);
|
||||
return;
|
||||
end
|
||||
|
||||
end
|
||||
-- print("4444idx..."..idx)
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,Cfg.bagtype,tmActivity10017LimitBags,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
--扣除消耗
|
||||
if Cfg.table then
|
||||
if CommonFunc.Consumes.Remove(pActor, Cfg.table, GameLog.Log_Activity10017, "兑换活动|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if Cfg.times then
|
||||
if Cfg.timesclear then
|
||||
actorData.ActorDaily[Cfg.subid] = (actorData.ActorDaily[Cfg.subid] or 0) + 1;
|
||||
else
|
||||
actorData.Limits[Cfg.subid] = (actorData.Limits[Cfg.subid] or 0) + 1;
|
||||
end
|
||||
end
|
||||
|
||||
CommonFunc.Awards.Give(pActor, Cfg.compose, GameLog.Log_Activity10017)
|
||||
Actor.sendTipmsgWithParams(pActor, tmActivity10017OperateSuccess,tstUI);
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
if Cfg.tips then
|
||||
local name = Actor.getName(pActor);
|
||||
local str = string.format(Cfg.tips,name)
|
||||
System.broadcastTipmsgLimitLev(str, tstKillDrop)
|
||||
end
|
||||
end
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
function getUseTimes(pActor,atvId, Cfg)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local usetimes = 0;
|
||||
if Cfg.times then
|
||||
if Cfg.timesclear then
|
||||
usetimes = actorData.ActorDaily[Cfg.subid] or 0;
|
||||
else
|
||||
usetimes = actorData.Limits[Cfg.subid] or 0;
|
||||
end
|
||||
end
|
||||
return usetimes;
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 17] 兑换活动"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 17]兑换活动id:"..atvId.."开始了!")
|
||||
ActivityDispatcher.ClearGlobalData(atvId);
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqExchange then --捐献
|
||||
local idx = DataPack.readByte(inPack)
|
||||
reqExChange(pActor, atvId , idx)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil then
|
||||
return;
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
local actorId = Actor.getIntProperty(pActor, PROP_ENTITY_ID )
|
||||
local donateValue = 0;
|
||||
if actorData.ActorDaily == nil then
|
||||
actorData.ActorDaily = {};
|
||||
end
|
||||
if actorData.Limits == nil then
|
||||
actorData.Limits = {}
|
||||
end
|
||||
if outPack then
|
||||
DataPack.writeInt(outPack, (#Cfg or 0))
|
||||
for _, cfg in ipairs(Cfg) do
|
||||
local lefttimes = -1;
|
||||
local usetimes = getUseTimes(pActor, atvId, cfg);
|
||||
lefttimes = cfg.times - (usetimes or 0)
|
||||
DataPack.writeByte(outPack, (cfg.subid or 0))
|
||||
DataPack.writeInt(outPack, (lefttimes or 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10017.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10017.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10017.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10017.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10017.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
print("[PActivity 17] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
-- 发送一个活动数据
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data == nil then
|
||||
data = {}
|
||||
end
|
||||
data.ActorDaily = {}
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10017.lua")
|
||||
@@ -0,0 +1,368 @@
|
||||
module("ActivityType10019", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
达标类
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
int nFlag // 标志
|
||||
int nValue //进度
|
||||
int endtime
|
||||
nNewFlag[]
|
||||
{
|
||||
nNewFlag
|
||||
}
|
||||
firstTips
|
||||
{}
|
||||
dealclear --标志
|
||||
gettimes --已经领取的数量
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10019
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10019Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--玩家请求领取奖励
|
||||
function reqGetAward(pActor, atvId , indexId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
return
|
||||
end
|
||||
local Cfg = getIndexCfg(atvId, indexId);
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local data = actorData[Cfg.subtype]
|
||||
if data == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件未达成|", tstUI)
|
||||
return
|
||||
end
|
||||
--提示已领取无法多次领取
|
||||
local res = GetBitData(atvId, pActor,indexId);
|
||||
-- if System.getIntBit((actorData.nFlag or 0),indexId) == 1 then
|
||||
if res == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取该奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if (data.nValue == nil) or (data.nValue < Cfg.value) then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件未达成|", tstUI)
|
||||
return
|
||||
end
|
||||
--检查格子够不够
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmGiftNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
if Cfg.GiftTable then
|
||||
local decstr = "个人达标类活动";
|
||||
if ActivitiesConf[atvId] and ActivitiesConf[atvId].ActivityName then
|
||||
decstr = ActivitiesConf[atvId].ActivityName
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, Cfg.GiftTable, GameLog.Log_Activity10019, decstr)
|
||||
end
|
||||
actorData.gettimes = (actorData.gettimes or 0) +1
|
||||
SetBitData(atvId, pActor, indexId);
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
if Cfg.tips then
|
||||
local name = Actor.getName(pActor);
|
||||
local str = string.format(Cfg.tips,name)
|
||||
System.broadcastTipmsgLimitLev(str, tstKillDrop)
|
||||
end
|
||||
Actor.SendJoinActivityLog(pActor,atvId,indexId);--领奖
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
actorData.dealclear = 1;
|
||||
print("atvId : ".." name : "..Actor.getName(pActor).." gettimes.."..actorData.gettimes)
|
||||
end
|
||||
|
||||
--
|
||||
function getIndexCfg(atvId, indexId)
|
||||
if ActivityConfig then
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.level == indexId then
|
||||
return cfg;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
|
||||
|
||||
function getTypeCfg(atvId, nType, nSubType)
|
||||
if ActivityConfig then
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.type == nType and cfg.subtype == nSubType then
|
||||
return cfg;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
print("[pActivitytype10019活动]---onstart atvId:"..atvId)
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqGetAchieveAward then --请求领取基金奖励
|
||||
local indexId = DataPack.readInt(inPack)
|
||||
reqGetAward(pActor, atvId , indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function GetBitData(atvId, pActor, level)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
local nFlag = 0;
|
||||
if level < 32 then
|
||||
nFlag = System.getIntBit((actorData.nFlag or 0), level)
|
||||
else
|
||||
if actorData.nNewFlag == nil then
|
||||
actorData.nNewFlag = {}
|
||||
end
|
||||
if actorData.nNewFlag[level] == nil then
|
||||
actorData.nNewFlag[level] = 0
|
||||
end
|
||||
|
||||
nFlag =actorData.nNewFlag[level] or 0;
|
||||
end
|
||||
return nFlag;
|
||||
end
|
||||
|
||||
function SetBitData(atvId, pActor, level)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
if level < 32 then
|
||||
actorData.nFlag = System.setIntBit(actorData.nFlag, level, 1) --将indexId位置置为1
|
||||
else
|
||||
if actorData.nNewFlag == nil then
|
||||
actorData.nNewFlag = {}
|
||||
end
|
||||
if actorData.nNewFlag[level] == nil then
|
||||
actorData.nNewFlag[level] = 0
|
||||
end
|
||||
actorData.nNewFlag[level] = 1;
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
if outPack == nil then
|
||||
return
|
||||
end
|
||||
DealClearAtvData(pActor, atvId);
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
local len = 0;
|
||||
|
||||
if Cfg then
|
||||
len = #Cfg;
|
||||
end
|
||||
|
||||
--长度
|
||||
-- print("len.."..(len or 0));
|
||||
DataPack.writeInt(outPack, (len or 0))
|
||||
local getNum = 0;
|
||||
if Cfg then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
for _, cfg in pairs(Cfg) do
|
||||
local value = 0;
|
||||
local data = actorData[cfg.subtype]
|
||||
if data then
|
||||
value = data.nValue or 0
|
||||
end
|
||||
local res =GetBitData(atvId, pActor, cfg.level);
|
||||
if res == 1 then getNum = getNum + 1 end
|
||||
if res == 1 then res = 2; end
|
||||
if res == 0 and value >= cfg.value then res = 1; end
|
||||
DataPack.writeByte(outPack, res)
|
||||
DataPack.writeInt(outPack, cfg.level)
|
||||
DataPack.writeInt(outPack, value)
|
||||
end
|
||||
if (actorData.gettimes or 0) < getNum then
|
||||
print("[pActivity10019] OnReqData() 活动id.."..atvId.." name : "..Actor.getName(pActor).." (actorData.gettimes or 0) : "..(actorData.gettimes or 0).."getNum : "..getNum)
|
||||
actorData.gettimes = getNum
|
||||
end
|
||||
end
|
||||
end
|
||||
--处理清空逻辑
|
||||
function DealClearAtvData(pActor, atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
local getNum = 0;
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
local res = GetBitData(atvId, pActor, cfg.level);
|
||||
if res == 1 then getNum = getNum + 1 end
|
||||
end
|
||||
end
|
||||
|
||||
if (actorData.gettimes or 0) < getNum then
|
||||
print("[pActivity10019] DealClearAtvData() 活动id.."..atvId.." name : "..Actor.getName(pActor).." (actorData.gettimes or 0) : "..(actorData.gettimes or 0).."getNum : "..getNum)
|
||||
actorData.gettimes = getNum
|
||||
end
|
||||
if (actorData.dealclear == nil and PActivitiesConf[atvId] and PActivitiesConf[atvId].isReset) and (actorData.gettimes and actorData.gettimes >= #Cfg) then
|
||||
print(Actor.getName(pActor).."..ClearActorData.."..atvId.."..gettimes.."..(actorData.gettimes or 0).."..#Cfg.."..(#Cfg or 0))
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId);
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
print("[pActivity10019] 活动id.."..atvId.."..结束")
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
end
|
||||
|
||||
--活动红点
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg) do
|
||||
local data = actorData[cfg.subtype]
|
||||
if data and data.nValue then
|
||||
if data.nValue >= cfg.value then
|
||||
local res =GetBitData(atvId, pActor, cfg.level);
|
||||
if res == 0 then ret = 1 break end;
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
function UpdateData(atvId, pActor, nType, nSubType,nValue)
|
||||
local Cfg = getTypeCfg(atvId, nType,nSubType);
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
if actorData[nSubType] == nil then
|
||||
actorData[nSubType] = {};
|
||||
end
|
||||
if actorData[nSubType].nValue == nil then
|
||||
actorData[nSubType].nValue = 0;
|
||||
end
|
||||
if Cfg.ValueType == 1 then
|
||||
actorData[nSubType].nValue = actorData[nSubType].nValue + nValue;
|
||||
else
|
||||
if actorData[nSubType].nValue < nValue then
|
||||
actorData[nSubType].nValue = nValue;
|
||||
end
|
||||
end
|
||||
if Cfg.firsttips then
|
||||
local res = GetBitData(atvId, pActor, Cfg.level);
|
||||
if actorData.firstTips == nil then
|
||||
actorData.firstTips = {}
|
||||
end
|
||||
if (actorData[nSubType].nValue >= Cfg.value) and (res == 0) then
|
||||
if actorData.firstTips[Cfg.level] == nil then
|
||||
local dropType = 1;
|
||||
if nType == nAchieveDropItem then
|
||||
dropType = 2;
|
||||
end
|
||||
local msg = "";
|
||||
msg = msg..dropType.."\\"..Cfg.firsttips
|
||||
-- print("msg.."..msg)
|
||||
Actor.sendTipmsg(pActor,msg, tstFirstKillDrop);
|
||||
actorData.firstTips[Cfg.level] = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
---更新活动数据
|
||||
function OnUpdateActivity(atvId, pActor, nType, nSubType, nValue)
|
||||
if nAchieveEquipment == nType then
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.type == nType and cfg.subtype <= nSubType then
|
||||
UpdateData(atvId, pActor, nType, cfg.subtype, nValue);
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
UpdateData(atvId, pActor, nType, nSubType,nValue);
|
||||
end
|
||||
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10019.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10019.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10019.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10019.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10019.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType10019.lua")
|
||||
|
||||
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
print("[PActivity 10019] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then return end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if (PActivitiesConf[atvId] and PActivitiesConf[atvId].isReset) and (data.gettimes and data.gettimes >= #Cfg) then
|
||||
print(Actor.getName(pActor).."..ClearActorData.."..atvId.."..gettimes.."..(data.gettimes or 0).."..#Cfg.."..(#Cfg or 0))
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId);
|
||||
end
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10019.lua")
|
||||
@@ -0,0 +1,206 @@
|
||||
module("ActivityType10020", package.seeall)
|
||||
--[[
|
||||
个人活动————开服特定寻宝
|
||||
抽奖活动!
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 已抽奖次数
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10020
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10020Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
--请求抽奖
|
||||
function reqXunBao(pActor, atvId, Conf)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
local atvStartTime = System.getRunningActivityStartTimeRelToday(atvId)
|
||||
local nowTime = System.getToday();
|
||||
local day = (nowTime -atvStartTime) / (24*3600) +1
|
||||
local Config = Conf[day]
|
||||
if not Config then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:数据有误|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--第N次免费抽奖
|
||||
local isFree = false
|
||||
local nTimes = 0
|
||||
if data.count == nil then
|
||||
nTimes = 1
|
||||
else
|
||||
nTimes = data.count + 1
|
||||
end
|
||||
for i, num in pairs(Config.freeNum) do
|
||||
if nTimes == num then
|
||||
isFree = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--消耗检查
|
||||
local consumes = Config.FirstCost
|
||||
if not isFree then
|
||||
if Config.FirstCost then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, Config.FirstCost) ~= true then
|
||||
consumes = nil
|
||||
end
|
||||
end
|
||||
if consumes == nil then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, Config.DrawPrice,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
consumes = Config.DrawPrice
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
else
|
||||
if data.count >= Config.Maxcount then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)--次数不足
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--背包检查,需要1格
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,12) ~= true then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:背包不足,装备、材料包裹必须剩余1格|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
local groupID = Config.NormalDropId
|
||||
for i , specialId in pairs(Config.SpecialCount) do
|
||||
if data.count == (specialId-1) then
|
||||
groupID = Config.SpecialDropId
|
||||
end
|
||||
end
|
||||
local strName = Actor.getName(pActor)
|
||||
--执行掉落组抽奖
|
||||
local RetTabel = Actor.ChouJiangByGroupId(pActor, groupID ,GameLog.Log_Activity10020,"抽奖活动| "..atvId )
|
||||
if RetTabel then
|
||||
for _, wupin in pairs(RetTabel) do
|
||||
if wupin ~=nil then
|
||||
if Config.tips and Config.tips[wupin.Id] then
|
||||
local strTips = string.format(Config.tips[wupin.Id].tips,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips, tstKillDrop)
|
||||
strTips = string.format(Config.tips[wupin.Id].tips_,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips, tstChatSystem)
|
||||
end
|
||||
end
|
||||
end
|
||||
--协议发送抽奖结果
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendChouJiangResult)
|
||||
if outPack then
|
||||
|
||||
DataPack.writeByte(outPack, #RetTabel)
|
||||
for _, wupin in pairs(RetTabel) do
|
||||
if wupin ~=nil then
|
||||
DataPack.writeUInt(outPack, wupin.Type)
|
||||
DataPack.writeUInt(outPack, wupin.Id)
|
||||
DataPack.writeUInt(outPack, wupin.Count)
|
||||
end
|
||||
end
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 扣取次数
|
||||
data.count = data.count + 1
|
||||
-- 扣取消耗
|
||||
if consumes and not isFree then
|
||||
CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity10020, "抽奖活动 | " .. atvId)
|
||||
end
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 10020] OnStart atvId:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
print("[GActivity 10020] OnEnd atvId:"..atvId)
|
||||
end
|
||||
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 10020] 寻宝活动"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count ==nil then data.count = 0 end
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count ==nil then data.count = 0 end
|
||||
DataPack.writeWord(outPack, (data.count or 0))
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
--print("[PActivity 10010] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqXunBao then -- 请求寻宝抽奖
|
||||
reqXunBao(pActor,atvId,Conf)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10020.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10020.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10020.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10020.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10020.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[PActivity 10010] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
--print("[PActivity 10010] "..Actor.getName(pActor).." 跨天活动次数归零,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
data.count = 0
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10020.lua")
|
||||
@@ -0,0 +1,287 @@
|
||||
module("ActivityType10021", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
二充
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
nSecondLeftTimes = 1111 当前档奖励位领取标志位
|
||||
nSecondGetFlag //领取标志
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10021
|
||||
--对应的活动配置
|
||||
ActivityConfig10021 = Activity10021Config
|
||||
if ActivityConfig10021 == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--玩家请求领取礼包
|
||||
function reqGetGiftBox(pActor, atvId , indexId,inerIndex)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
local Cfg = ActivityConfig10021[atvId]
|
||||
|
||||
if inerIndex ~= 1 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:无可领取的礼包|", tstUI)
|
||||
return;
|
||||
end
|
||||
|
||||
if actorData.nSecondLeftTimes == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:无可领取的礼包|", tstUI)
|
||||
return;
|
||||
end
|
||||
|
||||
if Cfg[1][1].Count == nil then
|
||||
--print("配置错误")
|
||||
end
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
if currentYuanBaoCount < Cfg[1][1].Count then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:未达到最低充值额度|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--print("indexId: "..indexId.." InnerIndex : "..inerIndex)
|
||||
if Cfg ~=nil and Cfg[indexId]~=nil and Cfg[indexId][inerIndex] ~=nil then
|
||||
--配置检查
|
||||
--if indexId ~= Cfg.GiftTable[indexId].value then return end
|
||||
if nil == Cfg[indexId][inerIndex].GiftTable then return end
|
||||
if indexId ~= Cfg[indexId][inerIndex].jobs then return end
|
||||
local Award = Cfg[indexId][inerIndex].GiftTable
|
||||
|
||||
|
||||
--提示没有购买次数
|
||||
if System.getIntBit((actorData.nSecondLeftTimes or 0),inerIndex-1) == 1 then
|
||||
--Actor.sendTipmsgWithId(pActor, tmNomoreYubao, tstUI)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- if actorData.GetTime == nil then
|
||||
-- actorData.nextIndex =1
|
||||
-- if inerIndex ~= 1 then
|
||||
-- if inerIndex == 2 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第二天才可领取|", tstUI)
|
||||
-- elseif inerIndex == 3 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第三天才可领取|", tstUI)
|
||||
-- end
|
||||
-- return
|
||||
-- end
|
||||
-- else
|
||||
-- if actorData.GetTime == System.getDaysSinceOpenServer() then
|
||||
-- --if actorData.nextIndex ~= inerIndex then
|
||||
-- if inerIndex == 2 and System.getIntBit((actorData.nSecondLeftTimes or 0),inerIndex-1) ==1 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第二天才可领取|", tstUI)
|
||||
-- elseif inerIndex == 3 and System.getIntBit((actorData.nSecondLeftTimes or 0),inerIndex-1) ==1 then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:充值后第三天才可领取|", tstUI)
|
||||
-- end
|
||||
|
||||
-- --end
|
||||
-- return
|
||||
-- end
|
||||
|
||||
-- end
|
||||
|
||||
--检查格子够不够
|
||||
-- if CommonFunc.Awards.CheckBagGridCount(pActor,Award) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmLeftBagNumNotEnough, tstUI)
|
||||
-- return
|
||||
-- end
|
||||
|
||||
if inerIndex > actorData.nSecondGetFlag then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:该礼包领取时间未到|", tstUI)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,17) ~= true then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:背包不足,药品、装备、材料包裹都必须剩余2格|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--if actorData.nSecondLeftTimes == 1 then
|
||||
--CommonFunc.GiveCommonAward(pActor, Award, GameLog.Log_Activity10021, "二充领取礼包|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, Award, GameLog.Log_Activity10021, "二充领取礼包|"..atvId)
|
||||
--print("req---> nSecondLeftTimes : "..(actorData.nSecondLeftTimes or 0 ).." GetTime : "..(actorData.GetTime or 0 ).." nextIndex : "..(actorData.nextIndex or 0 ))
|
||||
actorData.nSecondLeftTimes = System.setIntBit(actorData.nSecondLeftTimes, inerIndex-1, true)
|
||||
-- print("inerIndex..."..actorData.nSecondLeftTimes)
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
---策划fw
|
||||
local strName = Actor.getName(pActor)
|
||||
if inerIndex == 1 and Cfg[1][1].tips then
|
||||
local strTips = string.format(Cfg[1][1].tips,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips, tstKillDrop)
|
||||
end
|
||||
|
||||
if inerIndex == 1 and Cfg[1][1].tips2 then
|
||||
local strTips2 = string.format(Cfg[1][1].tips2,strName)
|
||||
System.broadcastTipmsgLimitLev(strTips2, tstChatSystem)
|
||||
end
|
||||
--end
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 10021] 二充"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
print("[activitytype 10021] ---onstart atvId:"..atvId)
|
||||
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.nSecondLeftTimes == nil then
|
||||
actorData.nSecondLeftTimes = 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
local InnerIndex = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqPurchaseGiftbag then --请求领取二充奖励
|
||||
local myjob = Actor.getIntProperty(pActor, PROP_ACTOR_VOCATION)
|
||||
--print("-------myjob:"..myjob)
|
||||
reqGetGiftBox(pActor, atvId , myjob,InnerIndex)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
--print("OnReqData 1111 atvId : ".. atvId.." name : "..Actor.getName(pActor))
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
--local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendActorDataTimes)
|
||||
|
||||
if actorData.nSecondLeftTimes == nil then
|
||||
actorData.nSecondLeftTimes = 0
|
||||
end
|
||||
|
||||
if outPack then
|
||||
--print("OnReqData 2222 atvId : ".. atvId.." name : "..Actor.getName(pActor).."getRechargeStatus() : "..Actor.getRechargeStatus(pActor))
|
||||
DataPack.writeUInt(outPack, Actor.getRechargeStatus(pActor) or 0)
|
||||
DataPack.writeByte(outPack, actorData.nSecondLeftTimes or 0)
|
||||
end
|
||||
--print("OnReqData 3333 atvId : ".. atvId.." name : "..Actor.getName(pActor))
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if actorData.nSecondGetFlag == nil then
|
||||
return ret
|
||||
end
|
||||
|
||||
if actorData.nSecondLeftTimes == nil then
|
||||
actorData.nSecondLeftTimes = 0
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig10021[atvId]
|
||||
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
if currentYuanBaoCount >= Cfg[1][1].Count then
|
||||
for i = 1, actorData.nSecondGetFlag,1 do
|
||||
if System.getIntBit((actorData.nSecondLeftTimes or 0),i-1) == 0 then
|
||||
ret = System.setIntBit(ret, i-1, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10021.lua")
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
---更新活动数据
|
||||
function OnUpdateActivity(atvId, pActor, nValue)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if actorData.nSecondLeftTimes == nil then
|
||||
actorData.nSecondLeftTimes = 0
|
||||
end
|
||||
if actorData.nSecondGetFlag then
|
||||
return;
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig10021[atvId]
|
||||
if nValue >= Cfg[1][1].Count then
|
||||
if actorData.nSecondGetFlag == nil then
|
||||
actorData.nSecondGetFlag = 0;
|
||||
end
|
||||
actorData.nSecondGetFlag = actorData.nSecondGetFlag +1;
|
||||
|
||||
Actor.setRechargeStatus(pActor, 2)
|
||||
end
|
||||
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType10021.lua")
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10021.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10021.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10021.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10021.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10021.lua")
|
||||
|
||||
|
||||
-- 跨天,
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[ActivityType10004 ] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
if runAtvIdList then
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
local Cfg = ActivityConfig10021[atvId]
|
||||
|
||||
local currentYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
if currentYuanBaoCount >= Cfg[1][1].Count then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData.nSecondGetFlag then
|
||||
actorData.nSecondGetFlag = actorData.nSecondGetFlag + ndiffday;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10021.lua")
|
||||
@@ -0,0 +1,335 @@
|
||||
module("ActivityType10022", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人活动(玩法),360大玩家特权
|
||||
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType = 0(默认值) or 1 服务器使用
|
||||
ReqSubGiftType1 = 0(默认值) or 1 服务器使用
|
||||
privilegeGift = 0 or 1 是否领取 360大玩家特权
|
||||
Fcm = 0 ~ 2 防沉迷 0:未填写身份证,1:成年,2:未成年
|
||||
FcmGiftFlag = 0 or 1 防沉迷 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10022
|
||||
--对应的活动配置
|
||||
ActivityConfig = Platform360Config
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
local HttpStatus = {
|
||||
Success = "0", -- 成功
|
||||
ArgError = "-4", -- param gkey error
|
||||
SignError = "-2", -- sign error
|
||||
}
|
||||
|
||||
|
||||
Host = ActivityConfig.host or "game.api.1360.com"
|
||||
Api = ActivityConfig.api or "/authcheck"
|
||||
Port = ActivityConfig.port or "80"
|
||||
|
||||
|
||||
function GetUserData(pActor)
|
||||
print("[Tip] ActivityType10022 GetUserData")
|
||||
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if var.userData== nil then
|
||||
var.userData = {}
|
||||
end
|
||||
|
||||
return var.userData
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- CPP回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 360玩家登录
|
||||
function On360Login(pActor)
|
||||
print("[Tip] ActivityType10022 On360Login")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10022 On360Login not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10022 On360Login not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10022 On360Login not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] [Platform360] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
|
||||
local userData = GetUserData(pActor)
|
||||
if userData.ReqMainGiftType == nil then
|
||||
userData.ReqMainGiftType = 0
|
||||
end
|
||||
if userData.ReqSubGiftType1 == nil then
|
||||
userData.ReqSubGiftType1 = 0
|
||||
end
|
||||
if userData.privilegeGift == nil then
|
||||
userData.privilegeGift = 0
|
||||
end
|
||||
if userData.Fcm == nil then
|
||||
userData.Fcm = 0
|
||||
end
|
||||
if userData.FcmGiftFlag == nil then
|
||||
userData.FcmGiftFlag = 0
|
||||
end
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSend360UserPrivilegeData)
|
||||
if npack then
|
||||
--print("[Tip] ActivityType10022 On360Login sSend360UserPrivilegeData ")
|
||||
DataPack.writeByte(npack, (userData.privilegeGift or 0)) -- 是否领取 360大玩家特权 礼包 0否1是
|
||||
DataPack.writeByte(npack, (userData.Fcm or 0)) -- 防沉迷 0:未填写身份证,1:成年,2:未成年
|
||||
DataPack.writeByte(npack, (userData.FcmGiftFlag or 0)) -- 防沉迷 礼包领取标志
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 请求 360大玩家特权 礼包
|
||||
function OnReq360PrivilegeGift(pActor)
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] [Platform360] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetUserData(pActor)
|
||||
if userData.privilegeGift == 1 then
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift userData.privilegeGift == 1 ")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.reward1 then
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift not ActivityConfig.reward1 ")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) ~= true then
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift CheckBagIsEnough ")
|
||||
return
|
||||
end
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSend360UserPrivilegeData)
|
||||
if npack then
|
||||
|
||||
userData.privilegeGift = 1
|
||||
|
||||
DataPack.writeByte(npack, (userData.privilegeGift or 1)) -- 是否领取 360大玩家特权 礼包 0否1是
|
||||
DataPack.writeByte(npack, (userData.Fcm or 0)) -- 防沉迷 0:未填写身份证,1:成年,2:未成年
|
||||
DataPack.writeByte(npack, (userData.FcmGiftFlag or 0)) -- 防沉迷 礼包领取标志
|
||||
DataPack.flush(npack)
|
||||
|
||||
local awards = ActivityConfig.reward1
|
||||
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_ActivityType10022)
|
||||
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
|
||||
print("[Tip] ActivityType10022 OnReq360PrivilegeGift Success ")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- 请求奖励
|
||||
function OnReq360Gift(pActor, packet)
|
||||
print("[Tip] ActivityType10022 OnReq360Gift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10022 OnReq360Gift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10022 OnReq360Gift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10022 OnReq360Gift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] [Platform360] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetUserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
userData.ReqSubGiftType1 = DataPack.readByte(packet)
|
||||
|
||||
if not userData.ReqMainGiftType then
|
||||
print("[Tip] ActivityType10022 OnReq360Gift not userData.ReqMainGiftType")
|
||||
return
|
||||
end
|
||||
|
||||
if not userData.ReqSubGiftType1 then
|
||||
print("[Tip] ActivityType10022 OnReq360Gift not userData.ReqSubGiftType1")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then
|
||||
if 1 == userData.ReqSubGiftType1 then
|
||||
Req360UserInfo(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 防沉迷奖励
|
||||
function SendFcmGift(pActor)
|
||||
print("[Tip] ActivityType10022 SendFcmGift")
|
||||
|
||||
local userData = GetUserData(pActor)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType1 = 0
|
||||
|
||||
if not userData.Fcm or userData.Fcm == 0 then
|
||||
print("[Tip] ActivityType10022 SendFcmGift not Fcm certification")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.FcmGiftFlag then
|
||||
print("[Tip] ActivityType10022 SendFcmGift already get FcmGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.authentication then
|
||||
print("[Tip] ActivityType10022 SendFcmGift not ActivityConfig or not ActivityConfig.authentication")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10022 SendFcmGift CheckBagIsEnough ")
|
||||
return
|
||||
end
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSend360UserPrivilegeData)
|
||||
if npack then
|
||||
|
||||
userData.FcmGiftFlag = 1
|
||||
DataPack.writeByte(npack, (userData.privilegeGift or 0)) -- 是否领取 360大玩家特权 礼包 0否1是
|
||||
DataPack.writeByte(npack, (userData.Fcm or 0)) -- 防沉迷 0:未填写身份证,1:成年,2:未成年
|
||||
DataPack.writeByte(npack, (userData.FcmGiftFlag or 1)) -- 是否领取 360大玩家特权 礼包 0否1是
|
||||
DataPack.flush(npack)
|
||||
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,1)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.authentication, GameLog.Log_ActivityType10022)
|
||||
|
||||
Actor.SendActivityLog(pActor,ActivityType,ActivityType,2)
|
||||
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
|
||||
print("[Tip] ActivityType10022 SendFcmGift Success ")
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq360UserPrivilegeGift, OnReq360PrivilegeGift)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq360Gift, OnReq360Gift)
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 请求平台玩家数据信息
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 设置 360用户数据
|
||||
function Set360UserData(paramPack,content,result)
|
||||
print("[Tip] ActivityType10022 Set360UserData content : "..content)
|
||||
print("[Tip] ActivityType10022 Set360UserData result : "..result)
|
||||
local nActorId = paramPack[1]
|
||||
local pActor = Actor.getActorById(nActorId)
|
||||
if not pActor then
|
||||
print("[Tip] ActivityType10022 Set360UserData [" .. nActorId .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[Tip] ActivityType10022 Set360UserData [" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[Tip] ActivityType10022 Set360UserData result:"..result)
|
||||
|
||||
if 0 == result then
|
||||
local status = string.match(content,"\"errno\":(%d+)")
|
||||
if (HttpStatus.Success == status) then
|
||||
|
||||
local strFcm = string.match(content,"\"status\":(%d+)")
|
||||
local nFcm = 0
|
||||
|
||||
if "null" ~= strFcm then
|
||||
nFcm = tonumber(strFcm)
|
||||
end
|
||||
|
||||
local userData = GetUserData(pActor)
|
||||
userData.Fcm = nFcm
|
||||
|
||||
if 1 == userData.ReqMainGiftType then
|
||||
if 1 == userData.ReqSubGiftType1 then
|
||||
SendFcmGift(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 请求 360用户信息
|
||||
function Req360UserInfo(pActor)
|
||||
print("[Tip] ActivityType10022 Req360UserInfo")
|
||||
|
||||
local nActorId = Actor.getActorId(pActor)
|
||||
|
||||
local gkey = "sbcq"
|
||||
local qid = Actor.getAccount(pActor)
|
||||
local time = os.time()
|
||||
local key = "uyTs8udOvowF3KAMsPbe3f1Kvfsyww1L"
|
||||
|
||||
local sign = System.MD5(gkey..qid..time..key)
|
||||
local req = Api..'?&qid='..qid..'&gkey='..gkey..'&time='..time..'&sign='..sign
|
||||
|
||||
print("[Tip] ActivityType10022 Req360UserInfo [" .. Actor.getName(pActor) .. "] : ".. Host)
|
||||
print("[Tip] ActivityType10022 Req360UserInfo [" .. Actor.getName(pActor) .. "] : ".. Port)
|
||||
print("[Tip] ActivityType10022 Req360UserInfo [" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
Set360UserData,
|
||||
{nActorId}
|
||||
)
|
||||
end
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
module("ActivityType10023", package.seeall)
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10023
|
||||
--对应的活动配置
|
||||
ActivityConfig = Platform7youxiConfig
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- CPP回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 7游戏玩家登录
|
||||
function On7GameLogin(pActor)
|
||||
print("[Tip] ActivityType10023 On7GameLogin")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10023 On7GameLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10023 On7GameLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10023 On7GameLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSend7GameGitfData)
|
||||
if npack then
|
||||
print("[Tip] ActivityType10023 On7GameLogin sSend7GameGitfData ")
|
||||
local nCurYuanBaoCount = Actor.getIntProperty(pActor,PROP_ACTOR_DRAW_YB_COUNT)
|
||||
|
||||
local nGiftFlag = 0;
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
if cdkdata.codeTypeTimes and PlatformConfig.type then
|
||||
if cdkdata.codeTypeTimes[PlatformConfig.type] then
|
||||
nGiftFlag = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
print("[Tip] ActivityType10023 On7GameLogin sSend7GameGitfData nGiftFlag : "..nGiftFlag)
|
||||
|
||||
DataPack.writeByte(npack, (nGiftFlag or 0)) -- 是否领取 7游戏 微信礼包 0否1是
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,819 @@
|
||||
module("ActivityType10024", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
LoginType = 0 or 1 鲁大师 登录类型(1:游戏盒子登录)
|
||||
LastTime = 0 鲁大师 上一次初始化的时间戳
|
||||
ReqMainGiftType = 0 ~ 4 鲁大师 请求奖励类型((服务器使用 登录发送奖励数据):0;
|
||||
vip:1(一级子类型:1:称号奖励(二级子类型:奖励Id);2:礼包奖励(二级子类型:奖励Id));
|
||||
会员:2(一级子类型:1:称号奖励(二级子类型:奖励Id);2:礼包奖励(二级子类型:奖励Id);3:每日奖励(二级子类型:奖励Id));
|
||||
手机礼包:3(一级子类型:1:手机绑定奖励(二级子类型:奖励Id);2:防沉迷奖励(二级子类型:奖励Id));
|
||||
游戏盒子:4(一级子类型:1:下载奖励(二级子类型:奖励Id);2:每日奖励(二级子类型:奖励Id);3:等级奖励(二级子类型:奖励Id)))
|
||||
ReqSubGiftType = 1 ~ 2 or 1 ~ 3 鲁大师 请求奖励一级子类型
|
||||
ReqSubGiftType2 = 0 ~ 4 鲁大师 请求奖励二级子类型(对应的奖励Id;0暂未使用)
|
||||
VipLevel = 0~9 鲁大师 vip等级 0-9
|
||||
PlusLevel = 0,1-4 鲁大师 超玩会等级 0,1-4
|
||||
BindPhone = 0 or 1 鲁大师 绑定手机 0表示未绑定, 1表示绑定
|
||||
Fcm = 0 or 1 鲁大师 防沉迷验证 0表示未通过防沉迷验证,1表示通过
|
||||
SVIPGiftFlag = 0 or 1 鲁大师 超级Vip 礼包领取标志
|
||||
DownLoadGameBoxGiftFlag = 0 or 1 鲁大师 游戏盒子下载 礼包领取标志
|
||||
BindPhoneGiftFlag = 0 or 1 鲁大师 手机绑定 礼包领取标志
|
||||
WeChatGiftFlag = 0 or 1 鲁大师 微信 礼包领取标志
|
||||
FcmGiftFlag = 0 or 1 鲁大师 防沉迷 礼包领取标志
|
||||
VipTitleFlag = 00000000 32位 鲁大师 Vip称号 礼包领取标志
|
||||
VipGiftFlag = 00000000 32位 鲁大师 Vip礼包 礼包领取标志
|
||||
MemberTitleFlag = 00000000 32位 鲁大师 会员称号 礼包领取标志
|
||||
MemberGiftFlag = 00000000 32位 鲁大师 会员礼包 礼包领取标志
|
||||
MemberDailyGiftFlag = 0 or 1 鲁大师 会员每日礼包 礼包领取标志
|
||||
GameBoxDailyGiftFlag = 0 or 1 鲁大师 游戏盒子每日礼包 礼包领取标志
|
||||
GameBoxLevelGiftFlag = 00000000 32位 鲁大师 游戏盒子等级礼包 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10024
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformludashiConfig
|
||||
VipConfig= LudashivipConfig
|
||||
MemberConfig = LudashimemberConfig
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
local HttpStatus = {
|
||||
Success = "0", -- 成功
|
||||
ArgError = "302", -- 参数错误
|
||||
SignError = "304", -- 签名错误
|
||||
LinkLost = "305", -- 链接失效,超时
|
||||
}
|
||||
|
||||
-- 服务接口
|
||||
Host = ActivityConfig.host or "wan.ludashi.com"
|
||||
Api = ActivityConfig.api or "/openApi/platformVipInfo"
|
||||
Port = ActivityConfig.port or "80"
|
||||
|
||||
|
||||
function GetMasterLuUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.MasterLuUserData then
|
||||
var.MasterLuUserData = {}
|
||||
end
|
||||
return var.MasterLuUserData
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 请求平台玩家数据信息
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 请求 鲁大师用户信息
|
||||
function ReqMasterLuUserInfo(pActor)
|
||||
print("[Tip] ActivityType10024 ReqMasterLuUserInfo")
|
||||
|
||||
local nActorId = Actor.getActorId(pActor)
|
||||
|
||||
local gid = "sbcq"
|
||||
local uid = Actor.getAccount(pActor)
|
||||
local time = os.time()
|
||||
local token = "2cA4xA5BiwRPyZJEb#eJYmeS@NznzaH6"
|
||||
|
||||
local sign = System.MD5(gid..uid..time..token)
|
||||
local req = Api..'?gid='..gid..'&uid='..uid..'&time='..time..'&sign='..sign
|
||||
|
||||
-- print("[Tip] ActivityType10024 ReqMasterLuUserInfo [" .. Actor.getName(pActor) .. "] : ".. Host)
|
||||
-- print("[Tip] ActivityType10024 ReqMasterLuUserInfo [" .. Actor.getName(pActor) .. "] : ".. Port)
|
||||
-- print("[Tip] ActivityType10024 ReqMasterLuUserInfo [" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
SetMasterLuUserData,
|
||||
{nActorId}
|
||||
)
|
||||
end
|
||||
|
||||
-- 设置 鲁大师用户数据
|
||||
function SetMasterLuUserData(paramPack,content,result)
|
||||
-- print("[Tip] ActivityType10024 SetMasterLuUserData content : "..content)
|
||||
-- print("[Tip] ActivityType10024 SetMasterLuUserData result : "..result)
|
||||
local nActorId = paramPack[1]
|
||||
local pActor = Actor.getActorById(nActorId)
|
||||
if not pActor then
|
||||
print("[Tip] ActivityType10024 SetMasterLuUserData [" .. nActorId .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[Tip] ActivityType10024 SetMasterLuUserData [" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[Tip] ActivityType10024 SetMasterLuUserData result:"..result)
|
||||
|
||||
if 0 == result then
|
||||
local status = string.match(content,"\"errno\":(%d+)")
|
||||
if (HttpStatus.Success == status) then
|
||||
local strVip = string.match(content,"\"vip\":(%d+)")
|
||||
local strPlus = string.match(content,"\"plus\":(%d+)")
|
||||
local strBindPhone = string.match(content,"\"bindPhone\":(%d+)")
|
||||
local strFcm = string.match(content,"\"fcm\":(%d+)")
|
||||
|
||||
local nVip = 0
|
||||
local nPlus = 0
|
||||
local nBindPhone = 0
|
||||
local nFcm = 0
|
||||
|
||||
if "null" ~= strVip then
|
||||
nVip = tonumber(strVip)
|
||||
end
|
||||
if "null" ~= strPlus then
|
||||
nPlus = tonumber(strPlus)
|
||||
end
|
||||
if "null" ~= strBindPhone then
|
||||
nBindPhone = tonumber(strBindPhone)
|
||||
end
|
||||
if "null" ~= strFcm then
|
||||
nFcm = tonumber(strFcm)
|
||||
end
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
userData.VipLevel = nVip
|
||||
userData.PlusLevel = nPlus
|
||||
userData.BindPhone = nBindPhone
|
||||
userData.Fcm = nFcm
|
||||
|
||||
if 0 == userData.ReqMainGiftType then
|
||||
SendMasterLuUserData(pActor)
|
||||
elseif 1 == userData.ReqMainGiftType then -- vip:1(一级子类型:1:称号奖励;2:礼包奖励)
|
||||
SendVipAwards(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 会员:2(一级子类型:1:称号奖励;2:礼包奖励;3:每日奖励)
|
||||
if 1 == userData.ReqSubGiftType or 2 == userData.ReqSubGiftType then
|
||||
SendMemberAwards(pActor)
|
||||
elseif 3 == userData.ReqSubGiftType then
|
||||
SendMemberDailyGift(pActor)
|
||||
end
|
||||
elseif 3 == userData.ReqMainGiftType then -- 手机礼包:3(一级子类型:1:手机绑定奖励;2:防沉迷奖励);
|
||||
if 1 == userData.ReqSubGiftType then
|
||||
SendBindPhoneGift(pActor)
|
||||
elseif 2 == userData.ReqSubGiftType then
|
||||
SendFcmGift(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 鲁大师玩家数据
|
||||
function SendMasterLuUserData(pActor)
|
||||
print("[Tip] ActivityType10024 SendMasterLuUserData")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10024 SendMasterLuUserData not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10024 SendMasterLuUserData not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10024 SendMasterLuUserData not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10024 SendMasterLuUserData [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSendMasterLuGitfData)
|
||||
if npack then
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes and PlatformConfig.type then
|
||||
if cdkdata.codeTypeTimes[PlatformConfig.type] then
|
||||
userData.SVIPGiftFlag = 1
|
||||
end
|
||||
end
|
||||
|
||||
-- 微信奖励
|
||||
if cdkdata.codeTypeTimes and PlatformConfig.type2 then
|
||||
if cdkdata.codeTypeTimes[PlatformConfig.type2] then
|
||||
userData.WeChatGiftFlag = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DataPack.writeByte(npack, (userData.VipLevel or 0))
|
||||
DataPack.writeByte(npack, (userData.PlusLevel or 0))
|
||||
DataPack.writeByte(npack, (userData.BindPhone or 0))
|
||||
DataPack.writeByte(npack, (userData.Fcm or 0))
|
||||
DataPack.writeByte(npack, (userData.SVIPGiftFlag or 0))
|
||||
DataPack.writeByte(npack, (userData.DownLoadGameBoxGiftFlag or 0))
|
||||
DataPack.writeByte(npack, (userData.BindPhoneGiftFlag or 0))
|
||||
DataPack.writeByte(npack, (userData.WeChatGiftFlag or 0))
|
||||
DataPack.writeByte(npack, (userData.FcmGiftFlag or 0))
|
||||
DataPack.writeUInt(npack, (userData.VipTitleFlag or 0))
|
||||
DataPack.writeUInt(npack, (userData.VipGiftFlag or 0))
|
||||
DataPack.writeUInt(npack, (userData.MemberTitleFlag or 0))
|
||||
DataPack.writeUInt(npack, (userData.MemberGiftFlag or 0))
|
||||
DataPack.writeByte(npack, (userData.MemberDailyGiftFlag or 0))
|
||||
DataPack.writeByte(npack, (userData.GameBoxDailyGiftFlag or 0))
|
||||
DataPack.writeUInt(npack, (userData.GameBoxLevelGiftFlag or 0))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 鲁大师玩家登录
|
||||
function OnReqMasterLuLogin(pActor, packet)
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuLogin")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local nLoginType = DataPack.readByte(packet) -- 1:游戏盒子登录
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
|
||||
-- 初始化 登录类型
|
||||
userData.LoginType = nLoginType
|
||||
|
||||
-- 初始化 每天奖励数据
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
if nil == userData.LastTime then
|
||||
userData.LastTime = currMiniTime
|
||||
userData.MemberDailyGiftFlag = 0
|
||||
userData.GameBoxDailyGiftFlag = 0
|
||||
else
|
||||
if not System.isSameDay(userData.LastTime, currMiniTime) then
|
||||
userData.LastTime = currMiniTime
|
||||
userData.MemberDailyGiftFlag = 0
|
||||
userData.GameBoxDailyGiftFlag = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- 初始化 奖励 相关数据
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
-- 请求 鲁大师平台 用户信息
|
||||
ReqMasterLuUserInfo(pActor)
|
||||
end
|
||||
|
||||
-- 请求 鲁大师奖励
|
||||
function OnReqMasterLuGift(pActor, packet)
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local nMainGiftType = DataPack.readByte(packet)
|
||||
local nSubGiftType = DataPack.readByte(packet)
|
||||
local nSubGiftType2 = DataPack.readByte(packet)
|
||||
|
||||
if nMainGiftType < 1 or nMainGiftType > 4 then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift nMainGiftType < 1 or nMainGiftType > 4")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == nMainGiftType or 3 == nMainGiftType then
|
||||
if nSubGiftType < 1 or nSubGiftType > 2 then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift nSubGiftType < 1 or nSubGiftType > 2 : "..nMainGiftType)
|
||||
return
|
||||
end
|
||||
elseif 2 == nMainGiftType or 4 == nMainGiftType then
|
||||
if nSubGiftType < 1 or nSubGiftType > 3 then
|
||||
print("[Tip] ActivityType10024 OnReqMasterLuGift nSubGiftType < 1 or nSubGiftType > 3 : "..nMainGiftType)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
userData.ReqMainGiftType = nMainGiftType
|
||||
userData.ReqSubGiftType = nSubGiftType
|
||||
userData.ReqSubGiftType2 = nSubGiftType2
|
||||
|
||||
if 4 ~= nMainGiftType then -- 请求 鲁大师平台 用户信息
|
||||
ReqMasterLuUserInfo(pActor)
|
||||
else --游戏盒子:4(一级子类型:1:下载奖励(二级子类型:奖励Id);2:每日奖励(二级子类型:奖励Id);3:等级奖励(二级子类型:奖励Id)))
|
||||
if 1 == userData.ReqSubGiftType then
|
||||
SendDownLoadGameBoxGift(pActor)
|
||||
elseif 2 == userData.ReqSubGiftType then
|
||||
SendGameBoxDailyGift(pActor)
|
||||
elseif 3 == userData.ReqSubGiftType then
|
||||
SendGameBoxLevelGift(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 游戏盒子下载奖励
|
||||
function SendDownLoadGameBoxGift(pActor)
|
||||
print("[Tip] ActivityType10024 SendDownLoadGameBoxGift ")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
|
||||
if not userData.LoginType then
|
||||
print("[Tip] ActivityType10024 SendDownLoadGameBoxGift not userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.DownLoadGameBoxGiftFlag then
|
||||
print("[Tip] ActivityType10024 SendDownLoadGameBoxGift already get award")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.downloadBoxReward then
|
||||
print("[Tip] ActivityType10024 SendDownLoadGameBoxGift not ActivityConfig.downloadBoxReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10024 SendDownLoadGameBoxGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.DownLoadGameBoxGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.downloadBoxReward, GameLog.Log_Activity10024)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 绑定手机奖励
|
||||
function SendBindPhoneGift(pActor)
|
||||
print("[Tip] ActivityType10024 SendBindPhoneGift")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
|
||||
if not userData.BindPhone or 1 ~= userData.BindPhone then
|
||||
print("[Tip] ActivityType10024 SendBindPhoneGift not userData.BindPhone or 1 ~= userData.BindPhone")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.BindPhoneGiftFlag then
|
||||
print("[Tip] ActivityType10024 SendBindPhoneGift already get BindPhoneGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.bindPhoneReward then
|
||||
print("[Tip] ActivityType10024 SendBindPhoneGift not ActivityConfig.bindPhoneReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10022 SendBindPhoneGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BindPhoneGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.bindPhoneReward, GameLog.Log_Activity10024)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 防沉迷奖励
|
||||
function SendFcmGift(pActor)
|
||||
print("[Tip] ActivityType10024 SendFcmGift")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
|
||||
if not userData.Fcm or 1 ~= userData.Fcm then
|
||||
print("[Tip] ActivityType10024 SendBindPhoneGift not userData.Fcm or 1 ~= userData.Fcm")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.FcmGiftFlag then
|
||||
print("[Tip] ActivityType10024 SendFcmGift already get FcmGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.FcmReward then
|
||||
print("[Tip] ActivityType10024 SendFcmGift not ActivityConfig.FcmReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10022 SendFcmGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.FcmGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.FcmReward, GameLog.Log_Activity10024)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 Vip奖励
|
||||
function SendVipAwards(pActor)
|
||||
print("[Tip] ActivityType10024 SendVipAwards")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
|
||||
|
||||
if not userData.VipLevel or userData.VipLevel < 0 or userData.VipLevel > 9 then
|
||||
print("[Tip] ActivityType10024 SendVipAwards not userData.VipLevel or userData.VipLevel < 0 or userData.VipLevel > 9")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 2 then
|
||||
print("[Tip] ActivityType10024 SendVipAwards userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 2")
|
||||
return
|
||||
end
|
||||
|
||||
if not VipConfig then
|
||||
print("[Tip] ActivityType10024 SendVipAwards not VipConfig")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType2 > #VipConfig then
|
||||
print("[Tip] ActivityType10024 SendVipAwards ReqSubGiftType2 > #VipConfig ReqSubGiftType : "..userData.ReqSubGiftType.."ReqSubGiftType2 : "..userData.ReqSubGiftType2)
|
||||
return
|
||||
end
|
||||
|
||||
if not VipConfig[userData.ReqSubGiftType2].vipLevel then
|
||||
print("[Tip] ActivityType10024 SendVipAwards not VipConfig[userData.ReqSubGiftType2].vipLevel")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqSubGiftType then
|
||||
if not VipConfig[userData.ReqSubGiftType2].titleReward then
|
||||
print("[Tip] ActivityType10024 SendVipAwards not VipConfig[userData.ReqSubGiftType2].titleReward")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.VipLevel >= VipConfig[userData.ReqSubGiftType2].vipLevel then
|
||||
if 0 == System.getIntBit(userData.VipTitleFlag, userData.ReqSubGiftType2 - 1) then
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10024 SendVipAwards not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.VipTitleFlag = System.setIntBit(userData.VipTitleFlag, userData.ReqSubGiftType2 - 1, true)
|
||||
CommonFunc.Awards.Give(pActor, VipConfig[userData.ReqSubGiftType2].titleReward, GameLog.Log_Activity10024)
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendVipAwards already get titleReward Id : "..userData.ReqSubGiftType2)
|
||||
return
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendVipAwards titleReward userData.VipLevel < VipConfig[userData.ReqSubGiftType2].vipLevel")
|
||||
return
|
||||
end
|
||||
elseif 2 == userData.ReqSubGiftType then
|
||||
if not VipConfig[userData.ReqSubGiftType2].giftReward then
|
||||
print("[Tip] ActivityType10024 SendVipAwards not VipConfig[userData.ReqSubGiftType2].giftReward")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.VipLevel >= VipConfig[userData.ReqSubGiftType2].vipLevel then
|
||||
if 0 == System.getIntBit(userData.VipGiftFlag, userData.ReqSubGiftType2 - 1) then
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10024 SendVipAwards not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.VipGiftFlag = System.setIntBit(userData.VipGiftFlag, userData.ReqSubGiftType2 - 1, true)
|
||||
CommonFunc.Awards.Give(pActor, VipConfig[userData.ReqSubGiftType2].giftReward, GameLog.Log_Activity10024)
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendVipAwards already get giftReward Id : "..userData.ReqSubGiftType2)
|
||||
return
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendVipAwards giftReward userData.VipLevel < VipConfig[userData.ReqSubGiftType2].vipLevel")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 会员奖励
|
||||
function SendMemberAwards(pActor)
|
||||
print("[Tip] ActivityType10024 SendMemberAwards")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
|
||||
if not userData.PlusLevel or userData.PlusLevel < 1 or userData.PlusLevel > 4 then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards not userData.PlusLevel or userData.PlusLevel < 1 or userData.PlusLevel > 4")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 2 then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 2")
|
||||
return
|
||||
end
|
||||
|
||||
if not MemberConfig then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards not MemberConfig")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType2 > #MemberConfig then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards ReqSubGiftType2 > #MemberConfig ReqSubGiftType : "..userData.ReqSubGiftType.."ReqSubGiftType2 : "..userData.ReqSubGiftType2)
|
||||
return
|
||||
end
|
||||
|
||||
if not MemberConfig[userData.ReqSubGiftType2].memberLevel then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards not MemberConfig[userData.ReqSubGiftType2].memberLevel")
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
if 1 == userData.ReqSubGiftType then
|
||||
if not MemberConfig[userData.ReqSubGiftType2].titleReward then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards not MemberConfig[userData.ReqSubGiftType2].titleReward")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.PlusLevel >= MemberConfig[userData.ReqSubGiftType2].memberLevel then
|
||||
if 0 == System.getIntBit(userData.MemberTitleFlag, userData.ReqSubGiftType2 - 1) then
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.MemberTitleFlag = System.setIntBit(userData.MemberTitleFlag, userData.ReqSubGiftType2 - 1, true)
|
||||
CommonFunc.Awards.Give(pActor, MemberConfig[userData.ReqSubGiftType2].titleReward, GameLog.Log_Activity10024)
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendMemberAwards already get titleReward Id : "..userData.ReqSubGiftType2)
|
||||
return
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendMemberAwards titleReward userData.PlusLevel < MemberConfig[userData.ReqSubGiftType2].memberLevel")
|
||||
return
|
||||
end
|
||||
elseif 2 == userData.ReqSubGiftType then
|
||||
if not MemberConfig[userData.ReqSubGiftType2].giftReward then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards not MemberConfig[userData.ReqSubGiftType2].giftReward")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.PlusLevel >= MemberConfig[userData.ReqSubGiftType2].memberLevel then
|
||||
if 0 == System.getIntBit(userData.MemberGiftFlag, userData.ReqSubGiftType2 - 1) then
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10024 SendMemberAwards not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.MemberGiftFlag = System.setIntBit(userData.MemberGiftFlag, userData.ReqSubGiftType2 - 1, true)
|
||||
CommonFunc.Awards.Give(pActor, MemberConfig[userData.ReqSubGiftType2].giftReward, GameLog.Log_Activity10024)
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendMemberAwards already get giftReward Id : "..userData.ReqSubGiftType2)
|
||||
return
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10024 SendMemberAwards giftReward userData.PlusLevel < MemberConfig[userData.ReqSubGiftType2].memberLevel")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 会员每日礼包
|
||||
function SendMemberDailyGift(pActor)
|
||||
print("[Tip] ActivityType10024 SendMemberDailyGift")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
|
||||
if userData.PlusLevel < 1 or userData.PlusLevel > 4 then
|
||||
print("[Tip] ActivityType10024 SendMemberDailyGift userData.PlusLevel < 1 or userData.PlusLevel > 4")
|
||||
return
|
||||
end
|
||||
|
||||
if 3 ~= userData.ReqSubGiftType then
|
||||
print("[Tip] ActivityType10024 SendMemberDailyGift 3 ~= userData.ReqSubGiftType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.MemberDailyGiftFlag then
|
||||
print("[Tip] ActivityType10024 SendMemberDailyGift already get MemberDailyGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not MemberConfig then
|
||||
print("[Tip] ActivityType10024 SendMemberDailyGift not MemberConfig")
|
||||
return
|
||||
end
|
||||
|
||||
if not MemberConfig[userData.ReqSubGiftType] or not MemberConfig[userData.ReqSubGiftType].giftReward then
|
||||
print("[Tip] ActivityType10024 SendMemberDailyGift not MemberConfig[userData.ReqSubGiftType].giftReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10022 SendMemberDailyGift CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.MemberDailyGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, MemberConfig[userData.ReqSubGiftType].giftReward, GameLog.Log_Activity10024)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 游戏盒子每日礼包
|
||||
function SendGameBoxDailyGift(pActor)
|
||||
print("[Tip] ActivityType10024 SendGameBoxDailyGift")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
if not userData.LoginType then
|
||||
print("[Tip] ActivityType10024 SendGameBoxDailyGift not userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.GameBoxDailyGiftFlag then
|
||||
print("[Tip] ActivityType10024 SendGameBoxDailyGift already get GameBoxDailyGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.boxdailyGift then
|
||||
print("[Tip] ActivityType10024 SendGameBoxDailyGift not ActivityConfig or not ActivityConfig.dailyGift")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10022 SendGameBoxDailyGift CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.GameBoxDailyGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.boxdailyGift, GameLog.Log_Activity10024)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 游戏盒子等级礼包
|
||||
function SendGameBoxLevelGift(pActor)
|
||||
print("[Tip] ActivityType10024 SendGameBoxLevelGift")
|
||||
|
||||
local userData = GetMasterLuUserData(pActor)
|
||||
if not userData.LoginType then
|
||||
print("[Tip] ActivityType10024 SendGameBoxLevelGift not userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType2 < 1 or userData.ReqSubGiftType2 > #ActivityConfig.levelGift or not ActivityConfig.levelGift[userData.ReqSubGiftType2] then
|
||||
print("[Tip] ActivityType10024 SendGameBoxLevelGift userData.ReqSubGiftType2 < 1 or userData.ReqSubGiftType2 > #ActivityConfig.levelGift or not ActivityConfig.levelGift[userData.ReqSubGiftType2]")
|
||||
return
|
||||
end
|
||||
|
||||
local nActorLevel = Actor.getIntProperty(pActor,PROP_CREATURE_LEVEL)
|
||||
if not ActivityConfig.levelGift[userData.ReqSubGiftType2].lvl or ActivityConfig.levelGift[userData.ReqSubGiftType2].lvl > nActorLevel then
|
||||
print("[Tip] ActivityType10024 SendGameBoxLevelGift not ActivityConfig.levelGift[userData.ReqSubGiftType2].lvl and ActivityConfig.levelGift[userData.ReqSubGiftType2].lvl > nActorLevel")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.levelGift[userData.ReqSubGiftType2].awards then
|
||||
print("[Tip] ActivityType10024 SendGameBoxLevelGift not ActivityConfig.levelGift[userData.ReqSubGiftType2].awards")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.GameBoxLevelGiftFlag, userData.ReqSubGiftType2 - 1) then
|
||||
print("[Tip] ActivityType10024 SendGameBoxLevelGift already get levelGift Id: "..userData.ReqSubGiftType2)
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10024 SendGameBoxLevelGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.GameBoxLevelGiftFlag = System.setIntBit(userData.GameBoxLevelGiftFlag, userData.ReqSubGiftType2 - 1, true)
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.levelGift[userData.ReqSubGiftType2].awards, GameLog.Log_Activity10024)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
userData.ReqSubGiftType2 = 0
|
||||
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cMasterLuLogin, OnReqMasterLuLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqMasterLuAward, OnReqMasterLuGift)
|
||||
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
print("[Tip] ActivityType10024 OnNewDayArrive")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10024 OnNewDayArrive not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10024 OnNewDayArrive not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10024 OnNewDayArrive not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10024 OnNewDayArrive [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local currMiniTime = System.getCurrMiniTime()
|
||||
local data = GetMasterLuUserData(pActor)
|
||||
if data.LastTime then
|
||||
if not System.isSameDay(data.LastTime, currMiniTime) then
|
||||
--print("跨一天")
|
||||
data.LastTime = currMiniTime
|
||||
data.MemberDailyGiftFlag = 0
|
||||
data.GameBoxDailyGiftFlag = 0
|
||||
SendMasterLuUserData(pActor)
|
||||
end
|
||||
-- SendData(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10024.lua")
|
||||
@@ -0,0 +1,412 @@
|
||||
module("ActivityType10027", package.seeall)
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
LoginType = 0 or 1(盒子登录)
|
||||
ReqGiftMainType = 0 ~ 3(1:盒子下载礼包(一次性);2:实名认证奖励(一次性);3:每日登录礼包;4:每日首充奖励和每日累计充值奖励)
|
||||
ReqSubGiftType1 = 每日累充奖励Id
|
||||
OneDayRechargesYBNum= ku25 每日累计充值元宝数
|
||||
BoxDownloadGiftFlag = 0 or 1 ku25 盒子下载礼包(一次性)
|
||||
RealNameAuthGiftFlag= 0 or 1 ku25 实名认证奖励(一次性)
|
||||
DailyLoginGiftFlag = 0 or 1 ku25 每日登录礼包
|
||||
OneDayRechargesGiftFlag = 32位 ku25 每日首充奖励和每日累计充值奖励
|
||||
WeChatGiftFlag = 0 or 1 ku25 微信礼包码 礼包
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
ActivityConfig = PlatformKU25Config -- 其他礼包
|
||||
ActivityDailyConfig = LoginKU25Config -- 每日充值礼包
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
function GetKu25UserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.Ku25UserData then
|
||||
var.Ku25UserData = {}
|
||||
end
|
||||
return var.Ku25UserData
|
||||
end
|
||||
|
||||
-- 发送 ku25玩家数据
|
||||
function SendKu25UserData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSendku25UserData)
|
||||
if npack then
|
||||
print("[Tip] ActivityType10027 SendKu25UserData")
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
|
||||
DataPack.writeUInt(npack, userData.OneDayRechargesYBNum)
|
||||
DataPack.writeByte(npack, userData.BoxDownloadGiftFlag)
|
||||
DataPack.writeByte(npack, userData.RealNameAuthGiftFlag)
|
||||
DataPack.writeByte(npack, userData.DailyLoginGiftFlag)
|
||||
DataPack.writeUInt(npack, userData.OneDayRechargesGiftFlag)
|
||||
DataPack.writeByte(npack, userData.WeChatGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 盒子下载 奖励
|
||||
function SendBoxDownloadGift(pActor)
|
||||
print("[Tip] ActivityType10027 SendBoxDownloadGift")
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
if not userData.LoginType then
|
||||
print("[Tip] ActivityType10027 SendBoxDownloadGift not userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.BoxDownloadGiftFlag then
|
||||
print("[Tip] ActivityType10027 SendBoxDownloadGift already get BoxDownloadGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.BoxReward then
|
||||
print("[Tip] ActivityType10027 SendBoxDownloadGift not ActivityConfig or not ActivityConfig.BoxReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10027 SendBoxDownloadGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BoxDownloadGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.BoxReward, GameLog.Log_Activity10027)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType1 = 0
|
||||
|
||||
SendKu25UserData(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
|
||||
-- 发送 实名认证奖励
|
||||
function SendRealNameAuthGift(pActor)
|
||||
print("[Tip] ActivityType10027 SendRealNameAuthGift")
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
if 1 == userData.RealNameAuthGiftFlag then
|
||||
print("[Tip] ActivityType10027 SendRealNameAuthGift already get RealNameAuthGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.RealnameReward then
|
||||
print("[Tip] ActivityType10027 SendRealNameAuthGift not ActivityConfig or not ActivityConfig.RealnameReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10027 SendRealNameAuthGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.RealNameAuthGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.downloadBoxReward, GameLog.Log_Activity10027)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType1 = 0
|
||||
|
||||
SendKu25UserData(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
|
||||
-- 发送 ku25每日登录奖励
|
||||
function SendDailyLoginGift(pActor)
|
||||
print("[Tip] ActivityType10027 SendDailyLoginGift")
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
if not userData.LoginType then
|
||||
print("[Tip] ActivityType10027 SendDailyLoginGift not userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.DailyLoginGiftFlag then
|
||||
print("[Tip] ActivityType10027 SendDailyLoginGift already get BoxDownloadGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.LoginReward then
|
||||
print("[Tip] ActivityType10027 SendDailyLoginGift not ActivityConfig or not ActivityConfig.LoginReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10027 SendDailyLoginGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.DailyLoginGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.LoginReward, GameLog.Log_Activity10027)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType1 = 0
|
||||
|
||||
SendKu25UserData(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
|
||||
-- 发送 每日首充、每日累充奖励
|
||||
function SendOneDayRechargesGift(pActor)
|
||||
print("[Tip] ActivityType10027 SendOneDayRechargesGift")
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
if not userData.LoginType then
|
||||
print("[Tip] ActivityType10027 SendOneDayRechargesGift not userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityDailyConfig or userData.ReqSubGiftType1 > #ActivityDailyConfig or not ActivityDailyConfig[userData.ReqSubGiftType1] then
|
||||
print("[Tip] ActivityType10027 SendOneDayRechargesGift already get OneDayRechargesGift Id : "..userData.ReqSubGiftType1)
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityDailyConfig[userData.ReqSubGiftType1].Target or userData.OneDayRechargesYBNum < ActivityDailyConfig[userData.ReqSubGiftType1].Target then
|
||||
print("[Tip] ActivityType10027 SendOneDayRechargesGift not ActivityDailyConfig[userData.ReqSubGiftType1].Target or userData.OneDayRechargesYBNum < ActivityDailyConfig[userData.ReqSubGiftType1].Target Id : "..userData.ReqSubGiftType1)
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.OneDayRechargesGiftFlag, userData.ReqSubGiftType1 - 1) then
|
||||
print("[Tip] ActivityType10027 SendOneDayRechargesGift already get OneDayRechargesGift Id : "..userData.ReqSubGiftType1)
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10027 SendOneDayRechargesGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.OneDayRechargesGiftFlag = System.setIntBit(userData.OneDayRechargesGiftFlag, userData.ReqSubGiftType1 - 1, true)
|
||||
|
||||
print("userData.OneDayRechargesGiftFlag : "..userData.OneDayRechargesGiftFlag.." userData.ReqSubGiftType1 : "..userData.ReqSubGiftType1)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityDailyConfig[userData.ReqSubGiftType1].reward, GameLog.Log_Activity10027)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType1 = 0
|
||||
|
||||
SendKu25UserData(pActor)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
|
||||
-- 检查 微信礼包码礼包 是否已经领取
|
||||
function CheckWeChatGift(pActor)
|
||||
print("[Tip] ActivityType10027 CheckWeChatGift")
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.WeChatRewardID then
|
||||
print("[Tip] ActivityType10027 CheckWeChatGift not ActivityConfig or not ActivityConfig.WeChatRewardID")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.WeChatRewardID] then
|
||||
userData.WeChatGiftFlag = 1
|
||||
else
|
||||
userData.WeChatGiftFlag = 0
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10027 CheckWeChatGift not cdkdata.codeTypeTimes")
|
||||
return
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10027 CheckWeChatGift not cdkdata")
|
||||
return
|
||||
end
|
||||
|
||||
SendKu25UserData(pActor)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- cpp回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 更新每日累计充值元宝数
|
||||
function ChangeOneDayRechargesYBNum(pActor, YBNum)
|
||||
print("[Tip] ActivityType10027 ChangeOneDayRechargesYBNum ActorName : "..Actor.getName(pActor).." YBNum : "..YBNum)
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
if nil == userData.OneDayRechargesYBNum then
|
||||
userData.OneDayRechargesYBNum = 0
|
||||
end
|
||||
|
||||
userData.OneDayRechargesYBNum = userData.OneDayRechargesYBNum + YBNum
|
||||
|
||||
-- 玩家数据更新到客户端
|
||||
SendKu25UserData(pActor)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- ku25 玩家登录
|
||||
function OnReqku25Login(pActor, packet)
|
||||
print("[Tip] ActivityType10027 OnReqku25Login")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10027 OnReqku25Login not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10027 OnReqku25Login not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10027 OnReqku25Login not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10027 OnReqku25Login [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
|
||||
-- 初始化 登录类型
|
||||
userData.LoginType = DataPack.readByte(packet) -- 1:盒子登录
|
||||
|
||||
-- 初始化 玩家数据
|
||||
if nil == userData.LoginType then
|
||||
userData.LoginType = 0
|
||||
end
|
||||
if nil == userData.ReqGiftMainType then
|
||||
userData.ReqGiftMainType = 0
|
||||
end
|
||||
if nil == userData.ReqSubGiftType1 then
|
||||
userData.ReqSubGiftType1 = 0
|
||||
end
|
||||
if nil == userData.OneDayRechargesYBNum then
|
||||
userData.OneDayRechargesYBNum = 0
|
||||
end
|
||||
if nil == userData.BoxDownloadGiftFlag then
|
||||
userData.BoxDownloadGiftFlag = 0
|
||||
end
|
||||
if nil == userData.RealNameAuthGiftFlag then
|
||||
userData.RealNameAuthGiftFlag = 0
|
||||
end
|
||||
if nil == userData.DailyLoginGiftFlag then
|
||||
userData.DailyLoginGiftFlag = 0
|
||||
end
|
||||
if nil == userData.OneDayRechargesGiftFlag then
|
||||
userData.OneDayRechargesGiftFlag = 0
|
||||
end
|
||||
if nil == userData.WeChatGiftFlag then
|
||||
userData.WeChatGiftFlag = 0
|
||||
end
|
||||
|
||||
-- 玩家数据更新到客户端
|
||||
SendKu25UserData(pActor)
|
||||
end
|
||||
|
||||
-- 请求 ku25奖励
|
||||
function OnReqKu25Gift(pActor, packet)
|
||||
print("[Tip] ActivityType10027 OnReqKu25Gift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10027 OnReqKu25Gift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10027 OnReqKu25Gift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10027 OnReqKu25Gift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10027 OnReqKu25Gift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetKu25UserData(pActor)
|
||||
userData.ReqGiftMainType = DataPack.readByte(packet)
|
||||
userData.ReqSubGiftType1 = DataPack.readByte(packet)
|
||||
|
||||
if not userData.ReqGiftMainType or userData.ReqGiftMainType < 1 or userData.ReqGiftMainType > 5 then
|
||||
print("[Tip] ActivityType10027 OnReqKu25Gift not userData.ReqGiftMainType or userData.ReqGiftMainType < 1 or userData.ReqGiftMainType > 5")
|
||||
return
|
||||
end
|
||||
|
||||
if 4 == userData.ReqGiftMainType then
|
||||
if not userData.ReqSubGiftType1 or userData.ReqSubGiftType1 < 1 or userData.ReqSubGiftType1 > 6 then
|
||||
print("[Tip] ActivityType10027 OnReqKu25Gift not userData.ReqSubGiftType1 or userData.ReqSubGiftType1 < 1 or userData.ReqSubGiftType1 > 6")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if 1 == userData.ReqGiftMainType then -- 盒子下载礼包(一次性)
|
||||
SendBoxDownloadGift(pActor)
|
||||
elseif 2 == userData.ReqGiftMainType then -- 实名认证奖励(一次性)
|
||||
SendRealNameAuthGift(pActor)
|
||||
elseif 3 == userData.ReqGiftMainType then -- 每日登录礼包
|
||||
SendDailyLoginGift(pActor)
|
||||
elseif 4 == userData.ReqGiftMainType then -- 每日首充奖励和每日累计充值奖励
|
||||
SendOneDayRechargesGift(pActor)
|
||||
elseif 5 == userData.ReqGiftMainType then -- 检查 是否领取微信礼包码 礼包
|
||||
CheckWeChatGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqku25Login, OnReqku25Login)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqku25Gift, OnReqKu25Gift)
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
print("[Tip] ActivityType10027 OnNewDayArrive")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10027 OnNewDayArrive not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10027 OnNewDayArrive not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10027 OnNewDayArrive not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10027 OnNewDayArrive [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
-- local currMiniTime = System.getCurrMiniTime()
|
||||
local data = GetKu25UserData(pActor)
|
||||
-- if data.LastTime then
|
||||
-- if not System.isSameDay(data.LastTime, currMiniTime) then
|
||||
-- data.LastTime = currMiniTime
|
||||
data.OneDayRechargesYBNum = 0
|
||||
data.DailyLoginGiftFlag = 0
|
||||
data.OneDayRechargesGiftFlag = 0
|
||||
SendKu25UserData(pActor)
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10027.lua")
|
||||
@@ -0,0 +1,291 @@
|
||||
module("ActivityType10028", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType = 0 or 1 请求奖励主类型 1: 检查SVIP礼包是否领取;2:请求手机绑定礼包
|
||||
BindPhone = 0 or 1 QiDian 是否绑定手机:0:未绑定;1:已绑定
|
||||
SVIPGiftFlag = 0 or 1 QiDian SVIP 礼包领取标志
|
||||
BindPhoneGiftFlag = 0 or 1 QiDian 手机绑定 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10024
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformqidianConfig
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
local HttpStatus = {
|
||||
Success = "0", -- 成功
|
||||
Other = "", -- 失败
|
||||
}
|
||||
|
||||
|
||||
-- 服务接口
|
||||
Host = "yyhunfurepeat.bigrnet.com"
|
||||
Api = "/Service/GetQiDianCode.php"
|
||||
|
||||
Port = ActivityConfig.port or "80"
|
||||
|
||||
|
||||
|
||||
-- 设置 qidian用户数据
|
||||
function SetQiDianUserData(paramPack,content,result)
|
||||
local nActorId = paramPack[1]
|
||||
local pActor = Actor.getActorById(nActorId)
|
||||
if not pActor then
|
||||
print("[Tip] ActivityType10028 SetQiDianUserData [" .. nActorId .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[Tip] ActivityType10028 SetQiDianUserData [" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[Tip] ActivityType10028 SetQiDianUserData result:"..result)
|
||||
|
||||
if 0 == result then
|
||||
local status = string.match(content,"\"ReturnCode\":(%d+)")
|
||||
if (HttpStatus.Success == status) then
|
||||
local strBindPhone = string.match(content,"\"bind\":(%d+)")
|
||||
|
||||
local nBindPhone = 0
|
||||
|
||||
if "null" ~= strBindPhone then
|
||||
nBindPhone = tonumber(strBindPhone)
|
||||
end
|
||||
|
||||
local userData = GetQiDianUserData(pActor)
|
||||
userData.BindPhone = nBindPhone
|
||||
|
||||
if 0 == userData.ReqMainGiftType then
|
||||
SendQiDianUserData(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 领取 绑定手机礼包
|
||||
SendBindPhoneGift(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function GetQiDianUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.QiDianUserData then
|
||||
var.QiDianUserData = {}
|
||||
end
|
||||
return var.QiDianUserData
|
||||
end
|
||||
|
||||
-- 发送 qidian玩家数据
|
||||
function SendQiDianUserData(pActor)
|
||||
print("[Tip] ActivityType10028 SendQiDianUserData")
|
||||
local userData = GetQiDianUserData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSendQiDianUserData)
|
||||
if npack then
|
||||
DataPack.writeByte(npack, userData.BindPhone)
|
||||
DataPack.writeByte(npack, userData.SVIPGiftFlag)
|
||||
DataPack.writeByte(npack, userData.BindPhoneGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 请求平台玩家数据信息
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 请求 qidian用户信息
|
||||
function ReqQiDianUserInfo(pActor)
|
||||
print("[Tip] ActivityType10028 ReqQiDianUserInfo")
|
||||
|
||||
local nActorId = Actor.getActorId(pActor)
|
||||
|
||||
local gameId = 589
|
||||
local userId = Actor.getAccount(pActor)
|
||||
local timestamp = os.time()
|
||||
local key = "8g9f87h64kj5hhgo456db1sv787e"
|
||||
|
||||
local sign = System.MD5(gameId..timestamp..userId..key)
|
||||
local req = Api..'?gameId='..gameId..'&userId='..userId..'×tamp='..timestamp..'&sign='..string.lower(sign)
|
||||
|
||||
print("[Tip] ActivityType10028 ReqQiDianUserInfo [" .. Actor.getName(pActor) .. "] : ".. Host)
|
||||
print("[Tip] ActivityType10028 ReqQiDianUserInfo [" .. Actor.getName(pActor) .. "] : ".. Port)
|
||||
print("[Tip] ActivityType10028 ReqQiDianUserInfo [" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
SetQiDianUserData,
|
||||
{nActorId}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 检查 是否领取SVIP礼包
|
||||
function CheckSVIPGift(pActor)
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
if not ActivityConfig.svipRewardId then
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift not ActivityConfig.svipRewardId")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
local userData = GetQiDianUserData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.svipRewardId] then
|
||||
userData.SVIPGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift not dkdata.codeTypeTimes[ActivityConfig.svipRewardId]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10028 CheckSVIPGift not cdkdata")
|
||||
end
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
SendQiDianUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 手机绑定礼包
|
||||
function SendBindPhoneGift(pActor)
|
||||
print("[Tip] ActivityType10028 SendBindPhoneGift")
|
||||
|
||||
local userData = GetQiDianUserData(pActor)
|
||||
if 1 == userData.BindPhoneGiftFlag then
|
||||
print("[Tip] ActivityType10028 SendBindPhoneGift already get BindPhoneGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.bindPhoneReward then
|
||||
print("[Tip] ActivityType10028 SendBindPhoneGift already get BindPhoneGift")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10028 SendBindPhoneGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BindPhoneGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.bindPhoneReward, GameLog.Log_Activity10028)
|
||||
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
SendQiDianUserData(pActor)
|
||||
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
|
||||
end
|
||||
|
||||
-- QiDian 玩家登录
|
||||
function OnReqQiDianLogin(pActor)
|
||||
print("[Tip] ActivityType10028 OnReqQiDianLogin")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
local userData = GetQiDianUserData(pActor)
|
||||
if nil == userData.ReqMainGiftType then
|
||||
userData.ReqMainGiftType = 0
|
||||
end
|
||||
if nil == userData.BindPhone then
|
||||
userData.BindPhone = 0
|
||||
end
|
||||
if nil == userData.SVIPGiftFlag then
|
||||
userData.SVIPGiftFlag = 0
|
||||
end
|
||||
if nil == userData.BindPhoneGiftFlag then
|
||||
userData.BindPhoneGiftFlag = 0
|
||||
end
|
||||
|
||||
-- 请求 qidian平台 用户信息
|
||||
ReqQiDianUserInfo(pActor)
|
||||
end
|
||||
|
||||
-- QiDian 玩家登录
|
||||
function OnReqQiDianGift(pActor, packet)
|
||||
print("[Tip] ActivityType10028 OnReqQiDianGift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianGift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetQiDianUserData(pActor)
|
||||
userData.ReqGiftMainType = DataPack.readByte(packet)
|
||||
if not userData.ReqGiftMainType or userData.ReqGiftMainType < 1 or userData.ReqGiftMainType > 2 then
|
||||
print("[Tip] ActivityType10028 OnReqQiDianGift not userData.ReqGiftMainType or userData.ReqGiftMainType < 1 or userData.ReqGiftMainType > 2")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqGiftMainType then -- 获取SVIP礼包领取标志
|
||||
CheckSVIPGift(pActor)
|
||||
elseif 2 == userData.ReqGiftMainType then -- 获取手机绑定礼包
|
||||
SendBindPhoneGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqQiDianLogin, OnReqQiDianLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqQiDianGift, OnReqQiDianGift)
|
||||
@@ -0,0 +1,270 @@
|
||||
module("ActivityType10029", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
LoginType = 0 or 1 爱奇艺 登录类型(1:游戏盒子登录)
|
||||
ReqMainGiftType 爱奇艺 请求奖励主类型:1:领取盒子下载 礼包领取;2:检查 微信礼包码 领取;3:检查 SVIP礼包码 领取;4:检查 QQ群礼包码 领取
|
||||
DownLoadBoxGiftFlag = 0 or 1 爱奇艺 盒子下载 礼包领取标志
|
||||
WeChatGiftFlag = 0 or 1 爱奇艺 微信礼包码 礼包领取标志
|
||||
SVIPGiftFlag = 0 or 1 爱奇艺 SVIP礼包码 礼包领取标志
|
||||
QQGroupGiftFlag = 0 or 1 爱奇艺 QQ群礼包码 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10029
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformaiqiyiConfig
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
function GetAiQiYiUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.AiQiYiUserData then
|
||||
var.AiQiYiUserData = {}
|
||||
end
|
||||
return var.AiQiYiUserData
|
||||
end
|
||||
|
||||
function SendAiQiYiUserData(pActor)
|
||||
print("[Tip] ActivityType10029 SendAiQiYiUserData")
|
||||
local userData = GetAiQiYiUserData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSendAiQiYiUserData)
|
||||
if npack then
|
||||
DataPack.writeByte(npack, userData.DownLoadBoxGiftFlag)
|
||||
DataPack.writeByte(npack, userData.WeChatGiftFlag)
|
||||
DataPack.writeByte(npack, userData.SVIPGiftFlag)
|
||||
DataPack.writeByte(npack, userData.QQGroupGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 发送 爱奇艺微端下载奖励
|
||||
function SendDownLoadBoxGift(pActor)
|
||||
print("[Tip] ActivityType10029 SendDownLoadBoxGift")
|
||||
|
||||
local userData = GetAiQiYiUserData(pActor)
|
||||
if not userData.LoginType then
|
||||
print("[Tip] ActivityType10029 SendDownLoadBoxGift not userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.DownLoadBoxGiftFlag then
|
||||
print("[Tip] ActivityType10029 SendDownLoadBoxGift already get DownLoadBoxGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.rewardClient then
|
||||
print("[Tip] ActivityType10029 SendDownLoadBoxGift not ActivityConfig or not ActivityConfig.rewardClient")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10029 SendDownLoadBoxGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.DownLoadBoxGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.rewardClient, GameLog.Log_Activity10029)
|
||||
|
||||
SendAiQiYiUserData(pActor)
|
||||
end
|
||||
|
||||
-- 检查玩家 微信礼包码 领取状态
|
||||
function CheckWeChatGift(pActor)
|
||||
print("[Tip] ActivityType10029 CheckWeChatGift")
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.wechat then
|
||||
print("[Tip] ActivityType10029 CheckWeChatGift")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = GetAiQiYiUserData(pActor)
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.wechat] then
|
||||
userData.WeChatGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckWeChatGift not cdkdata.codeTypeTimes[ActivityConfig.wechat]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckWeChatGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckWeChatGift not cdkdata")
|
||||
end
|
||||
|
||||
SendAiQiYiUserData(pActor)
|
||||
end
|
||||
|
||||
-- 检查玩家 SVIP礼包码 领取状态
|
||||
function CheckSVIPGift(pActor)
|
||||
print("[Tip] ActivityType10029 CheckSVIPGift")
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.SVIP then
|
||||
print("[Tip] ActivityType10029 CheckSVIPGift")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = GetAiQiYiUserData(pActor)
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.SVIP] then
|
||||
userData.SVIPGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckSVIPGift not cdkdata.codeTypeTimes[ActivityConfig.SVIP]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckSVIPGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckSVIPGift not cdkdata")
|
||||
end
|
||||
|
||||
SendAiQiYiUserData(pActor)
|
||||
end
|
||||
|
||||
-- 检查玩家 QQ群礼包码 领取状态
|
||||
function CheckQQGroupGift(pActor)
|
||||
print("[Tip] ActivityType10029 CheckQQGroupGift")
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.QQ then
|
||||
print("[Tip] ActivityType10029 CheckQQGroupGift")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = GetAiQiYiUserData(pActor)
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.QQ] then
|
||||
userData.QQGroupGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckQQGroupGift not cdkdata.codeTypeTimes[ActivityConfig.QQ]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckQQGroupGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10029 CheckQQGroupGift not cdkdata")
|
||||
end
|
||||
|
||||
SendAiQiYiUserData(pActor)
|
||||
end
|
||||
|
||||
-- 爱奇艺玩家登录
|
||||
function OnReqAiQiYiLogin(pActor, packet)
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiLogin")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetAiQiYiUserData(pActor)
|
||||
|
||||
-- 初始化 登录类型
|
||||
userData.LoginType = DataPack.readByte(packet)
|
||||
|
||||
if not userData.LoginType then
|
||||
userData.LoginType = 0
|
||||
end
|
||||
if not userData.ReqMainGiftType then
|
||||
userData.ReqMainGiftType = 0
|
||||
end
|
||||
if nil == userData.DownLoadBoxGiftFlag then
|
||||
userData.DownLoadBoxGiftFlag = 0
|
||||
end
|
||||
if nil == userData.WeChatGiftFlag then
|
||||
userData.WeChatGiftFlag = 0
|
||||
end
|
||||
if nil == userData.SVIPGiftFlag then
|
||||
userData.SVIPGiftFlag = 0
|
||||
end
|
||||
if nil == userData.QQGroupGiftFlag then
|
||||
userData.QQGroupGiftFlag = 0
|
||||
end
|
||||
|
||||
SendAiQiYiUserData(pActor)
|
||||
end
|
||||
|
||||
-- 请求爱奇艺礼包
|
||||
function OnReqAiQiYiGift(pActor, packet)
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiGift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiGift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetAiQiYiUserData(pActor)
|
||||
|
||||
-- 初始化 请求奖励类型
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
|
||||
if not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 4 then
|
||||
print("[Tip] ActivityType10029 OnReqAiQiYiGift not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 4")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then -- 请求 盒子下载 奖励
|
||||
SendDownLoadBoxGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 检查 微信礼包码 领取
|
||||
CheckWeChatGift(pActor)
|
||||
elseif 3 == userData.ReqMainGiftType then -- 检查 SVIP礼包码 领取
|
||||
CheckSVIPGift(pActor)
|
||||
elseif 4 == userData.ReqMainGiftType then -- 检查 QQ群礼包码 领取
|
||||
CheckQQGroupGift(pActor)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqAiQiYiLogin, OnReqAiQiYiLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqAiQiYiGift, OnReqAiQiYiGift)
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
module("ActivityType10030", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
SVIPGiftFlag = 0 or 1 yaodou SVIP 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10029
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformYaodouConfig
|
||||
|
||||
|
||||
function GetYaoDouUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.YaoDouUserData then
|
||||
var.YaoDouUserData = {}
|
||||
end
|
||||
return var.YaoDouUserData
|
||||
end
|
||||
|
||||
function SendYaoDouUserData(pActor)
|
||||
print("[Tip] ActivityType10030 SendYaoDouUserData")
|
||||
local userData = GetYaoDouUserData(pActor)
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, sSendYaoDouUserData)
|
||||
if npack then
|
||||
DataPack.writeByte(npack, userData.SVIPGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 检查玩家 SVIP 礼包领取状态
|
||||
function CheckSVIPGift(pActor)
|
||||
print("[Tip] ActivityType10030 CheckSVIPGift")
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.CDkeytype then
|
||||
print("[Tip] ActivityType10030 CheckSVIPGift")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = GetYaoDouUserData(pActor)
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.CDkeytype] then
|
||||
userData.SVIPGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10030 CheckSVIPGift not cdkdata.codeTypeTimes[ActivityConfig.CDkeytype]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10030 CheckSVIPGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10030 CheckSVIPGift not cdkdata")
|
||||
end
|
||||
|
||||
SendYaoDouUserData(pActor)
|
||||
end
|
||||
|
||||
-- yaodou玩家登录
|
||||
function OnReqYaoDouLogin(pActor)
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouLogin")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetYaoDouUserData(pActor)
|
||||
|
||||
if nil == userData.SVIPGiftFlag then
|
||||
userData.SVIPGiftFlag = 0
|
||||
end
|
||||
|
||||
SendYaoDouUserData(pActor)
|
||||
end
|
||||
|
||||
-- 请求yaodou礼包
|
||||
function OnReqYaoDouGift(pActor)
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouGift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10030 OnReqYaoDouGift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
CheckSVIPGift(pActor)
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqYaoDouLogin, OnReqYaoDouLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqYaoDouGift, OnReqYaoDouGift)
|
||||
@@ -0,0 +1,553 @@
|
||||
module("ActivityType10031", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
PlatformLoginType = 0 ~ 3 贪玩 设备登录类型 pc:(0:网页登录;1:盒子登录);2:手机登录;
|
||||
ReqMainGiftType 贪玩 请求奖励类型 1:获取SVIP礼包领取状态;2:获取 绑定手机礼包;3:获取 QQ群 礼包 领取状态;4:获取 微信礼包 领取状态;5:获取 实名认证 礼包;6:获取 盒子下载 礼包;7:获取 三端互通 礼包
|
||||
|
||||
RealNameAuth = 0 or 1 贪玩 实名认证 0:未实名认证;1:已实名认证
|
||||
BindPhone = 0 or 1 贪玩 绑定手机 0:未绑定手机;1:已绑定手机
|
||||
Age = 贪玩 年龄
|
||||
|
||||
PlatformLoginFlag 贪玩 设备登录类型标志
|
||||
SVIPGiftFlag = 0 or 1 贪玩 SVIP 礼包领取标志
|
||||
BindPhoneGiftFlag = 0 or 1 贪玩 绑定手机 礼包领取标志
|
||||
QQGroupeGiftFlag = 0 or 1 贪玩 QQ群 礼包领取标志
|
||||
WeChatGiftFlag = 0 or 1 贪玩 微信 礼包领取标志
|
||||
RealNameAuthGiftFlag = 0 or 1 贪玩 实名认证 礼包领取标志
|
||||
DownLoadBoxGiftFlag = 0 or 1 贪玩 盒子下载 礼包领取标志
|
||||
PlatformLoginGiftFlag = 贪玩 三端互通 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10031
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformTanwanConfig
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
local HttpStatus = {
|
||||
Failure = "0", -- 请求失败
|
||||
Success = "1", -- 获取成功
|
||||
}
|
||||
|
||||
|
||||
-- 服务接口
|
||||
Host = "www.tanwan.com"
|
||||
Api = "/api/check_bind_idcard.php"
|
||||
Port = ActivityConfig.port or "80"
|
||||
|
||||
function GetTanWanUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.TanWanUserData then
|
||||
var.TanWanUserData = {}
|
||||
end
|
||||
return var.TanWanUserData
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 发送数据到客户端
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 发送 贪玩 玩家数据
|
||||
function SendTanWanUserData(pActor)
|
||||
print("[Tip] ActivityType10031 SendTanWanUserData actorName : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSendTanWanGift)
|
||||
if npack then
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
|
||||
DataPack.writeByte(npack, userData.RealNameAuth)
|
||||
DataPack.writeByte(npack, userData.BindPhone)
|
||||
|
||||
DataPack.writeByte(npack, userData.PlatformLoginFlag)
|
||||
DataPack.writeByte(npack, userData.SVIPGiftFlag)
|
||||
DataPack.writeByte(npack, userData.BindPhoneGiftFlag)
|
||||
DataPack.writeByte(npack, userData.QQGroupeGiftFlag)
|
||||
DataPack.writeByte(npack, userData.WeChatGiftFlag)
|
||||
DataPack.writeByte(npack, userData.RealNameAuthGiftFlag)
|
||||
DataPack.writeByte(npack, userData.DownLoadBoxGiftFlag)
|
||||
DataPack.writeByte(npack, userData.PlatformLoginGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 检查玩家 SVIP礼包 领取状态
|
||||
function CheckSVIPGift(pActor)
|
||||
print("[Tip] ActivityType10031 CheckSVIPGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 == userData.SVIPGiftFlag then
|
||||
print("[Tip] ActivityType10031 CheckSVIPGift actorName : "..Actor.getName(pActor).." already get SVIPGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.SVIPReward then
|
||||
print("[Tip] ActivityType10031 CheckSVIPGift not ActivityConfig or not ActivityConfig.SVIPReward")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.SVIPReward] then
|
||||
userData.SVIPGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckSVIPGift actorName : "..Actor.getName(pActor).." not cdkdata.codeTypeTimes[ActivityConfig.SVIPReward]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckSVIPGift actorName : "..Actor.getName(pActor).." not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckSVIPGift actorName : "..Actor.getName(pActor).." not cdkdata")
|
||||
end
|
||||
|
||||
SendTanWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 手机绑定礼包
|
||||
function SendBindPhoneGift(pActor)
|
||||
print("[Tip] ActivityType10031 SendBindPhoneGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
-- print("userData.BindPhone : "..userData.BindPhone)
|
||||
if 0 == userData.BindPhone then
|
||||
print("[Tip] ActivityType10031 SendBindPhoneGift actorName : "..Actor.getName(pActor).." 0 == userData.BindPhone")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.BindPhoneGiftFlag then
|
||||
print("[Tip] ActivityType10031 SendBindPhoneGift actorName : "..Actor.getName(pActor).." already get BindPhoneGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.PhoneReward then
|
||||
print("[Tip] ActivityType10031 SendBindPhoneGift not ActivityConfig or not ActivityConfig.PhoneReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10031 SendBindPhoneGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BindPhoneGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.PhoneReward, GameLog.Log_Activity10031)
|
||||
|
||||
SendTanWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 检查玩家 QQ群礼包 领取状态
|
||||
function CheckQQGroupGift(pActor)
|
||||
print("[Tip] ActivityType10031 CheckQQGroupGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 == userData.QQGroupeGiftFlag then
|
||||
print("[Tip] ActivityType10031 CheckQQGroupGift actorName : "..Actor.getName(pActor).." already get QQGroupeGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.QQReward then
|
||||
print("[Tip] ActivityType10031 CheckQQGroupGift not ActivityConfig or not ActivityConfig.QQReward")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.QQReward] then
|
||||
userData.QQGroupeGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckQQGroupGift actorName : "..Actor.getName(pActor).." not cdkdata.codeTypeTimes[ActivityConfig.QQReward]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckQQGroupGift actorName : "..Actor.getName(pActor).." not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckQQGroupGift actorName : "..Actor.getName(pActor).." not cdkdata")
|
||||
end
|
||||
|
||||
SendTanWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 检查玩家 SVIP礼包 领取状态
|
||||
function CheckWeChatGift(pActor)
|
||||
print("[Tip] ActivityType10031 CheckWeChatGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 == userData.WeChatGiftFlag then
|
||||
print("[Tip] ActivityType10031 CheckWeChatGift actorName : "..Actor.getName(pActor).." already get WeChatGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.WechatReward then
|
||||
print("[Tip] ActivityType10031 CheckWeChatGift not ActivityConfig or not ActivityConfig.WechatReward")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.WechatReward] then
|
||||
userData.WeChatGiftFlag = 1
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckWeChatGift actorName : "..Actor.getName(pActor).." not cdkdata.codeTypeTimes[ActivityConfig.WechatReward]")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckWeChatGift actorName : "..Actor.getName(pActor).." not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("[Tip] ActivityType10031 CheckWeChatGift actorName : "..Actor.getName(pActor).." not cdkdata")
|
||||
end
|
||||
|
||||
SendTanWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 实名认证礼包
|
||||
function SendRealNameAuthGift(pActor)
|
||||
print("[Tip] ActivityType10031 SendRealNameAuthGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
-- print("userData.RealNameAuth : "..userData.RealNameAuth)
|
||||
if 0 == userData.RealNameAuth then
|
||||
print("[Tip] ActivityType10031 SendRealNameAuthGift actorName : "..Actor.getName(pActor).." 0 == userData.RealNameAuth")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.RealNameAuthGiftFlag then
|
||||
print("[Tip] ActivityType10031 SendRealNameAuthGift actorName : "..Actor.getName(pActor).." already get RealNameAuthGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.IdentityReward then
|
||||
print("[Tip] ActivityType10031 SendRealNameAuthGift not ActivityConfig or not ActivityConfig.IdentityReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10031 SendRealNameAuthGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.RealNameAuthGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.IdentityReward, GameLog.Log_Activity10031)
|
||||
|
||||
SendTanWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 盒子下载 礼包
|
||||
function SendDownLoadBoxGift(pActor)
|
||||
print("[Tip] ActivityType10031 SendDownLoadBoxGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 ~= userData.PlatformLoginType then
|
||||
print("[Tip] ActivityType10031 SendDownLoadBoxGift actorName : "..Actor.getName(pActor).." 1 ~= userData.PlatformLoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.DownLoadBoxGiftFlag then
|
||||
print("[Tip] ActivityType10031 SendDownLoadBoxGift actorName : "..Actor.getName(pActor).." already get DownLoadBoxGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.DownLoadBoxGift then
|
||||
print("[Tip] ActivityType10031 SendDownLoadBoxGift not ActivityConfig or not ActivityConfig.DownLoadBoxGift")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10031 SendDownLoadBoxGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.DownLoadGameBoxGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.DownLoadBoxGift, GameLog.Log_Activity10031)
|
||||
|
||||
SendTanWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 三端互通 礼包
|
||||
function SendPlatformLoginGift(pActor)
|
||||
print("[Tip] ActivityType10031 SendPlatformLoginGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 == userData.PlatformLoginGiftFlag then
|
||||
print("[Tip] ActivityType10031 SendPlatformLoginGift actorName : "..Actor.getName(pActor).." already get PlatformLoginGift")
|
||||
return
|
||||
end
|
||||
|
||||
if 4 >= userData.PlatformLoginFlag then
|
||||
print("[Tip] ActivityType10031 SendPlatformLoginGift actorName : "..Actor.getName(pActor).."4 >= userData.PlatformLoginFlag")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.ClientReward then
|
||||
print("[Tip] ActivityType10031 SendPlatformLoginGift not ActivityConfig or not ActivityConfig.ClientReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10031 SendPlatformLoginGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.PlatformLoginGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.ClientReward, GameLog.Log_Activity10031)
|
||||
|
||||
SendTanWanUserData(pActor)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 请求平台玩家数据信息
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 设置 贪玩手机绑定、防沉迷信息
|
||||
function SetTanWanUserInfo(paramPack,content,result)
|
||||
local nActorId = paramPack[1]
|
||||
local pActor = Actor.getActorById(nActorId)
|
||||
if not pActor then
|
||||
print("[Tip] ActivityType10031 SetTanWanUserInfo [" .. nActorId .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[Tip] ActivityType10031 SetTanWanUserInfo [" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[Tip] ActivityType10031 SetTanWanUserInfo [" .. Actor.getName(pActor) .. "] result:"..result)
|
||||
|
||||
if 0 == result then
|
||||
local status = string.match(content,"\"ret\":(%d+)")
|
||||
-- print(status)
|
||||
if (HttpStatus.Success == status) then
|
||||
local strRealNameAuth = string.match(content,"\"is_adult\":(%d+)")
|
||||
local strBindPhone = string.match(content,"\"bind_mobile\":(%d+)")
|
||||
local strAge = string.match(content,"\"Age\":(%d+)")
|
||||
|
||||
local nRealNameAuth = 0
|
||||
local nBindPhone = 0
|
||||
local nAge = 0
|
||||
|
||||
if "null" ~= strRealNameAuth then
|
||||
nRealNameAuth = tonumber(strRealNameAuth)
|
||||
end
|
||||
if "null" ~= strBindPhone then
|
||||
nBindPhone = tonumber(strBindPhone)
|
||||
end
|
||||
if "null" ~= strAge then
|
||||
nAge = tonumber(strAge)
|
||||
end
|
||||
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.RealNameAuth = nRealNameAuth
|
||||
userData.BindPhone = nBindPhone
|
||||
userData.Age = nAge
|
||||
|
||||
-- print(userData.ReqMainGiftType)
|
||||
|
||||
if 0 == userData.ReqMainGiftType then
|
||||
SendTanWanUserData(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 获取 绑定手机 礼包
|
||||
SendBindPhoneGift(pActor)
|
||||
elseif 5 == userData.ReqMainGiftType then -- 获取 实名认证 礼包
|
||||
SendRealNameAuthGift(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 请求 贪玩手机绑定、防沉迷信息
|
||||
function ReqTanWanUserInfo(pActor)
|
||||
print("[Tip] ActivityType10031 ReqTanWanUserInfo actorName : "..Actor.getName(pActor))
|
||||
|
||||
local nActorId = Actor.getActorId(pActor)
|
||||
|
||||
local userid = Actor.getAccount(pActor)
|
||||
local time = os.time()
|
||||
local key = "TWswCMjaS1ba4b1c5cUHFXAzLYy4f5uG"
|
||||
local sign = System.MD5(time..userid..System.MD5(key))
|
||||
|
||||
local req = Api..'?userid='..userid..'&time='..time..'&sign='..sign
|
||||
|
||||
print("[Tip] ActivityType10024 ReqMasterLuUserInfo [" .. Actor.getName(pActor) .. "] : ".. Host)
|
||||
print("[Tip] ActivityType10024 ReqMasterLuUserInfo [" .. Actor.getName(pActor) .. "] : ".. Port)
|
||||
print("[Tip] ActivityType10024 ReqMasterLuUserInfo [" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
SetTanWanUserInfo,
|
||||
{nActorId}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 贪玩 玩家登录
|
||||
function OnReqTanWanLogin(pActor, packet)
|
||||
print("[Tip] ActivityType10031 OnReqTanWanLogin actorName : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
-- 初始化 玩家数据
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.PlatformLoginType = DataPack.readByte(packet)
|
||||
|
||||
if userData.PlatformLoginType < 0 or userData.PlatformLoginType > 2 then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanLogin userData.PlatformLoginType < 0 or userData.PlatformLoginType > 2 actorName : "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
if nil == userData.PlatformLoginType then
|
||||
userData.PlatformLoginType = 0
|
||||
end
|
||||
if nil == userData.ReqMainGiftType then
|
||||
userData.ReqMainGiftType = 0
|
||||
end
|
||||
if nil == userData.RealNameAuth then
|
||||
userData.RealNameAuth = 0
|
||||
end
|
||||
if nil == userData.BindPhone then
|
||||
userData.BindPhone = 0
|
||||
end
|
||||
if nil == userData.Age then
|
||||
userData.Age = 0
|
||||
end
|
||||
if nil == userData.PlatformLoginFlag then
|
||||
userData.PlatformLoginFlag = 0
|
||||
end
|
||||
if nil == userData.SVIPGiftFlag then
|
||||
userData.SVIPGiftFlag = 0
|
||||
end
|
||||
if nil == userData.BindPhoneGiftFlag then
|
||||
userData.BindPhoneGiftFlag = 0
|
||||
end
|
||||
if nil == userData.QQGroupeGiftFlag then
|
||||
userData.QQGroupeGiftFlag = 0
|
||||
end
|
||||
if nil == userData.WeChatGiftFlag then
|
||||
userData.WeChatGiftFlag = 0
|
||||
end
|
||||
if nil == userData.RealNameAuthGiftFlag then
|
||||
userData.RealNameAuthGiftFlag = 0
|
||||
end
|
||||
if nil == userData.DownLoadBoxGiftFlag then
|
||||
userData.DownLoadBoxGiftFlag = 0
|
||||
end
|
||||
if nil == userData.PlatformLoginGiftFlag then
|
||||
userData.PlatformLoginGiftFlag = 0
|
||||
end
|
||||
|
||||
-- print("userData.PlatformLoginType : "..userData.PlatformLoginType)
|
||||
-- print("userData.PlatformLoginFlag 1111 : "..userData.PlatformLoginFlag)
|
||||
if 0 == System.getIntBit(userData.PlatformLoginFlag, userData.PlatformLoginType) then
|
||||
userData.PlatformLoginFlag = System.setIntBit(userData.PlatformLoginFlag, userData.PlatformLoginType, true)
|
||||
-- print("userData.PlatformLoginFlag 2222 : "..userData.PlatformLoginFlag)
|
||||
end
|
||||
|
||||
-- 请求 贪玩平台 用户信息
|
||||
ReqTanWanUserInfo(pActor)
|
||||
end
|
||||
|
||||
|
||||
-- 贪玩 玩家登录
|
||||
function OnReqTanWanGift(pActor, packet)
|
||||
print("[Tip] ActivityType10031 OnReqTanWanGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanGift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
-- 初始化 玩家数据
|
||||
local userData = GetTanWanUserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
|
||||
if not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 7 then
|
||||
print("[Tip] ActivityType10031 OnReqTanWanGift actorName : "..Actor.getName(pActor).." not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 7")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then -- 获取 SVIP 礼包领取状态
|
||||
CheckSVIPGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType or 5 == userData.ReqMainGiftType then -- 获取 绑定手机 或 实名认证礼包
|
||||
ReqTanWanUserInfo(pActor)
|
||||
elseif 3 == userData.ReqMainGiftType then -- 获取 QQ群 礼包领取状态
|
||||
CheckQQGroupGift(pActor)
|
||||
elseif 4 == userData.ReqMainGiftType then -- 获取 微信 礼包领取状态
|
||||
CheckWeChatGift(pActor)
|
||||
elseif 6 == userData.ReqMainGiftType then -- 获取 盒子下载 礼包
|
||||
SendDownLoadBoxGift(pActor)
|
||||
elseif 7 == userData.ReqMainGiftType then -- 获取 三端互通 礼包
|
||||
SendPlatformLoginGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqTanWanLogin, OnReqTanWanLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqTanWanGift, OnReqTanWanGift)
|
||||
@@ -0,0 +1,237 @@
|
||||
module("ActivityType10032", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType 哥们 请求奖励类型 0:默认类型(服务器自用);1:绑定手机奖励
|
||||
|
||||
BindPhone = 0 or 1 哥们 绑定手机 0:未绑定手机;1:已绑定手机
|
||||
BindPhoneGiftFlag = 0 or 1 哥们 绑定手机 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10032
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformGame2Config
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
local HttpStatus = {
|
||||
Error = "0", -- 请求错误
|
||||
Success = "1", -- 用户已绑定手机
|
||||
Failure = "2", -- 用户未绑定手机
|
||||
}
|
||||
|
||||
|
||||
-- 服务接口
|
||||
Host = "ldsht.bigrnet.com"
|
||||
Api = "/game2/user/index"
|
||||
Port = "80"
|
||||
|
||||
|
||||
function GetGame2UserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.Game2UserData then
|
||||
var.Game2UserData = {}
|
||||
end
|
||||
return var.Game2UserData
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 发送数据到客户端
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 发送 Game2 玩家数据
|
||||
function SendGame2UserData(pActor)
|
||||
print("[Tip] ActivityType10032 SendGame2UserData actorName : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSendTaGame2Gift)
|
||||
if npack then
|
||||
local userData = GetGame2UserData(pActor)
|
||||
|
||||
DataPack.writeByte(npack, userData.BindPhone)
|
||||
DataPack.writeByte(npack, userData.BindPhoneGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 Game2 绑定手机 奖励
|
||||
function SendBindPhoneGift(pActor)
|
||||
print("[Tip] ActivityType10032 SendBindPhoneGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetGame2UserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 ~= userData.BindPhone then
|
||||
print("[Tip] ActivityType10032 SendBindPhoneGift actorName : "..Actor.getName(pActor).." 1 ~= userData.BindPhone userData.BindPhone : "..userData.BindPhone)
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.BindPhoneGiftFlag then
|
||||
print("[Tip] ActivityType10032 SendBindPhoneGift actorName : "..Actor.getName(pActor).." already get BindPhoneGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.PhoneReward then
|
||||
print("[Tip] ActivityType10032 SendBindPhoneGift not ActivityConfig or not ActivityConfig.PhoneReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10032 SendBindPhoneGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BindPhoneGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.PhoneReward, GameLog.Log_Activity10032)
|
||||
|
||||
SendGame2UserData(pActor)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 请求平台玩家数据信息
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 设置 Game2 玩家手机绑定状态
|
||||
function SetGame2UserInfo(paramPack,content,result)
|
||||
local nActorId = paramPack[1]
|
||||
local pActor = Actor.getActorById(nActorId)
|
||||
if not pActor then
|
||||
print("[Tip] ActivityType10032 SetGame2UserInfo [" .. nActorId .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[Tip] ActivityType10032 SetGame2UserInfo [" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[Tip] ActivityType10032 SetGame2UserInfo [" .. Actor.getName(pActor) .. "] result:"..result)
|
||||
|
||||
if 0 == result then
|
||||
local status = string.match(content,"\"status\":(%d+)")
|
||||
local userData = GetGame2UserData(pActor)
|
||||
|
||||
if (HttpStatus.Success == status) then
|
||||
userData.BindPhone = tonumber(status)
|
||||
end
|
||||
|
||||
print("status : "..status.." userData.BindPhone : "..userData.BindPhone)
|
||||
|
||||
if 0 == userData.ReqMainGiftType then
|
||||
SendGame2UserData(pActor)
|
||||
elseif 1 == userData.ReqMainGiftType then --请求手机绑定奖励
|
||||
SendBindPhoneGift(pActor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 请求 贪玩手机绑定信息
|
||||
function ReqGame2UserInfo(pActor)
|
||||
local nActorId = Actor.getActorId(pActor)
|
||||
|
||||
local uid = Actor.getAccount(pActor)
|
||||
local req = Api..'?uid='..uid
|
||||
print("[Tip] ActivityType10032 ReqGame2UserInfo [" .. Actor.getName(pActor) .. "] : ".. Host)
|
||||
print("[Tip] ActivityType10032 ReqGame2UserInfo [" .. Actor.getName(pActor) .. "] : ".. Port)
|
||||
print("[Tip] ActivityType10032 ReqGame2UserInfo [" .. Actor.getName(pActor) .. "] : ".. req)
|
||||
|
||||
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
SetGame2UserInfo,
|
||||
{nActorId}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 贪玩 玩家登录
|
||||
function OnReqGame2Login(pActor)
|
||||
print("[Tip] ActivityType10032 OnReqGame2Login actorName : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Login not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Login not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Login not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Login [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
-- 初始化 玩家数据
|
||||
local userData = GetGame2UserData(pActor)
|
||||
if nil == userData.ReqMainGiftType then
|
||||
userData.ReqMainGiftType = 0
|
||||
end
|
||||
if nil == userData.BindPhone then
|
||||
userData.BindPhone = 0
|
||||
end
|
||||
if nil == userData.BindPhoneGiftFlag then
|
||||
userData.BindPhoneGiftFlag = 0
|
||||
end
|
||||
|
||||
-- 请求 贪玩平台 用户信息
|
||||
ReqGame2UserInfo(pActor)
|
||||
end
|
||||
|
||||
-- 贪玩 玩家登录
|
||||
function OnReqGame2Gift(pActor, packet)
|
||||
print("[Tip] ActivityType10032 OnReqGame2Gift actorName : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Gift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Gift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Gift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Gift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
-- 初始化 玩家数据
|
||||
local userData = GetGame2UserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
|
||||
if not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 1 then
|
||||
print("[Tip] ActivityType10032 OnReqGame2Gift actorName : "..Actor.getName(pActor).." not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 1")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then -- 获取 手机绑定 奖励
|
||||
ReqGame2UserInfo(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqGame2Login, OnReqGame2Login)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqGame2Gift, OnReqGame2Gift)
|
||||
@@ -0,0 +1,99 @@
|
||||
module("ActivityType10033", package.seeall)
|
||||
|
||||
|
||||
ActivityType = 10033
|
||||
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY10033
|
||||
|
||||
|
||||
ActivityConfig = Activity10033Config
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("ActivityType10033 OnStart")
|
||||
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
---更新活动数据
|
||||
function OnUpdateActivity(atvId, pActor, nType, nSubType, nValue)
|
||||
print("ActivityType10033 OnUpdateActivity actorName : "..Actor.getName(pActor).." nType : "..nType)
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
|
||||
-- 更新并保存玩家充值排行榜数据
|
||||
RankMgr.SetRank(actorId, RANKING_ID, nType)
|
||||
RankMgr.Save(RANKING_ID)
|
||||
end
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("ActivityType10033 OnEnd atvId : "..atvId)
|
||||
|
||||
if not ActivityConfig or not ActivityConfig[atvId] then
|
||||
print("ActivityType10033 OnEnd not ActivityConfig or not ActivityConfig[atvId]")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].pay or not ActivityConfig[atvId].awardList then
|
||||
print("ActivityType10033 OnEnd not ActivityConfig[atvId].pay or not ActivityConfig[atvId].awardList")
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1 then
|
||||
print("ActivityType10033 OnEnd not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].mailTitle2 or not ActivityConfig[atvId].mailContent2 then
|
||||
print("ActivityType10033 OnEnd not ActivityConfig[atvId].mailTitle2 or not ActivityConfig[atvId].mailContent2")
|
||||
return
|
||||
end
|
||||
|
||||
local rankAward = ActivityConfig[atvId].awardList
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
local startIndex = 1
|
||||
for awardIndex,awardInfo in ipairs(rankAward) do
|
||||
print("awardIndex : "..awardIndex)
|
||||
local rankNum = awardInfo.value
|
||||
if rankNum > itemNum then
|
||||
rankNum = itemNum
|
||||
end
|
||||
for curIndex = startIndex, rankNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, curIndex - 1)
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
local curPayValue = RankMgr.GetValue(actorId, RANKING_ID)
|
||||
|
||||
if curPayValue >= ActivityConfig[atvId].pay then
|
||||
if 1 == awardIndex then
|
||||
SendMail(actorId, ActivityConfig[atvId].mailTitle1, ActivityConfig[atvId].mailContent1, awardInfo.awards)
|
||||
elseif 2 == awardIndex then
|
||||
SendMail(actorId, ActivityConfig[atvId].mailTitle2, ActivityConfig[atvId].mailContent2, awardInfo.awards)
|
||||
end
|
||||
else
|
||||
print("actorId : "..actorId.." curPayValue : "..curPayValue)
|
||||
end
|
||||
end
|
||||
|
||||
startIndex = rankNum + 1
|
||||
if startIndex > itemNum then
|
||||
print("ActivityType10033 (id:"..atvId..") 奖励发完! 一共"..rankNum.."人获得上榜奖励!")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10033.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType10033.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10033.lua")module("ActivityType10033", package.seeall)
|
||||
@@ -0,0 +1,166 @@
|
||||
module("ActivityType10034", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType 2144 请求奖励类型 0:默认类型(服务器自用);1:绑定手机奖励;2:完善资料奖励
|
||||
|
||||
BindPhoneGiftFlag = 0 or 1 2144 绑定手机 礼包领取标志
|
||||
RealNameAuthenGiftFlag = 0 or 1 2144 完善资料 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10034
|
||||
--对应的活动配置
|
||||
ActivityConfig = Platform2144Config
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
function Get2144UserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.UserData2144 then
|
||||
var.UserData2144 = {}
|
||||
end
|
||||
return var.UserData2144
|
||||
end
|
||||
|
||||
-- 发送 2144 玩家数据
|
||||
function Send2144UserData(pActor)
|
||||
print("ActivityType10034 Send2144UserData actorName : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSend2144UserData)
|
||||
if npack then
|
||||
local userData = Get2144UserData(pActor)
|
||||
|
||||
DataPack.writeByte(npack, userData.BindPhoneGiftFlag)
|
||||
DataPack.writeByte(npack, userData.RealNameAuthenGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 手机绑定奖励
|
||||
function SendBindPhoneGift(pActor)
|
||||
print("ActivityType10034 SendBindPhoneGift")
|
||||
|
||||
local userData = Get2144UserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 == userData.BindPhoneGiftFlag then
|
||||
print("ActivityType10034 SendBindPhoneGift already get BindPhoneGift!")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.bindPhoneReward then
|
||||
print("ActivityType10034 SendBindPhoneGift not ActivityConfig or not ActivityConfig.bindPhoneReward!")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10034 SendBindPhoneGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BindPhoneGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.bindPhoneReward, GameLog.Log_Activity10034)
|
||||
|
||||
Send2144UserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 手机绑定奖励
|
||||
function SendRealNameAuthenGift(pActor)
|
||||
print("ActivityType10034 SendRealNameAuthenGift")
|
||||
|
||||
local userData = Get2144UserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if 1 == userData.RealNameAuthenGiftFlag then
|
||||
print("ActivityType10034 SendRealNameAuthenGift already get RealNameAuthenGift!")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.authentication then
|
||||
print("ActivityType10034 SendRealNameAuthenGift not ActivityConfig or not ActivityConfig.authentication!")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10034 SendRealNameAuthenGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.RealNameAuthenGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.authentication, GameLog.Log_Activity10034)
|
||||
|
||||
Send2144UserData(pActor)
|
||||
end
|
||||
|
||||
-- 2144 用户登录
|
||||
function OnReq2144Login(pActor)
|
||||
print("ActivityType10034 OnReq2144Login")
|
||||
|
||||
local userData = Get2144UserData(pActor)
|
||||
if nil == userData.BindPhoneGiftFlag then
|
||||
userData.BindPhoneGiftFlag = 0
|
||||
end
|
||||
if nil == userData.RealNameAuthenGiftFlag then
|
||||
userData.RealNameAuthenGiftFlag = 0
|
||||
end
|
||||
|
||||
Send2144UserData(pActor)
|
||||
end
|
||||
|
||||
-- 请求 2144 奖励
|
||||
function OnReq2144Gift(pActor, packet)
|
||||
print("ActivityType10034 OnReq2144Gift")
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10034 OnReq2144Gift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10034 OnReq2144Gift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10034 OnReq2144Gift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10034 OnReq2144Gift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
-- 初始化 玩家数据
|
||||
local userData = Get2144UserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
|
||||
print(userData.ReqMainGiftType)
|
||||
|
||||
if not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 2 then
|
||||
print("ActivityType10034 OnReq2144Gift not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 2")
|
||||
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then
|
||||
SendBindPhoneGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then
|
||||
SendRealNameAuthenGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq2144Login, OnReq2144Login)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq2144Gift, OnReq2144Gift)
|
||||
@@ -0,0 +1,176 @@
|
||||
module("ActivityType10035", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType 快玩 请求奖励类型 0:默认类型(服务器自用);1:检查SVIP礼包领取标志;2:检查微信礼包领取标志;
|
||||
|
||||
SVIPGiftFlag = 0 or 1 快玩 超级VIP 礼包领取标志
|
||||
WeChatGiftFlag = 0 or 1 快玩 微信礼包 礼包领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10035
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformteeqeeConfig
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
function GetKuaiWanUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.UserDataKuaiWan then
|
||||
var.UserDataKuaiWan = {}
|
||||
end
|
||||
return var.UserDataKuaiWan
|
||||
end
|
||||
|
||||
-- 发送 KuaiWan 玩家数据
|
||||
function SendKuaiWanUserData(pActor)
|
||||
print("[Tip] ActivityType10035 SendKuaiWanUserData actorName : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSendKuaiWanUserData)
|
||||
if npack then
|
||||
local userData = GetKuaiWanUserData(pActor)
|
||||
|
||||
DataPack.writeByte(npack, userData.SVIPGiftFlag)
|
||||
DataPack.writeByte(npack, userData.WeChatGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 查看快玩 SVIP 礼包领取情况
|
||||
function CheckSVIPGift(pActor)
|
||||
print("ActivityType10035 CheckSVIPGift")
|
||||
|
||||
local userData = GetKuaiWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.SVIPReward then
|
||||
print("ActivityType10035 CheckSVIPGift not ActivityConfig or not ActivityConfig.SVIPReward")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.SVIPReward] then
|
||||
userData.SVIPGiftFlag = 1
|
||||
end
|
||||
else
|
||||
print("ActivityType10035 CheckSVIPGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("ActivityType10035 CheckSVIPGift not cdkdata")
|
||||
end
|
||||
|
||||
SendKuaiWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 查看快玩 WeChat 礼包领取情况
|
||||
function CheckWeChatGift(pActor)
|
||||
print("ActivityType10035 CheckWeChatGift")
|
||||
|
||||
local userData = GetKuaiWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.WechatReward then
|
||||
print("ActivityType10035 CheckWeChatGift not ActivityConfig or not ActivityConfig.WechatReward")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 超级vip奖励
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.WechatReward] then
|
||||
userData.WeChatGiftFlag = 1
|
||||
end
|
||||
else
|
||||
print("ActivityType10035 CheckWeChatGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("ActivityType10035 CheckWeChatGift not cdkdata")
|
||||
end
|
||||
|
||||
SendKuaiWanUserData(pActor)
|
||||
end
|
||||
|
||||
|
||||
-- KuaiWan 用户登录
|
||||
function OnReqKuaiWanLogin(pActor)
|
||||
print("ActivityType10035 OnReqKuaiWanLogin ctorName : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetKuaiWanUserData(pActor)
|
||||
if nil == userData.SVIPGiftFlag then
|
||||
userData.SVIPGiftFlag = 0
|
||||
end
|
||||
if nil == userData.WeChatGiftFlag then
|
||||
userData.WeChatGiftFlag = 0
|
||||
end
|
||||
|
||||
SendKuaiWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- KuaiWan 获取奖励领取标志
|
||||
function OnReqKuaiWanGiftFlag(pActor, packet)
|
||||
print("ActivityType10035 OnReqKuaiWanGiftFlag actorName : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanGiftFlag not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanGiftFlag not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanGiftFlag not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10035 OnReqKuaiWanGiftFlag [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetKuaiWanUserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
|
||||
if nil == userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 2 then
|
||||
print("ActivityType10035 OnReqKuaiWanGiftFlag nil == userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 2")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then
|
||||
CheckSVIPGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then
|
||||
CheckWeChatGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqKuaiWanLogin, OnReqKuaiWanLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqKuaiWanGift, OnReqKuaiWanGiftFlag)
|
||||
@@ -0,0 +1,450 @@
|
||||
module("ActivityType10036", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType 顺网 请求奖励类型 0:默认类型(服务器自用);1:获取微信礼包码领取状态;2:获取绑定手机礼包码领取状态;3:获取防沉迷礼包码领取状态;4:领取盒子下载礼包;5:获取登录礼包;6: 领取等级礼包
|
||||
ReqSubGiftType 顺网 请求子奖励类型 0:默认类型(服务器自用);1~7:请求登录奖励的天数 或 请求等级礼包的级数
|
||||
LoginType = 0 ~ 3 顺网 登录类型 盒子登录:3
|
||||
LastLoginTime 上一次登录时间
|
||||
|
||||
|
||||
LoginDays = 1~7 顺网 盒子登录天数
|
||||
WeChatGiftFlag = 0 or 1 顺网 微信礼包 领取标志
|
||||
BindPhoneGiftFlag = 0 or 1 顺网 手机绑定礼包 领取标志
|
||||
FcmGiftFlag = 0 or 1 顺网 防沉迷礼包 领取标志
|
||||
BoxDownLoadGiftFlag = 0 or 1 顺网 盒子下载 领取标志
|
||||
BoxLoginGiftFlag 顺网 登录礼包 领取标志(只能领取七天)
|
||||
BoxLevelGiftFlag(Uint64) 顺网 等级礼包 领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10036
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformshunwangConfig
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
function GetSWUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.UserDataSW then
|
||||
var.UserDataSW = {}
|
||||
end
|
||||
return var.UserDataSW
|
||||
end
|
||||
|
||||
-- 发送 顺网 玩家数据
|
||||
function SendSWUserData(pActor)
|
||||
print("ActivityType10036 SendSWUserData actorName : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSendSWUserData)
|
||||
if npack then
|
||||
local userData = GetSWUserData(pActor)
|
||||
|
||||
-- print("userData.LoginDays 1111")
|
||||
-- print(userData.LoginDays)
|
||||
-- print("userData.LoginDays 2222")
|
||||
|
||||
DataPack.writeUint64(npack, userData.LoginDays)
|
||||
DataPack.writeByte(npack, userData.WeChatGiftFlag)
|
||||
DataPack.writeByte(npack, userData.BindPhoneGiftFlag)
|
||||
DataPack.writeByte(npack, userData.FcmGiftFlag)
|
||||
DataPack.writeByte(npack, userData.BoxDownLoadGiftFlag)
|
||||
DataPack.writeByte(npack, userData.BoxLoginGiftFlag)
|
||||
DataPack.writeUint64(npack, userData.BoxLevelGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 查看 顺网 微信礼包领取情况
|
||||
function CheckWeChatGift(pActor)
|
||||
print("ActivityType10036 CheckWeChatGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.WechatReward then
|
||||
print("ActivityType10036 CheckWeChatGift not ActivityConfig or not ActivityConfig.WechatReward")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 微信礼包
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.WechatReward] then
|
||||
userData.WeChatGiftFlag = 1
|
||||
end
|
||||
else
|
||||
print("ActivityType10036 CheckWeChatGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("ActivityType10036 CheckWeChatGift not cdkdata")
|
||||
end
|
||||
|
||||
SendSWUserData(pActor)
|
||||
end
|
||||
|
||||
-- 查看 顺网 绑定手机礼包领取情况
|
||||
function CheckBindPhoneGift(pActor)
|
||||
print("ActivityType10036 CheckBindPhoneGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.bindPhoneReward then
|
||||
print("ActivityType10036 CheckBindPhoneGift not ActivityConfig or not ActivityConfig.bindPhoneReward")
|
||||
return
|
||||
end
|
||||
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
-- 绑定手机礼包
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.bindPhoneReward] then
|
||||
userData.WeChatGiftFlag = 1
|
||||
end
|
||||
else
|
||||
print("ActivityType10036 CheckBindPhoneGift not cdkdata.codeTypeTimes")
|
||||
end
|
||||
else
|
||||
print("ActivityType10036 CheckBindPhoneGift not cdkdata")
|
||||
end
|
||||
|
||||
SendSWUserData(pActor)
|
||||
end
|
||||
|
||||
-- 查看 顺网 防沉迷礼包领取情况
|
||||
function CheckFcmGift(pActor)
|
||||
print("ActivityType10036 CheckFcmGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
if 1 == userData.FcmGiftFlag then
|
||||
print("ActivityType10036 CheckFcmGift actorName : "..Actor.getName(pActor).." already get FcmGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.FcmReward then
|
||||
print("ActivityType10036 CheckFcmGift not ActivityConfig or not ActivityConfig.FcmReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("ActivityType10036 CheckFcmGift actorName : "..Actor.getName(pActor).." not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.FcmGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.FcmReward, GameLog.Log_Activity10036)
|
||||
|
||||
SendSWUserData(pActor)
|
||||
end
|
||||
|
||||
-- 领取 顺网 盒子下载礼包
|
||||
function SendSWBoxDownLoadGift(pActor)
|
||||
print("ActivityType10036 SendSWBoxDownLoadGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
if not userData.LoginType or 3 ~= userData.LoginType then
|
||||
print("ActivityType10036 SendSWBoxDownLoadGift actorName : "..Actor.getName(pActor).." not userData.LoginType or 3 ~= userData.LoginType")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.BoxDownLoadGiftFlag then
|
||||
print("ActivityType10036 SendSWBoxDownLoadGift actorName : "..Actor.getName(pActor).." already get BoxDownLoadGift")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.downloadBoxReward then
|
||||
print("ActivityType10036 SendSWBoxDownLoadGift not ActivityConfig or not ActivityConfig.downloadBoxReward")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("ActivityType10036 SendSWBoxDownLoadGift actorName : "..Actor.getName(pActor).." not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BoxDownLoadGiftFlag = 1
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.downloadBoxReward, GameLog.Log_Activity10036)
|
||||
|
||||
SendSWUserData(pActor)
|
||||
end
|
||||
|
||||
-- 领取 顺网 盒子登录礼包
|
||||
function SendSWBoxLoginGift(pActor)
|
||||
print("ActivityType10036 SendSWBoxLoginGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if not userData.LoginType or 3 ~= userData.LoginType then
|
||||
print("ActivityType10036 SendSWBoxLoginGift actorName : "..Actor.getName(pActor).." not userData.LoginType or 3 ~= userData.LoginType")
|
||||
|
||||
--重置请求登录奖励天数
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not userData.ReqSubGiftType or userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 7 then
|
||||
print("ActivityType10036 SendSWBoxLoginGift actorName : "..Actor.getName(pActor).." not userData.ReqSubGiftType or userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 7")
|
||||
|
||||
--重置请求登录奖励天数
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType >= userData.LoginDays then
|
||||
print("ActivityType10036 SendSWBoxLoginGift actorName : "..Actor.getName(pActor).." userData.ReqSubGiftType >= userData.LoginDays userData.ReqSubGiftType : "..userData.ReqSubGiftType.." userData.LoginDays : "..userData.LoginDays)
|
||||
|
||||
--重置请求登录奖励天数
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.BoxLoginGiftFlag, userData.ReqSubGiftType - 1) then
|
||||
print("ActivityType10036 SendSWBoxLoginGift actorName : "..Actor.getName(pActor).." already get BoxLoginGift")
|
||||
|
||||
--重置请求登录奖励天数
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.loginGift or not ActivityConfig.loginGift[userData.ReqSubGiftType] or not ActivityConfig.loginGift[userData.ReqSubGiftType].awards then
|
||||
print("ActivityType10036 SendSWBoxLoginGift not ActivityConfig or not ActivityConfig.loginGift or not ActivityConfig.loginGift[userData.ReqSubGiftType] or not ActivityConfig.loginGift[userData.ReqSubGiftType].awards")
|
||||
|
||||
--重置请求登录奖励天数
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10036 SendSWBoxLoginGift actorName : "..Actor.getName(pActor).." not CheckBagIsEnough")
|
||||
|
||||
--重置请求登录奖励天数
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BoxLoginGiftFlag = System.setIntBit(userData.BoxLoginGiftFlag, userData.ReqSubGiftType - 1, true)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.loginGift[userData.ReqSubGiftType].awards, GameLog.Log_Activity10036)
|
||||
|
||||
--重置请求登录奖励天数
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
SendSWUserData(pActor)
|
||||
end
|
||||
|
||||
-- 领取 顺网 盒子等级礼包
|
||||
function SendSWBoxLevelGift(pActor)
|
||||
print("ActivityType10036 SendSWBoxLevelGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if not userData.LoginType or 3 ~= userData.LoginType then
|
||||
print("ActivityType10036 SendSWBoxLevelGift actorName : "..Actor.getName(pActor).." not userData.LoginType or 3 ~= userData.LoginType")
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not userData.ReqSubGiftType or userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 65 then
|
||||
print("ActivityType10036 SendSWBoxLevelGift actorName : "..Actor.getName(pActor).." not userData.ReqSubGiftType or userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > 65")
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.BoxLevelGiftFlag, userData.ReqSubGiftType - 1) then
|
||||
print("ActivityType10036 SendSWBoxLevelGift actorName : "..Actor.getName(pActor).." already get BoxLevelGift")
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.levelGift then
|
||||
print("ActivityType10036 SendSWBoxLevelGift not ActivityConfig or not ActivityConfig.levelGift")
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.levelGift[userData.ReqSubGiftType] or not ActivityConfig.levelGift[userData.ReqSubGiftType].lvl or not ActivityConfig.levelGift[userData.ReqSubGiftType].awards then
|
||||
print("ActivityType10036 SendSWBoxLevelGift not ActivityConfig.levelGift[userData.ReqSubGiftType] or not ActivityConfig.levelGift[userData.ReqSubGiftType].lvl or not ActivityConfig.levelGift[userData.ReqSubGiftType].awards userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
if nLevel < ActivityConfig.levelGift[userData.ReqSubGiftType].lvl then
|
||||
print("ActivityType10036 SendSWBoxLevelGift actorName : "..Actor.getName(pActor).." nLevel < ActivityConfig.levelGift[userData.ReqSubGiftType].lvl userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("[Tip] ActivityType10036 SendSWBoxLevelGift actorName : "..Actor.getName(pActor).." not CheckBagIsEnough")
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.BoxLevelGiftFlag = System.setIntBit(userData.BoxLevelGiftFlag, userData.ReqSubGiftType - 1, true)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.levelGift[userData.ReqSubGiftType].awards, GameLog.Log_Activity10036)
|
||||
|
||||
--重置请求等级奖励等级
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
SendSWUserData(pActor)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 顺网 玩家登录
|
||||
function OnReqSWLogin(pActor, packet)
|
||||
print("ActivityType10036 OnReqSWLogin actorName : "..Actor.getName(pActor))
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("[Tip] ActivityType10036 OnReqSWLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("[Tip] ActivityType10036 OnReqSWLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("[Tip] ActivityType10036 OnReqSWLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("[Tip] ActivityType10036 OnReqSWLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
if nil == userData.WeChatGiftFlag then
|
||||
userData.WeChatGiftFlag = 0
|
||||
end
|
||||
if nil == userData.BindPhoneGiftFlag then
|
||||
userData.BindPhoneGiftFlag = 0
|
||||
end
|
||||
if nil == userData.FcmGiftFlag then
|
||||
userData.FcmGiftFlag = 0
|
||||
end
|
||||
if nil == userData.BoxDownLoadGiftFlag then
|
||||
userData.BoxDownLoadGiftFlag = 0
|
||||
end
|
||||
if nil == userData.BoxLevelGiftFlag then
|
||||
userData.BoxLevelGiftFlag = 0
|
||||
end
|
||||
if nil == userData.BoxLoginGiftFlag then
|
||||
userData.BoxLoginGiftFlag = 0
|
||||
end
|
||||
|
||||
userData.LoginType = DataPack.readByte(packet)
|
||||
|
||||
-- print("userData.LoginType1111")
|
||||
-- print(userData.LoginType)
|
||||
-- print("userData.LoginType2222")
|
||||
|
||||
-- 当天初始化
|
||||
if 3 == userData.LoginType then
|
||||
if nil == userData.LastLoginTime then
|
||||
userData.LastLoginTime = System.getCurrMiniTime()
|
||||
userData.LoginDays = 1
|
||||
--print("第一天")
|
||||
else
|
||||
if not System.isSameDay(userData.LastLoginTime, System.getCurrMiniTime()) then
|
||||
--print("跨一天")
|
||||
userData.LastLoginTime = System.getCurrMiniTime()
|
||||
userData.LoginDays = userData.LoginDays + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SendSWUserData(pActor)
|
||||
end
|
||||
|
||||
function OnReqSWGift(pActor, packet)
|
||||
print("ActivityType10036 OnReqSWGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetSWUserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
userData.ReqSubGiftType = DataPack.readByte(packet)
|
||||
|
||||
if userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 6 then
|
||||
print("ActivityType10036 OnReqSWGift actorName : "..Actor.getName(pActor).." userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 6")
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then -- 1:获取微信礼包码领取状态;
|
||||
CheckWeChatGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 2:获取绑定手机礼包码领取状态;
|
||||
CheckBindPhoneGift(pActor)
|
||||
elseif 3 == userData.ReqMainGiftType then -- 3:获取防沉迷礼包码领取状态;
|
||||
CheckFcmGift(pActor)
|
||||
elseif 4 == userData.ReqMainGiftType then -- 4:领取盒子下载礼包;
|
||||
SendSWBoxDownLoadGift(pActor)
|
||||
elseif 5 == userData.ReqMainGiftType then -- 5:获取登录礼包;
|
||||
SendSWBoxLoginGift(pActor)
|
||||
elseif 6 == userData.ReqMainGiftType then -- 6: 领取等级礼包
|
||||
SendSWBoxLevelGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqSWLogin, OnReqSWLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqSWGift, OnReqSWGift)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,344 @@
|
||||
module("ActivityType10037", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType 迅玩 请求奖励类型 0:默认类型(服务器自用);1:会员专属称号礼包;2:会员特权礼包;3:会员每日礼包;
|
||||
ReqSubGiftType 迅玩 请求子奖励类型 0:默认类型(服务器自用);(1位:白金会员;2位:超级会员;3位:白金年费会员;4位:超级年费会员;)
|
||||
|
||||
MemberTitleGiftFlag = 00000000 32位 迅玩 会员专属称号 领取标志(1位:白金会员;2位:超级会员;3位:白金年费会员;4位:超级年费会员;)
|
||||
MemberPrivilegeGiftFlag = 00000000 32位 迅玩 特权礼包 领取标志(1位:白金会员;2位:超级会员;3位:白金年费会员;4位:超级年费会员;)
|
||||
MemberDailyGiftFlag = 00000000 32位 迅玩 每日礼包 领取标志(1位:白金会员;2位:超级会员;3位:白金年费会员;4位:超级年费会员;)
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10037
|
||||
--对应的活动配置
|
||||
ActivityConfig = PlatformxunwanConfig
|
||||
ActivityTitleConfig = XunwantitleConfig
|
||||
|
||||
|
||||
local PfId = System.getPfId()
|
||||
|
||||
|
||||
function GetXunWanUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.XunWanUserData then
|
||||
var.XunWanUserData = {}
|
||||
end
|
||||
return var.XunWanUserData
|
||||
end
|
||||
|
||||
-- 发送 迅玩 会员礼包领取标志
|
||||
function SendXunWanUserData(pActor)
|
||||
print("ActivityType10037 SendXunWanUserData actorName : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSendXunWanUserData)
|
||||
if npack then
|
||||
local userData = GetXunWanUserData(pActor)
|
||||
|
||||
DataPack.writeUInt(npack, userData.MemberTitleGiftFlag)
|
||||
DataPack.writeUInt(npack, userData.MemberPrivilegeGiftFlag)
|
||||
DataPack.writeUInt(npack, userData.MemberDailyGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 迅玩 会员专属称号礼包
|
||||
function SendXunWanMemberTitleGift(pActor)
|
||||
print("ActivityType10037 SendXunWanMemberTitleGift actorName : "..Actor.getName(pActor))
|
||||
|
||||
local userData = GetXunWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if not userData.ReqSubGiftType or not ActivityTitleConfig then
|
||||
print("ActivityType10037 SendXunWanMemberTitleGift not userData.ReqSubGiftType or not ActivityTitleConfig")
|
||||
|
||||
print(userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > #ActivityTitleConfig then
|
||||
print("ActivityType10037 SendXunWanMemberTitleGift actorName : "..Actor.getName(pActor).." userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > #ActivityTitleConfig userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.MemberTitleGiftFlag, userData.ReqSubGiftType - 1) then
|
||||
print("ActivityType10037 SendXunWanMemberTitleGift actorName : "..Actor.getName(pActor).." already get memberLevel "..userData.ReqSubGiftType.." MemberTitleGift!")
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityTitleConfig[userData.ReqSubGiftType] or not ActivityTitleConfig[userData.ReqSubGiftType].titleReward then
|
||||
print("ActivityType10037 SendXunWanMemberTitleGift not ActivityTitleConfig[userData.ReqSubGiftType] or not ActivityTitleConfig[userData.ReqSubGiftType].titleReward userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("ActivityType10037 SendXunWanMemberTitleGift actorName : "..Actor.getName(pActor).." not CheckBagIsEnough")
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.MemberTitleGiftFlag = System.setIntBit(userData.MemberTitleGiftFlag, userData.ReqSubGiftType - 1, true)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityTitleConfig[userData.ReqSubGiftType].titleReward, GameLog.Log_Activity10037)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
SendXunWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 迅玩 会员特权礼包
|
||||
function SendXunWanMemberPrivilegeGift(pActor)
|
||||
local userData = GetXunWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if not userData.ReqSubGiftType or not ActivityConfig or not ActivityConfig.vipGift then
|
||||
print("ActivityType10037 SendXunWanMemberPrivilegeGift not userData.ReqSubGiftType or not ActivityConfig or not ActivityConfig.vipGift")
|
||||
|
||||
print(userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > #ActivityConfig.vipGift then
|
||||
print("ActivityType10037 SendXunWanMemberPrivilegeGift actorName : "..Actor.getName(pActor).." userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > #ActivityConfig.vipGift userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.MemberPrivilegeGiftFlag, userData.ReqSubGiftType - 1) then
|
||||
print("ActivityType10037 SendXunWanMemberPrivilegeGift actorName : "..Actor.getName(pActor).." already get memberLevel "..userData.ReqSubGiftType.." MemberPrivilegeGift!")
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.vipGift[userData.ReqSubGiftType] or not ActivityConfig.vipGift[userData.ReqSubGiftType].awards then
|
||||
print("ActivityType10037 SendXunWanMemberPrivilegeGift not ActivityConfig.vipGift[userData.ReqSubGiftType] or not ActivityConfig.vipGift[userData.ReqSubGiftType].awards userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("ActivityType10037 SendXunWanMemberPrivilegeGift actorName : "..Actor.getName(pActor).." not CheckBagIsEnough")
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.MemberPrivilegeGiftFlag = System.setIntBit(userData.MemberPrivilegeGiftFlag, userData.ReqSubGiftType - 1, true)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.vipGift[userData.ReqSubGiftType].awards, GameLog.Log_Activity10037)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
SendXunWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 发送 迅玩 会员每日礼包
|
||||
function SendXunWanMemberDailyGift(pActor)
|
||||
local userData = GetXunWanUserData(pActor)
|
||||
userData.ReqMainGiftType = 0
|
||||
|
||||
if not userData.ReqSubGiftType or not ActivityConfig or not ActivityConfig.dailyGift then
|
||||
print("ActivityType10037 SendXunWanMemberDailyGift not userData.ReqSubGiftType or not ActivityConfig or not ActivityConfig.dailyGift")
|
||||
|
||||
print(userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > #ActivityConfig.dailyGift then
|
||||
print("ActivityType10037 SendXunWanMemberDailyGift actorName : "..Actor.getName(pActor).." userData.ReqSubGiftType < 1 or userData.ReqSubGiftType > #ActivityConfig.dailyGift userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.MemberDailyGiftFlag, userData.ReqSubGiftType - 1) then
|
||||
print("ActivityType10037 SendXunWanMemberDailyGift actorName : "..Actor.getName(pActor).." already get memberLevel "..userData.ReqSubGiftType.." MemberDailyGift!")
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig.dailyGift[userData.ReqSubGiftType] or not ActivityConfig.dailyGift[userData.ReqSubGiftType].awards then
|
||||
print("ActivityType10037 SendXunWanMemberDailyGift not ActivityConfig.dailyGift[userData.ReqSubGiftType] or not ActivityConfig.dailyGift[userData.ReqSubGiftType].awards userData.ReqSubGiftType : "..userData.ReqSubGiftType)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,16,tmDefNoBagNum,tstUI) then
|
||||
print("ActivityType10037 SendXunWanMemberDailyGift actorName : "..Actor.getName(pActor).." not CheckBagIsEnough")
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
-- 设置标志
|
||||
userData.MemberDailyGiftFlag = System.setIntBit(userData.MemberDailyGiftFlag, userData.ReqSubGiftType - 1, true)
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.dailyGift[userData.ReqSubGiftType].awards, GameLog.Log_Activity10037)
|
||||
|
||||
--重置(请求奖励子类型与奖励索引相对应)
|
||||
userData.ReqSubGiftType = 0
|
||||
|
||||
SendXunWanUserData(pActor)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 客户端请求协议回调
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 迅玩 玩家登录
|
||||
function OnReqXunWanLogin(pActor)
|
||||
print("ActivityType10037 OnReqXunWanLogin actorName : "..Actor.getName(pActor))
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("ActivityType10037 OnReqXunWanLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("ActivityType10037 OnReqXunWanLogin not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("ActivityType10037 OnReqXunWanLogin not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("ActivityType10037 OnReqXunWanLogin [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetXunWanUserData(pActor)
|
||||
if nil == userData.MemberTitleGiftFlag then
|
||||
userData.MemberTitleGiftFlag = 0
|
||||
end
|
||||
if nil == userData.MemberPrivilegeGiftFlag then
|
||||
userData.MemberPrivilegeGiftFlag = 0
|
||||
end
|
||||
if nil == userData.MemberDailyGiftFlag then
|
||||
userData.MemberDailyGiftFlag = 0
|
||||
end
|
||||
|
||||
SendXunWanUserData(pActor)
|
||||
end
|
||||
|
||||
-- 请求 迅玩 奖励
|
||||
function OnReqXunWanGift(pActor, packet)
|
||||
print("ActivityType10037 OnReqXunWanGift actorName : "..Actor.getName(pActor))
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("ActivityType10037 OnReqXunWanGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig then
|
||||
print("ActivityType10037 OnReqXunWanGift not ActivityConfig")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig.SPID then
|
||||
print("ActivityType10037 OnReqXunWanGift not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("ActivityType10037 OnReqXunWanGift [非本平台活动]")
|
||||
return --非本平台活动
|
||||
end
|
||||
|
||||
local userData = GetXunWanUserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
userData.ReqSubGiftType = DataPack.readByte(packet)
|
||||
|
||||
if not userData.ReqMainGiftType or userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 3 then
|
||||
print("ActivityType10037 OnReqXunWanGift actorName : "..Actor.getName(pActor).." userData.ReqMainGiftType < 1 or userData.ReqMainGiftType > 3")
|
||||
|
||||
print(userData.ReqMainGiftType)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then -- 1:获取会员专属称号礼包;
|
||||
SendXunWanMemberTitleGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 2:获取会员特权礼包;
|
||||
SendXunWanMemberPrivilegeGift(pActor)
|
||||
elseif 3 == userData.ReqMainGiftType then -- 3:会员每日礼包;
|
||||
SendXunWanMemberDailyGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
print("ActivityType10037 OnNewDayArrive actorName : "..Actor.getName(pActor).." 跨 "..ndiffday.." 天")
|
||||
local userData = GetXunWanUserData(pActor)
|
||||
if userData.MemberDailyGiftFlag then
|
||||
userData.MemberDailyGiftFlag = 0
|
||||
SendXunWanUserData(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10037.lua")
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqXunWanLogin, OnReqXunWanLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReqXunWanGift, OnReqXunWanGift)
|
||||
@@ -0,0 +1,379 @@
|
||||
module("ActivityType10038", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
全局活动 神秘福袋
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
awardTime = 神秘福袋开始计时时间
|
||||
onlineTime 在线时长
|
||||
nextAwardIndex = 当前神秘福袋索引
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
status, 活动状态,这个即使服务器重启了,也要保存这个数据
|
||||
nextPrintOnlineDataTime 下次打印玩家在线时长的时间戳
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 10038
|
||||
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity10038Config
|
||||
|
||||
--通知玩家在线时间间隔(单位:秒)
|
||||
PrintOnlineDataInterval = 5
|
||||
|
||||
--活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
Run = 1, --活动中
|
||||
End = 2, --活动结束了
|
||||
}
|
||||
|
||||
--在场景中的玩家
|
||||
actorsInFuben =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [actorId] = actorId
|
||||
--}
|
||||
}
|
||||
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
--请求领取阶段奖励
|
||||
function reqGetPhaseAward(pActor, atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if nil == actorData.awardTime then
|
||||
actorData.awardTime = System.getCurrMiniTime()
|
||||
end
|
||||
|
||||
if nil == actorData.nextAwardIndex then
|
||||
actorData.nextAwardIndex = 1
|
||||
end
|
||||
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if nil == actorsInFuben[atvId][actorId] then
|
||||
print("ActivityType10038 reqGetPhaseAward 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." actorId : "..actorId)
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig[atvId] or not ActivityConfig[atvId].reward or not ActivityConfig[atvId].reward[actorData.nextAwardIndex] then
|
||||
print("ActivityType10038 reqGetPhaseAward not ActivityConfig or not ActivityConfig[atvId] or not ActivityConfig[atvId].reward or not ActivityConfig[atvId].reward[actorData.nextAwardIndex] 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].reward[actorData.nextAwardIndex].time or not ActivityConfig[atvId].reward[actorData.nextAwardIndex].awards then
|
||||
print("ActivityType10038 reqGetPhaseAward not ActivityConfig[atvId].reward[actorData.nextAwardIndex].time or not ActivityConfig[atvId].reward[actorData.nextAwardIndex].awards 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
if actorData.onlineTime >= ActivityConfig[atvId].reward[actorData.nextAwardIndex].time then
|
||||
local awards = ActivityConfig[atvId].reward[actorData.nextAwardIndex].awards
|
||||
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor,1,tmDefNoBagNum,tstUI) then
|
||||
print("ActivityType10038 reqGetPhaseAward not BagEnough 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity10038, "Activity10038onlineAward|"..atvId)
|
||||
actorData.nextAwardIndex = actorData.nextAwardIndex + 1
|
||||
actorData.onlineTime = 0
|
||||
actorData.awardTime = System.getCurrMiniTime()
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
else
|
||||
print("ActivityType10038 reqGetPhaseAward 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." onlineTime : "..actorData.onlineTime.." time : "..ActivityConfig[atvId].reward[actorData.nextAwardIndex].time)
|
||||
end
|
||||
|
||||
print("ActivityType10038 reqGetPhaseAward 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." nextAwardIndex : "..actorData.nextAwardIndex)
|
||||
end
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("ActivityType10038 OnLoad 活动Id :"..atvId)
|
||||
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
cacheData.actors = {}
|
||||
actorsInFuben[atvId] = {}
|
||||
globalData.status = AtvStatus.Run
|
||||
globalData.nextPrintOnlineDataTime = System.getCurrMiniTime() + PrintOnlineDataInterval
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
--print("ActivityType10038 OnInit 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if nil == cacheData.actors then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if nil == actorsInFuben[atvId] then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
|
||||
if actorsInFuben[atvId][actorId] then
|
||||
--print("ActivityType10038 OnInit actorsInFuben[atvId][actorId] 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.awardTime = System.getCurrMiniTime() - (actorData.onlineTime or 0)
|
||||
|
||||
return
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if nil == actorData.awardTime then
|
||||
actorData.awardTime = System.getCurrMiniTime()
|
||||
actorData.onlineTime = 0
|
||||
actorData.nextAwardIndex = 1
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("ActivityType10038 OnStart 活动Id :"..atvId)
|
||||
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if nil == globalData.openTimes then
|
||||
globalData.openTimes = System.getCurrMiniTime()
|
||||
else
|
||||
globalData.openTimes = globalData.openTimes + 1
|
||||
end
|
||||
cacheData.actors = {}
|
||||
actorsInFuben[atvId] = {}
|
||||
globalData.status = AtvStatus.Run
|
||||
globalData.nextPrintOnlineDataTime = System.getCurrMiniTime() + PrintOnlineDataInterval
|
||||
end
|
||||
|
||||
--初始化活动数据
|
||||
function OnLoginGame(atvId, pActor)
|
||||
--print("ActivityType10038 OnLoginGame 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if nil == globalData.status or AtvStatus.Run ~= globalData.status then
|
||||
--print("ActivityType10038 OnLoginGame not globalData.status or AtvStatus.Run ~= globalData.status 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if nil == cacheData.actors then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if nil == actorsInFuben[atvId] then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
|
||||
if actorsInFuben[atvId][actorId] then
|
||||
--print("ActivityType10038 OnInit actorsInFuben[atvId][actorId] 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.awardTime = System.getCurrMiniTime() - (actorData.onlineTime or 0)
|
||||
|
||||
return
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if nil == actorData.awardTime then
|
||||
actorData.awardTime = System.getCurrMiniTime()
|
||||
actorData.onlineTime = 0
|
||||
actorData.nextAwardIndex = 1
|
||||
end
|
||||
end
|
||||
|
||||
--获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
--print("ActivityType10038 OnReqData 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
DataPack.writeUInt(outPack, (data.onlineTime or 0))
|
||||
DataPack.writeByte(outPack, (data.nextAwardIndex or 1))
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
--print("ActivityType10038 OnGetRedPoint 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local nRet = 0
|
||||
local nLimitLv = 0
|
||||
local nLimitZS = 0
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if not globalData.status or AtvStatus.Run ~= globalData.status then
|
||||
--print("ActivityType10038 OnGetRedPoint not globalData.status or AtvStatus.Run ~= globalData.status 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return nRet
|
||||
end
|
||||
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].openParam then
|
||||
nLimitLv = (ActivityConfig[atvId].openParam.level or 0)
|
||||
nLimitZS = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
end
|
||||
|
||||
local nLv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local nZSLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if nZSLv < nLimitZS then
|
||||
--print("ActivityType10038 OnGetRedPoint nZSLv < nLimitZS 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return nRet
|
||||
end
|
||||
if nLv < nLimitLv then
|
||||
--print("ActivityType10038 OnGetRedPoint nLv < nLimitLv 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return nRet
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if not ActivityConfig or not ActivityConfig[atvId] or not ActivityConfig[atvId].reward or not ActivityConfig[atvId].reward[actorData.nextAwardIndex] then
|
||||
--print("ActivityType10038 OnGetRedPoint not ActivityConfig or not ActivityConfig[atvId] or not ActivityConfig[atvId].reward or not ActivityConfig[atvId].reward[actorData.nextAwardIndex] 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).."actorData.nextAwardIndex : "..(actorData.nextAwardIndex or 1))
|
||||
return nRet
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].reward[actorData.nextAwardIndex].time or not actorData.onlineTime or actorData.onlineTime < ActivityConfig[atvId].reward[actorData.nextAwardIndex].time then
|
||||
--print("ActivityType10038 OnGetRedPoint not ActivityConfig[atvId].reward[actorData.nextAwardIndex].time or not actorData.onlineTime or actorData.onlineTime < ActivityConfig[atvId].reward[actorData.nextAwardIndex].time 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).."")
|
||||
return nRet
|
||||
end
|
||||
|
||||
nRet = 1
|
||||
|
||||
return nRet
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
-- print("ActivityType10038 OnUpdate 活动Id :"..atvId.." curTime : "..curTime)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if nil == globalData.status or AtvStatus.Run ~= globalData.status then
|
||||
--print("ActivityType10038 OnUpdate not globalData.status or AtvStatus.Run ~= globalData.status 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
-- 有玩家时才处理
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor then
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if nil == data.awardTime then
|
||||
data.awardTime = System.getCurrMiniTime()
|
||||
end
|
||||
|
||||
data.onlineTime = curTime - data.awardTime
|
||||
|
||||
if curTime > globalData.nextPrintOnlineDataTime then
|
||||
globalData.nextPrintOnlineDataTime = globalData.nextPrintOnlineDataTime + PrintOnlineDataInterval
|
||||
--print("ActivityType10038 OnUpdate 玩家 "..Actor.getName(pActor).." data.onlineTime : "..data.onlineTime)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cGetPhaseAward then --请求获取阶段奖励
|
||||
reqGetPhaseAward(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("ActivityType10038 OnEnd 活动Id :"..atvId)
|
||||
|
||||
-- 有玩家时才处理
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor then
|
||||
ActivityDispatcher.ClearActorData(pActor,atvId)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.status = AtvStatus.End
|
||||
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType10038.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10038.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10038.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType10038.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType10038.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType10038.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10038.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType1.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10038.lua")
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor, ndiffday)
|
||||
print("ActivityType10038 OnNewDayArrive "..Actor.getName(pActor).." 跨 "..ndiffday.." 天")
|
||||
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if nil == runAtvIdList then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
print("ActivityType10038 OnNewDayArrive "..Actor.getName(pActor).." 跨天重置神秘福袋,atvId = "..atvId)
|
||||
|
||||
ActivityDispatcher.ClearActorData(pActor,atvId)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10038.lua")
|
||||
@@ -0,0 +1,328 @@
|
||||
module("ActivityType10039", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动,竞技大乱斗
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
curYBConsumeNum 记录玩家当前元宝消耗数量
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
status, 活动状态,这个即使服务器重启了,也要保存这个数据
|
||||
actors = {actorId,...} 记录活动中的玩家id
|
||||
rankActors = {
|
||||
[actorId] = {
|
||||
modelId, -- 模型Id
|
||||
icon, -- 头像Id
|
||||
helmetId, -- 头盔道具Id
|
||||
soldierSoulAppearance, -- 衣服Id
|
||||
weaponId, -- 武器Id
|
||||
sex, -- 性别
|
||||
}
|
||||
}
|
||||
}
|
||||
]]--
|
||||
|
||||
-- 活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
Load = 0, -- 从数据库加载活动
|
||||
Run = 1, -- 活动中
|
||||
End = 2, -- 结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
|
||||
|
||||
-- 活动类型
|
||||
ActivityType = 10039
|
||||
|
||||
-- 对应的活动配置
|
||||
ActivityConfig = Activity10039Config
|
||||
|
||||
-- 排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY10039
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("ActivityType10039.lua OnLoad atvId : "..atvId)
|
||||
|
||||
if not System.isActivityRunning(atvId) then
|
||||
print("ActivityType10039.lua OnLoad not System.isActivityRunning(atvId) atvId : "..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.status = AtvStatus.Run
|
||||
|
||||
if nil == globalData.actors then
|
||||
globalData.actors = {}
|
||||
end
|
||||
if nil == globalData.rankActors then
|
||||
globalData.rankActors = {}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("ActivityType10039.lua OnInit actorName : "..Actor.getName(pActor).." atvId : "..atvId)
|
||||
end
|
||||
|
||||
-- 玩家登录
|
||||
function OnLoginGame(atvId, pActor)
|
||||
print("ActivityType10039.lua OnLoginGame actorName : "..Actor.getName(pActor).." atvId : "..atvId)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if nil == globalData.status or AtvStatus.Run ~= globalData.status then
|
||||
print("ActivityType10038 OnLoginGame nil == globalData.status or AtvStatus.Run ~= globalData.status 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
local actorId = Actor.getIntProperty(pActor, PROP_ENTITY_ID)
|
||||
if nil == globalData.rankActors then
|
||||
globalData.rankActors = {}
|
||||
end
|
||||
-- 更新消耗排行榜数据
|
||||
if globalData.rankActors[actorId] then
|
||||
globalData.rankActors[actorId] = {}
|
||||
globalData.rankActors[actorId].modelId = Actor.getIntProperty(pActor, PROP_ENTITY_MODELID)
|
||||
globalData.rankActors[actorId].icon = Actor.getIntProperty(pActor, PROP_ENTITY_ICON)
|
||||
globalData.rankActors[actorId].helmetId = Actor.getUserEquipmentInfo(pActor, 3) --type : 3(头盔)
|
||||
globalData.rankActors[actorId].soldierSoulAppearance = Actor.getIntProperty(pActor, PROP_ACTOR_SOLDIERSOULAPPEARANCE)
|
||||
globalData.rankActors[actorId].weaponId = Actor.getIntProperty(pActor, PROP_ACTOR_WEAPON_ID)
|
||||
globalData.rankActors[actorId].sex = Actor.getIntProperty(pActor, PROP_ACTOR_SEX)
|
||||
end
|
||||
|
||||
if nil == globalData.actors then
|
||||
globalData.actors = {}
|
||||
end
|
||||
if globalData.actors[actorId] then
|
||||
print("ActivityType10038 OnLoginGame globalData.actors[actorId] 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
globalData.actors[actorId] = actorId
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.curYBConsumeNum = 0
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("ActivityType10039.lua OnStart atvId : "..atvId)
|
||||
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.actors = {}
|
||||
globalData.rankActors = {}
|
||||
|
||||
globalData.status = AtvStatus.Run
|
||||
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
-- 请求玩家的元宝消耗数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
print("ActivityType10039.lua OnReqData actorName : "..Actor.getName(pActor).." atvId : "..atvId)
|
||||
|
||||
-- 玩家的排名 以及 当前消耗的元宝数
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
DataPack.writeUInt(outPack, (RankMgr.GetValue(actorId, RANKING_ID) or actorData.curYBConsumeNum or 0))
|
||||
DataPack.writeWord(outPack, RankMgr.GetMyRank(pActor, RANKING_ID))
|
||||
|
||||
-- 发送元宝消耗排行榜前三名玩家数据
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if nil == ranking then
|
||||
print("ActivityType10039.lua OnReqData nil == ranking actorName : "..Actor.getName(pActor).." atvId : "..atvId)
|
||||
end
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
if 3 < itemNum then
|
||||
itemNum = 3
|
||||
end
|
||||
|
||||
DataPack.writeByte(outPack, itemNum)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
for index = 1, itemNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, index - 1)
|
||||
if rankItem then
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
local curYBConsumeNum = Ranking.getPoint(rankItem)
|
||||
local actorName = Ranking.getSub(rankItem, 0)
|
||||
DataPack.writeUInt(outPack, actorId or 0)
|
||||
DataPack.writeUInt(outPack, curYBConsumeNum or 0)
|
||||
DataPack.writeString(outPack, actorName or "")
|
||||
|
||||
if globalData.rankActors[actorId] then
|
||||
DataPack.writeUInt(outPack, globalData.rankActors[actorId].modelId or 0)
|
||||
DataPack.writeShort(outPack, globalData.rankActors[actorId].icon or 0)
|
||||
DataPack.writeWord(outPack, globalData.rankActors[actorId].helmetId or 0)
|
||||
DataPack.writeWord(outPack, globalData.rankActors[actorId].soldierSoulAppearance or 0)
|
||||
DataPack.writeShort(outPack, globalData.rankActors[actorId].weaponId or 0)
|
||||
DataPack.writeByte(outPack, globalData.rankActors[actorId].sex or 0)
|
||||
else -- 针对逻辑服重启,有一段时间报错的处理
|
||||
DataPack.writeUInt(outPack, 0)
|
||||
DataPack.writeShort(outPack, 0)
|
||||
DataPack.writeWord(outPack, 0)
|
||||
DataPack.writeWord(outPack, 0)
|
||||
DataPack.writeShort(outPack, 0)
|
||||
DataPack.writeByte(outPack, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求排行榜数据
|
||||
function ReqRankData(pActor, atvId)
|
||||
print("ActivityType10039.lua ReqRankData actorName : "..Actor.getName(pActor).." atvId : "..atvId)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if nil == globalData.status or AtvStatus.Run ~= globalData.status then
|
||||
print("ActivityType10038 ReqRankData nil == globalData.status or AtvStatus.Run ~= globalData.status 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if nil == ranking then
|
||||
print("ActivityType10038 ReqRankData nil == ranking 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
DataPack.writeWord(npack, itemNum)
|
||||
|
||||
for index = 1, itemNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, index - 1)
|
||||
if rankItem then
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
local curYBConsumeNum = Ranking.getPoint(rankItem)
|
||||
local actorName = Ranking.getSub(rankItem, 0)
|
||||
DataPack.writeUInt(npack, actorId)
|
||||
DataPack.writeUInt(npack, curYBConsumeNum)
|
||||
DataPack.writeString(npack, actorName)
|
||||
end
|
||||
end
|
||||
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 更新活动数据
|
||||
function OnUpdateActivity(atvId, pActor, nConsumeYBNum, nYBComsumeRankLimitNum, nValue)
|
||||
print("ActivityType10039.lua OnUpdateActivity actorName : "..Actor.getName(pActor).." atvId : "..atvId.." nConsumeYBNum : "..nConsumeYBNum.." nYBComsumeRankLimitNum : "..nYBComsumeRankLimitNum)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if nil == actorData.curYBConsumeNum then
|
||||
actorData.curYBConsumeNum = 0
|
||||
end
|
||||
actorData.curYBConsumeNum = actorData.curYBConsumeNum + nConsumeYBNum
|
||||
|
||||
if nYBComsumeRankLimitNum <= actorData.curYBConsumeNum then
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
-- 设置排行榜数据
|
||||
RankMgr.SetRank(actorId, RANKING_ID, actorData.curYBConsumeNum)
|
||||
|
||||
-- 保存消耗排行榜数据
|
||||
RankMgr.Save(RANKING_ID)
|
||||
|
||||
-- 保存玩家数据
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.rankActors[actorId] = {}
|
||||
globalData.rankActors[actorId].modelId = Actor.getIntProperty(pActor, PROP_ENTITY_MODELID)
|
||||
globalData.rankActors[actorId].icon = Actor.getIntProperty(pActor, PROP_ENTITY_ICON)
|
||||
globalData.rankActors[actorId].helmetId = Actor.getUserEquipmentInfo(pActor, 3) --Item::itHelmet 头盔
|
||||
globalData.rankActors[actorId].soldierSoulAppearance = Actor.getIntProperty(pActor, PROP_ACTOR_SOLDIERSOULAPPEARANCE)
|
||||
globalData.rankActors[actorId].weaponId = Actor.getIntProperty(pActor, PROP_ACTOR_WEAPON_ID)
|
||||
globalData.rankActors[actorId].sex = Actor.getIntProperty(pActor, PROP_ACTOR_SEX)
|
||||
end
|
||||
|
||||
print("ActivityType10039.lua OnUpdateActivity actorName : "..Actor.getName(pActor).." atvId : "..atvId.." curYBConsumeNum : "..actorData.curYBConsumeNum)
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
print("ActivityType10039.lua OnUpdateActivity actorName : "..Actor.getName(pActor).." atvId : "..atvId)
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cReqRankData then
|
||||
ReqRankData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("ActivityType10039.lua OnEnd atvId : "..atvId)
|
||||
|
||||
-- 检查奖励相关配置
|
||||
if not ActivityConfig or not ActivityConfig[atvId] or not ActivityConfig[atvId] or not ActivityConfig[atvId].reward then
|
||||
print("ActivityType10039.lua OnEnd not ActivityConfig or not ActivityConfig[atvId] or not ActivityConfig[atvId] or not ActivityConfig[atvId].reward atvId : "..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1 or not ActivityConfig[atvId].mailTitle2 or not ActivityConfig[atvId].mailContent2 then
|
||||
print("ActivityType10039.lua OnEnd not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1 or not ActivityConfig[atvId].mailTitle2 or not ActivityConfig[atvId].mailContent2 atvId : "..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
for awardIndex = 1, 4 do
|
||||
if not ActivityConfig[atvId].reward[awardIndex] then
|
||||
print("ActivityType10039.lua OnEnd not ActivityConfig[atvId].reward[awardIndex] atvId : "..atvId.." awardIndex : "..awardIndex)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送奖励
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if nil == ranking then
|
||||
return
|
||||
end
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
for index = 1, itemNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, index - 1)
|
||||
if rankItem then
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
local curYBConsumeNum = Ranking.getPoint(rankItem)
|
||||
local actorName = Ranking.getSub(rankItem, 0)
|
||||
-- 发放前三名奖励
|
||||
if index < 4 then
|
||||
local content = string.format(ActivityConfig[atvId].mailContent1, index)
|
||||
SendMail(actorId, ActivityConfig[atvId].mailTitle1, content, ActivityConfig[atvId].reward[index])
|
||||
else
|
||||
SendMail(actorId, ActivityConfig[atvId].mailTitle2, ActivityConfig[atvId].mailContent2, ActivityConfig[atvId].reward[4])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.actors = {}
|
||||
globalData.rankActors = {}
|
||||
|
||||
globalData.status = AtvStatus.End
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType10039.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType10039.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType10039.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType10039.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType10039.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType10039.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType10039.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType10039.lua")
|
||||
@@ -0,0 +1,218 @@
|
||||
module("ActivityType10040", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
360沙城争霸 平台福利
|
||||
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType = 0(默认值) ~ 2 请求奖励类型 服务器使用
|
||||
ReqSubGiftType1 = 0(默认值) ~ 2 请求奖励子类型 服务器使用
|
||||
LoginType = 0~3 0:网页登录;1:微端登录;2:手机登录;3:360游戏大厅登录
|
||||
LastSignMonthOfYear = 1~12 上一次签到月份
|
||||
|
||||
bigPlayerGiftFlag = 0 or 1 大玩家礼包领取标志
|
||||
monthSingGiftFlag 月份签到领取标志
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--对应的活动配置
|
||||
ActivityConfig = Platform360sccsConfig
|
||||
|
||||
-- 平台Id
|
||||
local PfId = System.getPfId()
|
||||
|
||||
-- 360沙城争霸 获取玩家数据
|
||||
function Get360SCZBUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.UserData360SCZB then
|
||||
var.UserData360SCZB = {}
|
||||
end
|
||||
return var.UserData360SCZB
|
||||
end
|
||||
|
||||
-- 360沙城争霸 发送玩家数据
|
||||
function Send360SCZBUserData(pActor)
|
||||
--print("ActivityType10040.lua Send360SCZBUserData 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSend360SCZBUserData)
|
||||
if npack then
|
||||
local userData = Get360SCZBUserData(pActor)
|
||||
|
||||
DataPack.writeByte(npack, userData.bigPlayerGiftFlag)
|
||||
DataPack.writeUInt(npack, userData.monthSingGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 360沙城争霸 发送大玩家奖励
|
||||
function Send360SCZBBigPlayerGift(pActor)
|
||||
print("ActivityType10040.lua Send360SCZBBigPlayerGift 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.BigPlayer then
|
||||
print("ActivityType10040.lua Send360SCZBBigPlayerGift not ActivityConfig or not ActivityConfig.BigPlayer")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get360SCZBUserData(pActor)
|
||||
if 1 == userData.bigPlayerGiftFlag then
|
||||
print("ActivityType10040.lua Send360SCZBBigPlayerGift 玩家 : "..Actor.getName(pActor).." already get BigPlayerGift")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor, 16, tmDefNoBagNum, tstUI) ~= true then
|
||||
print("ActivityType10040.lua Send360SCZBBigPlayerGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.BigPlayer, GameLog.Log_Activity10040)
|
||||
|
||||
-- 设置标志位
|
||||
userData.bigPlayerGiftFlag = 1
|
||||
|
||||
Send360SCZBUserData(pActor)
|
||||
end
|
||||
|
||||
-- 360沙城争霸 发送签到奖励
|
||||
function Send360SCZBSignGift(pActor)
|
||||
print("ActivityType10040.lua Send360SCZBSignGift 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
local userData = Get360SCZBUserData(pActor)
|
||||
-- 跨月份,清空月份签到领取标志
|
||||
if System.getMonthOfNow() ~= userData.LastSignMonthOfYear then
|
||||
userData.LastSignMonthOfYear = 0
|
||||
userData.monthSingGiftFlag = 0
|
||||
end
|
||||
|
||||
local nDayofMonth = System.getDayOfMonth()
|
||||
if not ActivityConfig or not ActivityConfig.signreward or not ActivityConfig.signreward[nDayofMonth] then
|
||||
print("ActivityType10040.lua Send360SCZBSignGift not ActivityConfig or not ActivityConfig.BigPlayer")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get360SCZBUserData(pActor)
|
||||
if 1 ~= userData.LoginType and 3 ~= userData.LoginType then -- 1:微端登录;3:360大厅登录
|
||||
print("ActivityType10040.lua Send360SCZBSignGift 1 ~= userData.LoginType and 3 ~= userData.LoginType 玩家 : "..Actor.getName(pActor).." userData.LoginType : "..userData.LoginType)
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == System.getIntBit(userData.monthSingGiftFlag, nDayofMonth) then
|
||||
print("ActivityType10040.lua Send360SCZBSignGift 玩家 : "..Actor.getName(pActor).." already get SignGift nDayofMonth : "..nDayofMonth)
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor, 16, tmDefNoBagNum, tstUI) ~= true then
|
||||
print("ActivityType10040.lua Send360SCZBSignGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.signreward[nDayofMonth], GameLog.Log_Activity10040)
|
||||
|
||||
-- 设置标志位
|
||||
userData.monthSingGiftFlag = System.setIntBit(userData.monthSingGiftFlag, nDayofMonth, 1)
|
||||
userData.LastSignMonthOfYear = System.getMonthOfNow()
|
||||
|
||||
Send360SCZBUserData(pActor)
|
||||
end
|
||||
|
||||
-- 360沙城争霸 玩家登录
|
||||
function OnReq360SCZBLogin(pActor, packet)
|
||||
-- print("ActivityType10040.lua OnReq360SCZBLogin 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("ActivityType10040.lua OnReq360SCZBLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig or not ActivityConfig.SPID then
|
||||
print("ActivityType10040.lua OnReq360SCZBLogin not ActivityConfig or not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("ActivityType10040.lua OnReq360SCZBLogin tostring(PfId) ~= tostring(ActivityConfig.SPID) SPID : "..PfId)
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get360SCZBUserData(pActor)
|
||||
userData.LoginType = DataPack.readByte(packet)
|
||||
if nil == userData.LoginType or userData.LoginType < 0 or userData.LoginType > 3 then
|
||||
print("ActivityType10040.lua OnReq360SCZBLogin nil == userData.LoginType or userData.LoginType < 0 or userData.LoginType > 3 玩家 : "..Actor.getName(pActor))
|
||||
print(userData.LoginType)
|
||||
return
|
||||
end
|
||||
if nil == userData.ReqMainGiftType then
|
||||
userData.ReqMainGiftType = 0
|
||||
end
|
||||
if nil == userData.LastSignMonthOfYear then
|
||||
userData.LastSignMonthOfYear = 0
|
||||
end
|
||||
if nil == userData.bigPlayerGiftFlag then
|
||||
userData.bigPlayerGiftFlag = 0
|
||||
end
|
||||
if nil == userData.monthSingGiftFlag then
|
||||
userData.monthSingGiftFlag = 0
|
||||
end
|
||||
|
||||
Send360SCZBUserData(pActor)
|
||||
end
|
||||
|
||||
-- 360沙城争霸 玩家请求平台福利
|
||||
function OnReq360SCZBGift(pActor, packet)
|
||||
print("ActivityType10040.lua OnReq360SCZBGift 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("ActivityType10040.lua OnReq360SCZBGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig or not ActivityConfig.SPID then
|
||||
print("ActivityType10040.lua OnReq360SCZBGift not ActivityConfig or not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("ActivityType10040.lua OnReq360SCZBGift tostring(PfId) ~= tostring(ActivityConfig.SPID) SPID : "..PfId)
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get360SCZBUserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
if not userData.ReqMainGiftType then
|
||||
print("ActivityType10040.lua OnReq360SCZBGift not userData.ReqMainGiftType 玩家 : "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then -- 请求 360沙城争霸大玩家奖励
|
||||
Send360SCZBBigPlayerGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 请求 360沙城争霸签到奖励
|
||||
Send360SCZBSignGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq360SCZBLogin, OnReq360SCZBLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq360SCZBGift, OnReq360SCZBGift)
|
||||
|
||||
|
||||
-- 跨天处理
|
||||
function OnNewDayArrive(pActor, ndiffday)
|
||||
print("ActivityType10040.lua OnNewDayArrive 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
-- 跨月份,清空月份签到领取标志
|
||||
local userData = Get360SCZBUserData(pActor)
|
||||
|
||||
if nil == userData.LastSignMonthOfYear then
|
||||
return
|
||||
end
|
||||
|
||||
if System.getMonthOfNow() ~= userData.LastSignMonthOfYear then
|
||||
userData.LastSignMonthOfYear = 0
|
||||
userData.monthSingGiftFlag = 0
|
||||
|
||||
Send360SCZBUserData(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType10040.lua")
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
module("ActivityType10041", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
2144沙城争霸 平台福利
|
||||
|
||||
个人数据:userData
|
||||
{
|
||||
ReqMainGiftType = 0(默认值) ~ 2 1:手机绑定奖励;2:实名认证奖励
|
||||
|
||||
YBCount = 累计充值元宝数
|
||||
SVIPGiftFlag = 0 or 1 超级VIP奖励标志
|
||||
BindPhoneGiftFlag = 0 or 1 手机绑定奖励标志
|
||||
RealNameGiftFlag = 0 or 1 实名认证奖励标志
|
||||
}
|
||||
]]--
|
||||
|
||||
-- 对应的活动配置
|
||||
ActivityConfig = Platform2144sccsConfig
|
||||
|
||||
-- 平台Id
|
||||
local PfId = System.getPfId()
|
||||
|
||||
-- 2144沙城争霸 获取玩家数据
|
||||
function Get2144SCZBUserData(pActor)
|
||||
local var = Actor.getStaticVar(pActor)
|
||||
if nil == var.UserData2144SCZB then
|
||||
var.UserData2144SCZB = {}
|
||||
end
|
||||
return var.UserData2144SCZB
|
||||
end
|
||||
|
||||
-- 2144沙城争霸 发送玩家数据
|
||||
function Send2144SCZBUserData(pActor)
|
||||
print("ActivityType10041.lua Send2144SCZBUserData 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enPlatforMwelfareID, cSend2144SCZBUserData)
|
||||
if npack then
|
||||
local userData = Get2144SCZBUserData(pActor)
|
||||
|
||||
if ActivityConfig and ActivityConfig.type then
|
||||
local cdkdata = getActorCdkData(pActor)
|
||||
if cdkdata then
|
||||
if cdkdata.codeTypeTimes then
|
||||
if cdkdata.codeTypeTimes[ActivityConfig.type] then
|
||||
userData.SVIPGiftFlag = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DataPack.writeByte(npack, userData.SVIPGiftFlag)
|
||||
DataPack.writeByte(npack, userData.BindPhoneGiftFlag)
|
||||
DataPack.writeByte(npack, userData.RealNameGiftFlag)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 2144沙城争霸 发送手机绑定奖励
|
||||
function Send2144SCZBBindPhoneGift(pActor)
|
||||
print("ActivityType10041.lua Send2144SCZBBindPhoneGift 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.bindPhoneReward then
|
||||
print("ActivityType10041.lua Send2144SCZBBindPhoneGift not ActivityConfig or not ActivityConfig.bindPhoneReward")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get2144SCZBUserData(pActor)
|
||||
if 1 == userData.BindPhoneGiftFlag then
|
||||
print("ActivityType10041.lua Send2144SCZBBindPhoneGift 玩家 : "..Actor.getName(pActor).." already get BindPhoneGift")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor, 16, tmDefNoBagNum, tstUI) ~= true then
|
||||
print("ActivityType10041.lua Send2144SCZBBindPhoneGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.bindPhoneReward, GameLog.Log_Activity10041)
|
||||
|
||||
-- 设置标志位
|
||||
userData.BindPhoneGiftFlag = 1
|
||||
|
||||
Send2144SCZBUserData(pActor)
|
||||
end
|
||||
|
||||
-- 2144沙城争霸 发送手机绑定奖励
|
||||
function Send2144SCZBRealNameGift(pActor)
|
||||
print("ActivityType10041.lua Send2144SCZBRealNameGift 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
if not ActivityConfig or not ActivityConfig.authentication then
|
||||
print("ActivityType10041.lua Send2144SCZBRealNameGift not ActivityConfig or not ActivityConfig.authentication")
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get2144SCZBUserData(pActor)
|
||||
if 1 == userData.RealNameGiftFlag then
|
||||
print("ActivityType10041.lua Send2144SCZBRealNameGift 玩家 : "..Actor.getName(pActor).." already get RealNameGift")
|
||||
return
|
||||
end
|
||||
|
||||
--检测格子 16 : 活动通用
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor, 16, tmDefNoBagNum, tstUI) ~= true then
|
||||
print("ActivityType10041.lua Send2144SCZBRealNameGift not CheckBagIsEnough")
|
||||
return
|
||||
end
|
||||
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig.authentication, GameLog.Log_Activity10041)
|
||||
|
||||
-- 设置标志位
|
||||
userData.RealNameGiftFlag = 1
|
||||
|
||||
Send2144SCZBUserData(pActor)
|
||||
end
|
||||
|
||||
-- 2144沙城争霸 玩家登录
|
||||
function OnReq2144SCZBLogin(pActor, packet)
|
||||
print("ActivityType10041.lua OnReq2144SCZBLogin 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("ActivityType10041.lua OnReq2144SCZBLogin not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig or not ActivityConfig.SPID then
|
||||
print("ActivityType10041.lua OnReq2144SCZBLogin not ActivityConfig or not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("ActivityType10041.lua OnReq2144SCZBLogin tostring(PfId) ~= tostring(ActivityConfig.SPID) SPID : "..PfId)
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get2144SCZBUserData(pActor)
|
||||
if nil == userData.ReqMainGiftType then
|
||||
userData.ReqMainGiftType = 0
|
||||
end
|
||||
if nil == userData.SVIPGiftFlag then
|
||||
userData.SVIPGiftFlag = 0
|
||||
end
|
||||
if nil == userData.BindPhoneGiftFlag then
|
||||
userData.BindPhoneGiftFlag = 0
|
||||
end
|
||||
if nil == userData.RealNameGiftFlag then
|
||||
userData.RealNameGiftFlag = 0
|
||||
end
|
||||
|
||||
Send2144SCZBUserData(pActor)
|
||||
end
|
||||
|
||||
-- 2144沙城争霸 获取玩家数据
|
||||
function OnReq2144SCZBGift(pActor, packet)
|
||||
print("ActivityType10041.lua OnReq2144SCZBGift 玩家 : "..Actor.getName(pActor))
|
||||
|
||||
-- 平台验证
|
||||
if not PfId then
|
||||
print("ActivityType10041.lua OnReq2144SCZBGift not PfId")
|
||||
return
|
||||
end
|
||||
if not ActivityConfig or not ActivityConfig.SPID then
|
||||
print("ActivityType10041.lua OnReq2144SCZBGift not ActivityConfig or not ActivityConfig.SPID")
|
||||
return
|
||||
end
|
||||
if tostring(PfId) ~= tostring(ActivityConfig.SPID) then
|
||||
print("ActivityType10041.lua OnReq2144SCZBGift tostring(PfId) ~= tostring(ActivityConfig.SPID) SPID : "..PfId)
|
||||
return
|
||||
end
|
||||
|
||||
local userData = Get2144SCZBUserData(pActor)
|
||||
userData.ReqMainGiftType = DataPack.readByte(packet)
|
||||
if not userData.ReqMainGiftType then
|
||||
print("ActivityType10041.lua OnReq2144SCZBGift not userData.ReqMainGiftType 玩家 : "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
if 1 == userData.ReqMainGiftType then -- 请求 2144沙城争霸手机绑定奖励
|
||||
Send2144SCZBBindPhoneGift(pActor)
|
||||
elseif 2 == userData.ReqMainGiftType then -- 请求 2144沙城争霸实名认证奖励
|
||||
Send2144SCZBRealNameGift(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq2144SCZBLogin, OnReq2144SCZBLogin)
|
||||
NetmsgDispatcher.Reg(enPlatforMwelfareID, cReq2144SCZBGift, OnReq2144SCZBGift)
|
||||
|
||||
1092
server/cross/LogicServer/data/functions/Activity/ActivityType11.lua
Normal file
1092
server/cross/LogicServer/data/functions/Activity/ActivityType11.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,407 @@
|
||||
module("ActivityType12", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动————材料副本活动
|
||||
进副本扣进入消耗,通关扣取通关消耗及次数;
|
||||
次数与开服天数有关,从配置要求的开服天数以后开始每天叠加不清空;
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 当前的可进入次数
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 12
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity12Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求扫荡
|
||||
--使用扫荡券直接完成领奖
|
||||
function reqsaodang(pActor, atvId, Conf)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
--在材料副本中不能进行扫荡
|
||||
if Actor.getFubenId(pActor) ==Conf.fbId then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已在副本中|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--开服天数不满足
|
||||
if (ActivityConfig[atvId].countstart or 0) > System.getDaysSinceOpenServer() then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:开服天数不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--等级、转身等级限制
|
||||
local limitLv = 0;
|
||||
local limitzsLv = 0 ;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
limitzsLv = (cfg.openParam.zsLevel or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local zsLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if lv < limitLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if zsLv < zsLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:转身不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
-- if Conf.enterExpends then
|
||||
-- consumes = Conf.enterExpends
|
||||
-- if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
-- return
|
||||
-- end
|
||||
-- end
|
||||
|
||||
--检查扫荡所需特殊消耗
|
||||
if Conf.saodangExpends then
|
||||
consumes = Conf.saodangExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
--Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:扫荡卷不足|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if data.count == nil then
|
||||
if (ActivityConfig[atvId].countstart or 0) < System.getDaysSinceOpenServer() then
|
||||
local multi = 1
|
||||
if ActivityConfig[atvId].isFromOpenSrv then
|
||||
multi = System.getDaysSinceOpenServer()
|
||||
multi = multi - (ActivityConfig[atvId].countstart or 0) + 1
|
||||
end
|
||||
|
||||
if multi > 0 then
|
||||
data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
else
|
||||
data.count = 0
|
||||
end
|
||||
else
|
||||
data.count = 0
|
||||
end
|
||||
else
|
||||
if data.count <= 0 then
|
||||
--Actor.sendTipmsg(pActor, "次数没了!", tstUI)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)--次数不足
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--检查背包格子
|
||||
local awards = ActivityConfig[atvId].Persongift
|
||||
--if CommonFunc.Awards.CheckBagGridCount(pActor,awards) ~= true then
|
||||
-- return
|
||||
--end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,11,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- 发放奖励
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity12, "Activity12|"..atvId)
|
||||
|
||||
--Actor.sendTipmsg(pActor, "成功领取奖励!", tstGetItem)
|
||||
|
||||
-- 进入消耗
|
||||
local consumes = Conf.enterExpends
|
||||
-- if consumes then
|
||||
-- CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity12, OldLang.Log.l00093)
|
||||
-- end
|
||||
|
||||
--扫荡附加消耗
|
||||
local saodangconusmes = Conf.saodangExpends
|
||||
if saodangconusmes then
|
||||
CommonFunc.Consumes.Remove(pActor, saodangconusmes, GameLog.Log_Activity12, "材料副本活动|"..atvId)
|
||||
end
|
||||
|
||||
-- 消耗次数
|
||||
data.count = data.count - 1
|
||||
|
||||
Actor.sendTipmsg(pActor, "扫荡成功", tstUI)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId, Conf, inPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
--开服天数不满足
|
||||
if (ActivityConfig[atvId].countstart or 0) > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if Conf.enterExpends then
|
||||
consumes = Conf.enterExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if data.count == nil then
|
||||
if (ActivityConfig[atvId].countstart or 0) < System.getDaysSinceOpenServer() then
|
||||
local multi = 1
|
||||
if ActivityConfig[atvId].isFromOpenSrv then
|
||||
multi = System.getDaysSinceOpenServer()
|
||||
multi = multi - (ActivityConfig[atvId].countstart or 0) + 1
|
||||
end
|
||||
|
||||
if multi > 0 then
|
||||
data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
else
|
||||
data.count = 0
|
||||
end
|
||||
else
|
||||
data.count = 0
|
||||
end
|
||||
|
||||
else
|
||||
if data.count <= 0 then
|
||||
--Actor.sendTipmsg(pActor, "次数没了!", tstUI)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)--次数不足
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
|
||||
--进入副本
|
||||
if ActivityDispatcher.EnterFuben(atvId, pActor, Conf.fbId) ==nil then
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--初始化活动个人数据
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local multi = 1
|
||||
if ActivityConfig[atvId].isFromOpenSrv then
|
||||
multi = System.getDaysSinceOpenServer()
|
||||
multi = multi - (ActivityConfig[atvId].countstart or 0) + 1
|
||||
end
|
||||
|
||||
if multi > 0 then
|
||||
data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
else
|
||||
data.count = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
DataPack.writeInt(outPack, (data.count or 0))
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
--print("[PActivity 12] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
--print("operatecode : "..operaCode)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor,atvId,Conf,inPack)
|
||||
elseif operaCode == ActivityOperate.cReqSaoDang then -- 请求扫荡
|
||||
reqsaodang(pActor,atvId,Conf)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben, pOwner)
|
||||
-- 通关后才消耗门票跟次数
|
||||
if FubenDispatcher.GetReault(pFuben) == 1 then
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Conf = ActivityConfig[atvId]
|
||||
|
||||
-- 补充退出结算
|
||||
OnReqFubenAward(atvId, pFuben, pActor, pActor)
|
||||
|
||||
-- 消耗次数
|
||||
if data.count >0 then
|
||||
data.count = data.count - 1
|
||||
end
|
||||
|
||||
-- 消耗门票
|
||||
local consumes = Conf.enterExpends
|
||||
if consumes then
|
||||
CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity12, "材料副本活动|"..atvId)
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
--活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result, pOwner)
|
||||
--发送成功失败的旗帜
|
||||
if pOwner then
|
||||
if result == 1 then
|
||||
--完成副本任务
|
||||
--Actor.ExOnQuestEvent(pOwner, CQuestData.qtFuben, 12);
|
||||
end
|
||||
local npack = ActivityDispatcher.AllocResultPack(pOwner, atvId, result)
|
||||
if npack then
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动请求结算
|
||||
function OnReqFubenAward(atvId, pFuben, pActor, pOwner)
|
||||
-- 单人副本活动,所有者必须为自己
|
||||
if pOwner == pActor then
|
||||
if FubenDispatcher.GetReault(pFuben) == 1 then
|
||||
local fbcache = FubenDispatcher.GetCacheData(pFuben)
|
||||
if not fbcache.hasGetAward then
|
||||
local awards = ActivityConfig[atvId].Persongift
|
||||
--if CommonFunc.Awards.CheckBagGridCount(pActor,awards) ~= true then
|
||||
-- return
|
||||
--end
|
||||
-- if CommonFunc.Awards.CheckBagIsEnough(pActor,11,tmDefNoBagNum,tstUI) ~= true then
|
||||
-- return
|
||||
-- end
|
||||
-- CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity12, "Activity12")
|
||||
|
||||
--邮件发送奖励
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
local title = "材料副本任务奖励"
|
||||
local content = "恭喜您已完成材料副本任务!"
|
||||
SendMail(actorId, title, content, awards)
|
||||
Actor.sendTipmsg(pActor, "材料副本任务完成,奖励通过邮件发放!", tstGetItem)
|
||||
|
||||
fbcache.hasGetAward = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local ret = 0
|
||||
if data.count and (data.count > 0) then ret = 1 end
|
||||
local limitLv = 0;
|
||||
local limitzsLv = 0 ;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
limitzsLv = (cfg.openParam.zsLevel or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local zsLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if lv < limitLv then ret = 0 end
|
||||
if zsLv < zsLv then ret = 0 end
|
||||
--开服天数不满足
|
||||
--if (ActivityConfig[atvId].countstart or 0) > System.getDaysSinceOpenServer() then
|
||||
-- ret = 0
|
||||
--end
|
||||
return ret
|
||||
end
|
||||
|
||||
function OnCombineSrv(atvId, ndiffDay, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
|
||||
data.count = data.count + (2 * ndiffDay)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnCombineSrv, ActivityType, OnCombineSrv, "ActivityType12.lua")
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType12.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType12.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType12.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType12.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType12.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType12.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqFubenAward, ActivityType, OnReqFubenAward, "ActivityType12.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType12.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[PActivity 12] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
--print("[PActivity 12] "..Actor.getName(pActor).." 跨天加活动次数,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
--跨天还是不满足开服天数要求
|
||||
if (ActivityConfig[atvId].countstart or 0) > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
|
||||
if ActivityConfig[atvId].IsAdd then
|
||||
data.count = data.count + ((ActivityConfig[atvId].count or 1) * ndiffday)
|
||||
--print("----------diffday: "..ndiffday)
|
||||
else
|
||||
data.count = (ActivityConfig[atvId].count or 1)
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType12.lua")
|
||||
@@ -0,0 +1,624 @@
|
||||
module("ActivityType13", package.seeall)
|
||||
math.randomseed(System.getCurrMiniTime())
|
||||
--[[
|
||||
个人活动————驻守任务
|
||||
进副本扣进入消耗,通关扣取通关消耗及次数;
|
||||
次数与开服天数有关,从配置要求的开服天数以后开始每天叠加不清空;
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 当前的可进入次数
|
||||
|
||||
atvStat, 活动状态,0 非进行状态, 1 驻守任务进行中, 2 任务成功
|
||||
sceneIdIndex, 随机分配的本次场景id
|
||||
timeIndex, 本次分配的时间index
|
||||
assignEndTime, 本次分配场景的结束时间
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 13
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity13Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
-----------------------------我是分界线---------------------------
|
||||
-----------------------------功能函数-----------------------------
|
||||
--成功完成邮件发放奖励
|
||||
function onTaskSucc(atvId,pActor,awards)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
--print("-------------------data.count : "..data.count)
|
||||
--邮件发送奖励
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
local title = "驻守任务奖励"
|
||||
local content = "恭喜您已完成驻守任务!"
|
||||
SendMail(actorId, title, content, awards)
|
||||
|
||||
--消耗次数
|
||||
data.count = data.count - 1
|
||||
|
||||
--print("-------------------data.count : "..data.count)
|
||||
Actor.sendTipmsg(pActor, "驻守任务完成,奖励通过邮件发放", tstUI)
|
||||
|
||||
--回到最近的回城点
|
||||
Actor.returnCity(pActor)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
--数据重置
|
||||
data.atvStat = 0
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
|
||||
--发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
--请求扫荡
|
||||
--使用扫荡券直接完成领奖
|
||||
function reqsaodang(pActor, atvId, Conf)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
--开服天数不满足
|
||||
if ActivityConfig[atvId].countstart > System.getDaysSinceOpenServer() then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:开服天数不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--等级、转身等级限制
|
||||
local limitLv = 0;
|
||||
local limitzsLv = 0 ;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
limitzsLv = (cfg.openParam.zsLevel or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local zsLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if lv < limitLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if zsLv < zsLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:转身不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
-- if Conf.enterExpends then
|
||||
-- consumes = Conf.enterExpends
|
||||
-- if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
-- return
|
||||
-- end
|
||||
-- end
|
||||
|
||||
--检查扫荡所需特殊消耗
|
||||
if Conf.saodangExpends then
|
||||
consumes = Conf.saodangExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
--Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:扫荡卷不足|", tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- --次数检查
|
||||
-- if data.count == nil then
|
||||
-- if ActivityConfig[atvId].countstart < System.getDaysSinceOpenServer() then
|
||||
-- local multi = 1
|
||||
-- if ActivityConfig[atvId].isFromOpenSrv then
|
||||
-- multi = System.getDaysSinceOpenServer()
|
||||
-- multi = multi - (ActivityConfig[atvId].countstart) +1
|
||||
-- end
|
||||
|
||||
-- if multi > 0 then
|
||||
-- data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
-- else
|
||||
-- data.count = 0
|
||||
-- end
|
||||
-- else
|
||||
-- data.count = 0
|
||||
-- end
|
||||
-- else
|
||||
if data.count <= 0 then
|
||||
--Actor.sendTipmsg(pActor, "次数没了!", tstUI)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)--次数不足
|
||||
return
|
||||
end
|
||||
-- end
|
||||
|
||||
|
||||
if data.atvStat == 2 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已处于驻守任务中|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
local awards = ActivityConfig[atvId].Persongift
|
||||
|
||||
|
||||
--检查背包格子
|
||||
local awards = ActivityConfig[atvId].Persongift
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,13,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
-- 发放奖励
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity13, "Activity13|"..atvId)
|
||||
|
||||
--邮件发送奖励
|
||||
-- local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
-- local title = "驻守任务"
|
||||
-- local content = "恭喜您已完成驻守任务!"
|
||||
-- SendMail(actorId, title, content, awards)
|
||||
|
||||
-- 消耗次数
|
||||
data.count = data.count - 1
|
||||
|
||||
-- 进入消耗
|
||||
local consumes = Conf.enterExpends
|
||||
-- if consumes then
|
||||
-- CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity13, OldLang.Log.l00093)
|
||||
-- end
|
||||
|
||||
--扫荡附加消耗
|
||||
local saodangconusmes = Conf.saodangExpends
|
||||
if saodangconusmes then
|
||||
CommonFunc.Consumes.Remove(pActor, saodangconusmes, GameLog.Log_Activity13, "驻守任务|"..atvId)
|
||||
end
|
||||
--print("-------------------data.count : "..data.count)
|
||||
Actor.sendTipmsg(pActor, "扫荡成功", tstUI)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
|
||||
--请求进入驻守地图
|
||||
function reqZhuShou(pActor, atvId, Conf)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
--开服天数不满足
|
||||
if ActivityConfig[atvId].countstart > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
|
||||
--等级、转身等级限制
|
||||
local limitLv = 0;
|
||||
local limitzsLv = 0 ;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
limitzsLv = (cfg.openParam.zsLevel or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local zsLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if lv < limitLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if zsLv < zsLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:转身不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if Conf.enterExpends then
|
||||
consumes = Conf.enterExpends
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, consumes, tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--次数检查
|
||||
-- if data.count == nil then
|
||||
-- if ActivityConfig[atvId].countstart < System.getDaysSinceOpenServer() then
|
||||
-- local multi = 1
|
||||
-- if ActivityConfig[atvId].isFromOpenSrv then
|
||||
-- multi = System.getDaysSinceOpenServer()
|
||||
-- multi = multi - (ActivityConfig[atvId].countstart) +1
|
||||
-- end
|
||||
|
||||
-- if multi > 0 then
|
||||
-- data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
-- else
|
||||
-- data.count = 0
|
||||
-- end
|
||||
-- else
|
||||
-- data.count = 0
|
||||
-- end
|
||||
|
||||
-- else
|
||||
if data.count <= 0 then
|
||||
--Actor.sendTipmsg(pActor, "次数没了!", tstUI)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)--次数不足
|
||||
return
|
||||
end
|
||||
--end
|
||||
|
||||
local SceneIndex = 1
|
||||
local timeIndex = 1
|
||||
|
||||
|
||||
if data.atvStat == nil then
|
||||
data.atvStat = 0
|
||||
end
|
||||
|
||||
if data.atvStat == 2 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已处于驻守任务中|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--新进活动状态
|
||||
if data.atvStat ==0 then
|
||||
|
||||
if Conf.sceneTable.count then
|
||||
SceneIndex = math.random(Conf.sceneTable.count)
|
||||
end
|
||||
|
||||
if Conf.durationTime.count then
|
||||
timeIndex = math.random(Conf.durationTime.count)
|
||||
end
|
||||
|
||||
|
||||
if Conf.sceneTable.Table[SceneIndex] then
|
||||
--随机进入场景
|
||||
local mapId = Conf.sceneTable.Table[SceneIndex].mapid
|
||||
local posx = Conf.sceneTable.Table[SceneIndex].x
|
||||
local posy = Conf.sceneTable.Table[SceneIndex].y
|
||||
--随机进入场景
|
||||
Actor.enterScene(pActor , mapId , posx , posy )
|
||||
else
|
||||
--print("enter scene error , please check activity config , atvId= "..atvId)
|
||||
return
|
||||
end
|
||||
data.assignEndTime = System.getCurrMiniTime() + Conf.durationTime.Table[timeIndex]
|
||||
--挑战失败再次进入状态
|
||||
elseif data.atvStat == 1 then
|
||||
|
||||
SceneIndex = data.sceneIdIndex
|
||||
timeIndex = data.timeIndex
|
||||
|
||||
if Conf.sceneTable.Table[SceneIndex] then
|
||||
|
||||
local mapId = Conf.sceneTable.Table[SceneIndex].mapid
|
||||
local posx = Conf.sceneTable.Table[SceneIndex].x
|
||||
local posy = Conf.sceneTable.Table[SceneIndex].y
|
||||
--进入场景
|
||||
Actor.enterScene(pActor, mapId , posx , posy)
|
||||
else
|
||||
--print("enter scene error , please check activity config , atvId= "..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
data.assignEndTime = System.getCurrMiniTime() + Conf.durationTime.Table[timeIndex]
|
||||
end
|
||||
|
||||
--消耗门票
|
||||
if consumes then
|
||||
CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity13, "驻守任务|"..atvId)
|
||||
end
|
||||
--数据设置
|
||||
data.atvStat = 2
|
||||
data.sceneIdIndex = SceneIndex
|
||||
data.timeIndex = timeIndex
|
||||
|
||||
--发送一个活动数据
|
||||
--Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
--协议开始驻守flag
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendzhushoustatus)
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, 66)
|
||||
DataPack.writeUInt(outPack, (Conf.durationTime.Table[timeIndex] or 0))
|
||||
--DataPack.writeUInt(outPack, (data.assignEndTime or 0))
|
||||
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--初始化活动个人数据
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local multi = 1
|
||||
if ActivityConfig[atvId].isFromOpenSrv then
|
||||
multi = System.getDaysSinceOpenServer()
|
||||
|
||||
multi = multi - (ActivityConfig[atvId].countstart) +1
|
||||
end
|
||||
|
||||
if multi > 0 then
|
||||
data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
else
|
||||
data.count = (ActivityConfig[atvId].count or 1)
|
||||
end
|
||||
|
||||
|
||||
data.atvStat = 0
|
||||
data.sceneIdIndex = 1
|
||||
data.timeIndex = 1
|
||||
data.assignEndTime = 0
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
-- if data.count ==nil then
|
||||
-- local multi = 1
|
||||
-- if ActivityConfig[atvId].isFromOpenSrv then
|
||||
-- multi = System.getDaysSinceOpenServer()
|
||||
-- multi = multi - (ActivityConfig[atvId].countstart) +1
|
||||
-- end
|
||||
|
||||
-- if multi > 0 then
|
||||
-- data.count = multi * (ActivityConfig[atvId].count or 1)
|
||||
-- else
|
||||
-- data.count = 0
|
||||
-- end
|
||||
-- end
|
||||
|
||||
if data.atvStat ==nil then data.atvStat = 0 end
|
||||
|
||||
|
||||
DataPack.writeByte(outPack, (data.atvStat or 0))
|
||||
--print("-------------------data.count : "..data.count)
|
||||
DataPack.writeInt(outPack, (data.count or 0))
|
||||
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
--print("[PActivity 13] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
--print("operateCode: "..operaCode)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqZhuShou(pActor,atvId,Conf)
|
||||
elseif operaCode == ActivityOperate.cReqSaoDang then -- 请求扫荡
|
||||
reqsaodang(pActor,atvId,Conf)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime,pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if data.atvStat ==nil then data.atvStat = 0 end
|
||||
|
||||
if data.atvStat == 2 and (data.assignEndTime <= curTime) then
|
||||
local Conf = ActivityConfig[atvId]
|
||||
onTaskSucc(atvId,pActor,Conf.Persongift)
|
||||
end
|
||||
|
||||
math.randomseed(System.getCurrMiniTime())
|
||||
|
||||
end
|
||||
|
||||
--在普通野外地图的活动死亡
|
||||
function OnAtvAreaDeath(atvId, pEntity)
|
||||
if pEntity and (Actor.getEntityType(pEntity) ==enActor) then
|
||||
|
||||
local data = ActivityDispatcher.GetActorData(pEntity, atvId)
|
||||
if data.assignEndTime ~= nil then
|
||||
if (data.assignEndTime > System.getCurrMiniTime()) then
|
||||
if data.atvStat == nil then
|
||||
data.atvStat = 0
|
||||
end
|
||||
if data.atvStat == 2 then
|
||||
data.atvStat = 1
|
||||
Actor.sendTipmsg(pEntity, "|C:0xf56f00&T:驻守任务失败|", tstUI)
|
||||
--协议结束驻守flag
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pEntity, atvId, ActivityOperate.sSendzhushoustatus)
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, 0)
|
||||
DataPack.writeUInt(outPack, 0)
|
||||
--DataPack.writeUInt(outPack, (data.assignEndTime or 0))
|
||||
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动区域需要处理新增区域属性
|
||||
function OnEnterArea(atvId, pActor)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 离开活动区域
|
||||
function OnExitArea(atvId, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if data.assignEndTime ~= nil then
|
||||
if (data.assignEndTime > System.getCurrMiniTime()) then
|
||||
if data.atvStat == nil then
|
||||
data.atvStat = 0
|
||||
end
|
||||
if data.atvStat == 2 then
|
||||
data.atvStat = 1
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:驻守任务失败|", tstUI)
|
||||
--协议结束驻守flag
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendzhushoustatus)
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, 0)
|
||||
DataPack.writeUInt(outPack, 0)
|
||||
--DataPack.writeUInt(outPack, (data.assignEndTime or 0))
|
||||
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local ret = 0
|
||||
if data.count and (data.count > 0) then ret = 1 end
|
||||
local limitLv = 0;
|
||||
local limitzsLv = 0 ;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
limitzsLv = (cfg.openParam.zsLevel or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local zsLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if lv < limitLv then ret = 0 end
|
||||
if zsLv < zsLv then ret = 0 end
|
||||
--开服天数不满足
|
||||
if ActivityConfig[atvId].countstart > System.getDaysSinceOpenServer() then
|
||||
ret = 0
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
function OnCombineSrv(atvId, ndiffDay, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
|
||||
data.count = data.count + (1 * ndiffDay)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnCombineSrv, ActivityType, OnCombineSrv, "ActivityType13.lua")
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnAtvAreaDeath, ActivityType, OnAtvAreaDeath, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterArea, ActivityType, OnEnterArea, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitArea, ActivityType, OnExitArea, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType13.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType13.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
--print("[PActivity 13] "..Actor.getName(pActor).." 跨"..ndiffday.."天")
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
--print("[PActivity 13] "..Actor.getName(pActor).." 跨天加活动次数,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
--跨天还是不满足开服天数要求
|
||||
if ActivityConfig[atvId].countstart > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
--重置玩家活动状态
|
||||
if data.atvStat == nil or data.atvStat == 1 then
|
||||
data.atvStat = 0
|
||||
end
|
||||
|
||||
if ActivityConfig[atvId].isFromOpenSrv then
|
||||
data.count = data.count + ((ActivityConfig[atvId].count or 1) * ndiffday)
|
||||
else
|
||||
data.count = (ActivityConfig[atvId].count or 1)
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function OnUserLogout(pActor,actorId)
|
||||
--local pActor = Actor.getActorById(actorId)
|
||||
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.assignEndTime ~= nil then
|
||||
if (data.assignEndTime > System.getCurrMiniTime()) then
|
||||
if data.atvStat == nil then
|
||||
data.atvStat = 0
|
||||
end
|
||||
if data.atvStat == 2 then
|
||||
data.atvStat = 1
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:驻守任务失败|", tstUI)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType13.lua")
|
||||
ActorEventDispatcher.Reg(aeUserLogout, OnUserLogout, "ActivityType13.lua")
|
||||
|
||||
@@ -0,0 +1,858 @@
|
||||
module("ActivityType14", package.seeall)
|
||||
|
||||
--[[
|
||||
玛法战令
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
award[index]
|
||||
{
|
||||
}
|
||||
int sorce //积分
|
||||
daily --每日
|
||||
ever --永久
|
||||
openTime
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
int nNumber --活动编号
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动状态
|
||||
local AtvType =
|
||||
{
|
||||
Type1 = 1, --普通类型
|
||||
Type2 = 2, --黄金
|
||||
Type3 = 3, --至尊
|
||||
}
|
||||
|
||||
--活动类型
|
||||
ActivityType = 14
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity14Config
|
||||
ActivitySetConfig = ActivitysetConfig
|
||||
ShopCfg = Activity14shopConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
if ActivitySetConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--玩家请求领取奖励
|
||||
function reqGetAward(pActor, atvId ,nType, indexId)
|
||||
-- print("nType.."..(nType or 0).."..indexId.."..indexId);
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
-- local id = Actor.getIntProperty(pActor, PROP_ENTITY_ID);
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:数据异常,请重新登录|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = nil;
|
||||
if ActivityConfig[atvId] then
|
||||
local AtvCfg = ActivityConfig[atvId][(globalData.nNumber or 1)];
|
||||
if AtvCfg then
|
||||
Cfg = AtvCfg[indexId]
|
||||
end
|
||||
end
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local setCfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if setCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local sorce = Actor.getConsume(pActor, setCfg.timer,setCfg.timer)
|
||||
-- local sorce = Actor.getStaticCount(pActor, setCfg.timer)
|
||||
--初始化数据
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
--判断逻辑
|
||||
if sorce < Cfg.accumulate then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件未达成|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--未购买
|
||||
local data = actorData[nType];
|
||||
if data == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:该特权未激活|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--提示已领取无法多次领取
|
||||
if data[indexId] then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取该奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
--检查格子够不够
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,setCfg.bagremain,setCfg.tips,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--普通奖励
|
||||
if Cfg.rewardA and nType == AtvType.Type1 then
|
||||
CommonFunc.GiveCommonAward(pActor, Cfg.rewardA, GameLog.Log_Activity14, "玛法凭证奖励|"..atvId)
|
||||
end
|
||||
--黄金
|
||||
if Cfg.rewardB and nType == AtvType.Type2 then
|
||||
CommonFunc.GiveCommonAward(pActor, Cfg.rewardB, GameLog.Log_Activity14, "黄金凭证奖励|"..atvId)
|
||||
end
|
||||
|
||||
actorData[nType][indexId] = 1;
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
SendZLMoney(pActor);
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
--玩家请求领取奖励
|
||||
function reqGetAllAward(pActor, atvId )
|
||||
-- print("11111.."..atvId);
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:数据异常,请重新登录|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = nil;
|
||||
if ActivityConfig[atvId] then
|
||||
Cfg = ActivityConfig[atvId][(globalData.nNumber or 1)];
|
||||
end
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
-- print("fgfgfgf.."..atvId);
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
-- print("hhhh.."..atvId);
|
||||
local setCfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if setCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local sorce = Actor.getConsume(pActor, setCfg.timer,setCfg.timer)
|
||||
--初始化数据
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
local nSuccess = false;
|
||||
for index = 1, 60 do
|
||||
local cfg = Cfg[index]
|
||||
if cfg and sorce >= cfg.accumulate then
|
||||
if actorData[AtvType.Type1] and actorData[AtvType.Type1][cfg.tokenlevel] == nil then
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,setCfg.bagremain,setCfg.tips,tstUI) ~= true then
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
return
|
||||
end
|
||||
nSuccess = true;
|
||||
if cfg.rewardA then
|
||||
CommonFunc.GiveCommonAward(pActor, cfg.rewardA, GameLog.Log_Activity14, "玛法凭证奖励|"..atvId)
|
||||
end
|
||||
|
||||
actorData[AtvType.Type1][cfg.tokenlevel] = 1;
|
||||
end
|
||||
if actorData[AtvType.Type2] and actorData[AtvType.Type2][cfg.tokenlevel] == nil then
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,setCfg.bagremain,setCfg.tips,tstUI) ~= true then
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
return
|
||||
end
|
||||
nSuccess = true;
|
||||
if cfg.rewardB then
|
||||
CommonFunc.GiveCommonAward(pActor, cfg.rewardB, GameLog.Log_Activity14, "黄金凭证奖励|"..atvId)
|
||||
end
|
||||
|
||||
actorData[AtvType.Type2][cfg.tokenlevel] = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
if nSuccess then
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--购买
|
||||
function buyOrderWarLv(pActor, atvId , lv)
|
||||
-- print("lv.."..lv)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData == nil then
|
||||
return
|
||||
end
|
||||
-- local id = Actor.getIntProperty(pActor,PROP_ENTITY_ID);
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local setCfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if setCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local sorce = Actor.getConsume(pActor, setCfg.timer,setCfg.timer)
|
||||
-- print("sorce.."..sorce)
|
||||
-- local sorce = Actor.getStaticCount(pActor, setCfg.timer)
|
||||
local nowlv = getNowLv(atvId, (globalData.nNumber or 1), (sorce or 0))
|
||||
-- print("nowlv.."..nowlv)
|
||||
nowlv = (nowlv or 0) + lv
|
||||
-- print("add nowlv.."..nowlv)
|
||||
local value = 0;
|
||||
local limitLv = 0;
|
||||
if ActivityConfig[atvId] then
|
||||
local Cfg = ActivityConfig[atvId][(globalData.nNumber or 1)];
|
||||
if Cfg and Cfg[nowlv] then
|
||||
value = Cfg[nowlv].accumulate
|
||||
limitLv = Cfg[nowlv].levellimit
|
||||
end
|
||||
end
|
||||
if Actor.checkActorLevel(pActor, limitLv) ~= true then
|
||||
|
||||
Actor.sendTipmsgWithParams(pActor, tmNeedLv, tstUI, limitLv)
|
||||
return
|
||||
end
|
||||
-- print("value.."..value)
|
||||
value = value - (sorce or 0);
|
||||
-- print("now value.."..value)
|
||||
if value < 0 then
|
||||
value = 0;
|
||||
end
|
||||
|
||||
if value == 0 then
|
||||
return;
|
||||
end
|
||||
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local setCfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if setCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local Cost = {}
|
||||
local cost = {}
|
||||
cost.type = 4
|
||||
cost.id = 4
|
||||
cost.count = value/setCfg.proportion
|
||||
table.insert(Cost, cost);
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, Cost, tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
if Cost and CommonFunc.Consumes.Remove(pActor, Cost, GameLog.Log_Activity14, "购买战令等级|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- sorce = (sorce or 0 ) + value;
|
||||
Actor.giveAward(pActor, setCfg.timer,setCfg.timer,value)
|
||||
-- Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
end
|
||||
|
||||
|
||||
--激活
|
||||
function activeOrderWar(pActor, atvId , nType)
|
||||
-- print("nType.."..nType)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
-- local id = Actor.getIntProperty(pActor, PROP_ENTITY_ID)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:数据异常,请重新登录|", tstUI)
|
||||
return;
|
||||
end
|
||||
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
local data = actorData[nType]
|
||||
if data then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:无法重复购买|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if Cfg.mergelimit then
|
||||
if Actor.checkCommonLimit(pActor,
|
||||
(Cfg.mergelimit.level or 0),
|
||||
(Cfg.mergelimit.zsLevel or 0),
|
||||
(Cfg.mergelimit.vip or 0),
|
||||
(Cfg.mergelimit.office or 0) ) == false then
|
||||
Actor.sendTipmsgWithId(pActor, Cfg.vipnotips, tstUI)
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
local cost = {};
|
||||
if (nType == AtvType.Type2 or nType == AtvType.Type3 ) then --黄金凭证价格
|
||||
if actorData[AtvType.Type2] == nil then
|
||||
if Cfg.rewardBPrice then
|
||||
local price = {};
|
||||
price.type = Cfg.rewardBPrice.type
|
||||
price.id = Cfg.rewardBPrice.id
|
||||
price.count = Cfg.rewardBPrice.count
|
||||
table.insert(cost, price)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
if nType == AtvType.Type3 and Cfg.rewardCPrice then -- 至尊凭证价格 包含黄金凭证
|
||||
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,Cfg.VIPbagremain,Cfg.VIPtips,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
if #cost == 0 then
|
||||
table.insert(cost, Cfg.rewardCPrice)
|
||||
else
|
||||
for _, r in pairs(cost) do
|
||||
if r.type == Cfg.rewardCPrice.type and r.id == Cfg.rewardCPrice.id then
|
||||
|
||||
r.count = r.count + Cfg.rewardCPrice.count;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--检查消耗是否满足条件
|
||||
if cost then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, cost ,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
--扣除消耗
|
||||
if cost then
|
||||
if CommonFunc.Consumes.Remove(pActor, cost, GameLog.Log_Activity14, "激活凭证|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if nType == AtvType.Type3 then
|
||||
if actorData[AtvType.Type2] == nil then
|
||||
actorData[AtvType.Type2] = {}
|
||||
end
|
||||
actorData[AtvType.Type3] = {}
|
||||
Actor.giveAward(pActor, Cfg.timer,Cfg.timer, Cfg.VIPintegral)
|
||||
SendAward(pActor,atvId, (globalData.nNumber or 1));
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:至尊凭证激活成功|", tstUI)
|
||||
else
|
||||
actorData[AtvType.Type2] = {}
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:黄金凭证激活成功|", tstUI)
|
||||
end
|
||||
|
||||
local name = Actor.getName(pActor);
|
||||
System.broadTipmsgWithParams(tmAtv14Tips, tstKillDrop, name)
|
||||
System.broadTipmsgWithParams(tmAtv14Tips, tstChatSystem, name)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
end
|
||||
|
||||
|
||||
function SendAward(pActor,atvId, nNumber)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:数据异常,请重新登录|", tstUI)
|
||||
return;
|
||||
end
|
||||
local AtvCfg = Activity14Config[atvId];
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
local Cfg = AtvCfg[(nNumber or 1)];
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg) do
|
||||
|
||||
if cfg.rewardC then
|
||||
CommonFunc.GiveCommonAward(pActor, cfg.rewardC, GameLog.Log_Activity14, "至尊凭证激活奖励|"..atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
function getAwardIndexCfg(atvId, nNumber, indexId)
|
||||
if ActivityConfig then
|
||||
local Cfg = ActivityConfig[atvId][nNumber];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.tokenlevel == indexId then
|
||||
return cfg;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
|
||||
|
||||
function getNowLv(atvId, nNumber, sorce)
|
||||
local lv = 0;
|
||||
if ActivityConfig then
|
||||
local Cfg = ActivityConfig[atvId][nNumber];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if sorce >= cfg.accumulate and cfg.tokenlevel > lv then
|
||||
lv = cfg.tokenlevel;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return lv;
|
||||
end
|
||||
--------------------------我是分界线----------------------------
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
--
|
||||
local AtvOpentime = System.getRunningActivityStartTimeRelToday(atvId);
|
||||
local id = Actor.getStaticCount(pActor, 623);
|
||||
if id ~= atvId then
|
||||
print("[GActivity14 新活动] 战令活动"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
Actor.setStaticCount(pActor,622, 0);--积分清空
|
||||
ActivityDispatcher.ClearActorData(pActor,atvId);
|
||||
Actor.setStaticCount(pActor,623, atvId);
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.openTime = AtvOpentime;
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if AtvOpentime ~= (actorData.openTime or 0) then
|
||||
print("[GActivity14 重复活动] 战令活动"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
Actor.setStaticCount(pActor,622, 0);--积分清空
|
||||
ActivityDispatcher.ClearActorData(pActor,atvId);
|
||||
Actor.setStaticCount(pActor,623, atvId);
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.openTime = AtvOpentime;
|
||||
end
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId)
|
||||
-- print("[activitytype 14] 战令活动---onstart atvId:"..atvId)
|
||||
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
if globalData.openTimes == nil then
|
||||
local currentId = System.getCurrMiniTime();
|
||||
globalData.openTimes = currentId
|
||||
end
|
||||
--初始化
|
||||
local openDay = System.getDaysSinceOpenServer();
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
for _, cfg in pairs(SetCfg) do
|
||||
if openDay >= cfg.openday then
|
||||
globalData.nNumber = cfg.number;
|
||||
end
|
||||
end
|
||||
print("[activitytype 14] 战令活动---onstart atvId: "..(globalData.nNumber or 0))
|
||||
-- ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
|
||||
end
|
||||
--商城
|
||||
function SendShopInfo(pActor, atvId)
|
||||
local nMaxLen = 0
|
||||
if ShopCfg then
|
||||
nMaxLen = #ShopCfg;
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData.daily == nil then
|
||||
actorData.daily = {}
|
||||
end
|
||||
if actorData.ever == nil then
|
||||
actorData.ever = {}
|
||||
end
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sZLShopInfo)
|
||||
if npack and ShopCfg then
|
||||
local value = Actor.getStaticCount(pActor, 624);--战令积分
|
||||
DataPack.writeInt(npack, value);
|
||||
DataPack.writeWord(npack, nMaxLen);
|
||||
|
||||
for _, cfg in pairs(ShopCfg) do
|
||||
DataPack.writeWord(npack, cfg.shopid)
|
||||
local nLeftTime = -1;
|
||||
if cfg.limittimes then
|
||||
if cfg.daily then
|
||||
nLeftTime = cfg.limittimes - (actorData.daily[cfg.shopid] or 0)
|
||||
else
|
||||
nLeftTime = cfg.limittimes - (actorData.ever[cfg.shopid] or 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
DataPack.writeShort(npack, nLeftTime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--战令币更新
|
||||
function SendZLMoney(pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sZLBuyShop)
|
||||
if npack then
|
||||
local value = Actor.getStaticCount(pActor, 624);--战令积分
|
||||
DataPack.writeInt(npack, (value or 0))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
function SendZLShopChange(pActor, index, times)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sZLShopChange)
|
||||
if npack then
|
||||
DataPack.writeWord(npack, index)
|
||||
DataPack.writeShort(npack, times)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
--购买
|
||||
function BuyShop(pActor, atvId, index, Count)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if ShopCfg[index] == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if ShopCfg[index].showlimit then
|
||||
if Actor.checkCommonLimit(pActor,
|
||||
(ShopCfg[index].showlimit.level or 0),
|
||||
(ShopCfg[index].showlimit.zsLevel or 0),
|
||||
(ShopCfg[index].showlimit.vip or 0),
|
||||
(ShopCfg[index].showlimit.office or 0) ) == false then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件不满足|", tstUI)
|
||||
return;
|
||||
end
|
||||
end
|
||||
if ShopCfg[index].limittimes then
|
||||
local nBuyTimes = 0;
|
||||
if cfg.daily then
|
||||
nBuyTimes = (actorData.daily[cfg.shopid] or 0)
|
||||
else
|
||||
nBuyTimes = (actorData.ever[cfg.shopid] or 0)
|
||||
end
|
||||
|
||||
if (nBuyTimes + Count) > ShopCfg[index].limittimes then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:次数已达上限|", tstUI)
|
||||
return;
|
||||
end
|
||||
end
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, ShopCfg[index].price,tstUI) ~= true then
|
||||
return;
|
||||
end
|
||||
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,8,tmLeftBagNumNotEnough,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
CommonFunc.Consumes.Remove(pActor, ShopCfg[index].price, GameLog.Log_Activity14, "战令商店")
|
||||
CommonFunc.GiveCommonAward(pActor, ShopCfg[index].shop, GameLog.Log_Activity14, "战令商店")
|
||||
if ShopCfg[index].limittimes then
|
||||
local nLeftTime = ShopCfg[index].limittimes;
|
||||
if cfg.daily then
|
||||
actorData.daily[ShopCfg[index].shopid] = (actorData.daily[ShopCfg[index].shopid] or 0) + Count
|
||||
nLeftTime = nLeftTime - (actorData.daily[ShopCfg[index].shopid] or 0)
|
||||
else
|
||||
actorData.ever[ShopCfg[index].shopid] = (actorData.ever[ShopCfg[index].shopid] or 0) + Count
|
||||
nLeftTime = nLeftTime - (actorData.ever[ShopCfg[index].shopid] or 0)
|
||||
end
|
||||
SendZLShopChange(pActor,index, nLeftTime)
|
||||
end
|
||||
SendZLMoney(pActor);
|
||||
end
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cGetZLAward then --请求领取奖励
|
||||
local nType = DataPack.readByte(inPack)
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
reqGetAward(pActor, atvId , nType, indexId)
|
||||
elseif operaCode == ActivityOperate.cActiveOrderWar then --激活
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
activeOrderWar(pActor, atvId , indexId)
|
||||
elseif operaCode == ActivityOperate.cBuyOrderWarLv then --购买等级
|
||||
local lv = DataPack.readByte(inPack)
|
||||
buyOrderWarLv(pActor, atvId , lv)
|
||||
elseif operaCode == ActivityOperate.cGetAllAward then --
|
||||
reqGetAllAward(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cZLShopInfo then --战令商店信息
|
||||
SendShopInfo(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cBuyZLShop then --购买战令商品
|
||||
local index = DataPack.readWord(inPack);
|
||||
local count = DataPack.readWord(inPack);
|
||||
BuyShop(pActor, atvId,index,count)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
-- print("[PActivity14 战令活动 id:.."..atvId.."请求数据]")
|
||||
|
||||
if outPack == nil then
|
||||
return
|
||||
end
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
|
||||
local AtvCfg = ActivityConfig[atvId]
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
Cfg = AtvCfg[(globalData.nNumber or 1)]
|
||||
|
||||
local len = 0;
|
||||
|
||||
if Cfg then
|
||||
len = #Cfg;
|
||||
end
|
||||
|
||||
local SetCfg = ActivitySetConfig[atvId]
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local setCfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if setCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local id = Actor.getStaticCount(pActor, 623);
|
||||
-- print("id.."..id.."..actid.."..atvId)
|
||||
if id ~= atvId then
|
||||
Actor.setStaticCount(pActor,622, 0);--积分清空
|
||||
-- Actor.setStaticCount(pActor,624, 0);--战令币清空
|
||||
ActivityDispatcher.ClearActorData(pActor,atvId);
|
||||
Actor.setStaticCount(pActor,623, atvId);
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
--默认初始1
|
||||
actorData[AtvType.Type1] = {}
|
||||
end
|
||||
if actorData[AtvType.Type1] == nil then
|
||||
actorData[AtvType.Type1] = {}
|
||||
end
|
||||
|
||||
-- print("nNumber.."..(globalData.nNumber or 1))
|
||||
DataPack.writeInt(outPack, atvId)
|
||||
DataPack.writeByte(outPack, (globalData.nNumber or 1))
|
||||
local sorce = Actor.getConsume(pActor, setCfg.timer,setCfg.timer)
|
||||
DataPack.writeInt(outPack, (sorce or 0))
|
||||
-- print("sorce.."..(sorce or 1))
|
||||
local nowlv = getNowLv(atvId, (globalData.nNumber or 1), (sorce or 0))
|
||||
DataPack.writeInt(outPack, (nowlv or 0))
|
||||
local dataType1 = actorData[AtvType.Type1]
|
||||
local dataType2 = actorData[AtvType.Type2]
|
||||
local stateType = 0;
|
||||
if dataType2 then stateType = 1 end;
|
||||
DataPack.writeByte(outPack, (stateType or 0)) --黄金
|
||||
stateType = 0;
|
||||
if actorData[AtvType.Type3] then stateType = 1 end;
|
||||
DataPack.writeByte(outPack, (stateType or 0)) --至尊
|
||||
--长度
|
||||
DataPack.writeByte(outPack, (len or 0))
|
||||
if Cfg then
|
||||
|
||||
for _, cfg in pairs(Cfg) do
|
||||
DataPack.writeByte(outPack, cfg.tokenlevel)
|
||||
local state = 0;
|
||||
if sorce >= cfg.accumulate then
|
||||
state = 2
|
||||
end
|
||||
|
||||
if dataType1 and cfg.rewardA then
|
||||
if dataType1[cfg.tokenlevel] then state = 1 end
|
||||
else state = 0
|
||||
end
|
||||
DataPack.writeByte(outPack, state)
|
||||
if sorce >= cfg.accumulate then state = 2 end
|
||||
|
||||
if dataType2 and cfg.rewardB then
|
||||
if dataType2[cfg.tokenlevel] then state = 1 end
|
||||
else state = 0
|
||||
end
|
||||
-- print("state.."..state)
|
||||
DataPack.writeByte(outPack, state)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[PActivity 14] 活动id.."..atvId.."..结束")
|
||||
|
||||
-- dealMail(atvId);
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
end
|
||||
|
||||
--活动红点
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
--默认初始1
|
||||
actorData[AtvType.Type1] = {}
|
||||
end
|
||||
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local setCfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if setCfg == nil then
|
||||
return
|
||||
end
|
||||
local id = Actor.getStaticCount(pActor, 623);
|
||||
-- print("id.."..id.."..actid.."..atvId)
|
||||
if id ~= atvId then
|
||||
Actor.setStaticCount(pActor,622, 0);
|
||||
-- Actor.setStaticCount(pActor,624, 0);--战令币清空
|
||||
ActivityDispatcher.ClearActorData(pActor,atvId);
|
||||
Actor.setStaticCount(pActor,623, atvId);
|
||||
end
|
||||
|
||||
local sorce = Actor.getConsume(pActor, setCfg.timer,setCfg.timer)
|
||||
|
||||
local AtvCfg = ActivityConfig[atvId]
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
Cfg = AtvCfg[(globalData.nNumber or 1)]
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if sorce >= cfg.accumulate then
|
||||
if actorData[AtvType.Type1] and cfg.rewardA then
|
||||
if actorData[AtvType.Type1][cfg.tokenlevel] == nil then
|
||||
ret = 1;
|
||||
break;
|
||||
end
|
||||
end
|
||||
if actorData[AtvType.Type2] and cfg.rewardB then
|
||||
if actorData[AtvType.Type2][cfg.tokenlevel] == nil then
|
||||
ret = 1;
|
||||
break;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
|
||||
---更新活动数据
|
||||
function OnUpdateActivity(pActor, atvId)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
actorData[AtvType.Type1] ={}
|
||||
end
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
SendZLMoney(pActor);
|
||||
end
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType14.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType14.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType14.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType14.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType14.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType14.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType14.lua")
|
||||
@@ -0,0 +1,533 @@
|
||||
module("ActivityType15", package.seeall)
|
||||
|
||||
--[[
|
||||
任务
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
quest[type]//进度
|
||||
{
|
||||
}
|
||||
isred[index] 红点数据
|
||||
int nFalg //
|
||||
limit[itemtype]
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
int nNumber --期数
|
||||
int endTime;
|
||||
int nStartTime
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 15
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity15Config
|
||||
ActivitySetConfig = ActivitysetConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
EXP = 10000;
|
||||
|
||||
--玩家请求领取奖励
|
||||
function reqGetAward(pActor, atvId , indexId)
|
||||
print("atvId.."..atvId.."..indexId.."..indexId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local AtvCfg = ActivityConfig[atvId];
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = AtvCfg[(globalData.nNumber or 1)]
|
||||
if Cfg then
|
||||
Cfg = AtvCfg[(globalData.nNumber or 1)][indexId]
|
||||
end
|
||||
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local ntype = Cfg.type * EXP + Cfg.subtype
|
||||
if actorData.quest[ntype] == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件未达成|", tstUI)
|
||||
return
|
||||
end
|
||||
--提示已领取无法多次领取
|
||||
if System.getIntBit((actorData.nFlag or 0),indexId) == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已领取该奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if (actorData.quest[ntype] < Cfg.value) then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:条件未达成|", tstUI)
|
||||
return
|
||||
end
|
||||
local SetCfg = ActivitySetConfig[atvId]
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
local setCfg = SetCfg[(globalData.nNumber or 1)];
|
||||
if setCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
--检查格子够不够
|
||||
if setCfg.VIPbagremain and setCfg.VIPtips then
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,setCfg.VIPbagremain,setCfg.VIPtips,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if actorData.limit == nil then
|
||||
actorData.limit = {}
|
||||
end
|
||||
local gift1 = getAwardCfg(Cfg)
|
||||
if gift1 then
|
||||
CommonFunc.GiveCommonAward(pActor, gift1, GameLog.Log_Activity15, "战令任务|"..atvId)
|
||||
end
|
||||
|
||||
local gift2 = getLimitAwardCfg(Cfg, actorData.limit)
|
||||
|
||||
if gift2 and #gift2 > 0 then
|
||||
CommonFunc.GiveCommonAward(pActor, gift2, GameLog.Log_Activity15, "战令任务|"..atvId)
|
||||
|
||||
for i, data in pairs(gift2) do
|
||||
actorData.limit[i] = (actorData.limit[i] or 0) + data.count;
|
||||
end
|
||||
end
|
||||
|
||||
actorData.nFlag = System.setIntBit(actorData.nFlag, indexId, 1) --将indexId位置置为1
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
UpdateActivity(pActor, atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmMailGetItemSuccess, tstUI)
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
function getAwardCfg(Cfg)
|
||||
if Cfg.GiftTable then
|
||||
if Cfg.UpperLimit then
|
||||
local award1 = {}
|
||||
for i, cfg in pairs(Cfg.GiftTable) do
|
||||
if Cfg.UpperLimit[i] == nil then
|
||||
table.insert(award1, cfg)
|
||||
end
|
||||
end
|
||||
return award1;
|
||||
else
|
||||
return Cfg.GiftTable
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
function getLimitAwardCfg(Cfg, nLimitData)
|
||||
if Cfg.GiftTable then
|
||||
local award1 = {}
|
||||
for i, cfg in pairs(Cfg.GiftTable) do
|
||||
if Cfg.UpperLimit and Cfg.UpperLimit[i] then
|
||||
local nLeftCount = Cfg.UpperLimit[i]
|
||||
if nLimitData and nLimitData[i] then
|
||||
nLeftCount = nLeftCount - nLimitData[i]
|
||||
end
|
||||
|
||||
if nLeftCount > cfg.count then
|
||||
nLeftCount = cfg.count;
|
||||
end
|
||||
|
||||
if nLeftCount > 0 then
|
||||
local award2 = {}
|
||||
award2.type = cfg.type
|
||||
award2.id = cfg.id
|
||||
award2.count = nLeftCount
|
||||
award1[i] = award2
|
||||
end
|
||||
end
|
||||
end
|
||||
return award1;
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
function UpdateActivity(pActor, atvId)
|
||||
if ActivitiesConf[atvId] then
|
||||
if ActivitiesConf[atvId].activityid then
|
||||
for _, id in pairs(ActivitiesConf[atvId].activityid) do
|
||||
-- local atvType = 0
|
||||
-- if (ActivitiesConf[id] and ActivitiesConf[id].ActivityType) then
|
||||
-- atvType = ActivitiesConf[id].ActivityType
|
||||
-- end
|
||||
Actor.sendActivityData(pActor, id)
|
||||
-- ActivityDispatcher.OnEvent(OnUpdateActivity, atvType,id,pActor);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--玩家消耗道具 完成任务
|
||||
function deleteItemToComplete(pActor, atvId , indexId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
return
|
||||
end
|
||||
local AtvCfg = ActivityConfig[atvId];
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = AtvCfg[(globalData.nNumber or 1)]
|
||||
if Cfg then
|
||||
Cfg = AtvCfg[(globalData.nNumber or 1)][indexId]
|
||||
end
|
||||
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if Cfg.data == nil then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:当前任务无需贡献|", tstUI)
|
||||
return
|
||||
end
|
||||
local ntype = Cfg.type * EXP + Cfg.subtype
|
||||
|
||||
--提示已领取无法多次领取
|
||||
if System.getIntBit((actorData.nFlag or 0),indexId) == 1 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:当前任务已领取|", tstUI)
|
||||
return
|
||||
end
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, Cfg.data, tstUI) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
CommonFunc.Consumes.Remove(pActor, Cfg.data, GameLog.Log_Activity15, "完成任务|"..atvId)
|
||||
actorData.quest[ntype] = (actorData.quest[ntype] or 0) + Cfg.value;
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
function getTypeCfg(atvId, nType, nSubType, nNumber)
|
||||
local AtvCfg = ActivityConfig[atvId]
|
||||
if AtvCfg then
|
||||
local Cfg = AtvCfg[nNumber];
|
||||
if Cfg then
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.type == nType and cfg.subtype == nSubType then
|
||||
return cfg;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil;
|
||||
end
|
||||
--------------------------我是分界线----------------------------
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 15] 任务活动"..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
print("[activitytype 15] 任务活动---onstart atvId:"..atvId)
|
||||
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
if globalData.openTimes == nil then
|
||||
local currentId = System.getCurrMiniTime();
|
||||
globalData.openTimes = currentId
|
||||
end
|
||||
--初始化
|
||||
local openDay = System.getDaysSinceOpenServer();
|
||||
local SetCfg = ActivitySetConfig[atvId];
|
||||
if SetCfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
for _, cfg in pairs(SetCfg) do
|
||||
if openDay >= cfg.openday then
|
||||
globalData.nNumber = cfg.number;
|
||||
end
|
||||
end
|
||||
|
||||
globalData.nStartTime = System.getCurrMiniTime();
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cGetQuestAward then --请求奖励奖励
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
reqGetAward(pActor, atvId , indexId)
|
||||
elseif operaCode == ActivityOperate.cDeleteItem then --提交道具
|
||||
local indexId = DataPack.readByte(inPack)
|
||||
deleteItemToComplete(pActor, atvId ,indexId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
-- print("[activitytype 15 任务活动 id:.."..atvId.."请求数据]")
|
||||
|
||||
if outPack == nil then
|
||||
return
|
||||
end
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
local AtvCfg = ActivityConfig[atvId]
|
||||
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
local Cfg = AtvCfg[(globalData.nNumber or 1)]
|
||||
local len = 0;
|
||||
|
||||
if Cfg then
|
||||
len = #Cfg;
|
||||
end
|
||||
DealNewDay(pActor, atvId, System.getCurrMiniTime())
|
||||
--长度
|
||||
DataPack.writeByte(outPack, (globalData.nNumber or 1))
|
||||
DataPack.writeByte(outPack, (len or 0))
|
||||
if Cfg then
|
||||
|
||||
|
||||
local endtime = System.getActivityEndMiniSecond(atvId);
|
||||
if globalData.endTime then
|
||||
if globalData.endTime ~= endtime then
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
if globalData.endTime == nil then
|
||||
globalData.endTime = endtime;
|
||||
end
|
||||
|
||||
if actorData.quest == nil then
|
||||
actorData.quest = {};
|
||||
end
|
||||
|
||||
-- DataPack.writeInt(outPack, (actorData.nValue or 0))
|
||||
for _, cfg in pairs(Cfg) do
|
||||
DataPack.writeByte(outPack, cfg.taskID)
|
||||
local value = cfg.type * EXP + cfg.subtype;
|
||||
-- print("actorData.quest[value].."..(actorData.quest[value] or 0))
|
||||
DataPack.writeInt(outPack, (actorData.quest[value] or 0))
|
||||
local res = System.getIntBit((actorData.nFlag or 0), cfg.taskID)
|
||||
|
||||
if res == 1 then res = 2; end
|
||||
if res == 0 and (actorData.quest[value] and actorData.quest[value] >= cfg.value) then res = 1; end
|
||||
DataPack.writeByte(outPack, res)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
print("[PActivity 15] 活动id.."..atvId.."..结束")
|
||||
-- ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
end
|
||||
|
||||
--活动红点
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
local AtvCfg = ActivityConfig[atvId]
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
local Cfg = AtvCfg[(globalData.nNumber or 1)]
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
DealNewDay(pActor, atvId, System.getCurrMiniTime())
|
||||
local len = 0;
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
if actorData.quest == nil then
|
||||
actorData.quest = {}
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg) do
|
||||
local ntype = cfg.type * EXP + cfg.subtype
|
||||
if actorData.quest[ntype] then
|
||||
if actorData.quest[ntype] >= cfg.value then
|
||||
local res = System.getIntBit((actorData.nFlag or 0), cfg.taskID) --对应位为1表示该奖励可领取
|
||||
if res == 0 then ret = 1 break end;
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
---更新活动数据
|
||||
function OnUpdateActivity(atvId, pActor, nType, nSubType, nValue)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
if nType == 17 and nSubType == 35 then
|
||||
nSubType = 11
|
||||
end
|
||||
-- print("atvId.."..atvId.."..nType.."..nType.."..nSubType.."..nSubType.."..num.."..(globalData.nNumber or 1))
|
||||
local Cfg = getTypeCfg(atvId, nType, nSubType, (globalData.nNumber or 1));
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
DealNewDay(pActor, atvId, System.getCurrMiniTime())
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
if actorData.quest == nil then
|
||||
actorData.quest = {};
|
||||
end
|
||||
-- print("[PActivity 15] 活动id.."..atvId.."..结束")
|
||||
local ntype = nType * EXP + nSubType;
|
||||
|
||||
if Cfg.ValueType == 1 then
|
||||
actorData.quest[ntype] = (actorData.quest[ntype] or 0) + nValue
|
||||
else
|
||||
actorData.quest[ntype] = nValue;
|
||||
end
|
||||
|
||||
local ret = 0
|
||||
local AtvCfg = ActivityConfig[atvId]
|
||||
if AtvCfg == nil then
|
||||
return
|
||||
end
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
globalData = {}
|
||||
end
|
||||
local Cfg = AtvCfg[(globalData.nNumber or 1)]
|
||||
if Cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if actorData.isred == nil then
|
||||
actorData.isred = {}
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg) do
|
||||
if cfg.type == nType and cfg.subtype == nSubType then
|
||||
|
||||
if actorData.quest[ntype] >= cfg.value and actorData.isred[cfg.taskID] == nil then
|
||||
actorData.isred[cfg.taskID] = 1
|
||||
local res = System.getIntBit((actorData.nFlag or 0), cfg.taskID) --对应位为1表示该奖励可领取
|
||||
if res == 0 then
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function DealNewDay(pActor, atvId, curTime)
|
||||
if (ActivitiesConf[atvId] and ActivitiesConf[atvId].Resettask) then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if System.isSameDay( (actorData.nStartTime or 0), curTime) == true then
|
||||
return
|
||||
end
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
actorData.nStartTime = curTime;
|
||||
end
|
||||
end
|
||||
function OnUpdate(atvId, curTime)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if System.isSameDay( (globalData.nStartTime or 0), curTime) == true then
|
||||
return
|
||||
end
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
globalData.nStartTime = curTime
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType15.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType15.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType15.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType15.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType15.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType15.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdateActivity, ActivityType, OnUpdateActivity, "ActivityType15.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType15.lua")
|
||||
|
||||
|
||||
|
||||
-- -- 跨天,次数清零
|
||||
-- function OnNewDayArrive(pActor)
|
||||
-- local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
-- if runAtvIdList == nil then
|
||||
-- return
|
||||
-- end
|
||||
-- for i,atvId in ipairs(runAtvIdList) do
|
||||
-- if (ActivitiesConf[atvId] and ActivitiesConf[atvId].Resettask) then
|
||||
-- ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType15.lua")
|
||||
@@ -0,0 +1,221 @@
|
||||
module("ActivityType16", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动
|
||||
每日签到
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
LastLoginMonthofYear = 1 , 上次签到的月份
|
||||
donatelist[id]
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 16
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity16Config
|
||||
-- if ActivityConfig == nil then
|
||||
-- assert(false)
|
||||
-- end
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY16
|
||||
|
||||
function nextMonthClear(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local dayofMonth = System.getDayOfMonth()
|
||||
--local LinChengSec = System.getToday()
|
||||
local MonthofYear = System.getMonthOfNow();
|
||||
|
||||
if globalData.LastLoginMonthofYear ==nil then
|
||||
globalData.LastLoginMonthofYear = 0 ;
|
||||
end
|
||||
if globalData.donatelist ==nil then
|
||||
globalData.donatelist = {} ;
|
||||
end
|
||||
|
||||
--跨月了,数据清空
|
||||
if globalData.LastLoginMonthofYear ~= MonthofYear then
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg and Cfg.content then
|
||||
System.broadcastTipmsgLimitLev(Cfg.content, tstBigRevolving)
|
||||
System.broadcastTipmsgLimitLev(Cfg.content, tstChatSystem)
|
||||
end
|
||||
--清空排行榜
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
|
||||
globalData.donatelist = {} ;
|
||||
globalData.LastLoginMonthofYear = MonthofYear;
|
||||
end
|
||||
end
|
||||
|
||||
--玩家请求领取礼包
|
||||
function reqDonate(pActor, atvId , num)
|
||||
--print("[GActivity 16]reqDonate-------------------------------------------------------------- 捐献 活动数据加载,id:"..atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local Cfg = ActivityConfig
|
||||
|
||||
if Cfg then
|
||||
|
||||
local nowRankId = RankMgr.GetMyRank(pActor,RANKING_ID);
|
||||
local aid = Actor.getActorId(pActor)
|
||||
if num <= 0 or num < Cfg.minValue then
|
||||
Actor.sendTipmsgWithParams(pActor, tmDonateRankNoDonate,tstUI);
|
||||
return
|
||||
end
|
||||
local cost = {}
|
||||
local cost1= {}
|
||||
cost1["type"] = Cfg.costtype;
|
||||
cost1["id"] = Cfg.costid;
|
||||
cost1["count"] = num;
|
||||
table.insert(cost, cost1)
|
||||
if cost then
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, cost ,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
--扣除消耗
|
||||
if cost then
|
||||
if CommonFunc.Consumes.Remove(pActor, cost, GameLog.Log_Activity16, "捐献排行|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
RankMgr.AddValue(aid, RANKING_ID, num)
|
||||
local rankId = RankMgr.GetMyRank(pActor,RANKING_ID);
|
||||
if rankId > #Cfg.rankList then
|
||||
rankId = 0;
|
||||
end
|
||||
if rankId > 0 and nowRankId ~= rankId and Cfg.inrank then
|
||||
local str = string.format(Cfg.inrank,rankId)
|
||||
Actor.sendTipmsg(pActor, str,tstUI);
|
||||
if Cfg.tips[rankId] then
|
||||
local name = Actor.getName(pActor);
|
||||
local str = string.format(Cfg.tips[rankId],name)
|
||||
System.broadcastTipmsgLimitLev(str, tstKillDrop)
|
||||
end
|
||||
end
|
||||
globalData.donatelist[aid] = (globalData.donatelist[aid] or 0) + num;
|
||||
Actor.sendTipmsgWithParams(pActor, tmDonateRanksuccess,tstUI,num);
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
end
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------我是分界线----------------------------
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
end
|
||||
|
||||
--活动开始
|
||||
function OnStart(atvId)
|
||||
nextMonthClear(atvId)
|
||||
end
|
||||
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cDonateRank then --捐献
|
||||
local num = DataPack.readInt(inPack)
|
||||
reqDonate(pActor, atvId , num)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
--print("[GActivity 16]OnReqData-------------------------------------------------------------- 捐献 活动数据加载,id:"..atvId)
|
||||
nextMonthClear(atvId);
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg == nil then
|
||||
return;
|
||||
end
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
local donateValue = 0;
|
||||
if globalData.donatelist then
|
||||
donateValue = (globalData.donatelist[actorId] or 0)
|
||||
end
|
||||
if outPack then
|
||||
DataPack.writeInt(outPack, (donateValue or 0)) --
|
||||
local rankId = RankMgr.GetMyRank(pActor,RANKING_ID);
|
||||
if rankId > #Cfg.rankList then
|
||||
rankId = 0;
|
||||
end
|
||||
DataPack.writeWord(outPack, rankId)
|
||||
local num = Cfg.showRank
|
||||
|
||||
--print("[GActivity 16]OnReqData------------------------rankId:"..tostring(rankId))
|
||||
RankMgr.PushToPack(RANKING_ID, num, outPack)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function OnLoginGame(atvId,pActor)
|
||||
nextMonthClear(atvId)
|
||||
local rankId = RankMgr.GetMyRank(pActor,RANKING_ID);
|
||||
if rankId > 0 then
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg and Cfg.rankList[rankId] then
|
||||
for _, buffId in pairs(Cfg.rankList[rankId]) do
|
||||
Actor.addBuffById(pActor, buffId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function sendRankInfo(atvId)
|
||||
local num = 6;
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg then
|
||||
num = Cfg.showRank
|
||||
end
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID, num, npack)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg and Cfg.content then
|
||||
System.broadcastTipmsgLimitLev(Cfg.content, tstBigRevolving)
|
||||
System.broadcastTipmsgLimitLev(Cfg.content, tstChatSystem)
|
||||
end
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
end
|
||||
|
||||
function OnUpdate(atvId, curTime)
|
||||
nextMonthClear(atvId)
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType16.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoginGame, ActivityType, OnLoginGame, "ActivityType16.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType16.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType16.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType16.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType16.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType16.lua")
|
||||
@@ -0,0 +1,746 @@
|
||||
module("ActivityType17", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动,跨服大乱斗
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
nextLoginTime, 退出后下次可进来的时间戳
|
||||
isFirst , 第一次
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
nextAutoTime, 下一次自动加积分的时间戳
|
||||
firstHalfNotice, 上半场开场公告标记
|
||||
secondHalfNotice, 下半场开场公告标记
|
||||
broadcastTime, 下一次广播的时间戳
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
status, 活动状态,这个即使服务器重启了,也要保存这个数据
|
||||
nextChgStatusTime, 下一次活动状态改变的时间戳
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 17
|
||||
--对应的活动配置
|
||||
ActivityConfig17 = Activity17Config
|
||||
if ActivityConfig17 == nil then
|
||||
--assert(false)
|
||||
end
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY17
|
||||
|
||||
--活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
FirstHalf = 1, --上半场(自由击杀不限复活次,自由进出)
|
||||
SecondHalf = 2, --下半场(限复活次数,可出不可进)
|
||||
End = 3, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
|
||||
--助攻列表
|
||||
attackerList=
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [handle,被攻击者] =
|
||||
-- {
|
||||
-- [attkHandle,攻击者] = 最新攻击时间
|
||||
-- }
|
||||
--}
|
||||
}
|
||||
|
||||
--阶段奖励的领取记录,记录下一次要领取的阶段索引
|
||||
actorAwardIdx =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [aid] = idx
|
||||
--}
|
||||
}
|
||||
|
||||
--在场景中的玩家
|
||||
actorsInFuben =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [actorId] = actorId
|
||||
--}
|
||||
}
|
||||
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local fbHandle = Actor.getFubenHandle(pActor)
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--退出后登入的时间限制
|
||||
if actorData.nextLoginTime and actorData.nextLoginTime > System.getCurrMiniTime() then
|
||||
Actor.sendTipmsg(pActor, "请30秒后再进入!")
|
||||
return
|
||||
end
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if ActivityConfig17[atvId].enterExpends then
|
||||
consumes = ActivityConfig17[atvId].enterExpends
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, consumes, tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if ActivityConfig17[atvId].count and ActivityConfig17[atvId].count > 0 then
|
||||
if actorData.count == nil then
|
||||
actorData.count = 1
|
||||
else
|
||||
if actorData.count >= ActivityConfig17[atvId].count then
|
||||
Actor.sendTipmsg(pActor, "超过今日的次数了!"..actorData.count.."/"..ActivityConfig17[atvId].count, tstUI)
|
||||
return
|
||||
end
|
||||
actorData.count = actorData.count + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity3, "跨服大乱斗|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- 这个阶段还不能进入
|
||||
if globalData.status == AtvStatus.SecondHalf then
|
||||
-- Actor.sendTipmsg(pActor, "活动当前阶段不能进入!", tstUI)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoInOpenTime, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--进入副本
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig17[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 设置排行榜
|
||||
--RankMgr.SetRank(actorId, RANKING_ID, 0)
|
||||
|
||||
-- 重置下次进入时间
|
||||
actorData.nextLoginTime = nil
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
|
||||
-- 记录进入奖励索引
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
actorAwardIdx[atvId] = {}
|
||||
end
|
||||
|
||||
if actorAwardIdx[atvId][actorId] == nil then
|
||||
actorAwardIdx[atvId][actorId] = 1
|
||||
end
|
||||
|
||||
-- 发送下一次领取奖励的索引
|
||||
SendNextAwardIndex(pActor, atvId)
|
||||
|
||||
-- 发送场次信息
|
||||
SendCurrentTimeInfo(pActor, atvId)
|
||||
|
||||
-- 禁止普通频道聊天
|
||||
Actor.setChatForbit(pActor, ciChannelNear, true)
|
||||
|
||||
-- 广播一次排行榜
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
RankMgr.Save(RANKING_ID)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
|
||||
-- 强制全体pk模式
|
||||
Actor.setPkMode(pActor,fpPk)
|
||||
end
|
||||
end
|
||||
|
||||
--请求领取阶段奖励
|
||||
function reqGetPhaseAward(pActor, atvId)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
actorAwardIdx[atvId] = {}
|
||||
end
|
||||
|
||||
if actorAwardIdx[atvId][aid] == nil then
|
||||
actorAwardIdx[atvId][aid] = 1
|
||||
end
|
||||
|
||||
local curIdx = actorAwardIdx[atvId][aid]
|
||||
|
||||
local awardConf = ActivityConfig17[atvId].phaseAward[curIdx]
|
||||
if awardConf then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
if curVal >= awardConf.value then
|
||||
local awards = awardConf.awards
|
||||
-- if CommonFunc.Awards.CheckBagGridCount(pActor,awards) ~= true then
|
||||
-- return
|
||||
-- end
|
||||
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,1,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
print("[GActivity 17] "..Actor.getName(pActor).." 领取阶段奖励,".."id="..atvId.." ".."index="..curIdx)
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity3, "Activity3LevelAward|"..atvId)
|
||||
actorAwardIdx[atvId][aid] = actorAwardIdx[atvId][aid] + 1
|
||||
-- if actorAwardIdx[atvId][aid] == 2 then
|
||||
|
||||
-- end
|
||||
SendNextAwardIndex(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadRankData(atvId,fbHandle,sceneId)
|
||||
-- 广播所有玩家排行榜数据
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID, 4, npack)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家排行数据
|
||||
function SendRankData(atvId,pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMyRankData)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家下一次领取奖励的索引
|
||||
function SendNextAwardIndex(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sNextAwardIndex)
|
||||
if npack then
|
||||
local aid = Actor.getActorId(pActor)
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
actorAwardIdx[atvId] = {}
|
||||
end
|
||||
|
||||
if actorAwardIdx[atvId][aid] == nil then
|
||||
actorAwardIdx[atvId][aid] = 1
|
||||
end
|
||||
|
||||
DataPack.writeByte(npack, (actorAwardIdx[atvId][aid] or 1))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家当前场次时间信息
|
||||
function SendCurrentTimeInfo(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendTime)
|
||||
if npack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
DataPack.writeByte(npack, (globalData.status-2))
|
||||
local leftTime = globalData.nextChgStatusTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, leftTime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--广播当前场次时间信息
|
||||
function BroadCurrentTimeInfo(atvId,fbHandle,sceneId)
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendTime)
|
||||
if npack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
DataPack.writeByte(npack, (globalData.status-2))
|
||||
local leftTime = globalData.nextChgStatusTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, leftTime)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送排名奖励
|
||||
function SendRankAward(atvId)
|
||||
if ActivityConfig17[atvId].rankAward then
|
||||
local rankAward = ActivityConfig17[atvId].rankAward
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
local idx = 1
|
||||
for _,awardInfo in ipairs(rankAward) do
|
||||
local rankNum = awardInfo.value
|
||||
if rankNum > itemNum then
|
||||
rankNum = itemNum
|
||||
end
|
||||
for i=idx,rankNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
|
||||
local cfg = ActivityConfig17[atvId]
|
||||
if cfg and cfg.mailTitle1 and cfg.mailContent1 then
|
||||
local content = string.format(cfg.mailContent1, i)
|
||||
SendCrossServerMail(actorId, cfg.mailTitle1, content, awardInfo.awards)
|
||||
end
|
||||
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
local name = RankMgr.GetValueById(actorId, RANKING_ID, 0)
|
||||
print("[GActivity 17] 跨服大乱斗(id:"..atvId..") "..(name or actorId).." 获得第"..i.."名!")
|
||||
end
|
||||
idx = rankNum + 1
|
||||
if idx > itemNum then
|
||||
print("[GActivity 17] 跨服大乱斗(id:"..atvId..") 奖励发完! 一共"..rankNum.."人获得上榜奖励!")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送积分奖励
|
||||
function SendScoreAward(atvId)
|
||||
local MaxIdx = #ActivityConfig17[atvId].phaseAward
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
return
|
||||
end
|
||||
for aid,awdIdx in pairs(actorAwardIdx[atvId]) do
|
||||
if actorAwardIdx[atvId][aid] ~= nil then
|
||||
local rankValue = RankMgr.GetValue(aid, RANKING_ID)
|
||||
|
||||
local award = nil;
|
||||
for i=1,MaxIdx do
|
||||
local awardConf = ActivityConfig17[atvId].phaseAward[i]
|
||||
|
||||
if awardConf then
|
||||
if rankValue >= awardConf.value then
|
||||
award = awardConf;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if award then
|
||||
local cfg = ActivityConfig17[atvId]
|
||||
if cfg and cfg.mailTitle2 and cfg.mailContent2 then
|
||||
SendCrossServerMail(aid, cfg.mailTitle2, cfg.mailContent2, award.awards)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 设置复活,分场次,上半场随意复活(不设置它),下半场限制3次,超过就踢出去
|
||||
function SetAutoRelive(atvId,pActor,pFuben)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData.status == AtvStatus.SecondHalf then
|
||||
local deathLimit = FubenDispatcher.GetReliveCount(pFuben, pActor)
|
||||
if (deathLimit == nil) or (deathLimit == -1) then
|
||||
FubenDispatcher.SetReliveCount(pFuben, pActor, ActivityConfig17[atvId].Rebirthsecond)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 17] 跨服大乱斗 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig17[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 17] 跨服大乱斗 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.nextLoginTime = nil
|
||||
actorData.isFirst = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 17] 跨服大乱斗 活动开始了,id:"..atvId)
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
cacheData.nextAutoTime = 0
|
||||
cacheData.actors = {}
|
||||
cacheData.broadcastTime = 0
|
||||
|
||||
globalData.status = AtvStatus.FirstHalf
|
||||
globalData.nextChgStatusTime = System.getCurrMiniTime() + ActivityConfig17[atvId].firstHalfTime
|
||||
if globalData.openTimes == nil then
|
||||
local currentId = System.getCurrMiniTime();
|
||||
globalData.openTimes = currentId
|
||||
else
|
||||
globalData.openTimes = globalData.openTimes + 1
|
||||
end
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig17[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[GActivity 17] 跨服大乱斗 活动结束了,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
local pFuben = ActivityDispatcher.GetFuben(atvId)
|
||||
if pFuben then
|
||||
-- 设置副本结果
|
||||
FubenDispatcher.SetResult(pFuben,1)
|
||||
-- 延迟踢出副本
|
||||
FubenDispatcher.KictoutAfter(pFuben,15)
|
||||
end
|
||||
|
||||
-- 广播第一名
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, 0)
|
||||
local name = Ranking.getSub(rankItem, 0)
|
||||
if rankItem then
|
||||
System.broadcastTipmsgLimitLev("大乱斗活动结束了,恭喜玩家 "..name.." 获得第一名!", tstRevolving)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送奖励
|
||||
SendRankAward( atvId )
|
||||
|
||||
-- 补发阶段奖励
|
||||
SendScoreAward(atvId)
|
||||
|
||||
-- 关闭副本
|
||||
--Fuben.closeFuben( cacheData.fbHandle )
|
||||
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
ActivityDispatcher.ClearGlobalData( atvId )
|
||||
actorAwardIdx[atvId] = nil
|
||||
attackerList[atvId] = nil
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
-- 检测活动结束
|
||||
if globalData and globalData.status and globalData.status == AtvStatus.End then
|
||||
return
|
||||
end
|
||||
|
||||
if globalData.status == AtvStatus.FirstHalf then
|
||||
if cacheData.firstHalfNotice == nil then
|
||||
System.broadcastTipmsgLimitLev(ActivityConfig17[atvId].noticeFirstHalf, tstRevolving)
|
||||
cacheData.firstHalfNotice = 1
|
||||
BroadCurrentTimeInfo(atvId, cacheData.fbHandle, Fuben.getSceneId(cacheData.scenHandle))
|
||||
-- 发送一个活动数据
|
||||
-- Actor.sendActivityData(pActor, atvId)
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
ActivityDispatcher.BroadPopup(atvId);
|
||||
end
|
||||
elseif globalData.status == AtvStatus.SecondHalf then
|
||||
if cacheData.secondHalfNotice == nil then
|
||||
System.broadcastTipmsgLimitLev(ActivityConfig17[atvId].noticeSecondHalf, tstRevolving)
|
||||
cacheData.secondHalfNotice = 1
|
||||
BroadCurrentTimeInfo(atvId, cacheData.fbHandle, Fuben.getSceneId(cacheData.scenHandle))
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
-- 发送一个活动数据
|
||||
-- Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 有玩家时才处理
|
||||
if actorsInFuben[atvId] then
|
||||
|
||||
local hasMan = false
|
||||
|
||||
-- 泡点
|
||||
if (cacheData.nextAutoTime or 0) - curTime > ActivityConfig17[atvId].autoTime then
|
||||
cacheData.nextAutoTime = curTime
|
||||
end
|
||||
if curTime > (cacheData.nextAutoTime or 0) then
|
||||
cacheData.nextAutoTime = curTime + ActivityConfig17[atvId].autoTime
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
RankMgr.AddValue(actorid, RANKING_ID, ActivityConfig17[atvId].addScoreAuto)
|
||||
OnDealAchieve(atvId, pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
Actor.sendTipmsg(pActor, "持续参加活动,积分+"..ActivityConfig17[atvId].addScoreAuto..",当前积分为:"..curVal, tstGetItem)
|
||||
SendRankData(atvId,pActor)
|
||||
hasMan = true
|
||||
end
|
||||
end
|
||||
if hasMan then
|
||||
RankMgr.Save(RANKING_ID)
|
||||
end
|
||||
end
|
||||
|
||||
-- 每秒广播一次
|
||||
if (cacheData.broadcastTime or 0) - curTime > 1 then
|
||||
cacheData.broadcastTime = curTime
|
||||
end
|
||||
if curTime > (cacheData.broadcastTime or 0) then
|
||||
cacheData.broadcastTime = curTime + 1
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 场次检测
|
||||
if curTime > (globalData.nextChgStatusTime or 0) then
|
||||
globalData.status = (globalData.status or 0) + 1
|
||||
if globalData.status == AtvStatus.SecondHalf then
|
||||
globalData.nextChgStatusTime = curTime + ActivityConfig17[atvId].secondHalfTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cGetPhaseAward then --请求获取阶段奖励
|
||||
reqGetPhaseAward(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
|
||||
-- 玩家退出,从记录中排除
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
|
||||
-- 玩家下次进入时间限制
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nextLoginTime = System.getCurrMiniTime() + 30
|
||||
|
||||
-- 恢复禁止普通频道聊天
|
||||
Actor.setChatForbit(pActor, ciChannelNear, false)
|
||||
|
||||
-- 完成
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
--print(debug.traceback("Stack trace"))
|
||||
|
||||
if pKiller then
|
||||
local entityType = Actor.getEntityType(pEntity)--被击杀者的类型
|
||||
local killerType = Actor.getEntityType(pKiller)--击杀者的类型
|
||||
if killerType == enActor then
|
||||
if entityType == enActor then
|
||||
-- 杀玩家获得积分
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(killerId, RANKING_ID, ActivityConfig17[atvId].addScoreKill)
|
||||
OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你成功击败["..Actor.getName(pEntity).."],积分+"..ActivityConfig17[atvId].addScoreKill, tstGetItem)
|
||||
|
||||
-- 被玩家击杀的玩家获得的积分
|
||||
local entityId = Actor.getIntProperty( pEntity, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(entityId, RANKING_ID, ActivityConfig17[atvId].addScoreBeKill)
|
||||
OnDealAchieve(atvId, pEntity)
|
||||
Actor.sendTipmsg(pEntity, "你被["..Actor.getName(pKiller).."]击败了,积分+"..ActivityConfig17[atvId].addScoreBeKill, tstGetItem)
|
||||
|
||||
-- 设置复活
|
||||
SetAutoRelive(atvId, pEntity, pFuben)
|
||||
else
|
||||
-- 杀守卫获得积分
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(killerId, RANKING_ID, ActivityConfig17[atvId].addScoreGuard)
|
||||
OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你击败守卫,积分+"..ActivityConfig17[atvId].addScoreGuard, tstGetItem)
|
||||
end
|
||||
|
||||
if not attackerList[atvId] then attackerList[atvId] = {} end
|
||||
|
||||
-- 助攻积分
|
||||
local handle = Actor.getHandle(pEntity)
|
||||
local entityName = Actor.getName(pEntity)
|
||||
if attackerList[atvId][handle] then
|
||||
local nowTime = System.getCurrMiniTime()
|
||||
local killerHandle = Actor.getHandle(pKiller)
|
||||
for attkHandle,time in pairs(attackerList[atvId][handle]) do
|
||||
if nowTime - time <= ActivityConfig17[atvId].helpTime and killerHandle ~= attkHandle then
|
||||
local pActor = Actor.getEntity(attkHandle)
|
||||
if pActor then
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(actorId, RANKING_ID, ActivityConfig17[atvId].addScoreHelpKill)
|
||||
OnDealAchieve(atvId, pActor)
|
||||
Actor.sendTipmsg(pActor, "你助攻击败["..entityName.."],积分+"..ActivityConfig17[atvId].addScoreHelpKill, tstGetItem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
attackerList[atvId][handle] = nil
|
||||
else
|
||||
-- 设置复活
|
||||
SetAutoRelive(atvId, pEntity, pFuben)
|
||||
end
|
||||
SendRankData(atvId,pKiller)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动副本中,实体守到攻击
|
||||
function OnEntityAttacked(atvId, pEntity, pAttacker, pFuben)
|
||||
|
||||
-- 攻击者必须为玩家,才记录助攻
|
||||
if Actor.getEntityType(pAttacker) == enActor then
|
||||
|
||||
-- 通过句柄作为key(因为守卫的id是一样的,所以只能通过handle区分)
|
||||
local handle = Actor.getHandle(pEntity)
|
||||
local attkHandle = Actor.getHandle(pAttacker)
|
||||
|
||||
if not attackerList[atvId] then attackerList[atvId] = {} end
|
||||
|
||||
local info = attackerList[atvId][handle]
|
||||
if not info then
|
||||
attackerList[atvId][handle] = { [attkHandle] = System.getCurrMiniTime() }
|
||||
else
|
||||
info[attkHandle] = System.getCurrMiniTime()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result)
|
||||
--广播成功失败的旗帜(带上自己的排行数据)
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor then
|
||||
local npack = ActivityDispatcher.AllocResultPack(pActor, atvId, 1)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local ret = 0
|
||||
if globalData.status and (globalData.status == AtvStatus.FirstHalf) then ret = 1 end
|
||||
local limitLv = 0;
|
||||
local cfg = ActivityConfig17[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
if lv < limitLv then ret = 0 end
|
||||
return ret
|
||||
end
|
||||
|
||||
----处理成就问题
|
||||
function OnDealAchieve(atvId, pActor)
|
||||
local ActorType = Actor.getEntityType(pActor)--类型
|
||||
if ActorType ==enActor then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData and actorData.isFirst == nil and curVal >= 50 then
|
||||
Actor.triggerAchieveEvent(pActor,nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
actorData.isFirst = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---处理结束邮件问题
|
||||
function OnSendFailMail(atvId, pActor)
|
||||
local ActorType = Actor.getEntityType(pActor)--类型
|
||||
if ActorType ==enActor then
|
||||
local cfg = ActivityConfig17[atvId]
|
||||
if cfg and cfg.mailtitle and cfg.mailcontent then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
SendCrossServerMail(actorid, cfg.mailtitle, cfg.mailcontent)
|
||||
end
|
||||
end
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityAttacked, ActivityType, OnEntityAttacked, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType17.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnAtvGG, ActivityType, OnSendFailMail, "ActivityType17.lua")
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
1137
server/cross/LogicServer/data/functions/Activity/ActivityType18.lua
Normal file
1137
server/cross/LogicServer/data/functions/Activity/ActivityType18.lua
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,960 @@
|
||||
module("ActivityType19", package.seeall)
|
||||
|
||||
--[[
|
||||
跨服活动,跨服首领boss跨服领主
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
buffValue, 鼓舞属性
|
||||
nextLoginTime, 退出后下次可进来的时间戳
|
||||
inspire {
|
||||
[1] = {times, addvalue }
|
||||
} 鼓舞次数
|
||||
isFirst 第一次
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
notice{} 公告
|
||||
referFlag, 刷新标志位
|
||||
status
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
bossLv, boss等级
|
||||
bossDeath, 是否死亡
|
||||
killerName, 击杀者昵称
|
||||
killerId, 击杀者id
|
||||
atvStartTime, 当前活动开始时间
|
||||
isAward --是否发奖
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 19
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity19Config
|
||||
if ActivityConfig == nil then
|
||||
print("Activity19Config errer!")
|
||||
--assert(false)
|
||||
end
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY24
|
||||
|
||||
-- 活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
PreEnter = 1, --活动前5分钟(走马灯全服公告,不给进入)
|
||||
Start = 2, --开始
|
||||
End = 3, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
--在场景中的玩家
|
||||
actorsInFuben = {}
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local fbHandle = Actor.getFubenHandle(pActor)
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
--活动前走马灯通告的时间戳
|
||||
preEnterNoticeTime = 0
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
-- print("[GActivity 8] "..Actor.getName(pActor).." 请求进入副本 id"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--退出后登入的时间限制
|
||||
if actorData.nextLoginTime and actorData.nextLoginTime > System.getCurrMiniTime() then
|
||||
Actor.sendTipmsg(pActor, "请30秒后再进入!", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if globalData.bossDeath then
|
||||
Actor.sendTipmsgWithId(pActor, tmBossDeath, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
-- 这个阶段还不能进入
|
||||
if cacheData.status == AtvStatus.PreEnter then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoInOpenTime, tstUI)
|
||||
-- Actor.sendTipmsg(pActor, "活动当前阶段不能进入!", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--进入副本
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
--print("[Activity8----------------------------------------------------------------------- fbId: "..ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 重置下次进入时间
|
||||
actorData.nextLoginTime = nil
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
-- print("atvId = "..atvId.." actorId="..actorsInFuben[atvId][actorId])
|
||||
|
||||
-- 广播一次排行榜
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
RankMgr.Save(RANKING_ID)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
SendRankData(atvId,pActor)
|
||||
|
||||
--在跨服中的处理
|
||||
--if System.isAcrossServer() == false then
|
||||
-- 强制全体和平模式
|
||||
-- Actor.setPkMode(pActor, fpPk)
|
||||
--end
|
||||
|
||||
addInspireBuff(pActor, atvId);
|
||||
SendLeftTimeInfo(pActor, atvId);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadRankData(atvId,fbHandle,sceneId)
|
||||
-- 广播所有玩家排行榜数据
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID, 5, npack)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
--玩家鼓舞
|
||||
function ActorInspire(pActor, atvId, type)
|
||||
-- print("[GActivity 8] "..Actor.getName(pActor).." 玩家鼓舞 id "..atvId.." type "..type)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
local errorcode = 0;
|
||||
local value = 0;
|
||||
local lefttimes = 0;
|
||||
while(true)
|
||||
do
|
||||
if actorsInFuben[atvId] then
|
||||
--初始化鼓舞数据
|
||||
if actorData.inspire == nil then
|
||||
actorData.inspire = {}
|
||||
end
|
||||
if actorData.inspire[type] == nil then
|
||||
actorData.inspire[type] = {};
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[atvId].inspire
|
||||
if Cfg == nil then
|
||||
errorcode = 1;
|
||||
break
|
||||
end
|
||||
|
||||
local inspireCfg = Cfg[type]
|
||||
if inspireCfg == nil or inspireCfg.type ~= type then
|
||||
errorcode = 1;
|
||||
break
|
||||
end
|
||||
if actorData.inspire[type].times == nil then
|
||||
actorData.inspire[type].times = 0;
|
||||
end
|
||||
|
||||
if actorData.inspire[type].times >= inspireCfg.times then
|
||||
errorcode = 2;
|
||||
break;
|
||||
end
|
||||
|
||||
if inspireCfg.costs and CommonFunc.Consumes.Check(pActor, inspireCfg.costs) ~= true then
|
||||
errorcode = 3;
|
||||
break;
|
||||
end
|
||||
|
||||
if inspireCfg.costs and CommonFunc.Consumes.Remove(pActor, inspireCfg.costs, GameLog.Log_Activity8, "世界boss|"..atvId) ~= true then
|
||||
errorcode = 4
|
||||
break
|
||||
end
|
||||
if actorData.buffValue == nil then
|
||||
actorData.buffValue = 0;
|
||||
end
|
||||
|
||||
-- actorData.buffValue = actorData.buffValue + inspireCfg.value;
|
||||
actorData.buffValue = actorData.buffValue + 1;
|
||||
if actorData.inspire[type].addvalue == nil then
|
||||
actorData.inspire[type].addvalue = 0;
|
||||
end
|
||||
actorData.inspire[type].addvalue = actorData.inspire[type].addvalue + inspireCfg.value;
|
||||
value = actorData.inspire[type].addvalue
|
||||
-- print("鼓舞.."..actorData.inspire[type].addvalue )
|
||||
addInspireBuff(pActor, atvId);
|
||||
Actor.sendTipmsgWithId(pActor, tmBossGwSuccess, tstUI)
|
||||
actorData.inspire[type].times = actorData.inspire[type].times + 1;
|
||||
lefttimes = inspireCfg.times - actorData.inspire[type].times ;
|
||||
break;
|
||||
else
|
||||
errorcode = 5;
|
||||
end
|
||||
break;
|
||||
end
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sInspire)
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.writeByte(outPack, type)
|
||||
DataPack.writeInt(outPack, (value or 0))
|
||||
DataPack.writeInt(outPack, (lefttimes or 0))
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家排行数据
|
||||
function SendRankData(atvId,pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMyRankData)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
--发送最后一击奖励
|
||||
function SendLastAttackaward(atvId)
|
||||
if ActivityConfig[atvId].lastattack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
-- print("击杀世界BOSS..atcid.."..atvId.."...2222.."..(globalData.killerId or 0))
|
||||
if globalData.killerId == nil then
|
||||
return;
|
||||
end
|
||||
--local title = "跨服首领"
|
||||
--local content = string.format("恭喜你击杀跨服首领!")
|
||||
--SendMail(globalData.killerId, title, content, ActivityConfig[atvId].lastattack)
|
||||
SendCrossServerMail(globalData.killerId, ActivityConfig[atvId].mailTitle1, ActivityConfig[atvId].mailContent1, ActivityConfig[atvId].lastattack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送排名奖励
|
||||
function SendRankAward(atvId)
|
||||
if ActivityConfig[atvId].rankAward then
|
||||
local rankAward = ActivityConfig[atvId].rankAward
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
--local title = "跨服首领"
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
local idx = 1
|
||||
for _,awardInfo in ipairs(rankAward) do
|
||||
local rankNum = awardInfo.value
|
||||
-- print("rankNum:"..rankNum.." itemNum:"..itemNum)
|
||||
if rankNum > itemNum then
|
||||
rankNum = itemNum
|
||||
end
|
||||
for i=idx,rankNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
--local title = "跨服首领"
|
||||
local content = string.format(ActivityConfig[atvId].mailContent2, i)
|
||||
--SendMail(actorId, title, content, awardInfo.awards)
|
||||
SendCrossServerMail(actorId, ActivityConfig[atvId].mailTitle2, content, awardInfo.awards)
|
||||
|
||||
-- local pActor = Actor.getActorById(actorId)
|
||||
-- Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
-- Actor.triggerAchieveEvent(pOwner, nAchieveCompleteActivity,1 ,atvId);
|
||||
local name = RankMgr.GetValueById(actorId, RANKING_ID, 0)
|
||||
-- print("[GActivity 8] 世界BOSS(id:"..atvId..") "..(name or actorId).." 获得第"..i.."名!")
|
||||
end
|
||||
idx = rankNum + 1
|
||||
if idx > itemNum then
|
||||
-- print("[GActivity 8] 世界BOSS(id:"..atvId..") 奖励发完! 一共"..rankNum.."人获得上榜奖励!")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 踢出副本
|
||||
function KickoutAllActors(atvId)
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
RemoveInspireBuff(pActor, atvId) --清除鼓舞buff
|
||||
end
|
||||
end
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function addInspireBuff(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil and Cfg.buffid == nil then
|
||||
return
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
local job = Actor.getIntProperty( pActor, PROP_ACTOR_VOCATION )
|
||||
for _, cfg in pairs(Cfg.buffid) do
|
||||
|
||||
if cfg.times == actorData.buffValue then
|
||||
|
||||
for _, id in pairs(cfg.buffid) do
|
||||
Actor.addBuffById(pActor, id);
|
||||
end
|
||||
|
||||
-- Actor.addBuffValueById(pActor, cfg.id, (actorData.buffValue or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function RemoveInspireBuff(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil and Cfg.buffid == nil then
|
||||
return
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg.buffid) do
|
||||
if cfg.times == actorData.buffValue then
|
||||
|
||||
for _, id in pairs(cfg.buffid) do
|
||||
|
||||
Actor.delBuffById(pActor, id);
|
||||
end
|
||||
end
|
||||
-- Actor.delBuffById(actorid, cfg.id);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 19] 跨服首领 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
|
||||
FubenDispatcher.MapToActivity(pFuben,ActivityType, atvId);
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 19] 跨服首领 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.buffValue = nil
|
||||
actorData.nextLoginTime = nil
|
||||
actorData.inspire = nil
|
||||
actorData.isFirst = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 19] 跨服首领 活动开始了,id:"..atvId)
|
||||
CheckNewActivity(atvId);
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
cacheData.actors = {}
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
|
||||
FubenDispatcher.MapToActivity(pFuben,ActivityType, atvId);
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
function ClearGlobalData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
-- print("一支穿云箭,千军万马来相见!!")
|
||||
globalData.bossDeath = nil
|
||||
globalData.killerId = nil
|
||||
globalData.killerName = nil
|
||||
globalData.isAward = nil;
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[GActivity 19] 跨服首领 活动结束了,id:"..atvId)
|
||||
SendWorldBossAward(atvId)
|
||||
-- 踢出副本
|
||||
KickoutAllActors( atvId )
|
||||
-- 未死亡
|
||||
noDeathResult(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
-- 关闭副本
|
||||
Fuben.closeFuben( cacheData.fbHandle )
|
||||
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
|
||||
end
|
||||
|
||||
function SendWorldBossAward(atvId)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData.isAward then
|
||||
return;
|
||||
end
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
|
||||
if globalData.killerName ~= nil then
|
||||
|
||||
if Cfg.killtips then --
|
||||
--ActivityConfig[atvId].fbId)
|
||||
--local msg = "跨服领主当前等级:%d"
|
||||
local str = string.format(ActivityConfig[atvId].killtips, globalData.killerName)
|
||||
System.broadcastTipmsgLimitLev(str, tstRevolving)
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
--System.broadTipmsgWithParams(tmKuaFuBossTipsCs, tstRevolving, globalData.killerName)
|
||||
--System.broadTipmsgWithParams(tmKuaFuBossTipsCs, tstChatSystem, globalData.killerName)
|
||||
end
|
||||
end
|
||||
local pFuben = ActivityDispatcher.GetFuben(atvId)
|
||||
if pFuben then
|
||||
FubenDispatcher.SetResult(pFuben,1)
|
||||
-- 延迟踢出副本
|
||||
local nowtime = System.getCurrMiniTime() + 15
|
||||
FubenDispatcher.KictoutAfter(pFuben, nowtime)
|
||||
end
|
||||
-- 发送奖励
|
||||
SendRankAward( atvId )
|
||||
--最后一击
|
||||
SendLastAttackaward(atvId);
|
||||
globalData.isAward = 1;
|
||||
|
||||
end
|
||||
--公告
|
||||
function SendNotice(avtId, curTime)
|
||||
local cfg = ActivityConfig[avtId]
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cfg == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if cfg.notice then
|
||||
for _, notice in pairs(cfg.notice) do
|
||||
|
||||
if cacheData.notice == nil then
|
||||
cacheData.notice = {}
|
||||
end
|
||||
if notice.id then
|
||||
local startTime = System.getRunningActivityStartTime(avtId)
|
||||
if (curTime > startTime + notice.time) and cacheData.notice[notice.id] == nil then
|
||||
if cacheData.status == nil then
|
||||
cacheData.status = AtvStatus.PreEnter
|
||||
end
|
||||
|
||||
System.broadcastTipmsgLimitLev(notice.content, tstBigRevolving)
|
||||
System.broadcastTipmsgLimitLev(notice.content, tstChatSystem)
|
||||
cacheData.notice[notice.id] = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新boss
|
||||
function CreateWorldBoss(avtId, curTime)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(avtId);
|
||||
if globalData.bossDeath then
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[avtId]
|
||||
if Cfg == nil or Cfg.bossinfo == nil then
|
||||
return
|
||||
end
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cacheData.referFlag then
|
||||
return
|
||||
end
|
||||
|
||||
-- print("..avtId.."..avtId.."avtId.."..(globalData.bossDeath or 0))
|
||||
local startTime = System.getRunningActivityStartTime(avtId)
|
||||
if cacheData.scenHandle and (curTime >= startTime + Cfg.starttime) then
|
||||
|
||||
if globalData.bossLv == nil then
|
||||
globalData.bossLv =1;
|
||||
end
|
||||
|
||||
TestMsg(globalData.bossLv, avtId)
|
||||
cacheData.status = AtvStatus.Start
|
||||
local bossGrowValue = 1.1 ^ (globalData.bossLv-1) *100
|
||||
Fuben.createOneMonsters(cacheData.scenHandle, Cfg.bossinfo.bossid, Cfg.bossinfo.x, Cfg.bossinfo.y, 1,0,0, NULL, 0, (bossGrowValue or 100));
|
||||
cacheData.referFlag = 1;
|
||||
System.sendAllActorOneActivityData(avtId);
|
||||
ActivityDispatcher.BroadPopup(avtId);
|
||||
end
|
||||
end
|
||||
|
||||
function CheckNewActivity(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
local endTime = System.getActivityEndMiniSecond(atvId)
|
||||
if globalData.atvEndTime == nil or globalData.atvEndTime ~= endTime then
|
||||
-- print("改革春风吹满地!!")
|
||||
ClearGlobalData(atvId)
|
||||
ActivityDispatcher.ClearCacheData(atvId);
|
||||
globalData.atvEndTime = endTime
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
-- 检测活动结束
|
||||
-- CheckNewActivity(atvId);
|
||||
-- 公告
|
||||
SendNotice(atvId, curTime)
|
||||
-- 刷新boss
|
||||
CreateWorldBoss(atvId, curTime)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg and Cfg.inspire then
|
||||
local len = #Cfg.inspire;
|
||||
DataPack.writeByte(outPack, (len or 0))
|
||||
for _, cfg in pairs(Cfg.inspire) do
|
||||
DataPack.writeByte(outPack, (cfg.type or 0))
|
||||
local data = GetActorInpires(atvId, cfg.type, pActor);
|
||||
local addvalue = 0;
|
||||
local times = cfg.times;
|
||||
if data then
|
||||
addvalue = data.addvalue;
|
||||
times = times - data.times
|
||||
if times < 0 then
|
||||
times = 0
|
||||
end
|
||||
end
|
||||
DataPack.writeInt(outPack, addvalue)
|
||||
DataPack.writeInt(outPack, (times or 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function GetActorInpires(atvId, type, pActor)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData.inspire == nil then
|
||||
actorData.inspire = {}
|
||||
local inspire = {}
|
||||
inspire.times = 0;
|
||||
inspire.addvalue = 0;
|
||||
actorData.inspire[type] = inspire;
|
||||
end
|
||||
return actorData.inspire[type]
|
||||
end
|
||||
|
||||
-- 排行榜更新
|
||||
function OnOnAtvRank(atvId, curTime)
|
||||
print("[ActivityType19:OnOnAtvRank------------------------------------------------------------51155----------- OnOperator:")
|
||||
|
||||
-- 检测活动结束
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if actorsInFuben[atvId] and globalData.bossDeath == nil then
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
end
|
||||
print("[ActivityType19:OnOnAtvRank----------------------------------------------------------------------- OnOperator:")
|
||||
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
--print("[ActivityType19:OnOperator----------------------------------------------------------------------- OnOperator:".. tostring(operaCode))
|
||||
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cInspire then --鼓舞
|
||||
local type = DataPack.readByte(inPack);
|
||||
ActorInspire(pActor, atvId, type)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家当前剩余时间信息
|
||||
function SendLeftTimeInfo(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendWorldBossTime)
|
||||
if npack then
|
||||
local nEndTime = System.getActivityEndMiniSecond(atvId);
|
||||
local leftTime = nEndTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, leftTime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
|
||||
-- 玩家退出,从记录中排除
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
-- 玩家下次进入时间限制
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nextLoginTime = System.getCurrMiniTime() + 30
|
||||
RemoveInspireBuff(pActor,atvId );
|
||||
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡 TODO 缺个助攻积分
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
|
||||
end
|
||||
function noDeathResult(atvId)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData.bossDeath then
|
||||
return
|
||||
end
|
||||
|
||||
local time = 0;
|
||||
local bossLv = 0;
|
||||
|
||||
for _, cfg in pairs(ActivityConfig[atvId].growlist) do
|
||||
if cfg.time >= time then
|
||||
time = cfg.time
|
||||
bossLv = cfg.addlv
|
||||
end
|
||||
end
|
||||
if globalData.bossLv == nil then
|
||||
globalData.bossLv = 1;
|
||||
end
|
||||
|
||||
globalData.bossLv = globalData.bossLv + bossLv;
|
||||
if globalData.bossLv < 1 then
|
||||
globalData.bossLv = 1
|
||||
end
|
||||
TestMsg(globalData.bossLv, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
function TestMsg(lv, atvId)
|
||||
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg.leveltips then --
|
||||
--ActivityConfig[atvId].fbId)
|
||||
--local msg = "跨服领主当前等级:%d"
|
||||
local str = string.format(ActivityConfig[atvId].leveltips, (lv or 0))
|
||||
--print("Cfg--------string.format--------------------------------------"..tostring(str))
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
--print("Cfgstr------------------------------------------------------------------------%s", tostring(str))
|
||||
end
|
||||
|
||||
--print("Cfg------------------------------------------------------------------------%s", tostring(msg))
|
||||
--local str = string.format(msg, (lv or 0));
|
||||
--print("Cfg------------------------------------------------------------------------%s", tostring(str))
|
||||
-- System.SendChatMsg(str, 4)
|
||||
end
|
||||
|
||||
function setBossGrowLv(atvId, killTime)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
local costtime = killTime - (startTime + Cfg.starttime);
|
||||
if costtime < 0 then
|
||||
costtime = 0
|
||||
end
|
||||
|
||||
local time = 0;
|
||||
local bossLv = 0;
|
||||
for _, cfg in pairs(ActivityConfig[atvId].growlist) do
|
||||
if costtime < cfg.time then
|
||||
bossLv = cfg.addlv
|
||||
break
|
||||
end
|
||||
end
|
||||
-- print("bossLv.."..bossLv)
|
||||
globalData.bossLv = globalData.bossLv + bossLv;
|
||||
if globalData.bossLv < 1 then
|
||||
globalData.bossLv = 1
|
||||
end
|
||||
TestMsg(globalData.bossLv, atvId)
|
||||
-- print("globalData.bossLv .."..(globalData.bossLv or 0))
|
||||
end
|
||||
end
|
||||
|
||||
function OnEntityHurt(atvId, pEntity, damage, isKiller, killTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if actorsInFuben[atvId] and globalData.bossDeath == nil then
|
||||
-- if globalData.bossDeath == nil then
|
||||
-- 攻击boss 获得积分
|
||||
local killerId = Actor.getIntProperty(pEntity, PROP_ENTITY_ID )
|
||||
local addSocre = damage * 0.2 + ActivityConfig[atvId].addScoreKill;
|
||||
|
||||
addSocre = math.floor(addSocre)
|
||||
|
||||
RankMgr.AddValue(killerId, RANKING_ID, addSocre)
|
||||
OnDealAchieve(atvId, pEntity);
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
-- 改成定时 2秒BroadRankData(atvId, fbHandle, sceneId)
|
||||
SendRankData(atvId, pEntity)
|
||||
if isKiller ~= nil and isKiller == 1 and globalData.bossDeath == nil then
|
||||
-- local killerId = Actor.getIntProperty(pEntity, PROP_ENTITY_ID )
|
||||
local killName = Actor.getName(pEntity )
|
||||
globalData.killerId = killerId
|
||||
globalData.killerName = killName;
|
||||
globalData.bossDeath = killTime;
|
||||
-- print("bossdeath "..atvId.." ..atvId."..globalData.killerId)
|
||||
setBossGrowLv(atvId, killTime);
|
||||
-- SendWorldBossAward(atvId, 1);
|
||||
System.closeActivityRunning(atvId, true);
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result, pOwner)
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor then
|
||||
--满血结束血量
|
||||
-- local maxhp = Actor.getIntProperty(pActor,PROP_CREATURE_MAXHP)
|
||||
-- Actor.changeHp(pActor, maxhp)
|
||||
local npack = ActivityDispatcher.AllocResultPack(pActor, atvId, 1)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
WorldBossResult(atvId, npack, actorId)
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function WorldBossResult(atvId, npack, actorId)
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
for i = 1, 3 do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local name = "";
|
||||
if(rankItem) then
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
name = Ranking.getSub(rankItem, 0)
|
||||
end
|
||||
|
||||
DataPack.writeString(npack, name or "")
|
||||
end
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
DataPack.writeString(npack, globalData.killerName or "")
|
||||
local iskiller = 0;
|
||||
if actorId == globalData.killerId then
|
||||
iskiller = 1
|
||||
end
|
||||
DataPack.writeWord(npack, iskiller)
|
||||
end
|
||||
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local result = System.isActivityRunning(atvId)
|
||||
local ret = 0
|
||||
|
||||
-- if result then ret = 1 end
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
if cacheData.status and cacheData.status == AtvStatus.Start then ret = 1 end
|
||||
-- local cfg = ActivityConfig[atvId]
|
||||
-- if cfg and cfg.openParam then
|
||||
-- if Actor.checkActorLevel(pActor,(cfg.openParam.level or 0)) ~=true then ret = 0 end
|
||||
-- end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
----处理成就问题
|
||||
function OnDealAchieve(atvId, pActor)
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData and actorData.isFirst == nil and curVal >= 1000 then
|
||||
Actor.triggerAchieveEvent(pActor,nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
actorData.isFirst = 1;
|
||||
end
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType19.lua")
|
||||
-- ActivityDispatcher.Reg(ActivityEvent.OnEntityHurt, ActivityType, OnEntityHurt, "ActivityType19.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOnAtvRank, ActivityType, OnOnAtvRank, "ActivityType25.lua")
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 杀怪
|
||||
function OnHurtMonster(pActor,damage,isKiller,killTime)
|
||||
-- print("[PActivity 8] "..Actor.getName(pActor).." damage:"..damage.."isKiller: "..isKiller.." killTime: "..killTime)
|
||||
local pFuben = Actor.getFubenPrt(pActor);
|
||||
if pFuben and FubenDispatcher.IsActivityFuben(pFuben) then
|
||||
local atvType = FubenDispatcher.GetActivityType(pFuben);
|
||||
-- print("[PActivity 8] "..pFuben)
|
||||
if atvType == ActivityType then
|
||||
local atvId = FubenDispatcher.GetActivityId(pFuben);
|
||||
-- print("[PActivity 8] "..Actor.getName(pActor).." atvId:"..atvId)
|
||||
OnEntityHurt(atvId, pActor, damage, isKiller, killTime);
|
||||
end
|
||||
end
|
||||
end
|
||||
function OnActorBeKilled(pEntity, pKiller )
|
||||
if pEntity == nil or pKiller == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local entityType = Actor.getEntityType(pEntity)--被击杀者的类型
|
||||
local killerType = Actor.getEntityType(pKiller)--击杀者的类型
|
||||
if killerType ~= enActor or entityType ~= enActor then
|
||||
return
|
||||
end
|
||||
|
||||
local entityId = Actor.getIntProperty( pEntity, PROP_ENTITY_ID )
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
--print("--------------------pEntity---------------------------"..Actor.getName(pEntity)..":"..tostring(entityId))
|
||||
--print("--------------------pKiller---------------------------"..Actor.getName(pKiller)..":"..tostring(killerId))
|
||||
|
||||
--print("[ActivityType19:OnActorBeKilled-1111---------------------------------------------------------------------- OnActorBeKilled")
|
||||
local pFuben = Actor.getFubenPrt(pEntity);
|
||||
if pFuben and FubenDispatcher.IsActivityFuben(pFuben) then
|
||||
local atvType = FubenDispatcher.GetActivityType(pFuben);
|
||||
-- print("[PActivity 8] "..pFuben)
|
||||
if atvType == ActivityType then
|
||||
local atvId = FubenDispatcher.GetActivityId(pFuben);
|
||||
-- print("[PActivity 8] "..Actor.getName(pActor).." atvId:"..atvId)
|
||||
--print("[ActivityType19:OnActorBeKilled-231---------------------------------------------------------------------- OnActorBeKilled")
|
||||
OnEntityBeKilled(atvId, pEntity, pKiller);--收害被害的人对调
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function OnEntityBeKilled(atvId, pEntity, pKiller )
|
||||
|
||||
local entityType = Actor.getEntityType(pEntity)--被击杀者的类型
|
||||
local killerType = Actor.getEntityType(pKiller)--击杀者的类型
|
||||
if killerType ~= enActor or entityType ~= enActor then
|
||||
return
|
||||
end
|
||||
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
local entityId = Actor.getIntProperty( pEntity, PROP_ENTITY_ID )
|
||||
|
||||
local killerRankDate = RankMgr.GetValue(killerId, RANKING_ID)
|
||||
local entityRankDate = RankMgr.GetValue(entityId, RANKING_ID)
|
||||
|
||||
local addSocre = entityRankDate * (math.floor(ActivityConfig[atvId].Plunderratio)/10000)--0.03;
|
||||
addSocre = math.floor(addSocre)
|
||||
|
||||
RankMgr.AddValue(killerId, RANKING_ID, addSocre)
|
||||
RankMgr.SetRank(entityId, RANKING_ID, entityRankDate - addSocre)
|
||||
|
||||
-- 杀玩家获得积分
|
||||
--OnDealAchieve(atvId, pKiller)
|
||||
-- 被玩家击杀的玩家获得的积分
|
||||
--OnDealAchieve(atvId, pEntity)
|
||||
|
||||
Actor.sendTipmsgWithParams(pKiller , tmKuaFuBossPkWin, tstFigthing, tostring(addSocre))
|
||||
Actor.sendTipmsgWithParams(pEntity , tmKuaFuBossPkLost, tstFigthing, tostring(addSocre))
|
||||
--Actor.sendTipmsg(pKiller , "您成功击败["..Actor.getName(pEntity).."],掠夺了"..tostring(addSocre).."积分", tstGetItem)
|
||||
--Actor.sendTipmsg(pEntity, "您被["..Actor.getName(pKiller).."]击败了,扣除了"..tostring(addSocre).."积分", tstGetItem)
|
||||
--print("[ActivityType19:OnEntityBeKilled----------------------------------------------------------------------- OnEntityBeKilled")
|
||||
print("您成功击败["..Actor.getName(pEntity).."],掠夺了"..tostring(addSocre).."积分")
|
||||
print("您被["..Actor.getName(pKiller).."]击败了,扣除了"..tostring(addSocre).."积分")
|
||||
|
||||
--发送客户端刷新信息
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local cacheDataKiller = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
BroadRankData(atvId, fbHandle, sceneId) --公共数据
|
||||
SendRankData(atvId, pEntity) --本人数据
|
||||
SendRankData(atvId, pKiller) --本人数据
|
||||
--关闭活动 System.closeActivityRunning(atvId, true);
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
|
||||
end
|
||||
ActorEventDispatcher.Reg(aeHurtMonster, OnHurtMonster, "ActivityType19.lua")
|
||||
ActorEventDispatcher.Reg(aeOnActorBeKilled, OnActorBeKilled, "ActivityType19.lua")
|
||||
@@ -0,0 +1,370 @@
|
||||
module("ActivityType2", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动,鉴定类活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
usetimes[id]
|
||||
{
|
||||
times 每日已使用次数
|
||||
}
|
||||
|
||||
count[id]
|
||||
{
|
||||
times 拥有次数
|
||||
}
|
||||
openDay 统计开服时间
|
||||
|
||||
}
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 2
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity2Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
local AppraisalMainConfig = AppraisalMainConfig
|
||||
if AppraisalMainConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
--通用操作枚举
|
||||
local Operate = {
|
||||
Appraisal = 6, --鉴定操作
|
||||
}
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求鉴定
|
||||
function operaAppraisal(pActor, atvId, Conf, inPack)
|
||||
local nId = DataPack.readByte(inPack)
|
||||
-- print("operaAppraisal id:",nId)
|
||||
local errorcode = 0
|
||||
--消耗检查
|
||||
while(true)
|
||||
do
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local Conf = Conf[nId]
|
||||
if Conf == nil then
|
||||
errorcode = 1
|
||||
break
|
||||
end
|
||||
local consumes = Conf.number
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, consumes,tstUI) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmAppraisalNoItem, tstUI)
|
||||
errorcode = 2
|
||||
break
|
||||
end
|
||||
local extraCost = nil
|
||||
local myCount = GetOwnTimes(pActor, atvId, nId)
|
||||
local usetimes = GetDailyUseTimes(pActor, atvId, nId)
|
||||
if myCount ~= -1 then
|
||||
if myCount <= 0 then
|
||||
Actor.sendTipmsgWithId(pActor,tmAppraisalNoTimes, tstUI)
|
||||
errorcode = 3
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
-- if Conf.frequency then
|
||||
-- if usetimes >= Conf.frequency then
|
||||
-- extraCost = Conf.gold
|
||||
-- end
|
||||
-- end
|
||||
extraCost = Conf.gold
|
||||
|
||||
if extraCost and CommonFunc.Consumes.CheckActorSources(pActor, extraCost,tstUI) ~= true then
|
||||
-- Actor.sendTipmsgWithId(pActor, tmNoMoreCoin, tstUI)
|
||||
errorcode = 4
|
||||
break
|
||||
end
|
||||
if Conf.mexp then
|
||||
if(Actor.checkConsume(pActor, qatMultiExpUnused, 0, Conf.mexp)) then
|
||||
Actor.sendTipmsgWithId(pActor, tmdoubleExpFull, tstUI)
|
||||
errorcode = 5
|
||||
break
|
||||
end
|
||||
end
|
||||
if Actor.isMaxLevel(pActor) then
|
||||
Actor.sendTipmsgWithId(pActor, tmAppraisalMaxLevel, tstUI)
|
||||
errorcode = 6
|
||||
break
|
||||
end
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity2, "鉴定类活动|"..atvId) ~= true then
|
||||
errorcode = 7
|
||||
break
|
||||
end
|
||||
if extraCost and CommonFunc.Consumes.Remove(pActor, extraCost, GameLog.Log_Activity2, "鉴定类活动|"..atvId) ~= true then
|
||||
errorcode = 8
|
||||
break
|
||||
end
|
||||
addUseTime(pActor, atvId, nId)
|
||||
|
||||
if Conf.gexp then
|
||||
Actor.giveAward(pActor, qatMultiExpUnused, qatMultiExpUnused, Conf.gexp, 0, 0, 0,0, GameLog.Log_Activity2,"鉴定类活动|"..atvId)
|
||||
end
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
break
|
||||
end
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sAppraisal)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
DataPack.writeInt(outPack, nId)
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
--退出活动副本
|
||||
function onExitAtivityFuben(pActor, atvId, fbId)
|
||||
|
||||
end
|
||||
|
||||
-- 添加使用次数
|
||||
function addUseTime(pActor, atvId, nId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data == nil then
|
||||
return
|
||||
end
|
||||
--每日已使用次数
|
||||
if data.usetimes == nil then
|
||||
data.usetimes = {}
|
||||
end
|
||||
--总的可使用次数
|
||||
if data.usetimes[nId] == nil then
|
||||
data.usetimes[nId] = 0
|
||||
end
|
||||
data.usetimes[nId] = data.usetimes[nId] + 1
|
||||
|
||||
-- 扣除次数
|
||||
if data.count == nil then
|
||||
data.count = {}
|
||||
end
|
||||
if data.count[nId] == nil then
|
||||
data.count[nId] = 0
|
||||
end
|
||||
if data.count[nId] > 0 then
|
||||
data.count[nId] = data.count[nId] - 1
|
||||
end
|
||||
end
|
||||
|
||||
-- 获取每日使用次数
|
||||
function GetDailyUseTimes(pActor, atvId, nId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
--每日已使用次数
|
||||
if data.usetimes == nil then
|
||||
data.usetimes = {}
|
||||
end
|
||||
if data.usetimes[nId] == nil then
|
||||
data.usetimes[nId] = 0
|
||||
end
|
||||
|
||||
return data.usetimes[nId] or 0
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 获取拥有次数
|
||||
function GetOwnTimes(pActor, atvId, nId)
|
||||
|
||||
-- local myCount = Conf.frequency
|
||||
-- if Conf.iscostfree and Conf.iscostfree == 0 then
|
||||
-- local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
-- if data.count == nil then
|
||||
-- data.count = 0
|
||||
-- end
|
||||
-- myCount = data.count
|
||||
-- end
|
||||
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = {}
|
||||
end
|
||||
|
||||
return data.count[nId] or 0
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--清除上次活动个人数据
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
print("[PActivity 2] "..Actor.getName(pActor).." 活动开始了,id:"..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
-- data.count = openday * (ActivityConfig[atvId].count or 1)
|
||||
|
||||
if data.openDay == nil then
|
||||
data.openDay = openday
|
||||
end
|
||||
if data.count == nil then
|
||||
data.count = {}
|
||||
end
|
||||
local Conf = AppraisalMainConfig[atvId]
|
||||
if Conf then
|
||||
for _, cfg in ipairs(Conf) do
|
||||
local addValue = 1;
|
||||
|
||||
if cfg.iscostfree and cfg.iscostfree == 0 then
|
||||
addValue = openday
|
||||
end
|
||||
-- print("111111: "..addValue)
|
||||
data.count[cfg.id] = addValue* cfg.frequency;
|
||||
end
|
||||
end
|
||||
-- print("[Activity 2] "..Actor.getName(pActor).." 活动开始了,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
print("[Activity 2] "..Actor.getName(pActor).." 活动结束了,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime, pActor)
|
||||
--print("[Activity 1] "..Actor.getName(pActor).." 活动进行中,id:"..atvId.." now:"..curTime)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
-- local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
-- print("请求活动数据,id:: "..data.count);
|
||||
local Conf = AppraisalMainConfig[atvId]
|
||||
local t = 0
|
||||
if Conf then
|
||||
t = #Conf
|
||||
end
|
||||
|
||||
DataPack.writeInt(outPack, (t or 0))
|
||||
if Conf then
|
||||
for i,cfg in ipairs(Conf) do
|
||||
DataPack.writeByte(outPack, (cfg.id or 0))
|
||||
local usetimes = GetDailyUseTimes(pActor, atvId, cfg.id)
|
||||
DataPack.writeInt(outPack, (usetimes or 0))
|
||||
local times = GetOwnTimes(pActor, atvId, cfg.id)
|
||||
DataPack.writeInt(outPack, (times or 0))
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
-- print("[OnOperatorOnOperator 2] "..Actor.getName(pActor).." OnOperator,id:"..atvId)
|
||||
local Conf = AppraisalMainConfig[atvId]
|
||||
if Conf == nil then
|
||||
return
|
||||
-- print("[Activity 2] "..Actor.getName(pActor).." 鉴定类型中找不到活动id:"..atvId)
|
||||
end
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cAppraisal then -- 请求水晶鉴定
|
||||
operaAppraisal(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType2.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType2.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType2.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType2.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType2.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 进入副本
|
||||
function OnEnterFuben(pActor, fbId)
|
||||
|
||||
end
|
||||
|
||||
-- 退出副本
|
||||
function OnExitFuben(pActor, fbId)
|
||||
|
||||
end
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,ndiffday)
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
print("[Activity 2] "..Actor.getName(pActor).." 跨天,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count == nil then
|
||||
data.count = {}
|
||||
end
|
||||
|
||||
if data.usetimes then
|
||||
data.usetimes = {}
|
||||
end
|
||||
if data.openDay == nil then
|
||||
data.openDay = 0
|
||||
end
|
||||
|
||||
-- 按照离线时间
|
||||
local offline_day = 1;
|
||||
offline_day = openday- data.openDay;
|
||||
if offline_day < 1 then
|
||||
offline_day = 1;
|
||||
end
|
||||
data.openDay = openday
|
||||
local Conf = AppraisalMainConfig[atvId]
|
||||
if Conf then
|
||||
for _, cfg in ipairs(Conf) do
|
||||
|
||||
-- if data.count[cfg.id] == nil then
|
||||
-- data.count[cfg.id] = 0;
|
||||
-- end
|
||||
|
||||
if cfg.iscostfree and cfg.iscostfree == 0 then
|
||||
if data.count[cfg.id] == nil then
|
||||
data.count[cfg.id] = openday * cfg.frequency
|
||||
else
|
||||
data.count[cfg.id] = offline_day* cfg.frequency + data.count[cfg.id];
|
||||
end
|
||||
else
|
||||
data.count[cfg.id] = cfg.frequency;
|
||||
end
|
||||
end
|
||||
end
|
||||
-- data.openDay = openday
|
||||
-- data.count = data.count + offday* (ActivityConfig[atvId].count or 5)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeOnEnterFuben, OnEnterFuben, "ActivityType2.lua")
|
||||
ActorEventDispatcher.Reg(aeOnExitFuben, OnExitFuben, "ActivityType2.lua")
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType2.lua")
|
||||
@@ -0,0 +1,645 @@
|
||||
module("ActivityType20", package.seeall)
|
||||
|
||||
--[[
|
||||
沙巴克
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
sbkArea[sceneid] //sceneid 场景id
|
||||
{
|
||||
state //状态
|
||||
}
|
||||
needDealarea
|
||||
{
|
||||
area
|
||||
{
|
||||
sceneid, //场景id
|
||||
x, x坐标
|
||||
y, y坐标
|
||||
}
|
||||
}
|
||||
paodianTime,
|
||||
warNotice,--沙巴克皇宫可以开始占领!公告
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
sbkGuild sbk领主id
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 21
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity21Config
|
||||
--排行榜id
|
||||
RANKING_ID_1 = RANK_DEFINE_ACTIVITY20 --玩家积分
|
||||
RANKING_ID_2 = RANK_DEFINE_ACTIVITY21 --行会积分
|
||||
-- if ActivityConfig == nil then
|
||||
-- assert(false)
|
||||
-- end
|
||||
local SbkState = 0;
|
||||
-- 活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
PreEnter = 1, --活动前5分钟(走马灯全服公告,不给进入)
|
||||
Start = 2, --开始
|
||||
Sbk = 3, --沙巴克时间
|
||||
End = 4, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
--助攻列表
|
||||
attackerList=
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [handle,被攻击者] =
|
||||
-- {
|
||||
-- [attkHandle,攻击者] = 最新攻击时间
|
||||
-- }
|
||||
--}
|
||||
}
|
||||
|
||||
--阶段奖励的领取记录,记录下一次要领取的阶段索引
|
||||
actorAwardIdx =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [aid] = idx
|
||||
--}
|
||||
}
|
||||
|
||||
--在场景中的玩家
|
||||
actorsInFuben =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [actorId] = actorId
|
||||
--}
|
||||
}
|
||||
--在场景中的玩家
|
||||
guildsInFuben =
|
||||
{
|
||||
--[guild] =
|
||||
--{
|
||||
-- [actorId] = actorId
|
||||
--}
|
||||
}
|
||||
|
||||
local PaodianTime = 0;
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 20] 沙巴克 活动数据加载,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 20] 沙巴克 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
setSbkAwardFlag(nil);
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID_1)
|
||||
RankMgr.Clear(RANKING_ID_2)
|
||||
Guild.setSbkGuildId(0);
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
globalData.sbkGuild = 0
|
||||
print("[GActivity 20] 沙巴克 活动开始了,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg then
|
||||
-- System.broadcastTipmsgLimitLev(Cfg.endsbk, tstBigRevolving)
|
||||
-- System.broadcastTipmsgLimitLev(Cfg.endsbk, tstChatSystem)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData.sbkGuild then
|
||||
local guildName = Guild.getGuildName(globalData.sbkGuild)
|
||||
if guildName then
|
||||
local str = string.format(Cfg.endsbk, guildName)
|
||||
System.broadcastTipmsgLimitLev(str, tstBigRevolving)
|
||||
-- print("..on")
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
end
|
||||
if cacheData.sbkArea then
|
||||
for _, sceneid in Ipairs(cacheData.sbkArea) do
|
||||
-- print("vvvv.."..sceneid)
|
||||
Fuben.ResetFubenSceneConfig(sceneid);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
-- 发送奖励
|
||||
SendRankAward( atvId )
|
||||
SendSbkguildAward();
|
||||
-- 补发阶段奖励
|
||||
SendScoreAward(atvId)
|
||||
SbkState = AtvStatus.End
|
||||
ActivityDispatcher.ClearCacheData(atvId);
|
||||
actorAwardIdx[atvId] = nil
|
||||
attackerList[atvId] = nil
|
||||
actorsInFuben[atvId] = nil
|
||||
guildsInFuben= {};
|
||||
print("[GActivity 20] 沙巴克 活动结束了,id:"..atvId)
|
||||
end
|
||||
|
||||
|
||||
--公告
|
||||
function SendNotice(avtId, curTime)
|
||||
local cfg = ActivityConfig
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cfg == nil then
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 发送积分奖励
|
||||
function SendScoreAward(atvId)
|
||||
local MaxIdx = #ActivityConfig.phaseAward
|
||||
local title = ActivityConfig.phaseAwardMailTT
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
return
|
||||
end
|
||||
for aid,awdIdx in pairs(actorAwardIdx[atvId]) do
|
||||
if actorAwardIdx[atvId][aid] ~= nil then
|
||||
local rankValue = RankMgr.GetValue(aid, RANKING_ID_1)
|
||||
-- rankValue = rankValue+ 100
|
||||
-- print("SendScoreAward.."..rankValue)
|
||||
local award = nil;
|
||||
for i=1,MaxIdx do
|
||||
local awardConf = ActivityConfig.phaseAward[i]
|
||||
|
||||
if awardConf then
|
||||
if rankValue >= awardConf.value then
|
||||
award = awardConf;
|
||||
end
|
||||
end
|
||||
end
|
||||
-- print("awardConf.."..(award.value or 0).."..type.."..type(award.awards))
|
||||
if award then
|
||||
local content = string.format(ActivityConfig.phaseAwardMailCT, award.value)
|
||||
SendCrossServerMail(aid, title, content, award.awards)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 发送排名奖励
|
||||
function SendRankAward(atvId)
|
||||
local ranking = Ranking.getRanking( RANKING_ID_2 )
|
||||
if ranking then
|
||||
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
local idx = 0
|
||||
|
||||
for i=idx,itemNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i)
|
||||
local guildid = Ranking.getId(rankItem)
|
||||
System.sendGuildSBKRank(guildid, i+1);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送排名奖励
|
||||
function SendSbkguildAward()
|
||||
System.sendSBKGuild();
|
||||
end
|
||||
|
||||
---处理结束邮件问题
|
||||
function OnSendGuildMail(atvId, pActor)
|
||||
local ActorType = Actor.getEntityType(pActor)--类型
|
||||
if ActorType ==enActor then
|
||||
local cfg = ActivityConfig
|
||||
if cfg and cfg.mailtitle and cfg.mailcontent then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
SendCrossServerMail(actorid,srvid, cfg.mailtitle, cfg.mailcontent)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- end
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
SendNotice(atvId, curTime);
|
||||
DealSbkAreaAttr(atvId, curTime);
|
||||
dealGuildSbk(atvId,curTime);
|
||||
dealPaodianExp(atvId,curTime)
|
||||
|
||||
end
|
||||
|
||||
|
||||
--p泡点
|
||||
function dealPaodianExp(atvId, curTime)
|
||||
--检测沙巴克占领是否开启
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if Cfg then
|
||||
if Cfg.starttime then
|
||||
if curTime < (startTime + Cfg.starttime) then
|
||||
return
|
||||
end
|
||||
end
|
||||
if cacheData.paodianTime == nil then
|
||||
cacheData.paodianTime = 0
|
||||
end
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
|
||||
if curTime >= cacheData.paodianTime then
|
||||
cacheData.paodianTime = curTime + 10
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
local guildid = Actor.getGuildId(pActor);
|
||||
if guildid > 0 then
|
||||
-- 行会积分
|
||||
RankMgr.AddGuildRankValue(guildid, RANKING_ID_2, ActivityConfig.addScoreAuto)
|
||||
SendRankData(atvId,pActor);
|
||||
BroadSbkRankData(atvId);
|
||||
end
|
||||
RankMgr.AddValue(actorid, RANKING_ID_1, ActivityConfig.addScoreAuto)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID_1)
|
||||
-- OnDealAchieve(atvId, pActor)
|
||||
Actor.sendTipmsg(pActor, "持续参加活动,积分+"..ActivityConfig.addScoreAuto..",当前积分为:"..curVal, tstGetItem)
|
||||
SendMyRankData(atvId,pActor)
|
||||
hasMan = true
|
||||
end
|
||||
end
|
||||
if hasMan then
|
||||
RankMgr.Save(RANKING_ID_1);
|
||||
RankMgr.Save(RANKING_ID_2);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--沙巴克行为
|
||||
function dealGuildSbk(atvId, curTime)
|
||||
--检测沙巴克占领是否开启
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
-- print("dealGuild.."..startTime)
|
||||
if Cfg then
|
||||
if Cfg.wartime then
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if curTime < (startTime + Cfg.wartime) then
|
||||
return
|
||||
end
|
||||
|
||||
if not cacheData.warNotice and Cfg.wartimestr then
|
||||
cacheData.warNotice = 1
|
||||
System.broadcastTipmsgLimitLev(Cfg.wartimestr, tstRevolving)
|
||||
System.broadcastTipmsgLimitLev(Cfg.wartimestr, tstChatSystem)
|
||||
end
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData.sbkGuild == nil then
|
||||
globalData.sbkGuild = 0
|
||||
end
|
||||
if Cfg.winmap then
|
||||
local guildId = Fuben.GetNowSceneGuildList(Cfg.winmap);
|
||||
if guildId > 0 and globalData.sbkGuild ~= guildId then
|
||||
globalData.sbkGuild = guildId
|
||||
Guild.setSbkGuildId(guildId);
|
||||
local guildName = Guild.getGuildName(guildId)
|
||||
if guildName then
|
||||
local str = string.format(Cfg.sbknotic, guildName)
|
||||
System.broadcastTipmsgLimitLev(str, tstRevolving)
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 处理活动开始 设置sbk区域为战斗区域
|
||||
function DealSbkAreaAttr(atvId, curTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if Cfg and Cfg.starttime then
|
||||
if curTime > (startTime + Cfg.starttime) then
|
||||
if SbkState ~= AtvStatus.Sbk then
|
||||
SbkState = AtvStatus.Sbk
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
ActivityDispatcher.BroadPopup(atvId);
|
||||
end
|
||||
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
|
||||
if cacheData.sbkArea == nil then
|
||||
cacheData.sbkArea = {}
|
||||
end
|
||||
-- 已经设置OK
|
||||
for _, area in Ipairs(cacheData.needDealarea) do
|
||||
if Cfg.areaattr and Cfg.areaattr.attri then
|
||||
for _, attr in pairs(Cfg.areaattr.attri) do
|
||||
local index = Fuben.GetAreaListIndex(area.sceneid, area.x, area.y)
|
||||
local hScene = Fuben.getSceneHandleById(area.sceneid, 0)
|
||||
if index > 0 then
|
||||
Fuben.setSceneAreaAttri(hScene, index, attr.type, attr.value, NULL, (Cfg.areaattr.notips or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
-- print("西门吹雪 .."..area.sceneid)
|
||||
cacheData.sbkArea[area.sceneid] = area.sceneid
|
||||
end
|
||||
cacheData.needDealarea = nil;
|
||||
--设置战斗区域
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--发送玩家下一次领取奖励的索引
|
||||
function SendNextAwardIndex(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sNextAwardIndex)
|
||||
if npack then
|
||||
local aid = Actor.getActorId(pActor)
|
||||
|
||||
|
||||
|
||||
DataPack.writeByte(npack, (actorAwardIdx[atvId][aid] or 1))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
end
|
||||
|
||||
-- 活动区域需要处理新增区域属性
|
||||
function OnEnterArea(atvId, pActor)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local sceneId = Actor.getSceneId(pActor);
|
||||
if cacheData.areaAttr == nil then
|
||||
cacheData.areaAttr = {}
|
||||
end
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
local guildid = Actor.getGuildId(pActor);
|
||||
if guildsInFuben[guildid] == nil then
|
||||
guildsInFuben[guildid] = {}
|
||||
end
|
||||
guildsInFuben[guildid][actorId] = 1;
|
||||
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
actorAwardIdx[atvId] = {}
|
||||
end
|
||||
|
||||
if actorAwardIdx[atvId][actorId] == nil then
|
||||
actorAwardIdx[atvId][actorId] = 1
|
||||
end
|
||||
|
||||
local x,y = Actor.getEntityPosition(pActor,0,0)
|
||||
-- 已经初始化完成
|
||||
if cacheData.areaAttr[sceneId] then
|
||||
return;
|
||||
end
|
||||
print("来了吗.."..sceneId)
|
||||
cacheData.areaAttr[sceneId] = 1;
|
||||
local area = {};
|
||||
area.sceneid = sceneId;
|
||||
area.x = x
|
||||
area.y = y
|
||||
-- -- print("OnEnterArea x.."..x.." y.."..y);
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
|
||||
cacheData.needDealarea[sceneId] = area
|
||||
-- 发送下一次领取奖励的索引
|
||||
-- SendNextAwardIndex(pActor, atvId)
|
||||
-- table.insert(cacheData.needDealarea, area);
|
||||
end
|
||||
|
||||
|
||||
-- 离开活动区域
|
||||
function OnExitArea(atvId, pActor)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = 0
|
||||
local guildid = Actor.getGuildId(pActor);
|
||||
if guildsInFuben[guildid] == nil then
|
||||
guildsInFuben[guildid] = {}
|
||||
end
|
||||
guildsInFuben[guildid][actorId] = 0;
|
||||
end
|
||||
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
-- print("SbkState.."..SbkState)
|
||||
if SbkState == AtvStatus.Sbk then ret = 1 end
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
|
||||
--实体在活动副本中死亡
|
||||
function OnEntityDeath(atvId, pEntity)
|
||||
--print(debug.traceback("Stack trace"))
|
||||
local killerHandle = Actor.getKillHandle(pEntity);
|
||||
local pKiller = Actor.getEntity(killerHandle)
|
||||
if pKiller then
|
||||
|
||||
local entityType = Actor.getEntityType(pEntity)--被击杀者的类型
|
||||
local killerType = Actor.getEntityType(pKiller)--击杀者的类型
|
||||
-- print("111111111111111111..killerType"..killerType.."..entityType.."..entityType)
|
||||
if killerType == enActor then
|
||||
if entityType == enActor then
|
||||
-- 杀玩家获得积分
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
-- print("222enActor.."..killerId)
|
||||
RankMgr.AddValue(killerId, RANKING_ID_1, ActivityConfig.addScoreKill)
|
||||
local guildid = Actor.getGuildId(pKiller);
|
||||
if guildid > 0 then
|
||||
-- 行会积分
|
||||
RankMgr.AddGuildRankValue(guildid, RANKING_ID_2, ActivityConfig.addScoreKill)
|
||||
SendRankData(atvId,pKiller);
|
||||
BroadSbkRankData(atvId);
|
||||
end
|
||||
SendMyRankData(atvId, pKiller);
|
||||
Actor.sendTipmsg(pKiller, "你成功击败["..Actor.getName(pEntity).."],积分+"..ActivityConfig.addScoreKill, tstGetItem)
|
||||
|
||||
-- 被玩家击杀的玩家获得的积分
|
||||
local entityId = Actor.getIntProperty( pEntity, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(entityId, RANKING_ID_1, ActivityConfig.addScoreBeKill)
|
||||
local guildid = Actor.getGuildId(pEntity);
|
||||
if guildid > 0 then
|
||||
-- 行会积分
|
||||
RankMgr.AddGuildRankValue(guildid, RANKING_ID_2, ActivityConfig.addScoreBeKill)
|
||||
SendRankData(atvId,pEntity);
|
||||
BroadSbkRankData(atvId);
|
||||
end
|
||||
SendMyRankData(atvId, pEntity);
|
||||
Actor.sendTipmsg(pEntity, "你被["..Actor.getName(pKiller).."]击败了,积分+"..ActivityConfig.addScoreBeKill, tstGetItem)
|
||||
else
|
||||
-- 杀守卫获得积分
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
-- print("33333enActor.."..killerId)
|
||||
RankMgr.AddValue(killerId, RANKING_ID_1, ActivityConfig.addScoreGuard)
|
||||
local guildid = Actor.getGuildId(pKiller);
|
||||
if guildid > 0 then
|
||||
-- 行会积分
|
||||
RankMgr.AddGuildRankValue(guildid, RANKING_ID_2, ActivityConfig.addScoreGuard)
|
||||
SendRankData(atvId,pKiller);
|
||||
BroadSbkRankData(atvId);
|
||||
end
|
||||
SendMyRankData(atvId, pKiller);
|
||||
-- OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你击败守卫,积分+"..ActivityConfig.addScoreGuard, tstGetItem)
|
||||
end
|
||||
|
||||
if not attackerList[atvId] then attackerList[atvId] = {} end
|
||||
|
||||
-- 助攻积分
|
||||
local handle = Actor.getHandle(pEntity)
|
||||
local entityName = Actor.getName(pEntity)
|
||||
if attackerList[atvId][handle] then
|
||||
local nowTime = System.getCurrMiniTime()
|
||||
local killerHandle = Actor.getHandle(pKiller)
|
||||
for attkHandle,time in pairs(attackerList[atvId][handle]) do
|
||||
if nowTime - time <= ActivityConfig.helpTime and killerHandle ~= attkHandle then
|
||||
local pActor = Actor.getEntity(attkHandle)
|
||||
if pActor then
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(actorId, RANKING_ID_1, ActivityConfig.addScoreHelpKill)
|
||||
local guildid = Actor.getGuildId(pActor);
|
||||
if guildid > 0 then
|
||||
-- 行会积分
|
||||
RankMgr.AddGuildRankValue(guildid, RANKING_ID_2, ActivityConfig.addScoreHelpKill)
|
||||
SendRankData(atvId,pActor);
|
||||
BroadSbkRankData(atvId);
|
||||
end
|
||||
SendMyRankData(atvId, pActor);
|
||||
-- OnDealAchieve(atvId, pActor)
|
||||
Actor.sendTipmsg(pActor, "你助攻击败["..entityName.."],积分+"..ActivityConfig.addScoreHelpKill, tstGetItem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
attackerList[atvId][handle] = nil
|
||||
end
|
||||
SendRankData(atvId,pKiller)
|
||||
-- BroadSbkRankData(atvId);
|
||||
SendMyRankData(atvId, pKiller);
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动副本中,实体守到攻击
|
||||
function OnEntityAttacked(atvId, pEntity, pAttacker)
|
||||
|
||||
-- 攻击者必须为玩家,才记录助攻
|
||||
if Actor.getEntityType(pAttacker) == enActor then
|
||||
-- print("222222222222222222222222")
|
||||
-- 通过句柄作为key(因为守卫的id是一样的,所以只能通过handle区分)
|
||||
local handle = Actor.getHandle(pEntity)
|
||||
local attkHandle = Actor.getHandle(pAttacker)
|
||||
|
||||
if not attackerList[atvId] then attackerList[atvId] = {} end
|
||||
|
||||
local info = attackerList[atvId][handle]
|
||||
if not info then
|
||||
attackerList[atvId][handle] = { [attkHandle] = System.getCurrMiniTime() }
|
||||
else
|
||||
info[attkHandle] = System.getCurrMiniTime()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function BroadSbkRankData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local fbHandle = Fuben.getStaticFubenHandle()
|
||||
if cacheData.sbkArea then
|
||||
for _, sceneid in Ipairs(cacheData.sbkArea) do
|
||||
BroadRankData(atvId, fbHandle, sceneid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadRankData(atvId,fbHandle,sceneId)
|
||||
-- 广播所有玩家排行榜数据
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sCSSBKGuildRank)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID_2, 4, npack)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送行会排行数据
|
||||
function SendRankData(atvId,pActor)
|
||||
local guildid = Actor.getGuildId(pActor);
|
||||
if guildid > 0 then
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sCSSBKMyGuildRank)
|
||||
if npack then
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(guildid,RANKING_ID_2))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyGuildRank(guildid,RANKING_ID_2))
|
||||
DataPack.broadGuild(npack,guildid)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家排行数据
|
||||
function SendMyRankData(atvId,pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sCSSBKMyRank)
|
||||
if npack then
|
||||
local actorid = Actor.getActorId(pActor);
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorid,RANKING_ID_1))
|
||||
DataPack.writeByte(npack, 1)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnAtvAreaDeath, ActivityType, OnEntityDeath, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnAtvAreaAtk, ActivityType, OnEntityAttacked, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterArea, ActivityType, OnEnterArea, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitArea, ActivityType, OnExitArea, "ActivityType21.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType21.lua")
|
||||
@@ -0,0 +1,69 @@
|
||||
module("ActivityType22", package.seeall)
|
||||
|
||||
--[[
|
||||
跨服入口
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 22
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity22Config
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
function operaResult(pActor, atvId, Conf, inPack)
|
||||
local errorCode = 0;
|
||||
local nOpenDay = System.getDaysSinceOpenServer();
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg and Cfg.openParam then
|
||||
|
||||
if Actor.checkCommonLimit(pActor,(Cfg.openParam.level or 0), (Cfg.openParam.zsLevel or 0),
|
||||
(Cfg.openParam.vip or 0), (Cfg.openParam.office or 0)) == false then
|
||||
errorCode = 1
|
||||
end
|
||||
if (Cfg.openParam.openDay or 0) > nOpenDay then
|
||||
errorCode = 2
|
||||
end
|
||||
end
|
||||
print("errorCode.."..errorCode)
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.cCheckCSActivity)
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, errorCode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cCheckCSActivity then
|
||||
operaResult(pActor,atvId)
|
||||
end
|
||||
end
|
||||
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 1
|
||||
return ret
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType22.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType22.lua")
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
module("ActivityType23", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动,膜拜活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 剩余膜拜次数
|
||||
dailytime 每日次数
|
||||
openDay 统计开服时间
|
||||
}
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 23
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity23Config
|
||||
local WorshipCommonConfig= WorshipCommonConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
if WorshipCommonConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--膜拜操作
|
||||
function operaWorship(pActor, atvId, Conf, inPack)
|
||||
-- local nId = DataPack.readUInt(inPack)
|
||||
local nIndex = DataPack.readByte(inPack)
|
||||
local errorcode = 0
|
||||
local WorshipCfg = WorshipCommonConfig[atvId]
|
||||
if WorshipCfg == nil then
|
||||
return
|
||||
end
|
||||
while(true)
|
||||
do
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
|
||||
--次数检查
|
||||
|
||||
if data.count == nil then
|
||||
data.count = Conf.count
|
||||
else
|
||||
if data.count <= 0 then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)
|
||||
errorcode = 2
|
||||
break
|
||||
end
|
||||
end
|
||||
if data.dailytime == nil then
|
||||
data.dailytime = 0
|
||||
end
|
||||
|
||||
consumes = WorshipCfg.cost1
|
||||
if WorshipCfg.n then
|
||||
if data.dailytime >= WorshipCfg.n then
|
||||
consumes = WorshipCfg.cost2
|
||||
end
|
||||
end
|
||||
-- if WorshipCfg.rankid then
|
||||
|
||||
-- local ranking = Ranking.getRanking(WorshipCfg.rankid )
|
||||
-- if ranking then
|
||||
-- local result = Ranking.CheckActorIdInRank(ranking, nId)
|
||||
-- if result == false then
|
||||
-- errorcode = 3
|
||||
-- Actor.sendTipmsgWithId(pActor, tmPleaseReferRank, tstUI)
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
if consumes then
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoMoreBindCoin, tstUI)
|
||||
errorcode = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,11,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity4, "膜拜活动|"..atvId) ~= true then
|
||||
errorcode = 3
|
||||
break
|
||||
end
|
||||
if WorshipCfg.rewards then
|
||||
--CommonFunc.GiveCommonAward(pActor, WorshipCfg.rewards, GameLog.Log_Activity4, "膜拜活动|"..atvId)
|
||||
|
||||
if CommonFunc.Awards.Give(pActor, WorshipCfg.rewards, GameLog.Log_Activity4, "膜拜活动|"..atvId, 11 ) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
-- 操作成功
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
-- print("count:",data.count)
|
||||
data.count = data.count - 1
|
||||
-- print("count111111:",data.count)
|
||||
data.dailytime = data.dailytime + 1
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
break
|
||||
end
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sWorship)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
-- DataPack.writeUInt(outPack, nId)
|
||||
DataPack.writeByte(outPack, nIndex)
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--初始化活动个人数据
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
print("[PActivity 23] "..Actor.getName(pActor).." 活动开始了,id:"..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local openday = System.getDaysSinceOpenServer() - ((PActivitiesConf[atvId].OpenSrvDate or 0) -1);
|
||||
data.count = openday * (ActivityConfig[atvId].count or 1)
|
||||
if data.openDay == nil then
|
||||
data.openDay = System.getDaysSinceOpenServer()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- function SendPushToPack(Cfg, pack)
|
||||
-- local itemNum = 0;
|
||||
-- if itemNum ~= -1 and (Cfg ~= nil and Cfg.rankid ~= nil) then
|
||||
-- local ranking = Ranking.getRanking( Cfg.rankid )
|
||||
-- if (ranking == nil) then
|
||||
-- itemNum = 0
|
||||
-- end
|
||||
|
||||
-- local itemNum = Ranking.getRankItemCount(ranking)
|
||||
-- if (itemNum == nil) then
|
||||
-- itemNum = 0
|
||||
-- end
|
||||
|
||||
-- DataPack.writeByte(pack, itemNum)
|
||||
-- for idx=1,itemNum do
|
||||
-- local rankItem = Ranking.getItemFromIndex(ranking, idx-1)
|
||||
-- if rankItem then
|
||||
-- local playerId = Ranking.getId(rankItem)
|
||||
-- local name = Ranking.getSub(rankItem, 0)
|
||||
-- local sexJob = Ranking.getSub(rankItem, 1)
|
||||
-- DataPack.writeUInt(pack, playerId)
|
||||
-- DataPack.writeString(pack, name)
|
||||
-- DataPack.writeString(pack, sexJob)
|
||||
-- end
|
||||
-- end
|
||||
-- else
|
||||
-- DataPack.writeByte(pack, 0)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
print("[Activity 23] "..Actor.getName(pActor).." 活动结束了,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime, pActor)
|
||||
--print("[Activity 1] "..Actor.getName(pActor).." 活动进行中,id:"..atvId.." now:"..curTime)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
-- print("OnReqData:",data.count)
|
||||
DataPack.writeInt(outPack, (data.count or 0))
|
||||
-- local WorshipCfg = WorshipCommonConfig[atvId]
|
||||
-- -- 发送排行数据
|
||||
-- SendPushToPack(WorshipCfg, outPack)
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
print("[Activity 23] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cWorship then -- 请求膜拜
|
||||
operaWorship(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local ret = 0
|
||||
if data.count and (data.count > 0) then ret = 1 end
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
if Actor.checkActorLevel(pActor,(cfg.openParam.level or 0)) ~=true then ret = 0 end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType23.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType23.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType23.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType23.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType23.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType23.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor)
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
print("[Activity 23] "..Actor.getName(pActor).." 跨天清空活动次数,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
if data.openDay == nil then
|
||||
data.openDay = (PActivitiesConf[atvId].OpenSrvDate or 0) -1
|
||||
end
|
||||
-- 按照离线时间
|
||||
local offday = 1;
|
||||
-- print("OnNewDayArrive.."..data.openDay.."..openday.."..openday)
|
||||
offday = openday- data.openDay;
|
||||
if offday < 0 then
|
||||
offday = 1;
|
||||
end
|
||||
data.count = data.count + offday * (ActivityConfig[atvId].count or 1)
|
||||
-- print("OnNewDayArrive:",data.count)
|
||||
data.dailytime = 0
|
||||
|
||||
data.openDay = openday
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType23.lua")
|
||||
@@ -0,0 +1,36 @@
|
||||
module("ActivityType22", package.seeall)
|
||||
|
||||
--[[
|
||||
跨服入口
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 24
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity24Config
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[Activity 24] 活动结束了,id:"..atvId)
|
||||
System.KickAllCrossServerActor();
|
||||
end
|
||||
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType24.lua")
|
||||
|
||||
@@ -0,0 +1,854 @@
|
||||
module("ActivityType25", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动,世界boss
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
buffValue, 鼓舞属性
|
||||
nextLoginTime, 退出后下次可进来的时间戳
|
||||
inspire {
|
||||
[1] = {times, addvalue }
|
||||
} 鼓舞次数
|
||||
isFirst 第一次
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
notice{} 公告
|
||||
referFlag, 刷新标志位
|
||||
status
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
bossLv, boss等级
|
||||
bossDeath, 是否死亡
|
||||
killerName, 击杀者昵称
|
||||
killerId, 击杀者id
|
||||
atvStartTime, 当前活动开始时间
|
||||
isAward --是否发奖
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 25
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity25Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY4
|
||||
|
||||
-- 活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
PreEnter = 1, --活动前5分钟(走马灯全服公告,不给进入)
|
||||
Start = 2, --开始
|
||||
End = 3, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
--在场景中的玩家
|
||||
actorsInFuben = {}
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local fbHandle = Actor.getFubenHandle(pActor)
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
--活动前走马灯通告的时间戳
|
||||
preEnterNoticeTime = 0
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
BossConfAtvId = 11
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
-- print("[GActivity 8] "..Actor.getName(pActor).." 请求进入副本 id"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--退出后登入的时间限制
|
||||
if actorData.nextLoginTime and actorData.nextLoginTime > System.getCurrMiniTime() then
|
||||
Actor.sendTipmsg(pActor, "请30秒后再进入!", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if globalData.bossDeath then
|
||||
Actor.sendTipmsgWithId(pActor, tmBossDeath, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 这个阶段还不能进入
|
||||
if cacheData.status == AtvStatus.PreEnter then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoInOpenTime, tstUI)
|
||||
-- Actor.sendTipmsg(pActor, "活动当前阶段不能进入!", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--进入副本
|
||||
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 重置下次进入时间
|
||||
actorData.nextLoginTime = nil
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
-- print("atvId = "..atvId.." actorId="..actorsInFuben[atvId][actorId])
|
||||
|
||||
-- 广播一次排行榜
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
RankMgr.Save(RANKING_ID)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
SendRankData(atvId,pActor)
|
||||
-- 强制全体和平模式
|
||||
Actor.setPkMode(pActor,fpPeaceful)
|
||||
addInspireBuff(pActor, atvId);
|
||||
SendLeftTimeInfo(pActor, atvId);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadRankData(atvId,fbHandle,sceneId)
|
||||
-- 广播所有玩家排行榜数据
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID, 100, npack)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
--玩家鼓舞
|
||||
function ActorInspire(pActor, atvId, type)
|
||||
-- print("[GActivity 8] "..Actor.getName(pActor).." 玩家鼓舞 id "..atvId.." type "..type)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
local errorcode = 0;
|
||||
local value = 0;
|
||||
local lefttimes = 0;
|
||||
while(true)
|
||||
do
|
||||
if actorsInFuben[atvId] then
|
||||
--初始化鼓舞数据
|
||||
if actorData.inspire == nil then
|
||||
actorData.inspire = {}
|
||||
end
|
||||
if actorData.inspire[type] == nil then
|
||||
actorData.inspire[type] = {};
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[atvId].inspire
|
||||
if Cfg == nil then
|
||||
errorcode = 1;
|
||||
break
|
||||
end
|
||||
|
||||
local inspireCfg = Cfg[type]
|
||||
if inspireCfg == nil or inspireCfg.type ~= type then
|
||||
errorcode = 1;
|
||||
break
|
||||
end
|
||||
if actorData.inspire[type].times == nil then
|
||||
actorData.inspire[type].times = 0;
|
||||
end
|
||||
|
||||
if actorData.inspire[type].times >= inspireCfg.times then
|
||||
errorcode = 2;
|
||||
break;
|
||||
end
|
||||
|
||||
if inspireCfg.costs and CommonFunc.Consumes.Check(pActor, inspireCfg.costs) ~= true then
|
||||
errorcode = 3;
|
||||
break;
|
||||
end
|
||||
|
||||
if inspireCfg.costs and CommonFunc.Consumes.Remove(pActor, inspireCfg.costs, GameLog.Log_Activity8, "世界boss|"..atvId) ~= true then
|
||||
errorcode = 4
|
||||
break
|
||||
end
|
||||
if actorData.buffValue == nil then
|
||||
actorData.buffValue = 0;
|
||||
end
|
||||
|
||||
-- actorData.buffValue = actorData.buffValue + inspireCfg.value;
|
||||
actorData.buffValue = actorData.buffValue + 1;
|
||||
if actorData.inspire[type].addvalue == nil then
|
||||
actorData.inspire[type].addvalue = 0;
|
||||
end
|
||||
actorData.inspire[type].addvalue = actorData.inspire[type].addvalue + inspireCfg.value;
|
||||
value = actorData.inspire[type].addvalue
|
||||
-- print("鼓舞.."..actorData.inspire[type].addvalue )
|
||||
addInspireBuff(pActor, atvId);
|
||||
Actor.sendTipmsgWithId(pActor, tmBossGwSuccess, tstUI)
|
||||
actorData.inspire[type].times = actorData.inspire[type].times + 1;
|
||||
lefttimes = inspireCfg.times - actorData.inspire[type].times ;
|
||||
break;
|
||||
else
|
||||
errorcode = 5;
|
||||
end
|
||||
break;
|
||||
end
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sInspire)
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.writeByte(outPack, type)
|
||||
DataPack.writeInt(outPack, (value or 0))
|
||||
DataPack.writeInt(outPack, (lefttimes or 0))
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家排行数据
|
||||
function SendRankData(atvId,pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMyRankData)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
--发送最后一击奖励
|
||||
function SendLastAttackaward(atvId)
|
||||
--print("[PActivity 25]SendLastAttackaward------------9684312.300------------------ ".."atvId :"..tostring(atvId).."lastattack :"..tostring(ActivityConfig[atvId].lastattack))
|
||||
|
||||
if ActivityConfig[atvId].lastattack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId);
|
||||
-- print("击杀世界BOSS..atcid.."..atvId.."...2222.."..(globalData.killerId or 0))
|
||||
if globalData.killerId == nil then
|
||||
--print("[PActivity 25]globalData.killerId----------245kjbjkj242-------------------- ")
|
||||
|
||||
return;
|
||||
end
|
||||
local title = "世界BOSS"
|
||||
local content = string.format("恭喜你击杀世界BOSS!")
|
||||
SendMail(globalData.killerId, title, content, ActivityConfig[atvId].lastattack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送排名奖励
|
||||
function SendRankAward(atvId)
|
||||
if ActivityConfig[atvId].rankAward then
|
||||
local rankAward = ActivityConfig[atvId].rankAward
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
local title = "世界BOSS"
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
local idx = 1
|
||||
for _,awardInfo in ipairs(rankAward) do
|
||||
local rankNum = awardInfo.value
|
||||
-- print("rankNum:"..rankNum.." itemNum:"..itemNum)
|
||||
if rankNum > itemNum then
|
||||
rankNum = itemNum
|
||||
end
|
||||
for i=idx,rankNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
local title = "世界BOSS"
|
||||
local content = string.format("恭喜你在世界BOSS中取得第%d名!", i)
|
||||
SendMail(actorId, title, content, awardInfo.awards)
|
||||
-- local pActor = Actor.getActorById(actorId)
|
||||
-- Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
-- Actor.triggerAchieveEvent(pOwner, nAchieveCompleteActivity,1 ,atvId);
|
||||
local name = RankMgr.GetValueById(actorId, RANKING_ID, 0)
|
||||
-- print("[GActivity 8] 世界BOSS(id:"..atvId..") "..(name or actorId).." 获得第"..i.."名!")
|
||||
end
|
||||
idx = rankNum + 1
|
||||
if idx > itemNum then
|
||||
-- print("[GActivity 8] 世界BOSS(id:"..atvId..") 奖励发完! 一共"..rankNum.."人获得上榜奖励!")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 踢出副本
|
||||
function KickoutAllActors(atvId)
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
RemoveInspireBuff(pActor, atvId) --清除鼓舞buff
|
||||
end
|
||||
end
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function addInspireBuff(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil and Cfg.buffid == nil then
|
||||
return
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
local job = Actor.getIntProperty( pActor, PROP_ACTOR_VOCATION )
|
||||
for _, cfg in pairs(Cfg.buffid) do
|
||||
|
||||
if cfg.times == actorData.buffValue then
|
||||
|
||||
for _, id in pairs(cfg.buffid) do
|
||||
Actor.addBuffById(pActor, id);
|
||||
end
|
||||
|
||||
-- Actor.addBuffValueById(pActor, cfg.id, (actorData.buffValue or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function RemoveInspireBuff(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil and Cfg.buffid == nil then
|
||||
return
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg.buffid) do
|
||||
if cfg.times == actorData.buffValue then
|
||||
|
||||
for _, id in pairs(cfg.buffid) do
|
||||
|
||||
Actor.delBuffById(pActor, id);
|
||||
end
|
||||
end
|
||||
-- Actor.delBuffById(actorid, cfg.id);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 8] 世界boss 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
|
||||
FubenDispatcher.MapToActivity(pFuben,ActivityType, atvId);
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 8] 世界boss "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.buffValue = nil
|
||||
actorData.nextLoginTime = nil
|
||||
actorData.inspire = nil
|
||||
actorData.isFirst = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 8] 世界boss 活动开始了,id:"..atvId)
|
||||
CheckNewActivity(atvId);
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
cacheData.actors = {}
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
|
||||
FubenDispatcher.MapToActivity(pFuben,ActivityType, atvId);
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
function ClearGlobalData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId)
|
||||
--print("[GActivity 25]ClearGlobalData ----------------------------------------一支穿云箭,千军万马来相见!!")
|
||||
globalData.bossDeath = nil
|
||||
globalData.killerId = nil
|
||||
globalData.killerName = nil
|
||||
globalData.isAward = nil;
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[GActivity 8] 世界boss 活动结束了,id:"..atvId)
|
||||
SendWorldBossAward(atvId)
|
||||
-- 踢出副本
|
||||
KickoutAllActors( atvId )
|
||||
-- 未死亡
|
||||
noDeathResult(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
-- 关闭副本
|
||||
Fuben.closeFuben( cacheData.fbHandle )
|
||||
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
|
||||
end
|
||||
|
||||
function SendWorldBossAward(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId)
|
||||
if globalData.isAward then
|
||||
return;
|
||||
end
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
|
||||
if globalData.killerName ~= nil then
|
||||
System.broadcastTipmsgLimitLev("恭喜"..globalData.killerName.."击杀了世界BOSS,获得了大量奖励", tstRevolving)
|
||||
System.broadcastTipmsgLimitLev("恭喜"..globalData.killerName.."击杀了世界BOSS,获得了大量奖励", tstChatSystem)
|
||||
end
|
||||
local pFuben = ActivityDispatcher.GetFuben(atvId)
|
||||
if pFuben then
|
||||
FubenDispatcher.SetResult(pFuben,1)
|
||||
-- 延迟踢出副本
|
||||
local nowtime = System.getCurrMiniTime() + 15
|
||||
FubenDispatcher.KictoutAfter(pFuben, nowtime)
|
||||
end
|
||||
|
||||
--print("[PActivity 25]SendWorldBossAward----645644332-------------------------- ".."atvId "..tostring(atvId))
|
||||
-- 发送奖励
|
||||
SendRankAward( atvId )
|
||||
--最后一击
|
||||
SendLastAttackaward(atvId);
|
||||
globalData.isAward = 1;
|
||||
end
|
||||
|
||||
|
||||
--公告
|
||||
function SendNotice(avtId, curTime)
|
||||
local cfg = ActivityConfig[avtId]
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cfg == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if cfg.notice then
|
||||
for _, notice in pairs(cfg.notice) do
|
||||
|
||||
if cacheData.notice == nil then
|
||||
cacheData.notice = {}
|
||||
end
|
||||
if notice.id then
|
||||
local startTime = System.getRunningActivityStartTime(avtId)
|
||||
if (curTime > startTime + notice.time) and cacheData.notice[notice.id] == nil then
|
||||
if cacheData.status == nil then
|
||||
cacheData.status = AtvStatus.PreEnter
|
||||
end
|
||||
|
||||
System.broadcastTipmsgLimitLev(notice.content, tstBigRevolving)
|
||||
System.broadcastTipmsgLimitLev(notice.content, tstChatSystem)
|
||||
cacheData.notice[notice.id] = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新boss
|
||||
function CreateWorldBoss(avtId, curTime)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId);
|
||||
if globalData.bossDeath then
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[avtId]
|
||||
if Cfg == nil or Cfg.bossinfo == nil then
|
||||
return
|
||||
end
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cacheData.referFlag then
|
||||
return
|
||||
end
|
||||
|
||||
-- print("..avtId.."..avtId.."avtId.."..(globalData.bossDeath or 0))
|
||||
local startTime = System.getRunningActivityStartTime(avtId)
|
||||
if cacheData.scenHandle and (curTime >= startTime + Cfg.starttime) then
|
||||
|
||||
if globalData.bossLv == nil then
|
||||
globalData.bossLv =1;
|
||||
end
|
||||
TestMsg(globalData.bossLv)
|
||||
cacheData.status = AtvStatus.Start
|
||||
local bossGrowValue = 1.1 ^ (globalData.bossLv-1) *100
|
||||
Fuben.createOneMonsters(cacheData.scenHandle, Cfg.bossinfo.bossid, Cfg.bossinfo.x, Cfg.bossinfo.y, 1,0,0, NULL, 0, (bossGrowValue or 100));
|
||||
cacheData.referFlag = 1;
|
||||
System.sendAllActorOneActivityData(avtId);
|
||||
ActivityDispatcher.BroadPopup(avtId);
|
||||
end
|
||||
end
|
||||
|
||||
function CheckNewActivity(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId);
|
||||
local endTime = System.getActivityEndMiniSecond(atvId)
|
||||
if globalData.atvEndTime == nil or globalData.atvEndTime ~= endTime then
|
||||
-- print("改革春风吹满地!!")
|
||||
ClearGlobalData(atvId)
|
||||
ActivityDispatcher.ClearCacheData(atvId);
|
||||
globalData.atvEndTime = endTime
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
-- 检测活动结束
|
||||
-- CheckNewActivity(atvId);
|
||||
-- 公告
|
||||
SendNotice(atvId, curTime)
|
||||
-- 刷新boss
|
||||
CreateWorldBoss(atvId, curTime)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg and Cfg.inspire then
|
||||
local len = #Cfg.inspire;
|
||||
DataPack.writeByte(outPack, (len or 0))
|
||||
for _, cfg in pairs(Cfg.inspire) do
|
||||
DataPack.writeByte(outPack, (cfg.type or 0))
|
||||
local data = GetActorInpires(atvId, cfg.type, pActor);
|
||||
local addvalue = 0;
|
||||
local times = cfg.times;
|
||||
if data then
|
||||
addvalue = data.addvalue;
|
||||
times = times - data.times
|
||||
if times < 0 then
|
||||
times = 0
|
||||
end
|
||||
end
|
||||
DataPack.writeInt(outPack, addvalue)
|
||||
DataPack.writeInt(outPack, (times or 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function GetActorInpires(atvId, type, pActor)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData.inspire == nil then
|
||||
actorData.inspire = {}
|
||||
local inspire = {}
|
||||
inspire.times = 0;
|
||||
inspire.addvalue = 0;
|
||||
actorData.inspire[type] = inspire;
|
||||
end
|
||||
return actorData.inspire[type]
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cInspire then --鼓舞
|
||||
local type = DataPack.readByte(inPack);
|
||||
ActorInspire(pActor, atvId, type)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--发送玩家当前剩余时间信息
|
||||
function SendLeftTimeInfo(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendWorldBossTime)
|
||||
if npack then
|
||||
local nEndTime = System.getActivityEndMiniSecond(atvId);
|
||||
local leftTime = nEndTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, leftTime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
|
||||
-- 玩家退出,从记录中排除
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
-- 玩家下次进入时间限制
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nextLoginTime = System.getCurrMiniTime() + 30
|
||||
RemoveInspireBuff(pActor,atvId );
|
||||
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡 TODO 缺个助攻积分
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
|
||||
end
|
||||
|
||||
|
||||
function noDeathResult(atvId)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId)
|
||||
if globalData.bossDeath then
|
||||
return
|
||||
end
|
||||
|
||||
local time = 0;
|
||||
local bossLv = 0;
|
||||
|
||||
for _, cfg in pairs(ActivityConfig[atvId].growlist) do
|
||||
if cfg.time >= time then
|
||||
time = cfg.time
|
||||
bossLv = cfg.addlv
|
||||
end
|
||||
end
|
||||
if globalData.bossLv == nil then
|
||||
globalData.bossLv = 1;
|
||||
end
|
||||
|
||||
globalData.bossLv = globalData.bossLv + bossLv;
|
||||
if globalData.bossLv < 1 then
|
||||
globalData.bossLv = 1
|
||||
end
|
||||
TestMsg(globalData.bossLv)
|
||||
end
|
||||
end
|
||||
|
||||
function TestMsg(lv)
|
||||
local msg = "世界BOSS当前等级:%d"
|
||||
local str = string.format(msg, (lv or 0));
|
||||
-- System.SendChatMsg(str, 4)
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
|
||||
function setBossGrowLv(atvId, killTime)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
local costtime = killTime - (startTime + Cfg.starttime);
|
||||
if costtime < 0 then
|
||||
costtime = 0
|
||||
end
|
||||
|
||||
local time = 0;
|
||||
local bossLv = 0;
|
||||
for _, cfg in pairs(ActivityConfig[atvId].growlist) do
|
||||
if costtime < cfg.time then
|
||||
bossLv = cfg.addlv
|
||||
break
|
||||
end
|
||||
end
|
||||
-- print("bossLv.."..bossLv)
|
||||
globalData.bossLv = globalData.bossLv + bossLv;
|
||||
if globalData.bossLv < 1 then
|
||||
globalData.bossLv = 1
|
||||
end
|
||||
TestMsg(globalData.bossLv)
|
||||
-- print("globalData.bossLv .."..(globalData.bossLv or 0))
|
||||
end
|
||||
end
|
||||
|
||||
function OnEntityHurt(atvId, pEntity, damage, isKiller, killTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId)
|
||||
if actorsInFuben[atvId] and globalData.bossDeath == nil then
|
||||
-- if globalData.bossDeath == nil then
|
||||
-- 攻击boss 获得积分
|
||||
local killerId = Actor.getIntProperty(pEntity, PROP_ENTITY_ID )
|
||||
local addSocre = damage * 0.2 + ActivityConfig[atvId].addScoreKill;
|
||||
|
||||
addSocre = math.floor(addSocre)
|
||||
|
||||
RankMgr.AddValue(killerId, RANKING_ID, addSocre)
|
||||
OnDealAchieve(atvId, pEntity);
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
SendRankData(atvId,pEntity)
|
||||
|
||||
--print("[PActivity 25]OnEntityHurt--------------------OnHurtMonster---------------------------".."isKiller:"..tostring(isKiller).."bossDeath:"..tostring(globalData.bossDeath))
|
||||
if isKiller ~= nil and isKiller == 1 and globalData.bossDeath == nil then
|
||||
-- local killerId = Actor.getIntProperty(pEntity, PROP_ENTITY_ID )
|
||||
local killName = Actor.getName(pEntity )
|
||||
globalData.killerId = killerId
|
||||
globalData.killerName = killName;
|
||||
globalData.bossDeath = killTime;
|
||||
|
||||
--print("[PActivity 25]OnEntityHurt--643531--------".."killName:"..tostring(killName).."globalData.killerId:"..tostring(globalData.killerId).."killerId:"..tostring(killerId))
|
||||
-- print("bossdeath "..atvId.." ..atvId."..globalData.killerId)
|
||||
setBossGrowLv(atvId, killTime);
|
||||
-- SendWorldBossAward(atvId, 1);
|
||||
System.closeActivityRunning(atvId, true);
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result, pOwner)
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor then
|
||||
--满血结束血量
|
||||
-- local maxhp = Actor.getIntProperty(pActor,PROP_CREATURE_MAXHP)
|
||||
-- Actor.changeHp(pActor, maxhp)
|
||||
local npack = ActivityDispatcher.AllocResultPack(pActor, atvId, 1)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
WorldBossResult(atvId, npack, actorId)
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function WorldBossResult(atvId, npack, actorId)
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
for i = 1, 3 do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local name = "";
|
||||
if(rankItem) then
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
name = Ranking.getSub(rankItem, 0)
|
||||
end
|
||||
|
||||
DataPack.writeString(npack, name or "")
|
||||
end
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(BossConfAtvId)
|
||||
DataPack.writeString(npack, globalData.killerName or "")
|
||||
local iskiller = 0;
|
||||
if actorId == globalData.killerId then
|
||||
iskiller = 1
|
||||
end
|
||||
DataPack.writeWord(npack, iskiller)
|
||||
end
|
||||
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local result = System.isActivityRunning(atvId)
|
||||
local ret = 0
|
||||
|
||||
-- if result then ret = 1 end
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
if cacheData.status and cacheData.status == AtvStatus.Start then ret = 1 end
|
||||
-- local cfg = ActivityConfig[atvId]
|
||||
-- if cfg and cfg.openParam then
|
||||
-- if Actor.checkActorLevel(pActor,(cfg.openParam.level or 0)) ~=true then ret = 0 end
|
||||
-- end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
----处理成就问题
|
||||
function OnDealAchieve(atvId, pActor)
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData and actorData.isFirst == nil and curVal >= 1000 then
|
||||
Actor.triggerAchieveEvent(pActor,nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
actorData.isFirst = 1;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType25.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType25.lua")
|
||||
-- ActivityDispatcher.Reg(ActivityEvent.OnEntityHurt, ActivityType, OnEntityHurt, "ActivityType8.lua")
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 杀怪
|
||||
function OnHurtMonster(pActor, damage, isKiller, killTime)
|
||||
--print("[PActivity 25]OnHurtMonster+++++++++++++++++++++ "..Actor.getName(pActor).." damage:"..damage.."isKiller: "..isKiller.." killTime: "..killTime)
|
||||
local pFuben = Actor.getFubenPrt(pActor);
|
||||
if pFuben and FubenDispatcher.IsActivityFuben(pFuben) then
|
||||
local atvType = FubenDispatcher.GetActivityType(pFuben);
|
||||
--print("[PActivity 25]FubenDispatcher=================================== "..Actor.getName(pActor).."atvType:"..tostring(atvType).."atvType:"..tostring(ActivityType))
|
||||
|
||||
-- print("[PActivity 8] "..pFuben)
|
||||
if atvType == ActivityType then
|
||||
local atvId = FubenDispatcher.GetActivityId(pFuben);
|
||||
-- print("[PActivity 8] "..Actor.getName(pActor).." atvId:"..atvId)
|
||||
--print("[PActivity 25]OnHurtMonster--------------------OnHurtMonster---------------------------"..Actor.getName(pActor)..":"..tostring(killTime))
|
||||
OnEntityHurt(atvId, pActor, damage, isKiller, killTime);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeHurtMonster, OnHurtMonster, "ActivityType25.lua")
|
||||
@@ -0,0 +1,692 @@
|
||||
module("ActivityType26", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动,跨服逃脱试炼
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
nextLoginTime 退出后下次可进来的时间戳
|
||||
isFirst , 第一次
|
||||
nLifeStatus 玩家生命状态(0:存活; 1:死亡;)
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
nextAutoTime, 下一次自动加积分的时间戳
|
||||
broadcastTime, 下一次广播的时间戳
|
||||
escapeActors = {actorid,...} 记录活动副本中的已逃脱玩家id
|
||||
escapeActorsNames = {actorName,...} 记录活动副本中的已逃脱玩家名称
|
||||
}
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
nEscapePlayerNum, 当前已逃脱玩家人数
|
||||
nEndTime, 活动阶数时间戳
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 26
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity26Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY26
|
||||
|
||||
--在场景中的玩家
|
||||
actorsInFuben =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [actorId] = actorId
|
||||
--}
|
||||
}
|
||||
|
||||
--玩家任务状态
|
||||
actorsEscapeFromFuben =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [actorId] = actorId
|
||||
--}
|
||||
}
|
||||
|
||||
--已逃脱玩家名称
|
||||
actorsNameEscapeFromFuben =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [index] = actorName
|
||||
--}
|
||||
}
|
||||
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local fbHandle = Actor.getFubenHandle(pActor)
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
actorsEscapeFromFuben[atvId] = {}
|
||||
if cacheData and cacheData.escapeActors then
|
||||
for i,actorId in Ipairs(cacheData.escapeActors) do
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsEscapeFromFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
actorsNameEscapeFromFuben[atvId] = {}
|
||||
if cacheData and cacheData.escapeActorsNames then
|
||||
for nIndex,actorName in Ipairs(cacheData.escapeActorsNames) do
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsNameEscapeFromFuben[atvId][nIndex] = actorName
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
print("[GActivity 26] reqEnterFuben() "..Actor.getName(pActor))
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if actorsEscapeFromFuben[atvId] and actorsEscapeFromFuben[atvId][actorId] then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已经结算过名次,无法再次参与活动|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--等级、转身等级限制
|
||||
local nLimitLv = 0;
|
||||
local nLimitZSLv = 0 ;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
nLimitLv = (cfg.openParam.level or 0)
|
||||
nLimitZSLv = (cfg.openParam.zsLevel or 0)
|
||||
end
|
||||
if Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL) < nLimitLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE) < nLimitZSLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:转生不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--退出后登入的时间限制
|
||||
if actorData.nextLoginTime and actorData.nextLoginTime > System.getCurrMiniTime() then
|
||||
Actor.sendTipmsg(pActor, "请30秒后再进入!")
|
||||
return
|
||||
end
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if ActivityConfig[atvId].enterExpends then
|
||||
consumes = ActivityConfig[atvId].enterExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
-- Actor.sendTipmsg(pActor, "道具或金币元宝不足!", tstEcomeny)
|
||||
Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity26, "逃脱试炼|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--进入副本
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 重置玩家状态
|
||||
actorData.nLifeStatus = 0
|
||||
|
||||
-- 重置下次进入时间
|
||||
actorData.nextLoginTime = nil
|
||||
|
||||
-- 记录进入的玩家
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
-- 初始化已逃脱玩家
|
||||
if cacheData.escapeActors == nil then
|
||||
cacheData.escapeActors = {}
|
||||
end
|
||||
|
||||
if cacheData.escapeActorsNames == nil then
|
||||
cacheData.escapeActorsNames = {}
|
||||
end
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
|
||||
if actorsEscapeFromFuben[atvId] == nil then
|
||||
actorsEscapeFromFuben[atvId] = {}
|
||||
end
|
||||
|
||||
if actorsNameEscapeFromFuben[atvId] == nil then
|
||||
actorsNameEscapeFromFuben[atvId] = {}
|
||||
end
|
||||
|
||||
-- 通知玩家当前已经逃脱的玩家数
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local npack = DataPack.allocPacket(pActor, enActivityID, sSendCompletPlayerNum)
|
||||
if npack then
|
||||
DataPack.writeWord(npack, globalData.nEscapePlayerNum or 0)
|
||||
for i,actorid in pairs(actorsEscapeFromFuben[atvId]) do
|
||||
DataPack.writeUInt(npack, actorid)
|
||||
end
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
|
||||
-- 禁止普通频道聊天
|
||||
Actor.setChatForbit(pActor, ciChannelNear, true)
|
||||
|
||||
-- 广播一次排行榜
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
RankMgr.Save(RANKING_ID)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
|
||||
-- 强制全体pk模式
|
||||
Actor.setPkMode(pActor,fpPk)
|
||||
end
|
||||
end
|
||||
|
||||
--请求领取奖励
|
||||
function reqGetPhaseAward(pActor, atvId)
|
||||
print("[GActivity 26] reqGetPhaseAward() "..Actor.getName(pActor))
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
if RankMgr.GetValue(actorId,RANKING_ID) < ActivityConfig[atvId].Standardscore then
|
||||
return
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.nEscapePlayerNum = globalData.nEscapePlayerNum + 1
|
||||
|
||||
|
||||
|
||||
local nCurIdx = 1
|
||||
local nMaxIdx = #ActivityConfig[atvId].rankAward
|
||||
for i=1,nMaxIdx do
|
||||
local awardConf = ActivityConfig[atvId].rankAward[i]
|
||||
if awardConf then
|
||||
if globalData.nEscapePlayerNum > awardConf.value then
|
||||
nCurIdx = nCurIdx + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if nCurIdx > nMaxIdx then
|
||||
nCurIdx = nMaxIdx
|
||||
end
|
||||
|
||||
local awardConf = ActivityConfig[atvId].rankAward[nCurIdx]
|
||||
if awardConf then
|
||||
-- 已逃脱的玩家
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.escapeActors == nil then
|
||||
cacheData.escapeActors = {}
|
||||
end
|
||||
if cacheData.escapeActorsNames == nil then
|
||||
cacheData.escapeActorsNames = {}
|
||||
end
|
||||
cacheData.escapeActors[actorId] = actorId
|
||||
cacheData.escapeActorsNames[globalData.nEscapePlayerNum] = Actor.getName(pActor)
|
||||
|
||||
-- 广播当前已经逃脱的人数
|
||||
local npack = DataPack.allocPacketEx()
|
||||
if npack then
|
||||
DataPack.writeByte(npack,enActivityID)
|
||||
DataPack.writeByte(npack,sSendCompletPlayerNum)
|
||||
|
||||
-- 玩家已逃脱
|
||||
actorsEscapeFromFuben[atvId][actorId] = actorId
|
||||
|
||||
DataPack.writeWord(npack,globalData.nEscapePlayerNum)
|
||||
for i,actorid in pairs(actorsEscapeFromFuben[atvId]) do
|
||||
DataPack.writeUInt(npack, actorid)
|
||||
end
|
||||
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
DataPack.broadcastScene(npack, fbHandle, sceneId)
|
||||
DataPack.freePacketEx(npack)
|
||||
end
|
||||
|
||||
|
||||
actorsNameEscapeFromFuben[atvId][globalData.nEscapePlayerNum] = Actor.getName(pActor)
|
||||
|
||||
-- 聊天框、走马灯广播第一名
|
||||
if globalData.nEscapePlayerNum == 1 and actorsNameEscapeFromFuben[atvId][globalData.nEscapePlayerNum] then
|
||||
System.broadcastTipmsgLimitLev("恭喜 "..actorsNameEscapeFromFuben[atvId][globalData.nEscapePlayerNum].." 率先完成【跨服】逃脱试炼活动!", tstRevolving)
|
||||
System.broadcastTipmsgLimitLev("恭喜 "..actorsNameEscapeFromFuben[atvId][globalData.nEscapePlayerNum].." 率先完成【跨服】逃脱试炼活动!", tstChatSystem)
|
||||
end
|
||||
|
||||
-- 发送排名奖励
|
||||
local mainContent = string.format(ActivityConfig[atvId].mailContent1, globalData.nEscapePlayerNum)
|
||||
SendAward(atvId, pActor, globalData.nEscapePlayerNum, ActivityConfig[atvId].mailTitle1, mainContent, awardConf.awards)
|
||||
|
||||
-- 玩家积分清零
|
||||
RankMgr.SetRank(actorId, RANKING_ID, 0)
|
||||
|
||||
-- 踢出副本
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
end
|
||||
end
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadRankData(atvId,fbHandle,sceneId)
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID, 4, npack)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家排行数据
|
||||
function SendRankData(atvId,pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMyRankData)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 设置复活
|
||||
function SetAutoRelive(atvId,pActor,pFuben)
|
||||
local deathLimit = FubenDispatcher.GetReliveCount(pFuben, pActor)
|
||||
if (deathLimit == nil) or (deathLimit == -1) then
|
||||
FubenDispatcher.SetReliveCount(pFuben, pActor, ActivityConfig[atvId].Rebirthsecond)
|
||||
end
|
||||
end
|
||||
|
||||
--广播当前场次时间信息
|
||||
function BroadCurrentTimeInfo(atvId,fbHandle,sceneId)
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendTime)
|
||||
if npack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
DataPack.writeByte(npack, 0)
|
||||
local nLeftTime = globalData.nEndTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, nLeftTime)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 26] 跨服逃脱试炼 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 26] 跨服逃脱试炼 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
-- actorData.nextLoginTime = nil
|
||||
actorData.isFirst = nil
|
||||
actorData.nextLoginTime = nil
|
||||
actorData.nLifeStatus = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 26] 跨服逃脱试炼 活动开始了,id:"..atvId)
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
cacheData.nextAutoTime = 0
|
||||
cacheData.actors = {}
|
||||
cacheData.escapeActors = {}
|
||||
cacheData.escapeActorsNames = {}
|
||||
cacheData.broadcastTime = 0
|
||||
|
||||
globalData.nEscapePlayerNum = 0
|
||||
globalData.nEndTime = System.getCurrMiniTime() + ActivityConfig[atvId].Duration
|
||||
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[GActivity 26] 跨服逃脱试炼 活动结束了,id:"..atvId)
|
||||
-- local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
-- 参与奖
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
if actorsInFuben[atvId][actorid] then
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
-- 参与奖发送的排名为:0
|
||||
SendAward(atvId, pActor, 0, ActivityConfig[atvId].mailTitle2, ActivityConfig[atvId].mailContent2, ActivityConfig[atvId].partakeAward)
|
||||
end
|
||||
end
|
||||
|
||||
local pFuben = ActivityDispatcher.GetFuben(atvId)
|
||||
if pFuben then
|
||||
-- 设置副本结果
|
||||
FubenDispatcher.SetResult(pFuben,1)
|
||||
-- 延迟踢出副本
|
||||
FubenDispatcher.KictoutAfter(pFuben,15)
|
||||
end
|
||||
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
ActivityDispatcher.ClearGlobalData( atvId )
|
||||
actorsInFuben[atvId] = nil
|
||||
actorsEscapeFromFuben[atvId] = nil
|
||||
actorsNameEscapeFromFuben[atvId] = nil
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
BroadCurrentTimeInfo(atvId, cacheData.fbHandle, Fuben.getSceneId(cacheData.scenHandle))
|
||||
|
||||
-- 有玩家时才处理
|
||||
if actorsInFuben[atvId] then
|
||||
|
||||
local hasMan = false
|
||||
|
||||
-- 泡点
|
||||
if (cacheData.nextAutoTime or 0) - curTime > ActivityConfig[atvId].autoTime then
|
||||
cacheData.nextAutoTime = curTime
|
||||
end
|
||||
if curTime > (cacheData.nextAutoTime or 0) then
|
||||
cacheData.nextAutoTime = curTime + ActivityConfig[atvId].autoTime
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
if pActor ~= nil and actorData.nLifeStatus == 0 then
|
||||
RankMgr.AddValue(actorid, RANKING_ID, ActivityConfig[atvId].addScoreAuto)
|
||||
OnDealAchieve(atvId, pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
Actor.sendTipmsg(pActor, "持续参加活动,积分+"..ActivityConfig[atvId].addScoreAuto..",当前:"..curVal, tstGetItem)
|
||||
SendRankData(atvId,pActor)
|
||||
hasMan = true
|
||||
end
|
||||
|
||||
if pActor ~= nil and actorData.nLifeStatus == 1 then
|
||||
-- 玩家死亡时需要提示:角色复活期间无法获取积分
|
||||
Actor.sendTipmsg(pActor, "角色复活期间无法获取积分", tstGetItem)
|
||||
end
|
||||
end
|
||||
if hasMan then
|
||||
RankMgr.Save(RANKING_ID)
|
||||
end
|
||||
end
|
||||
|
||||
-- 每秒广播一次
|
||||
if (cacheData.broadcastTime or 0) - curTime > 1 then
|
||||
cacheData.broadcastTime = curTime
|
||||
end
|
||||
if curTime > (cacheData.broadcastTime or 0) then
|
||||
cacheData.broadcastTime = curTime + 1
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cGetPhaseAward then --请求获取阶段奖励
|
||||
reqGetPhaseAward(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
-- 玩家退出,从记录中排除
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors and cacheData.actors[actorId] then
|
||||
cacheData.actors[actorId] = nil
|
||||
end
|
||||
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
|
||||
-- 玩家下次进入时间限制
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nextLoginTime = System.getCurrMiniTime() + 30
|
||||
|
||||
-- 玩家积分清零
|
||||
RankMgr.SetRank(actorId, RANKING_ID, 0)
|
||||
|
||||
-- 恢复禁止普通频道聊天
|
||||
Actor.setChatForbit(pActor, ciChannelNear, false)
|
||||
|
||||
-- 完成
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
|
||||
if pKiller then
|
||||
local entityType = Actor.getEntityType(pEntity)--被击杀者的类型
|
||||
local killerType = Actor.getEntityType(pKiller)--击杀者的类型
|
||||
|
||||
if entityType == enActor then
|
||||
-- 玩家死亡时需要提示:角色复活期间无法获取积分
|
||||
Actor.sendTipmsg(pEntity, "角色复活期间无法获取积分", tstGetItem)
|
||||
|
||||
-- 设置玩家状态
|
||||
local actorData = ActivityDispatcher.GetActorData(pEntity,atvId)
|
||||
actorData.nLifeStatus = 1
|
||||
end
|
||||
|
||||
if killerType == enActor then
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
if entityType == enActor then
|
||||
-- 击杀杀玩家获得积分
|
||||
local nEntityServerId = Actor.getActorRawServerId(pEntity)--被击杀玩家的服务器ID
|
||||
local nKillerServerId = Actor.getActorRawServerId(pKiller)--击杀玩家的服务器ID
|
||||
if nEntityServerId and nKillerServerId then
|
||||
if nEntityServerId == nKillerServerId then --击杀本服玩家
|
||||
RankMgr.AddValue(killerId, RANKING_ID, ActivityConfig[atvId].addScoreHelpKill)
|
||||
OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你成功击败本服玩家["..Actor.getName(pEntity).."],积分+"..ActivityConfig[atvId].addScoreHelpKill, tstGetItem)
|
||||
else --击杀非本服玩家
|
||||
|
||||
RankMgr.AddValue(killerId, RANKING_ID, ActivityConfig[atvId].addScoreKill)
|
||||
OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你成功击败其他服玩家["..Actor.getName(pEntity).."],积分+"..ActivityConfig[atvId].addScoreKill, tstGetItem)
|
||||
end
|
||||
end
|
||||
-- 设置复活
|
||||
SetAutoRelive(atvId, pEntity, pFuben)
|
||||
else
|
||||
-- 杀守卫获得积分
|
||||
RankMgr.AddValue(killerId, RANKING_ID, ActivityConfig[atvId].addScoreGuard)
|
||||
OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你击败试炼怪物,积分+"..ActivityConfig[atvId].addScoreGuard, tstGetItem)
|
||||
end
|
||||
else
|
||||
-- 设置复活
|
||||
SetAutoRelive(atvId, pEntity, pFuben)
|
||||
end
|
||||
SendRankData(atvId,pKiller)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result)
|
||||
print("[GActivity 26] OnFubenFinish()")
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 1
|
||||
local nLimitLv = 0;
|
||||
local nLimitZSLv = 0 ;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
nLimitLv = (cfg.openParam.level or 0)
|
||||
nLimitZSLv = (cfg.openParam.zsLevel or 0)
|
||||
end
|
||||
if Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL ) < nLimitLv or Actor.getIntProperty( pActor, PROP_ACTOR_CIRCLE ) < nLimitZSLv then ret = 0 end
|
||||
return ret
|
||||
end
|
||||
|
||||
----处理成就问题
|
||||
function OnDealAchieve(atvId, pActor)
|
||||
local ActorType = Actor.getEntityType(pActor)--类型
|
||||
if ActorType ==enActor then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData and actorData.isFirst == nil and curVal >= 50 then
|
||||
Actor.triggerAchieveEvent(pActor,nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
actorData.isFirst = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 玩家在活动副本中复活
|
||||
function OnEnterFuben(atvId, pActor)
|
||||
print("[GActivity 26] OnEnterFuben()"..Actor.getName(pActor))
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if actorsInFuben[atvId][actorId] then
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nLifeStatus = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送奖励
|
||||
function SendAward(atvId, pActor, nRankNum, mailTitle, mailContent, awardList)
|
||||
local nActorId = Actor.getActorId(pActor)
|
||||
SendCrossServerMail(nActorId, mailTitle, mailContent, awardList);
|
||||
|
||||
-- 发送前 3 名玩家的名字以及自己的奖励
|
||||
local npack = ActivityDispatcher.AllocResultPack(pActor, atvId, 1)
|
||||
if npack then
|
||||
DataPack.writeUInt(npack, nRankNum);
|
||||
local nNumbers = 0
|
||||
for nIndex,strActorName in pairs(actorsNameEscapeFromFuben[atvId]) do
|
||||
nNumbers = nNumbers + 1
|
||||
end
|
||||
|
||||
if nNumbers > 3 then
|
||||
nNumbers = 3
|
||||
end
|
||||
|
||||
for nCurIndex=1, nNumbers do
|
||||
if actorsNameEscapeFromFuben[atvId][nCurIndex] then
|
||||
DataPack.writeString(npack, actorsNameEscapeFromFuben[atvId][nCurIndex])
|
||||
end
|
||||
end
|
||||
|
||||
if nNumbers < 3 then
|
||||
for i=nNumbers + 1, 3 do
|
||||
DataPack.writeString(npack, "")
|
||||
end
|
||||
end
|
||||
|
||||
local awardConf = awardList
|
||||
local nCount = 0;
|
||||
for _, award1 in pairs(awardConf) do
|
||||
if award1 and type(award1) == "table" then
|
||||
nCount = nCount + 1
|
||||
end
|
||||
end
|
||||
DataPack.writeByte(npack, nCount);
|
||||
|
||||
for i, award2 in pairs(awardConf) do
|
||||
|
||||
local nAwardType = 0;
|
||||
local nAwardId = 0;
|
||||
local nAwardCount = 0;
|
||||
for key, value in pairs(award2) do
|
||||
if key == "type" then
|
||||
nAwardType = value
|
||||
elseif key == "id" then
|
||||
nAwardId = value
|
||||
elseif key == "count" then
|
||||
nAwardCount = value
|
||||
end
|
||||
end
|
||||
|
||||
DataPack.writeUInt(npack, nAwardType);
|
||||
DataPack.writeUInt(npack, nAwardId);
|
||||
DataPack.writeUInt(npack, nAwardCount);
|
||||
end
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType26.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterFuben, ActivityType, OnEnterFuben, "ActivityType26.lua")
|
||||
@@ -0,0 +1,302 @@
|
||||
module("ActivityType27", package.seeall)
|
||||
|
||||
--[[
|
||||
沙巴克(开服第三天)
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
sbkArea[sceneid] //sceneid 场景id
|
||||
{
|
||||
state //状态
|
||||
}
|
||||
needDealarea
|
||||
{
|
||||
area
|
||||
{
|
||||
sceneid, //场景id
|
||||
x, x坐标
|
||||
y, y坐标
|
||||
}
|
||||
}
|
||||
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
paodianTime,
|
||||
warNotice,--沙巴克皇宫可以开始占领!公告
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
sbkGuild sbk领主id
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 27
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity27Config
|
||||
-- if ActivityConfig == nil then
|
||||
-- assert(false)
|
||||
-- end
|
||||
local SbkState = 0;
|
||||
-- 活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
PreEnter = 1, --活动前5分钟(走马灯全服公告,不给进入)
|
||||
Start = 2, --开始
|
||||
Sbk = 3, --沙巴克时间
|
||||
End = 4, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
local PaodianTime = 0;
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 27] 沙巴克 活动数据加载,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 27] 沙巴克 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
setSbkAwardFlag(nil);
|
||||
print("[GActivity 27] 沙巴克 活动开始了,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
local Cfg = ActivityConfig
|
||||
if Cfg then
|
||||
-- System.broadcastTipmsgLimitLev(Cfg.endsbk, tstBigRevolving)
|
||||
-- System.broadcastTipmsgLimitLev(Cfg.endsbk, tstChatSystem)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData.sbkGuild then
|
||||
local guildName = Guild.getGuildName(globalData.sbkGuild)
|
||||
if guildName then
|
||||
local str = string.format(Cfg.endsbk, guildName)
|
||||
System.broadcastTipmsgLimitLev(str, tstBigRevolving)
|
||||
-- print("..on")
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
end
|
||||
if cacheData.sbkArea then
|
||||
for _, sceneid in Ipairs(cacheData.sbkArea) do
|
||||
-- print("vvvv.."..sceneid)
|
||||
Fuben.ResetFubenSceneConfig(sceneid);
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
SbkState = AtvStatus.End
|
||||
ActivityDispatcher.ClearCacheData(atvId);
|
||||
print("[GActivity 27] 沙巴克 活动结束了,id:"..atvId)
|
||||
end
|
||||
|
||||
|
||||
--公告
|
||||
function SendNotice(avtId, curTime)
|
||||
local cfg = ActivityConfig
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cfg == nil then
|
||||
return;
|
||||
end
|
||||
end
|
||||
|
||||
-- function OnReqData(atvId, pActor)
|
||||
|
||||
-- end
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
SendNotice(atvId, curTime);
|
||||
DealSbkAreaAttr(atvId, curTime);
|
||||
dealGuildSbk(atvId,curTime);
|
||||
dealPaodianExp(atvId,curTime)
|
||||
end
|
||||
|
||||
|
||||
--p泡点
|
||||
function dealPaodianExp(atvId, curTime)
|
||||
--检测沙巴克占领是否开启
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if Cfg then
|
||||
if Cfg.starttime then
|
||||
-- local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if curTime < (startTime + Cfg.starttime) then
|
||||
return
|
||||
end
|
||||
end
|
||||
if cacheData.paodianTime == nil then
|
||||
cacheData.paodianTime = 0
|
||||
end
|
||||
if curTime >= cacheData.paodianTime then
|
||||
cacheData.paodianTime = curTime + 5
|
||||
if Cfg.idx then
|
||||
addPaodianExp(cacheData.actors, Cfg.idx,atvId);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--沙巴克行为
|
||||
function dealGuildSbk(atvId, curTime)
|
||||
--检测沙巴克占领是否开启
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
-- print("dealGuild.."..startTime)
|
||||
if Cfg then
|
||||
if Cfg.wartime then
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if curTime < (startTime + Cfg.wartime) then
|
||||
return
|
||||
end
|
||||
|
||||
if not cacheData.warNotice and Cfg.wartimestr then
|
||||
cacheData.warNotice = 1
|
||||
System.broadcastTipmsgLimitLev(Cfg.wartimestr, tstRevolving)
|
||||
System.broadcastTipmsgLimitLev(Cfg.wartimestr, tstChatSystem)
|
||||
end
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
if globalData.sbkGuild == nil then
|
||||
globalData.sbkGuild = 0
|
||||
end
|
||||
-- print("dealGuildSbk.."..cacheData.sbkGuild)
|
||||
if Cfg.winmap then
|
||||
local guildId = Fuben.GetNowSceneGuildList(Cfg.winmap);
|
||||
if guildId > 0 and globalData.sbkGuild ~= guildId then
|
||||
globalData.sbkGuild = guildId
|
||||
Guild.setSbkGuildId(guildId);
|
||||
local guildName = Guild.getGuildName(guildId)
|
||||
if guildName then
|
||||
local str = string.format(Cfg.sbknotic, guildName)
|
||||
-- print("..dealGuildSbk"..str)
|
||||
System.broadcastTipmsgLimitLev(str, tstRevolving)
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 处理活动开始 设置sbk区域为战斗区域
|
||||
function DealSbkAreaAttr(atvId, curTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if Cfg and Cfg.starttime then
|
||||
if curTime > (startTime + Cfg.starttime) then
|
||||
-- SbkState = AtvStatus.Sbk
|
||||
if SbkState ~= AtvStatus.Sbk then
|
||||
SbkState = AtvStatus.Sbk
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
ActivityDispatcher.BroadPopup(atvId);
|
||||
end
|
||||
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
|
||||
if cacheData.sbkArea == nil then
|
||||
cacheData.sbkArea = {}
|
||||
end
|
||||
-- 已经设置OK
|
||||
for _, area in Ipairs(cacheData.needDealarea) do
|
||||
if Cfg.areaattr and Cfg.areaattr.attri then
|
||||
for _, attr in pairs(Cfg.areaattr.attri) do
|
||||
local index = Fuben.GetAreaListIndex(area.sceneid, area.x, area.y)
|
||||
local hScene = Fuben.getSceneHandleById(area.sceneid, 0)
|
||||
if index > 0 then
|
||||
Fuben.setSceneAreaAttri(hScene, index, attr.type, attr.value, NULL, (Cfg.areaattr.notips or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
-- print("西门吹雪 .."..area.sceneid)
|
||||
cacheData.sbkArea[area.sceneid] = area.sceneid
|
||||
end
|
||||
cacheData.needDealarea = nil;
|
||||
--设置战斗区域
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
end
|
||||
|
||||
-- 活动区域需要处理新增区域属性
|
||||
function OnEnterArea(atvId, pActor)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local sceneId = Actor.getSceneId(pActor);
|
||||
if cacheData.areaAttr == nil then
|
||||
cacheData.areaAttr = {}
|
||||
end
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
local x,y = Actor.getEntityPosition(pActor,0,0)
|
||||
-- 已经初始化完成
|
||||
if cacheData.areaAttr[sceneId] then
|
||||
return;
|
||||
end
|
||||
-- print("来了吗.."..sceneId)
|
||||
cacheData.areaAttr[sceneId] = 1;
|
||||
local area = {};
|
||||
area.sceneid = sceneId;
|
||||
area.x = x
|
||||
area.y = y
|
||||
-- -- print("OnEnterArea x.."..x.." y.."..y);
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
cacheData.needDealarea[sceneId] = area
|
||||
-- table.insert(cacheData.needDealarea, area);
|
||||
end
|
||||
|
||||
|
||||
-- 离开活动区域
|
||||
function OnExitArea(atvId, pActor)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
cacheData.actors[actorId] = 0
|
||||
end
|
||||
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 0
|
||||
if SbkState == AtvStatus.Sbk then ret = 1 end
|
||||
return ret
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType27.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType27.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType27.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType27.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType27.lua")
|
||||
-- ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType27.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterArea, ActivityType, OnEnterArea, "ActivityType27.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitArea, ActivityType, OnExitArea, "ActivityType27.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType27.lua")
|
||||
@@ -0,0 +1,444 @@
|
||||
module("ActivityType28", package.seeall)
|
||||
|
||||
|
||||
--[[
|
||||
全局活动,秘境打宝
|
||||
|
||||
个人数据:actorData[AtvId]
|
||||
{
|
||||
nextLoginTime, 退出后下次可进来的时间戳
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
secretBoxScore={actorid=scores ,...} 记录活动副本中的玩家秘境宝箱数量(积分)
|
||||
wordsBoxScore={actorid=scores ,...} 记录活动副本中的玩家字诀宝箱数量(积分)
|
||||
materialsBoxScore={actorid=scores ,...} 记录活动副本中的玩家材料宝箱数量(积分)
|
||||
clearGlobalData = nil or 1 记录活动副本中是否需要清理全局活动数据
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
}
|
||||
]]--
|
||||
|
||||
|
||||
--活动类型
|
||||
ActivityType = 28
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity28Config
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
print("ActivityType28 reqEnterFuben 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." 角色Id : "..Actor.getIntProperty( pActor, PROP_ENTITY_ID ))
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
-- 清空数据
|
||||
if globalData.clearGlobalData then
|
||||
ClearSecretGlobalData(atvId)
|
||||
end
|
||||
|
||||
--退出后登入的时间限制
|
||||
if actorData.nextLoginTime and actorData.nextLoginTime > System.getCurrMiniTime() then
|
||||
Actor.sendTipmsg(pActor, "请30秒后再进入!")
|
||||
return
|
||||
end
|
||||
|
||||
--等级、转身等级限制
|
||||
local nLimitLv = 0
|
||||
local nLimitZSLv = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].openParam then
|
||||
nLimitLv = (ActivityConfig[atvId].openParam.level or 0)
|
||||
nLimitZSLv = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
end
|
||||
local nLv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local nZSLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if nLv < nLimitLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足|", tstUI)
|
||||
return
|
||||
end
|
||||
if nZSLv < nLimitZSLv then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:转身不足|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if ActivityConfig[atvId].enterExpends then
|
||||
consumes = ActivityConfig[atvId].enterExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity28, "秘境打宝|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--进入副本
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 重置下次进入时间
|
||||
actorData.nextLoginTime = nil
|
||||
|
||||
-- 记录进入的玩家
|
||||
local nActorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if nil == globalData.actors then
|
||||
globalData.actors = {}
|
||||
end
|
||||
globalData.actors[nActorId] = nActorId
|
||||
if nil == globalData.secretBoxScore then
|
||||
globalData.secretBoxScore = {}
|
||||
end
|
||||
if nil == globalData.wordsBoxScore then
|
||||
globalData.wordsBoxScore = {}
|
||||
end
|
||||
if nil == globalData.materialsBoxScore then
|
||||
globalData.materialsBoxScore = {}
|
||||
end
|
||||
|
||||
-- 发送 秘境打宝 玩家的秘境宝箱数量(积分)、字诀宝箱数量(积分)、材料宝箱数量(积分)
|
||||
SendActorTypesScore(atvId, pActor)
|
||||
|
||||
-- 发送本场活动剩余时间
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendTime)
|
||||
if npack then
|
||||
DataPack.writeByte(npack, 0)
|
||||
|
||||
local nEndTime = System.getActivityEndMiniSecond(atvId)
|
||||
local nLeftTime = nEndTime - System.getCurrMiniTime()
|
||||
|
||||
DataPack.writeUInt(npack, nLeftTime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
|
||||
-- 进入副本
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求 秘境宝箱数量(积分)、字诀宝箱数量(积分)、材料宝箱数量(积分)
|
||||
function OnReqTypesScore(pActor, packet)
|
||||
print("ActivityType28 OnReqTypesScore 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local nActivityId = DataPack.readByte(packet)
|
||||
if not nActivityId or not ActivityConfig or not ActivityConfig[nActivityId] then
|
||||
print("ActivityType28 OnReqTypesScore 玩家 "..Actor.getName(pActor).." not nActivityId or not ActivityConfig or not ActivityConfig[nActivityId]")
|
||||
return
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(nActivityId)
|
||||
if nil == globalData.secretBoxScore or nil == globalData.wordsBoxScore or nil == globalData.materialsBoxScore then
|
||||
print("ActivityType28 OnReqTypesScore 玩家 "..Actor.getName(pActor).." nil == globalData.secretBoxScore or nil == globalData.wordsBoxScore or nil == globalData.materialsBoxScore")
|
||||
return
|
||||
end
|
||||
|
||||
SendActorTypesScore(nActivityId, pActor)
|
||||
end
|
||||
|
||||
-- 更新 秘境打宝 玩家的秘境宝箱数量(积分)、字诀宝箱数量(积分)、材料宝箱数量(积分)
|
||||
function UpdateActorTypesScore(atvId, pActor, nScoresType, nScore)
|
||||
print("ActivityType28 UpdateActorTypesScore 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." 角色Id : "..Actor.getIntProperty( pActor, PROP_ENTITY_ID ).." nScoresType : "..nScoresType.." nScore : "..nScore)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local nActorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if nil == globalData.actors or nil == globalData.actors[nActorId] then
|
||||
print("ActivityType28 UpdateActorTypesScore nil == globalData.actors or nil == globalData.actors[nActorId] 玩家 : "..Actor.getName(pActor))
|
||||
return
|
||||
end
|
||||
|
||||
if qatSecretBoxScore == nScoresType then
|
||||
globalData.secretBoxScore[nActorId] = (globalData.secretBoxScore[nActorId] or 0) + nScore
|
||||
print("ActivityType28 UpdateActorTypesScore 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." 当前秘境宝箱积分 : "..globalData.secretBoxScore[nActorId])
|
||||
elseif qatWordsBoxScore == nScoresType then
|
||||
globalData.wordsBoxScore[nActorId] = (globalData.wordsBoxScore[nActorId] or 0) + nScore
|
||||
print("ActivityType28 UpdateActorTypesScore 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." 当前字诀宝箱积分 : "..globalData.wordsBoxScore[nActorId])
|
||||
elseif qatMaterialsBoxScore == nScoresType then
|
||||
globalData.materialsBoxScore[nActorId] = (globalData.materialsBoxScore[nActorId] or 0) + nScore
|
||||
print("ActivityType28 UpdateActorTypesScore 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor).." 当前材料宝箱积分 : "..globalData.materialsBoxScore[nActorId])
|
||||
end
|
||||
|
||||
SendActorTypesScore(atvId, pActor)
|
||||
end
|
||||
|
||||
-- 发送 秘境打宝 玩家的秘境宝箱数量(积分)、字诀宝箱数量(积分)、材料宝箱数量(积分)
|
||||
function SendActorTypesScore(atvId, pActor)
|
||||
print("ActivityType28 SendActorTypesScore 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local npack = DataPack.allocPacket(pActor, enActivityID, sSendActorTypesScores)
|
||||
if npack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local nActorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
DataPack.writeUInt(npack, globalData.secretBoxScore[nActorId] or 0)
|
||||
DataPack.writeUInt(npack, globalData.wordsBoxScore[nActorId] or 0)
|
||||
DataPack.writeUInt(npack, globalData.materialsBoxScore[nActorId] or 0)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送 活动奖励
|
||||
function SendAward(atvId)
|
||||
print("ActivityType28 SendAward 活动Id :"..atvId)
|
||||
|
||||
if not ActivityConfig or not ActivityConfig[atvId] then
|
||||
print("ActivityType28 SendAward not ActivityConfig or not ActivityConfig[atvId]")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].AwardA or "table" ~= type(ActivityConfig[atvId].AwardA) or #ActivityConfig[atvId].AwardA < 1 or not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1 then
|
||||
print("ActivityType28 SendAward not ActivityConfig[atvId].AwardA or table ~= type(ActivityConfig[atvId].AwardA) or #ActivityConfig[atvId].AwardA < 1 or not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].AwardB or "table" ~= type(ActivityConfig[atvId].AwardB) or #ActivityConfig[atvId].AwardB < 1 or not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1 then
|
||||
print("ActivityType28 SendAward not ActivityConfig[atvId].AwardB or table ~= type(ActivityConfig[atvId].AwardB) or #ActivityConfig[atvId].AwardB < 1 or not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1")
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig[atvId].AwardC or "table" ~= type(ActivityConfig[atvId].AwardC) or #ActivityConfig[atvId].AwardC < 1 or not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1 then
|
||||
print("ActivityType28 SendAward not ActivityConfig[atvId].AwardC or table ~= type(ActivityConfig[atvId].AwardC) or #ActivityConfig[atvId].AwardC < 1 or not ActivityConfig[atvId].mailTitle1 or not ActivityConfig[atvId].mailContent1")
|
||||
return
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
for i, actorId in Ipairs(globalData.actors) do
|
||||
print(actorId)
|
||||
if globalData.secretBoxScore[actorId] then
|
||||
local tempAwardA = {}
|
||||
for j = 1, #ActivityConfig[atvId].AwardA do
|
||||
tempAwardA[j] = {}
|
||||
tempAwardA[j].type = ActivityConfig[atvId].AwardA[j].type
|
||||
tempAwardA[j].id = ActivityConfig[atvId].AwardA[j].id
|
||||
tempAwardA[j].count = ActivityConfig[atvId].AwardA[j].count
|
||||
print("globalData.secretBoxScore[actorId] : "..globalData.secretBoxScore[actorId].." tempAwardA[j].count : "..tempAwardA[j].count)
|
||||
tempAwardA[j].count = globalData.secretBoxScore[actorId] * tempAwardA[j].count
|
||||
print("tempAwardA[j].count : "..tempAwardA[j].count)
|
||||
end
|
||||
SendCrossServerMail(actorId, ActivityConfig[atvId].mailTitle1, ActivityConfig[atvId].mailContent1, tempAwardA)
|
||||
else
|
||||
print("ActivityType28 SendAward not globalData.secretBoxScore[actorId]")
|
||||
end
|
||||
|
||||
if globalData.wordsBoxScore[actorId] then
|
||||
local tempAwardB = {}
|
||||
for j = 1, #ActivityConfig[atvId].AwardB do
|
||||
tempAwardB[j] = {}
|
||||
tempAwardB[j].type = ActivityConfig[atvId].AwardB[j].type
|
||||
tempAwardB[j].id = ActivityConfig[atvId].AwardB[j].id
|
||||
tempAwardB[j].count = ActivityConfig[atvId].AwardB[j].count
|
||||
print("globalData.wordsBoxScore[actorId] : "..globalData.wordsBoxScore[actorId].." tempAwardB[j].count : "..tempAwardB[j].count)
|
||||
tempAwardB[j].count = globalData.wordsBoxScore[actorId] * tempAwardB[j].count
|
||||
print("tempAwardB[j].count : "..tempAwardB[j].count)
|
||||
end
|
||||
SendCrossServerMail(actorId, ActivityConfig[atvId].mailTitle2, ActivityConfig[atvId].mailContent2, tempAwardB)
|
||||
else
|
||||
print("ActivityType28 SendAward not globalData.wordsBoxScore[actorId]")
|
||||
end
|
||||
|
||||
if globalData.materialsBoxScore[actorId] then
|
||||
local tempAwardC = {}
|
||||
for j = 1, #ActivityConfig[atvId].AwardC do
|
||||
tempAwardC[j] = {}
|
||||
tempAwardC[j].type = ActivityConfig[atvId].AwardC[j].type
|
||||
tempAwardC[j].id = ActivityConfig[atvId].AwardC[j].id
|
||||
tempAwardC[j].count = ActivityConfig[atvId].AwardC[j].count
|
||||
print("globalData.materialsBoxScore[actorId] : "..globalData.materialsBoxScore[actorId].." tempAwardC[j].count : "..tempAwardC[j].count)
|
||||
tempAwardC[j].count = globalData.materialsBoxScore[actorId] * tempAwardC[j].count
|
||||
print("tempAwardC[j].count : "..tempAwardC[j].count)
|
||||
end
|
||||
SendCrossServerMail(actorId, ActivityConfig[atvId].mailTitle3, ActivityConfig[atvId].mailContent3, tempAwardC)
|
||||
else
|
||||
print("ActivityType28 SendAward not globalData.materialsBoxScore[actorId]")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 踢出副本
|
||||
function KickoutAllActors(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if nil == globalData.actors then
|
||||
return
|
||||
end
|
||||
if nil == globalData.actors then
|
||||
for i,actorid in pairs(nil == globalData.actors) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
end
|
||||
end
|
||||
globalData.actors = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- 清理 秘境寻宝 全局数据
|
||||
function ClearSecretGlobalData(atvId)
|
||||
print("ActivityType28 ClearData 活动Id :"..atvId)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.actors = nil
|
||||
globalData.secretBoxScore = nil
|
||||
globalData.wordsBoxScore = nil
|
||||
globalData.materialsBoxScore = nil
|
||||
globalData.clearGlobalData = nil
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
cacheData.fbHandle = fbHandle
|
||||
|
||||
--副本中启用默认的场景刷怪方式
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("ActivityType28 OnInit 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.nextLoginTime = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("ActivityType28 OnStart 活动Id :"..atvId)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
globalData.actors = {}
|
||||
globalData.secretBoxScore = {}
|
||||
globalData.wordsBoxScore = {}
|
||||
globalData.materialsBoxScore = {}
|
||||
globalData.clearGlobalData = 1
|
||||
|
||||
--创建副本并记录
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
cacheData.fbHandle = fbHandle
|
||||
|
||||
--副本中启用默认的场景刷怪方式
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("ActivityType28 OnEnd 活动Id :"..atvId)
|
||||
|
||||
local pFuben = ActivityDispatcher.GetFuben(atvId)
|
||||
if pFuben then
|
||||
-- 设置副本结果
|
||||
FubenDispatcher.SetResult(pFuben,1)
|
||||
-- 延迟踢出副本
|
||||
FubenDispatcher.KictoutAfter(pFuben,15)
|
||||
end
|
||||
|
||||
--发放奖励
|
||||
SendAward(atvId)
|
||||
|
||||
--清空数据
|
||||
ClearSecretGlobalData(atvId)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
-- -- 踢出副本
|
||||
-- KickoutAllActors( atvId )
|
||||
|
||||
-- 关闭副本
|
||||
Fuben.closeFuben( cacheData.fbHandle )
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
print("ActivityType28 OnOperator 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
print("ActivityType28 OnExitFuben 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
-- 玩家下次进入时间限制
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nextLoginTime = System.getCurrMiniTime() + 30
|
||||
|
||||
-- 退出副本
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
end
|
||||
|
||||
--活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result, pOwner)
|
||||
print("ActivityType28 OnFubenFinish 活动Id :"..atvId)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
for i, actorId in Ipairs(globalData.actors) do
|
||||
print(actorId)
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local npack = ActivityDispatcher.AllocResultPack(pActor, atvId, result)
|
||||
if npack then
|
||||
DataPack.writeUInt(npack, globalData.secretBoxScore[actorId] or 0)
|
||||
DataPack.writeUInt(npack, globalData.wordsBoxScore[actorId] or 0)
|
||||
DataPack.writeUInt(npack, globalData.materialsBoxScore[actorId] or 0)
|
||||
DataPack.flush(npack)
|
||||
else
|
||||
print("ActivityType28 OnFubenFinish 活动Id :"..atvId.." not npack")
|
||||
end
|
||||
else
|
||||
print("ActivityType28 OnFubenFinish 活动Id :"..atvId.." not pActor")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
print("ActivityType28 OnGetRedPoint 活动Id :"..atvId.." 玩家 "..Actor.getName(pActor))
|
||||
|
||||
local nRet = 1
|
||||
local nLimitLv = 0
|
||||
local nLimitZS = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].openParam then
|
||||
nLimitLv = (ActivityConfig[atvId].openParam.level or 0)
|
||||
nLimitZS = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
end
|
||||
local nLv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
local nZSLv = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if nLv < nLimitLv or nZSLv < nLimitZS then nRet = 0 end
|
||||
return nRet
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType28.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType28.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType28.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType28.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType28.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType28.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType28.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType28.lua")
|
||||
|
||||
|
||||
NetmsgDispatcher.Reg(enActivityID, cReqXunWanGift, cReqActorTypesScores)
|
||||
|
||||
@@ -0,0 +1,549 @@
|
||||
module("ActivityType29", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动————每日Boss
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
lastChangeExtraVipLevel 上一次改变额外扫荡次数的等级
|
||||
remainTimes, 剩余挑战(扫荡)次数
|
||||
extraSaoDangRemainTimes, 剩余外扫荡次数
|
||||
extraSaoDangTimes, 额外扫荡次数
|
||||
}
|
||||
]]--
|
||||
|
||||
-- 活动类型
|
||||
ActivityType = 29
|
||||
|
||||
-- 对应的活动配置
|
||||
ActivityConfig = Activity29Config
|
||||
|
||||
|
||||
--扫荡类型
|
||||
local SaoDangType =
|
||||
{
|
||||
CommonSaoDang = 1, -- 普通扫荡
|
||||
ExtraSaoDang = 2, -- 额外扫荡
|
||||
}
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
-- 请求进入副本
|
||||
function reqEnterFuben(atvId, pActor)
|
||||
print("ActivityType29.lua reqEnterFuben 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
if not ActivityConfig or not ActivityConfig[atvId] then
|
||||
print("ActivityType29.lua reqEnterFuben not ActivityConfig or not ActivityConfig[atvId] 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
local openDayLimit = 0
|
||||
local zsLevelLimit = 0
|
||||
local levelLimit = 0
|
||||
-- 每日Boss挑战条件
|
||||
if ActivityConfig[atvId].openParam then
|
||||
openDayLimit = (ActivityConfig[atvId].openParam.openDay or 0)
|
||||
zsLevelLimit = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
levelLimit = (ActivityConfig[atvId].openParam.level or 0)
|
||||
end
|
||||
|
||||
-- 开服天数不足
|
||||
if openDayLimit > System.getDaysSinceOpenServer() then
|
||||
print("ActivityType29.lua reqEnterFuben DaysSinceOpenServer not enough 活动Id :"..atvId.." 开服 "..openDayLimit.." 天可以挑战")
|
||||
return
|
||||
end
|
||||
|
||||
-- 转生等级不足 或 等级不足
|
||||
local nZSLevel = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
if zsLevelLimit > nZSLevel or levelLimit > nLevel then
|
||||
--print("ActivityType29.lua reqEnterFuben CircleNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsg(pActor, (ActivityConfig[atvId].tips or " "), tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 挑战次数不足
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData.remainTimes <= 0 then
|
||||
--print("ActivityType29.lua reqEnterFuben actorData.remainTimes <= 0 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
if nil == ActivityDispatcher.EnterFuben(atvId, pActor, (ActivityConfig[atvId].fbId or 0)) then
|
||||
print("ActivityType29.lua reqEnterFuben EnterFuben failure 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 请求扫荡
|
||||
function reqSaoDang(atvId, pActor, inPack)
|
||||
print("ActivityType29.lua reqSaoDang 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
local nSaoDangType = DataPack.readByte(inPack)
|
||||
if nil == nSaoDangType or nSaoDangType < SaoDangType.CommonSaoDang or nSaoDangType > SaoDangType.ExtraSaoDang then
|
||||
print("ActivityType29.lua reqSaoDang nil == nSaoDangType or nSaoDangType < SaoDangType.CommonSaoDang or nSaoDangType > SaoDangType.ExtraSaoDang 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig[atvId] then
|
||||
print("ActivityType29.lua reqSaoDang not ActivityConfig or not ActivityConfig[atvId] 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if nSaoDangType == SaoDangType.CommonSaoDang then -- 普通扫荡
|
||||
local openDayLimit = 0
|
||||
local zsLevelLimit = 0
|
||||
local levelLimit = 0
|
||||
-- 每日Boss挑战条件
|
||||
if ActivityConfig[atvId].openParam then
|
||||
openDayLimit = (ActivityConfig[atvId].openParam.openDay or 0)
|
||||
zsLevelLimit = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
levelLimit = (ActivityConfig[atvId].openParam.level or 0)
|
||||
end
|
||||
|
||||
-- 开服天数不足
|
||||
if openDayLimit > System.getDaysSinceOpenServer() then
|
||||
print("ActivityType29.lua reqEnterFuben DaysSinceOpenServer not enough 活动Id :"..atvId.." 开服 "..openDayLimit.." 天可以挑战")
|
||||
return
|
||||
end
|
||||
|
||||
-- 转生等级不足 或 等级不足
|
||||
local nZSLevel = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
if zsLevelLimit > nZSLevel or levelLimit > nLevel then
|
||||
--print("ActivityType29.lua reqEnterFuben CircleNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsg(pActor, (ActivityConfig[atvId].tips or " "), tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
local vipLevelLimit = 0
|
||||
if ActivityConfig[atvId].SaoRequire then
|
||||
vipLevelLimit = (ActivityConfig[atvId].SaoRequire.vip or 0)
|
||||
end
|
||||
-- 特权等级不足
|
||||
local nVipLevel = Actor.GetMaxColorCardLevel(pActor)
|
||||
if vipLevelLimit > nVipLevel then
|
||||
--print("ActivityType29.lua reqSaoDang vipNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmComPoseVipLimit, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 扫荡次数不足
|
||||
if actorData.remainTimes <= 0 then
|
||||
--print("ActivityType29.lua reqSaoDang actorData.remainTimes <= 0 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)
|
||||
return
|
||||
end
|
||||
elseif nSaoDangType == SaoDangType.ExtraSaoDang then -- 额外扫荡
|
||||
local openDayLimit = 0
|
||||
local zsLevelLimit = 0
|
||||
local levelLimit = 0
|
||||
-- 每日Boss挑战条件
|
||||
if ActivityConfig[atvId].showParam then
|
||||
openDayLimit = (ActivityConfig[atvId].showParam.openDay or 0)
|
||||
zsLevelLimit = (ActivityConfig[atvId].showParam.zsLevel or 0)
|
||||
levelLimit = (ActivityConfig[atvId].showParam.level or 0)
|
||||
end
|
||||
|
||||
-- 开服天数不足
|
||||
if openDayLimit > System.getDaysSinceOpenServer() then
|
||||
print("ActivityType29.lua reqEnterFuben DaysSinceOpenServer not enough 活动Id :"..atvId.." 开服 "..openDayLimit.." 天可以挑战")
|
||||
return
|
||||
end
|
||||
|
||||
-- 转生等级不足
|
||||
local nZSLevel = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if zsLevelLimit > nZSLevel then
|
||||
--print("ActivityType2.lua reqEnterFuben CircleNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmCircleNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 等级不足
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
if levelLimit > nLevel then
|
||||
--print("ActivityType2.lua reqEnterFuben LevelNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmLevelLowernoenter, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 检查消耗
|
||||
if ActivityConfig[atvId].VipSaodangPrice then
|
||||
if true ~= CommonFunc.Consumes.CheckActorSources(pActor, ActivityConfig[atvId].VipSaodangPrice[actorData.extraSaoDangTimes + 1], tstUI) then
|
||||
--print("ActivityType29.lua reqSaoDang not CheckActorSources 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmYBNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 扫荡次数不足
|
||||
if actorData.extraSaoDangRemainTimes <= 0 then
|
||||
--print("ActivityType29.lua reqSaoDang actorData.extraSaoDangRemainTimes <= 0 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 检查背包格子
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor, 16, tmDefNoBagNum, tstUI) then
|
||||
print("ActivityType29.lua reqSaoDang CheckBagNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
-- 移除消耗
|
||||
if nSaoDangType == SaoDangType.ExtraSaoDang then
|
||||
if true ~= CommonFunc.Consumes.Remove(pActor, ActivityConfig[atvId].VipSaodangPrice[actorData.extraSaoDangTimes + 1], GameLog.Log_Activity29, "Activity29|"..atvId) then
|
||||
print("ActivityType29.lua reqSaoDang Remove Consumes fail 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 消耗次数
|
||||
if nSaoDangType == SaoDangType.CommonSaoDang then -- 普通扫荡
|
||||
actorData.remainTimes = actorData.remainTimes - 1
|
||||
elseif nSaoDangType == SaoDangType.ExtraSaoDang then -- 额外扫荡
|
||||
actorData.extraSaoDangTimes = actorData.extraSaoDangTimes + 1
|
||||
actorData.extraSaoDangRemainTimes = actorData.extraSaoDangRemainTimes - 1
|
||||
end
|
||||
|
||||
-- 发放奖励
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig[atvId].reward, GameLog.Log_Activity29, "Activity29|"..atvId)
|
||||
|
||||
Actor.sendTipmsg(pActor, "扫荡成功", tstUI)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor, atvId,ActivityType, 2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
-- 触发活跃事件
|
||||
if nSaoDangType == SaoDangType.CommonSaoDang then
|
||||
Actor.triggerActiveEvent(pActor,nAchieveActivity,1 ,atvId)
|
||||
Actor.triggerActiveEvent(pActor, nAchieveCompleteActivity,1 ,atvId)
|
||||
|
||||
Actor.triggerActiveEvent(pActor,nAchieveActivityType,1 ,ActivityType)
|
||||
end
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId, pActor)
|
||||
--print("ActivityType29.lua OnLoad 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
print("ActivityType29.lua OnStart 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
-- 开服第一天开始,初始化新玩家次数
|
||||
if 1 > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if nil == actorData.lastChangeExtraVipLevel then
|
||||
actorData.lastChangeExtraVipLevel = 0
|
||||
end
|
||||
if nil == actorData.remainTimes then
|
||||
actorData.remainTimes = 0
|
||||
end
|
||||
|
||||
local ndiffday = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] then
|
||||
local config = ActivityConfig[atvId]
|
||||
local nOpenTime = System.getOpenServerRelToday()
|
||||
local nDiffTime = math.max(nOpenTime, (config.SetTime or 0));
|
||||
local bNewActor = false
|
||||
local nTime = Actor.getStaticCount(pActor, config.counterid)
|
||||
if nTime == 0 then
|
||||
bNewActor = true
|
||||
end
|
||||
|
||||
local nOffDay = 0
|
||||
if nTime ~= nDiffTime then
|
||||
if bNewActor then
|
||||
nTime = System.getToday()
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + 1
|
||||
else
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + ndiffday
|
||||
end
|
||||
Actor.setStaticCount(pActor, config.counterid, nDiffTime)
|
||||
end
|
||||
|
||||
if nOffDay ~= 0 then
|
||||
ndiffday = nOffDay
|
||||
end
|
||||
else
|
||||
print("ActivityType29.lua OnStart not ActivityConfig or not ActivityConfig[atvId] atvId : "..atvId)
|
||||
end
|
||||
actorData.remainTimes = ndiffday
|
||||
|
||||
if nil == actorData.extraSaoDangRemainTimes then
|
||||
local nVipLevel = Actor.GetMaxColorCardLevel(pActor)
|
||||
local nExtraSaoDang = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].vipBuyCount then
|
||||
nExtraSaoDang = (ActivityConfig[atvId].vipBuyCount[nVipLevel] or 0)
|
||||
end
|
||||
actorData.extraSaoDangRemainTimes = nExtraSaoDang
|
||||
actorData.lastChangeExtraVipLevel = nVipLevel
|
||||
end
|
||||
if nil == actorData.extraSaoDangTimes then
|
||||
actorData.extraSaoDangTimes = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
print("ActivityType29.lua OnGetRedPoint 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
-- 开服天数
|
||||
local nOpenDays = System.getDaysSinceOpenServer()
|
||||
local nZSLevel = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
|
||||
-- 挑战限制条件
|
||||
local openDayLimit = 0
|
||||
local zsLevelLimit = 0
|
||||
local levelLimit = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].openParam then
|
||||
openDayLimit = (ActivityConfig[atvId].openParam.openDay or 0)
|
||||
zsLevelLimit = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
levelLimit = (ActivityConfig[atvId].openParam.level or 0)
|
||||
end
|
||||
|
||||
local ret = 1
|
||||
-- 开服天数不足
|
||||
if openDayLimit > nOpenDays then
|
||||
ret = 0
|
||||
end
|
||||
-- 转升等级不足
|
||||
if zsLevelLimit > nZSLevel then
|
||||
ret = 0
|
||||
end
|
||||
-- 等级不足
|
||||
if levelLimit > nLevel then
|
||||
ret = 0
|
||||
end
|
||||
-- 剩余挑战(扫荡)次数不足
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if not actorData.remainTimes or actorData.remainTimes <= 0 then
|
||||
ret = 0
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
print("ActivityType29.lua OnReqData 玩家 :"..Actor.getName(pActor).." 活动Id :"..atvId)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
-- 如果VIP等级发生变化,则增加相应次数
|
||||
local nVipLevel = Actor.GetMaxColorCardLevel(pActor)
|
||||
if actorData.lastChangeExtraVipLevel ~= nVipLevel then
|
||||
local nTimes = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].vipBuyCount then
|
||||
nTimes = (ActivityConfig[atvId].vipBuyCount[nVipLevel] or 0) - actorData.extraSaoDangTimes
|
||||
end
|
||||
|
||||
if nTimes then
|
||||
actorData.extraSaoDangRemainTimes = nTimes
|
||||
|
||||
actorData.lastChangeExtraVipLevel = nVipLevel
|
||||
else
|
||||
print("ActivityType29.lua OnReqData 玩家 :"..Actor.getName(pActor).." nTimes : "..nTimes)
|
||||
end
|
||||
end
|
||||
|
||||
DataPack.writeWord(outPack, (actorData.remainTimes or 0))
|
||||
DataPack.writeByte(outPack, (actorData.extraSaoDangRemainTimes or 0))
|
||||
DataPack.writeByte(outPack, (actorData.extraSaoDangTimes or 0))
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
print("ActivityType29.lua OnOperator 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(atvId, pActor)
|
||||
elseif operaCode == ActivityOperate.cReqSaoDang then -- 请求扫荡
|
||||
reqSaoDang(atvId, pActor, inPack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 进入副本
|
||||
function OnEnterFuben(atvId, pActor, pFuben, pOwner)
|
||||
--print("ActivityType29.lua OnEnterFuben 玩家 :"..Actor.getName(pActor).. " 副本Id :"..fbId)
|
||||
end
|
||||
|
||||
-- 玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben, pOwner)
|
||||
print("ActivityType29.lua OnExitFuben 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
if not ActivityConfig or not ActivityConfig[atvId] then
|
||||
print("ActivityType29.lua OnExitFuben not ActivityConfig or not ActivityConfig[atvId] 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
-- 通关后才消耗门票跟次数
|
||||
if 1 == FubenDispatcher.GetReault(pFuben) then
|
||||
-- 单人副本活动,所有者必须为自己
|
||||
if pOwner == pActor then
|
||||
local fbcache = FubenDispatcher.GetCacheData(pFuben)
|
||||
if not fbcache.hasGetAward then
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor, 16, tmDefNoBagNum, tstUI) then
|
||||
print("ActivityType29.lua OnReqFubenAward CheckBagNotEnough玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig[atvId].reward, GameLog.Log_Activity29, "Activity29|"..atvId)
|
||||
|
||||
Actor.sendTipmsg(pActor, "每日Boss任务完成,奖励已发放!", tstGetItem)
|
||||
|
||||
fbcache.hasGetAward = 1
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
-- 消耗次数
|
||||
if actorData.remainTimes > 0 then
|
||||
actorData.remainTimes = actorData.remainTimes - 1
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor, atvId, ActivityType, 2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
-- 触发活跃事件
|
||||
Actor.triggerActiveEvent(pActor,nAchieveActivity,1 ,atvId)
|
||||
Actor.triggerActiveEvent(pActor, nAchieveCompleteActivity,1 ,atvId)
|
||||
Actor.triggerActiveEvent(pActor, nAchieveActivityType,1 ,ActivityType)
|
||||
end
|
||||
end
|
||||
else
|
||||
print("ActivityType29.lua OnExitFuben 1 ~= FubenDispatcher.GetReault(pFuben) 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result, pOwner)
|
||||
print("ActivityType29.lua OnFubenFinish 活动Id :"..atvId.." result : "..result)
|
||||
|
||||
--发送成功失败的旗帜
|
||||
if pOwner then
|
||||
if result == 1 then
|
||||
--完成副本任务
|
||||
--Actor.ExOnQuestEvent(pOwner, CQuestData.qtFuben, 12);
|
||||
end
|
||||
local npack = ActivityDispatcher.AllocResultPack(pOwner, atvId, result)
|
||||
if npack then
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
--print("ActivityType29.lua OnEnd 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterFuben, ActivityType, OnEnterFuben, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType29.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType29.lua")
|
||||
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor, ndiffday)
|
||||
print("ActivityType29.lua OnNewDayArrive 玩家 :"..Actor.getName(pActor).. " 跨 "..ndiffday.." 天")
|
||||
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor, ActivityType)
|
||||
if runAtvIdList then
|
||||
-- 增加挑战(扫荡)的起始开服天数
|
||||
for i, atvId in ipairs(runAtvIdList) do
|
||||
|
||||
-- 开服第一天开始;累加挑战(扫荡次数)次数:
|
||||
if 1 > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if nil == actorData.lastChangeExtraVipLevel then
|
||||
actorData.lastChangeExtraVipLevel = 0
|
||||
end
|
||||
if nil == actorData.remainTimes then
|
||||
actorData.remainTimes = 0
|
||||
end
|
||||
if nil == actorData.extraSaoDangRemainTimes then
|
||||
actorData.extraSaoDangRemainTimes = 0
|
||||
end
|
||||
if nil == actorData.extraSaoDangTimes then
|
||||
actorData.extraSaoDangTimes = 0
|
||||
end
|
||||
|
||||
if ActivityConfig and ActivityConfig[atvId] then
|
||||
local config = ActivityConfig[atvId]
|
||||
local nOpenTime = System.getOpenServerRelToday()
|
||||
local nDiffTime = math.max(nOpenTime, (config.SetTime or 0));
|
||||
|
||||
local bNewActor = false
|
||||
local nTime = Actor.getStaticCount(pActor, config.counterid)
|
||||
if nTime == 0 then
|
||||
bNewActor = true
|
||||
end
|
||||
|
||||
local nOffDay = 0
|
||||
if nTime ~= nDiffTime then
|
||||
if bNewActor then
|
||||
nTime = System.getToday();
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + 1
|
||||
else
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + ndiffday
|
||||
end
|
||||
Actor.setStaticCount(pActor, config.counterid, nDiffTime)
|
||||
end
|
||||
|
||||
if nOffDay ~= 0 then
|
||||
ndiffday = nOffDay
|
||||
end
|
||||
else
|
||||
print("ActivityType29.lua OnNewDayArrive not ActivityConfig or ActivityConfig[atvId] atvId : "..atvId)
|
||||
end
|
||||
|
||||
actorData.remainTimes = actorData.remainTimes + ndiffday
|
||||
|
||||
-- 重置额外扫荡次数
|
||||
local nVipLevel = Actor.GetMaxColorCardLevel(pActor)
|
||||
local nExtraSaoDang = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].vipBuyCount then
|
||||
nExtraSaoDang = (ActivityConfig[atvId].vipBuyCount[nVipLevel] or 0)
|
||||
end
|
||||
actorData.extraSaoDangRemainTimes = nExtraSaoDang
|
||||
actorData.lastChangeExtraVipLevel = nVipLevel
|
||||
actorData.extraSaoDangTimes = 0
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType29.lua")
|
||||
|
||||
|
||||
@@ -0,0 +1,746 @@
|
||||
module("ActivityType3", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动,竞技大乱斗
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
nextLoginTime, 退出后下次可进来的时间戳
|
||||
isFirst , 第一次
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
nextAutoTime, 下一次自动加积分的时间戳
|
||||
firstHalfNotice, 上半场开场公告标记
|
||||
secondHalfNotice, 下半场开场公告标记
|
||||
broadcastTime, 下一次广播的时间戳
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
status, 活动状态,这个即使服务器重启了,也要保存这个数据
|
||||
nextChgStatusTime, 下一次活动状态改变的时间戳
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 3
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity3Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY3
|
||||
|
||||
--活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
FirstHalf = 1, --上半场(自由击杀不限复活次,自由进出)
|
||||
SecondHalf = 2, --下半场(限复活次数,可出不可进)
|
||||
End = 3, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
|
||||
--助攻列表
|
||||
attackerList=
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [handle,被攻击者] =
|
||||
-- {
|
||||
-- [attkHandle,攻击者] = 最新攻击时间
|
||||
-- }
|
||||
--}
|
||||
}
|
||||
|
||||
--阶段奖励的领取记录,记录下一次要领取的阶段索引
|
||||
actorAwardIdx =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [aid] = idx
|
||||
--}
|
||||
}
|
||||
|
||||
--在场景中的玩家
|
||||
actorsInFuben =
|
||||
{
|
||||
--[atvId] =
|
||||
--{
|
||||
-- [actorId] = actorId
|
||||
--}
|
||||
}
|
||||
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local fbHandle = Actor.getFubenHandle(pActor)
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--退出后登入的时间限制
|
||||
if actorData.nextLoginTime and actorData.nextLoginTime > System.getCurrMiniTime() then
|
||||
Actor.sendTipmsg(pActor, "请30秒后再进入!")
|
||||
return
|
||||
end
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if ActivityConfig[atvId].enterExpends then
|
||||
consumes = ActivityConfig[atvId].enterExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
-- Actor.sendTipmsg(pActor, "道具或金币元宝不足!", tstEcomeny)
|
||||
Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if ActivityConfig[atvId].count and ActivityConfig[atvId].count > 0 then
|
||||
if actorData.count == nil then
|
||||
actorData.count = 1
|
||||
else
|
||||
if actorData.count >= ActivityConfig[atvId].count then
|
||||
Actor.sendTipmsg(pActor, "超过今日的次数了!"..actorData.count.."/"..ActivityConfig[atvId].count, tstUI)
|
||||
return
|
||||
end
|
||||
actorData.count = actorData.count + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity3, "竞技大乱斗|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- 这个阶段还不能进入
|
||||
if globalData.status == AtvStatus.SecondHalf then
|
||||
-- Actor.sendTipmsg(pActor, "活动当前阶段不能进入!", tstUI)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoInOpenTime, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--进入副本
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 设置排行榜
|
||||
--RankMgr.SetRank(actorId, RANKING_ID, 0)
|
||||
|
||||
-- 重置下次进入时间
|
||||
actorData.nextLoginTime = nil
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
|
||||
-- 记录进入奖励索引
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
actorAwardIdx[atvId] = {}
|
||||
end
|
||||
|
||||
if actorAwardIdx[atvId][actorId] == nil then
|
||||
actorAwardIdx[atvId][actorId] = 1
|
||||
end
|
||||
|
||||
-- 发送下一次领取奖励的索引
|
||||
SendNextAwardIndex(pActor, atvId)
|
||||
|
||||
-- 发送场次信息
|
||||
SendCurrentTimeInfo(pActor, atvId)
|
||||
|
||||
-- 禁止普通频道聊天
|
||||
Actor.setChatForbit(pActor, ciChannelNear, true)
|
||||
|
||||
-- 广播一次排行榜
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
RankMgr.Save(RANKING_ID)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
|
||||
-- 强制全体pk模式
|
||||
Actor.setPkMode(pActor,fpPk)
|
||||
end
|
||||
end
|
||||
|
||||
--请求领取阶段奖励
|
||||
function reqGetPhaseAward(pActor, atvId)
|
||||
local aid = Actor.getActorId(pActor)
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
actorAwardIdx[atvId] = {}
|
||||
end
|
||||
|
||||
if actorAwardIdx[atvId][aid] == nil then
|
||||
actorAwardIdx[atvId][aid] = 1
|
||||
end
|
||||
|
||||
local curIdx = actorAwardIdx[atvId][aid]
|
||||
|
||||
local awardConf = ActivityConfig[atvId].phaseAward[curIdx]
|
||||
if awardConf then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
if curVal >= awardConf.value then
|
||||
local awards = awardConf.awards
|
||||
-- if CommonFunc.Awards.CheckBagGridCount(pActor,awards) ~= true then
|
||||
-- return
|
||||
-- end
|
||||
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,1,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
print("[GActivity 3] "..Actor.getName(pActor).." 领取阶段奖励,".."id="..atvId.." ".."index="..curIdx)
|
||||
CommonFunc.Awards.Give(pActor, awards, GameLog.Log_Activity3, "Activity3LevelAward|"..atvId)
|
||||
actorAwardIdx[atvId][aid] = actorAwardIdx[atvId][aid] + 1
|
||||
-- if actorAwardIdx[atvId][aid] == 2 then
|
||||
|
||||
-- end
|
||||
SendNextAwardIndex(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadRankData(atvId,fbHandle,sceneId)
|
||||
-- 广播所有玩家排行榜数据
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID, 4, npack)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家排行数据
|
||||
function SendRankData(atvId,pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMyRankData)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家下一次领取奖励的索引
|
||||
function SendNextAwardIndex(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sNextAwardIndex)
|
||||
if npack then
|
||||
local aid = Actor.getActorId(pActor)
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
actorAwardIdx[atvId] = {}
|
||||
end
|
||||
|
||||
if actorAwardIdx[atvId][aid] == nil then
|
||||
actorAwardIdx[atvId][aid] = 1
|
||||
end
|
||||
|
||||
DataPack.writeByte(npack, (actorAwardIdx[atvId][aid] or 1))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家当前场次时间信息
|
||||
function SendCurrentTimeInfo(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendTime)
|
||||
if npack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
DataPack.writeByte(npack, (globalData.status-2))
|
||||
local leftTime = globalData.nextChgStatusTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, leftTime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--广播当前场次时间信息
|
||||
function BroadCurrentTimeInfo(atvId,fbHandle,sceneId)
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendTime)
|
||||
if npack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
DataPack.writeByte(npack, (globalData.status-2))
|
||||
local leftTime = globalData.nextChgStatusTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, leftTime)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送排名奖励
|
||||
function SendRankAward(atvId)
|
||||
if ActivityConfig[atvId].rankAward then
|
||||
local rankAward = ActivityConfig[atvId].rankAward
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
local title = "竞技大乱斗"
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
local idx = 1
|
||||
for _,awardInfo in ipairs(rankAward) do
|
||||
local rankNum = awardInfo.value
|
||||
if rankNum > itemNum then
|
||||
rankNum = itemNum
|
||||
end
|
||||
for i=idx,rankNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
local title = "竞技大乱斗"
|
||||
local content = string.format("恭喜你在竞技大乱斗中取得第%d名!", i)
|
||||
SendMail(actorId, title, content, awardInfo.awards)
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
local name = RankMgr.GetValueById(actorId, RANKING_ID, 0)
|
||||
print("[GActivity 3] 竞技大乱斗(id:"..atvId..") "..(name or actorId).." 获得第"..i.."名!")
|
||||
end
|
||||
idx = rankNum + 1
|
||||
if idx > itemNum then
|
||||
print("[GActivity 3] 竞技大乱斗(id:"..atvId..") 奖励发完! 一共"..rankNum.."人获得上榜奖励!")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送积分奖励
|
||||
function SendScoreAward(atvId)
|
||||
local MaxIdx = #ActivityConfig[atvId].phaseAward
|
||||
local title = "竞技大乱斗未领奖励"
|
||||
|
||||
if actorAwardIdx[atvId] == nil then
|
||||
return
|
||||
end
|
||||
for aid,awdIdx in pairs(actorAwardIdx[atvId]) do
|
||||
if actorAwardIdx[atvId][aid] ~= nil then
|
||||
local rankValue = RankMgr.GetValue(aid, RANKING_ID)
|
||||
for i=awdIdx,MaxIdx do
|
||||
local awardConf = ActivityConfig[atvId].phaseAward[i]
|
||||
if awardConf then
|
||||
if rankValue >= awardConf.value then
|
||||
local content = string.format("你在竞技大乱斗中还有积分%d档的奖励未领取!", awardConf.value)
|
||||
SendMail(aid, title, content, awardConf.awards)
|
||||
actorAwardIdx[atvId][aid] = actorAwardIdx[atvId][aid] + 1
|
||||
local pActor = Actor.getActorById(aid)
|
||||
-- if actorAwardIdx[atvId][aid] == 2 and pActor then
|
||||
-- -- Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
-- -- Actor.triggerAchieveEvent(pOwner, nAchieveCompleteActivity,1 ,atvId);
|
||||
-- end
|
||||
|
||||
print("[GActivity 3] aid:"..aid.." 补发阶段奖励,".."id="..atvId.." ".."积分档次:"..awardConf.value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 设置复活,分场次,上半场随意复活(不设置它),下半场限制3次,超过就踢出去
|
||||
function SetAutoRelive(atvId,pActor,pFuben)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData.status == AtvStatus.SecondHalf then
|
||||
local deathLimit = FubenDispatcher.GetReliveCount(pFuben, pActor)
|
||||
if (deathLimit == nil) or (deathLimit == -1) then
|
||||
FubenDispatcher.SetReliveCount(pFuben, pActor, ActivityConfig[atvId].Rebirthsecond)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 3] 竞技大乱斗 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 3] 竞技大乱斗 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.nextLoginTime = nil
|
||||
actorData.isFirst = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 3] 竞技大乱斗 活动开始了,id:"..atvId)
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
cacheData.nextAutoTime = 0
|
||||
cacheData.actors = {}
|
||||
cacheData.broadcastTime = 0
|
||||
|
||||
globalData.status = AtvStatus.FirstHalf
|
||||
globalData.nextChgStatusTime = System.getCurrMiniTime() + ActivityConfig[atvId].firstHalfTime
|
||||
if globalData.openTimes == nil then
|
||||
local currentId = System.getCurrMiniTime();
|
||||
globalData.openTimes = currentId
|
||||
else
|
||||
globalData.openTimes = globalData.openTimes + 1
|
||||
end
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[GActivity 3] 竞技大乱斗 活动结束了,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
local pFuben = ActivityDispatcher.GetFuben(atvId)
|
||||
if pFuben then
|
||||
-- 设置副本结果
|
||||
FubenDispatcher.SetResult(pFuben,1)
|
||||
-- 延迟踢出副本
|
||||
FubenDispatcher.KictoutAfter(pFuben,15)
|
||||
end
|
||||
|
||||
-- 广播第一名
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, 0)
|
||||
local name = Ranking.getSub(rankItem, 0)
|
||||
if rankItem then
|
||||
System.broadcastTipmsgLimitLev("大乱斗活动结束了,恭喜玩家 "..name.." 获得第一名!", tstRevolving)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送奖励
|
||||
SendRankAward( atvId )
|
||||
|
||||
-- 补发阶段奖励
|
||||
SendScoreAward(atvId)
|
||||
|
||||
-- 关闭副本
|
||||
--Fuben.closeFuben( cacheData.fbHandle )
|
||||
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
ActivityDispatcher.ClearGlobalData( atvId )
|
||||
actorAwardIdx[atvId] = nil
|
||||
attackerList[atvId] = nil
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
|
||||
-- 检测活动结束
|
||||
if globalData and globalData.status and globalData.status == AtvStatus.End then
|
||||
return
|
||||
end
|
||||
|
||||
if globalData.status == AtvStatus.FirstHalf then
|
||||
if cacheData.firstHalfNotice == nil then
|
||||
System.broadcastTipmsgLimitLev(ActivityConfig[atvId].noticeFirstHalf, tstRevolving)
|
||||
cacheData.firstHalfNotice = 1
|
||||
BroadCurrentTimeInfo(atvId, cacheData.fbHandle, Fuben.getSceneId(cacheData.scenHandle))
|
||||
-- 发送一个活动数据
|
||||
-- Actor.sendActivityData(pActor, atvId)
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
ActivityDispatcher.BroadPopup(atvId);
|
||||
end
|
||||
elseif globalData.status == AtvStatus.SecondHalf then
|
||||
if cacheData.secondHalfNotice == nil then
|
||||
System.broadcastTipmsgLimitLev(ActivityConfig[atvId].noticeSecondHalf, tstRevolving)
|
||||
cacheData.secondHalfNotice = 1
|
||||
BroadCurrentTimeInfo(atvId, cacheData.fbHandle, Fuben.getSceneId(cacheData.scenHandle))
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
-- 发送一个活动数据
|
||||
-- Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 有玩家时才处理
|
||||
if actorsInFuben[atvId] then
|
||||
|
||||
local hasMan = false
|
||||
|
||||
-- 泡点
|
||||
if (cacheData.nextAutoTime or 0) - curTime > ActivityConfig[atvId].autoTime then
|
||||
cacheData.nextAutoTime = curTime
|
||||
end
|
||||
if curTime > (cacheData.nextAutoTime or 0) then
|
||||
cacheData.nextAutoTime = curTime + ActivityConfig[atvId].autoTime
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
RankMgr.AddValue(actorid, RANKING_ID, ActivityConfig[atvId].addScoreAuto)
|
||||
OnDealAchieve(atvId, pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
Actor.sendTipmsg(pActor, "持续参加活动,积分+"..ActivityConfig[atvId].addScoreAuto..",当前积分为:"..curVal, tstGetItem)
|
||||
SendRankData(atvId,pActor)
|
||||
hasMan = true
|
||||
end
|
||||
end
|
||||
if hasMan then
|
||||
RankMgr.Save(RANKING_ID)
|
||||
end
|
||||
end
|
||||
|
||||
-- 每秒广播一次
|
||||
if (cacheData.broadcastTime or 0) - curTime > 1 then
|
||||
cacheData.broadcastTime = curTime
|
||||
end
|
||||
if curTime > (cacheData.broadcastTime or 0) then
|
||||
cacheData.broadcastTime = curTime + 1
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
end
|
||||
end
|
||||
|
||||
-- 场次检测
|
||||
if curTime > (globalData.nextChgStatusTime or 0) then
|
||||
globalData.status = (globalData.status or 0) + 1
|
||||
if globalData.status == AtvStatus.SecondHalf then
|
||||
globalData.nextChgStatusTime = curTime + ActivityConfig[atvId].secondHalfTime
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cGetPhaseAward then --请求获取阶段奖励
|
||||
reqGetPhaseAward(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
|
||||
-- 玩家退出,从记录中排除
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
|
||||
-- 玩家下次进入时间限制
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nextLoginTime = System.getCurrMiniTime() + 30
|
||||
|
||||
-- 恢复禁止普通频道聊天
|
||||
Actor.setChatForbit(pActor, ciChannelNear, false)
|
||||
|
||||
-- 完成
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
--print(debug.traceback("Stack trace"))
|
||||
|
||||
if pKiller then
|
||||
local entityType = Actor.getEntityType(pEntity)--被击杀者的类型
|
||||
local killerType = Actor.getEntityType(pKiller)--击杀者的类型
|
||||
if killerType == enActor then
|
||||
if entityType == enActor then
|
||||
-- 杀玩家获得积分
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(killerId, RANKING_ID, ActivityConfig[atvId].addScoreKill)
|
||||
OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你成功击败["..Actor.getName(pEntity).."],积分+"..ActivityConfig[atvId].addScoreKill, tstGetItem)
|
||||
|
||||
-- 被玩家击杀的玩家获得的积分
|
||||
local entityId = Actor.getIntProperty( pEntity, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(entityId, RANKING_ID, ActivityConfig[atvId].addScoreBeKill)
|
||||
OnDealAchieve(atvId, pEntity)
|
||||
Actor.sendTipmsg(pEntity, "你被["..Actor.getName(pKiller).."]击败了,积分+"..ActivityConfig[atvId].addScoreBeKill, tstGetItem)
|
||||
|
||||
-- 设置复活
|
||||
SetAutoRelive(atvId, pEntity, pFuben)
|
||||
else
|
||||
-- 杀守卫获得积分
|
||||
local killerId = Actor.getIntProperty( pKiller, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(killerId, RANKING_ID, ActivityConfig[atvId].addScoreGuard)
|
||||
OnDealAchieve(atvId, pKiller)
|
||||
Actor.sendTipmsg(pKiller, "你击败守卫,积分+"..ActivityConfig[atvId].addScoreGuard, tstGetItem)
|
||||
end
|
||||
|
||||
if not attackerList[atvId] then attackerList[atvId] = {} end
|
||||
|
||||
-- 助攻积分
|
||||
local handle = Actor.getHandle(pEntity)
|
||||
local entityName = Actor.getName(pEntity)
|
||||
if attackerList[atvId][handle] then
|
||||
local nowTime = System.getCurrMiniTime()
|
||||
local killerHandle = Actor.getHandle(pKiller)
|
||||
for attkHandle,time in pairs(attackerList[atvId][handle]) do
|
||||
if nowTime - time <= ActivityConfig[atvId].helpTime and killerHandle ~= attkHandle then
|
||||
local pActor = Actor.getEntity(attkHandle)
|
||||
if pActor then
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
RankMgr.AddValue(actorId, RANKING_ID, ActivityConfig[atvId].addScoreHelpKill)
|
||||
OnDealAchieve(atvId, pActor)
|
||||
Actor.sendTipmsg(pActor, "你助攻击败["..entityName.."],积分+"..ActivityConfig[atvId].addScoreHelpKill, tstGetItem)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
attackerList[atvId][handle] = nil
|
||||
else
|
||||
-- 设置复活
|
||||
SetAutoRelive(atvId, pEntity, pFuben)
|
||||
end
|
||||
SendRankData(atvId,pKiller)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动副本中,实体守到攻击
|
||||
function OnEntityAttacked(atvId, pEntity, pAttacker, pFuben)
|
||||
|
||||
-- 攻击者必须为玩家,才记录助攻
|
||||
if Actor.getEntityType(pAttacker) == enActor then
|
||||
|
||||
-- 通过句柄作为key(因为守卫的id是一样的,所以只能通过handle区分)
|
||||
local handle = Actor.getHandle(pEntity)
|
||||
local attkHandle = Actor.getHandle(pAttacker)
|
||||
|
||||
if not attackerList[atvId] then attackerList[atvId] = {} end
|
||||
|
||||
local info = attackerList[atvId][handle]
|
||||
if not info then
|
||||
attackerList[atvId][handle] = { [attkHandle] = System.getCurrMiniTime() }
|
||||
else
|
||||
info[attkHandle] = System.getCurrMiniTime()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result)
|
||||
--广播成功失败的旗帜(带上自己的排行数据)
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor then
|
||||
local npack = ActivityDispatcher.AllocResultPack(pActor, atvId, 1)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local ret = 0
|
||||
if globalData.status and (globalData.status == AtvStatus.FirstHalf) then ret = 1 end
|
||||
local limitLv = 0;
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
limitLv = (cfg.openParam.level or 0)
|
||||
end
|
||||
local lv = Actor.getIntProperty( pActor, PROP_CREATURE_LEVEL )
|
||||
if lv < limitLv then ret = 0 end
|
||||
return ret
|
||||
end
|
||||
|
||||
----处理成就问题
|
||||
function OnDealAchieve(atvId, pActor)
|
||||
|
||||
local ActorType = Actor.getEntityType(pActor)--类型
|
||||
if ActorType ==enActor then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData and actorData.isFirst == nil and curVal >= 50 then
|
||||
Actor.triggerAchieveEvent(pActor,nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
actorData.isFirst = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---处理结束邮件问题
|
||||
function OnSendFailMail(atvId, pActor)
|
||||
local ActorType = Actor.getEntityType(pActor)--类型
|
||||
if ActorType ==enActor then
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.mailtitle and cfg.mailcontent then
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
SendMail(actorid, cfg.mailtitle, cfg.mailcontent)
|
||||
end
|
||||
end
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityAttacked, ActivityType, OnEntityAttacked, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType3.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnAtvGG, ActivityType, OnSendFailMail, "ActivityType3.lua")
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
@@ -0,0 +1,419 @@
|
||||
module("ActivityType30", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动,鉴定类活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
lastChangeExtraVipLevel 上一次改变额外鉴定次数的等级
|
||||
remainIdentifyTimes, 剩余鉴定次数
|
||||
remainExtraIdentifyTimes, 剩余外鉴定次数
|
||||
extraIdentifyimes, 额外鉴定次数
|
||||
}
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 30
|
||||
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity30Config
|
||||
|
||||
--鉴定类型
|
||||
local IdentifyType =
|
||||
{
|
||||
CommonIdentify = 1, -- 普通鉴定
|
||||
ExtraIdentify = 2, -- 额外鉴定
|
||||
}
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
-- 请求鉴定
|
||||
function reqAppraisal(atvId, pActor, inPack)
|
||||
print("ActivityType30.lua reqAppraisal 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
local nIdentifyType = DataPack.readByte(inPack)
|
||||
if nil == nIdentifyType or nIdentifyType < IdentifyType.CommonIdentify or nIdentifyType > IdentifyType.ExtraIdentify then
|
||||
print("ActivityType30.lua reqAppraisal nil == nIdentifyType or nIdentifyType < IdentifyType.CommonIdentify or nIdentifyType > IdentifyType.ExtraIdentify 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
if not ActivityConfig or not ActivityConfig[atvId] then
|
||||
print("ActivityType30.lua reqAppraisal not ActivityConfig or not ActivityConfig[atvId] 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if nIdentifyType == IdentifyType.CommonIdentify then -- 普通鉴定
|
||||
local openDayLimit = 0
|
||||
local zsLevelLimit = 0
|
||||
local levelLimit = 0
|
||||
-- 每日副本鉴定条件
|
||||
if ActivityConfig[atvId].openParam then
|
||||
openDayLimit = (ActivityConfig[atvId].openParam.openDay or 0)
|
||||
zsLevelLimit = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
levelLimit = (ActivityConfig[atvId].openParam.level or 0)
|
||||
end
|
||||
|
||||
-- 开服天数不足
|
||||
if openDayLimit > System.getDaysSinceOpenServer() then
|
||||
print("ActivityType30.lua reqEnterFuben DaysSinceOpenServer not enough 活动Id :"..atvId.." 开服 "..openDayLimit.." 天可以挑战")
|
||||
return
|
||||
end
|
||||
|
||||
-- 转生等级不足 或 等级不足
|
||||
local nZSLevel = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
if zsLevelLimit > nZSLevel or levelLimit > nLevel then
|
||||
--print("ActivityType30.lua reqEnterFuben CircleNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsg(pActor, (ActivityConfig[atvId].tips or " "), tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 鉴定次数不足
|
||||
if actorData.remainIdentifyTimes <= 0 then
|
||||
--print("ActivityType30.lua reqAppraisal actorData.remainIdentifyTimes <= 0 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)
|
||||
return
|
||||
end
|
||||
elseif nIdentifyType == IdentifyType.ExtraIdentify then -- 额外鉴定
|
||||
local openDayLimit = 0
|
||||
local zsLevelLimit = 0
|
||||
local levelLimit = 0
|
||||
-- 每日副本鉴定条件
|
||||
if ActivityConfig[atvId].showParam then
|
||||
openDayLimit = (ActivityConfig[atvId].showParam.openDay or 0)
|
||||
zsLevelLimit = (ActivityConfig[atvId].showParam.zsLevel or 0)
|
||||
levelLimit = (ActivityConfig[atvId].showParam.level or 0)
|
||||
end
|
||||
|
||||
-- 开服天数不足
|
||||
if openDayLimit > System.getDaysSinceOpenServer() then
|
||||
print("ActivityType30.lua reqEnterFuben DaysSinceOpenServer not enough 活动Id :"..atvId.." 开服 "..openDayLimit.." 天可以挑战")
|
||||
return
|
||||
end
|
||||
|
||||
-- 转生等级不足
|
||||
local nZSLevel = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
if zsLevelLimit > nZSLevel then
|
||||
--print("ActivityType30.lua reqEnterFuben CircleNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmCircleNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 等级不足
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
if levelLimit > nLevel then
|
||||
--print("ActivityType30.lua reqEnterFuben LevelNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmLevelLowernoenter, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 检查消耗
|
||||
if ActivityConfig[atvId].VipJiandingPrice then
|
||||
if true ~= CommonFunc.Consumes.CheckActorSources(pActor, ActivityConfig[atvId].VipJiandingPrice[actorData.extraIdentifyimes + 1], tstUI) then
|
||||
--print("ActivityType30.lua reqAppraisal not CheckActorSources 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
else
|
||||
print("ActivityType30.lua reqAppraisal not ActivityConfig[atvId].VipJiandingPrice 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
end
|
||||
|
||||
-- 鉴定次数不足
|
||||
if actorData.remainExtraIdentifyTimes <= 0 then
|
||||
--print("ActivityType30.lua reqAppraisal actorData.remainExtraIdentifyTimes <= 0 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 检查背包格子
|
||||
if true ~= CommonFunc.Awards.CheckBagIsEnough(pActor, 16, tmDefNoBagNum, tstUI) then
|
||||
print("ActivityType30.lua reqAppraisal CheckBagNotEnough 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
|
||||
-- 移除消耗
|
||||
if nIdentifyType == IdentifyType.ExtraIdentify then
|
||||
if true ~= CommonFunc.Consumes.Remove(pActor, ActivityConfig[atvId].VipJiandingPrice[actorData.extraIdentifyimes + 1], GameLog.Log_Activity12, "Activity12|"..atvId) then
|
||||
--print("ActivityType30.lua reqAppraisal Remove Consumes fail 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- 消耗次数
|
||||
if nIdentifyType == IdentifyType.CommonIdentify then -- 普通鉴定
|
||||
actorData.remainIdentifyTimes = actorData.remainIdentifyTimes - 1
|
||||
elseif nIdentifyType == IdentifyType.ExtraIdentify then -- 额外鉴定
|
||||
actorData.extraIdentifyimes = actorData.extraIdentifyimes + 1
|
||||
actorData.remainExtraIdentifyTimes = actorData.remainExtraIdentifyTimes - 1
|
||||
end
|
||||
|
||||
-- 发放奖励
|
||||
CommonFunc.Awards.Give(pActor, ActivityConfig[atvId].reward, GameLog.Log_Activity30, "Activity30|"..atvId)
|
||||
|
||||
Actor.sendTipmsg(pActor, "鉴定成功", tstUI)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor, atvId,ActivityType, 2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
-- 触发活跃事件
|
||||
if nIdentifyType == IdentifyType.CommonIdentify then
|
||||
Actor.triggerActiveEvent(pActor,nAchieveActivity,1 ,atvId)
|
||||
Actor.triggerActiveEvent(pActor, nAchieveCompleteActivity,1 ,atvId)
|
||||
|
||||
Actor.triggerActiveEvent(pActor,nAchieveActivityType,1 ,ActivityType)
|
||||
end
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId, pActor)
|
||||
--print("ActivityType30.lua OnLoad 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
print("ActivityType30.lua OnStart 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
-- 开服第一天开始,初始化新玩家次数
|
||||
if 1 > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if nil == actorData.lastChangeExtraVipLevel then
|
||||
actorData.lastChangeExtraVipLevel = 0
|
||||
end
|
||||
if nil == actorData.remainIdentifyTimes then
|
||||
actorData.remainIdentifyTimes = 0
|
||||
end
|
||||
|
||||
local ndiffday = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] then
|
||||
local config = ActivityConfig[atvId]
|
||||
local nOpenTime = System.getOpenServerRelToday()
|
||||
local nDiffTime = math.max(nOpenTime, (config.SetTime or 0));
|
||||
local bNewActor = false
|
||||
local nTime = Actor.getStaticCount(pActor, config.counterid)
|
||||
if nTime == 0 then
|
||||
bNewActor = true
|
||||
end
|
||||
|
||||
local nOffDay = 0
|
||||
if nTime ~= nDiffTime then
|
||||
if bNewActor then
|
||||
nTime = System.getToday()
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + 1
|
||||
else
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + ndiffday
|
||||
end
|
||||
Actor.setStaticCount(pActor, config.counterid, nDiffTime)
|
||||
end
|
||||
|
||||
if nOffDay ~= 0 then
|
||||
ndiffday = nOffDay
|
||||
end
|
||||
else
|
||||
print("ActivityType30.lua OnStart not ActivityConfig or not ActivityConfig[atvId] atvId : "..atvId)
|
||||
end
|
||||
actorData.remainIdentifyTimes = ndiffday
|
||||
|
||||
if nil == actorData.remainExtraIdentifyTimes then
|
||||
local nVipLevel = Actor.GetMaxColorCardLevel(pActor)
|
||||
local nExtraIdentify = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].vipBuyCount then
|
||||
nExtraIdentify = (ActivityConfig[atvId].vipBuyCount[nVipLevel] or 0)
|
||||
end
|
||||
actorData.remainExtraIdentifyTimes = nExtraIdentify
|
||||
actorData.lastChangeExtraVipLevel = nVipLevel
|
||||
end
|
||||
if nil == actorData.extraIdentifyimes then
|
||||
actorData.extraIdentifyimes = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
print("ActivityType30.lua OnGetRedPoint 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
-- 开服天数
|
||||
local nOpenDays = System.getDaysSinceOpenServer()
|
||||
local nZSLevel = Actor.getIntProperty(pActor, PROP_ACTOR_CIRCLE)
|
||||
local nLevel = Actor.getIntProperty(pActor, PROP_CREATURE_LEVEL)
|
||||
|
||||
-- 鉴定限制条件
|
||||
local openDayLimit = 0
|
||||
local zsLevelLimit = 0
|
||||
local levelLimit = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].openParam then
|
||||
openDayLimit = (ActivityConfig[atvId].openParam.openDay or 0)
|
||||
zsLevelLimit = (ActivityConfig[atvId].openParam.zsLevel or 0)
|
||||
levelLimit = (ActivityConfig[atvId].openParam.level or 0)
|
||||
end
|
||||
|
||||
local ret = 1
|
||||
-- 开服天数不足
|
||||
if openDayLimit > nOpenDays then
|
||||
ret = 0
|
||||
end
|
||||
-- 转升等级不足
|
||||
if zsLevelLimit > nZSLevel then
|
||||
ret = 0
|
||||
end
|
||||
-- 等级不足
|
||||
if levelLimit > nLevel then
|
||||
ret = 0
|
||||
end
|
||||
-- 剩余鉴定次数不足
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if not actorData.remainIdentifyTimes or actorData.remainIdentifyTimes <= 0 then
|
||||
ret = 0
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
print("ActivityType30.lua OnReqData 玩家 :"..Actor.getName(pActor).." 活动Id :"..atvId)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
|
||||
-- 如果VIP等级发生变化,则增加相应次数
|
||||
local nVipLevel = Actor.GetMaxColorCardLevel(pActor)
|
||||
if actorData.lastChangeExtraVipLevel ~= nVipLevel then
|
||||
local nTimes = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].vipBuyCount then
|
||||
nTimes = (ActivityConfig[atvId].vipBuyCount[nVipLevel] or 0) - actorData.extraIdentifyimes
|
||||
end
|
||||
|
||||
if nTimes then
|
||||
actorData.remainExtraIdentifyTimes = nTimes
|
||||
|
||||
actorData.lastChangeExtraVipLevel = nVipLevel
|
||||
else
|
||||
print("ActivityType30.lua OnReqData 玩家 :"..Actor.getName(pActor).." nTimes : "..nTimes)
|
||||
end
|
||||
end
|
||||
|
||||
DataPack.writeWord(outPack, (actorData.remainIdentifyTimes or 0))
|
||||
DataPack.writeByte(outPack, (actorData.remainExtraIdentifyTimes or 0))
|
||||
DataPack.writeByte(outPack, (actorData.extraIdentifyimes or 0))
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
print("ActivityType30.lua OnOperator 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cAppraisal then -- 请求鉴定
|
||||
reqAppraisal(atvId, pActor, inPack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
--print("ActivityType30.lua OnEnd 玩家 :"..Actor.getName(pActor).. " 活动Id :"..atvId)
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType30.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType30.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType30.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType30.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType30.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType30.lua")
|
||||
|
||||
|
||||
-- 跨天
|
||||
function OnNewDayArrive(pActor, ndiffday)
|
||||
print("ActivityType30.lua OnNewDayArrive 玩家 :"..Actor.getName(pActor).. " 跨 "..ndiffday.." 天")
|
||||
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor, ActivityType)
|
||||
if runAtvIdList then
|
||||
-- 增加鉴定的起始开服天数
|
||||
for i, atvId in ipairs(runAtvIdList) do
|
||||
|
||||
-- 开服第一天开始;累加鉴定次数:
|
||||
if 1 > System.getDaysSinceOpenServer() then
|
||||
return
|
||||
end
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if nil == actorData.lastChangeExtraVipLevel then
|
||||
actorData.lastChangeExtraVipLevel = 0
|
||||
end
|
||||
if nil == actorData.remainIdentifyTimes then
|
||||
actorData.remainIdentifyTimes = 0
|
||||
end
|
||||
if nil == actorData.remainExtraIdentifyTimes then
|
||||
actorData.remainExtraIdentifyTimes = 0
|
||||
end
|
||||
if nil == actorData.extraIdentifyimes then
|
||||
actorData.extraIdentifyimes = 0
|
||||
end
|
||||
|
||||
if ActivityConfig and ActivityConfig[atvId] then
|
||||
local config = ActivityConfig[atvId]
|
||||
local nOpenTime = System.getOpenServerRelToday()
|
||||
local nDiffTime = math.max(nOpenTime, (config.SetTime or 0));
|
||||
|
||||
local bNewActor = false
|
||||
local nTime = Actor.getStaticCount(pActor, config.counterid)
|
||||
if nTime == 0 then
|
||||
bNewActor = true
|
||||
end
|
||||
|
||||
local nOffDay = 0
|
||||
if nTime ~= nDiffTime then
|
||||
if bNewActor then
|
||||
nTime = System.getToday();
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + 1
|
||||
else
|
||||
nOffDay = math.ceil( (math.abs(nTime - nDiffTime)) / (24*3600) ) + ndiffday
|
||||
end
|
||||
Actor.setStaticCount(pActor, config.counterid, nDiffTime)
|
||||
end
|
||||
|
||||
if nOffDay ~= 0 then
|
||||
ndiffday = nOffDay
|
||||
end
|
||||
else
|
||||
print("ActivityType30.lua OnNewDayArrive not ActivityConfig or not ActivityConfig[atvId] atvId : "..atvId)
|
||||
end
|
||||
|
||||
actorData.remainIdentifyTimes = actorData.remainIdentifyTimes + ndiffday
|
||||
|
||||
-- 重置额外鉴定次数
|
||||
local nVipLevel = Actor.GetMaxColorCardLevel(pActor)
|
||||
local nExtraIdentify = 0
|
||||
if ActivityConfig and ActivityConfig[atvId] and ActivityConfig[atvId].vipBuyCount then
|
||||
nExtraIdentify = (ActivityConfig[atvId].vipBuyCount[nVipLevel] or 0)
|
||||
end
|
||||
actorData.remainExtraIdentifyTimes = nExtraIdentify
|
||||
actorData.lastChangeExtraVipLevel = nVipLevel
|
||||
actorData.extraIdentifyimes = 0
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType30.lua")
|
||||
@@ -0,0 +1,290 @@
|
||||
module("ActivityType4", package.seeall)
|
||||
|
||||
--[[
|
||||
个人活动,膜拜活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 剩余膜拜次数
|
||||
dailytime 每日次数
|
||||
openDay 统计开服时间
|
||||
}
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 4
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity4Config
|
||||
local WorshipCommonConfig= WorshipCommonConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
if WorshipCommonConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--膜拜操作
|
||||
function operaWorship(pActor, atvId, Conf, inPack)
|
||||
-- local nId = DataPack.readUInt(inPack)
|
||||
local nIndex = DataPack.readByte(inPack)
|
||||
local errorcode = 0
|
||||
local WorshipCfg = WorshipCommonConfig[atvId]
|
||||
if WorshipCfg == nil then
|
||||
return
|
||||
end
|
||||
while(true)
|
||||
do
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
|
||||
--次数检查
|
||||
|
||||
if data.count == nil then
|
||||
data.count = Conf.count
|
||||
else
|
||||
if data.count <= 0 then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoTimes, tstUI)
|
||||
errorcode = 2
|
||||
break
|
||||
end
|
||||
end
|
||||
if data.dailytime == nil then
|
||||
data.dailytime = 0
|
||||
end
|
||||
|
||||
consumes = WorshipCfg.cost1
|
||||
if WorshipCfg.n then
|
||||
if data.dailytime >= WorshipCfg.n then
|
||||
consumes = WorshipCfg.cost2
|
||||
end
|
||||
end
|
||||
-- if WorshipCfg.rankid then
|
||||
|
||||
-- local ranking = Ranking.getRanking(WorshipCfg.rankid )
|
||||
-- if ranking then
|
||||
-- local result = Ranking.CheckActorIdInRank(ranking, nId)
|
||||
-- if result == false then
|
||||
-- errorcode = 3
|
||||
-- Actor.sendTipmsgWithId(pActor, tmPleaseReferRank, tstUI)
|
||||
-- break
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
if consumes then
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoMoreBindCoin, tstUI)
|
||||
errorcode = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,11,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity4, "膜拜活动|"..atvId) ~= true then
|
||||
errorcode = 3
|
||||
break
|
||||
end
|
||||
if WorshipCfg.rewards then
|
||||
--CommonFunc.GiveCommonAward(pActor, WorshipCfg.rewards, GameLog.Log_Activity4, "膜拜活动|"..atvId)
|
||||
|
||||
if CommonFunc.Awards.Give(pActor, WorshipCfg.rewards, GameLog.Log_Activity4, "膜拜活动|"..atvId, 11 ) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
-- 操作成功
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
-- print("count:",data.count)
|
||||
data.count = data.count - 1
|
||||
-- print("count111111:",data.count)
|
||||
data.dailytime = data.dailytime + 1
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
break
|
||||
end
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sWorship)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
-- DataPack.writeUInt(outPack, nId)
|
||||
DataPack.writeByte(outPack, nIndex)
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId, pActor)
|
||||
--初始化活动个人数据
|
||||
ActivityDispatcher.ClearActorData(pActor, atvId)
|
||||
print("[PActivity 4] "..Actor.getName(pActor).." 活动开始了,id:"..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
data.count = openday * (ActivityConfig[atvId].count or 1)
|
||||
if data.openDay == nil then
|
||||
data.openDay = openday
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- function SendPushToPack(Cfg, pack)
|
||||
-- local itemNum = 0;
|
||||
-- if itemNum ~= -1 and (Cfg ~= nil and Cfg.rankid ~= nil) then
|
||||
-- local ranking = Ranking.getRanking( Cfg.rankid )
|
||||
-- if (ranking == nil) then
|
||||
-- itemNum = 0
|
||||
-- end
|
||||
|
||||
-- local itemNum = Ranking.getRankItemCount(ranking)
|
||||
-- if (itemNum == nil) then
|
||||
-- itemNum = 0
|
||||
-- end
|
||||
|
||||
-- DataPack.writeByte(pack, itemNum)
|
||||
-- for idx=1,itemNum do
|
||||
-- local rankItem = Ranking.getItemFromIndex(ranking, idx-1)
|
||||
-- if rankItem then
|
||||
-- local playerId = Ranking.getId(rankItem)
|
||||
-- local name = Ranking.getSub(rankItem, 0)
|
||||
-- local sexJob = Ranking.getSub(rankItem, 1)
|
||||
-- DataPack.writeUInt(pack, playerId)
|
||||
-- DataPack.writeString(pack, name)
|
||||
-- DataPack.writeString(pack, sexJob)
|
||||
-- end
|
||||
-- end
|
||||
-- else
|
||||
-- DataPack.writeByte(pack, 0)
|
||||
-- end
|
||||
-- end
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId, pActor)
|
||||
print("[Activity 4] "..Actor.getName(pActor).." 活动结束了,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime, pActor)
|
||||
--print("[Activity 1] "..Actor.getName(pActor).." 活动进行中,id:"..atvId.." now:"..curTime)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
-- print("OnReqData:",data.count)
|
||||
DataPack.writeInt(outPack, (data.count or 0))
|
||||
-- local WorshipCfg = WorshipCommonConfig[atvId]
|
||||
-- -- 发送排行数据
|
||||
-- SendPushToPack(WorshipCfg, outPack)
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
print("[Activity 4] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cWorship then -- 请求膜拜
|
||||
operaWorship(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local ret = 0
|
||||
if data.count and (data.count > 0) then ret = 1 end
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
if Actor.checkActorLevel(pActor,(cfg.openParam.level or 0)) ~=true then ret = 0 end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType4.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType4.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType4.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType4.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType4.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType4.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 进入副本
|
||||
function OnEnterFuben(pActor, fbId)
|
||||
|
||||
end
|
||||
|
||||
-- 退出副本
|
||||
function OnExitFuben(pActor, fbId)
|
||||
|
||||
end
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor)
|
||||
local openday = System.getDaysSinceOpenServer()
|
||||
|
||||
local runAtvIdList = Actor.getRunningActivityId(pActor,ActivityType)
|
||||
if runAtvIdList == nil then
|
||||
return
|
||||
end
|
||||
for i,atvId in ipairs(runAtvIdList) do
|
||||
print("[Activity 4] "..Actor.getName(pActor).." 跨天清空活动次数,atvId="..atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if data.count == nil then
|
||||
data.count = 0
|
||||
end
|
||||
if data.openDay == nil then
|
||||
data.openDay = 0
|
||||
end
|
||||
-- 按照离线时间
|
||||
local offday = 1;
|
||||
offday = openday- data.openDay;
|
||||
if offday < 0 then
|
||||
offday = 1;
|
||||
end
|
||||
data.count = data.count + offday * (ActivityConfig[atvId].count or 1)
|
||||
-- print("OnNewDayArrive:",data.count)
|
||||
data.dailytime = 0
|
||||
|
||||
data.openDay = openday
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeOnEnterFuben, OnEnterFuben, "ActivityType4.lua")
|
||||
ActorEventDispatcher.Reg(aeOnExitFuben, OnExitFuben, "ActivityType4.lua")
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType4.lua")
|
||||
@@ -0,0 +1,490 @@
|
||||
module("ActivityType5", package.seeall)
|
||||
|
||||
--[[
|
||||
NPC,夺宝类活动
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 剩余领取个人宝箱次数
|
||||
uint_times, 分配宝箱次数时候的时间
|
||||
|
||||
}
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
AtvArea[sceneid] //sceneid 场景id
|
||||
{
|
||||
state //状态
|
||||
}
|
||||
needDealarea
|
||||
{
|
||||
area
|
||||
{
|
||||
sceneid, //场景id
|
||||
x, x坐标
|
||||
y, y坐标
|
||||
}
|
||||
}
|
||||
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
nextAutoTime, 下一次自动加经验的时间戳
|
||||
|
||||
bigTreasureFlag, 本次活动大宝箱是否已经掉落
|
||||
canPicktime, //可捡取的时间
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 5
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity5Config
|
||||
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--领取个人宝箱操作
|
||||
function getPersonBox(pActor, atvId, Conf, inPack)
|
||||
local errorcode = 0
|
||||
|
||||
|
||||
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
|
||||
while(true)
|
||||
do
|
||||
if data.uint_times ==nil then
|
||||
data.uint_times = 0
|
||||
end
|
||||
if data.count ==nil then
|
||||
data.count = 1
|
||||
end
|
||||
|
||||
|
||||
--次数检查
|
||||
if System.getActivityEndMiniSecond(atvId)==0 then
|
||||
--Actor.sendTipmsg(pActor, "获取互动时间错误", tstUI)
|
||||
break
|
||||
end
|
||||
|
||||
if data.count == 0 and data.uint_times ~=System.getActivityEndMiniSecond(atvId) then
|
||||
data.count = 1
|
||||
else
|
||||
if data.count <=0 then
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmGetDuoBaoGiftYet, tstUI)
|
||||
errorcode = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
--检查背包
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,1,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
if Conf.Persongift then
|
||||
--CommonFunc.GiveCommonAward(pActor, Conf.Persongift, GameLog.Log_Activity5, "夺宝类活动|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, Conf.Persongift, GameLog.Log_Activity5, "夺宝类活动|"..atvId)
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmGetDuoBaoGiftSucc, tstUI)
|
||||
end
|
||||
data.uint_times =System.getActivityEndMiniSecond(atvId)
|
||||
-- 操作成功
|
||||
data.count = 0
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,7);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,7);
|
||||
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendPersonBox)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
end
|
||||
|
||||
--送宝掉大宝箱
|
||||
function getBigTreasure(pActor, atvId, Conf, inPack)
|
||||
local errorcode = 1
|
||||
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
|
||||
while(true)
|
||||
do
|
||||
|
||||
--时间限制检查
|
||||
if( System.isReachSecondBeforeActivityEnd(atvId,300) ~=true) then
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmActivityUnReachsongbaoTime, tstUI)
|
||||
break
|
||||
end
|
||||
|
||||
--次数检查
|
||||
if cacheData.bigTreasureFlag == nil then
|
||||
cacheData.bigTreasureFlag = 1
|
||||
else
|
||||
if cacheData.bigTreasureFlag == 0 then
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmSongBaoYet, tstUI)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
--掉落组掉落
|
||||
if Conf.bigTreasure then
|
||||
if Item.drop_item_in_random_area_byGroupID(Conf.sceneId, Conf.npcPosx, Conf.npcPosy, Conf.bigTreasure,Conf.picktime,Conf.tipsid) ~=true then
|
||||
break
|
||||
end
|
||||
|
||||
Actor.sendTipmsgWithId(pActor, tmSongBaoSuccess, tstUI)
|
||||
errorcode = 0
|
||||
end
|
||||
|
||||
-- 操作成功
|
||||
cacheData.bigTreasureFlag = 0
|
||||
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendBigTreasure)
|
||||
|
||||
if outPack then
|
||||
-- DataPack.writeUInt(outPack, nId)
|
||||
-- DataPack.writeByte(outPack, nIndex)
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--送宝掉大宝箱
|
||||
function AutoBigTreasure(atvId)
|
||||
|
||||
--时间限制检查
|
||||
if( System.isReachSecondBeforeActivityEnd(atvId,300) ~=true) then
|
||||
return
|
||||
end
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
return
|
||||
end
|
||||
-- print("cacheData.bigTreasureFlag.."..(cacheData.bigTreasureFlag or 0))
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData == nil then
|
||||
cacheData = {}
|
||||
end
|
||||
if cacheData.bigTreasureFlag and cacheData.bigTreasureFlag == 0 then
|
||||
return
|
||||
end
|
||||
--次数检查
|
||||
if cacheData.bigTreasureFlag == nil then
|
||||
cacheData.bigTreasureFlag = 1
|
||||
end
|
||||
--掉落组掉落
|
||||
if Conf.bigTreasure then
|
||||
Item.drop_item_in_random_area_byGroupID(Conf.sceneId, Conf.npcPosx, Conf.npcPosy, Conf.bigTreasure,Conf.picktime,Conf.tipsid)
|
||||
end
|
||||
-- 操作成功
|
||||
cacheData.bigTreasureFlag = 0
|
||||
cacheData.canPicktime = System.getCurrMiniTime() + Conf.picktime;
|
||||
local fbHandle = Fuben.getStaticFubenHandle();
|
||||
BroadCanPickTime(atvId,fbHandle,Conf.sceneId);
|
||||
end
|
||||
|
||||
-- 处理活动开始
|
||||
function DealAtvAreaAttr(atvId, curTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
if Cfg then
|
||||
if curTime > startTime then
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
if cacheData.AtvArea == nil then
|
||||
cacheData.AtvArea = {}
|
||||
end
|
||||
-- 已经设置OK
|
||||
for _, area in Ipairs(cacheData.needDealarea) do
|
||||
if Cfg.areaattr and Cfg.areaattr.attri then
|
||||
for _, attr in pairs(Cfg.areaattr.attri) do
|
||||
local index = Fuben.GetAreaListIndex(area.sceneid, area.x, area.y)
|
||||
local hScene = Fuben.getSceneHandleById(area.sceneid, 0)
|
||||
if index > 0 then
|
||||
Fuben.setSceneAreaAttri(hScene, index, attr.type, attr.value, NULL, (Cfg.areaattr.notips or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
cacheData.AtvArea[area.sceneid] = area.sceneid
|
||||
end
|
||||
cacheData.needDealarea = nil;
|
||||
--设置战斗区域
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--发送玩家当前剩余时间信息
|
||||
function SendLeftTimeInfo(pActor, atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.canPicktime then
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sDuoBaoPickLeftTime)
|
||||
if npack then
|
||||
DataPack.writeInt(npack, cacheData.canPicktime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadCanPickTime(atvId,fbHandle,sceneId)
|
||||
-- 广播所有玩家排行榜数据
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.canPicktime then
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sDuoBaoPickLeftTime)
|
||||
if npack then
|
||||
DataPack.writeInt(npack, cacheData.canPicktime)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--p泡点经验
|
||||
function dealPaodianExp(atvId, curTime)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
if Cfg then
|
||||
|
||||
if cacheData.paodianTime == nil then
|
||||
cacheData.paodianTime = 0
|
||||
end
|
||||
-- print("dealGuildSbk111111.."..curTime.." time .."..cacheData.paodianTime)
|
||||
if curTime >= cacheData.paodianTime then
|
||||
cacheData.paodianTime = curTime + 5
|
||||
if Cfg.idx then
|
||||
addPaodianExp(cacheData.actors, Cfg.idx,atvId);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
--print("[GActivity 5] 夺宝 活动开始了,id:"..atvId)
|
||||
|
||||
--data.count = 1
|
||||
System.broadcastTipmsg("夺宝地图已经开放,勇士们抓紧时间进入!",tstChatSystem);
|
||||
System.broadcastTipmsg("夺宝地图已经开放,勇士们抓紧时间进入!",tstRevolving);
|
||||
|
||||
--初始化全局缓存数据
|
||||
--ActivityDispatcher.ClearCacheData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
cacheData.bigTreasureFlag = 1
|
||||
cacheData.actors = {}
|
||||
cacheData.nextAutoTime = 0
|
||||
|
||||
--所有玩家推送活动数据
|
||||
System.sendAllActorOneActivityData(atvId) ;
|
||||
ActivityDispatcher.BroadPopup(atvId);
|
||||
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
|
||||
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg then
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
if cacheData.AtvArea then
|
||||
for _, sceneid in Ipairs(cacheData.AtvArea) do
|
||||
--print("vvvv.."..sceneid)
|
||||
Fuben.ResetFubenSceneConfig(sceneid);
|
||||
end
|
||||
end
|
||||
end
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
--print("[GActivity 5] 夺宝 活动结束了,id:"..atvId)
|
||||
|
||||
end
|
||||
|
||||
-- 进入活动区域
|
||||
-- 执行泡点经验等逻辑
|
||||
function OnEnterArea(atvId,pActor)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
local sceneId = Actor.getSceneId(pActor);
|
||||
if cacheData.areaAttr == nil then
|
||||
cacheData.areaAttr = {}
|
||||
end
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
SendLeftTimeInfo(pActor,atvId);
|
||||
|
||||
local x,y = Actor.getEntityPosition(pActor,0,0)
|
||||
-- 已经初始化完成
|
||||
if cacheData.areaAttr[sceneId] then
|
||||
return;
|
||||
end
|
||||
|
||||
cacheData.areaAttr[sceneId] = 1;
|
||||
local area = {};
|
||||
area.sceneid = sceneId;
|
||||
area.x = x
|
||||
area.y = y
|
||||
|
||||
if cacheData.needDealarea == nil then
|
||||
cacheData.needDealarea = {}
|
||||
end
|
||||
cacheData.needDealarea[sceneId] = area
|
||||
-- table.insert(cacheData.needDealarea, area);
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 离开活动区域
|
||||
function OnExitArea(atvId, pActor)
|
||||
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
cacheData.actors[actorId] = 0
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
|
||||
DealAtvAreaAttr(atvId, curTime);
|
||||
|
||||
dealPaodianExp(atvId,curTime)
|
||||
AutoBigTreasure(atvId);
|
||||
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if data.count ==nil then
|
||||
data.count = 1
|
||||
end
|
||||
--print("OnReqData:",data.count)
|
||||
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
--print("[Activity 4] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
--print("operaCode = "..operaCode)
|
||||
|
||||
if operaCode == ActivityOperate.cGetPersonBox then -- 领取个人宝箱
|
||||
getPersonBox(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
if operaCode == ActivityOperate.cGetTreasure then -- 送宝
|
||||
getBigTreasure(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 5] 夺宝 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.count = nil
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
|
||||
local ret = 1
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.count and (data.count == 0 ) then
|
||||
ret = 0
|
||||
end
|
||||
return ret
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterArea, ActivityType, OnEnterArea, "ActivityType5.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitArea, ActivityType, OnExitArea, "ActivityType5.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
-- 跨天,次数清零
|
||||
function OnNewDayArrive(pActor,atvId)
|
||||
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "ActivityType5.lua")
|
||||
@@ -0,0 +1,164 @@
|
||||
module("ActivityType6", package.seeall)
|
||||
math.randomseed(System.getCurrMiniTime())
|
||||
--[[
|
||||
全局活动,散财鹿
|
||||
|
||||
|
||||
|
||||
全局缓存:Cache[fbId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
refertime 刷新时间
|
||||
referid 刷新id
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
local ActivityType = 6
|
||||
--对应的活动配置
|
||||
local ActivityConfig = Activity6Config
|
||||
-- local LooseMoneyConfig= LooseMoneyConfig
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
-- if LooseMoneyConfig == nil then
|
||||
-- assert(false)
|
||||
-- end
|
||||
--------------------------------------------------------------------
|
||||
-- 活动刷新 逻辑
|
||||
--------------------------------------------------------------------
|
||||
function OnRefer(atvId, curTime)
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local data = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if data.refertime == nil then
|
||||
data.refertime = 0
|
||||
end
|
||||
|
||||
if data.referid == nil then
|
||||
data.referid = 0
|
||||
end
|
||||
-- 获取刷新坐标
|
||||
local nReferPos = nil
|
||||
if curTime >= data.refertime then
|
||||
nReferPos = GetReferPos(cfg, data.referid )
|
||||
end
|
||||
if nReferPos == nil then
|
||||
return
|
||||
end
|
||||
local sceneHandle = Fuben.getSceneHandleById(nReferPos.map, 0);
|
||||
if sceneHandle == nil then
|
||||
return
|
||||
end
|
||||
local tReferPosInfo = Fuben.getreateMonsterPosXY(sceneHandle, nReferPos.x, nReferPos.y, nReferPos.range)
|
||||
if tReferPosInfo == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
-- print("tReferPosInfo x: "..tReferPosInfo.x.. " y: "..tReferPosInfo.y)
|
||||
|
||||
local pMonster
|
||||
local refreshSuccess = false
|
||||
|
||||
if 1 < (cfg.refreshNum or 0) then
|
||||
for i = 1, cfg.refreshNum do
|
||||
local rangeX = math.random(1, nReferPos.range)
|
||||
local rangeY = math.random(1, nReferPos.range)
|
||||
pMonster = Fuben.createMonster(sceneHandle, cfg.monsterid, tReferPosInfo.x + rangeX, tReferPosInfo.y + rangeY)
|
||||
if pMonster then refreshSuccess = true end
|
||||
end
|
||||
else
|
||||
pMonster = Fuben.createMonster(sceneHandle, cfg.monsterid, tReferPosInfo.x, tReferPosInfo.y)
|
||||
if pMonster then refreshSuccess = true end
|
||||
end
|
||||
|
||||
if refreshSuccess then
|
||||
if cfg.notice then
|
||||
local str = string.format(cfg.content,tReferPosInfo.x,tReferPosInfo.y,nReferPos.map, tReferPosInfo.name, tReferPosInfo.x, tReferPosInfo.y)
|
||||
-- local str = string.format(cfg.content, tReferPosInfo.name, tReferPosInfo.x, tReferPosInfo.y)
|
||||
System.broadcastTipmsgLimitLev(str, tstBigRevolving)
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
-- System.SendChatMsg(str, 4)
|
||||
end
|
||||
end
|
||||
data.refertime = curTime + cfg.refertime
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
|
||||
function GetReferPos(Conf, nlastReferId)
|
||||
if Conf == nil then
|
||||
return nil
|
||||
end
|
||||
local data = {}
|
||||
if Conf.pos then
|
||||
for _, cfg in ipairs(Conf.pos) do
|
||||
if Conf.same and nlastReferId ~= cfg.id then
|
||||
table.insert(data,cfg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local len = #data
|
||||
-- print("len.."..len)
|
||||
if len > 0 then
|
||||
-- print(math.random(len))
|
||||
return data[math.random(len)]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
--初始化全局活动
|
||||
print("[PActivity 6] 活动开始了,id:"..atvId)
|
||||
local data = ActivityDispatcher.GetGlobalData(atvId)
|
||||
data.refertime = 0
|
||||
data.referid = 0
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[Activity 6] 活动结束了,id:"..atvId)
|
||||
ActivityDispatcher.ClearGlobalData(atvId);
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
OnRefer(atvId,curTime)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId)
|
||||
-- print("[Activity 6] 请求活动数据,id:"..atvId)
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId)
|
||||
|
||||
end
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 1
|
||||
return ret
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType6.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType6.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType6.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType6.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType6.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType6.lua")
|
||||
@@ -0,0 +1,321 @@
|
||||
module("ActivityType7", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动, 藏经峡谷,定时开放的打宝地图
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 7
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity7Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
|
||||
--活动状态
|
||||
local broadcastflags = {}
|
||||
--broadcastflags[atvId]: 0 活动开始前的广播阶段
|
||||
--broadcastflags[atvId]: 1 活动开始
|
||||
--broadcastflags[atvId]: 666 剩余十分钟
|
||||
|
||||
--在场景中的玩家
|
||||
actorsInFuben = {}
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local fbHandle = Actor.getFubenHandle(pActor)
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
--local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if ActivityConfig[atvId].openParam.level then
|
||||
|
||||
local actor_level = ActivityConfig[atvId].openParam.level
|
||||
if Actor.checkActorLevel(pActor,actor_level) ~=true then
|
||||
-- Actor.sendTipmsg(pActor, "等级不足!", tstEcomeny)
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if ActivityConfig[atvId].enterExpends then
|
||||
consumes = ActivityConfig[atvId].enterExpends
|
||||
if CommonFunc.Consumes.CheckActorSources(pActor, consumes, tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--进入副本
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity7, "藏经峡谷|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 踢出副本
|
||||
function KickoutAllActors(atvId)
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
end
|
||||
end
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- 设置复活,正常回城复活
|
||||
function SetAutoRelive(atvId,pActor)
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
actorsInFuben[atvId][actorid] = nil
|
||||
Actor.relive(pActor)
|
||||
Actor.clearReliveTimeOut(pActor)
|
||||
--Actor.setReliveTimeOut(pActor, 10)
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
--print("[GActivity 7] 藏经峡谷 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
--print("[GActivity 7] 藏经峡谷 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
|
||||
|
||||
System.broadcastTipmsg("藏经峡谷将于5分钟后开放,请勇士们做好准备!",tstRevolving);
|
||||
|
||||
broadcastflags[atvId] = 0
|
||||
|
||||
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
cacheData.actors = {}
|
||||
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
--print("[Activity 7] 藏经峡谷 活动结束了,id:"..atvId)
|
||||
broadcastflags[atvId] = 0
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
-- 踢出副本
|
||||
KickoutAllActors( atvId )
|
||||
-- 关闭副本
|
||||
Fuben.closeFuben( cacheData.fbHandle )
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
--local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--活动开始的提示
|
||||
if (System.isReachSecondBeforeActivityEnd(atvId,1800) ==true and broadcastflags[atvId] == 0 )then
|
||||
|
||||
System.broadcastTipmsg("藏经峡谷已经开放,勇士们抓紧时间进入",tstChatSystem)
|
||||
System.broadcastTipmsg("藏经峡谷已经开放,勇士们抓紧时间进入",tstRevolving)
|
||||
broadcastflags[atvId] = 1
|
||||
|
||||
System.sendAllActorOneActivityData(atvId) ;
|
||||
|
||||
-- if actorsInFuben[atvId] then
|
||||
-- for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
-- local pActor = Actor.getActorById(actorid)
|
||||
-- if pActor ~= nil then
|
||||
-- -- 发送一个活动数据
|
||||
-- Actor.sendActivityData(pActor, atvId)
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
--剩余十分钟的提示
|
||||
if( System.isReachSecondBeforeActivityEnd(atvId,600) ==true and broadcastflags[atvId] == 1) then
|
||||
System.broadcastTipmsg("藏经峡谷将于10分钟后关闭,勇士们抓紧时间进入",tstRevolving);
|
||||
broadcastflags[atvId] = 666
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
--活动前通告阶段不进入
|
||||
if broadcastflags[atvId] ==0 then
|
||||
Actor.sendTipmsg(pActor, "该活动暂未开启", tstUI)
|
||||
return
|
||||
end
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
-- 玩家退出,从记录中排除
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
|
||||
if pEntity and Actor.getEntityType(pEntity) == enActor then
|
||||
-- 设置复活
|
||||
--SetAutoRelive(atvId, pEntity)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local ret = 0
|
||||
if broadcastflags[atvId] ~=0 then ret = 1 end
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
if Actor.checkActorLevel(pActor,(cfg.openParam.level or 0)) ~=true then ret = 0 end
|
||||
end
|
||||
return ret
|
||||
|
||||
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType7.lua")
|
||||
|
||||
|
||||
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType7.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType7.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
@@ -0,0 +1,843 @@
|
||||
module("ActivityType8", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动,世界boss
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
buffValue, 鼓舞属性
|
||||
nextLoginTime, 退出后下次可进来的时间戳
|
||||
inspire {
|
||||
[1] = {times, addvalue }
|
||||
} 鼓舞次数
|
||||
isFirst 第一次
|
||||
}
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
notice{} 公告
|
||||
referFlag, 刷新标志位
|
||||
status
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
bossLv, boss等级
|
||||
bossDeath, 是否死亡
|
||||
killerName, 击杀者昵称
|
||||
killerId, 击杀者id
|
||||
atvStartTime, 当前活动开始时间
|
||||
isAward --是否发奖
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 8
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity8Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
--排行榜id
|
||||
RANKING_ID = RANK_DEFINE_ACTIVITY4
|
||||
|
||||
-- 活动状态
|
||||
local AtvStatus =
|
||||
{
|
||||
PreEnter = 1, --活动前5分钟(走马灯全服公告,不给进入)
|
||||
Start = 2, --开始
|
||||
End = 3, --结束了(发奖励,等待活动时间结束)
|
||||
}
|
||||
--在场景中的玩家
|
||||
actorsInFuben = {}
|
||||
function ReLoadScript()
|
||||
local actvsList = System.getRunningActivityId(ActivityType)
|
||||
if actvsList then
|
||||
for i,atvId in ipairs(actvsList) do
|
||||
actorsInFuben[atvId] = {}
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData and cacheData.actors then
|
||||
for i,actorId in Ipairs(cacheData.actors) do
|
||||
local pActor = Actor.getActorById(actorId)
|
||||
if pActor then
|
||||
local fbHandle = Actor.getFubenHandle(pActor)
|
||||
if cacheData.fbHandle == fbHandle then
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ReLoadScript()
|
||||
|
||||
--活动前走马灯通告的时间戳
|
||||
preEnterNoticeTime = 0
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
-- print("[GActivity 8] "..Actor.getName(pActor).." 请求进入副本 id"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--退出后登入的时间限制
|
||||
if actorData.nextLoginTime and actorData.nextLoginTime > System.getCurrMiniTime() then
|
||||
Actor.sendTipmsg(pActor, "请30秒后再进入!", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if globalData.bossDeath then
|
||||
Actor.sendTipmsgWithId(pActor, tmBossDeath, tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- 这个阶段还不能进入
|
||||
if cacheData.status == AtvStatus.PreEnter then
|
||||
Actor.sendTipmsgWithId(pActor, tmNoInOpenTime, tstUI)
|
||||
-- Actor.sendTipmsg(pActor, "活动当前阶段不能进入!", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
--进入副本
|
||||
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 重置下次进入时间
|
||||
actorData.nextLoginTime = nil
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
-- print("atvId = "..atvId.." actorId="..actorsInFuben[atvId][actorId])
|
||||
|
||||
-- 广播一次排行榜
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
RankMgr.Save(RANKING_ID)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
SendRankData(atvId,pActor)
|
||||
-- 强制全体和平模式
|
||||
Actor.setPkMode(pActor,fpPeaceful)
|
||||
addInspireBuff(pActor, atvId);
|
||||
SendLeftTimeInfo(pActor, atvId);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--广播排行榜数据
|
||||
function BroadRankData(atvId,fbHandle,sceneId)
|
||||
-- 广播所有玩家排行榜数据
|
||||
local npack = ActivityDispatcher.AllocOperReturnEx(atvId, ActivityOperate.sSendRankData)
|
||||
if npack then
|
||||
RankMgr.PushToPack(RANKING_ID, 100, npack)
|
||||
DataPack.broadcastScene(npack,fbHandle,sceneId)
|
||||
ActivityDispatcher.FreePacketEx(npack)
|
||||
end
|
||||
end
|
||||
--玩家鼓舞
|
||||
function ActorInspire(pActor, atvId, type)
|
||||
-- print("[GActivity 8] "..Actor.getName(pActor).." 玩家鼓舞 id "..atvId.." type "..type)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
local errorcode = 0;
|
||||
local value = 0;
|
||||
local lefttimes = 0;
|
||||
while(true)
|
||||
do
|
||||
if actorsInFuben[atvId] then
|
||||
--初始化鼓舞数据
|
||||
if actorData.inspire == nil then
|
||||
actorData.inspire = {}
|
||||
end
|
||||
if actorData.inspire[type] == nil then
|
||||
actorData.inspire[type] = {};
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[atvId].inspire
|
||||
if Cfg == nil then
|
||||
errorcode = 1;
|
||||
break
|
||||
end
|
||||
|
||||
local inspireCfg = Cfg[type]
|
||||
if inspireCfg == nil or inspireCfg.type ~= type then
|
||||
errorcode = 1;
|
||||
break
|
||||
end
|
||||
if actorData.inspire[type].times == nil then
|
||||
actorData.inspire[type].times = 0;
|
||||
end
|
||||
|
||||
if actorData.inspire[type].times >= inspireCfg.times then
|
||||
errorcode = 2;
|
||||
break;
|
||||
end
|
||||
|
||||
if inspireCfg.costs and CommonFunc.Consumes.Check(pActor, inspireCfg.costs) ~= true then
|
||||
errorcode = 3;
|
||||
break;
|
||||
end
|
||||
|
||||
if inspireCfg.costs and CommonFunc.Consumes.Remove(pActor, inspireCfg.costs, GameLog.Log_Activity8, "世界boss|"..atvId) ~= true then
|
||||
errorcode = 4
|
||||
break
|
||||
end
|
||||
if actorData.buffValue == nil then
|
||||
actorData.buffValue = 0;
|
||||
end
|
||||
|
||||
-- actorData.buffValue = actorData.buffValue + inspireCfg.value;
|
||||
actorData.buffValue = actorData.buffValue + 1;
|
||||
if actorData.inspire[type].addvalue == nil then
|
||||
actorData.inspire[type].addvalue = 0;
|
||||
end
|
||||
actorData.inspire[type].addvalue = actorData.inspire[type].addvalue + inspireCfg.value;
|
||||
value = actorData.inspire[type].addvalue
|
||||
-- print("鼓舞.."..actorData.inspire[type].addvalue )
|
||||
addInspireBuff(pActor, atvId);
|
||||
Actor.sendTipmsgWithId(pActor, tmBossGwSuccess, tstUI)
|
||||
actorData.inspire[type].times = actorData.inspire[type].times + 1;
|
||||
lefttimes = inspireCfg.times - actorData.inspire[type].times ;
|
||||
break;
|
||||
else
|
||||
errorcode = 5;
|
||||
end
|
||||
break;
|
||||
end
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sInspire)
|
||||
if outPack then
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.writeByte(outPack, type)
|
||||
DataPack.writeInt(outPack, (value or 0))
|
||||
DataPack.writeInt(outPack, (lefttimes or 0))
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
--发送玩家排行数据
|
||||
function SendRankData(atvId,pActor)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMyRankData)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
DataPack.writeUInt(npack, RankMgr.GetValue(actorId,RANKING_ID))
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
--发送最后一击奖励
|
||||
function SendLastAttackaward(atvId)
|
||||
if ActivityConfig[atvId].lastattack then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
-- print("击杀世界BOSS..atcid.."..atvId.."...2222.."..(globalData.killerId or 0))
|
||||
if globalData.killerId == nil then
|
||||
return;
|
||||
end
|
||||
local title = "世界BOSS"
|
||||
local content = string.format("恭喜你击杀世界BOSS!")
|
||||
SendMail(globalData.killerId, title, content, ActivityConfig[atvId].lastattack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 发送排名奖励
|
||||
function SendRankAward(atvId)
|
||||
if ActivityConfig[atvId].rankAward then
|
||||
local rankAward = ActivityConfig[atvId].rankAward
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
local title = "世界BOSS"
|
||||
local itemNum = Ranking.getRankItemCount(ranking)
|
||||
local idx = 1
|
||||
for _,awardInfo in ipairs(rankAward) do
|
||||
local rankNum = awardInfo.value
|
||||
-- print("rankNum:"..rankNum.." itemNum:"..itemNum)
|
||||
if rankNum > itemNum then
|
||||
rankNum = itemNum
|
||||
end
|
||||
for i=idx,rankNum do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
local title = "世界BOSS"
|
||||
local content = string.format("恭喜你在世界BOSS中取得第%d名!", i)
|
||||
SendMail(actorId, title, content, awardInfo.awards)
|
||||
-- local pActor = Actor.getActorById(actorId)
|
||||
-- Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
-- Actor.triggerAchieveEvent(pOwner, nAchieveCompleteActivity,1 ,atvId);
|
||||
local name = RankMgr.GetValueById(actorId, RANKING_ID, 0)
|
||||
-- print("[GActivity 8] 世界BOSS(id:"..atvId..") "..(name or actorId).." 获得第"..i.."名!")
|
||||
end
|
||||
idx = rankNum + 1
|
||||
if idx > itemNum then
|
||||
-- print("[GActivity 8] 世界BOSS(id:"..atvId..") 奖励发完! 一共"..rankNum.."人获得上榜奖励!")
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 踢出副本
|
||||
function KickoutAllActors(atvId)
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
RemoveInspireBuff(pActor, atvId) --清除鼓舞buff
|
||||
end
|
||||
end
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function addInspireBuff(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil and Cfg.buffid == nil then
|
||||
return
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
local job = Actor.getIntProperty( pActor, PROP_ACTOR_VOCATION )
|
||||
for _, cfg in pairs(Cfg.buffid) do
|
||||
|
||||
if cfg.times == actorData.buffValue then
|
||||
|
||||
for _, id in pairs(cfg.buffid) do
|
||||
Actor.addBuffById(pActor, id);
|
||||
end
|
||||
|
||||
-- Actor.addBuffValueById(pActor, cfg.id, (actorData.buffValue or 0));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function RemoveInspireBuff(pActor, atvId)
|
||||
local Cfg = ActivityConfig[atvId]
|
||||
if Cfg == nil and Cfg.buffid == nil then
|
||||
return
|
||||
end
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData == nil then
|
||||
actorData = {}
|
||||
end
|
||||
|
||||
for _, cfg in pairs(Cfg.buffid) do
|
||||
if cfg.times == actorData.buffValue then
|
||||
|
||||
for _, id in pairs(cfg.buffid) do
|
||||
|
||||
Actor.delBuffById(pActor, id);
|
||||
end
|
||||
end
|
||||
-- Actor.delBuffById(actorid, cfg.id);
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
print("[GActivity 8] 世界boss 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
|
||||
FubenDispatcher.MapToActivity(pFuben,ActivityType, atvId);
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
print("[GActivity 8] 世界boss "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.buffValue = nil
|
||||
actorData.nextLoginTime = nil
|
||||
actorData.inspire = nil
|
||||
actorData.isFirst = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
print("[GActivity 8] 世界boss 活动开始了,id:"..atvId)
|
||||
CheckNewActivity(atvId);
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
cacheData.actors = {}
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
local pFuben = Fuben.getFubenPtrByHandle(fbHandle)
|
||||
FubenDispatcher.MapToActivity(pFuben,ActivityType, atvId);
|
||||
--清空排行榜
|
||||
RankMgr.Clear(RANKING_ID)
|
||||
end
|
||||
|
||||
function ClearGlobalData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
-- print("一支穿云箭,千军万马来相见!!")
|
||||
globalData.bossDeath = nil
|
||||
globalData.killerId = nil
|
||||
globalData.killerName = nil
|
||||
globalData.isAward = nil;
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
print("[GActivity 8] 世界boss 活动结束了,id:"..atvId)
|
||||
SendWorldBossAward(atvId)
|
||||
-- 踢出副本
|
||||
KickoutAllActors( atvId )
|
||||
-- 未死亡
|
||||
noDeathResult(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
-- 关闭副本
|
||||
Fuben.closeFuben( cacheData.fbHandle )
|
||||
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
|
||||
end
|
||||
|
||||
function SendWorldBossAward(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData.isAward then
|
||||
return;
|
||||
end
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId);
|
||||
|
||||
if globalData.killerName ~= nil then
|
||||
System.broadcastTipmsgLimitLev("恭喜"..globalData.killerName.."击杀了世界BOSS,获得了大量奖励", tstRevolving)
|
||||
System.broadcastTipmsgLimitLev("恭喜"..globalData.killerName.."击杀了世界BOSS,获得了大量奖励", tstChatSystem)
|
||||
end
|
||||
local pFuben = ActivityDispatcher.GetFuben(atvId)
|
||||
if pFuben then
|
||||
FubenDispatcher.SetResult(pFuben,1)
|
||||
-- 延迟踢出副本
|
||||
local nowtime = System.getCurrMiniTime() + 15
|
||||
FubenDispatcher.KictoutAfter(pFuben, nowtime)
|
||||
end
|
||||
-- 发送奖励
|
||||
SendRankAward( atvId )
|
||||
--最后一击
|
||||
SendLastAttackaward(atvId);
|
||||
globalData.isAward = 1;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
--公告
|
||||
function SendNotice(avtId, curTime)
|
||||
local cfg = ActivityConfig[avtId]
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cfg == nil then
|
||||
return;
|
||||
end
|
||||
|
||||
if cfg.notice then
|
||||
for _, notice in pairs(cfg.notice) do
|
||||
|
||||
if cacheData.notice == nil then
|
||||
cacheData.notice = {}
|
||||
end
|
||||
if notice.id then
|
||||
local startTime = System.getRunningActivityStartTime(avtId)
|
||||
if (curTime > startTime + notice.time) and cacheData.notice[notice.id] == nil then
|
||||
if cacheData.status == nil then
|
||||
cacheData.status = AtvStatus.PreEnter
|
||||
end
|
||||
|
||||
System.broadcastTipmsgLimitLev(notice.content, tstBigRevolving)
|
||||
System.broadcastTipmsgLimitLev(notice.content, tstChatSystem)
|
||||
cacheData.notice[notice.id] = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- 刷新boss
|
||||
function CreateWorldBoss(avtId, curTime)
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(avtId);
|
||||
if globalData.bossDeath then
|
||||
return
|
||||
end
|
||||
|
||||
local Cfg = ActivityConfig[avtId]
|
||||
if Cfg == nil or Cfg.bossinfo == nil then
|
||||
return
|
||||
end
|
||||
local cacheData = ActivityDispatcher.GetCacheData(avtId);
|
||||
if cacheData.referFlag then
|
||||
return
|
||||
end
|
||||
|
||||
-- print("..avtId.."..avtId.."avtId.."..(globalData.bossDeath or 0))
|
||||
local startTime = System.getRunningActivityStartTime(avtId)
|
||||
if cacheData.scenHandle and (curTime >= startTime + Cfg.starttime) then
|
||||
|
||||
if globalData.bossLv == nil then
|
||||
globalData.bossLv =1;
|
||||
end
|
||||
TestMsg(globalData.bossLv)
|
||||
cacheData.status = AtvStatus.Start
|
||||
local bossGrowValue = 1.1 ^ (globalData.bossLv-1) *100
|
||||
Fuben.createOneMonsters(cacheData.scenHandle, Cfg.bossinfo.bossid, Cfg.bossinfo.x, Cfg.bossinfo.y, 1,0,0, NULL, 0, (bossGrowValue or 100));
|
||||
cacheData.referFlag = 1;
|
||||
System.sendAllActorOneActivityData(avtId);
|
||||
ActivityDispatcher.BroadPopup(avtId);
|
||||
end
|
||||
end
|
||||
|
||||
function CheckNewActivity(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId);
|
||||
local endTime = System.getActivityEndMiniSecond(atvId)
|
||||
if globalData.atvEndTime == nil or globalData.atvEndTime ~= endTime then
|
||||
-- print("改革春风吹满地!!")
|
||||
ClearGlobalData(atvId)
|
||||
ActivityDispatcher.ClearCacheData(atvId);
|
||||
globalData.atvEndTime = endTime
|
||||
end
|
||||
end
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
-- 检测活动结束
|
||||
-- CheckNewActivity(atvId);
|
||||
-- 公告
|
||||
SendNotice(atvId, curTime)
|
||||
-- 刷新boss
|
||||
CreateWorldBoss(atvId, curTime)
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg and Cfg.inspire then
|
||||
local len = #Cfg.inspire;
|
||||
DataPack.writeByte(outPack, (len or 0))
|
||||
for _, cfg in pairs(Cfg.inspire) do
|
||||
DataPack.writeByte(outPack, (cfg.type or 0))
|
||||
local data = GetActorInpires(atvId, cfg.type, pActor);
|
||||
local addvalue = 0;
|
||||
local times = cfg.times;
|
||||
if data then
|
||||
addvalue = data.addvalue;
|
||||
times = times - data.times
|
||||
if times < 0 then
|
||||
times = 0
|
||||
end
|
||||
end
|
||||
DataPack.writeInt(outPack, addvalue)
|
||||
DataPack.writeInt(outPack, (times or 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 获取活动数据
|
||||
function GetActorInpires(atvId, type, pActor)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId);
|
||||
if actorData.inspire == nil then
|
||||
actorData.inspire = {}
|
||||
local inspire = {}
|
||||
inspire.times = 0;
|
||||
inspire.addvalue = 0;
|
||||
actorData.inspire[type] = inspire;
|
||||
end
|
||||
return actorData.inspire[type]
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
if operaCode == ActivityOperate.cEnterFuben then -- 请求进入副本
|
||||
reqEnterFuben(pActor, atvId)
|
||||
elseif operaCode == ActivityOperate.cInspire then --鼓舞
|
||||
local type = DataPack.readByte(inPack);
|
||||
ActorInspire(pActor, atvId, type)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--发送玩家当前剩余时间信息
|
||||
function SendLeftTimeInfo(pActor, atvId)
|
||||
local npack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendWorldBossTime)
|
||||
if npack then
|
||||
local nEndTime = System.getActivityEndMiniSecond(atvId);
|
||||
local leftTime = nEndTime - System.getCurrMiniTime()
|
||||
DataPack.writeUInt(npack, leftTime)
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
|
||||
-- 玩家退出,从记录中排除
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData == nil then
|
||||
return
|
||||
end
|
||||
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
-- 玩家下次进入时间限制
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.nextLoginTime = System.getCurrMiniTime() + 30
|
||||
RemoveInspireBuff(pActor,atvId );
|
||||
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡 TODO 缺个助攻积分
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
|
||||
end
|
||||
|
||||
|
||||
function noDeathResult(atvId)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if globalData.bossDeath then
|
||||
return
|
||||
end
|
||||
|
||||
local time = 0;
|
||||
local bossLv = 0;
|
||||
|
||||
for _, cfg in pairs(ActivityConfig[atvId].growlist) do
|
||||
if cfg.time >= time then
|
||||
time = cfg.time
|
||||
bossLv = cfg.addlv
|
||||
end
|
||||
end
|
||||
if globalData.bossLv == nil then
|
||||
globalData.bossLv = 1;
|
||||
end
|
||||
|
||||
globalData.bossLv = globalData.bossLv + bossLv;
|
||||
if globalData.bossLv < 1 then
|
||||
globalData.bossLv = 1
|
||||
end
|
||||
TestMsg(globalData.bossLv)
|
||||
end
|
||||
end
|
||||
|
||||
function TestMsg(lv)
|
||||
local msg = "世界BOSS当前等级:%d"
|
||||
local str = string.format(msg, (lv or 0));
|
||||
-- System.SendChatMsg(str, 4)
|
||||
System.broadcastTipmsgLimitLev(str, tstChatSystem)
|
||||
end
|
||||
|
||||
function setBossGrowLv(atvId, killTime)
|
||||
local Cfg = ActivityConfig[atvId];
|
||||
if Cfg then
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local startTime = System.getRunningActivityStartTime(atvId)
|
||||
local costtime = killTime - (startTime + Cfg.starttime);
|
||||
if costtime < 0 then
|
||||
costtime = 0
|
||||
end
|
||||
|
||||
local time = 0;
|
||||
local bossLv = 0;
|
||||
for _, cfg in pairs(ActivityConfig[atvId].growlist) do
|
||||
if costtime < cfg.time then
|
||||
bossLv = cfg.addlv
|
||||
break
|
||||
end
|
||||
end
|
||||
-- print("bossLv.."..bossLv)
|
||||
globalData.bossLv = globalData.bossLv + bossLv;
|
||||
if globalData.bossLv < 1 then
|
||||
globalData.bossLv = 1
|
||||
end
|
||||
TestMsg(globalData.bossLv)
|
||||
-- print("globalData.bossLv .."..(globalData.bossLv or 0))
|
||||
end
|
||||
end
|
||||
|
||||
function OnEntityHurt(atvId, pEntity, damage, isKiller, killTime)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
if actorsInFuben[atvId] and globalData.bossDeath == nil then
|
||||
-- if globalData.bossDeath == nil then
|
||||
-- 攻击boss 获得积分
|
||||
local killerId = Actor.getIntProperty(pEntity, PROP_ENTITY_ID )
|
||||
local addSocre = damage * 0.2 + ActivityConfig[atvId].addScoreKill;
|
||||
|
||||
addSocre = math.floor(addSocre)
|
||||
|
||||
RankMgr.AddValue(killerId, RANKING_ID, addSocre)
|
||||
OnDealAchieve(atvId, pEntity);
|
||||
local fbHandle = cacheData.fbHandle
|
||||
local sceneId = Fuben.getSceneId(cacheData.scenHandle)
|
||||
BroadRankData(atvId, fbHandle, sceneId)
|
||||
SendRankData(atvId,pEntity)
|
||||
if isKiller ~= nil and isKiller == 1 and globalData.bossDeath == nil then
|
||||
-- local killerId = Actor.getIntProperty(pEntity, PROP_ENTITY_ID )
|
||||
local killName = Actor.getName(pEntity )
|
||||
globalData.killerId = killerId
|
||||
globalData.killerName = killName;
|
||||
globalData.bossDeath = killTime;
|
||||
-- print("bossdeath "..atvId.." ..atvId."..globalData.killerId)
|
||||
setBossGrowLv(atvId, killTime);
|
||||
-- SendWorldBossAward(atvId, 1);
|
||||
System.closeActivityRunning(atvId, true);
|
||||
System.sendAllActorOneActivityData(atvId);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动副本结束
|
||||
function OnFubenFinish(atvId, pFuben, result, pOwner)
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor then
|
||||
--满血结束血量
|
||||
-- local maxhp = Actor.getIntProperty(pActor,PROP_CREATURE_MAXHP)
|
||||
-- Actor.changeHp(pActor, maxhp)
|
||||
local npack = ActivityDispatcher.AllocResultPack(pActor, atvId, 1)
|
||||
if npack then
|
||||
local actorId = Actor.getActorId(pActor)
|
||||
WorldBossResult(atvId, npack, actorId)
|
||||
DataPack.writeWord(npack, RankMgr.GetMyRank(pActor,RANKING_ID))
|
||||
DataPack.flush(npack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function WorldBossResult(atvId, npack, actorId)
|
||||
local ranking = Ranking.getRanking( RANKING_ID )
|
||||
if ranking then
|
||||
for i = 1, 3 do
|
||||
local rankItem = Ranking.getItemFromIndex(ranking, i-1)
|
||||
local name = "";
|
||||
if(rankItem) then
|
||||
local actorId = Ranking.getId(rankItem)
|
||||
name = Ranking.getSub(rankItem, 0)
|
||||
end
|
||||
|
||||
DataPack.writeString(npack, name or "")
|
||||
end
|
||||
end
|
||||
|
||||
local globalData = ActivityDispatcher.GetGlobalData(atvId)
|
||||
DataPack.writeString(npack, globalData.killerName or "")
|
||||
local iskiller = 0;
|
||||
if actorId == globalData.killerId then
|
||||
iskiller = 1
|
||||
end
|
||||
DataPack.writeWord(npack, iskiller)
|
||||
end
|
||||
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local result = System.isActivityRunning(atvId)
|
||||
local ret = 0
|
||||
|
||||
-- if result then ret = 1 end
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
if cacheData.status and cacheData.status == AtvStatus.Start then ret = 1 end
|
||||
-- local cfg = ActivityConfig[atvId]
|
||||
-- if cfg and cfg.openParam then
|
||||
-- if Actor.checkActorLevel(pActor,(cfg.openParam.level or 0)) ~=true then ret = 0 end
|
||||
-- end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
----处理成就问题
|
||||
function OnDealAchieve(atvId, pActor)
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
local curVal = RankMgr.GetValue(actorid, RANKING_ID)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if actorData and actorData.isFirst == nil and curVal >= 1000 then
|
||||
Actor.triggerAchieveEvent(pActor,nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
actorData.isFirst = 1;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnFubenFinish, ActivityType, OnFubenFinish, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType8.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType8.lua")
|
||||
-- ActivityDispatcher.Reg(ActivityEvent.OnEntityHurt, ActivityType, OnEntityHurt, "ActivityType8.lua")
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
|
||||
-- 杀怪
|
||||
function OnHurtMonster(pActor,damage,isKiller,killTime)
|
||||
-- print("[PActivity 8] "..Actor.getName(pActor).." damage:"..damage.."isKiller: "..isKiller.." killTime: "..killTime)
|
||||
local pFuben = Actor.getFubenPrt(pActor);
|
||||
if pFuben and FubenDispatcher.IsActivityFuben(pFuben) then
|
||||
local atvType = FubenDispatcher.GetActivityType(pFuben);
|
||||
-- print("[PActivity 8] "..pFuben)
|
||||
if atvType == ActivityType then
|
||||
local atvId = FubenDispatcher.GetActivityId(pFuben);
|
||||
-- print("[PActivity 8] "..Actor.getName(pActor).." atvId:"..atvId)
|
||||
OnEntityHurt(atvId, pActor, damage, isKiller, killTime);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ActorEventDispatcher.Reg(aeHurtMonster, OnHurtMonster, "ActivityType8.lua")
|
||||
@@ -0,0 +1,619 @@
|
||||
module("ActivityType9", package.seeall)
|
||||
|
||||
--[[
|
||||
全局活动, 独闯天涯,定时开放的闯关地图,每层10个怪客户端也是写死的,修改需要客户端同步改
|
||||
|
||||
个人数据:ActorData[AtvId]
|
||||
{
|
||||
count, 剩余领取个人宝箱次数
|
||||
uint_times, 分配礼包次数时候的时间,用这个保证只领一次
|
||||
|
||||
bigTreasurecount ,剩余神秘大奖领取次数
|
||||
uint_times_big, 分配神秘大奖时候的时间,用这个保证只领一次
|
||||
|
||||
--floorNow ,当前闯到第几层了
|
||||
monsterCount ,当前层杀怪数
|
||||
|
||||
}
|
||||
|
||||
|
||||
全局缓存:Cache[AtvId]
|
||||
{
|
||||
fbHandle, 记录当前活动创建的副本,这个是多人副本,强制活动结束后才销毁
|
||||
scenHandle, 记录当前副本的场景
|
||||
actors = {actorid,...} 记录活动副本中的玩家id
|
||||
|
||||
bigTreasureNum , 排名奖励剩余礼包数量,策划上是50个
|
||||
}
|
||||
|
||||
全局数据:GlobalData[AtvId]
|
||||
{
|
||||
|
||||
}
|
||||
]]--
|
||||
|
||||
--活动类型
|
||||
ActivityType = 9
|
||||
--对应的活动配置
|
||||
ActivityConfig = Activity9Config
|
||||
if ActivityConfig == nil then
|
||||
assert(false)
|
||||
end
|
||||
|
||||
actorsInFuben = {}
|
||||
|
||||
local broadcastflags = {}
|
||||
--broadcastflags[atvId]: 0 活动开始前的10min
|
||||
--broadcastflags[atvId]: 1 活动开启前的1min
|
||||
--broadcastflags[atvId]: 2 活动开始
|
||||
--broadcastflags[atvId]: 666 剩余十分钟
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 详细逻辑
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--每次进入副本都从新开始
|
||||
function ClearQuestState(atvId,pActor)
|
||||
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
actorData.monsterCount = 0
|
||||
end
|
||||
|
||||
--请求进入副本
|
||||
function reqEnterFuben(pActor, atvId)
|
||||
--local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
if data.uint_times ==nil then
|
||||
data.uint_times = 0
|
||||
end
|
||||
if data.count ==nil then
|
||||
data.count = 1
|
||||
end
|
||||
|
||||
|
||||
--进入限制检查
|
||||
if System.getActivityEndMiniSecond(atvId)==0 then
|
||||
--Actor.sendTipmsg(pActor, "获取活动时间错误", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if data.count == 0 and data.uint_times ~=System.getActivityEndMiniSecond(atvId) then
|
||||
data.count = 1
|
||||
end
|
||||
|
||||
if data.count <=0 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:您已完成独闯天涯挑战 无法再次参加|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
if ActivityConfig[atvId].openParam.level then
|
||||
local actor_level = ActivityConfig[atvId].openParam.level
|
||||
if Actor.checkActorLevel(pActor,actor_level) ~=true then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:等级不足", tstEcomeny)
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--消耗检查
|
||||
local consumes = nil
|
||||
if ActivityConfig[atvId].enterExpends then
|
||||
consumes = ActivityConfig[atvId].enterExpends
|
||||
if CommonFunc.Consumes.Check(pActor, consumes) ~= true then
|
||||
-- Actor.sendTipmsg(pActor, "|C:0xf56f00&T:绑金不足", tstEcomeny)
|
||||
Actor.sendTipmsgWithId(pActor, tmNeedItemNotEnough, tstUI)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
ClearQuestState(atvId,pActor)
|
||||
|
||||
--进入副本
|
||||
local fbHandle = ActivityDispatcher.EnterFuben(atvId, pActor, ActivityConfig[atvId].fbId)
|
||||
if fbHandle then
|
||||
-- 消耗
|
||||
if consumes and CommonFunc.Consumes.Remove(pActor, consumes, GameLog.Log_Activity9, "独闯天涯|"..atvId) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,1)
|
||||
|
||||
-- 记录进入的玩家
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
cacheData.actors[actorId] = actorId
|
||||
|
||||
if actorsInFuben[atvId] == nil then
|
||||
actorsInFuben[atvId] = {}
|
||||
end
|
||||
actorsInFuben[atvId][actorId] = actorId
|
||||
--print("atvId = "..atvId.." actorId="..actorsInFuben[atvId][actorId])
|
||||
else --print("___________________________________________enterFuben error ")
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
--领取个人物品奖励
|
||||
function getGiftBox(pActor,atvId,Conf,inPack)
|
||||
local errorcode = 0
|
||||
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if Actor.getFubenId(pActor) ~= Conf.fbId then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:请在夺宝战七层领取奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
while(true)
|
||||
do
|
||||
if data.uint_times ==nil then
|
||||
data.uint_times = 0
|
||||
end
|
||||
if data.count ==nil then
|
||||
data.count = 1
|
||||
end
|
||||
|
||||
|
||||
--次数检查
|
||||
if System.getActivityEndMiniSecond(atvId)==0 then
|
||||
--Actor.sendTipmsg(pActor, "获取活动时间错误", tstUI)
|
||||
break
|
||||
end
|
||||
|
||||
if data.count == 0 and data.uint_times ~=System.getActivityEndMiniSecond(atvId) then
|
||||
data.count = 1
|
||||
else
|
||||
if data.count <=0 then
|
||||
Actor.sendTipmsgWithId(pActor, tmGetChuangGuanGiftYet, tstUI)
|
||||
errorcode = 1
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if Conf.Persongift then
|
||||
CommonFunc.GiveCommonAward(pActor, Conf.Persongift, GameLog.Log_Activity9, "独闯天涯个人奖励|"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmGetChuangGuanGiftSucc, tstUI)
|
||||
end
|
||||
data.uint_times =System.getActivityEndMiniSecond(atvId)
|
||||
-- 操作成功
|
||||
--print("count:",data.count)
|
||||
data.count = 0
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveActivity,1 ,atvId);
|
||||
Actor.triggerAchieveEvent(pActor, nAchieveCompleteActivity,1 ,atvId);
|
||||
--print("count now=:"..data.count)
|
||||
|
||||
-- 记录日志
|
||||
Actor.SendActivityLog(pActor,atvId,ActivityType,2)
|
||||
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendPersonBox)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
-- DataPack.writeUInt(outPack, nId)
|
||||
-- DataPack.writeByte(outPack, nIndex)
|
||||
DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--请求领取排名奖励, 限制50个
|
||||
function getBigTreasure(pActor, atvId, Conf, inPack)
|
||||
local errorcode = 1
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if Actor.getFubenId(pActor) ~= Conf.fbId then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:请在夺宝战七层领取奖励|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
while(true)
|
||||
do
|
||||
|
||||
if data.uint_times_big ==nil then
|
||||
data.uint_times_big = 0
|
||||
end
|
||||
if data.bigTreasurecount ==nil then
|
||||
data.bigTreasurecount = 1
|
||||
end
|
||||
|
||||
--一场活动只能领一个
|
||||
if System.getActivityEndMiniSecond(atvId)==0 then
|
||||
--Actor.sendTipmsg(pActor, "获取活动时间错误", tstUI)
|
||||
break
|
||||
end
|
||||
|
||||
if data.bigTreasurecount == 0 and data.uint_times_big ~=System.getActivityEndMiniSecond(atvId) then
|
||||
data.bigTreasurecount = 1
|
||||
else
|
||||
if data.bigTreasurecount <=0 then
|
||||
Actor.sendTipmsgWithId(pActor, tmGetSpeedAwardYet, tstUI)
|
||||
errorcode = 1
|
||||
break --已领取,break
|
||||
end
|
||||
end
|
||||
|
||||
--总的可领取次数检查
|
||||
if cacheData.bigTreasureNum == nil then
|
||||
cacheData.bigTreasureNum = Conf.bigTreasureNum
|
||||
else
|
||||
if cacheData.bigTreasureNum <= 0 then
|
||||
Actor.sendTipmsg(pActor, "神速礼包已发放完毕", tstUI)
|
||||
break --奖励发放完毕,break
|
||||
end
|
||||
end
|
||||
|
||||
--检测格子
|
||||
if CommonFunc.Awards.CheckBagIsEnough(pActor,1,tmDefNoBagNum,tstUI) ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
--领取神秘大奖,排名奖励
|
||||
if Conf.bigTreasure and data.bigTreasurecount == 1 then
|
||||
--CommonFunc.GiveCommonAward(pActor, Conf.bigTreasure, GameLog.Log_Activity9, "独闯天涯排名奖励|"..atvId)
|
||||
CommonFunc.Awards.Give(pActor, Conf.bigTreasure, GameLog.Log_Activity9, "独闯天涯排名奖励|"..atvId)
|
||||
Actor.sendTipmsgWithId(pActor, tmGetSpeedAwardSucess, tstUI)
|
||||
errorcode = 0
|
||||
end
|
||||
-- 操作成功
|
||||
--print("排名奖励:",cacheData.bigTreasureNum)
|
||||
if cacheData.bigTreasureNum >0 then
|
||||
cacheData.bigTreasureNum = cacheData.bigTreasureNum -1
|
||||
end
|
||||
|
||||
data.bigTreasurecount = 0
|
||||
data.uint_times_big =System.getActivityEndMiniSecond(atvId)
|
||||
|
||||
--print("排名奖励 个数剩余=:"..cacheData.bigTreasureNum)
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendBonusNum)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
-- DataPack.writeUInt(outPack, nId)
|
||||
-- DataPack.writeByte(outPack, nIndex)
|
||||
DataPack.writeByte(outPack, cacheData.bigTreasureNum)
|
||||
--DataPack.writeByte(outPack, errorcode)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
--请求奖励数量
|
||||
function getBonusNums(pActor, atvId, Conf, inPack)
|
||||
|
||||
|
||||
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.bigTreasureNum == nil then
|
||||
cacheData.bigTreasureNum = Conf.bigTreasureNum
|
||||
end
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendBonusNum)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
-- DataPack.writeUInt(outPack, nId)
|
||||
-- DataPack.writeByte(outPack, nIndex)
|
||||
DataPack.writeByte(outPack, cacheData.bigTreasureNum)
|
||||
--print("---------------------------------------cacheData.bigTreasureNum"..cacheData.bigTreasureNum)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
--请求当前刷怪数
|
||||
function getMonsterNums(pActor, atvId, Conf, inPack)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMonsterNum)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
-- DataPack.writeUInt(outPack, nId)
|
||||
-- DataPack.writeByte(outPack, nIndex)
|
||||
if actorData.monsterCount > 127 then
|
||||
actorData.monsterCount = 127
|
||||
end
|
||||
DataPack.writeByte(outPack, actorData.monsterCount)
|
||||
--DataPack.writeByte(outPack, 10)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
-- 踢出副本
|
||||
function KickoutAllActors(atvId)
|
||||
if actorsInFuben ==nil then
|
||||
return
|
||||
end
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
end
|
||||
end
|
||||
actorsInFuben[atvId] = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- 设置复活,正常回城复活
|
||||
function SetAutoRelive(atvId,pActor)
|
||||
local actorid = Actor.getActorId(pActor)
|
||||
actorsInFuben[atvId][actorid] = nil
|
||||
Actor.relive(pActor)
|
||||
Actor.clearReliveTimeOut(pActor)
|
||||
--Actor.setReliveTimeOut(pActor, 10)
|
||||
Actor.exitFubenAndBackCity(pActor)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 活动 回调注册
|
||||
--------------------------------------------------------------------
|
||||
|
||||
-- 加载活动时(启动服务器从数据库返回的)
|
||||
function OnLoad(atvId)
|
||||
--print("[GActivity 9] 独闯天涯 活动数据加载,id:"..atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
end
|
||||
|
||||
-- 初始化玩家数据
|
||||
function OnInit(atvId, pActor)
|
||||
--print("[GActivity 9] 独闯天涯 "..Actor.getName(pActor).." 初始化 id:"..atvId)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor, atvId)
|
||||
actorData.deathLimit = nil
|
||||
actorData.nextLoginTime = nil
|
||||
end
|
||||
|
||||
-- 活动开始
|
||||
function OnStart(atvId)
|
||||
--System.broadcastTipmsg("独闯天涯活动将在10分钟后开启,请各位勇士做好准备",tstRevolving);
|
||||
--System.broadcastTipmsg("独闯天涯活动将在10分钟后开启,请各位勇士做好准备",tstChatNotice)
|
||||
broadcastflags[atvId] = 0
|
||||
|
||||
|
||||
ActivityDispatcher.ClearCacheData(atvId)
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
cacheData.actors = {}
|
||||
|
||||
--创建副本并记录
|
||||
local fbid = ActivityConfig[atvId].fbId
|
||||
local defsceneid = StaticFubens[fbid].defSceneID or StaticFubens[fbid].scenes[1]
|
||||
local fbHandle = Fuben.createFuBen(fbid)
|
||||
local scenHandle = Fuben.getSceneHandleById(defsceneid, fbHandle)
|
||||
cacheData.fbHandle = fbHandle
|
||||
cacheData.scenHandle = scenHandle
|
||||
cacheData.bigTreasureNum = nil
|
||||
|
||||
Fuben.useDefaultCreateMonster(fbHandle, true)
|
||||
end
|
||||
|
||||
-- 活动结束
|
||||
function OnEnd(atvId)
|
||||
--print("[Activity 9] 独闯天涯 活动结束了,id:"..atvId)
|
||||
broadcastflags[atvId] = 0
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
-- 踢出副本
|
||||
KickoutAllActors( atvId )
|
||||
-- 关闭副本
|
||||
Fuben.closeFuben( cacheData.fbHandle )
|
||||
-- 清空活动数据
|
||||
ActivityDispatcher.ClearCacheData( atvId )
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 活动帧更新
|
||||
function OnUpdate(atvId, curTime)
|
||||
--local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
|
||||
--活动开始前1min的提示
|
||||
if (broadcastflags[atvId] == 0 )then
|
||||
|
||||
--System.broadcastTipmsg("独闯天涯活动将在1分钟后开启,请各位勇士做好准备",tstRevolving)
|
||||
--System.broadcastTipmsg("独闯天涯活动将在1分钟后开启,请各位勇士做好准备",tstChatNotice)
|
||||
broadcastflags[atvId] = 1
|
||||
end
|
||||
|
||||
--活动开始的提示
|
||||
if( broadcastflags[atvId] == 1) then
|
||||
System.broadcastTipmsg("独闯天涯活动已开启,请各位勇士积极参与",tstRevolving)
|
||||
System.broadcastTipmsg("独闯天涯活动已开启,请各位勇士积极参与",tstChatNotice)
|
||||
broadcastflags[atvId] = 2
|
||||
ActivityDispatcher.BroadPopup(atvId);
|
||||
|
||||
if actorsInFuben[atvId] then
|
||||
for i,actorid in pairs(actorsInFuben[atvId]) do
|
||||
local pActor = Actor.getActorById(actorid)
|
||||
if pActor ~= nil then
|
||||
-- 发送一个活动数据
|
||||
Actor.sendActivityData(pActor, atvId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--活动结束前10min的提示
|
||||
if( System.isReachSecondBeforeActivityEnd(atvId,600) ==true and broadcastflags[atvId] == 2) then
|
||||
System.broadcastTipmsg("独闯天涯活动将在十分钟后关闭入口,请还未参加活动的勇士抓紧时间",tstRevolving)
|
||||
System.broadcastTipmsg("独闯天涯活动将在十分钟后关闭入口,请还未参加活动的勇士抓紧时间",tstChatNotice)
|
||||
broadcastflags[atvId] = 666
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- 获取活动数据
|
||||
function OnReqData(atvId, pActor, outPack)
|
||||
end
|
||||
|
||||
-- 通用操作
|
||||
function OnOperator(atvId, pActor, inPack)
|
||||
|
||||
--测试用完删
|
||||
--broadcastflags[atvId] = 2
|
||||
--测试用完删
|
||||
|
||||
|
||||
--活动前通告阶段不进入
|
||||
if broadcastflags[atvId] <2 then
|
||||
Actor.sendTipmsg(pActor, "|C:0xf56f00&T:该活动暂未开启|", tstUI)
|
||||
return
|
||||
end
|
||||
|
||||
-- id对应配置
|
||||
local Conf = ActivityConfig[atvId]
|
||||
if Conf == nil then
|
||||
--print("[Activity 4] "..Actor.getName(pActor).." 活动配置中找不到活动id:"..atvId)
|
||||
end
|
||||
-- 操作码对应操作
|
||||
local operaCode = DataPack.readByte(inPack)
|
||||
--print("__________________________________before request___________________operator: "..operaCode)
|
||||
-- 请求进入副本
|
||||
if operaCode == ActivityOperate.cEnterFuben then
|
||||
reqEnterFuben(pActor, atvId)
|
||||
end
|
||||
|
||||
--领取奖励
|
||||
if operaCode == ActivityOperate.cGetPersonBox then
|
||||
getGiftBox(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
|
||||
--请求排名奖励,先到先得50个
|
||||
if operaCode == ActivityOperate.cGetTreasure then
|
||||
getBigTreasure(pActor,atvId,Conf,inPack)
|
||||
end
|
||||
|
||||
--npc请求排名奖励剩余个数
|
||||
if operaCode == ActivityOperate.cGetBonusNum then
|
||||
getBonusNums(pActor, atvId, Conf, inPack)
|
||||
end
|
||||
|
||||
--npc请求当前刷怪数
|
||||
if operaCode == ActivityOperate.cGetMonsterNum then
|
||||
getMonsterNums(pActor, atvId, Conf, inPack)
|
||||
end
|
||||
end
|
||||
|
||||
function OnEnterFuben(atvId, pActor, pFuben)
|
||||
local actorData = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pActor, atvId, ActivityOperate.sSendMonsterNum)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
|
||||
DataPack.writeByte(outPack, 0)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
end
|
||||
|
||||
--玩家退出活动副本
|
||||
function OnExitFuben(atvId, pActor, pFuben)
|
||||
-- 玩家退出,从记录中排除
|
||||
local cacheData = ActivityDispatcher.GetCacheData(atvId)
|
||||
if cacheData.actors == nil then
|
||||
cacheData.actors = {}
|
||||
end
|
||||
local actorId = Actor.getIntProperty( pActor, PROP_ENTITY_ID )
|
||||
actorsInFuben[atvId][actorId] = nil
|
||||
end
|
||||
|
||||
--实体在活动副本中死亡
|
||||
function OnEntityDeath(atvId, pEntity,pKiller,pFuben)
|
||||
|
||||
if pEntity and Actor.getEntityType(pEntity) == enActor then
|
||||
-- 设置复活
|
||||
--SetAutoRelive(atvId, pEntity)
|
||||
end
|
||||
if pEntity and Actor.getEntityType(pEntity) == enMonster then
|
||||
if pKiller and Actor.getEntityType(pKiller) == enActor then
|
||||
local actorData = ActivityDispatcher.GetActorData(pKiller,atvId)
|
||||
if actorData.monsterCount ==nil then
|
||||
actorData.monsterCount = 0
|
||||
end
|
||||
actorData.monsterCount = actorData.monsterCount +1
|
||||
|
||||
local outPack = ActivityDispatcher.AllocOperReturn(pKiller, atvId, ActivityOperate.sSendMonsterNum)
|
||||
-- local netPack = DataPack.allocPacket(pActor,enActivityID, sSendPersonActivityUpdate)
|
||||
if outPack then
|
||||
|
||||
if actorData.monsterCount > 127 then
|
||||
actorData.monsterCount = 127
|
||||
end
|
||||
DataPack.writeByte(outPack, actorData.monsterCount)
|
||||
--DataPack.writeByte(outPack, 10)
|
||||
DataPack.flush(outPack)
|
||||
end
|
||||
|
||||
if actorData.monsterCount < 10 then
|
||||
Actor.sendTipmsg(pKiller, "当前已击杀怪物"..actorData.monsterCount.."/10", tstUI)
|
||||
else
|
||||
Actor.sendTipmsgWithId(pKiller, tmkillMonsterEnoughYet, tstUI)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--活动红点数据
|
||||
function OnGetRedPoint(atvId, pActor)
|
||||
local ret = 1
|
||||
local data = ActivityDispatcher.GetActorData(pActor,atvId)
|
||||
|
||||
if (broadcastflags[atvId] <2) or (data.count and (data.count == 0 )) then
|
||||
ret = 0
|
||||
end
|
||||
|
||||
local cfg = ActivityConfig[atvId]
|
||||
if cfg and cfg.openParam then
|
||||
if Actor.checkActorLevel(pActor,(cfg.openParam.level or 0)) ~=true then ret = 0 end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnGetRedPoint, ActivityType, OnGetRedPoint, "ActivityType9.lua")
|
||||
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnLoad, ActivityType, OnLoad, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnInit, ActivityType, OnInit, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnStart, ActivityType, OnStart, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnd, ActivityType, OnEnd, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnUpdate, ActivityType, OnUpdate, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnReqData, ActivityType, OnReqData, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnOperator, ActivityType, OnOperator, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnExitFuben, ActivityType, OnExitFuben, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEntityDeath, ActivityType, OnEntityDeath, "ActivityType9.lua")
|
||||
ActivityDispatcher.Reg(ActivityEvent.OnEnterFuben, ActivityType, OnEnterFuben, "ActivityType9.lua")
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- 玩家 回调注册
|
||||
--------------------------------------------------------------------
|
||||
@@ -0,0 +1,66 @@
|
||||
require("Activity.ActivityType1") --个人活动:副本类型活动
|
||||
require("Activity.ActivityType2") --个人活动:鉴定类型活动
|
||||
require("Activity.ActivityType3") --全局活动:竞技大乱斗
|
||||
require("Activity.ActivityType4") --个人活动:膜拜类活动
|
||||
require("Activity.ActivityType6") --全局活动:散财鹿类型活动
|
||||
require("Activity.ActivityType5") --全局活动:npc夺宝类
|
||||
require("Activity.ActivityType7") --全局活动:藏经峡谷类
|
||||
require("Activity.ActivityType8") --全局活动:世界boss
|
||||
require("Activity.ActivityType9") --全局活动:闯关
|
||||
require("Activity.ActivityType10") --全局活动:沙巴克(开服第四天后,每周三、周六)
|
||||
require("Activity.ActivityType11") --全局活动:夜战沃玛三
|
||||
require("Activity.ActivityType12") --个人活动:材料副本
|
||||
require("Activity.ActivityType13") --个人活动:驻守任务
|
||||
require("Activity.ActivityType14") --个人活动:材料副本
|
||||
require("Activity.ActivityType15") --个人活动:驻守任务
|
||||
require("Activity.ActivityType16") --全局活动:捐献排行
|
||||
require("Activity.ActivityType17") --全局活动:跨服竞技大乱斗
|
||||
require("Activity.ActivityType21") --全局活动:跨服沙巴克
|
||||
require("Activity.ActivityType25") --全局活动:世界boss
|
||||
require("Activity.ActivityType26") --全局活动:跨服逃脱试炼
|
||||
require("Activity.ActivityType27") --全局活动:沙巴克(开服第三天)
|
||||
require("Activity.ActivityType28") --全局活动:秘境打宝
|
||||
|
||||
require("Activity.ActivityType18") --跨服夜战沃玛三
|
||||
require("Activity.ActivityType19") --跨服活动:跨服首领
|
||||
require("Activity.ActivityType22") --跨服入口
|
||||
require("Activity.ActivityType23") --跨服膜拜
|
||||
require("Activity.ActivityType24") --跨服活动完结
|
||||
|
||||
require("Activity.ActivityType10001") --个人活动:累计充值
|
||||
require("Activity.ActivityType10002") --个人活动:特惠礼包
|
||||
require("Activity.ActivityType10003") --个人活动:首冲
|
||||
require("Activity.ActivityType10004") --个人活动:七天登录
|
||||
require("Activity.ActivityType10005") --个人活动:月份签到
|
||||
require("Activity.ActivityType10006") --个人活动:登录基金
|
||||
require("Activity.ActivityType10009") --个人活动:达标活动
|
||||
require("Activity.ActivityType10010") --个人活动:寻宝活动
|
||||
require("Activity.ActivityType10011") --玩法:YY大厅特权
|
||||
require("Activity.ActivityType10012") --玩法:YY会员
|
||||
require("Activity.ActivityType10013") --玩法:超玩会员
|
||||
require("Activity.ActivityType10014") --玩法:微信礼包
|
||||
require("Activity.ActivityType10015") --全局个人活动:每周固定时间的礼包活动
|
||||
require("Activity.ActivityType10016") --玩法:YY4366
|
||||
require("Activity.ActivityType10017") --兑换活动
|
||||
require("Activity.ActivityQQHall") --QQ大厅
|
||||
require("Activity.ActivityType10019") --
|
||||
require("Activity.ActivityLuckyTree") --
|
||||
require("Activity.ActivityOnlineMin") --
|
||||
require("Activity.ActivityType10020") --
|
||||
require("Activity.ActivityType10021") --个人活动:二充
|
||||
require("Activity.ActivityType10022") --玩法:360大玩家特权
|
||||
require("Activity.ActivityType10023") --7游戏 微信礼包
|
||||
require("Activity.ActivityType10024") --鲁大师
|
||||
require("Activity.ActivityType10027") --ku25
|
||||
require("Activity.ActivityType10028") --QiDian
|
||||
require("Activity.ActivityType10029") --aiqiyi
|
||||
require("Activity.ActivityType10030") --yaodou
|
||||
require("Activity.ActivityType10031") --贪玩
|
||||
require("Activity.ActivityType10032") --哥们
|
||||
require("Activity.ActivityType10033") --区服冠名
|
||||
require("Activity.ActivityType10034") --2144平台福利
|
||||
require("Activity.ActivityType10035") --快玩平台福利
|
||||
require("Activity.ActivityType10036") --顺网平台福利
|
||||
require("Activity.ActivityType10037") --迅玩平台福利
|
||||
require("Activity.ActivityType10038") --神秘福袋
|
||||
require("Activity.TanWanChatReport") --贪玩聊天上报
|
||||
@@ -0,0 +1,79 @@
|
||||
module("TanWanChatReport", package.seeall)
|
||||
|
||||
|
||||
Host = "yyhunfuht.bigrnet.com"
|
||||
Api = "/tanwan/api/wechat"
|
||||
Port = "80"
|
||||
|
||||
|
||||
local HttpStatus = {
|
||||
Success = "10001", -- 访问成功
|
||||
Send = "10009", -- 可以发送
|
||||
}
|
||||
|
||||
|
||||
function AfterCheckTanWanChatReport(paramPack,content,result)
|
||||
print("TanWanChatReport AfterCheckTanWanChatReport")
|
||||
|
||||
local nActorId = paramPack[1]
|
||||
local pActor = Actor.getActorById(nActorId)
|
||||
if not pActor then
|
||||
print("[Tip] TanWanChatReport AfterCheckTanWanChatReport [" .. nActorId .. "] 已离线")
|
||||
return
|
||||
end
|
||||
print("[Tip] TanWanChatReport AfterCheckTanWanChatReport [" .. Actor.getName(pActor) .. "] content:"..content)
|
||||
print("[Tip] TanWanChatReport AfterCheckTanWanChatReport [" .. Actor.getName(pActor) .. "] result:"..result)
|
||||
|
||||
if 0 == result then
|
||||
local status = string.match(content,"\"status\":(%d+)")
|
||||
local code = string.match(content,"\"code\":(%d+)")
|
||||
|
||||
if HttpStatus.Success == status then
|
||||
print("TanWanChatReport OnReqTanWanChatReport visit Success!")
|
||||
else
|
||||
print("TanWanChatReport OnReqTanWanChatReport visit Fail! status : "..status)
|
||||
end
|
||||
|
||||
if HttpStatus.Send == code then
|
||||
print("TanWanChatReport OnReqTanWanChatReport can Send!")
|
||||
else
|
||||
print("TanWanChatReport OnReqTanWanChatReport can't Send! code : "..code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- --------------------------------------------------------------------
|
||||
-- -- CPP回调
|
||||
-- --------------------------------------------------------------------
|
||||
|
||||
|
||||
function OnReqTanWanChatReport(nServerId, szServerName, szAccount, nActorId, szActorName, nTanWanChannleId, szMsg, szSendToActorName)
|
||||
print("TanWanChatReport OnReqTanWanChatReport nServerId :"..nServerId.." szServerName : "..szServerName.." Account: "..szAccount.." nActorId : "..nActorId.." ActorName : "..szActorName.." nTanWanChannleId : "..nTanWanChannleId.." SendToActorName : "..szSendToActorName)
|
||||
print("TanWanChatReport OnReqTanWanChatReport ".." msg: "..szMsg)
|
||||
|
||||
local game_server_id = nServerId
|
||||
local game_server_name = szServerName
|
||||
local uid = szAccount
|
||||
local username = szAccount
|
||||
local role_id = nActorId
|
||||
local role_name = szActorName
|
||||
local content_type = nTanWanChannleId
|
||||
local content = szMsg
|
||||
local to_role_name = szSendToActorName
|
||||
local send_time = os.time()
|
||||
|
||||
local req = Api..'?game_server_id='..game_server_id..'&game_server_name='..game_server_name..'&uid='..uid..'&username='..username..'&role_id='..role_id
|
||||
req = req..'&role_name='..role_name..'&content_type='..content_type..'&content='..content..'&to_role_name='..to_role_name..'&send_time='..send_time
|
||||
|
||||
-- print("TanWanChatReport OnReqTanWanChatReport [" .. Actor.getName(pActor) .. "] Host : ".. Host)
|
||||
-- print("TanWanChatReport OnReqTanWanChatReport [" .. Actor.getName(pActor) .. "] Port : ".. Port)
|
||||
-- print("TanWanChatReport OnReqTanWanChatReport [" .. Actor.getName(pActor) .. "] req : ".. req)
|
||||
|
||||
AsyncWorkDispatcher.Add(
|
||||
{'GetHttpContent',Host,Port,req},
|
||||
AfterCheckTanWanChatReport,
|
||||
{nActorId}
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user