Skip to content

Commit 6323807

Browse files
committed
add damageType for terrain kersplosions.
1 parent 6b7db6e commit 6323807

8 files changed

Lines changed: 65 additions & 10 deletions

File tree

‎src/Battlescape/BattlescapeGame.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ void BattlescapeGame::endTurn()
417417
{
418418
Position p = Position(t->getPosition().x * 16, t->getPosition().y * 16, t->getPosition().z * 24);
419419
statePushNext(new ExplosionBState(this, p, 0, 0, t));
420-
t = _save->getTileEngine()->checkForTerrainExplosions();
421420
statePushBack(0);
422421
return;
423422
}

‎src/Battlescape/ExplosionBState.cpp‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,27 @@ void ExplosionBState::explode()
279279
}
280280
if (_tile)
281281
{
282-
save->getTileEngine()->explode(_center, _power, DT_HE, _power/10);
282+
ItemDamageType DT;
283+
switch (_tile->getExplosiveType())
284+
{
285+
case 0:
286+
DT = DT_HE;
287+
break;
288+
case 5:
289+
DT = DT_IN;
290+
break;
291+
case 6:
292+
DT = DT_STUN;
293+
break;
294+
default:
295+
DT = DT_SMOKE;
296+
break;
297+
}
298+
if (DT != DT_HE)
299+
{
300+
_tile->setExplosive(0,0,true);
301+
}
302+
save->getTileEngine()->explode(_center, _power, DT, _power/10);
283303
terrainExplosion = true;
284304
}
285305
if (!_tile && !_item)

‎src/Battlescape/TileEngine.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ void TileEngine::explode(const Position &center, int power, ItemDamageType type,
11681168
if (type == DT_HE)
11691169
{
11701170
// explosives do 1/2 damage to terrain and 1/2 up to 3/2 random damage to units (the halving is handled elsewhere)
1171-
dest->setExplosive(power_);
1171+
dest->setExplosive(power_, 0);
11721172
}
11731173

11741174
ret = tilesAffected.insert(dest); // check if we had this tile already
@@ -1351,7 +1351,7 @@ bool TileEngine::detonate(Tile* tile)
13511351
{
13521352
int explosive = tile->getExplosive();
13531353
if (explosive == 0) return false; // no damage applied for this tile
1354-
tile->setExplosive(0,true);
1354+
tile->setExplosive(0,0,true);
13551355
bool objective = false;
13561356
Tile* tiles[9];
13571357
static const int parts[9]={0,1,2,0,1,2,3,3,3}; //6th is the object of current

‎src/Ruleset/MapData.cpp‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace OpenXcom
2828
MapData::MapData(MapDataSet *dataset) : _dataset(dataset), _specialType(TILE),
2929
_isUfoDoor(false), _stopLOS(false), _isNoFloor(false), _isGravLift(false), _isDoor(false), _blockFire(false), _blockSmoke(false), _baseModule(false),
3030
_yOffset(0), _TUWalk(0), _TUFly(0), _TUSlide(0), _terrainLevel(0), _footstepSound(0), _dieMCD(0), _altMCD(0), _objectType(0), _lightSource(0),
31-
_armor(0), _flammable(0), _fuel(0), _explosive(0), _bigWall(0), _miniMapIndex(0)
31+
_armor(0), _flammable(0), _fuel(0), _explosive(0), _explosiveType(0), _bigWall(0), _miniMapIndex(0)
3232
{
3333
std::fill_n(_sprite, 8, 0);
3434
std::fill_n(_block, 6, 0);
@@ -482,6 +482,24 @@ void MapData::setExplosive(int value)
482482
_explosive = value;
483483
}
484484

485+
/**
486+
* Gets the type of explosive.
487+
* @return The amount of explosive.
488+
*/
489+
int MapData::getExplosiveType() const
490+
{
491+
return _explosiveType;
492+
}
493+
494+
/**
495+
* Sets the type of explosive.
496+
* @param value The type of explosive.
497+
*/
498+
void MapData::setExplosiveType(int value)
499+
{
500+
_explosiveType = value;
501+
}
502+
485503
/**
486504
* Sets the SCANG.DAT index for minimap.
487505
* @param i The minimap index.

‎src/Ruleset/MapData.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class MapData
5656
SpecialTileType _specialType;
5757
bool _isUfoDoor, _stopLOS, _isNoFloor, _isGravLift, _isDoor, _blockFire, _blockSmoke, _baseModule;
5858
int _yOffset, _TUWalk, _TUFly, _TUSlide, _terrainLevel, _footstepSound, _dieMCD, _altMCD, _objectType, _lightSource;
59-
int _armor, _flammable, _fuel, _explosive, _bigWall;
59+
int _armor, _flammable, _fuel, _explosive, _explosiveType, _bigWall;
6060
int _sprite[8];
6161
int _block[6];
6262
int _loftID[12];
@@ -146,6 +146,10 @@ class MapData
146146
int getExplosive() const;
147147
/// Sets the amount of explosive.
148148
void setExplosive(int value);
149+
/// Gets the type of explosive.
150+
int getExplosiveType() const;
151+
/// Sets the type of explosive.
152+
void setExplosiveType(int value);
149153
/// Sets the MiniMap index
150154
void setMiniMapIndex(unsigned short i);
151155
/// Gets the MiniMap index

‎src/Ruleset/MapDataSet.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ void MapDataSet::loadData()
192192
to->setArmor((int)mcd.Armor);
193193
to->setFlammable((int)mcd.Flammable);
194194
to->setFuel((int)mcd.Fuel);
195+
to->setExplosiveType((int)mcd.HE_Type);
195196
to->setExplosive((int)mcd.HE_Strength);
196197
mcd.ScanG = SDL_SwapLE16(mcd.ScanG);
197198
to->setMiniMapIndex(mcd.ScanG);

‎src/Savegame/Tile.cpp‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Tile::SerializationKey Tile::serializationKey =
4949
* constructor
5050
* @param pos Position.
5151
*/
52-
Tile::Tile(const Position& pos): _smoke(0), _fire(0), _explosive(0), _pos(pos), _unit(0), _animationOffset(0), _markerColor(0), _visible(false), _preview(-1), _TUMarker(-1), _overlaps(0), _danger(false)
52+
Tile::Tile(const Position& pos): _smoke(0), _fire(0), _explosive(0), _explosiveType(0), _pos(pos), _unit(0), _animationOffset(0), _markerColor(0), _visible(false), _preview(-1), _TUMarker(-1), _overlaps(0), _danger(false)
5353
{
5454
for (int i = 0; i < 4; ++i)
5555
{
@@ -475,7 +475,7 @@ bool Tile::destroy(int part)
475475
}
476476
if (originalPart->getExplosive())
477477
{
478-
setExplosive(originalPart->getExplosive());
478+
setExplosive(originalPart->getExplosive(), originalPart->getExplosiveType());
479479
}
480480
}
481481
/* check if the floor on the lowest level is gone */
@@ -508,11 +508,12 @@ bool Tile::damage(int part, int power)
508508
* @param power Power of the damage.
509509
* @param force Force damage.
510510
*/
511-
void Tile::setExplosive(int power, bool force)
511+
void Tile::setExplosive(int power, int damageType, bool force)
512512
{
513513
if (force || _explosive < power)
514514
{
515515
_explosive = power;
516+
_explosiveType = damageType;
516517
}
517518
}
518519

@@ -525,6 +526,15 @@ int Tile::getExplosive() const
525526
return _explosive;
526527
}
527528

529+
/**
530+
* Get explosive on this tile.
531+
* @return explosive
532+
*/
533+
int Tile::getExplosiveType() const
534+
{
535+
return _explosiveType;
536+
}
537+
528538
/*
529539
* Flammability of a tile is the lowest flammability of it's objects.
530540
* @return Flammability : the lower the value, the higher the chance the tile/object catches fire.

‎src/Savegame/Tile.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Tile
6969
int _smoke;
7070
int _fire;
7171
int _explosive;
72+
int _explosiveType;
7273
Position _pos;
7374
BattleUnit *_unit;
7475
std::vector<BattleItem *> _inventory;
@@ -165,9 +166,11 @@ class Tile
165166
/// Damage a tile part.
166167
bool damage(int part, int power);
167168
/// Set a "virtual" explosive on this tile, to detonate later.
168-
void setExplosive(int power, bool force = false);
169+
void setExplosive(int power, int damageType, bool force = false);
169170
/// Get explosive power of this tile.
170171
int getExplosive() const;
172+
/// Get explosive power of this tile.
173+
int getExplosiveType() const;
171174
/// Animated the tile parts.
172175
void animate();
173176
/// Get object sprites.

0 commit comments

Comments
 (0)