Skip to content

Commit

Permalink
Require players to have a HQ just once to use saved templates.
Browse files Browse the repository at this point in the history
Stops an unfair advantage where a player could save a Viper-MG-Wheels template
and begin producing them much sooner than someone who didn't in later matches.
  • Loading branch information
KJeff01 committed Jun 12, 2019
1 parent b7ba6b5 commit 95f25ba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions data/base/script/campaign/cam3-a.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ function eventStartLevel()
setPower(PLAYER_POWER, CAM_HUMAN_PLAYER);
cam3Setup();

enableTemplate("ConstructionDroid");

camSetEnemyBases({
"NEXUS-WBase": {
cleanup: "westBaseCleanup",
Expand Down
2 changes: 2 additions & 0 deletions data/base/script/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ function reticuleDesignCheck()
{
setReticuleButton(4, _("Design - construct HQ first"), "", "");
setMiniMap(false);
// Will enable templates that are researched whenever the reticule buttons update.
setDesign(false);
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ std::map<int, DROID_TEMPLATE *> droidTemplates[MAX_PLAYERS];

bool allowDesign = true;
bool includeRedundantDesigns = false;
bool playerBuiltHQ = false;


static bool researchedItem(const DROID_TEMPLATE* /*psCurr*/, int player, COMPONENT_TYPE partIndex, int part, bool allowZero, bool allowRedundant)
Expand Down Expand Up @@ -645,6 +646,11 @@ void fillTemplateList(std::vector<DROID_TEMPLATE *> &pList, STRUCTURE *psFactory

BODY_SIZE iCapacity = (BODY_SIZE)psFactory->capacity;

if (!playerBuiltHQ)
{
playerBuiltHQ = structureExists(player, REF_HQ, true, false) || structureExists(player, REF_HQ, true, true);
}

/* Add the templates to the list*/
for (DROID_TEMPLATE &i : localTemplates)
{
Expand All @@ -661,8 +667,10 @@ void fillTemplateList(std::vector<DROID_TEMPLATE *> &pList, STRUCTURE *psFactory
}
}

if (!psCurr->enabled || !validTemplateForFactory(psCurr, psFactory, false)
|| !researchedTemplate(psCurr, player, includeRedundantDesigns))
if (!psCurr->enabled
|| (bMultiPlayer && !playerBuiltHQ)
|| !validTemplateForFactory(psCurr, psFactory, false)
|| !researchedTemplate(psCurr, player, includeRedundantDesigns))
{
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/template.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern std::map<int, DROID_TEMPLATE *> droidTemplates[MAX_PLAYERS];

extern bool allowDesign;
extern bool includeRedundantDesigns;
extern bool playerBuiltHQ;


bool initTemplates();
Expand Down

0 comments on commit 95f25ba

Please sign in to comment.