Skip to content

Commit 170ff45

Browse files
committed
add "siteType" to alienMissions
allow modders to override what kind of terror mission will be spawned.
1 parent be78b8a commit 170ff45

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

‎src/Mod/RuleAlienMission.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ void RuleAlienMission::load(const YAML::Node &node)
8282
_spawnZone = node["spawnZone"].as<int>(_spawnZone);
8383
_weights = node["missionWeights"].as< std::map<size_t, int> >(_weights);
8484
_retaliationOdds = node["retaliationOdds"].as<int>(_retaliationOdds);
85+
_siteType = node["siteType"].as<std::string>(_siteType);
8586
//Only allow full replacement of mission racial distribution.
8687
if (const YAML::Node &weights = node["raceWeights"])
8788
{

‎src/Mod/RuleAlienMission.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class RuleAlienMission
9292
int getWeight(const size_t monthsPassed) const;
9393
/// Gets the inherent odds of this mission spawning a retaliation mission.
9494
int getRetaliationOdds() const;
95+
/// the type of missionSite to spawn (if any)
96+
std::string getSiteType() const { return _siteType; }
9597
private:
9698
/// The mission's type ID.
9799
std::string _type;
@@ -111,6 +113,8 @@ class RuleAlienMission
111113
int _spawnZone;
112114
/// The odds that this mission will result in retaliation
113115
int _retaliationOdds;
116+
/// the type of missionSite to spawn (if any)
117+
std::string _siteType;
114118
};
115119

116120
}

‎src/Savegame/AlienMission.cpp‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class MatchBaseCoordinates: public std::unary_function<const Base *, bool>
372372
*/
373373
void AlienMission::ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe)
374374
{
375-
const Mod &rules = *engine.getMod();
375+
const Mod &mod = *engine.getMod();
376376
SavedGame &game = *engine.getSavedGame();
377377
const size_t curWaypoint = ufo.getTrajectoryPoint();
378378
const size_t nextWaypoint = curWaypoint + 1;
@@ -392,7 +392,7 @@ void AlienMission::ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe
392392
}
393393
ufo.setAltitude(trajectory.getAltitude(nextWaypoint));
394394
ufo.setTrajectoryPoint(nextWaypoint);
395-
const RuleRegion &regionRules = *rules.getRegion(_region);
395+
const RuleRegion &regionRules = *mod.getRegion(_region);
396396
std::pair<double, double> pos = getWaypoint(trajectory, nextWaypoint, globe, regionRules);
397397

398398
Waypoint *wp = new Waypoint();
@@ -418,8 +418,16 @@ void AlienMission::ufoReachedWaypoint(Ufo &ufo, Game &engine, const Globe &globe
418418
ufo.setStatus(Ufo::DESTROYED);
419419

420420
MissionArea area = regionRules.getMissionZones().at(trajectory.getZone(curWaypoint)).areas.at(_missionSiteZone);
421-
Texture *texture = rules.getGlobe()->getTexture(area.texture);
422-
AlienDeployment *deployment = rules.getDeployment(texture->getRandomDeployment());
421+
Texture *texture = mod.getGlobe()->getTexture(area.texture);
422+
AlienDeployment *deployment;
423+
if (mod.getDeployment(_rule.getSiteType()))
424+
{
425+
deployment = mod.getDeployment(_rule.getSiteType());
426+
}
427+
else
428+
{
429+
deployment = mod.getDeployment(texture->getRandomDeployment());
430+
}
423431
MissionSite *missionSite = spawnMissionSite(game, deployment, area);
424432
if (missionSite)
425433
{

0 commit comments

Comments
 (0)