examples update

This commit is contained in:
Evil Factory
2021-04-30 11:34:21 -03:00
parent 9dd746b92b
commit 197e34ccd5
2 changed files with 118 additions and 81 deletions
+104 -75
View File
@@ -4,19 +4,20 @@ traitormod.peoplePercentages = {}
traitormod.roundtraitors = {} traitormod.roundtraitors = {}
traitormod.selectedCodeResponses = {} traitormod.selectedCodeResponses = {}
traitormod.selectedCodePhrases = {} traitormod.selectedCodePhrases = {}
traitormod.gamemodes = {}
traitormod.enabled = true traitormod.disableRadioChat = false
traitormod.roundGamemode = ""
local traitorAssignDelay = 0 local traitorAssignDelay = 0
local traitorsAssigned = true local traitorsAssigned = true
local warningClients = {} local warningClients = {}
Game.OverrideTraitors(true) -- shutup old traitors
local config = dofile("lua/traitormod/traitorconfig.lua") local config = dofile("lua/traitormod/traitorconfig.lua")
local util = dofile("lua/traitormod/util.lua") local util = dofile("lua/traitormod/util.lua")
Game.OverrideTraitors(config.enableTraitors) -- shutup old traitors
Game.AllowWifiChat(config.enableWifiChat)
traitormod.config = config traitormod.config = config
traitormod.setPercentage = function(client, amount) traitormod.setPercentage = function(client, amount)
@@ -25,31 +26,35 @@ traitormod.setPercentage = function(client, amount)
if traitormod.peoplePercentages[client.SteamID] == nil then if traitormod.peoplePercentages[client.SteamID] == nil then
traitormod.peoplePercentages[client.SteamID] = {} traitormod.peoplePercentages[client.SteamID] = {}
traitormod.peoplePercentages[client.SteamID].penalty = 1 traitormod.peoplePercentages[client.SteamID].penalty = 1
traitormod.peoplePercentages[client.SteamID].p = config.firstJoinPercentage traitormod.peoplePercentages[client.SteamID].p =
config.firstJoinPercentage
end end
traitormod.peoplePercentages[client.SteamID].p = amount traitormod.peoplePercentages[client.SteamID].p = amount
end end
traitormod.addPenalty = function (client, amount) traitormod.addPenalty = function(client, amount)
if client == nil then return end if client == nil then return end
if traitormod.peoplePercentages[client.SteamID] == nil then if traitormod.peoplePercentages[client.SteamID] == nil then
traitormod.peoplePercentages[client.SteamID] = {} traitormod.peoplePercentages[client.SteamID] = {}
traitormod.peoplePercentages[client.SteamID].penalty = 1 traitormod.peoplePercentages[client.SteamID].penalty = 1
traitormod.peoplePercentages[client.SteamID].p = config.firstJoinPercentage traitormod.peoplePercentages[client.SteamID].p =
config.firstJoinPercentage
end end
traitormod.peoplePercentages[client.SteamID].penalty = traitormod.peoplePercentages[client.SteamID].penalty + amount traitormod.peoplePercentages[client.SteamID].penalty =
traitormod.peoplePercentages[client.SteamID].penalty + amount
end end
traitormod.getPenalty = function (client) traitormod.getPenalty = function(client)
if client == nil then return end if client == nil then return 0 end
if traitormod.peoplePercentages[client.SteamID] == nil then if traitormod.peoplePercentages[client.SteamID] == nil then
traitormod.peoplePercentages[client.SteamID] = {} traitormod.peoplePercentages[client.SteamID] = {}
traitormod.peoplePercentages[client.SteamID].penalty = 1 traitormod.peoplePercentages[client.SteamID].penalty = 1
traitormod.peoplePercentages[client.SteamID].p = config.firstJoinPercentage traitormod.peoplePercentages[client.SteamID].p =
config.firstJoinPercentage
end end
return traitormod.peoplePercentages[client.SteamID].penalty return traitormod.peoplePercentages[client.SteamID].penalty
@@ -61,19 +66,22 @@ traitormod.addPercentage = function(client, amount)
if traitormod.peoplePercentages[client.SteamID] == nil then if traitormod.peoplePercentages[client.SteamID] == nil then
traitormod.peoplePercentages[client.SteamID] = {} traitormod.peoplePercentages[client.SteamID] = {}
traitormod.peoplePercentages[client.SteamID].penalty = 1 traitormod.peoplePercentages[client.SteamID].penalty = 1
traitormod.peoplePercentages[client.SteamID].p = config.firstJoinPercentage traitormod.peoplePercentages[client.SteamID].p =
config.firstJoinPercentage
end end
traitormod.peoplePercentages[client.SteamID].p = traitormod.peoplePercentages[client.SteamID].p + amount traitormod.peoplePercentages[client.SteamID].p =
traitormod.peoplePercentages[client.SteamID].p + amount
end end
traitormod.getPercentage = function (client) traitormod.getPercentage = function(client)
if client == nil then return end if client == nil then return 0 end
if traitormod.peoplePercentages[client.SteamID] == nil then if traitormod.peoplePercentages[client.SteamID] == nil then
traitormod.peoplePercentages[client.SteamID] = {} traitormod.peoplePercentages[client.SteamID] = {}
traitormod.peoplePercentages[client.SteamID].penalty = 1 traitormod.peoplePercentages[client.SteamID].penalty = 1
traitormod.peoplePercentages[client.SteamID].p = config.firstJoinPercentage traitormod.peoplePercentages[client.SteamID].p =
config.firstJoinPercentage
end end
return traitormod.peoplePercentages[client.SteamID].p return traitormod.peoplePercentages[client.SteamID].p
@@ -104,9 +112,7 @@ traitormod.selectPlayerPercentages = function(ignore)
for i = 1, #players, 1 do for i = 1, #players, 1 do
for key, value in pairs(ignore) do for key, value in pairs(ignore) do
if players[i] == value then if players[i] == value then table.remove(players, i) end
table.remove(players, i)
end
end end
end end
@@ -236,7 +242,10 @@ traitormod.chooseNextObjective = function(key, value)
end end
Hook.Add("roundStart", "traitor_start", function() Hook.Add("roundStart", "traitor_start", function()
if not traitormod.enabled then return end
Game.SendMessage(
"We are using Custom Traitors Plugin by EvilFactory (https://steamcommunity.com/id/evilfactory/)\n Join discord.gg/f9zvNNuxu9",
3)
local players = util.GetValidPlayersNoBots() local players = util.GetValidPlayersNoBots()
@@ -247,69 +256,105 @@ Hook.Add("roundStart", "traitor_start", function()
traitormod.addPenalty(client, -1) traitormod.addPenalty(client, -1)
end end
traitormod.addPercentage(client, config.roundEndPercentageIncrease / traitormod.getPenalty(client)) traitormod.addPercentage(client, config.roundEndPercentageIncrease /
traitormod.getPenalty(client))
end end
traitormod.chooseCodes() traitormod.chooseCodes()
local rng = Random.Range(0, 100) if config.enableTraitors then
if rng < config.traitorShipChance and config.traitorShipEnabled == true then local rng = Random.Range(0, 100)
local amount = config.getAmountShipTraitors(#util.GetValidPlayers())
Game.Log("Infiltraiton Gamemode selected, Random = " .. rng, 6) if rng < config.traitorShipChance and config.traitorShipEnabled == true then
traitormod.roundGamemode = "Infiltraiton" local amount = config.getAmountShipTraitors(#util.GetValidPlayers())
traitormod.traitorShipRoundStart(amount) Game.Log("Infiltraition Gamemode selected, Random = " .. rng, 6)
else table.insert(traitormod.gamemodes, "Infiltraition")
traitorsAssigned = false
traitorAssignDelay = Timer.GetTime() + config.traitorSpawnDelay
Game.Log("Assasination Gamemode was selected, Random = " .. rng, 6) traitormod.traitorShipRoundStart(amount)
traitormod.roundGamemode = "Assasination" else
traitorsAssigned = false
traitorAssignDelay = Timer.GetTime() + config.traitorSpawnDelay
if config.traitorShipEnabled then Game.Log("Assasination Gamemode was selected, Random = " .. rng, 6)
traitormod.spawnTraitorShipAndHide() table.insert(traitormod.gamemodes, "Assasination")
if config.traitorShipEnabled then
traitormod.spawnTraitorShipAndHide()
end
end
if config.enableCommunicationsOffline then
rng = Random.Range(0, 100)
if rng < config.communicationsOfflineChance then
table.insert(traitormod.gamemodes, "Offline Communications")
traitormod.disableRadioChat = true
Game.SendMessage(
"—-radiation closing in on our location, comms down!", 11)
Game.SendMessage(
"—-radiation closing in on our location, comms down!", 3)
for key, value in pairs(Player.GetAllCharacters()) do
if value.IsHuman then
Player.SetRadioRange(value, 0)
end
end
end
end
end
if config.enableSabotage then
for key, value in pairs(Player.GetAllClients()) do
if value.Character then
value.Character.IsTraitor = true
end
Game.SendTraitorMessage(value, 'traitor', 'traitor',
TraitorMessageType.Objective) -- enable everyone to sabotage
end end
end end
for key, value in pairs(Player.GetAllClients()) do
Game.SendTraitorMessage(value, 'traitor', 'traitor', TraitorMessageType.Objective) -- enable everyone to sabotage
end
Game.SendMessage(
"We are using Custom Traitors Plugin by EvilFactory (https://steamcommunity.com/id/evilfactory/)\n Join discord.gg/f9zvNNuxu9",
3)
end) end)
Hook.Add("roundEnd", "traitor_end", function() Hook.Add("roundEnd", "traitor_end", function()
if not traitormod.enabled then return end if config.enableTraitors then
local msg = "Traitors of the round: " local msg = "Traitors of the round: "
for key, value in pairs(traitormod.roundtraitors) do for key, value in pairs(traitormod.roundtraitors) do
msg = msg .. "\"" .. key.name .. "\" " msg = msg .. "\"" .. key.name .. "\" "
end end
msg = msg .. "\n\nGamemode: " .. traitormod.roundGamemode msg = msg .. "\n\nGamemodes:"
Game.SendMessage(msg, 1) for key, value in pairs(traitormod.gamemodes) do
msg = msg .. " \"" .. value .. "\""
end
Game.SendMessage(msg, 1)
for key, value in pairs(traitormod.roundtraitors) do
local c = util.clientChar(key)
traitormod.setPercentage(c, config.traitorPercentageSet)
traitormod.addPenalty(c, config.traitorPenalty)
end
for key, value in pairs(traitormod.roundtraitors) do
local c = util.clientChar(key)
traitormod.setPercentage(c, config.traitorPercentageSet)
traitormod.addPenalty(c, config.traitorPenalty)
end end
traitormod.roundtraitors = {} traitormod.roundtraitors = {}
traitormod.selectedCodeResponses = {} traitormod.selectedCodeResponses = {}
traitormod.selectedCodePhrases = {} traitormod.selectedCodePhrases = {}
traitormod.gamemodes = {}
warningClients = {} warningClients = {}
end) end)
Hook.Add("think", "traitor_think", function() Hook.Add("think", "traitor_think", function()
if not traitormod.enabled then return end
if not traitorsAssigned and traitorAssignDelay < Timer.GetTime() then if not traitorsAssigned and traitorAssignDelay < Timer.GetTime() then
local amount = config.getAmountTraitors(#util.GetValidPlayers()) local amount = config.getAmountTraitors(#util.GetValidPlayers())
traitormod.assignNormalTraitors(amount) traitormod.assignNormalTraitors(amount)
@@ -371,21 +416,6 @@ end)
Hook.Add("chatMessage", "chatcommands", function(msg, client) Hook.Add("chatMessage", "chatcommands", function(msg, client)
if bit32.band(client.Permissions, 0x40) == 0x40 then if bit32.band(client.Permissions, 0x40) == 0x40 then
if msg == "!toggletraitormod" then
traitormod.enabled = not traitormod.enabled
if traitormod.enabled then
Game.SendDirectChatMessage("", "TraitorMod Enabled", nil, 1,
client)
else
Game.SendDirectChatMessage("", "TraitorMod Disabled", nil, 1,
client)
end
Game.OverrideTraitors(traitormod.enabled)
return true
end
if msg == "!toggletraitorship" then if msg == "!toggletraitorship" then
config.traitorShipEnabled = not config.traitorShipEnabled config.traitorShipEnabled = not config.traitorShipEnabled
@@ -419,18 +449,16 @@ Hook.Add("chatMessage", "chatcommands", function(msg, client)
local num = 0 local num = 0
for key, value in pairs(traitormod.roundtraitors) do for key, value in pairs(traitormod.roundtraitors) do
if key.IsDead == false then if key.IsDead == false then num = num + 1 end
num = num + 1
end
end end
if num > 0 then if num > 0 then
traitormod.sendTraitorMessage("There are traitors alive.", client) traitormod.sendTraitorMessage("There are traitors alive.",
client)
else else
traitormod.sendTraitorMessage("All traitors are dead!", client) traitormod.sendTraitorMessage("All traitors are dead!", client)
end end
return true return true
end end
@@ -451,7 +479,8 @@ Hook.Add("chatMessage", "chatcommands", function(msg, client)
if msg == "!percentage" then if msg == "!percentage" then
traitormod.sendTraitorMessage("You have " .. traitormod.sendTraitorMessage("You have " ..
math.floor(traitormod.getPercentage(client)) .. math.floor(
traitormod.getPercentage(client)) ..
"% of being traitor", client) "% of being traitor", client)
return true return true
+9 -1
View File
@@ -8,15 +8,23 @@ local codewords = {
"tire", "trunk", "blow sticks", "thrashers" "tire", "trunk", "blow sticks", "thrashers"
} }
config.enableTraitors = true
config.codewords = codewords config.codewords = codewords
config.amountCodewords = 2 config.amountCodewords = 2
config.traitorSpawnDelay = 60 config.traitorSpawnDelay = 60
config.nextMissionDelay = 60 config.nextMissionDelay = 60
config.traitorShipEnabled = true -- set this to false for the respawn shuttles to work config.traitorShipEnabled = true -- set this to false for the respawn shuttles to work
config.traitorShipChance = 15 config.traitorShipChance = 18
config.traitorShipGodModeDistance = 4000 config.traitorShipGodModeDistance = 4000
config.enableCommunicationsOffline = true
config.communicationsOfflineChance = 20
-- Gameplay Options
config.enableSabotage = true -- allow everyone to sabotage
config.enableWifiChat = true -- allow people to wire wifi components to the chat ingame
-- Traitor Selection Options -- Traitor Selection Options
config.roundEndPercentageIncrease = 10 config.roundEndPercentageIncrease = 10