Skip to content

Update DROID_CONSTRUCT description to not include cyborgs #4239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aco4
Copy link
Contributor

@aco4 aco4 commented Mar 19, 2025

doc/js-objects.md incorrectly states that DROID_CONSTRUCT includes cyborg constructors. I fixed this, and was also planning on adding the updated droid types DROID_CYBORG_CONSTRUCT DROID_CYBORG_REPAIR and DROID_CYBORG_SUPER:

enum DROID_TYPE
{
DROID_WEAPON, ///< Weapon droid
DROID_SENSOR, ///< Sensor droid
DROID_ECM, ///< ECM droid
DROID_CONSTRUCT, ///< Constructor droid
DROID_PERSON, ///< person
DROID_CYBORG, ///< cyborg-type thang
DROID_TRANSPORTER, ///< guess what this is!
DROID_COMMAND, ///< Command droid
DROID_REPAIR, ///< Repair droid
DROID_DEFAULT, ///< Default droid
DROID_CYBORG_CONSTRUCT, ///< cyborg constructor droid - new for update 28/5/99
DROID_CYBORG_REPAIR, ///< cyborg repair droid - new for update 28/5/99
DROID_CYBORG_SUPER, ///< cyborg repair droid - new for update 7/6/99
DROID_SUPERTRANSPORTER, ///< SuperTransport (MP)
DROID_ANY, ///< Any droid. Used as a parameter for various stuff.
};

But I came across #614 which seems to suggest that these newer droid types are intentionally excluded? So I didn't add them.

Mod

The following mod fails to preserve Cyborg Constructor templates

multiplay/scripts/mods/init.js:

namespace("OnlyTrucks_");

function OnlyTrucks_eventStartLevel() {
    enforce();
}

function OnlyTrucks_eventMenuManufacture() {
    enforce();
}

function OnlyTrucks_eventDesignQuit() {
    enforce();
}

function enforce() {
    enumTemplates(selectedPlayer).forEach(t => {
        if (t.droidType != DROID_CONSTRUCT) {
            removeTemplate(t.name);
        }
    });
}

While the following mod DOES preserve them:

...

function enforce() {
    enumTemplates(selectedPlayer).forEach(t => {
        if (t.droidType != DROID_CONSTRUCT  && t.droidType != 10) {
            removeTemplate(t.name);
        }
    });
}

@KJeff01
Copy link
Member

KJeff01 commented Mar 21, 2025

It technically does. the wzapi combines them all into one shared type. If you enumDroid(x, DROID_CONSTRUCT) it will contain combat engineers and trucks. This goes for repairs and super cyborgs as well. Thus their droidType, as a droid object as far as the wzapi is concerned, will also show them as DROID_CONSTRUCT to scripts. Now, if someone wants to actually find the unique cyborg variants they will need to search for other methods like checking the droid components (which isn't super ideal).

What's probably really going on here, in your case, is that the function that looks at templates, enumTemplates(), is merely returning the type as defined in the template itself without considering this combined type behavior as used elsewhere in the wzapi. Unsurprisingly, this wasn't caught much earlier probably cause nobody tried using this particular function before (at least I haven't). I may be wrong on that as I didn't investigate this totally, but that would make the most sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants