* Runs state functionality every cycle. * Progresses the death, displays any messages, checks if the mission is over, ... */
| 111 | * Progresses the death, displays any messages, checks if the mission is over, ... |
| 112 | */ |
| 113 | void UnitDieBState::think() |
| 114 | { |
| 115 | if (_unit->getDirection() != 3 && _damageType != DT_HE) |
| 116 | { |
| 117 | int dir = _unit->getDirection() + 1; |
| 118 | if (dir == 8) |
| 119 | { |
| 120 | dir = 0; |
| 121 | } |
| 122 | _unit->lookAt(dir); |
| 123 | _unit->turn(); |
| 124 | if (dir == 3) |
| 125 | { |
| 126 | _parent->setStateInterval(BattlescapeState::DEFAULT_ANIM_SPEED); |
| 127 | } |
| 128 | } |
| 129 | else if (_unit->getStatus() == STATUS_COLLAPSING) |
| 130 | { |
| 131 | _unit->keepFalling(); |
| 132 | } |
| 133 | else if (!_unit->isOut()) |
| 134 | { |
| 135 | _unit->startFalling(); |
| 136 | |
| 137 | if (!_noSound) |
| 138 | { |
| 139 | playDeathSound(); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | if (_unit->isOut()) |
| 144 | { |
| 145 | if (!_noSound && _damageType == DT_HE && _unit->getStatus() != STATUS_UNCONSCIOUS) |
| 146 | { |
| 147 | playDeathSound(); |
| 148 | } |
| 149 | if (_unit->getStatus() == STATUS_UNCONSCIOUS && _unit->getSpecialAbility() == SPECAB_EXPLODEONDEATH) |
| 150 | { |
| 151 | _unit->instaKill(); |
| 152 | } |
| 153 | _parent->getMap()->setUnitDying(false); |
| 154 | if (_unit->getTurnsSinceSpotted() < 255) |
| 155 | { |
| 156 | _unit->setTurnsSinceSpotted(255); |
| 157 | } |
| 158 | if (!_unit->getSpawnUnit().empty()) |
| 159 | { |
| 160 | // converts the dead zombie to a chryssalid |
| 161 | BattleUnit *newUnit = _parent->convertUnit(_unit, _unit->getSpawnUnit()); |
| 162 | newUnit->lookAt(_originalDir); |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | convertUnitToCorpse(); |
| 167 | } |
| 168 | _parent->getTileEngine()->calculateUnitLighting(); |
| 169 | _parent->popState(); |
| 170 | if (_unit->getOriginalFaction() == FACTION_PLAYER && _unit->getSpawnUnit().empty()) |
nothing calls this directly
no test coverage detected