Skip to content
Permalink
Browse files

qtscript: Fix bugs giving cyborg engineers only legs, no body.

The problem lies with the hardcoded 'droid type', which needs
to be set somehow. It used to be hardcoded in the body component,
but once those were merged, the type information was lost. Now
with this patch they are supplied by turret components instead.
In the longer run, we should just remove reliance upon 'droid type'
altogether.
  • Loading branch information...
perim committed Jul 16, 2017
1 parent 80d2fce commit 5aab20b02d3631d9894498fa8a8ab201675a7694
Showing with 66 additions and 29 deletions.
  1. +2 −0 data/mp/stats/construction.json
  2. +1 −0 data/mp/stats/ecm.json
  3. +3 −0 data/mp/stats/repair.json
  4. +6 −0 data/mp/stats/sensor.json
  5. +51 −26 src/stats.cpp
  6. +3 −3 src/statsdef.h
@@ -3,6 +3,7 @@
"buildPoints": 65,
"buildPower": 10,
"constructPoints": 5,
"droidType": "CYBORG_CONSTRUCT",
"hitpoints": 35,
"id": "CyborgSpade",
"mountModel": "cybody.pie",
@@ -15,6 +16,7 @@
"buildPower": 17,
"constructPoints": 8,
"designable": 1,
"droidType": "DROID_CONSTRUCT",
"hitpoints": 25,
"id": "Spade1Mk1",
"name": "Truck",
@@ -3,6 +3,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_ECM",
"hitpoints": 200,
"id": "ECM1TurretMk1",
"location": "TURRET",
@@ -10,6 +10,7 @@
"buildPoints": 100,
"buildPower": 35,
"id": "CyborgRepair",
"droidType": "CYBORG_REPAIR",
"location": "TURRET",
"model": "cy_rep.pie",
"mountModel": "cybody.pie",
@@ -22,6 +23,7 @@
"buildPoints": 300,
"buildPower": 70,
"designable": 1,
"droidType": "DROID_REPAIR",
"id": "HeavyRepair",
"location": "TURRET",
"model": "GNMREPR2.PIE",
@@ -35,6 +37,7 @@
"buildPoints": 250,
"buildPower": 50,
"designable": 1,
"droidType": "DROID_REPAIR",
"id": "LightRepair1",
"location": "TURRET",
"model": "GNMREPAR.PIE",
@@ -27,6 +27,7 @@
},
"DefaultSensor1Mk1": {
"id": "DefaultSensor1Mk1",
"droidType": "DROID_SENSOR",
"location": "DEFAULT",
"name": "*Default Sensor*",
"power": 500,
@@ -68,6 +69,7 @@
"buildPoints": 25,
"buildPower": 5,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "Sensor-WideSpec",
"location": "TURRET",
@@ -97,6 +99,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "SensorTurret1Mk1",
"location": "TURRET",
@@ -126,6 +129,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "Sys-CBTurret01",
"location": "TURRET",
@@ -170,6 +174,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"hitpoints": 200,
"id": "Sys-VTOLCBTurret01",
"location": "TURRET",
@@ -199,6 +204,7 @@
"buildPoints": 100,
"buildPower": 20,
"designable": 1,
"droidType": "DROID_SENSOR",
"id": "Sys-VstrikeTurret01",
"location": "TURRET",
"mountModel": "TRLSNSR1.PIE",
@@ -297,6 +297,57 @@ static void loadCompStats(WzConfig &json, COMPONENT_STATS *psStats, int index)
psStats->weight = json.value("weight", 0).toUInt();
psStats->pBase->hitpoints = json.value("hitpoints", 0).toUInt();
psStats->pBase->hitpointPct = json.value("hitpointPct", 100).toUInt();

QString dtype = json.value("droidType", "DROID").toString();
psStats->droidTypeOverride = DROID_DEFAULT;
if (dtype.compare("PERSON") == 0)
{
psStats->droidTypeOverride = DROID_PERSON;
}
else if (dtype.compare("TRANSPORTER") == 0)
{
psStats->droidTypeOverride = DROID_TRANSPORTER;
}
else if (dtype.compare("CYBORG") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG;
}
else if (dtype.compare("CYBORG_SUPER") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_SUPER;
}
else if (dtype.compare("CYBORG_CONSTRUCT") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_CONSTRUCT;
}
else if (dtype.compare("CYBORG_REPAIR") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_REPAIR;
}
else if (dtype.compare("DROID_CONSTRUCT") == 0)
{
psStats->droidTypeOverride = DROID_CONSTRUCT;
}
else if (dtype.compare("DROID_ECM") == 0)
{
psStats->droidTypeOverride = DROID_ECM;
}
else if (dtype.compare("DROID_COMMAND") == 0)
{
psStats->droidTypeOverride = DROID_COMMAND;
}
else if (dtype.compare("DROID_SENSOR") == 0)
{
psStats->droidTypeOverride = DROID_SENSOR;
}
else if (dtype.compare("DROID_REPAIR") == 0)
{
psStats->droidTypeOverride = DROID_REPAIR;
}
else if (dtype.compare("DROID") != 0)
{
debug(LOG_ERROR, "Unrecognized droidType %s", dtype.toUtf8().constData());
}
}

/*Load the weapon stats from the file exported from Access*/
@@ -533,32 +584,6 @@ bool loadBodyStats(const char *pFileName)
{
psStats->upgrade[j] = psStats->base;
}
QString dtype = ini.value("droidType", "DROID").toString();
psStats->droidTypeOverride = DROID_DEFAULT;
if (dtype.compare("PERSON") == 0)
{
psStats->droidTypeOverride = DROID_PERSON;
}
else if (dtype.compare("TRANSPORTER") == 0)
{
psStats->droidTypeOverride = DROID_TRANSPORTER;
}
else if (dtype.compare("CYBORG") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG;
}
else if (dtype.compare("CYBORG_SUPER") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_SUPER;
}
else if (dtype.compare("CYBORG_CONSTRUCT") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_CONSTRUCT;
}
else if (dtype.compare("CYBORG_REPAIR") == 0)
{
psStats->droidTypeOverride = DROID_CYBORG_REPAIR;
}
psStats->ref = REF_BODY_START + i;
if (!getBodySize(ini.value("size").toString().toUtf8().constData(), &psStats->size))
{
@@ -260,14 +260,15 @@ struct BASE_STATS
struct COMPONENT_STATS : public BASE_STATS
{
COMPONENT_STATS() : buildPower(0), buildPoints(0), weight(0), designable(false), pIMD(nullptr),
compType(COMP_NUMCOMPONENTS) {}
compType(COMP_NUMCOMPONENTS), droidTypeOverride(DROID_ANY) {}

UDWORD buildPower; /**< Power required to build the component */
UDWORD buildPoints; /**< Time required to build the component */
UDWORD weight; /**< Component's weight */
bool designable; /**< flag to indicate whether this component can be used in the design screen */
iIMDShape *pIMD; /**< The IMD to draw for this component */
COMPONENT_TYPE compType;
DROID_TYPE droidTypeOverride; ///< If not DROID_ANY, sets droid type.

struct UPGRADE
{
@@ -471,15 +472,14 @@ struct BRAIN_STATS : public COMPONENT_STATS

struct BODY_STATS : public COMPONENT_STATS
{
BODY_STATS() : size(SIZE_NUM), weaponSlots(0), droidTypeOverride(DROID_ANY)
BODY_STATS() : size(SIZE_NUM), weaponSlots(0)
{
pBase = &base;
for (int i = 0; i < MAX_PLAYERS; i++) pUpgrade[i] = &upgrade[i];
}

BODY_SIZE size; ///< How big the body is - affects how hit
UDWORD weaponSlots; ///< The number of weapon slots on the body
DROID_TYPE droidTypeOverride; // if not DROID_ANY, sets droid type

std::vector<iIMDShape *> ppIMDList; ///< list of IMDs to use for propulsion unit - up to numPropulsionStats
std::vector<iIMDShape *> ppMoveIMDList; ///< list of IMDs to use when droid is moving - up to numPropulsionStats

0 comments on commit 5aab20b

Please sign in to comment.
You can’t perform that action at this time.