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

Method updateFallingIntoUnit

game/state/battle/battleunit.cpp:2870–2904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2868}
2869
2870void BattleUnit::updateFallingIntoUnit(GameState &state, BattleUnit &unit)
2871{
2872 if (agent->isBrainsucker)
2873 {
2874 // Must fall from above (almost)
2875 if (velocity.z < 0.1f)
2876 {
2877 if (position.z < unit.getMuzzleLocation().z)
2878 {
2879 StateRef<DamageType> brainsucker = {&state, "DAMAGETYPE_BRAINSUCKER"};
2880 if (!unit.brainSucker &&
2881 brainsucker->dealDamage(100, unit.agent->type->damage_modifier) == 0)
2882 {
2883 // Cannot suck this head, get stunned
2884 applyDamageDirect(state, 9001, false, BodyPart::Body,
2885 agent->current_stats.health + TICKS_PER_TURN);
2886 }
2887 else
2888 {
2889 // Can suck this head, attach!
2890 int facingDelta = BattleUnitMission::getFacingDelta(facing, unit.facing);
2891 cancelMissions(state, true);
2892 spendRemainingTU(state, true);
2893 setMission(state,
2894 BattleUnitMission::brainsuck(*this, {&state, unit.id}, facingDelta));
2895 }
2896 }
2897 }
2898 }
2899 else
2900 {
2901 // Get stunned
2902 applyDamageDirect(state, 9001, false, BodyPart::Body, agent->current_stats.health * 3 / 2);
2903 }
2904}
2905
2906void BattleUnit::updateMovementNormal(GameState &state, unsigned int &moveTicksRemaining,
2907 bool &wasUsingLift)

Callers

nothing calls this directly

Calls 2

dealDamageMethod · 0.80
getMuzzleLocationMethod · 0.45

Tested by

no test coverage detected