Adding more static NPCs (houses, cabins, and elsewhere)

Post first mentioned in the Needful things forum, so I’ll quote my post…

[quote=“Random_dragon, post:2790, topic:5570”]So, here’s an idea that might warrant its own thread, maybe.

Adding random changes of static NPCs spawning in various additional locations. Like regular hunters in cabins, small chances of mundane survivors in houses, things like that.

The key here being the idea of less than 100% odds of placing an NPC, so you get some unpredictability with static NPCs, but without having the insanity that dynamic NPCs tends to cause.[/quote]

…along with relevent discussion that ensued after that.

[quote=“Malkeus, post:2791, topic:5570”]It would be an interesting thing to have hordes break into a house and surprise an NPC survivor, it would be a nice distraction or a horribly timed event depending on your cirumstances. Making a seperate setting to control how often they spawn would let us simulate a zero-day scenario where a bunch of people are still around being murdered by the zombie hordes, or we could go the other route with NPC’s living innawoods since the cataclysm and occasional survivors who managed to make it in town. All in all, good things imo.
However it gets done, it should scale down over time so you find fewer and fewer survivors as time goes on, or maybe they could start appearing rarely in groups to simulate people who banded together to survive.[/quote]

(no idea if that was directed at me or Malkeus)

[quote=“Chezzo, post:2794, topic:5570”]Please please post what you come up with somewhere. I am really interested in manipulating npcs with lua for a mod.

You know once I get the tileset done. And the iso set. And the sounds. Bah![/quote]

So. As I stated, the way to make a pseudo-dynamic static spawn would entail a low percentage, but LUA scripting would be an alternative, as Malkeus suggested.

Either way, I would firmly be in favor of it staying in line with static mode’s behavior of spawning NPCs at the start, so we don’t have the issue of ninja looting due to the little vermin teleporting into a secured base.

I like this and would like to add an addendum. I would like a way to be able to place npcs in custom buildings that are not the pre-made static ones.

Oh? There is a way to place NPCs in a mapgen file, so… :V

There is but those npcs have to be from the npc.json file or ones you create, not random ones.

Oh right. Hmm. There is a way to simulate that by defining a generic-ish NPC in the NPC file, but…

I see one caveat here. I wish there was a way to allow random selection of their NC class and starter quest. This is…hmm.

How is the starter starter NPC handled? At a minimum you can define a generic NPC that starts in the same conversation tree, but that still needs random quest selection at the very least.

Though in the case of NC class, there is a generic-ish class option that allows wildcard skills and gear.

We don’t have random npcs or fully customization to them, we have this wierd hybrid thing. I tried making them have the generic talk option but it spits an error. If custom buildings would have random npcs, that would make static spawn more interesting.

True. Though…hmm? An error? There should be a specific topic you want them to start on. I recall re-using for my bandit mod that made bandits friendly…

    "class" : 0,
    "chat" : "TALK_SHELTER",

That should result in the generic, unpredictable NPC skill/item loadout, and the generic talk topic that starter NPCs use.

What might be better, in my opinion? NPC groups that can be referenced when spawning in a mapgen file. This would be the easiest source-code workaround to randomizing starting talk topic, class, and quest.

I’ve had no luck figuring out how to trigger a script on generation of a building. It would help if I could figure out how on_day_passed worked (this is the call made by statsthruskills mod to recalculate stats at midnight). It works for the mod, but I don’t understand how lua knows a day has passed to trigger the script.

I would like something like this to occur:
On world creation as the map is generated, I’d like some kind of hook into mapgen that would be called each time an overmap tile was generated (either from a json list or possibly a tag). Exactly like the on_day_passed function, except triggered at by a different part of the flow.
When it’s called, a diceroll could be made (defined in settings preferably, to give the player control over how many npcs they will see)
If successful, a random npc could be placed, using the method random_dragon stated above at first, but open to customization at a later date.

I could see the generation getting out of hand if the percentage was too high, or the list of tagged tiles was to broad, but thats a balancing issue and could be adjusted if we got it working. Does anyone know enough about how on_day_passed functions to nudge me in the right direction?

Hmm. I can see that being interesting, the only problem is I’m unsure how well it might work. Also whether it can be easily restricted to being called immediately, rather than over time like in Stats Through Skills (and the example elf mod).

I’m bad enough with LUA tweaks in GMod, let alone Cataclysm. ;w;

[quote=“Random_dragon, post:9, topic:11178”]Hmm. I can see that being interesting, the only problem is I’m unsure how well it might work. Also whether it can be easily restricted to being called immediately, rather than over time like in Stats Through Skills (and the example elf mod).

I’m bad enough with LUA tweaks in GMod, let alone Cataclysm. ;w;[/quote]
I’m envisioning it being similar to how monsters are generated with the terrain in static mode, but I can’t figure out how/where to tap into that. Missions are capable of spawning an npc in a random house, but again, haven’t worked out if thats possible to hijack with lua. I’m headed out now, I’m going to bang my head on this brick wall some more later.

Ah, have fun then. XP

And yeah, I’m still pondering other possible methods, like a JSON solution instead, but a LUA solution would be more useful if we implemented this as a mod.

Ok, so I’ve figured out how to add a hook for lua. Coolthulu pointed it out to me, it’s ridiculously easy and the only reason I couldn’t find it was githubs stupid search engine. lua_callback(“on_building_gen”); is what I plan to use. I’d like to insert a switch which will only fire the callback after certain buildings are created, but mapgen is a clusterfuck of insanity and I can’t figure out where exactly would be the proper place to catch them, especially buildings from json. A flag might be the way to go, but I’ll have to learn how to do that first and I’m still not sure where I’d want to check for the presence of the flag.

I’m going to work on the lua side of things for now.

i dont mind the idea of more static npcs. but arent they just guarentted friendly fillers?

I suppose that the ‘bandits’ in the game count as static, right? they sit inside a heavily fortified cabin by a road and wait for you to torch them to death?

I suppose more fortified structures would be nice, and the (sparse) people in it would be reliably safe quest givers. But then the pc will drag monsters to it.

I guess you could also give npcs a home to spawn from, and make barebones factions while tweaking this. The npcs will mostly spawn from established fortresses and coupled with the fortress guard defend the place.

Give npcs vehicle mounted solar guns for now, make it a ‘crime’ to steal or dismantle the guns, and viola.

omg, how cool would it be for npcs to loot the surrunding area and return all their loot to a pile in said fortress!

Your stuff gets looted and you have your chance to catch it again! buy it back or murderize the annoying but more realistic forty bits.

They don’t have to be friendly. Like you said, bandits can be placed as well. It would making looting houses a bit more exciting if you had a chance to encounter a hostile npc. Npc’s being as dumb as they are, would have no qualms about firing a gun whilst a giant horde wandered past outside. I’m sure that some of them would spawn in view of the street, so they would attract zombies to break into the house. It would be chaos, with random fires from flamethrower wielding nutjobs, to poor bastards who attracted a hulk and got their house knocked down. I’m not planning to touch npc AI, but altering and adding factions is something I’d like to do. I’d like to see 3 or 4 way battles, with some people being friendly to the player, others hostile or indifferent and interactions among npcs as well.

For right now though, I’ll settle for making an NPC spawn where I want him to.

Problem is all npcs are currently marked on your map as soon as they gen, and they wouldnt just be ‘hanging out’ in a simple house, would they?

So maybe survivor housed, boarded up and otherwise fortified? Still too easy to identify and torch.

I don’t understand your obsession with setting your fellow survivors on fire…Anyway, I don’t know how hard it would be to change it so they don’t show up on the map if they are hostile to you…but I’ll keep that in mind. Seems as though it wouldn’t be a difficult thing to check for, the hard part will be locating the relevant part of the code. Though that’s been much easier since I learned you can’t trust github’s search engine.

This is another reason that NPC spawn groups could be useful. That house might gen a random survivor, a doctor, a bandit, etc.

Also, regarding visibility. It seems like static NPCs aren’t marked on the map until spotted, last I checked. Either that, or until you’re close enough to the area, dunno. >.>

I think it’s a proximity thing. I was assaulting one of Noctifer’s incredibly loot bloated Survivor Emcampments™ last night and it appeared empty until I got close. I got jumped by a couple guys on the side of the base and happened to check my map for horde icons. It listed about 6 npcs all of the sudden, none of which I’d seen or had seen me, as they were still in their individual rooms.

That would explain it, yeah. o3o

How about a somwhat randomly spawned merchant that talks to you through a grilled window?