Skip to content

Commit dc91cf7

Browse files
committed
Added a stat gain commendation
1 parent 87377cc commit dc91cf7

5 files changed

Lines changed: 41 additions & 4 deletions

File tree

bin/data/Ruleset/Commendations.rul

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ extraStrings:
339339
STR_MEDAL_ALLRANKS_DESCRIPTION: "Given to a soldier who as killed aliens of all ranks."
340340
STR_MEDAL_ORIGINAL8_NAME: "First to Serve"
341341
STR_MEDAL_ORIGINAL8_DESCRIPTION: "Given to a soldier who was first in line to combat the enemy unknown."
342+
STR_MEDAL_STATGAIN_NAME: "Improvement Citation"
343+
STR_MEDAL_STATGAIN_DESCRIPTION: "Given to a soldier who has dedicated himself or herself to improvement."
342344
STR_AWARD_0: "First award"
343345
STR_AWARD_1: "Second award"
344346
STR_AWARD_2: "Third award"
@@ -509,6 +511,8 @@ extraStrings:
509511
STR_MEDAL_ALLRANKS_DESCRIPTION: "Given to a soldier who as killed aliens of all ranks."
510512
STR_MEDAL_ORIGINAL8_NAME: "First to Serve"
511513
STR_MEDAL_ORIGINAL8_DESCRIPTION: "Given to a soldier who was first in line to combat the enemy unknown."
514+
STR_MEDAL_STATGAIN_NAME: "Improvement Citation"
515+
STR_MEDAL_STATGAIN_DESCRIPTION: "Given to a soldier who has dedicated himself or herself to improvement."
512516
STR_AWARD_0: "First award"
513517
STR_AWARD_1: "Second award"
514518
STR_AWARD_2: "Third award"
@@ -1355,7 +1359,12 @@ commendations:
13551359
sprite: 00
13561360
criteria:
13571361
totalLongDistanceHits: [999]
1358-
# Dummy criteria so the game doesn't enter an infinite loop .
1362+
# Dummy criteria so the game doesn't enter an infinite loop.
1363+
- type: STR_MEDAL_STATGAIN_NAME
1364+
description: STR_MEDAL_STATGAIN_DESCRIPTION
1365+
sprite: 00
1366+
criteria:
1367+
totalStatGain: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
13591368
ufopaedia:
13601369
- id: STR_MEDAL_MILITARY_CROSS_NAME
13611370
type_id: 7
@@ -1686,6 +1695,13 @@ ufopaedia:
16861695
text: STR_MEDAL_ORIGINAL8_MEDAL_UFOPEDIA
16871696
text_width: 164
16881697
listOrder: 6046
1698+
- id: STR_MEDAL_STATGAIN_NAME
1699+
type_id: 7
1700+
section: STR_HEAVY_WEAPONS_PLATFORMS
1701+
image_id: PLACEHOLDER #STATGAIN
1702+
text: STR_MEDAL_STATGAIN_MEDAL_UFOPEDIA
1703+
text_width: 164
1704+
listOrder: 6046
16891705
# entries below move the HWPs to the Craft Section of the UFOPedia
16901706
- id: STR_TANK_CANNON
16911707
section: STR_XCOM_CRAFT_ARMAMENT

src/Battlescape/DebriefingState.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ DebriefingState::DebriefingState() : _region(0), _country(0), _noContainment(fal
285285
(*j)->getStatistics()->KIA = true;
286286
}
287287

288+
// Set the UnitStats delta
289+
(*j)->getStatistics()->delta = *(*j)->getGeoscapeSoldier()->getCurrentStats() - *(*j)->getGeoscapeSoldier()->getInitStats();
290+
288291
(*j)->getGeoscapeSoldier()->getDiary()->updateDiary((*j)->getStatistics(), _missionStatistics, _game->getRuleset());
289292
if ((*j)->getStatus() != STATUS_DEAD && (*j)->getGeoscapeSoldier()->getDiary()->manageCommendations(_game->getRuleset()))
290293
{

src/Savegame/BattleUnit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct BattleUnitStatistics
184184
bool nikeCross; // Tracks if a soldier killed every alien
185185
bool mercyCross; // Tracks if a soldier stunned every alien
186186
int woundsHealed; // Tracks how many times a fatal wound was healed by thits unit
187+
UnitStats delta; // Tracks the increase in unit stats
187188

188189
/// Functions
189190
// Friendly fire check

src/Savegame/SoldierDiary.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ SoldierDiary::SoldierDiary() : _killList(), _regionTotal(), _countryTotal(), _ty
4040
_totalShotByFriendlyCounter(0), _totalShotFriendlyCounter(0), _ironManTotal(0), _importantMissionTotal(0), _longDistanceHitCounterTotal(0),
4141
_lowAccuracyHitCounterTotal(0), _shotsFiredCounterTotal(0), _shotsLandedCounterTotal(0), _shotAtCounter10in1Mission(0), _hitCounter5in1Mission(0),
4242
_reactionFireTotal(0), _timesWoundedTotal(0), _valiantCruxTotal(0), _KIA(0), _trapKillTotal(0), _alienBaseAssaultTotal(0), _allAliensKilledTotal(0), _allAliensStunnedTotal(0),
43-
_woundsHealedTotal(0), _allUFOs(0), _allMissionTypes(0)
43+
_woundsHealedTotal(0), _allUFOs(0), _allMissionTypes(0), _statGainTotal(0)
4444
{
4545
}
4646
/**
@@ -112,6 +112,7 @@ void SoldierDiary::load(const YAML::Node& node)
112112
_woundsHealedTotal = node["_woundsHealedTotal"].as<int>(_woundsHealedTotal);
113113
_allUFOs = node["_allUFOs"].as<int>(_allUFOs);
114114
_allMissionTypes = node["_allMissionTypes"].as<int>(_allMissionTypes);
115+
_statGainTotal = node["_statGainTotal"].as<int>(_statGainTotal);
115116
}
116117
/**
117118
* Saves the diary to a YAML file.
@@ -163,6 +164,7 @@ YAML::Node SoldierDiary::save() const
163164
if (_woundsHealedTotal) node["_woundsHealedTotal"] = _woundsHealedTotal;
164165
if (_allUFOs) node["_allUFOs"] = _allUFOs;
165166
if (_allMissionTypes) node["_allMissionTypes"] = _allMissionTypes;
167+
if (_statGainTotal) node["_statGainTotal"] =_statGainTotal;
166168
return node;
167169
}
168170
/**
@@ -253,6 +255,20 @@ void SoldierDiary::updateDiary(BattleUnitStatistics *unitStatistics, MissionStat
253255
_allUFOs = 1;
254256
if ((_UFOTotal.size() + _typeTotal.size()) == (rules->getUfosList().size() + rules->getDeploymentsList().size() - 2))
255257
_allMissionTypes = 1;
258+
259+
// Stat change long hand calculation
260+
_statGainTotal += unitStatistics->delta.tu;
261+
_statGainTotal += unitStatistics->delta.stamina;
262+
_statGainTotal += unitStatistics->delta.health;
263+
_statGainTotal += unitStatistics->delta.bravery / 10; // Normalize
264+
_statGainTotal += unitStatistics->delta.reactions;
265+
_statGainTotal += unitStatistics->delta.firing;
266+
_statGainTotal += unitStatistics->delta.throwing;
267+
_statGainTotal += unitStatistics->delta.strength;
268+
_statGainTotal += unitStatistics->delta.psiStrength;
269+
_statGainTotal += unitStatistics->delta.melee;
270+
_statGainTotal += unitStatistics->delta.psiSkill;
271+
256272
_missionIdList.push_back(missionStatistics->id);
257273
}
258274
/**
@@ -334,7 +350,8 @@ bool SoldierDiary::manageCommendations(Ruleset *rules)
334350
((*j).first == "totalAllAliensStunned" && _allAliensStunnedTotal < (*j).second.at(nextCommendationLevel["noNoun"])) ||
335351
((*j).first == "totalWoundsHealed" && _woundsHealedTotal < (*j).second.at(nextCommendationLevel["noNoun"])) ||
336352
((*j).first == "totalAllUFOs" && _allUFOs < (*j).second.at(nextCommendationLevel["noNoun"])) ||
337-
((*j).first == "totalAllMissionTypes" && _allMissionTypes < (*j).second.at(nextCommendationLevel["noNoun"])) )
353+
((*j).first == "totalAllMissionTypes" && _allMissionTypes < (*j).second.at(nextCommendationLevel["noNoun"])) ||
354+
((*j).first == "totalStatGain" && _statGainTotal < (*j).second.at(nextCommendationLevel["noNoun"])) )
338355
{
339356
awardCommendationBool = false;
340357
break;

src/Savegame/SoldierDiary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SoldierDiary
7676
_terrorMissionTotal, _nightMissionTotal, _nightTerrorMissionTotal, _monthsService, _unconciousTotal, _shotAtCounterTotal, _hitCounterTotal, _ironManTotal,
7777
_importantMissionTotal, _longDistanceHitCounterTotal, _lowAccuracyHitCounterTotal, _shotsFiredCounterTotal, _shotsLandedCounterTotal, _shotAtCounter10in1Mission,
7878
_hitCounter5in1Mission, _reactionFireTotal, _timesWoundedTotal, _valiantCruxTotal, _KIA, _trapKillTotal, _alienBaseAssaultTotal, _allAliensKilledTotal, _allAliensStunnedTotal,
79-
_woundsHealedTotal, _allUFOs, _allMissionTypes;
79+
_woundsHealedTotal, _allUFOs, _allMissionTypes, _statGainTotal;
8080
void manageModularCommendations(std::map<std::string, int> &nextCommendationLevel, std::map<std::string, int> &modularCommendations, std::pair<std::string, int> statTotal, int criteria);
8181
void awardCommendation(std::string type, std::string noun = "noNoun");
8282
public:

0 commit comments

Comments
 (0)