Skip to content

Commit

Permalink
Various Bugfixes
Browse files Browse the repository at this point in the history
- Changed DROID_TRANSPORT to DROID_SUPERTRANSPORTER where applicable (fixes #2)
- Fixed bomb upgrades referencing a non-existing research message
- Updated debug.js to the latest version to fix various incompatibilities
  • Loading branch information
DARwins1 committed Jan 9, 2023
1 parent ed77667 commit 677a7f5
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 85 deletions.
2 changes: 1 addition & 1 deletion script/campaign/cam2-a.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ function eventStartLevel()
startedFromMenu = false;

//Only if starting Beta directly rather than going through Alpha
if (enumDroid(CAM_HUMAN_PLAYER, DROID_TRANSPORTER).length === 0)
if (enumDroid(CAM_HUMAN_PLAYER, DROID_SUPERTRANSPORTER).length === 0)
{
startedFromMenu = true;
sendPlayerTransporter();
Expand Down
2 changes: 1 addition & 1 deletion script/campaign/cam3-a.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ function eventStartLevel()
startedFromMenu = false;

//Only if starting Gamma directly rather than going through Beta
if (enumDroid(CAM_HUMAN_PLAYER, DROID_TRANSPORTER).length === 0)
if (enumDroid(CAM_HUMAN_PLAYER, DROID_SUPERTRANSPORTER).length === 0)
{
startedFromMenu = true;
setReinforcementTime(LZ_COMPROMISED_TIME);
Expand Down
138 changes: 60 additions & 78 deletions script/campaign/libcampaign_includes/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
// Debugging helpers.
////////////////////////////////////////////////////////////////////////////////

//;; ## camMarkTiles(label | array of labels)
//;; ## camMarkTiles(label|labels)
//;;
//;; Mark area on the map by label(s), but only if debug mode is enabled.
//;; Otherwise, remember what to mark in case it is going to be.
//;;
//;; @param {string|string[]} label
//;; @returns {void}
//;;
function camMarkTiles(label)
{
if (camIsString(label))
Expand All @@ -16,7 +19,7 @@ function camMarkTiles(label)
}
else
{
for (var i = 0, l = label.length; i < l; ++i)
for (let i = 0, l = label.length; i < l; ++i)
{
__camMarkedTiles[label[i]] = true;
}
Expand All @@ -25,10 +28,13 @@ function camMarkTiles(label)
__camUpdateMarkedTiles();
}

//;; ## camUnmarkTiles(label | array of labels)
//;; ## camUnmarkTiles(label|labels)
//;;
//;; No longer mark area(s) with given label(s) in debug mode.
//;;
//;; @param {string|string[]} label
//;; @returns {void}
//;;
function camUnmarkTiles(label)
{
if (camIsString(label))
Expand All @@ -37,7 +43,7 @@ function camUnmarkTiles(label)
}
else
{
for (var i = 0, l = label.length; i < l; ++i)
for (let i = 0, l = label.length; i < l; ++i)
{
delete __camMarkedTiles[label[i]];
}
Expand All @@ -46,88 +52,86 @@ function camUnmarkTiles(label)
__camUpdateMarkedTiles();
}

//;; ## camDebug(string...)
//;; ## camDebug(...args)
//;;
//;; Pretty debug prints - a wrapper around ```debug()```.
//;; Prints a function call stack and the argument message,
//;; prefixed with "DEBUG". Only use this function to indicate
//;; actual bugs in the scenario script, because game shouldn't
//;; print things when nothing is broken. If you want to keep
//;; some prints around to make debugging easier without distracting
//;; the user, use ```camTrace()```.
//;; Pretty debug prints - a wrapper around `debug()`.
//;; Prints a function call stack and the argument message, prefixed with `DEBUG`.
//;; Only use this function to indicate actual bugs in the scenario script,
//;; because game shouldn't print things when nothing is broken.
//;; If you want to keep some prints around to make debugging easier
//;; without distracting the user, use `camTrace()`.
//;;
function camDebug()
//;; @param {...string} args
//;; @returns {void}
//;;
function camDebug(...args)
{
__camGenericDebug("DEBUG",
arguments.callee.caller.name,
arguments,
true,
__camBacktrace());
__camGenericDebug("DEBUG", debugGetCallerFuncName(), args, true, __camBacktrace());
}

//;; ## camDebugOnce(string...)
//;; ## camDebugOnce(...args)
//;;
//;; Same as `camDebug()`, but prints each message only once during script lifetime.
//;;
//;; Same as ```camDebug()```, but prints each message only once
//;; during script lifetime.
//;; @param {...string} args
//;; @returns {void}
//;;
function camDebugOnce()
function camDebugOnce(...args)
{
var str = arguments.callee.caller.name + ": " + Array.prototype.join.call(arguments, " ");
var str = debugGetCallerFuncName() + ": " + args.join(" ");
if (camDef(__camDebuggedOnce[str]))
{
return;
}
__camDebuggedOnce[str] = true;
__camGenericDebug("DEBUG",
arguments.callee.caller.name,
arguments,
true,
__camBacktrace());
__camGenericDebug("DEBUG", debugGetCallerFuncName(), args, true, __camBacktrace());
}

//;; ## camTrace(string...)
//;; ## camTrace(...args)
//;;
//;; Same as ```camDebug()```, but only warns in cheat mode.
//;; Prefixed with "TRACE". It's safe and natural to keep ```camTrace()```
//;; calls in your code for easier debugging.
//;; Same as `camDebug()`, but only warns in cheat mode.
//;; Prefixed with `TRACE`. It's safe and natural to keep `camTrace()` calls in your code for easier debugging.
//;;
function camTrace()
//;; @param {...string} args
//;; @returns {void}
//;;
function camTrace(...args)
{
if (!__camCheatMode)
if (!camIsCheating())
{
return;
}
__camGenericDebug("TRACE",
arguments.callee.caller.name,
arguments);
__camGenericDebug("TRACE", debugGetCallerFuncName(), args);
}

//;; ## camTraceOnce(string...)
//;; ## camTraceOnce(...args)
//;;
//;; Same as `camTrace()`, but prints each message only once during script lifetime.
//;;
//;; Same as ```camTrace()```, but prints each message only once
//;; during script lifetime.
//;; @param {...string} args
//;; @returns {void}
//;;
function camTraceOnce()
function camTraceOnce(...args)
{
if (!__camCheatMode)
if (!camIsCheating())
{
return;
}
var str = arguments.callee.caller.name + ": " + Array.prototype.join.call(arguments, " ");
var str = debugGetCallerFuncName() + ": " + args.join(" ");
if (camDef(__camTracedOnce[str]))
{
return;
}
__camTracedOnce[str] = true;
__camGenericDebug("TRACE",
arguments.callee.caller.name,
arguments);
__camGenericDebug("TRACE", debugGetCallerFuncName(), args);
}

//;; ## camIsCheating()
//;;
//;; Check if the player is in cheat mode.
//;;
//;; @returns {boolean}
//;;
function camIsCheating()
{
return __camCheatMode;
Expand All @@ -138,9 +142,9 @@ function camIsCheating()
function __camUpdateMarkedTiles()
{
hackMarkTiles();
if (__camCheatMode && camDef(__camMarkedTiles))
if (camIsCheating() && camDef(__camMarkedTiles))
{
for (var label in __camMarkedTiles)
for (const label in __camMarkedTiles)
{
hackMarkTiles(label);
}
Expand All @@ -154,28 +158,20 @@ function __camLetMeWin()
__camGameWon();
}

function __camWinInfo()
{
console("Picked up", __camNumArtifacts,
"artifacts out of", Object.keys(__camArtifacts).length);
console("Eliminated", __camNumEnemyBases,
"enemy bases out of", Object.keys(__camEnemyBases).length);
}

function __camGenericDebug(flag, func, args, err, bt)
function __camGenericDebug(flag, functionName, args, err, backtrace)
{
if (camDef(bt) && bt)
if (camDef(backtrace) && backtrace)
{
for (var i = bt.length - 1; i >= 0; --i)
for (let i = backtrace.length - 1; i >= 0; --i)
{
debug("STACK: from", [bt[i]]);
debug("STACK: from", [backtrace[i]]);
}
}
if (!func)
if (!functionName)
{
func = "<anonymous>";
functionName = "<anonymous>";
}
var str = flag + ": " + func + ": " + Array.prototype.join.call(args, " ");
var str = flag + ": " + functionName + ": " + Array.prototype.join.call(args, " ");
debug(str);
if (camDef(err) && err)
{
Expand All @@ -185,19 +181,5 @@ function __camGenericDebug(flag, func, args, err, bt)

function __camBacktrace()
{
var func = arguments.callee.caller;
var list = [];
while (camDef(func) && func)
{
if (func.name)
{
list.push(func.name);
}
else
{
list.push("<anonymous>");
}
func = func.caller;
}
return list;
return debugGetBacktrace();
}
2 changes: 1 addition & 1 deletion script/campaign/libcampaign_includes/victory.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ function __camPlayerDead()
var droidCount = 0;
enumDroid(CAM_HUMAN_PLAYER).forEach(function(obj) {
droidCount += 1;
if (obj.droidType === DROID_TRANSPORTER)
if (obj.droidType === DROID_SUPERTRANSPORTER)
{
droidCount += enumCargo(obj).length;
}
Expand Down
2 changes: 1 addition & 1 deletion stats/body.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@
"armourKinetic": 100,
"buildPoints": 5000,
"class": "Transports",
"droidType": "TRANSPORTER",
"droidType": "SUPERTRANSPORTER",
"hitpoints": 5000,
"id": "TransporterBody",
"model": "drtrans.pie",
Expand Down
6 changes: 3 additions & 3 deletions stats/research.json
Original file line number Diff line number Diff line change
Expand Up @@ -4709,7 +4709,7 @@
"iconID": "IMAGE_RES_WEAPONTECH",
"id": "R-Wpn-Bomb-Accuracy01",
"imdName": "trlvtlhe.PIE",
"msgName": "RES_W_BAC1",
"msgName": "RES_W_BDMG1",
"name": "Thermal Imaging Bombsight",
"requiredResearch": [
"R-Wpn-Bomb01",
Expand Down Expand Up @@ -4747,7 +4747,7 @@
"id": "R-Wpn-Bomb-Accuracy02",
"keyTopic": 1,
"imdName": "trlvtlhe.PIE",
"msgName": "RES_W_BAC2",
"msgName": "RES_W_BDMG2",
"name": "Laser Guided Bombsight",
"requiredResearch": [
"R-Wpn-Bomb-Accuracy01"
Expand Down Expand Up @@ -7364,7 +7364,7 @@
"iconID": "IMAGE_RES_WEAPONTECH",
"id": "R-Wpn-Bomb-Accuracy03",
"imdName": "trlvtlhe.PIE",
"msgName": "RES_W_BAC3",
"msgName": "RES_W_BDMG3",
"name": "Target Acquisition Bombsight",
"requiredResearch": [
"R-Wpn-Mortar-Acc03",
Expand Down

0 comments on commit 677a7f5

Please sign in to comment.