Project Zomboid

Project Zomboid

Subpar Survivors
sf 29 Jun, 2021 @ 8:12pm
Bug/Issue: SuperSurvivor:ReadyGun
Posted it in discussion as comment has length restrictions (and may be harder to keep track)
Looked into the code and debug mode (don't know lua though I code in other langs) to provide more actionable feedback.

It seems like there is a "potential" problem with reloading magazine (if the player messes around with the char inventory using the debug swap, which should really be made into a proper character swapping feature imo, but that's for another time).

in
lua/client/2_Other/SuperSurvivor.lua:
function SuperSurvivor:ReadyGun

iiuc, the agent will be trying to load a suitable magazine if it is found in inventory.
But it will fail if the magazine is actually in a sub-inventory (the action seems considered bugged cleared by native game code afterwards) which resulted in the agent stuck trying to do the same thing over and over (and action gets dumped by game)

Potential fixes:
0) ignore. just assume that this won't happen if "character swap" was never used.
1) restrict the finding magazine to main inventory only (which may mean creating magazines unnecessarily)
2) (prob better long term), add a retrieve item to main inventory check what will move an item from a sub-inventory to main inventory if the native game code (assuming those starting with "IS"?) does not automatically do it


Just comment:
Noticed that currently inventory management for the NPC agents seems very messy/restrictive in general (prob inherited from code long time ago), which prevented effective expansion in a lot of other behavior since most of it involved inventory interactions somewhat. Any plans to design a new sub-framework for it? Ideally, the behavior, actions and even flavor-conversations etc can be framework-tized enough that individual actions/behavior can be modded/added in the future...

I am actually very interested in the NPC-line of mod being developed and glad that it is still continued (real thanks!) as it is one of the main preconditions I got the game after knowing it for so long. Single-survivor games gets really stale after a while, no matter how sophisticated, which there are a lot of other 3D 1st/3rd person titles around. Multiplayer, though more dynamic, is too demanding on time for me.
< >
Showing 1-5 of 5 comments
ExterminaTor 30 Jun, 2021 @ 4:13am 
With update survivor not join to the group !! XD
SlightlyMadman  [developer] 30 Jun, 2021 @ 6:21am 
Thanks for digging into this, sf! Fixing bugs caused by debug character swap isn't a priority for me (it causes all sorts of problems, mostly around inventory and item equipping, and isn't meant to be used in regular play). You're right though, that it's a symptom of a much bigger problem.

When I first started tweaking this mod, I got the idea to strip it down to its bones and rebuild, but as soon as I started on that task I saw Aiteron post about their NPC mod work, so I didn't want to waste my time on something that a modder with much more experience in this game would likely do better.

Now that he's changed his path to a java rewrite of that mod however, I think there's plenty of time to do some significant work on this mod before Aiteron's drops.

I'll dig through the inventory management code a bit and see if I can come up with a better system, as I think that could make fixing this and other issue easier. Once serious problem I've run into in certain tasks is that the game automatically adds things to the player's inventory on some actions (like harvest), and the only way to get around that may be building a smart sync system for survivor inventories that detects problems and reconciles them.
sf 30 Jun, 2021 @ 8:13am 
as a stop-gap measure, how about an idle-time "manage inventory task" which is run occasionally, where the NPC will try to clear out all unnecessary things also to keep the encumbrance manageable).

things they could do during this task:

- throw all trash (maybe at new zone trash zone, pref with a trashcan/container). things like empty food wrappers etc (one other problem they have is that they choose food badly when hunger enabled, which I felt was more lively).

- drop unnecessary tools/medicine/food at the respective zones if possible

- drop all other unnecessary stuff maybe at a new general storage area (they can find whatever they need for a job anyway)

- maintain their equipment (maybe replace worn/thrown away clothing), check weapon (pre-load magazines).


Not too related to above, is there some object/place to store group-level policies? e.g. allowing/disallowing certain actions. Was thinking that it could be more interesting if say they clean themselves occasionally, unlimited if water is still running, but if after water has stopped, maybe it will be controlled by some group policy flags which can be set via context menu or something.

If possible, could be interesting to set up more "idle tasks" like maintaining their clothing (replacing/patching), refilling ammo (if not unlimited), or even change to better weapons if they could find it, if allowed. Since each game is different, always allowing these will prob not work out, which is why they should only be considered if there is a way for the player to control the behavior.

Btw, if you are interested in refactoring the code (not completely rewrite, but rather start replacing parts with similar, but better organized code), I may be able to offer some help if you need it. Have some experience in designing software/coding framework/libraries. Won't be "boost-level", but may be able to make the mod easier to maintain.

One simpler starting point I would recommend is on compatibility. iiuc, currently, to make the mod compatible with any other mods (esp on new items and their use etc), the maintainer (that's you) have to manually look up those mods and do it yourself. If a better interface can be setup, we could provide a hook for other mods to link their stuff into your mod instead, in addition to the ones that you already support, thus relieving some of the maintenance work.

We can discuss on other areas if you are interested. E.g. it would be good if other mods can add their own actions/tasks in THEIR mods and hook it up to the survivor mod to make it work together (i.e. becoming a core framework mod that makes different things by different parties work together). E.g. say a mod that uses alternative method of farming can add their own farm task, so that it will run together with the vanilla one allowing an NPC to actually interact and farm with the 2 systems.
SlightlyMadman  [developer] 30 Jun, 2021 @ 8:42am 
These are great ideas. It also ties in well with another goal I have of NPCs being able to clean up the base and sort items into appropriate containers. Let me stew on it for a bit and I'll keep this thread updated.
Honestly, the idea of building frameworks for this sounds good, if anyone puts in the time and effort to make it happen. It would also give other modders the ability to expand on that, as long as the code is well documented.
< >
Showing 1-5 of 5 comments
Per page: 1530 50