MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / postPathProcedures

Method postPathProcedures

src/Battlescape/UnitWalkBState.cpp:471–529  ·  view source on GitHub ↗

* Handles some calculations when the path is finished. */

Source from the content-addressed store, hash-verified

469 * Handles some calculations when the path is finished.
470 */
471void UnitWalkBState::postPathProcedures()
472{
473 _action.TU = 0;
474 if (_unit->getFaction() != FACTION_PLAYER)
475 {
476 int dir = _action.finalFacing;
477 if (_action.finalAction)
478 {
479 _unit->dontReselect();
480 }
481 if (_unit->getCharging() != 0)
482 {
483 dir = _parent->getTileEngine()->getDirectionTo(_unit->getPosition(), _unit->getCharging()->getPosition());
484 if (_parent->getTileEngine()->validMeleeRange(_unit, _action.actor->getCharging(), dir))
485 {
486 BattleAction action;
487 action.actor = _unit;
488 action.target = _unit->getCharging()->getPosition();
489 action.weapon = _unit->getMainHandWeapon();
490 action.type = BA_HIT;
491 action.TU = _unit->getActionTUs(action.type, action.weapon);
492 action.targeting = true;
493 _unit->setCharging(0);
494 _parent->statePushBack(new ProjectileFlyBState(_parent, action));
495 }
496 }
497 else if (_unit->_hidingForTurn)
498 {
499 dir = _unit->getDirection() + 4;
500 _unit->_hidingForTurn = false;
501 _unit->dontReselect();
502 }
503 if (dir != -1)
504 {
505 if (dir >= 8)
506 {
507 dir -= 8;
508 }
509 _unit->lookAt(dir);
510 while (_unit->getStatus() == STATUS_TURNING)
511 {
512 _unit->turn();
513 _parent->getTileEngine()->calculateFOV(_unit);
514 }
515 }
516 }
517 else if (!_parent->getPanicHandled())
518 {
519 //todo: set the unit to aggrostate and try to find cover?
520 _unit->setTimeUnits(0);
521 }
522
523 _unit->setCache(0);
524 _terrain->calculateUnitLighting();
525 _terrain->calculateFOV(_unit);
526 _parent->getMap()->cacheUnit(_unit);
527 if (!_falling)
528 _parent->popState();

Callers

nothing calls this directly

Calls 15

getFactionMethod · 0.80
dontReselectMethod · 0.80
getChargingMethod · 0.80
getDirectionToMethod · 0.80
validMeleeRangeMethod · 0.80
getMainHandWeaponMethod · 0.80
getActionTUsMethod · 0.80
setChargingMethod · 0.80
statePushBackMethod · 0.80
lookAtMethod · 0.80
turnMethod · 0.80
calculateFOVMethod · 0.80

Tested by

no test coverage detected