CleverRaven/Cataclysm-DDA — pull request #8265 by BevapDin (2014-07-17 15:54:00+00:00)
Title: npcs bugs, autopickup bug, price calculation:

Currently npcs travel with you in vehicle, but their in-vehicle status is not save. When you save while driving and a npc is boarded in your car, upon reload the npc thinks it's is not boarded anymore as `player::in_vehicle` is not stored for npcs.

`vehicle::part_collision` ignores collisions with in-vehicle creatures, but the npcs is not in vehicle anymore and is hurt by the car. Similar the code in npc move thinks the npcs is not in the car, but the player is, so he has to follow. The npcs tries to find a free seat in the car, they seat it is currently on is marked as in use (the npcs, seen from the vehicle is still boarded). So the npcs jumps to another one but is no boarded on two seats, and each car movement moves them twice.

That's fixed.

I replaced `some_item.tname() == "none"` with `some_item.is_null()` because `tname` returns the translated name. Under the locale "ko", this could be "없음" (assuming I read the po file correctly).

Npcs that spawn with a pneumatic assault riffle have no ammo with that riffle because there was no default ammo for it. Considering how easy pebbles are made, this is simply wrong.

Ammo for npcs is now spawned in their container, or if they don't have a container in a plastic bottle. This prevents the stray gasoline item in npcs inventory (when they start with a flamethrower).

Instead of `weapon.make(...)` call `weapon = item(...) `for starting npc weapons.
`player::weapon` is initially a null-item, null-items have no charges so their charges value is set to -1. If the weapon is made into a throwing knife/axe it needs charges, but `item::make` does not set those charges.
This results in npcs wielding a throwing knife (which is ammo!) that has -1 charges. Try this out: spawn and kill enough npcs until one finally drops a throwing knife/axe. It will show (in the advanced inventory) as having negative weight (because -1 charges * weight is negative).

About npc item generation: `item_controller->id_from` is used alot and it can return either "MISSING_ITEM" if the item group is not defined or "null" if the item group is empty. Both cases are not checked. Clothes for example are simple taken from those groups and added to the worn vector, without check that thse items

----

Auto pickup from adjacent ignored the SEALED flag. I have the seeds in the auto-pickup list and they were promptly picked up after I planted them, which of course lead to crash as the plant related code assumes there is a seed.

----

Price calculation fix:
- Rotten items are worth 10% of their original value (or should this be nothing at all?)
- contained ammo is no included in the calculation.
- Tools with charges and without ammo type (spray can) get their value calculated based on the fraction of charges left (a spray can with 5 charges has only half the value, a spray can without charges has no value at all).
- items that are counted by charge (ammo/food) consider their current charges. Currently a stack of cookies (100) is a s valuable as a stack of cookies (1). A 3l glass of cooked blueberry is no 12 times as valuable as a single cooked blueberry item (because it contains 12 servings of it). The price from json applies to the default item (e.g. created in the debug menu).
- damaged items are worth less: 100% when undamaged, down to 90% at maximal damage level, reinforced items give no bonus.

----

And as non-bugfix, but enhancements: moved the function `game::place_corpse` into the player class (where it belongs) and use it from `npc::die` instead of replicating the code there.