Skip to content

Commit

Permalink
Traitor Mod 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
evilfactory authored Jul 12, 2022
2 parents d5da6fa + 99d1185 commit c495e5f
Show file tree
Hide file tree
Showing 17 changed files with 1,061 additions and 334 deletions.
4 changes: 4 additions & 0 deletions Lua/Autorun/init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
if CLIENT then return end

Traitormod = {}
Traitormod.VERSION = "2.1-SNAPSHOT"

print(">> Traitor Mod v" .. Traitormod.VERSION .. " by Evil Factory")
print(">> Special thanks to Qunk, Femboy69 and JoneK for helping in the development of this mod.")

local path = table.pack(...)[1]

Expand Down
80 changes: 63 additions & 17 deletions Lua/commands.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
----- USER COMMANDS -----
Traitormod.AddCommand("!help", function (client, args)
Traitormod.SendMessage(client, Traitormod.Language.Help)

return true
end)

Traitormod.AddCommand("!version", function (client, args)
Traitormod.SendMessage(client, "Running Evil Factory's Traitor Mod v" .. Traitormod.VERSION)

return true
end)

Traitormod.AddCommand("!traitor", function (client, args)
if Game.RoundStarted and Traitormod.SelectedGamemode then
Traitormod.SelectedGamemode.ShowInfo(client.Character)
if Game.ServerSettings.TraitorsEnabled == 0 then
Traitormod.SendMessage(client, Traitormod.Language.NoTraitors)
elseif Game.RoundStarted and Traitormod.SelectedGamemode and Traitormod.SelectedGamemode.GetTraitorObjectiveSummary then
local summary = Traitormod.SelectedGamemode.GetTraitorObjectiveSummary(client.Character)
Traitormod.SendMessage(client, summary)
elseif Game.RoundStarted then
Traitormod.SendMessage(client, Traitormod.Language.NoTraitor)
else
Traitormod.SendMessage(client, Traitormod.Language.RoundNotStarted)
end
Expand All @@ -15,22 +27,18 @@ Traitormod.AddCommand("!traitor", function (client, args)
end)

Traitormod.AddCommand("!points", function (client, args)
local maxPoints = 0
for index, value in pairs(Client.ClientList) do
maxPoints = maxPoints + (Traitormod.GetData(value, "Weight") or 0)
end

local percentage = (Traitormod.GetData(client, "Weight") or 0) / maxPoints * 100
Traitormod.SendMessage(client, Traitormod.GetDataInfo(client, true))

if percentage ~= percentage then
percentage = 100 -- percentage is NaN, set it to 100%
end

Traitormod.SendMessage(client, string.format(Traitormod.Language.PointsInfo, math.floor(Traitormod.GetData(client, "Points") or 0), Traitormod.GetData(client, "Lives") or Traitormod.Config.MaxLives, math.floor(percentage)))
return true
end)

Traitormod.AddCommand("!info", function (client, args)
Traitormod.SendWelcome(client)

return true
end)

----- ADMIN COMMANDS -----
Traitormod.AddCommand("!alive", function (client, args)
if not (client.Character == nil or client.Character.IsDead) and not client.HasPermission(ClientPermissions.ConsoleCommands) then return end

Expand Down Expand Up @@ -59,8 +67,8 @@ end)
Traitormod.AddCommand("!roundinfo", function (client, args)
if not client.HasPermission(ClientPermissions.ConsoleCommands) then return end

if Game.RoundStarted and Traitormod.SelectedGamemode then
Traitormod.SelectedGamemode.ShowRoundInfo(client)
if Game.RoundStarted and Traitormod.SelectedGamemode and Traitormod.SelectedGamemode.GetRoundSummary then
Traitormod.SendMessage(client, Traitormod.SelectedGamemode.GetRoundSummary())
elseif Traitormod.LastRoundSummary ~= nil then
Traitormod.SendMessage(client, Traitormod.LastRoundSummary)
else
Expand Down Expand Up @@ -104,18 +112,56 @@ Traitormod.AddCommand("!addpoint", function (client, args)
local found = nil

for key, value in pairs(Client.ClientList) do
if value.Name == name then
if value.Name == name or tostring(value.SteamID) == name then
found = value
break
end
end

if found == nil then
Traitormod.SendMessage(client, "Couldn't find a client with name " .. name)
Traitormod.SendMessage(client, "Couldn't find a client with name / steamID " .. name)
return true
end

Traitormod.AddData(found, "Points", amount)
Traitormod.SendMessage(client, string.format("Gave %s points to %s.", amount, found.Name))

return true
end)

Traitormod.AddCommand("!removepoint", function (client, args)
if not client.HasPermission(ClientPermissions.ConsoleCommands) then return end

if #args < 2 then
Traitormod.SendMessage(client, "Incorrect amount of arguments. usage: !removepoint \"Client Name\" 500")

return true
end

local name = table.remove(args, 1)
local amount = tonumber(table.remove(args, 1))

if amount == nil or amount ~= amount then
Traitormod.SendMessage(client, "Invalid number value.")
return true
end

local found = nil

for key, value in pairs(Client.ClientList) do
if value.Name == name or tostring(value.SteamID) == name then
found = value
break
end
end

if found == nil then
Traitormod.SendMessage(client, "Couldn't find a client with name / steamID " .. name)
return true
end

Traitormod.AddData(found, "Points", -amount)
Traitormod.SendMessage(client, string.format("Removed %s points from %s.", amount, found.Name))

return true
end)
53 changes: 41 additions & 12 deletions Lua/config.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
local config = {}
config.DebugLogs = true

----- USER FEEDBACK -----
config.Language = "English"
config.SendWelcomeMessage = true
config.ChatMessageType = ChatMessageType.Private -- Error = red | Private = green | Dead = blue | Radio = yellow

----- GAMEPLAY -----
config.Codewords = {
"hull", "tabacco", "nonsense", "fish", "clown", "quartermaster", "fast", "possibility",
"thalamus", "hungry", "water", "looks", "renegade", "angry", "green", "sink", "rubber",
Expand All @@ -12,11 +17,18 @@ config.Codewords = {

config.AmountCodeWords = 2

config.PermanentPoints = true
config.FreeExperience = 50 -- temporary experience given every ExperienceTimer seconds
config.ExperienceTimer = 120

config.EnableControlHusk = false -- EXPERIMENTAL: enable to control husked character after death

----- POINTS + LIVES -----
config.PermanentPoints = true -- sets if points and lives will be stored in and loaded from a file
config.MaxLives = 4
config.DistanceToEndOutpostRequired = 5000

config.DistanceToEndOutpostRequired = 5000
config.PointsGainedFromCrewMissionsCompleted = 1000
config.LivesGainedFromCrewMissionsCompleted = 1
config.PointsGainedFromSkill = {
medical = 4,
weapons = 4,
Expand All @@ -25,12 +37,10 @@ config.PointsGainedFromSkill = {
helm = 1,
}

-- looses half points
config.PointsLostAfterNoLives = function (x)
return x * 0.75
end

-- 400 points = 200 experience
config.AmountExperienceWithPoints = function (x)
return x * 0.5
end
Expand All @@ -42,6 +52,7 @@ config.AmountWeightWithPoints = function (x)
return math.log(x + 10) -- add 1 because log of 0 is -infinity
end

----- OBJECTIVES -----
config.ObjectiveConfig = {
Assassinate = {
Enabled = true,
Expand All @@ -50,7 +61,9 @@ config.ObjectiveConfig = {

Survive = {
Enabled = true,
AmountPoints = 2500,
AlwaysActive = true,
AmountPoints = 500,
AmountLives = 1,
},

StealCaptainID = {
Expand All @@ -61,7 +74,7 @@ config.ObjectiveConfig = {
KidnapSecurity = {
Enabled = true,
AmountPoints = 4500,
Seconds = 500,
Seconds = 300,
},

PoisonCaptain = {
Expand All @@ -70,15 +83,22 @@ config.ObjectiveConfig = {
},
}

----- GAMEMODE -----
config.GamemodeConfig = {
Assassination = {
Enabled = true,
WeightChance = 50,
EndOnComplete = true, -- end round when there are no assassination targets left
EndGameDelaySeconds = 5,

SelectionDelay = 60,
StartDelayMin = 90,
StartDelayMax = 180,
NextDelayMin = 30,
NextDelayMax = 90,

NextTargetDelay = 60,
SelectBotsAsTargets = false,
SelectBotsAsTargets = true,
SelectPiratesAsTargets = false,
SelectUniqueTargets = true, -- every traitor target can only be chosen once per traitor (respawn+false -> no end)

-- Codewords, Names, None
TraitorMethodCommunication = "Names",
Expand All @@ -88,9 +108,17 @@ config.GamemodeConfig = {
SubObjectives = {"StealCaptainID", "Survive", "KidnapSecurity", "PoisonCaptain"},

AmountTraitors = function (amountPlayers)
config.TestMode = false
if amountPlayers > 12 then return 3 end
if amountPlayers > 5 then return 2 end
return 1
if amountPlayers > 6 then return 2 end
if amountPlayers > 2 then return 1 end
if amountPlayers == 1 then
Traitormod.Log("1P testing mode - no points can be gained or lost")
config.TestMode = true
return 1
end
print("Not enough players to start traitor mode.")
return 0
end,

TraitorFilter = function (client)
Expand All @@ -102,11 +130,12 @@ config.GamemodeConfig = {
}
}

----- EVENTS -----
config.RandomEventConfig = {
AnyRandomEventChance = 10, -- percentage

CommunicationsOffline = {
Enabled = true,
Enabled = false,
WeightChance = 10,
},

Expand Down
2 changes: 1 addition & 1 deletion Lua/data.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"76561198067985351":{"Weight":20.407635114262,"Points":28275,"Lives":4},"76561197960695626":{"Weight":2.302585092994},"76561197970951375":{"Weight":2.302585092994},"76561197995266558":{"Weight":2.302585092994}}
{}
Loading

0 comments on commit c495e5f

Please sign in to comment.