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

Method think

src/Battlescape/UnitDieBState.cpp:113–208  ·  view source on GitHub ↗

* Runs state functionality every cycle. * Progresses the death, displays any messages, checks if the mission is over, ... */

Source from the content-addressed store, hash-verified

111 * Progresses the death, displays any messages, checks if the mission is over, ...
112 */
113void 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())

Callers

nothing calls this directly

Calls 15

lookAtMethod · 0.80
turnMethod · 0.80
keepFallingMethod · 0.80
isOutMethod · 0.80
startFallingMethod · 0.80
instaKillMethod · 0.80
setUnitDyingMethod · 0.80
getTurnsSinceSpottedMethod · 0.80
setTurnsSinceSpottedMethod · 0.80
convertUnitMethod · 0.80
calculateUnitLightingMethod · 0.80
getOriginalFactionMethod · 0.80

Tested by

no test coverage detected