Skip to content

Commit

Permalink
Actually require faction association to spawn faction-limited entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Doridian committed Apr 2, 2024
1 parent 4dd0ba7 commit a3838d6
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 9 deletions.
10 changes: 9 additions & 1 deletion lua/entities/sa_base_rd3_entity/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ function ENT:CAF_PostInit()
self:InitializeRankedVars()

if self.ForcedModel and self:GetModel():lower() ~= self.ForcedModel:lower() then
ply:AddHint("Tried to spawn entity with invalid model (got \"" .. self:GetModel() .. "\", required \"" .. self.ForcedModel .. "\")!", NOTIFY_ERROR, 5)
self:Remove()
return
end

self:CalcVars(self:GetTable().Founder)
local ply = self:GetTable().Founder

Check failure on line 14 in lua/entities/sa_base_rd3_entity/init.lua

View workflow job for this annotation

GitHub Actions / lint

Variable 'ply' shadows existing binding, defined at line 9, column 3
if self.RequireFaction and ply.sa_data.faction_name ~= self.RequireFaction then
local faction = SA.Factions.GetByName(self.RequireFaction)
ply:AddHint("You must be a member of " .. faction.display_name .. " to spawn this entity!", NOTIFY_ERROR, 5)
self:Remove()
return
end
self:CalcVars(ply)
end

function ENT:CalcVars(ply)

Check failure on line 24 in lua/entities/sa_base_rd3_entity/init.lua

View workflow job for this annotation

GitHub Actions / lint

Variable 'ply' shadows existing binding, defined at line 9, column 3
Expand Down
1 change: 1 addition & 0 deletions lua/entities/sa_ice_mining_laser/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ ENT.RankedVars = {
LaserConsume = 7245 * 2,
LaserCycle = 30,
IceLaserModMin = 2,
RequireFaction = "ice",
}
}
1 change: 1 addition & 0 deletions lua/entities/sa_ice_refinery/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ENT.RankedVars = {
CycleVol = 1,
RefineEfficiency = 1,
MinIceRefineryMod = 2,
RequireFaction = "ice",
},
}

Expand Down
1 change: 1 addition & 0 deletions lua/entities/sa_mining_drill/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ ENT.RankedVars = {
YieldOffset = 100,
YieldIncrement = 20,
MinTibDrillMod = 1,
RequireFaction = "legion",
},
}
2 changes: 2 additions & 0 deletions lua/entities/sa_mining_laser/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ ENT.RankedVars = {

BeamLength = 5000,
BeamWidthOffset = 60,

RequireFaction = "miners",
},
}
18 changes: 15 additions & 3 deletions lua/entities/sa_rta/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ AddCSLuaFile("shared.lua")
include("shared.lua")
util.PrecacheSound("tools/ifm/beep.wav")

local function ClampLevelByFaction(ply)
if not IsValid(ply) then
return 0
end
local level = ply.sa_data.research.rta[1]
if ply.sa_data.faction_name == "corporation" then
return level
end
if level > 1 then
level = 1
end
return level
end

local function OpenTerminal(ent, ply, founder)
if CurTime() < ent.NextUse then return end
ent.NextUse = CurTime() + 1
if ent:GetPos():Distance(SA.Terminal.GetStationPos()) > SA.Terminal.GetStationSize() and
(not (founder and founder.sa_data.research.rta[1] and founder.sa_data.research.rta[1] > 1)) then

if ent:GetPos():Distance(SA.Terminal.GetStationPos()) > SA.Terminal.GetStationSize() and ClampLevelByFaction(founder) <= 1 then
ent:EmitSound("tools/ifm/beep.wav")
ply:AddHint("RTA device out of range of station.", NOTIFY_CLEANUP, 5)
return
Expand Down
1 change: 1 addition & 0 deletions lua/entities/sa_storage_ice/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ ENT.RankedVars = {
{
ForcedModel = "models/mandrac/resource_cache/colossal_cache.mdl",
MinRawIceStorageMod = 4,
RequireFaction = "ice",
}
}
1 change: 1 addition & 0 deletions lua/entities/sa_storage_ice_product/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ ENT.RankedVars = {
{
ForcedModel = "models/slyfo/doublecarrier.mdl",
MinIceProductStorageMod = 6,
RequireFaction = "ice",
},
}
11 changes: 6 additions & 5 deletions lua/entities/sa_storage_ore/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,31 @@ ENT.RankedVars = {
ForcedModel = "models/slyfo/sat_resourcetank.mdl",
MinOreManage = 0,
StorageOffset = 50000,
StorageIncrement = 5000
StorageIncrement = 5000,
},
{
ForcedModel = "models/slyfo/nacshortsleft.mdl",
MinOreManage = 1,
StorageOffset = 1600000,
StorageIncrement = 10000
StorageIncrement = 10000,
},
{
ForcedModel = "models/slyfo/nacshuttleright.mdl",
MinOreManage = 2,
StorageOffset = 4600000,
StorageIncrement = 20000
StorageIncrement = 20000,
},
{
ForcedModel = "models/slyfo/crate_resource_small.mdl",
MinOreManage = 3,
StorageOffset = 9600000,
StorageIncrement = 40000
StorageIncrement = 40000,
},
{
ForcedModel = "models/slyfo/crate_resource_large.mdl",
MinOreManage = 4,
StorageOffset = 19600000,
StorageIncrement = 80000
StorageIncrement = 80000,
RequireFaction = "miners",
}
}
1 change: 1 addition & 0 deletions lua/entities/sa_storage_tiberium/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ ENT.RankedVars = {
MinTiberiumStorageMod = 1,
StorageOffset = 1550000,
StorageIncrement = 10000,
RequireFaction = "legion",
},
}

0 comments on commit a3838d6

Please sign in to comment.