init
This commit is contained in:
		@@ -0,0 +1,78 @@
 | 
			
		||||
--#include "data\config\achieve\AchieveCfg.txt" once
 | 
			
		||||
--#include "data\functions\ItemEvent\ItemUseCount.txt" once
 | 
			
		||||
 | 
			
		||||
function OnGetAchieveAwardsCfg(nAchieveID)
 | 
			
		||||
	for k,v in pairs(AchieveCfg)do
 | 
			
		||||
		for i,cfg in pairs(v.AchieveInfo)do
 | 
			
		||||
			if(cfg.id == nAchieveID)then
 | 
			
		||||
				return cfg
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--<2D>ȼ<EFBFBD>鹻<EFBFBD><E9B9BB><EFBFBD><EFBFBD>
 | 
			
		||||
function AchieveLogicCheck(sysarg, consumes, nCount)
 | 
			
		||||
    --<2D><><EFBFBD>ļ<EFBFBD><C4BC>
 | 
			
		||||
	for k,v in pairs(consumes) do
 | 
			
		||||
		local bCheck = Actor.checkConsume(sysarg, v.type, v.id, v.count*nCount, v.quality or 0, v.strong or 0, -1 , 0) 
 | 
			
		||||
		--BaseFuc_Print("v.type, v.id, v.count*nCount",bCheck,v.type, v.id, v.count*nCount)
 | 
			
		||||
		if bCheck ~= true then
 | 
			
		||||
			if v.type == qatBindMoney then   --<2D>˴<EFBFBD><CBB4>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
			
		||||
				--local myBindCoin = Actor.getMoneyCount( sysarg, mtBindCoin )
 | 
			
		||||
				Actor.sendNotEnoughMoney(sysarg, mtBindCoin, v.count * nCount)
 | 
			
		||||
			else
 | 
			
		||||
				local name = Item.getAwardDesc(v.type, v.id)
 | 
			
		||||
				local tips = string.format(OldLang.Script.EquipHecheng006, name, v.count)
 | 
			
		||||
				Actor.sendTipmsg(sysarg, tips, ttFlyTip)
 | 
			
		||||
			end
 | 
			
		||||
			return false
 | 
			
		||||
		end
 | 
			
		||||
	end	
 | 
			
		||||
	return true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function SendAchieveResult(sysarg, nId, bReslut)
 | 
			
		||||
	local GAME_MSG_S2C_SEND_ACHIEGVE_DRAW_DATA = 11
 | 
			
		||||
	local netPack = DataPack.allocPacket(sysarg,enAchieveSystemID, GAME_MSG_S2C_SEND_ACHIEGVE_DRAW_DATA)	
 | 
			
		||||
	DataPack.writeShort(netPack, nId) 
 | 
			
		||||
	DataPack.writeByte(netPack,bReslut)	
 | 
			
		||||
	DataPack.flush(netPack)		
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function OnGetAchieveAwards(sysarg, nAchieveID)
 | 
			
		||||
	local cfg = OnGetAchieveAwardsCfg(nAchieveID)
 | 
			
		||||
	if(AchieveLogicCheck(sysarg, cfg.consume, 1) ~= true)then
 | 
			
		||||
		return --print("AllDayLogicCheck")
 | 
			
		||||
	end	
 | 
			
		||||
	local logId = 180
 | 
			
		||||
	local logStr = OldLang.Log.LogWingActivation	
 | 
			
		||||
	if(SubBatchItemByType(sysarg, cfg.consume, logId, logStr) ~= true)then
 | 
			
		||||
		return --print("btType",btType)
 | 
			
		||||
	end	
 | 
			
		||||
	if(0 < #cfg.award )then
 | 
			
		||||
		if CommonFunc.Awards.CheckBagGridCount(sysarg, {cfg.award}) ~= true then
 | 
			
		||||
			local actorId = Actor.getActorId(sysarg)
 | 
			
		||||
			local title = OldLang.NoticeStr.n093
 | 
			
		||||
			local content = OldLang.NoticeStr.n094
 | 
			
		||||
			SendMail(actorId, title, content, awards)	
 | 
			
		||||
			return 
 | 
			
		||||
		end	
 | 
			
		||||
		CommonFunc.Awards.Give(sysarg, {cfg.award}, logId, logStr)	
 | 
			
		||||
	end	
 | 
			
		||||
	Actor.setAchieveGiveAwards(sysarg, nAchieveID)
 | 
			
		||||
	SendAchieveResult(sysarg, nAchieveID, 1)
 | 
			
		||||
	Actor.sendTipmsg(sysarg, string.format(OldLang.NoticeStr.Achieve1001,cfg.name), ttFlyTip)
 | 
			
		||||
	sendItemUseCount(sysarg, 4)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GMAchieveFuc(sysarg, arg2,	arg3 )
 | 
			
		||||
	if(arg2 == 1)then
 | 
			
		||||
		Actor.triggerQuestEvent(sysarg, 16, 800, 1)
 | 
			
		||||
		return Actor.setAchieveFinished(sysarg, arg3)		-- @DebugLua 2003 1 1
 | 
			
		||||
	end
 | 
			
		||||
	if(arg2 == 2)then
 | 
			
		||||
		return OnGetAchieveAwards(sysarg, arg3)				-- @DebugLua 2003 2 1
 | 
			
		||||
	end	
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,120 @@
 | 
			
		||||
--lua script
 | 
			
		||||
 | 
			
		||||
--#include "data\config\combat\combatConfig.txt"  once
 | 
			
		||||
--#include "data\functions\ActorSystems\CombatSystem\CombatPkCommonOp.txt"  once
 | 
			
		||||
 | 
			
		||||
function GetCombatBaseInfo(sysarg, args)
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function SelectPayers(sysarg, args)
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function StartCombatPK(sysarg, args)
 | 
			
		||||
	CombatPkCommon(sysarg, args[2])
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function ClearCooldown(sysarg, args)
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function RechargeAward(sysarg, args)
 | 
			
		||||
	local awardId = args[2]
 | 
			
		||||
	local curRank = args[3]
 | 
			
		||||
	local config = CombatConfig
 | 
			
		||||
	local award
 | 
			
		||||
	local index = 0
 | 
			
		||||
	for k, v in ipairs(config.rankShop) do
 | 
			
		||||
		if v.id == awardId then
 | 
			
		||||
			index = k
 | 
			
		||||
			award = v
 | 
			
		||||
			break
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	if index < 1 and index > 32 then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	local day = System.getDaysSinceOpenServer()
 | 
			
		||||
	if day < config.openDay then
 | 
			
		||||
	    return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	if curRank > award.rankLimit or curRank <= 0 then
 | 
			
		||||
		Actor.sendTipmsg(sysarg, OldLang.Script.CombatRank002, ttFlyTip)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	local sex = Actor.getIntProperty(sysarg, PROP_ACTOR_SEX)
 | 
			
		||||
	if award.sex >= 0 and award.sex ~= sex then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local job = Actor.getIntProperty(sysarg, PROP_ACTOR_VOCATION)
 | 
			
		||||
	if award.job ~= 0 and award.job ~= job then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	local sVar = Actor.getStaticVar(sysarg)
 | 
			
		||||
	if not sVar.CombatShopData then
 | 
			
		||||
		sVar.CombatShopData = 0
 | 
			
		||||
	end
 | 
			
		||||
	local isGetAward = System.getIntBit(sVar.CombatShopData, index-1)
 | 
			
		||||
	if isGetAward > 0 then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	--兑换道具
 | 
			
		||||
	local bCheck = Actor.checkConsume(sysarg, 33, 0, award.price)
 | 
			
		||||
	if not bCheck then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	Actor.removeConsume(sysarg, 33, 0, award.price)
 | 
			
		||||
	Actor.giveAward(sysarg, 0, award.item, award.count, award.quality or 0, award.strong or 0, award.bind or 0, 0, 312, "CombatRechargeAward")
 | 
			
		||||
 | 
			
		||||
	sVar.CombatShopData = System.setIntBit(sVar.CombatShopData, index-1, true)
 | 
			
		||||
	local pack = DataPack.allocPacket(sysarg, 57, 5)
 | 
			
		||||
	if (pack) then	
 | 
			
		||||
		DataPack.writeInt(pack, award.id)
 | 
			
		||||
		DataPack.flush(pack)  		
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetCombatLog(sysarg, args)
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetCombatRank(sysarg, args)
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetRankAwardList(sysarg, args)
 | 
			
		||||
	local config = CombatConfig
 | 
			
		||||
	local awardList = {}
 | 
			
		||||
	local sVar = Actor.getStaticVar(sysarg)
 | 
			
		||||
	if sVar.CombatShopData then
 | 
			
		||||
		local isGetAward = 0
 | 
			
		||||
		for k,v in ipairs(config.rankShop) do
 | 
			
		||||
			if k > 32 then
 | 
			
		||||
				break
 | 
			
		||||
			end
 | 
			
		||||
			isGetAward = System.getIntBit(sVar.CombatShopData, k-1)
 | 
			
		||||
			if isGetAward > 0 then
 | 
			
		||||
				awardList[#awardList + 1] = v.id
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local pack = DataPack.allocPacket(sysarg, 57, 8)
 | 
			
		||||
	if (pack) then	
 | 
			
		||||
		DataPack.writeInt(pack, #awardList)
 | 
			
		||||
		for _, v in ipairs(awardList) do
 | 
			
		||||
			DataPack.writeInt(pack, v)
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		DataPack.flush(pack)  		
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,299 @@
 | 
			
		||||
--lua script
 | 
			
		||||
 | 
			
		||||
--#include "data\config\combat\combatConfig.txt"  once
 | 
			
		||||
--#include "data\config\combat\combatRank.txt"  once  --基本设置 
 | 
			
		||||
 | 
			
		||||
function CombatRankInit() 
 | 
			
		||||
	local config = CombatRankConfig
 | 
			
		||||
	for _, value in ipairs(config.RankInfo) do
 | 
			
		||||
		Rank.Init(value.RankName, value.RankFile, config.RankColumn, config.MaxRankNum, 0)
 | 
			
		||||
 | 
			
		||||
		local ranking = Ranking.getRanking(value.RankName)
 | 
			
		||||
		if not ranking then 
 | 
			
		||||
			return 
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		local nCount = Ranking.getRankItemCount(ranking)
 | 
			
		||||
		if nCount == 0 then
 | 
			
		||||
			for _, v in ipairs(value.RankDefaultItem) do	
 | 
			
		||||
				local item = Ranking.addItem(ranking, v[1], v[2], false)
 | 
			
		||||
				if item then
 | 
			
		||||
					for i = 1, #config.RankColumn do
 | 
			
		||||
						Ranking.setSub(item, i-1, tostring(v[i+2]))
 | 
			
		||||
					end
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function CombatRankFinal()
 | 
			
		||||
	local config = CombatRankConfig
 | 
			
		||||
	for _, value in ipairs(config.RankInfo) do
 | 
			
		||||
		local ranking = Ranking.getRanking(value.RankName)
 | 
			
		||||
		if ranking then
 | 
			
		||||
			Ranking.save(ranking, value.RankFile, true)
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
table.insert(InitFnTable, CombatRankInit)
 | 
			
		||||
table.insert(FinaFnTable, CombatRankFinal)
 | 
			
		||||
 | 
			
		||||
--职业宗师pk流程
 | 
			
		||||
function CombatPkCommon(sysarg, nActorId)
 | 
			
		||||
	local config = CombatConfig
 | 
			
		||||
	local mJop = Actor.getIntProperty(sysarg, PROP_ACTOR_VOCATION)
 | 
			
		||||
	local skills = config.skills[mJop]
 | 
			
		||||
	if not skills then
 | 
			
		||||
		return 
 | 
			
		||||
	end
 | 
			
		||||
	local RankInfo = CombatRankConfig.RankInfo[mJop]
 | 
			
		||||
	if not RankInfo then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local ranking = Ranking.getRanking(RankInfo.RankName)
 | 
			
		||||
	if not ranking then return end
 | 
			
		||||
 | 
			
		||||
	-- 对方的排名项
 | 
			
		||||
	local tItem = Ranking.getItemPtrFromId(ranking,nActorId)
 | 
			
		||||
	if not tItem then
 | 
			
		||||
		return
 | 
			
		||||
	end	
 | 
			
		||||
 | 
			
		||||
	local myId = Actor.getIntProperty(sysarg,PROP_ENTITY_ID)	
 | 
			
		||||
	--local myItem = Ranking.getItemPtrFromId(ranking,myId)
 | 
			
		||||
	local mRanking = Ranking.getItemIndexFromId(ranking, myId) + 1
 | 
			
		||||
	local tRanking = Ranking.getItemIndexFromId(ranking, nActorId) + 1
 | 
			
		||||
	local Awards
 | 
			
		||||
	local Swap = 0
 | 
			
		||||
 | 
			
		||||
	local Me = {
 | 
			
		||||
		num = 0,
 | 
			
		||||
		sex = Actor.getIntProperty(sysarg, PROP_ACTOR_SEX),
 | 
			
		||||
		name = Actor.getName(sysarg),
 | 
			
		||||
		level = Actor.getIntProperty(sysarg, PROP_CREATURE_LEVEL),
 | 
			
		||||
		icon = Actor.getIntProperty(sysarg, PROP_ENTITY_ICON),
 | 
			
		||||
		model = Actor.getIntProperty(sysarg, PROP_ENTITY_MODELID),
 | 
			
		||||
		weapon = Actor.getIntProperty(sysarg, PROP_ACTOR_WEAPONAPPEARANCE),
 | 
			
		||||
		swing = Actor.getIntProperty(sysarg, PROP_ACTOR_SWINGAPPEARANCE),
 | 
			
		||||
		hp = Actor.getIntProperty(sysarg, PROP_CREATURE_MAXHP),
 | 
			
		||||
		attack = Actor.getMaxAttack(sysarg),
 | 
			
		||||
		defence = Actor.getMaxDefence(sysarg),
 | 
			
		||||
		hit = Actor.getIntProperty(sysarg, PROP_CREATURE_HITVALUE),
 | 
			
		||||
		crit = Actor.getIntProperty(sysarg, PROP_ACTOR_CRIT_RATE),
 | 
			
		||||
		dodge = Actor.getIntProperty(sysarg, PROP_CREATURE_DODVALUE),
 | 
			
		||||
		battlePower = Actor.getIntProperty(sysarg, PROP_ACTOR_BATTLE_POWER),
 | 
			
		||||
		isreal = 1,
 | 
			
		||||
	}
 | 
			
		||||
	Me.curHp = Me.hp
 | 
			
		||||
	local Target = {
 | 
			
		||||
		num = 1,
 | 
			
		||||
		sex = tonumber(Ranking.getSub(tItem, 3)),
 | 
			
		||||
		name = Ranking.getSub(tItem, 0),
 | 
			
		||||
		level = tonumber(Ranking.getSub(tItem, 2)),
 | 
			
		||||
		icon = tonumber(Ranking.getSub(tItem, 4)),
 | 
			
		||||
		model = tonumber(Ranking.getSub(tItem, 5)),
 | 
			
		||||
		weapon = tonumber(Ranking.getSub(tItem, 6)),
 | 
			
		||||
		swing = tonumber(Ranking.getSub(tItem, 7)),
 | 
			
		||||
		hp = tonumber(Ranking.getSub(tItem, 8)),
 | 
			
		||||
		attack = tonumber(Ranking.getSub(tItem, 9)),
 | 
			
		||||
		defence = tonumber(Ranking.getSub(tItem, 10)),
 | 
			
		||||
		hit = tonumber(Ranking.getSub(tItem, 11)),
 | 
			
		||||
		crit = tonumber(Ranking.getSub(tItem, 12)),
 | 
			
		||||
		dodge = tonumber(Ranking.getSub(tItem, 13)) or 0,
 | 
			
		||||
		isreal = tonumber(Ranking.getSub(tItem, 14)) or 0,
 | 
			
		||||
		battlePower = tonumber(Ranking.getPoint(tItem)),
 | 
			
		||||
	}
 | 
			
		||||
	Target.curHp = Target.hp
 | 
			
		||||
 | 
			
		||||
	local actions = {}
 | 
			
		||||
	local OneHit = function(attacker, defencer, order)
 | 
			
		||||
 | 
			
		||||
		local action = {
 | 
			
		||||
			num = attacker.num,
 | 
			
		||||
			skill = skills[order],
 | 
			
		||||
			hp = 0,
 | 
			
		||||
			isHit = 0,
 | 
			
		||||
			isCrit = 0,
 | 
			
		||||
			isDead = 0,
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		-- 1 是否命中
 | 
			
		||||
		if attacker.hit > defencer.dodge then
 | 
			
		||||
			action.isHit = 1
 | 
			
		||||
		elseif attacker.hit >= math.random(defencer.dodge) then
 | 
			
		||||
			action.isHit = 1
 | 
			
		||||
		else
 | 
			
		||||
			action.isHit = 0
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		if action.isHit == 0 then
 | 
			
		||||
			action.hp = defencer.curHp	
 | 
			
		||||
			actions[#actions + 1] = action
 | 
			
		||||
			return false
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		-- 2 计算伤害
 | 
			
		||||
		local attackMin = math.floor(attacker.attack * 325 / 100)
 | 
			
		||||
		local attackMax = math.floor(attacker.attack * 375 / 100)
 | 
			
		||||
		local attackValue = math.random(attackMin, attackMax)
 | 
			
		||||
		local damage = attackValue - defencer.defence
 | 
			
		||||
		if damage < 0 then
 | 
			
		||||
			damage = 0
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		-- 3 是否暴击
 | 
			
		||||
		if attacker.crit >= math.random(10000) then
 | 
			
		||||
			action.isCrit = 1
 | 
			
		||||
			damage = math.floor(damage + damage * 20 / 100)
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		defencer.curHp = defencer.curHp - damage
 | 
			
		||||
		action.hp = defencer.curHp
 | 
			
		||||
		-- 记录战斗
 | 
			
		||||
		if defencer.curHp <= 0 then
 | 
			
		||||
			action.isDead = 1
 | 
			
		||||
			actions[#actions + 1] = action
 | 
			
		||||
			return true
 | 
			
		||||
		else
 | 
			
		||||
			actions[#actions + 1] = action
 | 
			
		||||
			return false
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	local winNum = 0
 | 
			
		||||
	local order = 0
 | 
			
		||||
	local skillCount = #skills
 | 
			
		||||
	while(1) do
 | 
			
		||||
		local result = OneHit(Me, Target, order + 1)
 | 
			
		||||
		if result then
 | 
			
		||||
			winNum = Me.num
 | 
			
		||||
			break
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		result = OneHit(Target, Me, order + 1)
 | 
			
		||||
		if result then
 | 
			
		||||
			winNum = Target.num
 | 
			
		||||
			break
 | 
			
		||||
		end
 | 
			
		||||
		order = (order + 1) % skillCount
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	-- 发送协议和奖励处理
 | 
			
		||||
	local pack = DataPack.allocPacket(sysarg, 57, 3)
 | 
			
		||||
	if (pack) then	
 | 
			
		||||
		-- 基本信息
 | 
			
		||||
		DataPack.writeByte(pack,2)
 | 
			
		||||
		for i =1,2 do
 | 
			
		||||
			if i == 1 then -- 自己
 | 
			
		||||
				DataPack.writeByte(pack, Me.num)
 | 
			
		||||
				DataPack.writeByte(pack, Me.sex)
 | 
			
		||||
				DataPack.writeString(pack, Me.name)				
 | 
			
		||||
				DataPack.writeInt(pack, Me.level)
 | 
			
		||||
				DataPack.writeInt(pack, Me.icon)
 | 
			
		||||
				DataPack.writeInt(pack, Me.model)
 | 
			
		||||
				DataPack.writeInt(pack, Me.weapon)
 | 
			
		||||
				DataPack.writeInt(pack, Me.swing)
 | 
			
		||||
				DataPack.writeInt(pack, Me.hp)
 | 
			
		||||
				DataPack.writeInt(pack, Me.battlePower)
 | 
			
		||||
 | 
			
		||||
			elseif i == 2 then -- 对方
 | 
			
		||||
				DataPack.writeByte(pack, Target.num)
 | 
			
		||||
				DataPack.writeByte(pack, Target.sex)
 | 
			
		||||
				DataPack.writeString(pack, Target.name)				
 | 
			
		||||
				DataPack.writeInt(pack, Target.level)
 | 
			
		||||
				DataPack.writeInt(pack, Target.icon)
 | 
			
		||||
				DataPack.writeInt(pack, Target.model)
 | 
			
		||||
				DataPack.writeInt(pack, Target.weapon)
 | 
			
		||||
				DataPack.writeInt(pack, Target.swing)
 | 
			
		||||
				DataPack.writeInt(pack, Target.hp)
 | 
			
		||||
				DataPack.writeInt(pack, Target.battlePower)
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		-- 动作序列
 | 
			
		||||
		DataPack.writeInt(pack, #actions) -- 动作数量	
 | 
			
		||||
		for _, v in ipairs(actions) do
 | 
			
		||||
			DataPack.writeByte(pack, v.num)
 | 
			
		||||
			DataPack.writeInt(pack,  v.skill)
 | 
			
		||||
			DataPack.writeInt(pack,  v.hp)
 | 
			
		||||
			DataPack.writeByte(pack, v.isCrit)
 | 
			
		||||
			DataPack.writeByte(pack, v.isDead)
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		--战胜
 | 
			
		||||
		if winNum == 0 then	
 | 
			
		||||
			if mRanking > tRanking or mRanking <= 0 then 
 | 
			
		||||
				Swap = tRanking	
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			Awards= config.combatResultAward[1]	
 | 
			
		||||
			--失败
 | 
			
		||||
		else 
 | 
			
		||||
			Awards = config.combatResultAward[2]
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		-- 胜出方
 | 
			
		||||
		DataPack.writeByte(pack, winNum)
 | 
			
		||||
		DataPack.writeInt(pack, Swap)
 | 
			
		||||
 | 
			
		||||
		--奖励的消息
 | 
			
		||||
		DataPack.writeInt(pack, #Awards)
 | 
			
		||||
		for _, v in ipairs(Awards) do
 | 
			
		||||
			DataPack.writeInt(pack, v.type)
 | 
			
		||||
			DataPack.writeInt(pack, v.count)
 | 
			
		||||
		end
 | 
			
		||||
		DataPack.flush(pack)  		
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	GiveCommonAward(sysarg, Awards, 311, "CombatChallengeAward")
 | 
			
		||||
	if winNum == 0 then		--胜利
 | 
			
		||||
		if mRanking > tRanking or mRanking <= 0 then 
 | 
			
		||||
			Actor.swapCombatRank(sysarg, myId, nActorId)
 | 
			
		||||
			if tRanking > 0 and tRanking < 11 then
 | 
			
		||||
				str = string.format(OldLang.Script.CombatRank001, tRanking, Target.name, Me.name)
 | 
			
		||||
				System.broadcastTipmsgLimitLev(str, ttScreenCenter + ttChatWindow, CombatRankConfig.LevLimit)
 | 
			
		||||
			end
 | 
			
		||||
			Actor.ChallegeOverOp(sysarg, 2, nActorId, Target.name, Target.isreal)
 | 
			
		||||
		else
 | 
			
		||||
			Actor.ChallegeOverOp(sysarg, 1, nActorId, Target.name, Target.isreal)
 | 
			
		||||
		end
 | 
			
		||||
	else
 | 
			
		||||
		Actor.ChallegeOverOp(sysarg, -1, nActorId, Target.name, Target.isreal)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--职业宗师定时排名奖励发放
 | 
			
		||||
function CombatRankAwardTimeing()
 | 
			
		||||
	local config = CombatConfig
 | 
			
		||||
	local title = OldLang.Script.CombatRank003
 | 
			
		||||
 | 
			
		||||
	for _, value in ipairs(CombatRankConfig.RankInfo) do
 | 
			
		||||
		local ranking = Ranking.getRanking(value.RankName)
 | 
			
		||||
		if not ranking then 
 | 
			
		||||
			return 
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		local nCount = Ranking.getRankItemCount(ranking)
 | 
			
		||||
		for idx=1, nCount do
 | 
			
		||||
			for _, v in ipairs(config.combatRankAward) do
 | 
			
		||||
				if idx >= v.rankRange[1] and idx <=	v.rankRange[2] then
 | 
			
		||||
					local rankItem = Ranking.getItemFromIndex(ranking, idx-1)
 | 
			
		||||
					if rankItem then
 | 
			
		||||
						isreal = tonumber(Ranking.getSub(rankItem, 14)) or 0
 | 
			
		||||
						if isreal > 0 then
 | 
			
		||||
							local actorId = Ranking.getId(rankItem)
 | 
			
		||||
							local content = string.format(OldLang.Script.CombatRank004, idx)
 | 
			
		||||
							SendMail(actorId, title, content, v.awards)
 | 
			
		||||
						end
 | 
			
		||||
					end
 | 
			
		||||
					break
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@@ -0,0 +1,320 @@
 | 
			
		||||
--[[
 | 
			
		||||
    激活码功能
 | 
			
		||||
 | 
			
		||||
    个人数据:CdKeyData
 | 
			
		||||
    {
 | 
			
		||||
        lastTime,上次使用时间
 | 
			
		||||
        codeTimes = 
 | 
			
		||||
        {
 | 
			
		||||
            [id1], 礼包id1的使用次数
 | 
			
		||||
            [id2],
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
[60] = {
 | 
			
		||||
	Id = 60,
 | 
			
		||||
	awards = {{type=0,id=1270,count=1},{type=0,id=1271,count=1}},
 | 
			
		||||
	limits = 1,
 | 
			
		||||
	mailtitle = "VIP进游礼包",
 | 
			
		||||
	mailcontent = "礼包兑换成功,这是为您准备的礼包,请收好",
 | 
			
		||||
	switch = 1,
 | 
			
		||||
},
 | 
			
		||||
[61] = {
 | 
			
		||||
	Id = 61,
 | 
			
		||||
	awards = {{type=0,id=1242,count=33},{type=0,id=388,count=1},{type=0,id=1248,count=10}},
 | 
			
		||||
	limits = 1,
 | 
			
		||||
	mailtitle = "特权资源礼包",
 | 
			
		||||
	mailcontent = "礼包兑换成功,这是为您准备的礼包,请收好",
 | 
			
		||||
	switch = 1,
 | 
			
		||||
},
 | 
			
		||||
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
local CODE_SUCCESS = 0	    -- 成功
 | 
			
		||||
local CODE_INVALID = 1      -- 已被使用
 | 
			
		||||
local CODE_NOTEXIST = 2     -- 不存在
 | 
			
		||||
local CODE_USED = 3 	    -- 已使用过同类型
 | 
			
		||||
local CODE_ERR = 4		    -- SQL查询错误
 | 
			
		||||
local CODE_TIME = 5		    -- 未到使用时间
 | 
			
		||||
local CODE_TIMEEXPIRE = 6   -- 礼包码过期了
 | 
			
		||||
local CODE_HTTP = 11        -- HTTP接口错误
 | 
			
		||||
local CODE_PF = 12          -- 非本平台礼包码
 | 
			
		||||
local CODE_LIMIT = 13       -- 使用次数超过限制
 | 
			
		||||
 | 
			
		||||
local PfId = System.getPfId()
 | 
			
		||||
local SrvId = System.getServerId()
 | 
			
		||||
local ServiceConf = CdkeyServiceConf[PfId]
 | 
			
		||||
 | 
			
		||||
--配置的服务检测
 | 
			
		||||
function OnCheckCanPlatform()
 | 
			
		||||
    -- 平台验证
 | 
			
		||||
    if not PfId then
 | 
			
		||||
        print("[ERR][CdKey old]0 load CdkeyServiceConfig error! ")
 | 
			
		||||
        return false
 | 
			
		||||
    end 
 | 
			
		||||
    if ServiceConf == nil then 
 | 
			
		||||
        print("[ERR][CdKey old]1 load CdkeyServiceConfig error! ")
 | 
			
		||||
        return false
 | 
			
		||||
    end
 | 
			
		||||
    if ServiceConf.host == nil then
 | 
			
		||||
        print("[ERR][CdKey old]2 load CdkeyServiceConfig error! ")
 | 
			
		||||
        return false
 | 
			
		||||
    end
 | 
			
		||||
    if ServiceConf.port == nil then
 | 
			
		||||
        print("[ERR][CdKey old]3 load CdkeyServiceConfig error! ")
 | 
			
		||||
        return false
 | 
			
		||||
    end
 | 
			
		||||
    if ServiceConf.url == nil then
 | 
			
		||||
        print("[ERR][CdKey old]4 load CdkeyServiceConfig error! ")
 | 
			
		||||
        return false
 | 
			
		||||
    end  
 | 
			
		||||
    return true
 | 
			
		||||
end
 | 
			
		||||
-- 根据 CDKey 获取礼包码id
 | 
			
		||||
local function getCodeId(code)
 | 
			
		||||
    local len = string.byte(string.sub(code, -1)) - 97
 | 
			
		||||
    local pos = string.byte(string.sub(code, -2,-2)) - 97
 | 
			
		||||
	local str = string.sub(code, pos + 1, pos + len)
 | 
			
		||||
 | 
			
		||||
	--print("gift code len :"..tostring(len))
 | 
			
		||||
    ---print("gift code pos :"..tostring(pos))
 | 
			
		||||
	--print("gift code str :"..tostring(str))
 | 
			
		||||
 | 
			
		||||
    local id = 0
 | 
			
		||||
    for i=1, string.len(str) do
 | 
			
		||||
        id = id * 10 + (math.abs(string.byte(string.sub(str, i, i)) - 97))
 | 
			
		||||
    end
 | 
			
		||||
    return id
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- 检测平台号
 | 
			
		||||
local function checkPfid(code)
 | 
			
		||||
    local pos = string.byte(string.sub(code, -2,-2)) - 97
 | 
			
		||||
    local str = string.sub(code, 1, pos)
 | 
			
		||||
    return str == PfId
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- 获取玩家的 CDKey 数据
 | 
			
		||||
local function getActorData(pActor)
 | 
			
		||||
    if Actor.getEntityType(pActor) ~= enActor then
 | 
			
		||||
        assert(false)
 | 
			
		||||
    end
 | 
			
		||||
    local var = Actor.getStaticVar(pActor);
 | 
			
		||||
    if var.CdKeyData == nil then
 | 
			
		||||
        var.CdKeyData = {}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if not var.CdKeyData.codeTimes then
 | 
			
		||||
        var.CdKeyData.codeTimes = {}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return var.CdKeyData
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- 获取玩家的 CDKey 数据
 | 
			
		||||
function getActorCdkData(pActor)
 | 
			
		||||
    if Actor.getEntityType(pActor) ~= enActor then
 | 
			
		||||
        assert(false)
 | 
			
		||||
    end
 | 
			
		||||
    local var = Actor.getStaticVar(pActor);
 | 
			
		||||
    if var.CdKeyData == nil then
 | 
			
		||||
        var.CdKeyData = {}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if not var.CdKeyData.codeTimes then
 | 
			
		||||
        var.CdKeyData.codeTimes = {}
 | 
			
		||||
    end
 | 
			
		||||
    if not var.CdKeyData.codeTypeTimes then
 | 
			
		||||
        var.CdKeyData.codeTypeTimes = {}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return var.CdKeyData
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- 检测完CDKey后的回调
 | 
			
		||||
local function AfterCheckCDkey(paramPack,content,result)
 | 
			
		||||
    print("[TIP] AfterCheckCDkey : content("..content.."), result: "..result)
 | 
			
		||||
    local aid = paramPack[1]
 | 
			
		||||
    local id = paramPack[2]
 | 
			
		||||
    local pActor = Actor.getActorById(aid)
 | 
			
		||||
    local res = CODE_SUCCESS
 | 
			
		||||
    local giftid = id
 | 
			
		||||
    if pActor and (result == 0) then
 | 
			
		||||
        -- 获取结果
 | 
			
		||||
        res,giftid = string.match(content, "(%d+),(%d+)")
 | 
			
		||||
        res = tonumber(res)
 | 
			
		||||
        giftid = tonumber(giftid)
 | 
			
		||||
        if res ~= nil then
 | 
			
		||||
            if res == CODE_SUCCESS then
 | 
			
		||||
                -- 发派奖励
 | 
			
		||||
                local conf = CDKeyConf[id]
 | 
			
		||||
                SendMail(aid, conf.mailtitle or "兑换码", conf.mailcontent or "兑换码兑换成功!", conf.awards)
 | 
			
		||||
                -- 记录使用
 | 
			
		||||
                local data = getActorData(pActor)
 | 
			
		||||
                data.codeTimes[id] = (data.codeTimes[id] or 0) + 1
 | 
			
		||||
                
 | 
			
		||||
                if not data.codeTypeTimes then
 | 
			
		||||
                    data.codeTypeTimes = {}
 | 
			
		||||
                end 
 | 
			
		||||
                data.codeTypeTimes[giftid] = (data.codeTypeTimes[giftid] or 0) + 1
 | 
			
		||||
            end
 | 
			
		||||
        else
 | 
			
		||||
            res = CODE_HTTP
 | 
			
		||||
            print("[ERROR] AfterCheckCDkey : res("..res.."), content: "..content)
 | 
			
		||||
        end
 | 
			
		||||
    else
 | 
			
		||||
        res = CODE_HTTP
 | 
			
		||||
        print("[ERROR] AfterCheckCDkey : result("..result.."), content: "..content)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    -- 回复使用结果
 | 
			
		||||
    local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
 | 
			
		||||
    if npack then
 | 
			
		||||
        DataPack.writeByte(npack, res)
 | 
			
		||||
        DataPack.flush(npack)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--使用激活码
 | 
			
		||||
function UseCDKey(pActor, code)
 | 
			
		||||
    print("[DEBUG] UseCDKey, code="..code)
 | 
			
		||||
 | 
			
		||||
    local ServiceHost = ServiceConf.host
 | 
			
		||||
    local ServicePort = ServiceConf.port
 | 
			
		||||
    local ServiceUrl = ServiceConf.url
 | 
			
		||||
 | 
			
		||||
    if checkPfid(code) == false then
 | 
			
		||||
        --Actor.sendTipmsg(pActor,"非本平台的礼包码!")
 | 
			
		||||
        -- 回复使用结果
 | 
			
		||||
        local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
 | 
			
		||||
        if npack then
 | 
			
		||||
            DataPack.writeByte(npack, CODE_PF)
 | 
			
		||||
            DataPack.flush(npack)
 | 
			
		||||
        end
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    local data = getActorData(pActor)
 | 
			
		||||
    local time = System.getCurrMiniTime()
 | 
			
		||||
    if data.lastTime and data.lastTime >= time then
 | 
			
		||||
        Actor.sendTipmsg(pActor,"请求过快!")
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    local id = getCodeId(code)
 | 
			
		||||
    
 | 
			
		||||
    if CDKeyConf[id] == nil then   
 | 
			
		||||
        Actor.sendTipmsg(pActor, "礼包码错误02!") 
 | 
			
		||||
        print("[ERROR] getCodeId error : code = " .. code.."id = " .. id.." name="..Actor.getName(pActor))
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    local limit = CDKeyConf[id].limits or 1  --礼包码限制数量
 | 
			
		||||
    if data.codeTimes[id] then
 | 
			
		||||
        if data.codeTimes[id] >= limit then
 | 
			
		||||
            --Actor.sendTipmsg(pActor,"使用次数超过限制!")
 | 
			
		||||
            -- 回复使用结果
 | 
			
		||||
            local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
 | 
			
		||||
            if npack then
 | 
			
		||||
                DataPack.writeByte(npack, CODE_LIMIT)
 | 
			
		||||
                DataPack.flush(npack)
 | 
			
		||||
            end
 | 
			
		||||
            return
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    --加入异步工作
 | 
			
		||||
    local account = Actor.getAccount(pActor)
 | 
			
		||||
    local aid = Actor.getActorId(pActor)
 | 
			
		||||
 | 
			
		||||
    local req = ServiceUrl..'?pfid='..PfId..'&cdkey='..code..'&aid='..aid..'&sid='..SrvId..'&account='..account..'&limit='..limit
 | 
			
		||||
    print("[TIP] [CdKey] GetHttpContent -------------------------ServiceHost:"..tostring(ServiceHost))
 | 
			
		||||
    print("[TIP] [CdKey] GetHttpContent -------------------------ServicePort:"..tostring(ServicePort))
 | 
			
		||||
    print("[TIP] [CdKey] GetHttpContent -------------------------req:"..tostring(req)) 
 | 
			
		||||
 | 
			
		||||
    print("[TIP] getCodeId error : code = " .. code.."id = " .. id.." name="..Actor.getName(pActor))
 | 
			
		||||
    AsyncWorkDispatcher.Add(
 | 
			
		||||
        {'GetHttpContent', ServiceHost, ServicePort, req},
 | 
			
		||||
        AfterCheckCDkey,
 | 
			
		||||
        {aid,id}
 | 
			
		||||
    )
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--使用通码
 | 
			
		||||
function UseCommonCDKey(pActor, code)
 | 
			
		||||
    print("[DEBUG] UseCommonCDKey, code="..code)
 | 
			
		||||
 | 
			
		||||
    local data = getActorData(pActor)
 | 
			
		||||
    local time = System.getCurrMiniTime()
 | 
			
		||||
    if data.lastTime and data.lastTime >= time then
 | 
			
		||||
        Actor.sendTipmsg(pActor,"请求过快!")
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if CommonCDKeyConf[code].switch == 0 then
 | 
			
		||||
        local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
 | 
			
		||||
        if npack then
 | 
			
		||||
            DataPack.writeByte(npack, CODE_TIMEEXPIRE)
 | 
			
		||||
            DataPack.flush(npack)
 | 
			
		||||
        end
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    -- 使用次数超过限制
 | 
			
		||||
    if data.codeTimes[code] then
 | 
			
		||||
        if data.codeTimes[code] >= 1 then
 | 
			
		||||
            local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
 | 
			
		||||
            if npack then
 | 
			
		||||
                DataPack.writeByte(npack, CODE_LIMIT)
 | 
			
		||||
                DataPack.flush(npack)
 | 
			
		||||
            end
 | 
			
		||||
            return
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    -- 发派奖励
 | 
			
		||||
    local conf = CommonCDKeyConf[code]
 | 
			
		||||
    local aid = Actor.getActorId(pActor)
 | 
			
		||||
    SendMail(aid, conf.mailtitle or "兑换码", conf.mailcontent or "兑换码兑换成功!", conf.awards)
 | 
			
		||||
 | 
			
		||||
    -- 记录使用
 | 
			
		||||
    local data = getActorData(pActor)
 | 
			
		||||
    data.codeTimes[code] = (data.codeTimes[code] or 0) + 1
 | 
			
		||||
 | 
			
		||||
    -- 回复使用结果
 | 
			
		||||
    local npack = DataPack.allocPacket(pActor, enMiscSystemID, sUseCdkey)
 | 
			
		||||
    if npack then
 | 
			
		||||
        DataPack.writeByte(npack, CODE_SUCCESS)
 | 
			
		||||
        DataPack.flush(npack)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--是否是通码
 | 
			
		||||
function isCommonKey(code)
 | 
			
		||||
    if CommonCDKeyConf and CommonCDKeyConf[code] then
 | 
			
		||||
        return true
 | 
			
		||||
    end
 | 
			
		||||
    return false
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- 客户端请求使用激活码
 | 
			
		||||
function OnUseCDKey(pActor, packet)
 | 
			
		||||
    print("[DEBUG] OnUseCDKey, PfId="..PfId)
 | 
			
		||||
 | 
			
		||||
    if OnCheckCanPlatform() == false then
 | 
			
		||||
        print("[DEBUG] OnUseCDKey, OnCheckCanPlatform() == false")
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    local code = DataPack.readString(packet)
 | 
			
		||||
    print("[DEBUG][Tip] OnUseCDKey: code = " .. code)
 | 
			
		||||
 | 
			
		||||
    if isCommonKey(code) then
 | 
			
		||||
        UseCommonCDKey(pActor, code)
 | 
			
		||||
    else
 | 
			
		||||
        UseCDKey(pActor,code)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
NetmsgDispatcher.Reg(enMiscSystemID, cUseCdkey, OnUseCDKey)
 | 
			
		||||
@@ -0,0 +1,358 @@
 | 
			
		||||
--module("PcDownLoadGift", package.seeall)
 | 
			
		||||
 | 
			
		||||
--[[
 | 
			
		||||
    微端功能 个人数据
 | 
			
		||||
    PcClientData = {
 | 
			
		||||
        pcGift
 | 
			
		||||
    }
 | 
			
		||||
]]
 | 
			
		||||
 | 
			
		||||
local FcmServiceHostHttp = "http://fcmds.sdo.com"  
 | 
			
		||||
local FcmServiceHost = "fcmds.sdo.com"   ---/http://fcmds.sdo.com/heartbeat //"devops.191game.com"
 | 
			
		||||
local FcmServicePort = "80"
 | 
			
		||||
local FcmHeartbeateUrl = "/heartbeat"
 | 
			
		||||
local FcmUseroffline = "/useroffline"
 | 
			
		||||
local FcmUseronline = "/useronline"
 | 
			
		||||
local Fcmappid = "1100012" 
 | 
			
		||||
 | 
			
		||||
local FcmSecretkey = "01mbv7nqqj4f34m7zjnd14a9zfamvphx"
 | 
			
		||||
local FcmAccounttype = 1
 | 
			
		||||
local FcmMerchant_name = "1_1100012_7429"
 | 
			
		||||
local FcmSignature_method = "MD5"
 | 
			
		||||
 | 
			
		||||
local FcmIpadd = "16777343"
 | 
			
		||||
local FcmSevPort = 443
 | 
			
		||||
 | 
			
		||||
PlatformConfig = NativeRewardConfig 
 | 
			
		||||
local PfId = System.getPfId()
 | 
			
		||||
 | 
			
		||||
function getActorPcClientData(pActor)
 | 
			
		||||
    if Actor.getEntityType(pActor) ~= enActor then
 | 
			
		||||
        assert(false)
 | 
			
		||||
    end
 | 
			
		||||
    local var = Actor.getStaticVar(pActor);
 | 
			
		||||
    if var.PcClientData == nil then
 | 
			
		||||
        var.PcClientData = {}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return var.PcClientData
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function OnPcDownLoadGift(pActor, packet)
 | 
			
		||||
    if PfId ~= nil and PlatformConfig.SPID ~= nil and table.getn(PlatformConfig.SPID) > 0 then
 | 
			
		||||
        --print("[Tip] [PlatformQQ] SendQQHallData ---------------------PfId:"..PfId.."--- SPID:"..PlatformConfig.SPID)
 | 
			
		||||
        local Can = 0
 | 
			
		||||
        for k, v in ipairs(PlatformConfig.SPID) do
 | 
			
		||||
           -- print(k,v)
 | 
			
		||||
            --print("[Tip] [NativeRewardConfig] NativeRewardConfig333 ---------------- SPID MSG:"..tostring(v))
 | 
			
		||||
            if tostring(PfId) == tostring(v) then
 | 
			
		||||
                Can = Can + 1
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
        --print("[Tip] [NativeRewardConfig] NativeRewardConfig444 ---------------- SPID count:"..tostring(Can))
 | 
			
		||||
        if Can == 0 then
 | 
			
		||||
            print("[Tip] [NativeRewardConfig] [非本平台活动]")
 | 
			
		||||
            return --非本平台活动
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    local data = getActorPcClientData(pActor)
 | 
			
		||||
    if data.pcGift then
 | 
			
		||||
        Actor.sendTipmsg(pActor, "|C:0xf56f00&T:已领取|", tstUI)
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    local conf = PlatformConfig
 | 
			
		||||
 | 
			
		||||
    if conf and conf.reward then
 | 
			
		||||
        CommonFunc.Awards.Give(pActor, conf.reward, GameLog.Log_PcGift)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    data.pcGift = 1;
 | 
			
		||||
    Actor.sendTipmsg(pActor, "|C:0xf56f00&T:领取成功|", tstUI)
 | 
			
		||||
    SendPcClientState(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 strTipm2 = string.format(conf.tips2,strName)
 | 
			
		||||
        System.broadcastTipmsgLimitLev(strTipm2, tstChatSystem)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function SendPcClientState(pActor)
 | 
			
		||||
    local npack = DataPack.allocPacket(pActor, enDefaultEntitySystemID, sPcClientDownLoadState)
 | 
			
		||||
    if npack then
 | 
			
		||||
        -- print("1111")
 | 
			
		||||
        local data = getActorPcClientData(pActor)
 | 
			
		||||
        DataPack.writeByte(npack, (data.pcGift or 0)) --
 | 
			
		||||
        DataPack.flush(npack)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
-- 回调
 | 
			
		||||
local function AfterGetHttpContent(paramPack, content, result) 
 | 
			
		||||
    local aid = paramPack[1]
 | 
			
		||||
    print("[Tip] [SQFcm] AfterGetHttpContent --------------------------aid:"..aid.."------------------- content:"..tostring(content))  
 | 
			
		||||
 | 
			
		||||
    --测试数据local strContent00 = "{\"return_code\":-10250031,\"return_message\":\"Server reject, no authority, remote ip is 49.234.73.200\",\"data\":{}}"
 | 
			
		||||
    
 | 
			
		||||
    local strPattern11 = "^(.*)(return_code%s*\"%s*)(%b:,)(.*)$"
 | 
			
		||||
    local strPattern22 = "^(.*)(return_message\"%s*:%s*)(%b\"\")(.*)$"
 | 
			
		||||
 | 
			
		||||
    --local strContent = "abcde  csdn = {博客}  csdn.net" 
 | 
			
		||||
    --local strPattern = "^(.*)(csdn%s*=%s*)(%b{})(.*)$" 
 | 
			
		||||
    --local strCapture1, strCapture2, strCapture3, strCapture4 = string.match(strContent, strPattern)
 | 
			
		||||
 
 | 
			
		||||
    --print("t------"..tostring(strCapture1).."------"..tostring(strCapture2).."------"..tostring(strCapture3).."------"..tostring(strCapture4))
 | 
			
		||||
    if result == 0 then
 | 
			
		||||
        local strCapture1, strCapture2, return_code, strCapture3, strCapture4 = string.match(content, strPattern11)
 | 
			
		||||
        local strCapture1, strCapture2, return_message, strCapture4 = string.match(content, strPattern22)
 | 
			
		||||
        --local return_code = string.match(strContent00,"return_code\":-(%a+),\"return")
 | 
			
		||||
        --local return_message = string.match(strContent00,"return_message\":\"(%a+)\",\"") 
 | 
			
		||||
        --code = (string.gsub(return_code, "^[%s\n\r\t]*(.-)[%s\n\r\t]*$", "%1"))
 | 
			
		||||
        --message = (string.gsub(return_message, "^[%s\n\r\t]*(.-)[%s\n\r\t]*$", "%1"))
 | 
			
		||||
        --code = string.match(return_code,":%s+,")
 | 
			
		||||
        --message = string.match(return_message, "\"%s+\"")
 | 
			
		||||
        print("[Tip] [SQFcm] AfterGetHttpContent ----------return_code:"..tostring(return_code) )
 | 
			
		||||
        print("[Tip] [SQFcm] AfterGetHttpContent ---------return_message:"..tostring(return_message) )  
 | 
			
		||||
        --print("[return_code-----------------------------------------------------------------------return_code:"..tostring(code) )
 | 
			
		||||
        --print("[return_message--------------------------------------------------------------------return_message:"..tostring(message) ) 
 | 
			
		||||
    end 
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function GetHttpContentOnline(paramPack, content, result) 
 | 
			
		||||
    local aid = paramPack[1]
 | 
			
		||||
    print("[Tip] [SQFcm] GetHttpContentOnline --------------------------aid:"..aid.."------------------- content:"..tostring(content)) 
 | 
			
		||||
 
 | 
			
		||||
    local strPattern11 = "^(.*)(return_code%s*\"%s*)(%b:,)(.*)$"
 | 
			
		||||
    local strPattern22 = "^(.*)(return_message\"%s*:%s*)(%b\"\")(.*)$"
 | 
			
		||||
 
 | 
			
		||||
    if result == 0 then
 | 
			
		||||
        local strCapture1, strCapture2, return_code, strCapture3, strCapture4 = string.match(content, strPattern11)
 | 
			
		||||
        local strCapture1, strCapture2, return_message, strCapture4 = string.match(content, strPattern22) 
 | 
			
		||||
        print("[Tip] [SQFcm] GetHttpContentOnline ----------return_code:"..tostring(return_code) )
 | 
			
		||||
        print("[Tip] [SQFcm] GetHttpContentOnline ---------return_message:"..tostring(return_message) ) 
 | 
			
		||||
        
 | 
			
		||||
        if(tostring(return_code) == ": 0,") then
 | 
			
		||||
 | 
			
		||||
            local strPattern33 = "^(.*)(remainingTime%s*\"%s*)(%b:,)(.*)$" 
 | 
			
		||||
           
 | 
			
		||||
            local str1, str2, remainingTime, str4 = string.match(content, strPattern33) 
 | 
			
		||||
            print("[Tip] [SQFcm] GetHttpContentOnline ----------remainingTime:"..tostring(remainingTime)) 
 | 
			
		||||
            if remainingTime == nil then
 | 
			
		||||
                return
 | 
			
		||||
            end      
 | 
			
		||||
            local sscount = string.len(remainingTime)
 | 
			
		||||
   
 | 
			
		||||
            if(sscount > 2) then 
 | 
			
		||||
                res = string.sub(remainingTime, 2, sscount - 1)   
 | 
			
		||||
                print("[GetHttpContentOnline---------------------------------remainingTime = :"..tostring(res))
 | 
			
		||||
                local remaining =  tonumber(res)
 | 
			
		||||
                local pActor = Actor.getActorById(actorid)
 | 
			
		||||
                --Actor.changeFcmTime(pActor, remaining) 
 | 
			
		||||
                print("[Tip] [SQFcm] GetHttpContentOnline ----------remainingTime"..tostring(remaining)) 
 | 
			
		||||
            end
 | 
			
		||||
      
 | 
			
		||||
        end     
 | 
			
		||||
    end 
 | 
			
		||||
end
 | 
			
		||||
-- 防沉迷
 | 
			
		||||
function OnFcmUseOnline(pActor, packet) 
 | 
			
		||||
    local ntype = DataPack.readByte(packet)
 | 
			
		||||
    local nMsg = DataPack.readByte(packet)
 | 
			
		||||
    local nSub = DataPack.readByte(packet)
 | 
			
		||||
    --local ServerIndex = DataPack.readint(packet) 
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOnline -------------------------id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub)  )
 | 
			
		||||
 
 | 
			
		||||
    --local AccountName = DataPack.readString(packet)
 | 
			
		||||
    --local code = DataPack.readString(packet)
 | 
			
		||||
    --print("[Tip] OnFcmUseOnline : code = " .. tostring(code).."name"..Actor.getName(pActor))
 | 
			
		||||
 | 
			
		||||
   --加入异步工作
 | 
			
		||||
   --local account = Actor.getAccount(pActor)
 | 
			
		||||
   --local aid = Actor.getActorId(pActor)
 | 
			
		||||
 | 
			
		||||
    --即时生成
 | 
			
		||||
    local eventtime = System.getCurrMiniTime()
 | 
			
		||||
    local match_eventtime = os.date("%Y-%m-%d %H:%M:%S", os.time()) 
 | 
			
		||||
    local characterid = Actor.getName(pActor);
 | 
			
		||||
    local PfId = System.getPfId()
 | 
			
		||||
    local SrvId = System.getServerId() 
 | 
			
		||||
    local account = 'om00748880396.pt'--Actor.getAccount(pActor)--盛趣正式账号 om00748880396.pt'om00748880396.pt'--
 | 
			
		||||
    local aid = Actor.getActorId(pActor)
 | 
			
		||||
    local str_guid = System.MD5(tostring(eventtime))
 | 
			
		||||
    --local nYear,  nMonth, nDay
 | 
			
		||||
	--System.getDate(nYear,  nMonth, nDay) 
 | 
			
		||||
    --local nHour, nMinute, nSecond, nMiliSecond
 | 
			
		||||
	--System.getTime(nHour, nMinute, nSecond, nMiliSecond) 
 | 
			
		||||
    --print("[OnFcmUseOnline--eventtime------------------------------------"..tostring(eventtime))
 | 
			
		||||
    --print("[OnFcmUseOnline--str_guid------------------------------------"..tostring(str_guid))
 | 
			
		||||
    --固定
 | 
			
		||||
    local reqSign = 'accounttype='..FcmAccounttype..'&appid='..Fcmappid..'&areaid='..'1'..'&characterid='..aid..'&endpointip='..FcmIpadd..'&endpointport='..FcmSevPort..'&eventtime='..match_eventtime..'&groupid='..SrvId..'&guid='..tostring(str_guid)..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'×tamp='..tostring(eventtime)..'&userid='..tostring(account)
 | 
			
		||||
    local reqSign1 = 'accounttype='..FcmAccounttype..'appid='..Fcmappid..'areaid='..'1'..'characterid='..aid..'endpointip='..FcmIpadd..'endpointport='..FcmSevPort..'eventtime='..match_eventtime..'groupid='..SrvId..'guid='..tostring(str_guid)..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)..'userid='..tostring(account)
 | 
			
		||||
 | 
			
		||||
    local sign = System.MD5(tostring(reqSign1..FcmSecretkey))
 | 
			
		||||
    --print("[OnFcmUseOnline--reqSign1-----------------reqSign1Size:-------------------"..string.len(tostring(reqSign1..FcmSecretkey)))
 | 
			
		||||
    
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOnline -------------------------reqSign:"..tostring(reqSign1)) 
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOnline -------------------------FcmSecretkey:"..tostring(FcmSecretkey)) 
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOnline -------------------------sign:"..tostring(sign)) 
 | 
			
		||||
 | 
			
		||||
    local req = FcmUseronline..'?'..reqSign..'&signature='..tostring(sign)
 | 
			
		||||
 | 
			
		||||
    AsyncWorkDispatcher.Add(
 | 
			
		||||
        {'GetHttpContent', FcmServiceHost, FcmServicePort, req},
 | 
			
		||||
        GetHttpContentOnline,
 | 
			
		||||
        {aid, 0}
 | 
			
		||||
    )
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function OnFcmUseOffline(pActor, packet)
 | 
			
		||||
    local ntype = DataPack.readByte(packet)
 | 
			
		||||
    local nMsg = DataPack.readByte(packet)
 | 
			
		||||
    local nSub = DataPack.readByte(packet) 
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOffline -------------------------id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub)  )
 | 
			
		||||
 
 | 
			
		||||
    --local code = DataPack.readString(packet)
 | 
			
		||||
    --print("[Tip] OnFcmUseOnline : code = " .. tostring(code).."name"..Actor.getName(pActor))
 | 
			
		||||
 | 
			
		||||
    --即时生成
 | 
			
		||||
    local eventtime = System.getCurrMiniTime()
 | 
			
		||||
    local match_eventtime = os.date("%Y-%m-%d %H:%M:%S", os.time()) 
 | 
			
		||||
    local characterid = Actor.getName(pActor);
 | 
			
		||||
    local PfId = System.getPfId()
 | 
			
		||||
    local SrvId = System.getServerId() 
 | 
			
		||||
    local account = 'om00748880396.pt'--Actor.getAccount(pActor)--'om00748880396.pt'--
 | 
			
		||||
    local aid = Actor.getActorId(pActor)
 | 
			
		||||
    local str_guid = System.MD5(tostring(eventtime)) 
 | 
			
		||||
    --print("[OnFcmUseOnline--str_guid------------------------------------"..tostring(str_guid))
 | 
			
		||||
    --固定
 | 
			
		||||
    local reqSign = 'accounttype='..FcmAccounttype..'&appid='..Fcmappid..'&areaid='..'1'..'&characterid='..aid..'&endpointip='..FcmIpadd..'&endpointport='..FcmSevPort..'&eventtime='..match_eventtime..'&groupid='..SrvId..'&guid='..tostring(str_guid)..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'×tamp='..tostring(eventtime)..'&userid='..tostring(account)
 | 
			
		||||
    local reqSign1 = 'accounttype='..FcmAccounttype..'appid='..Fcmappid..'areaid='..'1'..'characterid='..aid..'endpointip='..FcmIpadd..'endpointport='..FcmSevPort..'eventtime='..match_eventtime..'groupid='..SrvId..'guid='..tostring(str_guid)..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)..'userid='..tostring(account)
 | 
			
		||||
 | 
			
		||||
    local sign = System.MD5(tostring(reqSign1..FcmSecretkey))
 | 
			
		||||
    --print("[OnFcmUseOnline--reqSign1-----------------reqSign1Size:-------------------"..string.len(tostring(reqSign1..FcmSecretkey)))
 | 
			
		||||
    
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOffline -------------------------reqSign:"..tostring(reqSign1)) 
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOffline -------------------------FcmSecretkey:"..tostring(FcmSecretkey)) 
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseOffline -------------------------sign:"..tostring(sign)) 
 | 
			
		||||
 
 | 
			
		||||
    local req = FcmUseroffline..'?'..reqSign..'&signature='..tostring(sign)
 | 
			
		||||
  
 | 
			
		||||
    AsyncWorkDispatcher.Add(
 | 
			
		||||
        {'GetHttpContent', FcmServiceHost, FcmServicePort, req},
 | 
			
		||||
        AfterGetHttpContent,
 | 
			
		||||
        {aid, 0}
 | 
			
		||||
    )
 | 
			
		||||
end 
 | 
			
		||||
 | 
			
		||||
function OnFcmUseHeatbeat2(ppActor, packet) 
 | 
			
		||||
    local ntype = DataPack.readByte(packet)
 | 
			
		||||
    local nMsg = DataPack.readByte(packet)
 | 
			
		||||
    local nSub = DataPack.readByte(packet)
 | 
			
		||||
 | 
			
		||||
    local nCount = DataPack.readByte(packet)
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseHeatbeat2 -------------------------id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub) .."nCount:"..tostring(nCount) ) 
 | 
			
		||||
  
 | 
			
		||||
    local eventtime = System.getCurrMiniTime()
 | 
			
		||||
    local PfId = System.getPfId()
 | 
			
		||||
    local SrvId = System.getServerId() 
 | 
			
		||||
 | 
			
		||||
    --固定
 | 
			
		||||
    local reqSign = 'appid='..Fcmappid..'ip='..FcmIpadd..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)
 | 
			
		||||
    local reqSign1 = 'appid='..Fcmappid..'&ip='..FcmIpadd..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'×tamp='..tostring(eventtime)
 | 
			
		||||
 | 
			
		||||
    local msghead = "usersinfo=["
 | 
			
		||||
    local msgItem = ""
 | 
			
		||||
  	for i = 1,  nCount do
 | 
			
		||||
        --print("[OnFcmUseHeatbeat2----------------------------------------i:"..tostring(i))
 | 
			
		||||
        local actorid = DataPack.readUInt(packet)
 | 
			
		||||
        --print("[OnFcmUseHeatbeat2----------------------------------------i:"..tostring(actorid))
 | 
			
		||||
        local pActor = Actor.getActorById(actorid)
 | 
			
		||||
        print("[Tip] [SQFcm] OnFcmUseHeatbeat2 usersinfo---------------------- name:"..Actor.getName(pActor).."actorid:"..tostring(actorid)) 
 | 
			
		||||
        
 | 
			
		||||
        if pActor == nil then
 | 
			
		||||
            break
 | 
			
		||||
        end
 | 
			
		||||
        local characterid = Actor.getName(pActor);
 | 
			
		||||
        local account = 'om00748880396.pt'--Actor.getAccount(pActor)
 | 
			
		||||
        local aid = Actor.getActorId(pActor)
 | 
			
		||||
 | 
			
		||||
        msgItem = msgItem..'{\"areaid\":'..'1'..',\"groupid\":'..SrvId..',\"userid\":\"'..account..'\",\"accounttype\":'..FcmAccounttype..',\"characterid\":\"'..aid..'\"},'
 | 
			
		||||
        --if(i < nCount)
 | 
			
		||||
        --{
 | 
			
		||||
        --    msgItem = msgItem..','
 | 
			
		||||
        --}
 | 
			
		||||
  	end
 | 
			
		||||
    if msgItem == "" then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    local msg = msghead..msgItem..']'
 | 
			
		||||
 | 
			
		||||
    local sign = System.MD5(tostring(reqSign..msg..FcmSecretkey))
 | 
			
		||||
    local req = FcmHeartbeateUrl..'?'..reqSign1..'&signature='..tostring(sign)
 | 
			
		||||
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------reqSign:"..tostring(reqSign1))
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------FcmSecretkey:"..tostring(FcmSecretkey))
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------sign:"..tostring(sign))
 | 
			
		||||
 | 
			
		||||
	local str = string.format("POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n%s",  req, FcmServiceHost, string.len(msg), msg)
 | 
			
		||||
 | 
			
		||||
    ---AsyncWorkDispatcher.Add({'Test', 1,2},AfterGetHttpContent,{expect=1+1})
 | 
			
		||||
    AsyncWorkDispatcher.Add(
 | 
			
		||||
        {'PostHttpContent2', FcmServiceHost, FcmServicePort, str},
 | 
			
		||||
        AfterGetHttpContent,
 | 
			
		||||
        {aid, 0}
 | 
			
		||||
    )
 | 
			
		||||
    print("[Tip] [SQFcm] OnFcmUseHeatbeat -------------------------msghead:"..tostring(msghead))
 | 
			
		||||
end
 | 
			
		||||
function OnFcmUseHeatbeat(pActor, packet) 
 | 
			
		||||
    local ntype = DataPack.readByte(packet)
 | 
			
		||||
    local nMsg = DataPack.readByte(packet)
 | 
			
		||||
    local nSub = DataPack.readByte(packet)
 | 
			
		||||
   -- print("[OnFcmUseHeatbeat----------------------------------------------------------------------- id:"..tostring(ntype).."nMsg:"..tostring(nMsg).."nSub:"..tostring(nSub)  )
 | 
			
		||||
 | 
			
		||||
    local code = DataPack.readString(packet)
 | 
			
		||||
   -- print("[Tip] OnFcmUseOnline : code = " .. tostring(code).."name"..Actor.getName(pActor))
 | 
			
		||||
 
 | 
			
		||||
    --即时生成
 | 
			
		||||
    local eventtime = System.getCurrMiniTime()
 | 
			
		||||
    local characterid = Actor.getName(pActor);
 | 
			
		||||
    local PfId = System.getPfId()
 | 
			
		||||
    local SrvId = System.getServerId() 
 | 
			
		||||
    local account = Actor.getAccount(pActor)
 | 
			
		||||
    local aid = Actor.getActorId(pActor)
 | 
			
		||||
    --固定
 | 
			
		||||
    local reqSign = 'appid='..Fcmappid..'ip='..FcmIpadd..'merchant_name='..tostring(FcmMerchant_name)..'signature_method='..tostring(FcmSignature_method)..'timestamp='..tostring(eventtime)
 | 
			
		||||
    local reqSign1 = 'appid='..Fcmappid..'&ip='..FcmIpadd..'&merchant_name='..tostring(FcmMerchant_name)..'&signature_method='..tostring(FcmSignature_method)..'×tamp='..tostring(eventtime)
 | 
			
		||||
 | 
			
		||||
    local msg = 'usersinfo=[{\"areaid\":'..'1'..',\"groupid\":'..SrvId..',\"userid\":\"'..account..'\",\"accounttype\":'..FcmAccounttype..',\"characterid\":\"'..aid..'\"}]'
 | 
			
		||||
 | 
			
		||||
    local sign = System.MD5(tostring(reqSign..msg..FcmSecretkey))
 | 
			
		||||
    local req = FcmHeartbeateUrl..'?'..reqSign1..'&signature='..tostring(sign)
 | 
			
		||||
 | 
			
		||||
   -- print("[OnFcmUseHeatbeat--reqSign1------------------------------------"..tostring(reqSign1))
 | 
			
		||||
    --print("[OnFcmUseHeatbeat--FcmSecretkey------------------------------------"..tostring(FcmSecretkey))
 | 
			
		||||
    --print("[OnFcmUseHeatbeat--sign------------------------------------"..tostring(sign))
 | 
			
		||||
 | 
			
		||||
	local str = string.format("POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\n\r\n%s",  req, FcmServiceHost, string.len(msg), msg)
 | 
			
		||||
 | 
			
		||||
    ---AsyncWorkDispatcher.Add({'Test', 1,2},AfterGetHttpContent,{expect=1+1})
 | 
			
		||||
    AsyncWorkDispatcher.Add(
 | 
			
		||||
        {'PostHttpContent2', FcmServiceHost, FcmServicePort, str},
 | 
			
		||||
        AfterGetHttpContent,
 | 
			
		||||
        {aid, 0}
 | 
			
		||||
    )
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
NetmsgDispatcher.Reg(enDefaultEntitySystemID, cGetPcClientDownLoadGift, OnPcDownLoadGift)
 | 
			
		||||
-- 防沉迷
 | 
			
		||||
NetmsgDispatcher.Reg(enMiscSystemID, sFcmUseOnline, OnFcmUseOnline)
 | 
			
		||||
NetmsgDispatcher.Reg(enMiscSystemID, sFcmUseOffline, OnFcmUseOffline)
 | 
			
		||||
--NetmsgDispatcher.Reg(enMiscSystemID, sFcmUseHeatbeat, OnFcmUseHeatbeat)
 | 
			
		||||
NetmsgDispatcher.Reg(enMiscSystemID, sFcmAllUseHeatbeat, OnFcmUseHeatbeat2)
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
--lua script
 | 
			
		||||
--#include "data\config\friend\FriendConfig.txt" once
 | 
			
		||||
 | 
			
		||||
--<2D><><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
 | 
			
		||||
function SendCanAddFriendList(sysarg,args)
 | 
			
		||||
	--print("SendCanAddFriendList...")
 | 
			
		||||
	local nLevel = args[2]
 | 
			
		||||
	local nFlag = false
 | 
			
		||||
	for i=1,table.getn(FriendConfig.PromptLevel) do
 | 
			
		||||
		if nLevel == FriendConfig.PromptLevel[i] then
 | 
			
		||||
			nFlag = true
 | 
			
		||||
			break
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	if nFlag == true then
 | 
			
		||||
		Actor.sendCanAddFriendList(sysarg, 
 | 
			
		||||
			FriendConfig.LevelInterval[1], FriendConfig.LevelInterval[2],
 | 
			
		||||
			FriendConfig.MaxNum)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
@@ -0,0 +1,61 @@
 | 
			
		||||
--#include "data\config/guild/Notice.config" once --
 | 
			
		||||
--领取沙巴克奖励
 | 
			
		||||
local function getSbkData()
 | 
			
		||||
    local var = System.getStaticVar();
 | 
			
		||||
    return var.SbkAwardFlag
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function setSbkAwardFlag(nFlag)
 | 
			
		||||
    local var = System.getStaticVar();
 | 
			
		||||
    var.SbkAwardFlag = nFlag;
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function  HandleGetSBKAward(pActor, packet)
 | 
			
		||||
    if Actor.getEntityType(pActor) ~= enActor then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    local errorcode = 0;
 | 
			
		||||
    while(true) 
 | 
			
		||||
    do
 | 
			
		||||
        local guild = Actor.getGuildPtr(pActor);
 | 
			
		||||
        if guild == nil then
 | 
			
		||||
            errorcode = 1;
 | 
			
		||||
            break;
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        local isSbk = Actor.MyGuildIsSbk(pActor);
 | 
			
		||||
        if isSbk == 0 then
 | 
			
		||||
            errorcode = 2;
 | 
			
		||||
            break;
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        local nGuildPos = Actor.getGuildPos(pActor);
 | 
			
		||||
        local cfg = NoticeConfig[nGuildPos];
 | 
			
		||||
        if cfg == nil then
 | 
			
		||||
            errorcode = 3;
 | 
			
		||||
            break;
 | 
			
		||||
        end
 | 
			
		||||
        local nFlag = getSbkData();
 | 
			
		||||
        if nFlag then
 | 
			
		||||
            errorcode = 4;
 | 
			
		||||
            break;
 | 
			
		||||
        end
 | 
			
		||||
        if Actor.isActivityRunning(pActor, (cfg.ActivityID or 0)) or Actor.isActivityRunning(pActor, (cfg.ActivityID2 or 0)) then
 | 
			
		||||
            errorcode = 5;
 | 
			
		||||
            break;
 | 
			
		||||
        end
 | 
			
		||||
        if cfg.noticereward then
 | 
			
		||||
            CommonFunc.Awards.Give(pActor, cfg.noticereward, GameLog.Log_SBKaward, "沙巴克领奖")
 | 
			
		||||
        end
 | 
			
		||||
        setSbkAwardFlag(1);
 | 
			
		||||
        break;
 | 
			
		||||
    end
 | 
			
		||||
    -- 回复使用结果
 | 
			
		||||
    local npack = DataPack.allocPacket(pActor, enGuildSystemID, sGuildGetSbkAward)
 | 
			
		||||
    if npack then
 | 
			
		||||
        DataPack.writeByte(npack, errorcode)
 | 
			
		||||
        DataPack.flush(npack)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
NetmsgDispatcher.Reg(enGuildSystemID, cGuildGetSbkAward, HandleGetSBKAward)
 | 
			
		||||
@@ -0,0 +1,290 @@
 | 
			
		||||
--英雄系统
 | 
			
		||||
--#include "data\config\Hero\HeroConfig.txt" once
 | 
			
		||||
 | 
			
		||||
--人物升级时判断是否自动给予英雄
 | 
			
		||||
function AutoAddHero(sysarg,level)
 | 
			
		||||
    print("[DEBUG] AutoAddHero, level="..level)
 | 
			
		||||
    for k,v in ipairs(HeroConfig.HeroList) do
 | 
			
		||||
	    if level >= v.OpenLevel and v.AutoGet == true then
 | 
			
		||||
		    local hasHero = Hero.getHeroProperty(sysarg,k,0)
 | 
			
		||||
			if hasHero == 0 then
 | 
			
		||||
			    if Hero.canAddHero(sysarg,false) == true then
 | 
			
		||||
				    --添加英雄和技能
 | 
			
		||||
	                Hero.addHero(sysarg,k,1,1)
 | 
			
		||||
					HeroLearnSkill(sysarg,k,1)	
 | 
			
		||||
					Actor.sendTipmsg(sysarg, OldLang.Script.Hero006, ttFlyTip)
 | 
			
		||||
	            end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--英雄经验是否已满
 | 
			
		||||
function HeroExpIsFull(sysarg,AddExp)
 | 
			
		||||
    local nHeroId = Hero.getBattleHeroId(sysarg)
 | 
			
		||||
	if nHeroId == -1  then
 | 
			
		||||
        nHeroId = 1
 | 
			
		||||
    end
 | 
			
		||||
	local Stage = Hero.getHeroProperty(sysarg,nHeroId,enHeroStage)
 | 
			
		||||
	if Stage == 0 then
 | 
			
		||||
	    return false
 | 
			
		||||
	end
 | 
			
		||||
	local Level = Hero.getHeroProperty(sysarg,nHeroId,enHeroLevel)
 | 
			
		||||
	local Exp   = Hero.getHeroProperty(sysarg,nHeroId,enHeroExp)
 | 
			
		||||
	local cfg = HeroConfig.HeroList[nHeroId]
 | 
			
		||||
	if not cfg then
 | 
			
		||||
	    return false
 | 
			
		||||
	end
 | 
			
		||||
	local LevelCfg = cfg.Levels[Level]
 | 
			
		||||
	local StageCfg = cfg.Stages[Stage]
 | 
			
		||||
	if not StageCfg or not LevelCfg then
 | 
			
		||||
	    return false
 | 
			
		||||
	end
 | 
			
		||||
	local MaxLevel = StageCfg.MaxLevel 
 | 
			
		||||
	local MaxExp = LevelCfg.LevelUpExp
 | 
			
		||||
	if  Level == MaxLevel  and ((Exp + AddExp) >= MaxExp) then
 | 
			
		||||
	    return true
 | 
			
		||||
	end
 | 
			
		||||
    return false
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--英雄升级
 | 
			
		||||
function HeroLevelUp(sysarg)
 | 
			
		||||
    local nHeroId = Hero.getBattleHeroId(sysarg)
 | 
			
		||||
	if nHeroId == -1  then
 | 
			
		||||
        nHeroId = 1
 | 
			
		||||
    end
 | 
			
		||||
	local Stage = Hero.getHeroProperty(sysarg,nHeroId,enHeroStage)
 | 
			
		||||
	if Stage == 0 then
 | 
			
		||||
	    return false
 | 
			
		||||
	end
 | 
			
		||||
	local Level = Hero.getHeroProperty(sysarg,nHeroId,enHeroLevel)
 | 
			
		||||
	local nExp = 0 
 | 
			
		||||
    for i=1,#HeroConfig.HeroExpConfig  do
 | 
			
		||||
	    nExp = nExp + UseHeroLevlUpItem(sysarg, nHeroId, HeroConfig.HeroExpConfig[i].itemid, HeroConfig.HeroExpConfig[i].exp)
 | 
			
		||||
	end
 | 
			
		||||
	local NewLevel = Hero.getHeroProperty(sysarg,nHeroId,enHeroLevel)
 | 
			
		||||
	local AddLevel = NewLevel - Level 
 | 
			
		||||
	if nExp > 0 then
 | 
			
		||||
	    if AddLevel > 0 then
 | 
			
		||||
			Actor.sendTipmsg(sysarg, string.format(OldLang.Script.Hero013,nExp,AddLevel), ttFlyTip)
 | 
			
		||||
		else
 | 
			
		||||
			Actor.sendTipmsg(sysarg, string.format(OldLang.Script.Hero012,nExp), ttFlyTip)
 | 
			
		||||
		end    
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function UseHeroLevlUpItem(sysarg, nHeroId,itemidx,ItemExp)
 | 
			
		||||
    local count = Actor.getItemCount(sysarg, itemidx)
 | 
			
		||||
	if count == 0  then return 0 end
 | 
			
		||||
	--判断英雄等级是否已经到了本阶最高等级
 | 
			
		||||
	local Stage = Hero.getHeroProperty(sysarg,nHeroId,enHeroStage)
 | 
			
		||||
	local Level = Hero.getHeroProperty(sysarg,nHeroId,enHeroLevel)
 | 
			
		||||
	local Exp   = Hero.getHeroProperty(sysarg,nHeroId,enHeroExp)
 | 
			
		||||
	local cfg = HeroConfig.HeroList[nHeroId]
 | 
			
		||||
	if not cfg then
 | 
			
		||||
	    return 0 
 | 
			
		||||
	end
 | 
			
		||||
	local LevelCfg = cfg.Levels[Level]
 | 
			
		||||
	local StageCfg = cfg.Stages[Stage]
 | 
			
		||||
	if not StageCfg or not LevelCfg then
 | 
			
		||||
	    return 0
 | 
			
		||||
	end
 | 
			
		||||
	local MaxLevel = StageCfg.MaxLevel 
 | 
			
		||||
	local MaxExp = LevelCfg.LevelUpExp
 | 
			
		||||
	if  Level == MaxLevel  and Exp >=  MaxExp then
 | 
			
		||||
	    return 0
 | 
			
		||||
	end
 | 
			
		||||
	local canAddExp = MaxExp - Exp
 | 
			
		||||
	if Level < MaxLevel then
 | 
			
		||||
		for idx = Level + 1, MaxLevel do
 | 
			
		||||
			LevelCfg = cfg.Levels[idx]
 | 
			
		||||
			canAddExp = canAddExp + LevelCfg.LevelUpExp
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	local useCount = math.ceil(canAddExp/ItemExp)
 | 
			
		||||
	if useCount > count then
 | 
			
		||||
		useCount = count
 | 
			
		||||
	end
 | 
			
		||||
	local logId,logStr = 303,"HeroExp"
 | 
			
		||||
 | 
			
		||||
	useCount = Actor.removeItem(sysarg,itemidx,useCount,-1,-1,-1,logStr,logId)
 | 
			
		||||
	if useCount > 0 then
 | 
			
		||||
		local addExp = ItemExp * useCount
 | 
			
		||||
		if addExp > canAddExp then
 | 
			
		||||
			addExp = canAddExp
 | 
			
		||||
		end
 | 
			
		||||
		Hero.addExp(sysarg, addExp,nHeroId)
 | 
			
		||||
		return addExp
 | 
			
		||||
	end
 | 
			
		||||
	return 0
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--英雄进阶
 | 
			
		||||
function HeroUpStage(sysarg,heroid,stage,bless,count)
 | 
			
		||||
    --BaseFuc_Print("HeroUpStage:", heroid,stage,bless)
 | 
			
		||||
    if count <= 0 then
 | 
			
		||||
    	return
 | 
			
		||||
    end
 | 
			
		||||
    local ybReplace = true
 | 
			
		||||
    if count == 1 then
 | 
			
		||||
    	ybReplace = false
 | 
			
		||||
    end
 | 
			
		||||
    local HeroCfg  = HeroConfig.HeroList[heroid]
 | 
			
		||||
	if not HeroCfg then
 | 
			
		||||
	    return
 | 
			
		||||
	end
 | 
			
		||||
	local StageCfg = HeroCfg.Stages[stage]
 | 
			
		||||
	if not StageCfg then
 | 
			
		||||
	    return
 | 
			
		||||
	end
 | 
			
		||||
	--已达最高阶
 | 
			
		||||
	local NewStageCfg = HeroCfg.Stages[stage+1]
 | 
			
		||||
	if  not NewStageCfg then
 | 
			
		||||
	    Actor.sendTipmsg(sysarg, OldLang.Script.Hero001, ttFlyTip)
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local oldbless = bless
 | 
			
		||||
	local realCount  = count
 | 
			
		||||
	local Succ = false
 | 
			
		||||
	for i=1,count do
 | 
			
		||||
		if not CheckConsumeCondReplaceEx(sysarg, StageCfg.Consumes, i, ybReplace) then
 | 
			
		||||
			realCount = i-1
 | 
			
		||||
			break 
 | 
			
		||||
		end
 | 
			
		||||
		--如果祝福值已满,进阶必成功,否则按几率提升
 | 
			
		||||
		if bless >= StageCfg.MaxBless then
 | 
			
		||||
		    Succ = true
 | 
			
		||||
		    realCount = i
 | 
			
		||||
		    break
 | 
			
		||||
	    else
 | 
			
		||||
		    local RandNum = System.getRandomNumber(10000)
 | 
			
		||||
			if RandNum <= GetStageSuccRate(StageCfg.SuccRate,bless) then
 | 
			
		||||
			    Succ = true
 | 
			
		||||
			    realCount = i
 | 
			
		||||
			    break
 | 
			
		||||
			else
 | 
			
		||||
			    bless = bless + GetStageUpBless(StageCfg.AddBless)
 | 
			
		||||
				if bless > StageCfg.MaxBless then
 | 
			
		||||
				    bless = StageCfg.MaxBless
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	if realCount <=  0 then
 | 
			
		||||
		return 
 | 
			
		||||
	end
 | 
			
		||||
	Actor.sendTipmsg(sysarg, string.format(OldLang.Script.Hero010,realCount), ttTipmsgWindow)
 | 
			
		||||
    if not Succ then
 | 
			
		||||
    	 Actor.sendTipmsg(sysarg, string.format(OldLang.Script.Hero011,bless-oldbless), ttTipmsgWindow)
 | 
			
		||||
    end
 | 
			
		||||
	local logId, logStr = 92, "HeroStageUp"
 | 
			
		||||
	if UseConsumeCondReplaceEx(sysarg, StageCfg.Consumes, realCount, ybReplace, logId, logStr) ~= true then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	if Succ then
 | 
			
		||||
	    local newStage = stage + 1
 | 
			
		||||
	    Hero.StageUp(sysarg, heroid,newStage,0)
 | 
			
		||||
		Actor.sendTipmsg(sysarg, string.format(OldLang.Script.Hero002,newStage), ttFlyTip)
 | 
			
		||||
		--升阶成功,自动学习技能
 | 
			
		||||
		HeroLearnSkill(sysarg,heroid,newStage)
 | 
			
		||||
		local broadcast = StageCfg.broadcast or false
 | 
			
		||||
		if broadcast then
 | 
			
		||||
		    local msg = string.format(OldLang.Script.Hero008,Actor.getName(sysarg),newStage)
 | 
			
		||||
		    System.broadcastTipmsg(msg, ttScreenCenter + ttChatWindow,HeroCfg.OpenLevel)
 | 
			
		||||
		end
 | 
			
		||||
    else
 | 
			
		||||
	    Hero.StageUp(sysarg,heroid,stage,bless)
 | 
			
		||||
		Actor.sendTipmsg(sysarg, OldLang.Script.Hero003, ttFlyTip)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetStageSuccRate(cfg,bless)
 | 
			
		||||
    for k,v in ipairs(cfg) do 
 | 
			
		||||
	    if bless >= v.Min and bless <= v.Max then
 | 
			
		||||
		    return v.rate
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	return 0
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetStageUpBless(cfg)
 | 
			
		||||
    local nMin,nMax = cfg[1], cfg[2]
 | 
			
		||||
	local rand = System.getRandomNumber(nMax - nMin) + nMin
 | 
			
		||||
    return rand
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--英雄学习技能
 | 
			
		||||
function  HeroLearnSkill(sysarg,heroid,stage)
 | 
			
		||||
    local HeroCfg = HeroConfig.HeroList[heroid]
 | 
			
		||||
	if not HeroCfg then
 | 
			
		||||
	    return 
 | 
			
		||||
	end
 | 
			
		||||
    for k, v in ipairs(HeroCfg.Skills) do
 | 
			
		||||
	    if v.stage == stage and  Hero.getSkillLevel(sysarg,heroid, v.skillid) <= 0 then
 | 
			
		||||
	        local flag = Hero.learnSkill(sysarg,heroid,v.skillid)
 | 
			
		||||
	        if flag then
 | 
			
		||||
	            Actor.sendTipmsg(sysarg, OldLang.Script.Hero007, ttFlyTip)
 | 
			
		||||
	        end
 | 
			
		||||
	    end
 | 
			
		||||
    end		
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--英雄技能升级
 | 
			
		||||
function HeroUpSkill(sysarg,heroid,skillid,level)
 | 
			
		||||
    --BaseFuc_Print("HeroUpSkill:",heroid,skillid,level)
 | 
			
		||||
    local cfg = GetHeroSKill(heroid,skillid)
 | 
			
		||||
	if not cfg then
 | 
			
		||||
	    return
 | 
			
		||||
	end
 | 
			
		||||
	local LevelCfg = cfg.Levels[level]
 | 
			
		||||
	if not LevelCfg then
 | 
			
		||||
	    return
 | 
			
		||||
	end
 | 
			
		||||
	--所需阶
 | 
			
		||||
	local stage = Hero.getHeroProperty(sysarg,heroid,enHeroStage)
 | 
			
		||||
	if stage < LevelCfg.stage then
 | 
			
		||||
	    Actor.sendTipmsg(sysarg, string.format(OldLang.Script.Hero004,LevelCfg.stage), ttFlyTip)
 | 
			
		||||
		return 
 | 
			
		||||
	end
 | 
			
		||||
	--消耗
 | 
			
		||||
	if CommonFunc.Consumes.Check(sysarg, LevelCfg.Consumes) ~= true then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local logId, logStr = 91, "HeroSkillUp"
 | 
			
		||||
	if CommonFunc.Consumes.Remove(sysarg, LevelCfg.Consumes, logId, logStr) ~= true then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	Hero.skillLevelUp(sysarg,heroid,skillid)
 | 
			
		||||
	Actor.sendTipmsg(sysarg, OldLang.Script.Hero005, ttFlyTip)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function GetHeroSKill(heroid,skillid)
 | 
			
		||||
	if not HeroConfig.HeroList[heroid] then
 | 
			
		||||
	   return nil
 | 
			
		||||
	end
 | 
			
		||||
	for k,v in ipairs(HeroConfig.HeroList[heroid].Skills) do
 | 
			
		||||
	    if v.skillid == skillid then
 | 
			
		||||
		    return v
 | 
			
		||||
		end
 | 
			
		||||
    end
 | 
			
		||||
	return nil
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--英雄给人物加BUFF
 | 
			
		||||
function  HeroAddBuffToOwner(sysarg,heroid,skillid,skilllevel)
 | 
			
		||||
    local SkillCfg = GetHeroSKill(heroid,skillid)
 | 
			
		||||
	if not SkillCfg then
 | 
			
		||||
	    return
 | 
			
		||||
	end
 | 
			
		||||
	local SkillLevelCfg = SkillCfg.Levels[skilllevel] or nil
 | 
			
		||||
	if not SkillLevelCfg then
 | 
			
		||||
	    return
 | 
			
		||||
	end
 | 
			
		||||
	local BuffCfg = SkillLevelCfg.Buff or nil
 | 
			
		||||
	if BuffCfg then
 | 
			
		||||
	    for i=1,#BuffCfg do
 | 
			
		||||
		    Actor.addBuffById(sysarg, BuffCfg[i])
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
@@ -0,0 +1,36 @@
 | 
			
		||||
module("Fee", package.seeall)
 | 
			
		||||
 | 
			
		||||
-- 玩家产生付费
 | 
			
		||||
function OnFeeCmd(pActor, sPfId, sProdId, nNum)
 | 
			
		||||
    print("[DEBUG][OnFeeCmd] "..Actor.getName(pActor).." sPfId:"..(sPfId or "none").." sProdId:"..(sProdId or "none").." nNum:"..(nNum or 1))
 | 
			
		||||
    if ProdItemMapConf and ProdItemMapConf[sPfId] then
 | 
			
		||||
        local IDMap = ProdItemMapConf[sPfId][sProdId]
 | 
			
		||||
        if IDMap and IDMap.ItemId then
 | 
			
		||||
            local ItemId = IDMap.ItemId
 | 
			
		||||
 | 
			
		||||
            --直接购买元宝
 | 
			
		||||
            if ItemId < 200 then
 | 
			
		||||
                local conf = RechargeConf[ItemId]
 | 
			
		||||
                if conf then
 | 
			
		||||
                    local rechargeNum = conf.Num
 | 
			
		||||
                    Actor.changeMoney(pActor, mtYuanbao, rechargeNum, GameLog.Log_Recharge, "充值")
 | 
			
		||||
                    print("[OnFeeCmd] "..Actor.getName(pActor).." 充值元宝: "..rechargeNum)
 | 
			
		||||
                    return true
 | 
			
		||||
                end
 | 
			
		||||
            --直接购买礼包物品
 | 
			
		||||
            elseif ItemId <= 300 then
 | 
			
		||||
                local conf = GiftItemConf[ItemId]
 | 
			
		||||
                if conf and conf.Items then
 | 
			
		||||
                    CommonFunc.Awards.Give(pActor, conf.Items, GameLog.Log_Recharge, "充值")
 | 
			
		||||
                    print("[OnFeeCmd] "..Actor.getName(pActor).." 购买礼包: "..ItemId)
 | 
			
		||||
                    return true
 | 
			
		||||
                end
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
    elseif sProdId == "gold" then --无配置平台的,直接充值nNum元宝数
 | 
			
		||||
        Actor.changeMoney(pActor, mtYuanbao, nNum, GameLog.Log_Recharge, "充值")
 | 
			
		||||
        print("[OnFeeCmd] "..Actor.getName(pActor).." 充值元宝: "..nNum)
 | 
			
		||||
        return true
 | 
			
		||||
    end
 | 
			
		||||
    return false
 | 
			
		||||
end
 | 
			
		||||
@@ -0,0 +1,174 @@
 | 
			
		||||
--回收元宝
 | 
			
		||||
--回收 19-6
 | 
			
		||||
-- 获取玩家的 recover 数据
 | 
			
		||||
local function getYbActorData(pActor)
 | 
			
		||||
    if Actor.getEntityType(pActor) ~= enActor then
 | 
			
		||||
        assert(false)
 | 
			
		||||
    end
 | 
			
		||||
    local var = Actor.getStaticVar(pActor);
 | 
			
		||||
    if var.YBRecoverData == nil then
 | 
			
		||||
        var.YBRecoverData = {}
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return var.YBRecoverData
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function getUseTimeData(pActor, nIdx, nType)
 | 
			
		||||
    local data = getYbActorData(pActor);
 | 
			
		||||
    if data.daily == nil then
 | 
			
		||||
        data.daily = {}
 | 
			
		||||
    end
 | 
			
		||||
    if data.forever == nil then
 | 
			
		||||
        data.forever = {}
 | 
			
		||||
    end
 | 
			
		||||
    if nType == 1 then
 | 
			
		||||
        return data.daily[nIdx] or 0
 | 
			
		||||
    else
 | 
			
		||||
        return data.forever[nIdx] or 0
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function AddUsetimeData(pActor, nIdx, nType)
 | 
			
		||||
    local data = getYbActorData(pActor);
 | 
			
		||||
    if data.daily == nil then
 | 
			
		||||
        data.daily = {}
 | 
			
		||||
    end
 | 
			
		||||
    if data.forever == nil then
 | 
			
		||||
        data.forever = {}
 | 
			
		||||
    end
 | 
			
		||||
    if nType == 1 then
 | 
			
		||||
        data.daily[nIdx] = (data.daily[nIdx] or 0) + 1
 | 
			
		||||
    else
 | 
			
		||||
        data.forever[nIdx] = (data.forever[nIdx] or 0) + 1
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function  HandleRecoverItem(pActor, packet)
 | 
			
		||||
    if Actor.getEntityType(pActor) ~= enActor then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    local nId = DataPack.readInt(packet)
 | 
			
		||||
    local errorcode = 0;
 | 
			
		||||
    local nOpenDay = System.getDaysSinceOpenServer();
 | 
			
		||||
    local recoverCfg = YBrecoverConfig[nId];
 | 
			
		||||
    local nLeftTime = 0;
 | 
			
		||||
    while(true) 
 | 
			
		||||
    do
 | 
			
		||||
        if recoverCfg == nil then
 | 
			
		||||
            errorcode = 1;
 | 
			
		||||
            break;
 | 
			
		||||
        end
 | 
			
		||||
        if recoverCfg.recoverlimit then
 | 
			
		||||
            if Actor.checkActorLevel(pActor, recoverCfg.recoverlimit.level or 0, recoverCfg.recoverlimit.zsLevel or 0) ~= true then
 | 
			
		||||
                errorcode = 2;
 | 
			
		||||
                break;
 | 
			
		||||
            end
 | 
			
		||||
 | 
			
		||||
            if nOpenDay < recoverCfg.recoverlimit.openDay then
 | 
			
		||||
                errorcode = 3;
 | 
			
		||||
                break;
 | 
			
		||||
            end
 | 
			
		||||
            if recoverCfg.daylimit > 0 then
 | 
			
		||||
                if nOpenDay > (recoverCfg.recoverlimit.openDay + recoverCfg.daylimit - 1) then
 | 
			
		||||
                    errorcode = 4;
 | 
			
		||||
                    break;
 | 
			
		||||
                end
 | 
			
		||||
            end
 | 
			
		||||
            if recoverCfg.timeslimit > 0 then
 | 
			
		||||
                if recoverCfg.timeslimit <= getUseTimeData(pActor, recoverCfg.id, recoverCfg.dayclear or 0) then
 | 
			
		||||
                    errorcode = 5;
 | 
			
		||||
                    break;
 | 
			
		||||
                end
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        local nActorRight = Actor.GetMaxColorCardLevel(pActor);
 | 
			
		||||
        if nActorRight < recoverCfg.privilegelimit then
 | 
			
		||||
            errorcode = 6;
 | 
			
		||||
            break;
 | 
			
		||||
        end
 | 
			
		||||
        local item = recoverCfg.item
 | 
			
		||||
        if item and CommonFunc.Consumes.CheckActorSources(pActor, item,tstUI) ~= true then
 | 
			
		||||
            errorcode = 7;
 | 
			
		||||
            break
 | 
			
		||||
        end
 | 
			
		||||
        if item and CommonFunc.Consumes.Remove(pActor, item, GameLog.Log_YBRecover, "回收给元宝") ~= true then
 | 
			
		||||
            errorcode = 8
 | 
			
		||||
            break
 | 
			
		||||
        end 
 | 
			
		||||
        local nAward = recoverCfg.privilegeaward[nActorRight]
 | 
			
		||||
        if nAward then
 | 
			
		||||
            if CommonFunc.Awards.Give(pActor, nAward, GameLog.Log_YBRecover, "回收给元宝") ~= true  then 
 | 
			
		||||
                errorcode = 9 
 | 
			
		||||
                break
 | 
			
		||||
            end 
 | 
			
		||||
        end
 | 
			
		||||
        nLeftTime = recoverCfg.timeslimit
 | 
			
		||||
        if recoverCfg.timeslimit > 0 then
 | 
			
		||||
            AddUsetimeData(pActor, recoverCfg.id, (recoverCfg.dayclear or 0));
 | 
			
		||||
            nLeftTime = recoverCfg.timeslimit - getUseTimeData(pActor, recoverCfg.id, (recoverCfg.dayclear or 0));
 | 
			
		||||
        end
 | 
			
		||||
        break;
 | 
			
		||||
    end
 | 
			
		||||
    -- 回复使用结果
 | 
			
		||||
    local npack = DataPack.allocPacket(pActor, enBasicFunctionsSystemID, enYBRecoverResult)
 | 
			
		||||
    if npack then
 | 
			
		||||
        -- print("errorcode"..errorcode)
 | 
			
		||||
        DataPack.writeByte(npack, errorcode)
 | 
			
		||||
        DataPack.writeInt(npack, nId)
 | 
			
		||||
        DataPack.writeInt(npack, nLeftTime)
 | 
			
		||||
        DataPack.flush(npack)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--列表 19-7
 | 
			
		||||
function ClientGetData(pActor, packet)
 | 
			
		||||
    local nCount = 0;
 | 
			
		||||
 | 
			
		||||
    local recoverCfg = YBrecoverConfig;
 | 
			
		||||
    local nOpenDay = System.getDaysSinceOpenServer();
 | 
			
		||||
 | 
			
		||||
    if recoverCfg then
 | 
			
		||||
        for _, cfg in ipairs(recoverCfg) do
 | 
			
		||||
            if cfg.timeslimit > 0 or cfg.daylimit > 0 then
 | 
			
		||||
                DataPack.writeInt(packet, cfg.id);
 | 
			
		||||
                local nLeftTime = cfg.daylimit
 | 
			
		||||
                if cfg.daylimit > 0 then
 | 
			
		||||
                    local nLeftDay = cfg.recoverlimit.openDay + cfg.daylimit - nOpenDay;
 | 
			
		||||
                    local todaytime = System.getToday() + nLeftDay*24*3600;
 | 
			
		||||
	 			    local nNowTime = System.getRealtimeMiniTime();
 | 
			
		||||
                    nLeftTime = todaytime - nNowTime;
 | 
			
		||||
                    if nLeftTime < 0 then
 | 
			
		||||
                        nLeftTime = 0
 | 
			
		||||
                    end
 | 
			
		||||
                    -- print("openday.."..cfg.recoverlimit.openDay.."..cfg.daylimit.."..cfg.daylimit.."oop.."..nOpenDay)
 | 
			
		||||
                end
 | 
			
		||||
 | 
			
		||||
                DataPack.writeInt(packet, nLeftTime);
 | 
			
		||||
                local nLeftTimes = cfg.timeslimit
 | 
			
		||||
                if cfg.timeslimit > 0 then
 | 
			
		||||
                    local nUseCount = getUseTimeData(pActor, cfg.id, (cfg.dayclear or 0));
 | 
			
		||||
                    nLeftTimes = cfg.timeslimit - nUseCount;
 | 
			
		||||
                end
 | 
			
		||||
 | 
			
		||||
                DataPack.writeShort(packet, nLeftTimes);
 | 
			
		||||
                nCount = nCount + 1;
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
    return nCount;
 | 
			
		||||
end
 | 
			
		||||
function OnNewDayArrive(pActor)
 | 
			
		||||
    local ybData = getYbActorData(pActor);
 | 
			
		||||
    if ybData == nil then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if ybData.daily == nil then
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    ybData.daily = nil
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
NetmsgDispatcher.Reg(enBasicFunctionsSystemID, enYBRecover, HandleRecoverItem)
 | 
			
		||||
ActorEventDispatcher.Reg(aeNewDayArrive, OnNewDayArrive, "YBRecover.lua")
 | 
			
		||||
@@ -0,0 +1,173 @@
 | 
			
		||||
--翅膀系统
 | 
			
		||||
--#include "data\config\AlmirahSystem\WingCfg.txt" once
 | 
			
		||||
--#include "data\functions\Common\CommonMisc.txt" once
 | 
			
		||||
 | 
			
		||||
--直接下一级的概率获取
 | 
			
		||||
function getNextWingRand(nLv, nLuck)
 | 
			
		||||
	local cfg = WingCfg.directLv[nLv]
 | 
			
		||||
	if(cfg == nil or type(nLuck) ~= 'number')then
 | 
			
		||||
		print("getNextWingRand", cfg, nLuck)
 | 
			
		||||
		return 0 
 | 
			
		||||
	end
 | 
			
		||||
	for k,v in pairs(cfg)do
 | 
			
		||||
		if( nLuck <= v[1] )then
 | 
			
		||||
			return v[2]
 | 
			
		||||
		end	
 | 
			
		||||
	end
 | 
			
		||||
	return 0
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--直接本次提升增加的幸运值
 | 
			
		||||
function getLuckWingRand(nLv)
 | 
			
		||||
	local cfg = WingCfg.level[nLv]
 | 
			
		||||
	if(cfg == nil or cfg.LuckRand == nil)then
 | 
			
		||||
		print("getLuckWingRand", nLv)
 | 
			
		||||
		return 0 
 | 
			
		||||
	end
 | 
			
		||||
	local nMinRand = cfg.LuckRand[1]
 | 
			
		||||
	local nMaxRand = cfg.LuckRand[2] - nMinRand
 | 
			
		||||
	local randNum =  System.getRandomNumber(nMaxRand) + nMinRand
 | 
			
		||||
	return randNum, cfg.LuckValue
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--先检查够不够
 | 
			
		||||
function ItemWingLogicCheck(sysarg, consumes)
 | 
			
		||||
    --消耗检查
 | 
			
		||||
	for k,v in pairs(consumes) do
 | 
			
		||||
		local bCheck = Actor.checkConsume(sysarg, v.type, v.id, v.count, v.quality or 0, v.strong or 0, -1 , 0) 
 | 
			
		||||
		if bCheck ~= true then
 | 
			
		||||
			Actor.sendAwardNotEnough(sysarg, v.type, v.id, v.count)
 | 
			
		||||
			return false
 | 
			
		||||
		end
 | 
			
		||||
	end	
 | 
			
		||||
	return true
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--翅膀吞噬
 | 
			
		||||
function WingDevour(sysarg, ...)
 | 
			
		||||
	local nModelId = arg[1]
 | 
			
		||||
	local btType = arg[2]		--元宝替代
 | 
			
		||||
	--BaseFuc_Print("Enter WingDevour",nModelId)	
 | 
			
		||||
	if(Actor.getActivation(sysarg, nModelId) == true)then
 | 
			
		||||
		return Actor.sendTipmsg(sysarg,OldLang.Script.WingActivation02,ttFlyTip)
 | 
			
		||||
	end	
 | 
			
		||||
	local logId = 180
 | 
			
		||||
	local logStr = OldLang.Log.LogWingActivation	
 | 
			
		||||
	local nLv = Actor.getIntProperty( sysarg, PROP_ACTOR_WING_LV ) + 1
 | 
			
		||||
	if(nLv < 1 or #WingCfg.consumes < nLv)then	--等级条件检测
 | 
			
		||||
		return	BaseFuc_Print(#WingCfg.consumes,nLv)
 | 
			
		||||
	end
 | 
			
		||||
	local consumes = WingCfg.consumes[nLv]	
 | 
			
		||||
	
 | 
			
		||||
	local  nPrice =  WingCfg.level[nLv].Yb
 | 
			
		||||
	local consumesList = {}
 | 
			
		||||
	for k,v in pairs(consumes)do
 | 
			
		||||
		local csm = {type = v.type, id = v.id, count = v.count, quality = qualitytem, strong = v.strong, bind = v.bind}	
 | 
			
		||||
		if(v.type == 0)then			--道具
 | 
			
		||||
			if(btType == 1)then		--元宝替代
 | 
			
		||||
				local myCount = Actor.getItemCount(sysarg, v.id) 
 | 
			
		||||
				if(myCount < v.count )then 
 | 
			
		||||
					local money = {type = 10, id = 0, count = (v.count-myCount)*nPrice , quality = 0, strong = 0, bind = -1}
 | 
			
		||||
					csm.count = myCount
 | 
			
		||||
					table.insert(consumesList,money)
 | 
			
		||||
				end
 | 
			
		||||
			end		
 | 
			
		||||
			table.insert(consumesList,csm)
 | 
			
		||||
		else
 | 
			
		||||
			table.insert(consumesList,csm)
 | 
			
		||||
		end
 | 
			
		||||
	end	
 | 
			
		||||
	if(SubBatchItemByType(sysarg, consumesList, logId, logStr) ~= true)then
 | 
			
		||||
		return print("btType",btType)
 | 
			
		||||
	end
 | 
			
		||||
	--[[
 | 
			
		||||
	if ItemWingLogicCheck(sysarg, consumesList)~= true then
 | 
			
		||||
		return print("ItemWingLogicCheck")
 | 
			
		||||
	end
 | 
			
		||||
	if CommonFunc.Consumes.Remove(sysarg, consumesList, logId,logStr) ~= true then
 | 
			
		||||
		return print("Remove")
 | 
			
		||||
	end	
 | 
			
		||||
	]]
 | 
			
		||||
	local nLuckPoint = Actor.getIntProperty( sysarg, PROP_ACTOR_WINGPOINT )
 | 
			
		||||
	local nRand = getNextWingRand(nLv, nLuckPoint)
 | 
			
		||||
	local randNum =  System.getRandomNumber(WingCfg.nMaxRand)+1	
 | 
			
		||||
	local bLevel = false
 | 
			
		||||
	if(randNum <= nRand )then			--随机升级
 | 
			
		||||
		bLevel = true
 | 
			
		||||
	end
 | 
			
		||||
	local nAddLuck,LuckValue = getLuckWingRand(nLv)
 | 
			
		||||
	nLuckPoint = nLuckPoint + nAddLuck 
 | 
			
		||||
	if(LuckValue <= nLuckPoint)then		--最大幸运值升级
 | 
			
		||||
		bLevel = true
 | 
			
		||||
	end
 | 
			
		||||
	--BaseFuc_Print("nLuckPoint,LuckValue",nLuckPoint,LuckValue)
 | 
			
		||||
	if(bLevel == true)then
 | 
			
		||||
		Actor.setUIntProperty(sysarg, PROP_ACTOR_WING_LV, nLv)
 | 
			
		||||
		WingActivation(sysarg, nModelId)
 | 
			
		||||
		Actor.setUIntProperty(sysarg, PROP_ACTOR_WINGPOINT, 0)
 | 
			
		||||
		WingDayMatch(sysarg,nLv) --每日竞技,进阶翅膀
 | 
			
		||||
	else
 | 
			
		||||
		Actor.setUIntProperty(sysarg, PROP_ACTOR_WINGPOINT, nLuckPoint)
 | 
			
		||||
	end	
 | 
			
		||||
	Actor.collectOperate(sysarg,0)			--刷新属性
 | 
			
		||||
	--OnOpenServerActWingAct(sysarg, nLv)	--开服活动激活翅膀
 | 
			
		||||
	--BaseFuc_Print("nLv",nLv)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--获得当前等级配置和进度百分比
 | 
			
		||||
function getWingCfgAndPercent(nLevel)
 | 
			
		||||
	local cfg,percent
 | 
			
		||||
	for i,curCfg in ipairs(WingCfg.level) do
 | 
			
		||||
		if curCfg.WingLevel > nLevel then
 | 
			
		||||
			cfg = curCfg
 | 
			
		||||
			local preWingLevel = 0
 | 
			
		||||
			local preWcfg = WingCfg.level[i-1]
 | 
			
		||||
			if preWcfg then
 | 
			
		||||
				preWingLevel = preWcfg.WingLevel
 | 
			
		||||
			end
 | 
			
		||||
			percent = math.floor(100/(curCfg.WingLevel - preWingLevel))* (nLevel - preWingLevel)
 | 
			
		||||
			break
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
	return cfg,percent
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--激活翅膀
 | 
			
		||||
function WingActivation(sysarg, nModelId)
 | 
			
		||||
	--BaseFuc_Print("Enter WingActivation")
 | 
			
		||||
	if(Actor.getActivation(sysarg, nModelId) == true)then
 | 
			
		||||
		return Actor.sendTipmsg(sysarg,OldLang.Script.WingActivation02,ttFlyTip)
 | 
			
		||||
	end
 | 
			
		||||
	local cfg = WingCfg.level[nModelId]
 | 
			
		||||
	if(cfg == nil)then
 | 
			
		||||
		return
 | 
			
		||||
	end
 | 
			
		||||
	local strNotice = cfg.strNotice
 | 
			
		||||
	Actor.setActivation(sysarg,nModelId)
 | 
			
		||||
	if(strNotice)then
 | 
			
		||||
		local sNotice = string.format(strNotice,Actor.getName(sysarg))
 | 
			
		||||
		System.broadcastTipmsg(sNotice, ttScreenCenter + ttChatWindow)	
 | 
			
		||||
	end
 | 
			
		||||
	--BaseFuc_Print("Sucess")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function ClearActorWingDailyData(sysarg)
 | 
			
		||||
	local nLv = Actor.getIntProperty( sysarg, PROP_ACTOR_WING_LV ) + 1
 | 
			
		||||
	if(WingCfg.ClearLv <= nLv)then
 | 
			
		||||
		Actor.setUIntProperty(sysarg, PROP_ACTOR_WINGPOINT, 0)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- @DebugLua 1001 1 1
 | 
			
		||||
function GMTestWing(sysarg,arg1,arg2)
 | 
			
		||||
	--BaseFuc_Print(arg1,arg2)
 | 
			
		||||
	if(arg1 == 0)then	--GM 激活一个翅膀
 | 
			
		||||
		Actor.setActivation(sysarg,arg2)
 | 
			
		||||
	end
 | 
			
		||||
	if(arg1 == 1)then	--GM 升级一个翅膀
 | 
			
		||||
		WingDevour(sysarg,arg2, 1)
 | 
			
		||||
	end	
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user