Improvements to spree handling

* changed default settings to disable records when bots are playing
* changed bot records bitflag to not include sprees when either source or victim is a bot
This commit is contained in:
Timo Smit 2019-02-11 13:00:09 +01:00
parent 1562e74489
commit 2e2c471d98
2 changed files with 12 additions and 11 deletions

View file

@ -59,7 +59,7 @@ area = 3
bots = 1 bots = 1
[records] [records]
bots = 1 bots = 0
[sprees] [sprees]
file = "sprees.toml" file = "sprees.toml"

View file

@ -31,8 +31,8 @@ local toml = wolfa_requireLib("toml")
local sprees = {} local sprees = {}
sprees.RECORD_BOTS = 1 sprees.RECORD_BOTS_PLAYING = 1
sprees.RECORD_PLAYER_BOTSON = 2 sprees.RECORD_BOTS = 2
sprees.SOUND_PLAY_SELF = 0 sprees.SOUND_PLAY_SELF = 0
sprees.SOUND_PLAY_PUBLIC = 1 sprees.SOUND_PLAY_PUBLIC = 1
@ -237,14 +237,15 @@ function sprees.onGameStateChange(gameState)
end end
end end
function sprees.onPlayerSpree(clientId, type, sourceId) function sprees.onPlayerSpree(clientId, causeId, type)
playerSprees[clientId][type] = playerSprees[clientId][type] + 1 playerSprees[clientId][type] = playerSprees[clientId][type] + 1
local currentSpree = playerSprees[clientId][type] local currentSpree = playerSprees[clientId][type]
if db.isConnected() and settings.get("g_spreeRecords") ~= 0 and if db.isConnected() and settings.get("g_spreeRecords") ~= 0 and
(bits.hasbit(settings.get("g_botRecords"), sprees.RECORD_PLAYER_BOTSON) or tonumber(et.trap_Cvar_Get("omnibot_playing")) == 0) and (bits.hasbit(settings.get("g_botRecords"), sprees.RECORD_BOTS_PLAYING) or tonumber(et.trap_Cvar_Get("omnibot_playing")) == 0) and
(bits.hasbit(settings.get("g_botRecords"), sprees.RECORD_BOTS) or not players.isBot(clientId)) and (bits.hasbit(settings.get("g_botRecords"), sprees.RECORD_BOTS) or not players.isBot(clientId)) and
(bits.hasbit(settings.get("g_botRecords"), sprees.RECORD_BOTS) or not players.isBot(causeId)) and
(not currentRecords[type] or currentSpree > currentRecords[type]["record"]) then (not currentRecords[type] or currentSpree > currentRecords[type]["record"]) then
currentRecords[type] = { currentRecords[type] = {
["player"] = db.getPlayerId(clientId), ["player"] = db.getPlayerId(clientId),
@ -352,35 +353,35 @@ end
function sprees.onPlayerDeath(victimId, killerId, mod) function sprees.onPlayerDeath(victimId, killerId, mod)
if killerId == 1022 then -- killed by map if killerId == 1022 then -- killed by map
events.trigger("onPlayerSpreeEnd", victimId) events.trigger("onPlayerSpreeEnd", victimId)
events.trigger("onPlayerSpree", victimId, sprees.TYPE_DEATH) events.trigger("onPlayerSpree", victimId, nil, sprees.TYPE_DEATH)
elseif victimId == killerId then -- suicides elseif victimId == killerId then -- suicides
-- happens when a bot disconnects, it selfkills before leaving, thus emptying the -- happens when a bot disconnects, it selfkills before leaving, thus emptying the
-- player data table, resulting in errors. I'm sorry for your spree records, bots. -- player data table, resulting in errors. I'm sorry for your spree records, bots.
if not players.isConnected(victimId) then return end if not players.isConnected(victimId) then return end
events.trigger("onPlayerSpreeEnd", victimId, killerId) events.trigger("onPlayerSpreeEnd", victimId, killerId)
events.trigger("onPlayerSpree", victimId, sprees.TYPE_DEATH) events.trigger("onPlayerSpree", victimId, killerId, sprees.TYPE_DEATH)
else -- regular kills else -- regular kills
if et.gentity_get(victimId, "sess.sessionTeam") == et.gentity_get(killerId, "sess.sessionTeam") then if et.gentity_get(victimId, "sess.sessionTeam") == et.gentity_get(killerId, "sess.sessionTeam") then
-- teamkill handling -- teamkill handling
events.trigger("onPlayerSpreeEnd", victimId, killerId) events.trigger("onPlayerSpreeEnd", victimId, killerId)
events.trigger("onPlayerSpree", victimId, sprees.TYPE_DEATH) events.trigger("onPlayerSpree", victimId, killerId, sprees.TYPE_DEATH)
else else
events.trigger("onPlayerSpreeEnd", killerId, victimId, sprees.TYPE_DEATH) events.trigger("onPlayerSpreeEnd", killerId, victimId, sprees.TYPE_DEATH)
events.trigger("onPlayerSpree", killerId, sprees.TYPE_KILL) events.trigger("onPlayerSpree", killerId, victimId, sprees.TYPE_KILL)
-- happens when a bot disconnects, it selfkills before leaving, thus emptying the -- happens when a bot disconnects, it selfkills before leaving, thus emptying the
-- player data table, resulting in errors. I'm sorry for your spree records, bots. -- player data table, resulting in errors. I'm sorry for your spree records, bots.
if not players.isConnected(victimId) then return end if not players.isConnected(victimId) then return end
events.trigger("onPlayerSpreeEnd", victimId, killerId) events.trigger("onPlayerSpreeEnd", victimId, killerId)
events.trigger("onPlayerSpree", victimId, sprees.TYPE_DEATH) events.trigger("onPlayerSpree", victimId, killerId, sprees.TYPE_DEATH)
end end
end end
end end
function sprees.onPlayerRevive(clientMedic, clientVictim) function sprees.onPlayerRevive(clientMedic, clientVictim)
events.trigger("onPlayerSpree", clientMedic, sprees.TYPE_REVIVE) events.trigger("onPlayerSpree", clientMedic, clientVictim, sprees.TYPE_REVIVE)
end end
return sprees return sprees