=========================== TileEngine.h:144 + /// Get current unit fire origination voxel + Position getUnitFireOrigin(int actiontype, BattleUnit *bu, Position target = Position(-1,-1,-1)); =========================== TileEngine.cpp:837 // closer than 20 tiles distanceSq(unit->getPosition(), (*i)->getPosition()) <= MAX_VIEW_DISTANCE_SQR) { - Position originVoxel = _save->getTileEngine()->getSightOriginVoxel(*i); - originVoxel.z -= 2; + Position originVoxel = _save->getTileEngine()->getUnitFireOrigin(BA_SNAPSHOT, *i, unit->getPosition()); Position targetVoxel; AIModule *ai = (*i)->getAIModule(); bool gotHit = (ai != 0 && ai->getWasHitBy(unit->getId())); =========================== TileEngine.cpp:2911 INSERT /** * Gets the origin voxel of certain action (wrapped version). * @param actiontype Battle action type (BA_SNAPSHOT for example). * @param bu Pointer to the acting battle unit. * @param target position of target tile, OPTIONAL - not set = current direction. * @return origin voxel position. */ Position TileEngine::getUnitFireOrigin(int actiontype, BattleUnit *bu, Position target) { BattleAction action; Position _dir; action.actor = bu; action.type = (BattleActionType) actiontype;// BA_SNAPSHOT; if (target.z<0) { Pathfinding::directionToVector(bu->getDirection(), &_dir); action.target = bu->getPosition() + _dir*2; } else action.target = target; return _save->getTileEngine()->getOriginVoxel(action, 0); } =========================== Projectile.cpp:123 Tile *targetTile = _save->getTile(_action.target); BattleUnit *bu = _action.actor; + if (_targetVoxel.z < 0) + { + Log(LOG_WARNING) << "Failed to shoot (z<0): " << _action.actor->getNameASCII(true) << " at " << _action.actor->getPosition() << " to " << _action.target; + return V_EMPTY; + } int test; if (excludeUnit) =========================== BattleUnit.cpp:2398 INSERT /** * Get unit's name for logging. * An aliens name is its race and rank. * @param debugAppendId Append unit ID to name for debug purposes. * @return name charstring of the unit's name. */ std::string BattleUnit::getNameASCII(bool debugAppendId) const { std::stringstream ss; if (debugAppendId) { ss << _id << " "; } if (_type != "SOLDIER") { if (_type.find("STR_") != std::string::npos) ss << _type; else ss << _race; } else ss << Language::wstrToUtf8(_name); return ss.str(); } =========================== BattleUnit.h:349 /// Gets the unit's name. std::wstring getName(Language *lang, bool debugAppendId = false) const; + /// Gets the unit's loggable name. + std::string getNameASCII(bool debugAppendId) const; /// Gets the unit's stats. UnitStats *getBaseStats();