Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 154ffe2fed | |||
| dd0d995f3f | |||
| 6333f2390b | |||
| a3cd160929 |
@@ -16,8 +16,12 @@ If you want your enemies to be more human, this mod will change all hostile NPC
|
||||
- Change the behavior of custom models NPCs from combine to citizen
|
||||
- Allows hostile to attack with melee weapons
|
||||
|
||||
---
|
||||
|
||||
I'll make VJ version if i can
|
||||
|
||||
---
|
||||
|
||||
models used:
|
||||
- Lenna https://steamcommunity.com/sharedfiles/filedetails/?id=3167885628
|
||||
- Tomoko https://steamcommunity.com/sharedfiles/filedetails/?id=3133369749
|
||||
|
||||
Note: i couldn't find a mod similar to the one i made, so i don't know who made it first.
|
||||
@@ -1,17 +1,90 @@
|
||||
local npcs = list.Get("NPC")
|
||||
local citizenEnemy = npcs["npc_citizen_rebel_enemy"]
|
||||
local function loadBlacklistFile()
|
||||
local json = file.Read("npc_blacklist.json", "DATA")
|
||||
if not json or json == "" then return {} end
|
||||
local data = util.JSONToTable(json)
|
||||
return istable(data) and data or {}
|
||||
end
|
||||
|
||||
if citizenEnemy then
|
||||
local function resetHostile()
|
||||
local npcs = list.Get("NPC")
|
||||
for class, npc in pairs(npcs) do
|
||||
if npc["m_OldData"] then
|
||||
local oldData = util.JSONToTable(npc["m_OldData"])
|
||||
if oldData then
|
||||
list.Set("NPC", class, oldData)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function replaceHostile()
|
||||
local blacklist = loadBlacklistFile()
|
||||
local npcs = list.Get("NPC")
|
||||
local citizenEnemy = npcs["npc_citizen_rebel_enemy"]
|
||||
|
||||
for class, npc in pairs(npcs) do
|
||||
if table.HasValue(blacklist, class) then continue end
|
||||
if npc["Class"] == "npc_combine_s" and npc["Category"] ~= "#spawnmenu.category.combine" then
|
||||
npc["m_OldData"] = npc["m_OldData"] or util.TableToJSON(npc, false)
|
||||
npc["Class"] = citizenEnemy["Class"]
|
||||
npc["KeyValues"] = {
|
||||
Hostile = 1,
|
||||
SquadName = "overwatch",
|
||||
citizentype = 4
|
||||
}
|
||||
|
||||
list.Set("NPC", class, npc)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
CreateClientConVar("replacehostile_blacklist", "", false, false, "Blacklist NPC Classes")
|
||||
|
||||
concommand.Add("replacehostile_reload", function()
|
||||
resetHostile()
|
||||
replaceHostile()
|
||||
print("NPC Hostile Reloaded")
|
||||
end)
|
||||
|
||||
hook.Add("PopulateToolMenu", "ReplaceHostileMenu", function()
|
||||
local blacklist = loadBlacklistFile()
|
||||
local defaultBlacklistStr = table.concat(blacklist, ",")
|
||||
|
||||
RunConsoleCommand("replacehostile_blacklist", defaultBlacklistStr)
|
||||
|
||||
spawnmenu.AddToolMenuOption("Options", "Replace Hostile", "ReplaceHostileConfig", "Settings", "", "", function(panel)
|
||||
panel:ClearControls()
|
||||
|
||||
local blacklistEntry = panel:TextEntry("Blacklist Classes", "replacehostile_blacklist")
|
||||
|
||||
panel:ControlHelp("Separate classes with commas.\nExample: npc_my_custom_hostile,npc_my_hostile,npc_hostile_test")
|
||||
panel:Button("Reload NPCs", "replacehostile_reload")
|
||||
|
||||
blacklistEntry.OnChange = function(self)
|
||||
local val = self:GetValue() or ""
|
||||
local newBlacklist = {}
|
||||
|
||||
for e in string.gmatch(val, '([^,]+)') do
|
||||
local trimmed = string.Trim(e)
|
||||
if trimmed ~= "" then
|
||||
table.insert(newBlacklist, trimmed)
|
||||
end
|
||||
end
|
||||
|
||||
local valid = true
|
||||
for _, v in ipairs(newBlacklist) do
|
||||
if type(v) ~= "string" or v == "" then
|
||||
valid = false
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if valid then
|
||||
file.Write("npc_blacklist.json", util.TableToJSON(newBlacklist, false))
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
timer.Simple(0, function()
|
||||
replaceHostile()
|
||||
end)
|
||||
Reference in New Issue
Block a user