Skip to content

Commit

Permalink
Even more campaign updates.
Browse files Browse the repository at this point in the history
-cam1-d: Use the original coordinates for the NW base as otherwise it was way too big.
-Remove useless message and proximity files that are not used.
-Move cam2-2 commander escape to south road.
-cam1-b: Move enemyBase3 cleanup farther north.
-cam1-4a: Remove blip after reaching LZ 2.
-QtScript: fireWeaponAtLoc(x, y, weapon). Fire a weapon projectile at a given location.
-Fix mixed base detection/elimination.
  • Loading branch information
KJeff01 committed Sep 21, 2017
1 parent a74041b commit 3c907bd
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 47 deletions.
1 change: 0 additions & 1 deletion data/base/messages/brief1-8.txt

This file was deleted.

2 changes: 0 additions & 2 deletions data/base/messages/brief2-3.txt

This file was deleted.

2 changes: 0 additions & 2 deletions data/base/messages/brief2-4.txt

This file was deleted.

2 changes: 0 additions & 2 deletions data/base/messages/brief3-3.txt

This file was deleted.

6 changes: 0 additions & 6 deletions data/base/messages/prox1-8.txt

This file was deleted.

1 change: 0 additions & 1 deletion data/base/messages/prox2-3.txt

This file was deleted.

1 change: 0 additions & 1 deletion data/base/messages/prox2-4.txt

This file was deleted.

1 change: 0 additions & 1 deletion data/base/messages/prox2c2.txt

This file was deleted.

1 change: 0 additions & 1 deletion data/base/messages/prox2d2.txt

This file was deleted.

1 change: 0 additions & 1 deletion data/base/messages/prox3ab.txt

This file was deleted.

8 changes: 8 additions & 0 deletions data/base/script/campaign/cam1-1.js
Expand Up @@ -31,6 +31,14 @@ camAreaEvent("ambush2Trigger", function()
);
});

function eventPickup(feature, droid)
{
if (droid.player === CAM_HUMAN_PLAYER && feature.stattype === ARTIFACT)
{
hackRemoveMessage("C1-1_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER);
}
}

//Mission setup stuff
function eventStartLevel()
{
Expand Down
1 change: 1 addition & 0 deletions data/base/script/campaign/cam1-4a.js
Expand Up @@ -68,6 +68,7 @@ camAreaEvent("LandingZoneTrigger", function()
{
var lz = getObject("LandingZone2"); // will override later
setNoGoArea(lz.x, lz.y, lz.x2, lz.y2, CAM_HUMAN_PLAYER);
hackRemoveMessage("C1-4_OBJ1", PROX_MSG, CAM_HUMAN_PLAYER); //Remove mission objective.
playSound("pcv456.ogg");
// continue after 4 seconds
queue("moreLandingZoneTrigger", 4000);
Expand Down
39 changes: 16 additions & 23 deletions data/base/script/campaign/libcampaign.js
Expand Up @@ -1147,44 +1147,42 @@ function __camIsValidLeftover(obj)
return false;
}

// Calling this without a defined group will check non-eliminated bases for
// having the conditions to be destroyed. Helps fix earlier save files that
// had problems with bases not being eliminated properly.
function __camCheckBaseEliminated(group)
{
// FIXME: O(n) lookup here
for (var blabel in __camEnemyBases)
{
var bi = __camEnemyBases[blabel];
var foundLeftover = false;
if (bi.eliminated || (camDef(group) && (bi.group !== group)))
if (bi.eliminated || (bi.group !== group))
continue;
if (camDef(bi.cleanup))
{
var leftovers = enumArea(bi.cleanup);
var nonValidLeftovers = leftovers.filter(function(obj) {
var nonLeftovers = enumArea(bi.cleanup).filter(function(obj) {
return (obj.player !== CAM_HUMAN_PLAYER
&& obj.type === STRUCTURE
&& !__camIsValidLeftover(obj)
&& (!camDef(bi.player) ||
camPlayerMatchesFilter(obj.player, bi.player))
&& (!camDef(bi.player)
|| (camDef(bi.player) && camPlayerMatchesFilter(obj.player, bi.player)))
);
});
if (nonValidLeftovers.length)
var leftovers = enumArea(bi.cleanup).filter(function(obj) {
return (obj.player !== CAM_HUMAN_PLAYER
&& obj.type === STRUCTURE
&& __camIsValidLeftover(obj)
&& (!camDef(bi.player)
|| (camDef(bi.player) && camPlayerMatchesFilter(obj.player, bi.player)))
);
});
if (nonLeftovers.length > 0)
{
continue;
}
for (var i = 0, l = leftovers.length; i < l; i++)
{
var obj = leftovers[i];
foundLeftover = true;
if (__camIsValidLeftover(obj))
{
// remove with special effect
camSafeRemoveObject(obj, camDef(group));
}
// remove with special effect
camSafeRemoveObject(leftovers[i], true);
}
if (camDef(group) && !bi.eliminated && camDef(bi.eliminateSnd))
if (camDef(bi.eliminateSnd))
{
// play sound
var pos = camMakePos(bi.cleanup);
Expand All @@ -1196,8 +1194,6 @@ function __camCheckBaseEliminated(group)
camDebug("All bases must have a cleanup area : " + blabel);
continue;
}
if (!camDef(group) && !foundLeftover)
continue;
if (camDef(bi.detectMsg) && bi.detected) // remove the beacon
hackRemoveMessage(bi.detectMsg, PROX_MSG, 0);
camTrace("Enemy base", blabel, "eliminated");
Expand Down Expand Up @@ -3170,9 +3166,6 @@ function cam_eventGameLoaded()

//Subscribe to eventGroupSeen again.
camSetEnemyBases();

//Mark any dead bases if for some reason some did not eliminate properly.
__camCheckBaseEliminated();
}

//Plays Nexus sounds if nexusActivated is true.
Expand Down
2 changes: 1 addition & 1 deletion data/base/wrf/cam1/cam1b/labels.json
Expand Up @@ -2,7 +2,7 @@
"area_0": { "label": "landingZone", "pos1": [ 1280, 6528 ], "pos2": [ 1536, 6784 ]},
"area_1": { "label": "enemybase1", "pos1": [ 3840, 8960 ], "pos2": [ 5504, 10112 ]},
"area_2": { "label": "enemybase2", "pos1": [ 704, 8896 ], "pos2": [ 2496, 9728 ]},
"area_3": { "label": "enemybase3", "pos1": [ 2432, 10496 ], "pos2": [ 4352, 12672 ]},
"area_3": { "label": "enemybase3", "pos1": [ 2432, 10496 ], "pos2": [ 4224, 12288 ]},
"area_4": { "label": "enemybase4", "pos1": [ 2240, 12864 ], "pos2": [ 5312, 14400 ]},
"area_5": { "label": "AttackArea1", "subscriber": 0, "pos1": [ 4032, 8000 ], "pos2": [ 5440, 9024 ]},
"area_6": { "label": "AttackArea2", "subscriber": 0, "pos1": [ 320, 9792 ], "pos2": [ 6720, 13120 ]},
Expand Down
2 changes: 1 addition & 1 deletion data/base/wrf/cam1/sub1-d/labels.json
Expand Up @@ -27,7 +27,7 @@
"area_9": { "label": "hoversAttack", "pos1": [ 832, 1216 ], "pos2": [ 1344, 1728 ] },
"area_10": { "label": "hoversDefense", "pos1": [ 3776, 2112 ], "pos2": [ 4160, 2624 ] },
"area_11": { "label": "NPSouthEast", "pos1": [ 3072, 12800 ], "pos2": [ 6272, 16000 ] },
"area_12": { "label": "NPMiddle", "pos1": [ 1408, 256 ], "pos2": [ 6016, 6144 ] },
"area_12": { "label": "NPMiddle", "pos1": [ 3392, 1984 ], "pos2": [ 6080, 5184 ] },
"area_13": { "label": "NPNorthEast", "pos1": [ 6016, 128 ], "pos2": [ 9984, 3968 ] },

"object_0": { "label": "artifact1", "id": 555, "player": 0, "type": 2 },
Expand Down
6 changes: 3 additions & 3 deletions data/base/wrf/cam2/sub2-2/labels.json
Expand Up @@ -9,13 +9,13 @@
"position_7": { "label": "wayPoint1", "pos": [ 4672, 1984 ] },
"position_8": { "label": "wayPoint2", "pos": [ 1856, 1600 ] },
"position_9": { "label": "wayPoint3", "pos": [ 960, 1472 ] },
"position_10": { "label": "wayPoint4", "pos": [ 50, 7900 ] },
"position_10": { "label": "wayPoint4", "pos": [ 896, 8064 ] },
"position_11": { "label": "fac2WayPoint1", "pos": [ 1472, 4800 ] },
"position_12": { "label": "fac2WayPoint2", "pos": [ 5696, 7232 ] },
"position_13": { "label": "eastAssembly2", "pos": [ 4160, 4544 ] },
"position_14": { "label": "westAssembly2", "pos": [ 5696, 6976 ] },
"position_15": { "label": "vtolRemovePoint", "pos": [ 3604, 320 ] },
"position_16": { "label": "defensePos", "pos": [ 1536, 6784 ] },
"position_16": { "label": "defensePos", "pos": [ 1664, 7040 ] },

"area_0": { "label": "landingZone", "pos1": [ 5504, 7168 ], "pos2": [ 5760, 7424 ] },
"area_1": { "label": "RTLZ", "pos1": [ 5184, 6592 ], "pos2": [ 7104, 8128 ] },
Expand All @@ -28,7 +28,7 @@
"object_1": { "label": "COFactoryEast", "id": 518, "player": 2, "type": 1 },
"object_2": { "label": "COFactoryWest", "id": 517, "player": 2, "type": 1 },

"radius_0": { "label": "failZone", "subscriber": 2, "pos" : [ 600, 7800 ], "radius": 700 },
"radius_0": { "label": "failZone", "subscriber": 2, "pos" : [ 896, 8064 ], "radius": 400 },
"radius_1": { "label": "wayPoint1Rad", "subscriber": 2, "pos" : [ 4672, 1984 ], "radius": 300 },
"radius_2": { "label": "wayPoint2Rad", "subscriber": 2, "pos" : [ 1856, 1400 ], "radius": 300 },
"radius_3": { "label": "vtolRemoveZone", "subscriber": 2, "pos" : [ 3604, 320 ], "radius": 200 }
Expand Down
1 change: 0 additions & 1 deletion data/base/wrf/cam3/cam3ab.wrf
Expand Up @@ -6,7 +6,6 @@
/* Directory for Proximity messages and mission briefs */
directory "messages"
file SMSG "brief3a-b.txt"
file SMSG "prox3ab.txt"

/* Directory for uncompiled script files */
directory "script/text"
Expand Down
24 changes: 24 additions & 0 deletions src/qtscriptfuncs.cpp
Expand Up @@ -4356,6 +4356,29 @@ static QScriptValue js_replaceTexture(QScriptContext *context, QScriptEngine *)
return QScriptValue();
}

//-- \subsection{fireWeaponAtLoc(x, y, weapon_name)}
//-- Fires a weapon at the given coordinates (3.2.4+ only).
static QScriptValue js_fireWeaponAtLoc(QScriptContext *context, QScriptEngine *)
{
int xLocation = context->argument(0).toInt32();
int yLocation = context->argument(1).toInt32();

QScriptValue weaponValue = context->argument(2);
int weapon = getCompFromName(COMP_WEAPON, weaponValue.toString());
SCRIPT_ASSERT(context, weapon > 0, "No such weapon: %s", weaponValue.toString().toUtf8().constData());

Vector3i target;
target.x = xLocation;
target.y = yLocation;
target.z = map_Height(xLocation, yLocation);

WEAPON sWeapon;
sWeapon.nStat = weapon;
// send the projectile using the selectedPlayer so that it can always be seen
proj_SendProjectile(&sWeapon, nullptr, selectedPlayer, target, nullptr, true, 0);
return QScriptValue();
}

//-- \subsection{changePlayerColour(player, colour)}
//-- Change a player's colour slot. The current player colour can be read from the playerData array. There are as many
//-- colour slots as the maximum number of players. (3.2.3+ only)
Expand Down Expand Up @@ -5529,6 +5552,7 @@ bool registerFunctions(QScriptEngine *engine, const QString& scriptName)
engine->globalObject().setProperty("startTransporterEntry", engine->newFunction(js_startTransporterEntry));
engine->globalObject().setProperty("setTransporterExit", engine->newFunction(js_setTransporterExit));
engine->globalObject().setProperty("setObjectFlag", engine->newFunction(js_setObjectFlag));
engine->globalObject().setProperty("fireWeaponAtLoc", engine->newFunction(js_fireWeaponAtLoc));

// Set some useful constants
engine->globalObject().setProperty("TER_WATER", TER_WATER, QScriptValue::ReadOnly | QScriptValue::Undeletable);
Expand Down

0 comments on commit 3c907bd

Please sign in to comment.