Commit 53227d9c2f3b86eb471baaa5c73885d46c625bd9
1 parent
e8ca14c4
pvp 编队胜利推送
Showing
2 changed files
with
73 additions
and
11 deletions
Show diff stats
src/actions/PvpAction.lua
... | ... | @@ -23,6 +23,7 @@ local _revengeRecord = {} -- 复仇对单人1分钟间隔 |
23 | 23 | local RevengeWaitTime = 60 |
24 | 24 | |
25 | 25 | function _M.formatCommonRpc(agent , data) |
26 | + if true then return end | |
26 | 27 | local role = agent.role |
27 | 28 | local roleId = role:getProperty("id") |
28 | 29 | local msg = MsgPack.unpack(data) |
... | ... | @@ -63,7 +64,8 @@ function _M.formatHighRpc(agent , data) |
63 | 64 | local role = agent.role |
64 | 65 | local roleId = role:getProperty("id") |
65 | 66 | local msg = MsgPack.unpack(data) |
66 | - | |
67 | + | |
68 | + if not role:isCrossServerPvpPlayer() then return end | |
67 | 69 | local pvpTH = {} |
68 | 70 | local had = {} -- 上阵的角色 |
69 | 71 | local supportHad = {} |
... | ... | @@ -258,6 +260,36 @@ function _M.startBattleRpc(agent, data) |
258 | 260 | local pvpTC = role:getProperty("pvpTC") |
259 | 261 | if not pvpTC.heros or not next(pvpTC.heros) then return 1 end |
260 | 262 | |
263 | + local team = msg.team | |
264 | + if not team then return end | |
265 | + | |
266 | + for slot, heroId in pairs(team.heros or {}) do | |
267 | + if not role.heros[heroId] then | |
268 | + return | |
269 | + end | |
270 | + end | |
271 | + if not team.heros or not next(team.heros) then | |
272 | + return | |
273 | + end | |
274 | + local supports = {} | |
275 | + for slot, support in pairs(team.supports) do | |
276 | + if slot ~= 1 and slot ~= 2 then return end | |
277 | + local level = role.dinerData:getProperty("dishTree"):getv(support, 0) | |
278 | + if level <= 0 then return end | |
279 | + supports[slot] = support | |
280 | + end | |
281 | + | |
282 | + local pvpTC = {} | |
283 | + pvpTC.heros = {} | |
284 | + for slot, heroId in pairs(team.heros) do | |
285 | + pvpTC.heros[slot] = heroId | |
286 | + end | |
287 | + pvpTC.leader = team.leader | |
288 | + pvpTC.supports = supports | |
289 | + if team.tactics and globalCsv.tactics_skill_passive_cell[team.tactics] then | |
290 | + pvpTC.tactics = team.tactics | |
291 | + end | |
292 | + | |
261 | 293 | local matchInfo, result, key, wait |
262 | 294 | |
263 | 295 | local now = skynet.timex() |
... | ... | @@ -299,7 +331,7 @@ function _M.startBattleRpc(agent, data) |
299 | 331 | end |
300 | 332 | |
301 | 333 | key = tostring(math.random()) |
302 | - _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge} | |
334 | + _pvpStartBattleCacheC = {idx = idx, key = key, revenge = revenge, pvpTC = pvpTC} | |
303 | 335 | |
304 | 336 | role:checkTaskEnter("PvpBattle") |
305 | 337 | |
... | ... | @@ -342,7 +374,15 @@ function _M.endBattleRpc(agent, data) |
342 | 374 | |
343 | 375 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpBonus, true) |
344 | 376 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleC"}}) |
345 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) | |
377 | + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 | |
378 | + -- 失败了没再排行榜 不计入 | |
379 | + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_COMMON)) then | |
380 | + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank= role:changePvpScoreCommon(match.t == 1 and match.id or -1, isWin) | |
381 | + end | |
382 | + if isWin then | |
383 | + -- 记录编队 | |
384 | + role:savePvpCTeam(_pvpStartBattleCacheC.pvpTC) | |
385 | + end | |
346 | 386 | |
347 | 387 | -- 请求上传录像 |
348 | 388 | local params = { |
... | ... | @@ -472,7 +512,6 @@ function _M.startBattleHRpc(agent, data) |
472 | 512 | curTeam.tactics = team.tactics |
473 | 513 | end |
474 | 514 | |
475 | - | |
476 | 515 | table.insert(pvpTH, curTeam) |
477 | 516 | end |
478 | 517 | |
... | ... | @@ -644,9 +683,18 @@ function _M.endBattleHRpc(agent, data) |
644 | 683 | -- 战斗结束了发奖 |
645 | 684 | local temp = string.randWeight(csvdb["player_expCsv"][role:getProperty("level")].pvpgroupBonus, true) |
646 | 685 | local reward, change = role:award({[temp[1]] = temp[2]}, {log = {desc = "pvpBattleH"}}) |
647 | - local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, 0, 0 | |
648 | - if role:isTimeResetOpen(TimeReset.PvpHight) then | |
649 | - myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | |
686 | + | |
687 | + | |
688 | + local myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = 0, 0, 0, 0, -1, -1 | |
689 | + -- 失败了没再排行榜 不计入 | |
690 | + if role:isTimeResetOpen(TimeReset.PvpHight) then | |
691 | + if isWin or (not isWin and role:isInPvpRank(RANK_PVP_HIGHT)) then | |
692 | + myScore, matchScore, oldmyScore, oldMatchScore, myRank, oldMyRank = role:changePvpScoreHigh(match.t == 1 and match.id or -1, isWin) | |
693 | + end | |
694 | + -- 记录编队 | |
695 | + if isWin then | |
696 | + role:savePvpHTeam(_pvpStartBattleCacheH.pvpTH) | |
697 | + end | |
650 | 698 | end |
651 | 699 | |
652 | 700 | -- 加入战斗记录 | ... | ... |
src/models/RolePvp.lua
... | ... | @@ -6,7 +6,7 @@ RolePvp.bind = function (Role) |
6 | 6 | local PVP_RANK_TIME_SORT_STD = 1924876800 -- 2030-12-31 00:00:00 |
7 | 7 | local PVP_RANK_TIME_SORT_PLACE = 1000000 -- 时间戳占据 6位数 |
8 | 8 | local PVP_RANK_TIME_SORT_PRECISION = 360 -- 时间精度 每6分钟忽略差异 |
9 | -local PVP_RANK_ROBOT_SCORE = globalCsv.pvp_base_score -- 机器人积分 | |
9 | +local PVP_RANK_BASE_SCORE = globalCsv.pvp_base_score -- 机器人积分 | |
10 | 10 | |
11 | 11 | |
12 | 12 | function Role:unpackPvpScore(score) |
... | ... | @@ -34,7 +34,7 @@ function Role:changePvpScore(rankKey, changeScoreCallback, matchId) |
34 | 34 | end) |
35 | 35 | local myScore = self:unpackPvpScore(redret[1]) |
36 | 36 | local oldMyRank = tonumber(redret[2] or -2) + 1 |
37 | - local matchScore = PVP_RANK_ROBOT_SCORE | |
37 | + local matchScore = PVP_RANK_BASE_SCORE | |
38 | 38 | if isPlayer then |
39 | 39 | matchScore = self:unpackPvpScore(redret[3]) |
40 | 40 | end |
... | ... | @@ -68,7 +68,7 @@ function Role:changePvpScoreCommon(matchId, isWin) |
68 | 68 | if isWin then |
69 | 69 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((myScore - matchScore) / 400))) |
70 | 70 | myScore = myScore + scoreChange |
71 | - matchScore = matchScore - scoreChange | |
71 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
72 | 72 | else |
73 | 73 | local scoreChange = math.ceil(60 / (1 + 10 ^ ((matchScore - myScore) / 400))) |
74 | 74 | myScore = myScore - scoreChange |
... | ... | @@ -134,7 +134,7 @@ function Role:changePvpScoreHigh(matchId, isWin) |
134 | 134 | if isWin then |
135 | 135 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((myScore - matchScore) / 1000))) |
136 | 136 | myScore = myScore + scoreChange |
137 | - matchScore = matchScore - scoreChange | |
137 | + matchScore = matchScore - math.ceil(scoreChange / 3) -- 防守方失败时,扣分减为原来的1/3 | |
138 | 138 | else |
139 | 139 | local scoreChange = math.ceil(50 / (1 + 10 ^ ((matchScore - myScore) / 1000))) |
140 | 140 | myScore = myScore - scoreChange |
... | ... | @@ -166,6 +166,20 @@ function Role:changePvpScoreHigh(matchId, isWin) |
166 | 166 | return table.unpack(result) |
167 | 167 | end |
168 | 168 | |
169 | +function Role:isInPvpRank(rankKey) | |
170 | + local Fields = { | |
171 | + [RANK_PVP_COMMON] = "pvpMC", | |
172 | + [RANK_PVP_HIGHT] = "pvpMH", | |
173 | + } | |
174 | + local dbKey = self:getPvpDBKey(rankKey) | |
175 | + local roleId = self:getProperty("id") | |
176 | + if redisproxy:zscore(dbKey, roleId) then | |
177 | + return true | |
178 | + end | |
179 | + return false | |
180 | +end | |
181 | + | |
182 | + | |
169 | 183 | function Role:refreshPvpMatch(score, rankKey) |
170 | 184 | |
171 | 185 | local Fields = { | ... | ... |