Permalink
Browse files

Merge pull request #1187 from Player701/ModdableCapturability

Allow mods to define whether a unit can be captured alive. Cyberdisc and Sectopod are now uncapturable in vanilla.

Modder alert: Exploding units are now capturable by default.
  • Loading branch information...
SupSuper committed Jul 8, 2018
2 parents 9c71d43 + 888aa6d commit 642c7bbbf9b4707eb61cb14a08ed60e1625807c3
@@ -307,6 +307,7 @@ units:
energyRecovery: 50
specab: 1
livingWeapon: true
capturable: false
- type: STR_FLOATER_SOLDIER
race: STR_FLOATER
rank: STR_LIVE_SOLDIER
@@ -829,6 +830,7 @@ units:
aggression: 1
energyRecovery: 50
livingWeapon: true
capturable: false
- type: STR_ZOMBIE
race: STR_ZOMBIE
rank: STR_LIVE_TERRORIST
@@ -211,7 +211,7 @@ void UnitDieBState::think()
{
playDeathSound();
}
if (_unit->getStatus() == STATUS_UNCONSCIOUS && (_unit->getSpecialAbility() == SPECAB_EXPLODEONDEATH || _unit->getSpecialAbility() == SPECAB_BURN_AND_EXPLODE))
if (_unit->getStatus() == STATUS_UNCONSCIOUS && !_unit->getCapturable())
{
_unit->instaKill();
}
@@ -27,7 +27,7 @@ namespace OpenXcom
* Creates a certain type of unit.
* @param type String defining the type.
*/
Unit::Unit(const std::string &type) : _type(type), _standHeight(0), _kneelHeight(0), _floatHeight(0), _value(0), _aggroSound(-1), _moveSound(-1), _intelligence(0), _aggression(0), _energyRecovery(30), _specab(SPECAB_NONE), _livingWeapon(false), _psiWeapon("ALIEN_PSI_WEAPON")
Unit::Unit(const std::string &type) : _type(type), _standHeight(0), _kneelHeight(0), _floatHeight(0), _value(0), _aggroSound(-1), _moveSound(-1), _intelligence(0), _aggression(0), _energyRecovery(30), _specab(SPECAB_NONE), _livingWeapon(false), _psiWeapon("ALIEN_PSI_WEAPON"), _capturable(true)
{
}
@@ -67,6 +67,7 @@ void Unit::load(const YAML::Node &node, Mod *mod)
_livingWeapon = node["livingWeapon"].as<bool>(_livingWeapon);
_meleeWeapon = node["meleeWeapon"].as<std::string>(_meleeWeapon);
_psiWeapon = node["psiWeapon"].as<std::string>(_psiWeapon);
_capturable = node["capturable"].as<bool>(_capturable);
_builtInWeapons = node["builtInWeaponSets"].as<std::vector<std::vector<std::string> > >(_builtInWeapons);
if (node["builtInWeapons"])
{
@@ -293,4 +294,13 @@ const std::vector<std::vector<std::string> > &Unit::getBuiltInWeapons() const
return _builtInWeapons;
}
/**
* Gets whether the alien can be captured alive.
* @return a value determining whether the alien can be captured alive.
*/
bool Unit::getCapturable() const
{
return _capturable;
}
}
@@ -71,6 +71,7 @@ class Unit
bool _livingWeapon;
std::string _meleeWeapon, _psiWeapon;
std::vector<std::vector<std::string> > _builtInWeapons;
bool _capturable;
public:
/// Creates a blank unit ruleset.
Unit(const std::string &type);
@@ -120,6 +121,8 @@ class Unit
std::string getPsiWeapon() const;
/// Gets a vector of integrated items this unit has available.
const std::vector<std::vector<std::string> > &getBuiltInWeapons() const;
/// Gets whether the alien can be captured alive.
bool getCapturable() const;
};
}
@@ -54,7 +54,7 @@ BattleUnit::BattleUnit(Soldier *soldier, int depth) :
_expBravery(0), _expReactions(0), _expFiring(0), _expThrowing(0), _expPsiSkill(0), _expPsiStrength(0), _expMelee(0),
_motionPoints(0), _kills(0), _hitByFire(false), _hitByAnything(false), _moraleRestored(0), _coverReserve(0), _charging(0), _turnsSinceSpotted(255),
_statistics(), _murdererId(0), _mindControllerID(0), _fatalShotSide(SIDE_FRONT), _fatalShotBodyPart(BODYPART_HEAD),
_geoscapeSoldier(soldier), _unitRules(0), _rankInt(0), _turretType(-1), _hidingForTurn(false), _respawn(false)
_geoscapeSoldier(soldier), _unitRules(0), _rankInt(0), _turretType(-1), _hidingForTurn(false), _respawn(false), _capturable(true)
{
_name = soldier->getName(true);
_id = soldier->getId();
@@ -187,6 +187,7 @@ BattleUnit::BattleUnit(Unit *unit, UnitFaction faction, int id, Armor *armor, St
_spawnUnit = unit->getSpawnUnit();
_value = unit->getValue();
_faceDirection = -1;
_capturable = unit->getCapturable();
_movementType = _armor->getMovementType();
if (_movementType == MT_FLOAT)
@@ -3287,4 +3288,12 @@ void BattleUnit::resetHitState()
_hitByAnything = false;
}
/**
* Gets whether this unit can be captured alive (applies to aliens).
*/
bool BattleUnit::getCapturable() const
{
return _capturable;
}
}
@@ -128,6 +128,7 @@ class BattleUnit
bool _hidingForTurn, _floorAbove, _respawn;
MovementType _movementType;
std::vector<std::pair<Uint8, Uint8> > _recolor;
bool _capturable;
/// Helper function initing recolor vector.
void setRecolor(int basicLook, int utileLook, int rankLook);
@@ -502,7 +503,8 @@ class BattleUnit
bool getHitState();
/// reset the unit hit state.
void resetHitState();
/// Gets whether this unit can be captured alive (applies to aliens).
bool getCapturable() const;
};
}

0 comments on commit 642c7bb

Please sign in to comment.