Skip to content

Commit 1903b62

Browse files
committed
make the vapor probability a ruleset value.
1 parent bd3aeff commit 1903b62

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎src/Battlescape/Projectile.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Projectile::Projectile(ResourcePack *res, SavedBattleGame *save, BattleAction ac
7171
_bulletSprite = ammo->getRules()->getBulletSprite();
7272
_vaporColor = ammo->getRules()->getVaporColor();
7373
_vaporDensity = ammo->getRules()->getVaporDensity();
74+
_vaporProbability = ammo->getRules()->getVaporProbability();
7475
_speed = std::max(1, _speed + ammo->getRules()->getBulletSpeed());
7576
}
7677

@@ -87,7 +88,10 @@ Projectile::Projectile(ResourcePack *res, SavedBattleGame *save, BattleAction ac
8788
{
8889
_vaporDensity = _action.weapon->getRules()->getVaporDensity();
8990
}
91+
if (_vaporProbability == 5)
9092
{
93+
_vaporProbability = _action.weapon->getRules()->getVaporProbability();
94+
}
9195
if (!ammo || (ammo != _action.weapon || ammo->getRules()->getBulletSpeed() == 0))
9296
{
9397
_speed = std::max(1, _speed + _action.weapon->getRules()->getBulletSpeed());
@@ -364,7 +368,7 @@ bool Projectile::move()
364368
_position--;
365369
return false;
366370
}
367-
if (_save->getDepth() > 0 && _vaporColor != -1 && _action.type != BA_THROW && RNG::percent(5))
371+
if (_save->getDepth() > 0 && _vaporColor != -1 && _action.type != BA_THROW && RNG::percent(_vaporProbability))
368372
{
369373
addVaporCloud();
370374
}

‎src/Battlescape/Projectile.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Projectile
4949
int _speed;
5050
int _bulletSprite;
5151
bool _reversed;
52-
int _vaporColor, _vaporDensity;
52+
int _vaporColor, _vaporDensity, _vaporProbability;
5353
void applyAccuracy(const Position& origin, Position *target, double accuracy, bool keepRange, Tile *targetTile, bool extendLine);
5454
public:
5555
/// Creates a new Projectile.

‎src/Ruleset/RuleItem.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RuleItem::RuleItem(const std::string &type) : _type(type), _name(type), _size(0.
3232
_accuracyAuto(0), _accuracySnap(0), _accuracyAimed(0), _tuAuto(0), _tuSnap(0), _tuAimed(0), _clipSize(0), _accuracyMelee(0), _tuMelee(0), _battleType(BT_NONE), _twoHanded(false), _waypoint(false), _fixedWeapon(false), _invWidth(1), _invHeight(1),
3333
_painKiller(0), _heal(0), _stimulant(0), _woundRecovery(0), _healthRecovery(0), _stunRecovery(0), _energyRecovery(0), _tuUse(0), _recoveryPoints(0), _armor(20), _turretType(-1), _recover(true), _liveAlien(false), _blastRadius(-1), _attraction(0),
3434
_flatRate(false), _arcingShot(false), _listOrder(0), _maxRange(200), _aimRange(200), _snapRange(15), _autoRange(7), _minRange(0), _dropoff(2), _bulletSpeed(0), _explosionSpeed(0), _autoShots(3), _shotgunPellets(0),
35-
_strengthApplied(false), _skillApplied(true), _LOSRequired(false), _underwaterOnly(false), _meleeSound(39), _meleePower(0), _meleeAnimation(0), _meleeHitSound(-1), _specialType(-1), _vaporColor(-1), _vaporDensity(0)
35+
_strengthApplied(false), _skillApplied(true), _LOSRequired(false), _underwaterOnly(false), _meleeSound(39), _meleePower(0), _meleeAnimation(0), _meleeHitSound(-1), _specialType(-1), _vaporColor(-1), _vaporDensity(0), _vaporProbability(5)
3636
{
3737
}
3838

@@ -184,6 +184,7 @@ void RuleItem::load(const YAML::Node &node, int modIndex, int listOrder)
184184
_specialType = node["specialType"].as<int>(_specialType);
185185
_vaporColor = node["vaporColor"].as<int>(_vaporColor);
186186
_vaporDensity = node["vaporDensity"].as<int>(_vaporDensity);
187+
_vaporProbability = node["vaporProbability"].as<int>(_vaporProbability);
187188

188189
if (!_listOrder)
189190
{
@@ -922,4 +923,14 @@ const int RuleItem::getVaporDensity() const
922923
{
923924
return _vaporDensity;
924925
}
926+
927+
/**
928+
* Gets the vapor cloud probability for the vapor trail.
929+
* @return the vapor probability.
930+
*/
931+
const int RuleItem::getVaporProbability() const
932+
{
933+
return _vaporProbability;
934+
}
935+
925936
}

‎src/Ruleset/RuleItem.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class RuleItem
6767
int _listOrder, _maxRange, _aimRange, _snapRange, _autoRange, _minRange, _dropoff, _bulletSpeed, _explosionSpeed, _autoShots, _shotgunPellets;
6868
std::string _zombieUnit;
6969
bool _strengthApplied, _skillApplied, _LOSRequired, _underwaterOnly;
70-
int _meleeSound, _meleePower, _meleeAnimation, _meleeHitSound, _specialType, _vaporColor, _vaporDensity;
70+
int _meleeSound, _meleePower, _meleeAnimation, _meleeHitSound, _specialType, _vaporColor, _vaporDensity, _vaporProbability;
7171
public:
7272
/// Creates a blank item ruleset.
7373
RuleItem(const std::string &type);
@@ -227,6 +227,8 @@ class RuleItem
227227
const int getVaporColor() const;
228228
/// Gets the vapor cloud density.
229229
const int getVaporDensity() const;
230+
/// Gets the vapor cloud probability.
231+
const int getVaporProbability() const;
230232

231233
};
232234

0 commit comments

Comments
 (0)