Skip to content

Commit

Permalink
Distinguish the second truck better in the tutorial.
Browse files Browse the repository at this point in the history
Prevents players from selecting the truck that built the power generator, moving it,
then selecting it again to advance the tutorial state.

Accounts for if both trucks have DORDER_BUILD when checking if the second truck
was helping to build the power generator. This happens if both trucks are close enough
to the build location.
  • Loading branch information
KJeff01 committed Jun 13, 2019
1 parent f41f78a commit 518b256
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions data/base/script/tutorial.js
Expand Up @@ -4,6 +4,7 @@ var consoleVar;
var tutState;
var didTheyHelpBuildGen;
var producedUnits;
var firstTruckID;

//Alias for button
const CLOSE_BUTTON = 0;
Expand Down Expand Up @@ -275,6 +276,23 @@ function checkForPowGen()
{
setReticuleButton(BUILD_BUTTON, _("Build - manufacture constructor droids first"), "", "");
increaseTutorialState();

//Get the truck that is building the generator and store its ID.
var trucks = enumDroid(CAM_HUMAN_PLAYER, DROID_CONSTRUCT);
for (var i = 0, len = trucks.length; i < len; ++i)
{
var truck = trucks[i];
if (truck.order === DORDER_BUILD)
{
firstTruckID = truck.id;
break;
}
}

if (firstTruckID === 0)
{
firstTruckID = trucks[0].id;
}
}
else
{
Expand Down Expand Up @@ -307,7 +325,10 @@ function checkHelpBuild()
for (var i = 0, l = objects.length; i < l; ++i)
{
var obj = objects[i];
if (obj.type === DROID && obj.droidType === DROID_CONSTRUCT && obj.order === DORDER_HELPBUILD)
if (obj.type === DROID &&
obj.droidType === DROID_CONSTRUCT &&
(obj.order === DORDER_HELPBUILD || obj.order === DORDER_BUILD) &&
obj.id !== firstTruckID)
{
increaseTutorialState();
didTheyHelpBuildGen = true;
Expand Down Expand Up @@ -399,7 +420,7 @@ function eventSelectionChanged(objects)
enableStructure("A0ResourceExtractor", CAM_HUMAN_PLAYER);
increaseTutorialState();
}
else if (tut5 && obj.order !== DORDER_BUILD)
else if (tut5 && obj.id !== firstTruckID)
{
increaseTutorialState();
checkHelpBuild();
Expand All @@ -419,6 +440,7 @@ function eventStructureBuilt(structure, droid)
else if (tutState <= 7 && structure.stattype === POWER_GEN)
{
//Maybe they did not understand instructions. Whatever the case, move on.
firstTruckID = 0;
if (!didTheyHelpBuildGen)
{
const NEXT_STATE = 8;
Expand Down Expand Up @@ -460,6 +482,7 @@ function eventStartLevel()
var startpos = getObject("startPosition");
tutState = 0;
didTheyHelpBuildGen = false;
firstTruckID = 0;
producedUnits = {
tank: false,
truck: false,
Expand Down

0 comments on commit 518b256

Please sign in to comment.