Skip to content

Commit 3c9294c

Browse files
committed
Merge pull request OpenXcom#1021 from myk002/mission_triggers
Mission triggers
2 parents 567fa48 + 5f1e7b1 commit 3c9294c

4 files changed

Lines changed: 36 additions & 45 deletions

File tree

bin/standard/xcom1/alienDeployments.rul

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,8 +1223,8 @@ alienDeployments:
12231223
shade: 15
12241224
race: STR_SECTOID
12251225
nextStage: STR_MARS_THE_FINAL_ASSAULT
1226-
noRetreat: true
12271226
finalDestination: true
1227+
loseCutscene: losegame
12281228
briefing:
12291229
textOffset: -16
12301230
palette: 6
@@ -1380,13 +1380,13 @@ alienDeployments:
13801380
- UBASE
13811381
shade: 5
13821382
race: STR_MIXED
1383-
noRetreat: true
1384-
finalMission: true
1383+
winCutscene: wingame
1384+
loseCutscene: losegame
13851385
briefing:
13861386
textOffset: -16
13871387
palette: 6
13881388
music: GMNEWMAR
13891389
showTarget: false
13901390
showCraft: false
13911391
background: BACK01.SCR
1392-
script: BOSSBATTLE
1392+
script: BOSSBATTLE

src/Battlescape/BattlescapeState.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,35 +1936,25 @@ void BattlescapeState::finishBattle(bool abort, int inExitArea)
19361936
_animTimer->stop();
19371937
_gameTimer->stop();
19381938
_game->popState();
1939-
if (abort || (!abort && inExitArea == 0))
1939+
_game->pushState(new DebriefingState);
1940+
std::string cutscene;
1941+
if (_game->getRuleset()->getDeployment(_save->getMissionType()))
19401942
{
1941-
// abort was done or no player is still alive
1942-
// this concludes to defeat when in mars or mars landing mission
1943-
if (_game->getRuleset()->getDeployment(_save->getMissionType()) &&
1944-
_game->getRuleset()->getDeployment(_save->getMissionType())->isNoRetreat() &&
1945-
_game->getSavedGame()->getMonthsPassed() > -1)
1943+
if (abort || inExitArea == 0)
19461944
{
1947-
_game->pushState(new CutsceneState("losegame"));
1945+
cutscene = _game->getRuleset()->getDeployment(_save->getMissionType())->getLoseCutscene();
19481946
}
19491947
else
19501948
{
1951-
_game->pushState(new DebriefingState);
1949+
cutscene = _game->getRuleset()->getDeployment(_save->getMissionType())->getWinCutscene();
19521950
}
19531951
}
1954-
else
1952+
if (!cutscene.empty())
19551953
{
1956-
// no abort was done and at least a player is still alive
1957-
// this concludes to victory when in mars mission
1958-
if (_game->getRuleset()->getDeployment(_save->getMissionType()) &&
1959-
_game->getRuleset()->getDeployment(_save->getMissionType())->isFinalMission() &&
1960-
_game->getSavedGame()->getMonthsPassed() > -1)
1961-
{
1962-
_game->pushState(new CutsceneState("wingame"));
1963-
}
1964-
else
1965-
{
1966-
_game->pushState(new DebriefingState);
1967-
}
1954+
// if cutscene is "wingame" or "losegame", then the DebriefingState
1955+
// pushed above will get popped without being shown. otherwise
1956+
// it will get shown after the cutscene.
1957+
_game->pushState(new CutsceneState(cutscene));
19681958
}
19691959
}
19701960
}

src/Ruleset/AlienDeployment.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace OpenXcom
108108
* type of deployment data.
109109
* @param type String defining the type.
110110
*/
111-
AlienDeployment::AlienDeployment(const std::string &type) : _type(type), _width(0), _length(0), _height(0), _civilians(0), _shade(-1), _noRetreat(false), _finalDestination(false), _finalMission(false), _markerIcon(-1), _durationMin(0), _durationMax(0), _minDepth(0), _maxDepth(0), _minSiteDepth(0), _maxSiteDepth(0)
111+
AlienDeployment::AlienDeployment(const std::string &type) : _type(type), _width(0), _length(0), _height(0), _civilians(0), _shade(-1), _finalDestination(false), _markerIcon(-1), _durationMin(0), _durationMax(0), _minDepth(0), _maxDepth(0), _minSiteDepth(0), _maxSiteDepth(0)
112112
{
113113
}
114114

@@ -135,9 +135,9 @@ void AlienDeployment::load(const YAML::Node &node)
135135
_shade = node["shade"].as<int>(_shade);
136136
_nextStage = node["nextStage"].as<std::string>(_nextStage);
137137
_race = node["race"].as<std::string>(_race);
138-
_noRetreat = node["noRetreat"].as<bool>(_noRetreat);
139138
_finalDestination = node["finalDestination"].as<bool>(_finalDestination);
140-
_finalMission = node["finalMission"].as<bool>(_finalMission);
139+
_winCutscene = node["winCutscene"].as<std::string>(_winCutscene);
140+
_loseCutscene = node["loseCutscene"].as<std::string>(_loseCutscene);
141141
_script = node["script"].as<std::string>(_script);
142142
_alert = node["alert"].as<std::string>(_alert);
143143
_briefingData = node["briefing"].as<BriefingData>(_briefingData);
@@ -251,30 +251,30 @@ std::string AlienDeployment::getScript() const
251251
}
252252

253253
/**
254-
* Gets if aborting this mission will fail the game.
255-
* @return if aborting this mission will fail the game.
254+
* Gets if winning this mission completes the game.
255+
* @return if winning this mission completes the game.
256256
*/
257-
bool AlienDeployment::isNoRetreat() const
257+
bool AlienDeployment::isFinalDestination() const
258258
{
259-
return _noRetreat;
259+
return _finalDestination;
260260
}
261261

262262
/**
263-
* Gets if winning this mission completes the game.
264-
* @return if winning this mission completes the game.
263+
* Gets the cutscene to play when the mission is won.
264+
* @return the cutscene to play when the mission is won.
265265
*/
266-
bool AlienDeployment::isFinalDestination() const
266+
std::string AlienDeployment::getWinCutscene() const
267267
{
268-
return _finalDestination;
268+
return _winCutscene;
269269
}
270270

271271
/**
272-
* Gets if winning this mission completes the game.
273-
* @return if winning this mission completes the game.
272+
* Gets the cutscene to play when the mission is lost.
273+
* @return the cutscene to play when the mission is lost.
274274
*/
275-
bool AlienDeployment::isFinalMission() const
275+
std::string AlienDeployment::getLoseCutscene() const
276276
{
277-
return _finalMission;
277+
return _loseCutscene;
278278
}
279279

280280
/**

src/Ruleset/AlienDeployment.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class AlienDeployment
6767
std::vector<std::string> _terrains, _music;
6868
int _shade;
6969
std::string _nextStage, _race, _script;
70-
bool _noRetreat, _finalDestination, _finalMission;
70+
bool _finalDestination;
71+
std::string _winCutscene, _loseCutscene;
7172
std::string _alert;
7273
BriefingData _briefingData;
7374
std::string _markerName;
@@ -97,12 +98,12 @@ class AlienDeployment
9798
std::string getRace() const;
9899
/// Gets the script to use for this deployment.
99100
std::string getScript() const;
100-
/// Checks if aborting this mission will fail the game (all mars and t'leth stages).
101-
bool isNoRetreat() const;
102101
/// Checks if this is the destination for the final mission (mars stage 1, t'leth stage 1).
103102
bool isFinalDestination() const;
104-
/// Checks if winning this mission will complete the game (mars stage 2, t'leth stage 3).
105-
bool isFinalMission() const;
103+
/// Gets the cutscene to play when this mission is won.
104+
std::string getWinCutscene() const;
105+
/// Gets the cutscene to play when this mission is lost.
106+
std::string getLoseCutscene() const;
106107
/// Gets the alert message for this mission type.
107108
std::string getAlertMessage() const;
108109
/// Gets the briefing data for this mission type.

0 commit comments

Comments
 (0)