Skip to content

Commit

Permalink
Allow setting propulsion types via chat command
Browse files Browse the repository at this point in the history
Plus more tweaking to this functionality.
  • Loading branch information
KJeff01 committed Aug 1, 2023
1 parent 2469854 commit 14651b3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
4 changes: 4 additions & 0 deletions data/base/script/campaign/libcampaign_includes/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function cam_eventChat(from, to, message)
camSetExpLevel(Number(message.substring(5)));
camSetOnMapEnemyUnitExp();
}
if (message.lastIndexOf("prop ", 0) === 0)
{
camSetPropulsionTypeLimit(Number(message.substring(5)));
}
if (!camIsCheating())
{
return;
Expand Down
35 changes: 16 additions & 19 deletions data/base/script/campaign/libcampaign_includes/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ function camQueueDroidProduction(playerId, template)

//;; ## camSetPropulsionTypeLimit([limit])
//;;
//;; On hard and insane the propulsion type can be limited with this.
//;; For type II pass in `2`, and for type III pass in `3`. Hard defaults to type II and insane defaults to type III.
//;; If nothing is passed in then the type limit will match what is in templates.json.
//;; This function can automatically augment units to use Type I/II/III propulsions.
//;; If nothing or zero is passed in then the type limit will match what is in templates.json.
//;;
//;; @param {number} [limit]
//;; @returns {void}
Expand All @@ -164,6 +163,10 @@ function camSetPropulsionTypeLimit(limit)
{
__camPropulsionTypeLimit = "NO_USE";
}
else if (limit === 1)
{
__camPropulsionTypeLimit = "01";
}
else if (limit === 2)
{
__camPropulsionTypeLimit = "02";
Expand All @@ -172,6 +175,10 @@ function camSetPropulsionTypeLimit(limit)
{
__camPropulsionTypeLimit = "03";
}
else
{
camTrace("Unknown propulsion level specified. Use 1 - 3 to force the propulsion type, 0 to disable.");
}
}

//;; ## camUpgradeOnMapTemplates(template1, template2, playerId[, excluded])
Expand Down Expand Up @@ -238,7 +245,7 @@ function camUpgradeOnMapTemplates(template1, template2, playerId, excluded)
let droidInfo = {x: dr.x, y: dr.y, name: dr.name};
camSafeRemoveObject(dr, false);
let droid = addDroid(playerId, droidInfo.x, droidInfo.y, droidInfo.name, template2.body,
__camChangePropulsionOnDiff(template2.prop), "", "", template2.weap);
__camChangePropulsionOnDiff(template2.prop, playerId), "", "", template2.weap);
camSetDroidExperience(droid);
}
}
Expand Down Expand Up @@ -297,11 +304,11 @@ function __camAddDroidToFactoryGroup(droid, structure)
__camFactoryUpdateTactics(flabel);
}

function __camChangePropulsionOnDiff(propulsion)
function __camChangePropulsionOnDiff(propulsion, playerId)
{
if (__camPropulsionTypeLimit === "NO_USE")
if (__camPropulsionTypeLimit === "NO_USE" || playerId === CAM_HUMAN_PLAYER)
{
return propulsion; //this mission don't want this feature then
return propulsion;
}

var name = propulsion;
Expand All @@ -320,17 +327,7 @@ function __camChangePropulsionOnDiff(propulsion)
var currentProp = VALID_PROPS[i];
if (name === currentProp)
{
var typeModifier;
//if a future template has a type III and the limit is type II then this will ensure it stays type III.
if (__camPropulsionTypeLimit === "02" && lastTwo === "03")
{
typeModifier = "03";
}
else
{
typeModifier = __camPropulsionTypeLimit;
}
return currentProp.concat(typeModifier);
return currentProp.concat(__camPropulsionTypeLimit);
}
}

Expand All @@ -350,7 +347,7 @@ function __camBuildDroid(template, structure)
{
return false;
}
var prop = __camChangePropulsionOnDiff(template.prop);
var prop = __camChangePropulsionOnDiff(template.prop, structure.player);
makeComponentAvailable(template.body, structure.player);
makeComponentAvailable(prop, structure.player);
makeComponentAvailable(template.weap, structure.player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function camSendReinforcement(playerId, position, templates, kind, data)
for (let i = 0, l = templates.length; i < l; ++i)
{
var template = templates[i];
var prop = __camChangePropulsionOnDiff(template.prop);
var prop = __camChangePropulsionOnDiff(template.prop, playerId);
var droid = addDroid(playerId, pos.x, pos.y, "Reinforcement", template.body, prop, "", "", template.weap);
camSetDroidExperience(droid);
droids.push(droid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function __camDispatchTransporterUnsafe()
for (let i = 0, l = list.length; i < l; ++i)
{
var template = list[i];
var prop = __camChangePropulsionOnDiff(template.prop);
var prop = __camChangePropulsionOnDiff(template.prop, player);
var droid = addDroid(player, -1, -1, "Reinforcement", template.body, prop, "", "", template.weap);
droids.push(droid);
addDroidToTransporter(trans, droid);
Expand Down

0 comments on commit 14651b3

Please sign in to comment.