CleverRaven/Cataclysm-DDA — pull request #8348 by BevapDin (2014-07-27 20:53:43+00:00)
Title: Bugs and const

First a bug fix: I introduced this bug when combining the two monster die functions. The kill is not correctly registered in the players kill count. This is fixed by the first commit.

----

The next commit makes many Creature/player/npc/monster function const, as it should be. It removes some const_casts. Nothing special.

----

Then I recognized that the npc class also has two die functions. Those have been merged into one. `npc::dead` is private, similar to `monster::dead`. Do npcs kill other npcs? And are they affected by morale? If so, the code in `npc::die` could be changed to add the killing npc, not just the player.

----

And now that monster/player/npc use a common `die` interface, it was time for more unification: the function `print_info` is now part of the Creature interface. The monster (monster descriptions), player ("You (name)") and npc (name, weapon, armor) class override it with their own content.

This makes some code simple: instead of "is there a monster, print info, else: is there a npc, print info, else is the player there, print info", one can now write "is a creature there, print info". You can now see the npc information when targeting a npc (like when targeting a monster).

----

To make drawing the monster/npc/player symbol on the map simpler, I added `game::draw_critter`. It calculates the positions of the creature on the terrain window (and checks its validity), it checks that the player can see it (or that it is warm blooded and the player has infrared vision) and then displays it.

Again this makes it easier to draw any kind of creature. It also enables npc to be seen with infrared. All objects of type `Character` (player,npc) are warm blooded, see `Character::is_warm`.

----

And than I fixed some exploits that showed up during testing: it was possible to "detect" an invisible creature.

----

Fixes #7607 - triggered by the death by melee. When the npc dies (the die function is called), it fails the mission and calls the mission-fail function. The "get antibiotics" mission calls `mission_fail::kill_npc` and that function would remove the npc that is currently dying (the object whose `die` function is currently being called). It also changes the `game::active_npc` vector.

This should be reproducible by getting a npc with the "get antibiotics" mission and letting it killed.