Compare commits
No commits in common. "main" and "1.0.2" have entirely different histories.
29
addon.txt
29
addon.txt
@ -1,32 +1,27 @@
|
|||||||
Title: Custom Hostile NPCs to Citizen
|
Title: Custom Hostile NPCs to Citizen!
|
||||||
|
|
||||||
This is my first mod ever!
|
This is my first mod ever!
|
||||||
|
|
||||||
[h2]About this Addon[/h2]
|
# About this Addon
|
||||||
Tired of hearing your favorite character's enemy NPC sound like a combine? or buggy if using weapons rather than citizen NPCs?
|
|
||||||
|
|
||||||
This simple mod changes custom hostile NPC models change their behavior from combine to citizen by [b]overwriting the spawnmenu data[/b]. making hostile more human.
|
This mod makes custom hostile NPC models change their behavior from Combine to Citizen.
|
||||||
|
|
||||||
If you spawn NPCs from custom model addons as enemies or hostiles you realize that their behavior and their voices are combine soldiers. That's because most hostile NPCs from custom model addons use combine as their base NPC.
|
If you spawn NPCs from custom model addons as enemies or hostiles you realize that their behavior and their voices are combine soldiers. That's because most hostile NPCs from custom model addons use Combine as their base NPC.
|
||||||
|
|
||||||
Since the March 2025 update, gmod has added a new NPC called Enemy Rebel, which makes citizens hostile. This can be changed to custom NPCs that use Combine as their enemy.
|
Since the March 2025 update, gmod has added a new NPC called Enemy Rebel, which makes citizens hostile. This can be changed to custom NPCs that use Combine as their enemy.
|
||||||
|
|
||||||
[h2]Features[/h2]
|
If you want your enemies to be more human, this mod will change all hostile NPC custom models to behave like citizens.
|
||||||
[list]
|
|
||||||
[*] Change the behavior of custom models NPCs from combine to citizen
|
|
||||||
[*] Blacklist of NPCs who don't want to become citizens.
|
|
||||||
[/list]
|
|
||||||
|
|
||||||
To blacklist an NPC, right-click and copy the NPC in the spawn menu, go to Options > Replace Hostile Settings, paste the NPC class into the blacklist. to add multiple NPC, separate them with commas, example: npc_myhostile,npc_lenna,gfl2_lenna_enemy
|
# Features
|
||||||
|
- Change the behavior of custom models NPCs from combine to citizen
|
||||||
|
- Allows hostile to attack with melee weapons
|
||||||
|
|
||||||
You can reload blacklisted and non-blacklisted hostile NPCs with [b]replacehostile_reload[/b] or “Reload NPCs” button in settings
|
I'll make VJ version if i can
|
||||||
|
|
||||||
I'll make VJ version if i can. i'm still learning...
|
---
|
||||||
|
|
||||||
-----------
|
|
||||||
|
|
||||||
models used:
|
models used:
|
||||||
- [url=https://steamcommunity.com/sharedfiles/filedetails/?id=3167885628]Lenna[/url]
|
- Lenna https://steamcommunity.com/sharedfiles/filedetails/?id=3167885628
|
||||||
- [url=https://steamcommunity.com/sharedfiles/filedetails/?id=3133369749]Tomoko[/url]
|
- 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.
|
Note: i couldn't find a mod similar to the one i made, so i don't know who made it first.
|
@ -1,90 +1,32 @@
|
|||||||
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
|
|
||||||
|
|
||||||
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 npcs = list.Get("NPC")
|
||||||
local citizenEnemy = npcs["npc_citizen_rebel_enemy"]
|
local citizenEnemy = npcs["npc_citizen_rebel_enemy"]
|
||||||
|
local originalListSet = list.Set
|
||||||
|
|
||||||
for class, npc in pairs(npcs) do
|
function list.Set(listType, class, npc)
|
||||||
if table.HasValue(blacklist, class) then continue end
|
if listType == "NPC" then
|
||||||
if npc["Class"] == "npc_combine_s" and npc["Category"] ~= "#spawnmenu.category.combine" then
|
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["Class"] = citizenEnemy["Class"]
|
||||||
npc["KeyValues"] = {
|
npc["KeyValues"] = {
|
||||||
Hostile = 1,
|
Hostile = 1,
|
||||||
SquadName = "overwatch",
|
SquadName = "overwatch",
|
||||||
citizentype = 4
|
citizentype = 4
|
||||||
}
|
}
|
||||||
list.Set("NPC", class, npc)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
originalListSet(listType, class, npc)
|
||||||
end
|
end
|
||||||
|
|
||||||
CreateClientConVar("replacehostile_blacklist", "", false, false, "Blacklist NPC Classes")
|
-- Second stage. idk if one of these necessary
|
||||||
|
|
||||||
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 ()
|
timer.Simple(0, function ()
|
||||||
replaceHostile()
|
for class, npc in pairs(npcs) do
|
||||||
|
if npc["Class"] == "npc_combine_s" and npc["Category"] ~= "#spawnmenu.category.combine" then
|
||||||
|
npc["Class"] = citizenEnemy["Class"]
|
||||||
|
npc["KeyValues"] = {
|
||||||
|
Hostile = 1,
|
||||||
|
SquadName = "overwatch",
|
||||||
|
citizentype = 4
|
||||||
|
}
|
||||||
|
originalListSet("NPC", class, npc)
|
||||||
|
end
|
||||||
|
end
|
||||||
end)
|
end)
|
BIN
pics/pic_2.jpg
BIN
pics/pic_2.jpg
Binary file not shown.
Before Width: | Height: | Size: 194 KiB |
Loading…
x
Reference in New Issue
Block a user