Skip to content

Commit

Permalink
Basic Campaign Selector Support
Browse files Browse the repository at this point in the history
- Added cursed-audio-overrides.json
- Added files for Campaign Selector integration.
- Fixed errors when enabling components for enemy multi-turret units.
- Prevented artifacts from being picked up twice.
- Changed camUpgradeOnMapStructures and camUpgradeOnMapFeatures to add a delay between removing and replacing an object.
  • Loading branch information
DARwins1 committed Jun 23, 2024
1 parent 7504ba5 commit 7c3690b
Show file tree
Hide file tree
Showing 7 changed files with 672 additions and 29 deletions.
340 changes: 340 additions & 0 deletions COPYING

Large diffs are not rendered by default.

181 changes: 181 additions & 0 deletions audio/cursed-audio-overrides.json

Large diffs are not rendered by default.

Binary file added mod-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions mod-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "Cursed Warzone",
"version": "1.1.0",
"author": "DARwins",
"type": "alternateCampaign",
"license": "GPL-2.0-or-later",
"minVersionSupported": "4.5.0",
"maxVersionTested": "4.5.0",
"description": {
"en": "A campaign mod for Warzone 2100 that completely ruins the story and adds a whole bunch of stupid funny stuff."
},
"updatesUrl": "https://github.com/DARwins1/cursed-warzone/releases/latest",
"campaigns": [
"alpha.json",
"beta.json",
"gamma.json"
],
"universe": "unique",
"difficultyLevels": "default",
"camTweakOptions": [
{
"id": "timerPowerBonus",
"default": true,
"userEditable": false
},
{
"id": "classicTimers",
"default": false,
"userEditable": false
},
{
"id": "playerUnitCap40",
"default": false,
"userEditable": false
},
{
"id": "autosavesOnly",
"default": false,
"userEditable": false
}
]
}
6 changes: 6 additions & 0 deletions script/campaign/libcampaign_includes/artifact.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ function __camPickupArtifact(artifact)
camTrace("Artifact", artifact.id, "is not managed");
return;
}
if (Object.hasOwn(ai, "pickedUp") && ai.pickedUp === true)
{
camTrace("Already picked up the artifact", __ALABEL);
return;
}
ai.pickedUp = true;

camTrace("Picked up", ai.tech);
playSound(camSounds.project.artiRecovered, artifact.x, artifact.y, artifact.z);
Expand Down
129 changes: 101 additions & 28 deletions script/campaign/libcampaign_includes/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,22 +321,21 @@ function camUpgradeOnMapStructures(struct1, struct2, playerId, excluded)

//Check if this object has a label and/or group assigned to it
// FIXME: O(n) lookup here
const __STRUCT_LABEL = getLabel(structure);
const __STRUCT_GROUP = structure.group;

//Replace it
const structInfo = {x: structure.x * 128, y: structure.y * 128};
let label = (getLabel(structure));
let group = (structure.group);
let structInfo = {x: structure.x * 128, y: structure.y * 128};
camSafeRemoveObject(structure, false);
const newStruct = addStructure(struct2, playerId, structInfo.x, structInfo.y);

if (camDef(__STRUCT_LABEL))
{
addLabel(newStruct, __STRUCT_LABEL);
}
if (__STRUCT_GROUP !== null)
{
groupAdd(__STRUCT_GROUP, newStruct);
}

// Compile all the needed information into a string
let infoString =
"__STRUCTNAME" + struct2
+ "__PLAYER" + playerId
+ "__XPOS" + structInfo.x
+ "__YPOS" + structInfo.y;
if (camDef(label)) infoString += "__LABEL" + label;
if (group !== null) infoString += "__GROUP" + group;
// Queue up a replacement
queue("__camQueueReplacementStruct", __CAM_TICKS_PER_FRAME, infoString);
}
}

Expand Down Expand Up @@ -395,36 +394,39 @@ function camUpgradeOnMapFeatures(feat1, feat2, excluded)

//Check if this object has a label assigned to it
// FIXME: O(n) lookup here
const __FEATURE_LABEL = getLabel(feature);
const label = getLabel(feature);

//Replace it
const featInfo = {x: feature.x, y: feature.y};
camSafeRemoveObject(feature, false);
let newFeat;
let featName;
if (feat2 === "Pipis" && camRand(100) < 1)
{
// 1/100 chance to place a Ms. Pipis instead of a normal Pipis
newFeat = addFeature("PipisM", featInfo.x, featInfo.y);
featName = "PipisM";
}
else if (feat2 === "PipisDummy" && camRand(100) < 1)
{
// 1/100 chance to place a Ms. Pipis Dummy instead of a normal Pipis Dummy
newFeat = addFeature("PipisMDummy", featInfo.x, featInfo.y);
featName = "PipisMDummy";
}
else if (feat2 === "SpamSign")
{
// Choose a random Spamton Sign from the list
newFeat = addFeature(__camSpamtonSigns[camRand(__camSpamtonSigns.length)], featInfo.x, featInfo.y);
featName = __camSpamtonSigns[camRand(__camSpamtonSigns.length)];
}
else
{
newFeat = addFeature(feat2, featInfo.x, featInfo.y);
}

if (camDef(__FEATURE_LABEL))
{
addLabel(newFeat, __FEATURE_LABEL);
featName = feat2;
}

// Compile all the needed information into a string
let infoString =
"__FEATNAME" + featName
+ "__XPOS" + feature.x
+ "__YPOS" + feature.y;
if (camDef(label)) infoString += "__LABEL" + label;
// Queue up a replacement
queue("__camQueueReplacementFeat", __CAM_TICKS_PER_FRAME, infoString);
}
}

Expand Down Expand Up @@ -530,19 +532,24 @@ function __camBuildDroid(template, structure)
const __PROP = __camChangePropulsion(template.prop, structure.player);
makeComponentAvailable(template.body, structure.player);
makeComponentAvailable(__PROP, structure.player);
makeComponentAvailable(template.weap, structure.player);
const __NAME = camNameTemplate(template.weap, template.body, __PROP);
// multi-turret templates are NOW supported :)
if (typeof template.weap === "object" && camDef(template.weap[2]))
{
makeComponentAvailable(template.weap[0], structure.player);
makeComponentAvailable(template.weap[1], structure.player);
makeComponentAvailable(template.weap[2], structure.player);
return buildDroid(structure, __NAME, template.body, __PROP, "", "", template.weap[0], template.weap[1], template.weap[2]);
}
else if (typeof template.weap === "object" && camDef(template.weap[1]))
{
makeComponentAvailable(template.weap[0], structure.player);
makeComponentAvailable(template.weap[1], structure.player);
return buildDroid(structure, __NAME, template.body, __PROP, "", "", template.weap[0], template.weap[1]);
}
else
{
makeComponentAvailable(template.weap, structure.player);
return buildDroid(structure, __NAME, template.body, __PROP, "", "", template.weap);
}
}
Expand Down Expand Up @@ -627,3 +634,69 @@ function __camContinueProduction(structure)
}
fi.lastprod = gameTime;
}

// Add a structure with the information given in the string
function __camQueueReplacementStruct(infoString)
{
// console("parsing \"" + infoString + "\"!")
// Parse the info string
const nameMarker = "__STRUCTNAME";
const playerMarker = "__PLAYER";
const xMarker = "__XPOS";
const yMarker = "__YPOS";
const labelMarker = "__LABEL";
const groupMarker = "__GROUP";
const __NAMEINDEX = infoString.indexOf(nameMarker);
const __PLAYERINDEX = infoString.indexOf(playerMarker);
const __XINDEX = infoString.indexOf(xMarker);
const __YINDEX = infoString.indexOf(yMarker);
const __LABELINDEX = infoString.indexOf(labelMarker);
const __GROUPINDEX = infoString.indexOf(groupMarker);

const structName = infoString.substring(__NAMEINDEX + nameMarker.length, __PLAYERINDEX);
const __PLAYER = parseInt(infoString.substring(__PLAYERINDEX + playerMarker.length, __XINDEX));
const __XPOS = parseInt(infoString.substring(__XINDEX + xMarker.length, __YINDEX));
const __YPOS = parseInt(infoString.substring(__YINDEX + yMarker.length, ((__LABELINDEX > 0) ? __LABELINDEX : ((__GROUPINDEX > 0) ? __GROUPINDEX : undefined))));
const label = (__LABELINDEX > 0) ? infoString.substring(__LABELINDEX + labelMarker.length, ((__GROUPINDEX > 0) ? __GROUPINDEX : undefined)) : undefined;
const group = (__GROUPINDEX > 0) ? infoString.substring(__GROUPINDEX + groupMarker.length) : undefined;

// Add the structure
const newStruct = addStructure(structName, __PLAYER, __XPOS, __YPOS);
// Apply label/group
if (camDef(label))
{
addLabel(newStruct, label);
}
if (camDef(group))
{
groupAdd(group, newStruct);
}
}

// Add a feature with the information given in the string
function __camQueueReplacementFeat(infoString)
{
// console("parsing \"" + infoString + "\"!")
// Parse the info string
const nameMarker = "__FEATNAME";
const xMarker = "__XPOS";
const yMarker = "__YPOS";
const labelMarker = "__LABEL";
const __NAMEINDEX = infoString.indexOf(nameMarker);
const __XINDEX = infoString.indexOf(xMarker);
const __YINDEX = infoString.indexOf(yMarker);
const __LABELINDEX = infoString.indexOf(labelMarker);

const featName = infoString.substring(__NAMEINDEX + nameMarker.length, __XINDEX);
const __XPOS = parseInt(infoString.substring(__XINDEX + xMarker.length, __YINDEX));
const __YPOS = parseInt(infoString.substring(__YINDEX + yMarker.length, ((__LABELINDEX > 0) ? __LABELINDEX : undefined)));
const label = (__LABELINDEX > 0) ? infoString.substring(__LABELINDEX + labelMarker.length) : undefined;

// Add the feature
const newFeat = addFeature(featName, __XPOS, __YPOS);
// Apply label/group
if (camDef(label))
{
addLabel(newFeat, label);
}
}
3 changes: 2 additions & 1 deletion wrf/audio.wrf
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,5 @@ file WAV "uplink.ogg"
file WAV "lasstrk.ogg"
file WAV "beacon.ogg"
directory "audio"
file AUDIOCFG "audio.cfg"
file AUDIOCFG "audio.json"
file AUDIOCFG "cursed-audio-overrides.json"

0 comments on commit 7c3690b

Please sign in to comment.