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

Method dropDown

game/state/battle/battleunit.cpp:4454–4552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4452}
4453
4454void BattleUnit::dropDown(GameState &state)
4455{
4456 state.current_battle->checkMissionEnd(state, false);
4457 state.current_battle->checkIfBuildingDisabled(state);
4458 // Reset states, cancel actions
4459 cloakTicksAccumulated = 0;
4460 stopAttacking();
4461 stopAttackPsi(state);
4462 // Iterate over copy as stopAttackPsi will modify the map.
4463 auto psiAttackersCopy = psiAttackers;
4464 for (auto &a : psiAttackersCopy)
4465 {
4466 auto attacker = StateRef<BattleUnit>(&state, a.first);
4467 if (attacker->psiStatus != PsiStatus::Stun)
4468 {
4469 attacker->stopAttackPsi(state);
4470 }
4471 }
4472
4473 aiList.reset(state, *this);
4474 resetGoal();
4475 setHandState(HandState::AtEase);
4476 setBodyState(state, target_body_state);
4477 startFalling(state);
4478 brainSucker.clear();
4479 fireDebuffTicksRemaining = 0;
4480 enzymeDebuffIntensity = 0;
4481 moraleState = MoraleState::Normal;
4482 BodyState targetState = isDead() ? BodyState::Dead : BodyState::Downed;
4483 // Check if we can drop from current state
4484 // Adjust current state so that we can then drop down
4485 BodyState proposedBodyState = current_body_state;
4486 while (agent->getAnimationPack()->getFrameCountBody(displayedItem, proposedBodyState,
4487 targetState, current_hand_state,
4488 current_movement_state, facing) == 0)
4489 {
4490 switch (proposedBodyState)
4491 {
4492 case BodyState::Jumping:
4493 case BodyState::Throwing:
4494 case BodyState::Flying:
4495 if (agent->isBodyStateAllowed(BodyState::Standing))
4496 {
4497 proposedBodyState = BodyState::Standing;
4498 continue;
4499 }
4500 // Intentional fall-through
4501 case BodyState::Standing:
4502 if (agent->isBodyStateAllowed(BodyState::Kneeling))
4503 {
4504 proposedBodyState = BodyState::Kneeling;
4505 continue;
4506 }
4507 // Intentional fall-through
4508 case BodyState::Kneeling:
4509 proposedBodyState = BodyState::Prone;
4510 continue;
4511 // Unit has no downed animation, abort

Callers

nothing calls this directly

Calls 11

markUnVisibleMethod · 0.95
checkMissionEndMethod · 0.80
stopAttackPsiMethod · 0.80
getFrameCountBodyMethod · 0.80
getAnimationPackMethod · 0.80
isBodyStateAllowedMethod · 0.80
endMethod · 0.80
resetMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected