Просмотр исходного кода

1.增加在线奖励活动 2.修改公会bug 3.增加战斗buff-liuxue2

gitxsm 1 год назад
Родитель
Сommit
33075f7205

+ 2 - 0
script/common/Lang.lua

@@ -40,6 +40,8 @@ COMMON_COMFIG_ERROR = [[配置错误]]
 COMMON_MAXLEVEL = [[已达到最高等级]]
 COMMON_ITEM_NOT_ENOUGH = [[道具不足]]
 COMMON_TYPE_ERROR = [[类型错误]]
+COMMON_TIME_NOT_ENOUGH = [[时间不足]]
+COMMON_DAY_RECHARGE_NOT_ENOUGH = [[当日充值金额不足]]
 
 --------------------------------------------------
 

+ 1 - 0
script/common/LogDefine.lua

@@ -264,6 +264,7 @@ DEFINE = {
 	lotteryByDiamonds		= 753,			--古玉充能
 	talisman				= 754,			--秘宝
 	duobaoqibing			= 755,			--夺宝奇兵
+	OnlineAwardLogic 		= 756,			-- 在线奖励
 }
 
 

+ 5 - 0
script/common/ProtoID.lua

@@ -1331,3 +1331,8 @@ _ENV[1352]="CG_DBQB_TIPS"
 _ENV[1353]="GC_DBQB_TIPS"
 _ENV[1354]="CG_DRAWCARD_GET_RECOMMEND_LINEUP"
 _ENV[1355]="GC_DRAWCARD_GET_RECOMMEND_LINEUP"
+_ENV[1360]="CG_ONLINEAWARD_QUERY"
+_ENV[1361]="GC_ONLINEAWARD_QUERY"
+_ENV[1362]="CG_ONLINEAWARD_CLAIM"
+
+

+ 2 - 1
script/core/ObjHuman.lua

@@ -88,6 +88,7 @@ local WarOrder = require("shop.WarOrder")
 local OpenServerActPowerUp = require("present.OpenServerActPowerUp")
 local VoucherShopLogic = require("voucher.VoucherShopLogic")
 local RacialTrialLogic = require("racialTrial.RacialTrialLogic")
+local OnlineAwardLogic = require("present.OnlineAwardLogic")
 
 local Json = require("common.Json")
 
@@ -790,7 +791,7 @@ function updateDaily(human, isGm)
     UnionRedBagLogic.updateDaily(human)
 	JjcGodWarLogic.updateDaily(human)
 	RacialTrialLogic.updateDaily(human)
-
+	OnlineAwardLogic.NewUpdateDaily(human)
 	-- 红点 发送  理论放最后
 	RoleSystemLogic.onLogin(human)
 end

+ 1 - 1
script/module/combat/BeSkill.lua

@@ -1047,7 +1047,7 @@ function onAddBuffer(obj,buffer)
 	local conf = BufferExcel[buffer.id]
 	local attacker = CombatImpl.objList[buffer.attackPos]
 	local cmd = conf.cmd
-	if cmd == "hurt" or cmd == "liuxue" or cmd == "zhongdu" or cmd == "ranshao" then
+	if cmd == "hurt" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "ranshao" then
 		if obj.beSkillList[BESKILL_TYPE10] then
 			for _,v in ipairs(obj.beSkillList[BESKILL_TYPE10]) do
 				use(obj,{attacker},v)

+ 42 - 2
script/module/combat/CombatBuff.lua

@@ -16,7 +16,7 @@ local ProjectLogic = require("platform.ProjectLogic")
 
 --和血量相关的作用
 local function isHpCmd(cmd)
-	if cmd == "hp" or cmd == "hurt" or cmd == "hurt1" or cmd == "liuxue" or cmd == "zhongdu" or cmd == "ranshao" or cmd == "ranshao1" or cmd == "huiheYinji" then
+	if cmd == "hp" or cmd == "hurt" or cmd == "hurt1" or cmd == "liuxue" or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "ranshao" or cmd == "ranshao1" or cmd == "huiheYinji" then
 		return true
 	end
 	return false
@@ -135,6 +135,7 @@ CMD2KEY = {
 	["ranshao"] = RoleDefine.STATUS_MIANYI_RATE5,
 	["ranshao1"] = RoleDefine.STATUS_MIANYI_RATE5,
 	["liuxue"] = RoleDefine.STATUS_MIANYI_RATE6,
+	["liuxue2"] = RoleDefine.STATUS_MIANYI_RATE6,
 	["zhongdu"] = RoleDefine.STATUS_MIANYI_RATE7,
     ["hunluan"] = RoleDefine.STATUS_MIANYI_RATE9,
 }
@@ -1285,6 +1286,35 @@ local function chixuHurtDel(target,buffer)
 	end
 	return hurt
 end
+
+--处理器, 实时计算伤害
+local function chixuHurtDel2(target,buffer)
+	local id = buffer.id
+	local conf = BufferExcel.buffer[id]
+	local attackPos = buffer.attackPos
+	local attacker
+	if attackPos > CombatDefine.COMBAT_HERO_ALL_CNT then
+		attacker = CombatImpl.helpList[attackPos]
+	else
+		attacker = CombatImpl.objList[attackPos]
+	end
+	local isAddHp = conf.cmd == "hp"
+	buffer.arg = CombatCalc.calcBufferHp(attacker,target,id,isAddHp)
+
+
+    local hurt = buffer.arg
+	local hurtDelRate = target.attr[RoleDefine.CHIXU_HURT_DEL_RATE] / 10000
+    --持续类buff 伤害加成
+    -- local attacker = CombatImpl.objList[buffer.attackPos]
+    -- local conf = BufferExcel.buffer[buffer.id]
+    local beSkillHurtRate = BeSkill.getBuffChixuHurt(attacker, conf.cmd)
+	hurtDelRate = hurtDelRate > 1 and 1 or hurtDelRate
+	if hurtDelRate > 0 or beSkillHurtRate > 0 then
+		hurt = hurt * (1 - hurtDelRate + beSkillHurtRate)
+	end
+	return hurt
+end
+
 handler = {}
 
 
@@ -1343,6 +1373,7 @@ function handler.hp(target, buffer,conf)
 	buffer.attrs[RoleDefine.HP_COMBAT] = hp
 	HANDLER_ONCE["hp"] = target.pos
 end
+
 --流血
 function handler.liuxue(target, buffer,conf)
 	local hurt = chixuHurtDel(target,buffer)
@@ -1350,6 +1381,15 @@ function handler.liuxue(target, buffer,conf)
 	buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
 	onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
 end
+
+--流血2
+function handler.liuxue2(target, buffer,conf)
+	local hurt = chixuHurtDel2(target,buffer)
+	local d = CombatObj.updateHp(target, -hurt, nil, nil, buffer.attackPos,CombatObj.BUFFER_HP_TYPE)
+	buffer.attrs[RoleDefine.HP_COMBAT] = -hurt
+	onExtraCombatRecord(buffer.attackPos,hurt,"liuxue")
+end
+
 --中毒
 function handler.zhongdu(target, buffer,conf)
 	local hurt = chixuHurtDel(target,buffer)
@@ -1543,7 +1583,7 @@ function qingsuan(target)
 		local buffer = target.buffer[j]
 		local conf = BufferExcel.buffer[buffer.id]
 		local cmd = conf.cmd
-		if cmd == "ranshao" or cmd == "ranshao1" or cmd == "liuxue" or cmd == "zhongdu" or cmd == "hurt" or cmd == "hurt1" then
+		if cmd == "ranshao" or cmd == "ranshao1" or cmd == "liuxue"or cmd == "liuxue2" or cmd == "zhongdu" or cmd == "hurt" or cmd == "hurt1" then
 			round = 1
 			if buffer.round and buffer.round > 0 then
 				round = buffer.round

+ 10 - 0
script/module/combat/CombatObj.lua

@@ -491,6 +491,11 @@ function getStatusHurtRate(attacker,defender)
 	if status["liuxue"] then
 		extraHurtRate = extraHurtRate + attr[RoleDefine.STATUS_HURT_RATE6]
 	end
+
+	if status["liuxue2"] then
+		extraHurtRate = extraHurtRate + attr[RoleDefine.STATUS_HURT_RATE6]
+	end
+
 	if status["zhongdu"] then
 		extraHurtRate = extraHurtRate + attr[RoleDefine.STATUS_HURT_RATE7]
 	end
@@ -523,6 +528,9 @@ function getStatusBaoji(attacker,defender)
 	if status["liuxue"] then
 		baoji = baoji + attr[RoleDefine.STATUS_BAOJI_RATE6]
 	end
+	if status["liuxue2"] then
+		baoji = baoji + attr[RoleDefine.STATUS_BAOJI_RATE6]
+	end
 	if status["zhongdu"] then
 		baoji = baoji + attr[RoleDefine.STATUS_BAOJI_RATE7]
 	end
@@ -551,6 +559,8 @@ function getStatusBaojiHurtRate(attacker,defender)
 		baoji = baoji + attr[RoleDefine.STATUS_BAOJI_HURT_RATE5]
 	elseif status["liuxue"] then
 		baoji = baoji + attr[RoleDefine.STATUS_BAOJI_HURT_RATE6]
+	elseif status["liuxue2"] then
+		baoji = baoji + attr[RoleDefine.STATUS_BAOJI_HURT_RATE6]
 	elseif status["zhongdu"] then
 		baoji = baoji + attr[RoleDefine.STATUS_BAOJI_HURT_RATE7]
 	elseif status["jiansu"] then

+ 12 - 0
script/module/present/Handler.lua

@@ -36,6 +36,7 @@ local OpenServerActPowerUp = require("present.OpenServerActPowerUp")
 local esteemGift = require("present.esteemGift")
 local hugeRecharge = require("present.hugeRecharge")
 local OpenServerActAddUpCharge = require("present.OpenServerActAddUpCharge")
+local OnlineAwardLogic = require("present.OnlineAwardLogic")
 
 -- 充值-特权商店
 function CG_TEQUANSHOP_QUERY(human)
@@ -370,3 +371,14 @@ end
 function CG_PRESENT_OPEN_ADDUP_CHARGE_GETPRIZE(human, msg)
     OpenServerActAddUpCharge.ActAddUpCharge_GetPrize(human, msg.nID)
 end
+
+
+-------------------------------在线奖励活动----------------------------------
+function CG_ONLINEAWARD_QUERY(human, msg)
+    OnlineAwardLogic.Query(human)
+end
+
+--领奖
+function CG_ONLINEAWARD_CLAIM(human, msg)
+    OnlineAwardLogic.ClaimAward(human)
+end

+ 371 - 0
script/module/present/OnlineAwardLogic.lua

@@ -0,0 +1,371 @@
+--在线奖励活动
+
+--db
+--[=[
+    human.db.OnlineRewardData = {
+        haveTime = nil,       --活动获得时间, 即首充时间
+        dailyData = {       --每日数据,key为当前时间距离 haveTime 的天数
+            [1] = {
+                [1] = nil,  --记录当天某个档位奖励的领取情况, key 为档位,有记录表示已经领取了(不可领取和可领取两种状态不存db)
+                [2] = nil,
+            },
+            [2] = {
+                [1] = nil,
+                [2] = nil,
+            },
+        }
+    }
+]=]--
+
+local Msg = require("core.Msg")
+local Grid = require("bag.Grid")
+local Util = require("common.Util")
+local BagLogic = require("bag.BagLogic")
+local Broadcast = require("broadcast.Broadcast")
+local Lang = require("common.Lang")
+local onlineAardCfg = require("excel.onlineAward").onlineAward
+local YunYingLogic = require("yunying.YunYingLogic")
+local PanelDefine = require("broadcast.PanelDefine")
+local Timer = require("core.Timer")
+
+
+--分钟转秒
+local TIMEBASE = 60
+
+--一天的秒数
+local DAYSEC = 86400
+
+--本活动日志标识
+local LOGTYPE = "OnlineAwardLogic"
+
+--是否在线
+IsOnline = false
+
+--活动ID
+local ACTID = 18001
+
+
+--检查活动获得时间, 如果没有初始化则初始化
+local function checkHaveTime(human)
+    local OnlineRewardData = human.db.OnlineRewardData
+    if not OnlineRewardData or not OnlineRewardData.haveTime then
+        human.db.OnlineRewardData = human.db.OnlineRewardData or {}
+        human.db.OnlineRewardData.haveTime = os.time()
+    end
+end
+
+--计算当天到目前为止的总在线时长
+local function calcTotalOnlineTime(human)
+    local lastOnlineTime = human.db.onlineTimeDay or 0
+    local loginTime = human.db.lastLoginTime
+
+    --可能存在玩家在线跨天情况,需要判断登录时间与当前时间是否属于同一天,如果不是, 那么在此活动中,当天的登录时间应该为当天0点
+    local now = os.time()
+    if not Util.isSameDay(loginTime) then
+        loginTime = Util.getDayStartTime(now)
+    end
+
+    local totalOnlineTime = now - loginTime + lastOnlineTime
+    return totalOnlineTime
+end
+
+--获取当前时间距离startTime相差多少天
+local function getDiffDay(startTime)
+    local passDay = Util.diffDay(startTime) + 1
+    return passDay
+end
+
+--是否获得该活动
+local function isHaveAct(human)
+    local topupAcount = human.db.topupAcount
+    if topupAcount and topupAcount > 0 then
+        return true
+    end
+    return false
+end
+
+--计算下一个未获得奖励需要的在线时间
+local function calcLeftTime(human)
+    local OnlineRewardData = human.db.OnlineRewardData
+    local targetDay = getDiffDay(OnlineRewardData.haveTime)
+    local targetCfg = onlineAardCfg[targetDay]
+
+    if not targetCfg then
+        return
+    end
+
+    local leftTime = 0
+    local totalNeedTime = 0
+    local timeCfg = targetCfg.onlineTimeVec
+    local totalOnlineTime = calcTotalOnlineTime(human)
+
+    for _, needTime in ipairs(timeCfg) do
+        totalNeedTime = totalNeedTime + needTime * TIMEBASE
+        if totalNeedTime > totalOnlineTime then
+            leftTime = totalNeedTime - totalOnlineTime
+            break
+        end
+    end
+    return leftTime
+end
+
+--返回可领取奖励的index Vec
+local function getCanReceiveAwardVec(human, isRed)
+    local OnlineRewardData = human.db.OnlineRewardData
+    local dailyData = OnlineRewardData.dailyData
+
+    local targetDay = getDiffDay(OnlineRewardData.haveTime)
+    local targetCfg = onlineAardCfg[targetDay]
+    local todayRecordData = dailyData and dailyData[targetDay]
+
+    if not targetCfg then
+        if not isRed then
+            Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
+        end
+        return
+    end
+
+    --充值金额是否符合
+    local topupAcountDaily = human.db.topupAcountDaily
+    if not topupAcountDaily or topupAcountDaily < targetCfg.needRecharge then
+        if not isRed then
+            Broadcast.sendErr(human, Lang.COMMON_DAY_RECHARGE_NOT_ENOUGH)
+        end
+        return
+    end
+
+    local totalNeedTime = 0
+    local cfgOnlineTimeVec = targetCfg.onlineTimeVec
+    local totalOnlineTime = calcTotalOnlineTime(human)
+
+    local len = 0
+    local awardIdxVec = {}
+
+    for idx, needTime in ipairs(cfgOnlineTimeVec) do
+        totalNeedTime = totalNeedTime + needTime * TIMEBASE
+        if totalOnlineTime >= totalNeedTime and (not todayRecordData or not todayRecordData[idx]) then
+            len = len + 1
+            awardIdxVec[len] = idx
+        end
+    end
+
+    if len == 0 then
+        return
+    end
+    return awardIdxVec
+end
+
+--定时器任务
+local function timeFunc(human)
+    if not IsOnline then
+        return
+    end
+
+    local leftTime = calcLeftTime(human)
+    if leftTime and leftTime > 0 then
+        local now = os.time()
+        local todayStartTi = Util.getDayStartTime(now)
+        local nextDayStartTi = todayStartTi + DAYSEC
+
+        --只有需要挂机时间 + 当前时间 < 下一天0点, 那么才加定时器
+        if leftTime + now < nextDayStartTi then
+            Timer.addLater(leftTime, function ()
+                Query(human)
+                --红点更新
+                YunYingLogic.updateIcon(YYInfo[ACTID], human, true)
+                timeFunc(human)
+            end)
+        end
+    end
+end
+
+
+--红点判断
+function isRed(human, YYInfo, funcConfig)
+    if not isHaveAct(human) then
+        return false
+    end
+    if not getCanReceiveAwardVec(human, true) then
+        return false
+    end
+    return true
+end
+
+
+--是否开启(外部调用)
+function isOpen(human)
+    if not isHaveAct(human) then
+        return false
+    end
+
+    local OnlineRewardData = human.db.OnlineRewardData
+    local targetDay = getDiffDay(OnlineRewardData.haveTime)
+    local targetCfg = onlineAardCfg[targetDay]
+    --配置错误或者已经超过配置里的天数了都不显示
+    if not targetCfg then
+        return false
+    end
+    return true
+end
+
+
+--登录
+function onLogin(human, actID)
+    if not isHaveAct(human) then
+        return
+    end
+
+    IsOnline = true
+
+    checkHaveTime(human)
+
+    timeFunc(human)
+end
+
+--下线
+function onLogout(human, funcID, parameter, parameter2)
+    IsOnline = false
+end
+
+--跨天
+function updateDaily(human, funcID)
+    checkHaveTime(human)
+end
+
+--新跨天函数,这里用新的跨天函数是因为ObjHuman.lua中 重置每日在线时间代码会晚于运营活动中的 updateDaily()执行
+--这个活动中,会用到每日在线时间,所以需要重新定义一个跨天函数,在重置每日在线时间后再执行
+function NewUpdateDaily(human)
+    if not isHaveAct(human) then
+        return
+    end
+
+    if IsOnline then
+        --针对玩家在线跨天情况,下发一次最新数据
+        Query(human)
+        timeFunc(human)
+    end
+end
+
+
+--充值
+function onCharge(human, price)
+    local OnlineRewardData = human.db.OnlineRewardData
+    if not OnlineRewardData or not OnlineRewardData.haveTime then
+        checkHaveTime(human)
+        timeFunc(human)
+        YunYingLogic.updateIcon(YYInfo[ACTID], human, true)
+    end
+
+    OnlineRewardData = human.db.OnlineRewardData
+    local targetDay = getDiffDay(OnlineRewardData.haveTime)
+    local targetCfg = onlineAardCfg[targetDay]
+
+    local topupAcountDaily = human.db.topupAcountDaily
+    if topupAcountDaily and topupAcountDaily >= targetCfg.needRecharge then
+        Query(human)
+    end
+
+    return true
+end
+
+
+--查询
+function Query(human)
+    if not isHaveAct(human) then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local OnlineRewardData = human.db.OnlineRewardData
+    local dailyData = OnlineRewardData.dailyData
+
+    local targetDay = getDiffDay(OnlineRewardData.haveTime)
+    local targetCfg = onlineAardCfg[targetDay]
+    local todayData = dailyData and dailyData[targetDay]
+
+    if not targetCfg then
+        return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
+    end
+
+    local timeCfg = targetCfg.onlineTimeVec
+    local awardCfg = targetCfg.awardVec
+
+    if #timeCfg ~= #awardCfg then
+        return Broadcast.sendErr(human, Lang.COMMON_COMFIG_ERROR)
+    end
+
+    local len = 0
+    local totalNeedTime = 0
+    local totalOnlineTime = calcTotalOnlineTime(human)
+
+    local msgRet = Msg.gc.GC_ONLINEAWARD_QUERY
+    msgRet.leftTime = 0
+    msgRet.needRecharge = targetCfg.needRecharge
+
+    msgRet.isReach = 0
+    local topupAcountDaily = human.db.topupAcountDaily
+    if topupAcountDaily and topupAcountDaily >= targetCfg.needRecharge then
+        msgRet.isReach = 1
+    end
+
+
+    local msgAwardVec = msgRet.awardVec
+    msgAwardVec[0] = 0
+
+    for idx, needTime in ipairs(timeCfg) do
+        len = len + 1
+        msgAwardVec[len].state = 0
+        Grid.makeItem(msgAwardVec[len].itemInfo, awardCfg[idx][1], awardCfg[idx][2])
+        totalNeedTime = totalNeedTime + needTime * TIMEBASE
+        if totalOnlineTime >= totalNeedTime then
+            msgAwardVec[len].state = 1
+            if todayData and todayData[idx] then
+                msgAwardVec[len].state = 2
+            end
+        else
+            if msgRet.leftTime == 0 then
+                msgRet.leftTime = totalNeedTime - totalOnlineTime
+            end
+        end
+    end
+    msgAwardVec[0] = len
+
+    Msg.send(msgRet, human.fd)
+end
+
+
+--领奖
+function ClaimAward(human)
+    if not isHaveAct(human) then
+        return Broadcast.sendErr(human, Lang.YUNYING_ERR_TIME)
+    end
+
+    local awardIdxVec = getCanReceiveAwardVec(human)
+    if not awardIdxVec then
+        return
+    end
+
+    local OnlineRewardData = human.db.OnlineRewardData
+    local targetDay = getDiffDay(OnlineRewardData.haveTime)
+
+    OnlineRewardData.dailyData = OnlineRewardData.dailyData or {}
+    OnlineRewardData.dailyData[targetDay] = OnlineRewardData.dailyData[targetDay] or {}
+    local todayRecoedData = OnlineRewardData.dailyData[targetDay]
+
+    local len = 0
+    local awardVec = {}
+    local targetCfg = onlineAardCfg[targetDay]
+    local awardCfg = targetCfg.awardVec
+
+    for _, idx in ipairs(awardIdxVec) do
+        len = len + 1
+        awardVec[len] = {awardCfg[idx][1], awardCfg[idx][2]}
+        todayRecoedData[idx] = true
+    end
+    BagLogic.addItemList(human, awardVec, LOGTYPE)
+
+    --下发数据更新
+    Query(human)
+
+    --红点更新
+    YunYingLogic.updateIcon(YYInfo[ACTID], human, true)
+end

+ 25 - 1
script/module/present/Proto.lua

@@ -989,4 +989,28 @@ GC_PRESEN_OPEN_ADDUP_CHARGE_QUERY =
 -- 请求领取累计充值活动奖励
 CG_PRESENT_OPEN_ADDUP_CHARGE_GETPRIZE = {
     {"nID",             1,      "int"},         -- 领取奖励ID
-}
+}
+
+
+---------------------------在线奖励-------------------------
+SINGLE_AWARD_INFO = {
+    {"itemInfo",       1,  ItemData},
+    {"state",          1,  "byte"},        -- 0 不可领取, 1-可领取,  2-已领取
+}
+
+
+--查询
+CG_ONLINEAWARD_QUERY = {}
+
+GC_ONLINEAWARD_QUERY = {
+    {"awardVec",            12,  SINGLE_AWARD_INFO},   --当天所有的奖励数据
+    {"leftTime",            1,  "int"},                --领取下一档奖励的倒计时
+    {"needRecharge",        1,  "double"},             --当日领奖需要充值金额
+    {"isReach",             1,  "byte"},               --是否充值达标,0-未达标,1-达标
+}
+
+
+
+--领取
+CG_ONLINEAWARD_CLAIM = {
+}

+ 5 - 4
script/module/union/UnionDonateLogic.lua

@@ -25,15 +25,16 @@ function unionDonateQuery(human)
         return
     end
 
-    local nextLv = union.lv + 1
+    local unionLv = math.min(union.lv, #UnionExcel.union)
+
+    local nextLv = unionLv + 1
     local config = UnionExcel.union[nextLv]
 
     -- 写协议数据
     local msgRet = Msg.gc.GC_UNION_DONATE_QUERY
-    msgRet.unionLv = union.lv
+    msgRet.unionLv = unionLv
     msgRet.unionExp = union.exp
-    msgRet.lvUpExp = UnionExcel.union[union.lv].exp
-    msgRet.nextMemCnt = config and config.maxCnt or 0
+    msgRet.lvUpExp = UnionExcel.union[unionLv].exp
     msgRet.nextMemCnt = config and config.maxCnt or 0
     msgRet.todayExp = union.donate and union.donate[1] or 0