CleverRaven/Cataclysm-DDA — pull request #7522 by BevapDin (2014-05-03 10:07:55+00:00)
Title: Fix for #6758

Fixes #6758

Create the blood splatter only when the shot did damage the target.

----

`slope_of`: returning a pair of pair of double and double?
so `result.first.first` is dx, `result.first.second` is dy and `result.second` is dz? Yes, that's probably the best way to do it.

```
int len = line.size();
double normDx = (line.back().x - line.front().x) / len;
double normDy = (line.back().y - line.front().y) / len;
std::pair ret = std::make_pair(normDx, normDy);
```
First: `normD` is always a whole number (the calculations are done using only integers). So why not return a `std::pair`?

Second: A line usually contains points of a path, that is a list of consecutively adjacent points. Delta-x and delta-y between two consecutive points is at most 1 there and calculated on the whole line means `line.back().x - line.front().x <= line.length()`. Together with the integer calculations above means `normD` is always either -1, 0 or +1. The returned pair usually contains a 0 value, except when the line is exactly a diagonal line (in which case `abs(line.back().x - line.front().x) == len` and the same for y).

I fixed this by using proper floating point calculation (made `len` a `double`).

Than I made `continue_line` (the 2D-version) simpler, just a simple `new_end = end + distance * slope_vector`. For some reason the 3D-version is already that simple, so it can't be wrong.

Now the blood splatters are created in the right direction, which fixes https://github.com/CleverRaven/Cataclysm-DDA/issues/6758#issuecomment-38047370