MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / attackTarget

Method attackTarget

game/state/city/vehicle.cpp:2830–2852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2828}
2829
2830bool Vehicle::attackTarget(GameState &state, sp<TileObjectVehicle> enemyTile)
2831{
2832 auto target = enemyTile->getVoxelCentrePosition();
2833 auto targetVelocity = enemyTile->getVehicle()->velocity;
2834 bool checkLOF = true;
2835 auto eq = getFirstFiringWeapon(state, target, checkLOF, targetVelocity, enemyTile);
2836
2837 if (eq)
2838 {
2839 // Cancel cloak
2840 cloakTicksAccumulated = 0;
2841
2842 // Let the enemy dodge us
2843 auto enemyVehicle = enemyTile->getVehicle();
2844 enemyVehicle->ticksAutoActionAvailable = 0;
2845
2846 // Fire
2847 eq->fire(state, target, {&state, enemyVehicle});
2848 return true;
2849 }
2850
2851 return false;
2852}
2853
2854bool Vehicle::attackTarget(GameState &state, sp<TileObjectProjectile> projectileTile)
2855{

Callers

nothing calls this directly

Calls 5

getVehicleMethod · 0.80
getProjectileMethod · 0.80
fireMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected