61 lines
1.8 KiB
Lua
61 lines
1.8 KiB
Lua
local npcs = list.Get("NPC")
|
|
local citizenEnemy = npcs["npc_citizen_rebel_enemy"]
|
|
local originalListSet = list.Set
|
|
|
|
function list.Set(listType, class, npc)
|
|
if listType == "NPC" then
|
|
if npc["Class"] == "npc_combine_s" and npc["Category"] ~= "#spawnmenu.category.combine" then
|
|
if !npc["KeyValues"] then
|
|
npc["KeyValues"] = {}
|
|
end
|
|
npc["KeyValues"]["SquadName"] = "m_EnemyRebel"
|
|
end
|
|
end
|
|
originalListSet(listType, class, npc)
|
|
end
|
|
|
|
hook.Add("OnEntityCreated", "ForceReplaceCombine", function(ent)
|
|
timer.Simple(0, function()
|
|
if !SERVER then return end
|
|
if not IsValid(ent) then return end
|
|
|
|
if ent:GetClass() == "npc_citizen" then
|
|
end
|
|
|
|
if ent:GetKeyValues()["squadname"] == "m_EnemyRebel" then
|
|
local pos = ent:GetPos()
|
|
local ang = ent:GetAngles()
|
|
local mdl = ent:GetModel()
|
|
local weps = ent:GetWeapons()
|
|
local health = ent:GetMaxHealth()
|
|
local keyValues = ent:GetKeyValues()
|
|
|
|
ent:Remove()
|
|
|
|
local npc = ents.Create("npc_citizen")
|
|
if not IsValid(npc) then return end
|
|
|
|
for key, value in pairs(keyValues) do
|
|
npc:SetKeyValue(key, tostring(value))
|
|
-- if value ~= "" then
|
|
-- end
|
|
end
|
|
|
|
npc:SetHealth(health)
|
|
npc:SetMaxHealth(health)
|
|
|
|
npc:SetKeyValue("hostile", 1)
|
|
npc:SetKeyValue("squadname", "overwatch")
|
|
npc:SetKeyValue("citizentype", 4)
|
|
|
|
for _, wep in ipairs(weps) do
|
|
npc:Give(wep:GetClass())
|
|
end
|
|
|
|
npc:SetPos(pos)
|
|
npc:SetAngles(ang)
|
|
npc:SetModel(mdl)
|
|
npc:Spawn()
|
|
end
|
|
end)
|
|
end) |