Someone was just commenting about the difficulty in getting zombies to hold their stuff so that when they revive, they’re not naked. Can someone who has seen the unpacked code tell me how CDDA is coded, in general terms? If I was coding a roguelike from scratch, I’d probably use object-oriented programming so I could create instances and move them inside of each other as virtual objects. It makes keeping track of what is where much easier in my experience. Does CDDA use a different style?
CDDA does that, but the codebase is quirky (arguably does what it has to do quite competently, but there are limitations)
look here for the whole codebase, and specifically the monster and mondeath files to undestand the problem. Revivification is handled by the MF_REVIVES tag, so grep for this also.
IIRC items are only spawned on death, and are never part of a monster since a monster class differs from the NPC class in that it has no inventory (not the only difference). I don’t know if implementing all monsters as NPC’s (or even making a new monster class and then creating the NPC class as a subclass from that) is feasible.
Best ask here or raise an issue here to get dev attention.
Monsters do have an inventory, and we would be interested in doing drop spawn into that inventory at monster spawn time instead of at death.
The real problem rhough is associating item drops with the corpse, the cirpse could “contain” them, but that would probably ne essitate changes elsewhere to keep item visibility working correctly.
I just imagine my character looking in fear and disgust at all those naked zombies walking around xD
Hmm, a ‘WORN_BY’ tag for items could work maybe?
When the corpse gets moved, the code could check if there are worn items by that corpse, and move them all together.
At revive, the corpse should look for items ‘worn’ in the corpse tile and put them in the inventory.
Can’t remember if each zed has a specific id (i think not), but we’d have to somehow differentiate between each specific zed for this to work.
But then we’d need to handle tags on item creation to remove tags that shouldn’t be kept.
For example, we’d need to prevent volume overload from putting all sorts of bras and panties on a nearby hulk corpse.
Right, no tag, it also cannot store info on who is wearing them.
On the same vein: A duplicate inventory for zeds? Invisible and not interacting with anything other than:
At death it is not emptied, but stays intact.
At move corpse it (a) updates itself removing all items it contains not on the source tile and (b) deletes them and respawns them on the target tile.
At revification it also (a) updates and (b) deletes them from the ground and puts them in the ‘real’ inventory.
Its not that hacky i hope.
Monsters have an inventory, items have a contents array. What I meant is on death a monster can spawn a corpse and add items to it. You’d just need an update to code that displays items on the ground to also display those items. It might look just like it is now, or it might show that they are associated with a corpse. If the corpse revives the items would be added to the new mobsters inventory.
Maybe force players to “search corpse” to discover what it has, and use perception to allow for a potential bonus in finding better or more stuff.
It’d be more like a better check makes it faster, if you’re determined and take your tine you aren’t going to miss much on something the size of a corpse.