2323#include " TileEngine.h"
2424#include " Pathfinding.h"
2525#include " Map.h"
26+ #include " InfoboxState.h"
2627#include " Camera.h"
2728#include " AlienBAIState.h"
2829#include " ../Savegame/Tile.h"
2930#include " ../Engine/RNG.h"
31+ #include " ../Engine/Game.h"
32+ #include " ../Engine/Language.h"
3033#include " ../Savegame/SavedBattleGame.h"
3134#include " ../Savegame/BattleUnit.h"
3235#include " ../Savegame/BattleItem.h"
@@ -41,7 +44,7 @@ namespace OpenXcom
4144/* *
4245 * Sets up a MeleeAttackBState.
4346 */
44- MeleeAttackBState::MeleeAttackBState (BattlescapeGame *parent, BattleAction action) : BattleState(parent, action), _unit(0 ), _target(0 ), _weapon(0 ), _ammo(0 ), _initialized(false )
47+ MeleeAttackBState::MeleeAttackBState (BattlescapeGame *parent, BattleAction action) : BattleState(parent, action), _unit(0 ), _target(0 ), _weapon(0 ), _ammo(0 ), _initialized(false ), _deathMessage( false )
4548{
4649}
4750
@@ -128,6 +131,13 @@ void MeleeAttackBState::init()
128131 */
129132void MeleeAttackBState::think ()
130133{
134+ if (_deathMessage)
135+ {
136+ Game *game = _parent->getSave ()->getBattleState ()->getGame ();
137+ game->pushState (new InfoboxState (game->getLanguage ()->getString (" STR_HAS_BEEN_KILLED" , _target->getGender ()).arg (_target->getName (game->getLanguage ()))));
138+ _parent->popState ();
139+ return ;
140+ }
131141 _parent->getSave ()->getBattleState ()->clearMouseScrollingState ();
132142
133143 // if the unit burns floortiles, burn floortiles
@@ -140,7 +150,6 @@ void MeleeAttackBState::think()
140150 // this is because unlike regular bullet hits or explosions, melee attacks can MISS.
141151 // we also do it at this point instead of in performMeleeAttack because we want the scream to come AFTER the hit sound
142152 resolveHit ();
143-
144153 // aliens
145154 if (_unit->getFaction () != FACTION_PLAYER &&
146155 // with enough TU for a second attack (*2 because they'll get charged for the initial attack when this state pops.)
@@ -172,8 +181,15 @@ void MeleeAttackBState::think()
172181 {
173182 _parent->setupCursor ();
174183 }
175- _parent->convertInfected ();
176- _parent->popState ();
184+ if (_parent->convertInfected () && Options::battleNotifyDeath && _target && _target->getFaction () == FACTION_PLAYER )
185+ {
186+ _deathMessage = true ;
187+ _parent->setStateInterval (BattlescapeState::DEFAULT_ANIM_SPEED );
188+ }
189+ else
190+ {
191+ _parent->popState ();
192+ }
177193 }
178194}
179195
0 commit comments