Customizable spawner of base guards (and other smart terrains).
Description
Faction bases in Anomaly feel empty after some time, because spawned squads always go travel somewhere else (except bar guards). Purpose of this addon is to change it and be easily adjustable. Guards will stay on spawned location forever.
There is a small guide at the top of the script, but I'll duplicate it here:
- "spawn_timer" game seconds after which new guards are going to spawn;
- default guards are from vanilla configs, so most of them have from 1 to 3 npcs;
- you can spawn whatever you want from squad_descr_default_stalkers.ltx (or make yours) as long as it does not have "story_id" in squad section;
- "guards_t" table is where you change spawns:
- "factions" picks a random faction to spawn from array;
- "ranks" picks a random rank (combined with "factions");
- "max_amount" will spawn squads until max_amount is reached;
- "squads" you can put certain squads that are gonna be spawned instead of squads that are generated by "factions" and "ranks" here, need full squad section names (picked randomly).
- (you can add more locations, their names are displayed in PDA when you enable Anomaly's debug, press f7 in game and turn on Debug HUD.)
Compabitility/uninstallation
Should be compatible with everything. You can install/uninstall addon whenever you want, but already spawned squads will still be there. If you want to delete them set "DELETE_ALL_GUARDS" to true, reload your game, save again and uninstall addon.
Example in pictures xd
Changelog
- 0.3:
- Realized how unoptimized the feature to make spawned enemy factions and mutants friendly to everyone around (even if none of them are spawned), so I removed it. If you already spawned some chimeras to defend rookie village, after updating they will obliterate it xd
- 0.22:
- Noticed that some addons can force change NPC logic and it touches guards, so they start wandering around (especially after emissions and reloadings). Added script that fix it and send them back, small change to make table global in main script needed too.
- 0.21:
- Smallest update for potential (and apparently very rare) crash.
rsrvd
Anomaly is the best game ever because of modders like you! Woah!!
Nice! Now my personal hideout can finally become a full-blown outpost!
bvcx, you are a real master 💯
will done
Ah the non stop flow of cool mods will never dry up! this is great :) tx
Please explain how to use it
Aww, it's already explained.
factions: if we change here to {"stalker", "csky"} it's gonna pick faction randomly, for example it picks "clear sky".
ranks: if we change here to {"novice", "veteran"} it's gonna pick a random rank for our picked faction "clear sky" in our case, for example "veteran".
So, this is going to spawn clear sky veteran squad as guard for this location. Then after the time has passed it will do this again until "max_amount" is reached.
If smart_faction = "stalker" then our clear sky veteran squad will be friendly to every faction that is friendly to loners (same for being hostile).
squads: this will ignore factions and ranks and spawn squads that you put here, for example: squads = { "bandit_sim_squad_novice", "simulation_boar" }
Hope it's clear now.
Sound cool!
Bro, maybe im idiot but a can't understand how i actually should spawn guard squads)
When i spawn them through debug menu they just keep walking away, but should stay in one place you say)
Please explain
Where does it say you need to spawn them with debug? Addon is called "Spawner" it is gonna spawn them by itself, you only need to fill up the table in script as it said in description.
can you add more areas like Zaton and red forest?
It's why I left how to add it in description (at the end before screenshots), if you know name of smarts it's gonna take 2 minutes to add. I never been on CoP maps in Anomaly to do it correctly and didn't want to break anything. Not sure why red forest need guards tho.
Hey mate love the idea of this but I have a query. Will this interfere with warfare base captures? For example I roll into a bandit/army base, will it then respawn those gaurds from those factions after it's been captured or does it adapt? Or does the user need to avoid this by editing the script?
This wasn't intended to work with warfare sorry ;p It is gonna spawn squads and change their faction to only what is inside the script's table. This gotta be modified a bit for Warfare, but I never tried it and don't want to break anything ;[
Loving the mod so far. I always found it weird that many places that should have guards are usually left unguarded.
Is it possible for us to add more smart terrains to the list? I was thinking of adding guards to certain locations, like the checkpoint north of Cordon.
Tnx. As for adding it's in the description's last line before screenshots.
This comment is currently awaiting admin approval, join now to view.
bvcx я тебя люблю... сколько годноты ты наклепал, неисчислимо...
Excellent job. Thanks.
This seems like a great idea, because indeed the bases get empty and I had it a couple of times now that military or bandits invaded the farm and shot at the dealers continously until I came around and nailed them - there were no guards.
So I read the instructions carefully and modified some values from the script - as I understand it, the script comes with some default values that are ready to go already? So I can just modify the values according to the instructions? Because I saw more people walking around the areas after I added the mod, but the other time I went past the farm it was empty again. Do the guards still go on patrol in the greater area, or does it mean it didn't work?
I commented out everything outside of cordon, since I didn't venture out much yet and since I see it also places guards on enemy camps, I didn't want them changed yet. I used "--[[" for that. Is that bad and does it prevent it from working correctly or is it something else? I fear that if I write 0 squads to everything else it will make it go empty.. xD
And finally, I noticed more and more military in Cordon after soem time, always camping the railway bridge and even some smaller camps. So I decided to teach them a lesson and eradicate the main outpost in the south of cordon. I wanted to use the script to change the faction of that place to stalker so I can use the vice and not have to worry about so much military on the roads. So I wrote into the script at the southern military outpost: smart_faction = "stalker" I did this change just after I saved at the emptied outpost. A day later I check on the outpost and it is filled with military again. Is that not how this works? :(
Sorry for the many questions, thank you for any answers.
If there are too many of them - additional squads are spawned by vanilla game. If there are none even after some time they either died offline or it does not work (but it should) ;]
To comment out a line you need a "--", if you use "--[[" without closing it you will comment out everything below.
I don't spawn any military on Cordon besides of their south outpost, unless you added smart terrains to the table. Sorry, I just realized how confusing the instruction can be, "faction" is actual faction that is going to spawn, "smart_faction" is what relations they gonna have.
Thank you for the reply.
I used "--[[" with "]]--" at the end of the location list (after Pripyat). So that should work then.
I didn't add any smart terrains. I will check again soon if something changed, but my line for the outpost at the moment is:
["esc_smart_terrain_3_16"] = { facti "stalker" }, max_amount = 3, ranks = { "advanced", "veteran" }, smart_faction = "stalker", squads = {} }
If you say the game still spawns garrisons of its own, maybe that just means those stalkers get killed off as they spawn? O_o
Can happen if their smart_faction relations are enemy to those on smart terrain.
This comment is currently awaiting admin approval, join now to view.
FATAL ERROR
[error]Expression : <no expression>
[error]Function : CScriptEngine::lua_pcall_failed
[error]File : ..\xrServerEntities\script_engine.cpp
[error]Line : 204
[error]Description : fatal error
[error]Arguments : LUA error: ...ly/anomaly/bin/..\gamedata\scripts\guards_spawner.script:146: attempt to call method 'commander_id' (a nil value)
stack trace:
Hello, recently I started getting this error that crashes the game. It only happens whenever I stay in army warehouse for a period of time. I've tried reinstalling the mod, the game itself, reloading to a previous save to no avail. It never happens in other parts of the game and I don't want to start over a new playthrough.
Open that script (guards_spawner.script) in your gamedata and fix the line:
if squad and squad:commander_id()
to the following:
if squad and squad:commander_id ~= nil and squad:commander_id()
It will work this way.
This comment is currently awaiting admin approval, join now to view.
hey so when I go into the .script file, its written like:
if squad and squad.commander_id
as opposed to what you wrote. Should I literally just uncompress the folder, modify the file using notepad, save it, compress again, load into the correct spot?
FATAL ERROR
[error]Expression : <no expression>
[error]Function : CScriptEngine::lua_pcall_failed
[error]File : ..\xrServerEntities\script_engine.cpp
[error]Line : 204
[error]Description : fatal error
[error]Arguments : LUA error: ...ly/anomaly/bin/..\gamedata\scripts\guards_spawner.script:146: attempt to call method 'commander_id' (a nil value)
stack trace:
Hello, recently I started getting this error that crashes the game. It only happens whenever I stay in army warehouse for a period of time. I've tried reinstalling the mod, the game itself, reloading to a previous save to no avail. It never happens in other parts of the game and I don't want to start over a new playthrough.
Did you change the code? Because my line 146 does not have anything. Could you tell me where this line is in default script? ;]
Hey bro, you have to check squad:commander_id ~= nil
in addition to "if squad and squad:commander_id()" on line 188.
Line 146 is from the G.A.M.M.A version of your mod
I fixed that in my build, however it should be done in upstream, because actually that error is kinda stupid and annoying.
This error was stupid I agree, which is why I fixed it quickly. What is more stupid is to still use this version in your modpack because this error was fixed 9 months ago.
Anyone know if spawning guards will affect the overall stalker population or the population of a particular faction? For example, if I spawn 30 military to stay in Radar, will the number of military spawning in other locations be lower?
In vanilla (not warfare) population only cares about total amount, not factions.
Good idea, per se. I tried placing some stalkers right next to the campfires. e.g. esc_smart_terrain_8_9_campfire_1
But that doesn't seem to work. Is this terrain not valid?
The code is: ["esc_smart_terrain_8_9_campfire_1"] = { facti "stalker" }, max_amount = 1, ranks = {"novice", "advanced", "veteran"}, smart_faction = "stalker", squads = {stalker_sim_squad_advanced_3_4} },
What is wrong?
Oh, and if you change settings, do you need a new game?
Greetz
Smart name is displayed in debug hud (yellow circle in PDA when u enable it). "esc_smart_terrain_8_9_campfire_1" looks like an animpoint, whereas smart terrain will look like this "esc_smart_terrain_8_9".
The goal was to make it tweakable without the need to do anything else, safe to change however you like mid-game, I do that all the time ;]
Yes, thanks. I took the smart names from the DEbug Hud. I wanted to send squads to campfires because some smarts are quite large and have multiple campfires that are also far enough apart that the squads don't fight each other right away. Hence my idea. For example, if I send 3 squads from opposing factions into the Same Smart, there is immediate chaos. :)
It, unfortunately, was not designed to send them to certain animpoints on smart terrains. Sending them to animpoints is much more complex.
Hey, then you know what you could work on. XD No, I think your script is pretty good. Noticed that in some smarts, the stalkers will automatically go to a campfire. But, as I hired 2 stalkers as companions there, I hope that the fire will be remanned. I'm curious. In any case, "Spawn via Script" is a really good idea. Sorry is Google translator. :)
I keep getting the same exact error:
[error]Expression : <no expression>
[error]Function : CScriptEngine::lua_pcall_failed
[error]File : ..\xrServerEntities\script_engine.cpp
[error]Line : 204
[error]Description : fatal error
[error]Arguments : LUA error: ...ly/anomaly/bin/..\gamedata\scripts\guards_spawner.script:146: attempt to call method 'commander_id' (a nil value)
I tried going into the script, modifying line 188 to what dzen said, saving it, yet it still crashes. Am I missing something here? what am I doing wrong exactly?
Heres what I see on Line 188 in my code (WITHOUT ANY CHANGES) Help would be appreciated.
if squad and squad.commander_id then
for se_npc in squad:squad_members() do
local npc = level.object_by_id(se_npc.id)
local smarts_faction = guards_t[smart_name] and guards_t[smart_name].smart_faction
if npc and smarts_faction then
Your crash is on line 146, not 188. What dzen said is incorrect, because in "if squad and squad.commander_id then" we don't get any returned value, we check if function exist to validate that object is squad, that's all and it can't crash (I don't even have any method :commander_id() calls anywhere in my script).
The error you just sent is definitely on your side. Send error that was happening before any changes to the script that actually broke it ;]
I had this addon for 90 in game days without a single problem, if you are playing some modpack that changed the code - I can't help with that.
Update: Ok I get it, you guys are all came from GAMMA which is still using a first version that was fixed 9 months ago ;s
Absolutely. And by the way, thanks for your work, it's amazing.
Crazy question, can you spawn helicopters with this?
Never tried.
Amazing job bro, a question, is required start a new game?
To quote the description that you didn't bother to read:
"Should be compatible with everything. You can install/uninstall addon whenever you want, but already spawned squads will still be there. If you want to delete them set "DELETE_ALL_GUARDS" to true, reload your game, save again and uninstall addon."
Hello, I'm using the latest version of gamma which includes this mod by default. After a few days in the zone alot of npcs have gathered at the rookie village and it's starting to hurt my frame rate. I read the instructions on this mod and it says that you need to set the delete all npcs parameter to "true" and then start a game, save it, exit the game, uninstall the mod and they will be gone. However, they are still there and I can't get rid of them.
No idea what gamma does.
can you explain in more details how to use it? How do you spawn guards?? what you wrire and where. Cuase from your discription i dont understand anything
There is description and a picture. I can't explain it in words clearer than that. It's like simply filling up the configs.