What describes a corpse?

I have this crazy idea of making corpses over into a draggable container which conceals its contents, much like a locker. I’m having difficulty tracking down what MAKES a corpse though. I’d like to test this idea by adding a new death_action flag to mondeath but I’ve gotten lost in item.cpp looking for what defines a corpse. Could someone give me a nudge in the right direction?

Edit: Ok, apparently corpses are defined in mtype.cpp, so thats one piece of the puzzle. What specifically gives the player the ability to grab and move things? As near as I can tell it’s the blocksdoor flag which conceals contained items until you are next to the locker, but I can’t find where grabbing things is done, yet.

There is no support for dragging items, only for vehicles and furniture.
It will be very similar to the existing dragging support, but with a little more data to track since it has to keep track of the square the item is on as well as the location of the item within that square.

FTFY

[quote=“Kevin Granade, post:2, topic:11025”]There is no support for dragging items, only for vehicles and furniture.
It will be very similar to the existing dragging support, but with a little more data to track since it has to keep track of the square the item is on as well as the location of the item within that square.[/quote]

I’m having trouble locating that dragging support. I’m probably aiming a little high for my first attempt at coding since college, but I want to try. My aim is to make corpses into a form of furniture which would be covered by the existing dragging code. I’m pretty sure I’m not ready to tackle making storage capable items into containers which are draggable, but who knows.

Is there a specific location that handles player actions on the world? I thought iuse actor would be it, but I couldn’t find anything that seemed like dragging.

hmm i should have checked here first, by i replied to you post in the pockets discussion

Imo furnitures or vehicles aren’t going to be a good solution to the problem. You need to add dragability to items. You also need to make corpses have inventory, just like the player has.

Because dragability to all items is a potential great problem. I suggest creating a new ‘corpse’ class that will behave however you need it to.

Dragging items has further benefits as it would allow players to carry things like V8 engines or kegs full of whiskey. After implementing item dragging, it could be that dragging corpses also drags everything else in a tile, but this breaks down when you have things in a tile that the corpse didn’t have on them or multiple corpses in one tile. A little hack might be that once you grab a corpse, it grabs every item in that tile from the corpse’s index down to the next corpse’s index.

Ideally, what I want to end up with is a flag which can be added to an item to allow it to be dragged. If I can accomplish that, I’ll tackle making corpses into items that contain the monsters items and can be dragged.

A question: Are the monsters drops actually equipped on their person, or are they randomly generated on death? Afaik, monsters don’t have limbs and can’t wear items on them, all their stats are inherent to the monster type and not dependent on external items, is that a correct assumption? I haven’t had the opportunity to trace item spawns yet, but from playing the game, reanimated corpses don’t keep on dropping things, there must be a flag set for that, right?

They’re generated upon death, and revived monsters have a flag that tells them to not drop additional items. See game::revive_corpse and item::process_corpse for revival info.

Theoretically just about any item should be able to be dragged, it just needs to be in line with other draggable items and take into account the item weight/volume and the player’s strength. Making container items is probably going to be unreasonable to tackle in the scope of this (though it’s something people have wanted for a long time).

Keeping the items tied to the corpse won’t be easy.

Making the corpse contain the items would make it very annoying to pick up drops, so it is not acceptable to do just that and implementing a proper interface for it would be a LOAD of work.
Making the corpse contain all the items on the tile is obviously out, since that would allow covering V12s with a corpse to drag them.
Making it contain all clothing on the tile also would be hacky and would allow “vacuuming” clothing by dragging a corpse over it, which would be quite stupid.

I don’t see a good solution for corpses keeping their items that wouldn’t involve a ton of work.
It would be much easier to just allow dragging multiple items at a time.

That said something like this (if done well) would also make it rather easy to have revived creatures not be suddenly stripped naked by their death. Zombies that you knock down and later stand up will keep wearing their clothing and all that jazz. (Course we would also need completely working monster inventories for that to happen :P).

It could be a part of the item class for corpse items that saves a list containing the items that the corpse generates when the monster dies. When the corpse rezzes, it attempts to grab everything back into the inventory of the monster, and the item dragging could automatically move these items when grabbing a corpse?

As I stated above, I’m going to add in code to make select items grabbable, I’ll leave the corpses as containers for a later date. I’ve been familiarizing myself with the grabbing/moving code as time permits, it’s starting to make sense.

I’m can’t decide if I should add a GRAB flag to items or have the code decide if an item is draggable based on it’s weight, either will be equally difficult for me to attempt, what do you guys think?

I think we will need a menu to select among multiple GRABbable items on a single tile. I’m going to limit grabs to adjacent tiles only for simplicities sake.

I’m slowly working my way through the functions that make up the grab/move code, I hope I’ve found everything. I’m adding in additional else if statements to allow us to handle items the same way we currently handle furniture, ie push/pull as appropriate and shifting things if not pushing/pulling with appropriate strength checks. I’m not sure how I’ll handle the case of an item being pushed into furniture yet, probably leave it the same as furniture. We can use AIM to shift whatever it is that last tile if you want to put barrels on racks or something.

I’m currently working on adding the has_gitem bool to map.h and map.cpp, which will function like the has_furn bool and search the tile for items which are either really heavy or have the GRAB flag, whichever route I end up taking. Then gitem_at (like furn_at) will pop up a menu if there’s more than one grabbable item at the specified tile. I would welcome any pointers for dealing with this, I haven’t done any coding since college. It’s slowly coming back, but the skill rust has set in HARD. For instance, the mechanics of actually moving stuff from one tile to another is wrecking my brain right now, I forsee a lot of headaches once I can actually grab an item.

If this works out, at the very least we will be able to drag corpses into a pile to burn them without getting back strain.

No need to limit what is draggable, except based on character’s strength.
Currently the player can grab ultra-heavy cars just fine, just won’t be able to pull them.

When grabbing a tile, check if the tile has items, furniture, vehicles etc. If it has only one, then it should always grab that.
If it has more, it should ask: first if the player wants to grab furniture, vehicles or items, then (if it’s items) it should open the item selection menu (like on pickup) and allow selecting items to drag.

I hadn’t really thought about the flow, thanks for bringing it up.
I want to maintain the current functionality as much as possible. It seems like it would get pretty tedious to have a menu pop up every time you grab your shopping cart. I’d like for us to be able to just grab it, unless there are items on the ground.

Is there a way to differentiate between items on the floor and items in a vehicle? I don’t think it’s possible to have items in a piece of furniture and items on the floor as well, the code seems to prevent it. Lockers and dressers drag their contents, are there more pieces of furniture like this?

So these wouldn’t get a menu, just grab it:
furniture that holds it’s contents (locker, dresser [is there a flag for this? Are there more?]),
furniture that doesn’t hold it’s contents and doesn’t have items on it,
vehicles without items on the ground,
single item.

And if I detect furniture that doesn’t hold its contents with items on it,
vehicles with items on the ground,
or multiple items,

I populate a menu with whatever category is detected (Furniture and Items or Vehicle and Items)
And if the player selects items or multiple items are detected I just bring up the item selection menu (It takes me forever to find things in the code, could you point me towards the item selection code?).

I think that should cover all cases, probably wrong. Am I making this more complicated than it needs to be?

Would we want the player to be able to drag multiple items? That seems kind of unrealistic to me.

Don’t try to implement the system for items on vehicles yet. It would be simpler if you required the items to be on the floor first, which the player can achieve (even for incredibly heavy items) by using advanced inventory menu to move the items out of the vehicle.

All furniture with “CONTAINER” flag does that.

[quote=“Malkeus, post:14, topic:11025”]I think that should cover all cases, probably wrong. Am I making this more complicated than it needs to be?

Would we want the player to be able to drag multiple items? That seems kind of unrealistic to me.[/quote]

Looks like all cases to me. You aren’t complicating things.

Dragging multiple items would make the whole system more useful. For example, dragging a fully clothed zed corpse.
It could also represent player holding a “mountain” of rags.
As for realism - the player character usually has at least two hands. Dragging 2 zed child corpses wouldn’t be that hard.

If you feel multi-item dragging would be hard, don’t implement it, but try to avoid making it too dependent on the item being a single item.

Ok, I’ll leave that alone for now.

[quote=“Coolthulhu, post:15, topic:11025”]All furniture with “CONTAINER” flag does that.

Looks like all cases to me. You aren’t complicating things.

Dragging multiple items would make the whole system more useful. For example, dragging a fully clothed zed corpse.
It could also represent player holding a “mountain” of rags.
As for realism - the player character usually has at least two hands. Dragging 2 zed child corpses wouldn’t be that hard.[/quote]

Thanks for pointing out the CONTAINER flag, I stared at the things in furniture.json for a half hour last night and that didn’t click.

How hackish would it be if I summoned an invisible piece of furniture with the CONTAINER flag and put all the selected items into it? This would simplify things as I could just use the existing furniture moving code. And I’d be able to specify a maximum volume draggable as well…how to implement that as part of the selection eludes me at the moment, but it should be possible.

The system would only work if the items were on a tile by themselves and that would mean I wouldn’t need to try to figure out how to check if items were on the ground or inside a container. I wouldn’t need to worry about creating an uber scoop either, as the system currently displaces items when you drag a CONTAINER over them.

I would want to add a check to confirm pushing the false container a block away from the player to avoid having to reselect all those items though. Maybe the first try will simply grab an entire tiles worth of items at once without giving an option to pick and choose. Sort of like mounding all your laundry into a pile and grabbing it all at once to carry to the wash. Selection could be tacked on later.

In any case, I’m going to have to think this all through again, probably scrap what I’ve done so far as a bad try, it looks nothing like the flow I described.

Incredibly hacky.
It would also make it impossible to move less anything less than everything on the tile.
It would be better if you copied the relevant sections from the furniture code. Even if you copied the entire blocks and removed the furniture parts it would be less hacky than adding a temporary furniture piece.

You could start by moving all the items at first (with uber scoop included) - it would actually be simpler to implement than moving just one item.
Later on you could limit it to only some items by storing their indices and updating them on each move.

I had a feeling that wouldn’t go over well. When I get home, I’ll spend the evening trying to understand how moving items works. Moving a locker over a tile with items already present displaces those items, I’ll look at that code first. And I’ll hunt up the container flag and see how that’s done. Code blocks is really handy for tracing a function, I’m enjoying figuring out how things work.

Can’t wait to try compiling something :slight_smile:

edit: I can compile! Persistence and the art of beating your head on a brick wall…I haven’t forgotten about you grabbable items, I’m just building up to you.