123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- //***************************************************************************
- //
- // cmponent.h -- File contains the Component definition
- //
- // MechCommander 2
- //
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #ifndef CMPONENT_H
- #define CMPONENT_H
- //---------------------------------------------------------------------------
- #ifndef INIFILE_H
- #include "inifile.h"
- #endif
- #ifndef ERR_H
- #include "err.h"
- #endif
- #include <string.h>
- #ifndef _MBCS
- #include <gameos.hpp>
- #else
- #include <assert.h>
- #define gosASSERT assert
- #define gos_Malloc malloc
- #define gos_Free free
- #endif
- //***************************************************************************
- #define MAXLEN_COMPONENT_NAME 256
- #define MAXLEN_COMPONENT_ABBREV 256
- #define NUM_BODY_LOCATIONS 8
- #define TECH_BASE_CLAN 1
- #define TECH_BASE_INNERSPHERE 2
- #define COMPONENT_USE_MECH 1
- #define COMPONENT_USE_VEHICLE 2
- #define COMPONENT_USE_CLAN 16
- #define COMPONENT_USE_INNERSPHERE 32
- #define WEAPON_AMMO_OFFSET 65 // Master Component Index Offset from weapon
- typedef enum {
- COMPONENT_FORM_SIMPLE = 0,
- COMPONENT_FORM_COCKPIT,
- COMPONENT_FORM_SENSOR,
- COMPONENT_FORM_ACTUATOR,
- COMPONENT_FORM_ENGINE,
- COMPONENT_FORM_HEATSINK,
- COMPONENT_FORM_WEAPON,
- COMPONENT_FORM_WEAPON_ENERGY,
- COMPONENT_FORM_WEAPON_BALLISTIC,
- COMPONENT_FORM_WEAPON_MISSILE,
- COMPONENT_FORM_AMMO,
- COMPONENT_FORM_JUMPJET,
- COMPONENT_FORM_CASE,
- COMPONENT_FORM_LIFESUPPORT,
- COMPONENT_FORM_GYROSCOPE,
- COMPONENT_FORM_POWER_AMPLIFIER,
- COMPONENT_FORM_ECM,
- COMPONENT_FORM_PROBE,
- COMPONENT_FORM_JAMMER,
- COMPONENT_FORM_BULK,
- NUM_COMPONENT_FORMS
- } ComponentFormType;
- typedef enum {
- WEAPON_AMMO_NONE, // unlimited ammo (energy weapons)
- WEAPON_AMMO_SRM,
- WEAPON_AMMO_LRM,
- WEAPON_AMMO_ST,
- WEAPON_AMMO_LIMITED, // not SRM, LRM or ST, but still finite ammo amount
- NUM_WEAPON_AMMO_TYPES
- } WeaponAmmoType;
- typedef enum {
- WEAPON_STATE_READY,
- WEAPON_STATE_RECYCLING,
- WEAPON_STATE_DAMAGED,
- WEAPON_STATE_DESTROYED
- } WeaponStateType;
- typedef enum {
- WEAPON_RANGE_SHORT,
- WEAPON_RANGE_MEDIUM,
- WEAPON_RANGE_LONG,
- WEAPON_RANGE_SHORT_MEDIUM,
- WEAPON_RANGE_MEDIUM_LONG,
- NUM_WEAPON_RANGE_TYPES
- } WeaponRangeType;
- //******************************************************************************************
- #define WEAPON_FLAG_STREAK 1
- #define WEAPON_FLAG_INFERNO 2
- #define WEAPON_FLAG_LBX 4
- #define WEAPON_FLAG_ARTILLERY 8
- typedef union {
- struct {
- float range; // in meters
- } sensor;
- struct {
- float range;
- float effect;
- } ecm;
- struct {
- float effect;
- } jammer;
- struct {
- float effect;
- } probe;
- struct {
- short rating;
- } engine;
- struct {
- short dissipation;
- } heatsink;
- struct {
- float heat; // how much heat does it generate?
- float damage; // amount of damage
- float recycleTime; // in seconds
- long ammoAmount; // amount of ammo per shot
- unsigned char ammoType; // 0 = unlimited, 1 = finite amount (e.g. bullets)
- unsigned char ammoMasterId; // ammo used by this weapon
- unsigned char range; // short, med or long
- unsigned char flags;
- short type; // which weapon type is this
- char specialEffect; // used to cue whatever visual/sound effects this needs
- } weapon;
- struct {
- long ammoPerTon; // ammo per ton
- float explosiveDamage;// damage done (per missile) if it explodes
- } ammo;
- struct {
- long rangeMod; // range modifier
- } jumpjet;
- } ComponentStats;
- //******************************************************************************************
- class MasterComponent;
- typedef MasterComponent* MasterComponentPtr;
- class MasterComponent {
- private:
- long masterID; // unique ID for component
- long resourcePoints; // resource cost of object
- ComponentFormType form; // form of component
- char name[MAXLEN_COMPONENT_NAME]; // name string/description
- char abbreviation[MAXLEN_COMPONENT_ABBREV]; // abbreviated name
- float tonnage; // in tons
- char size; // # of total spaces used
- char health; // # of hits before destroyed
- char criticalSpacesReq[NUM_BODY_LOCATIONS]; // # of critical spaces required in specific location
- char disableLevel; // # of critical spaces to disable
- unsigned char uses;
- unsigned char techBase;
- float CV; // CV for this component
- ComponentStats stats;
- unsigned long art;
- public:
- static MasterComponentPtr masterList;
- static long numComponents;
- static long armActuatorID;
- static long legActuatorID;
- static long clanAntiMissileSystemID;
- static long innerSphereAntiMissileSystemID;
- public:
- void* operator new (size_t mySize);
- void operator delete (void* us);
- void destroy (void);
- ~MasterComponent (void) {
- destroy();
- }
-
- void init (void) {
- masterID = -1;
- name[0] = NULL;
- abbreviation[0] = NULL;
- }
- MasterComponent (void) {
- init();
- }
-
- long init (FitIniFile* componentFile);
- long initEXCEL (char* dataLine, float baseSensorRange);
- long saveEXCEL (FilePtr file, unsigned char masterId,float baseSensorRange);
- char* getName (void) {
- return(&name[0]);
- }
- long getMasterID (void) {
- return(masterID);
- }
- long getResourcePoints (void) {
- return(resourcePoints);
- }
-
- ComponentFormType getForm (void) {
- return(form);
- }
- long getSize (void) {
- return(size);
- }
- void setSize (long sz)
- {
- size = sz;
- }
-
- long getHealth (void) {
- return(health);
- }
- char getCriticalSpacesReq (long location)
- {
- if ((location < 0) && (location > NUM_BODY_LOCATIONS))
- return -1;
- return(criticalSpacesReq[location]);
- }
- void setCriticalSpacesReq (long location, char value)
- {
- if ((location < 0) && (location > NUM_BODY_LOCATIONS))
- return;
- criticalSpacesReq[location] = value;
- }
- char getDisableLevel (void) {
- return(disableLevel);
- }
- float getCV (void) {
- return(CV);
- }
- void setCV (float cv)
- {
- CV = cv;
- }
- float getTonnage (void) {
- return(tonnage);
- }
-
- void setTonnage (float tons)
- {
- tonnage = tons;
- }
- float getHeatDissipation (void)
- {
- return (stats.heatsink.dissipation);
- }
- void setHeatDissipation (float heatD)
- {
- stats.heatsink.dissipation = heatD;
- }
- float getWeaponHeat (void) {
- return(stats.weapon.heat);
- }
- void setWeaponHeat (float weaponHeat)
- {
- stats.weapon.heat = weaponHeat;
- }
- float getWeaponDamage (void) {
- return(stats.weapon.damage);
- }
- void setWeaponDamage (float weapDmg)
- {
- stats.weapon.damage = weapDmg;
- }
- float getWeaponRecycleTime (void) {
- return(stats.weapon.recycleTime);
- }
- void setWeaponRecycleTime (float recycleTime)
- {
- stats.weapon.recycleTime = recycleTime;
- }
- long getWeaponAmmoAmount (void) {
- return(stats.weapon.ammoAmount);
- }
- void setWeaponAmmoAmount (long weaponAmmo)
- {
- stats.weapon.ammoAmount = weaponAmmo;
- }
- unsigned long getWeaponAmmoType (void) {
- return(stats.weapon.ammoType);
- }
- void setWeaponAmmoType (long ammoType)
- {
- stats.weapon.ammoType = ammoType;
- }
- unsigned long getWeaponAmmoMasterId (void) {
- return(stats.weapon.ammoMasterId);
- }
- void setWeaponAmmoMasterId (long ammoId)
- {
- stats.weapon.ammoMasterId = ammoId;
- }
- long getWeaponRange (void) {
- return(stats.weapon.range);
- }
- void setWeaponRange (long weaponRange) {
- stats.weapon.range = weaponRange;
- }
- void clearWeaponFlags (void)
- {
- stats.weapon.flags = 0;
- }
- bool getWeaponInferno (void) {
- return((stats.weapon.flags & WEAPON_FLAG_INFERNO) != 0);
- }
- void setWeaponInferno (void)
- {
- stats.weapon.flags |= WEAPON_FLAG_INFERNO;
- }
- bool getWeaponStreak (void) {
- return((stats.weapon.flags & WEAPON_FLAG_STREAK) != 0);
- }
- void setWeaponStreak (void)
- {
- stats.weapon.flags |= WEAPON_FLAG_STREAK;
- }
- bool getWeaponLBX (void) {
- return((stats.weapon.flags & WEAPON_FLAG_LBX) != 0);
- }
- void setWeaponLBX (void)
- {
- stats.weapon.flags |= WEAPON_FLAG_LBX;
- }
- bool getWeaponArtillery (void) {
- return((stats.weapon.flags & WEAPON_FLAG_ARTILLERY) != 0);
- }
- void setWeaponArtillery (void)
- {
- stats.weapon.flags |= WEAPON_FLAG_ARTILLERY;
- }
- bool getCanClanUse (void)
- {
- return ((uses & COMPONENT_USE_CLAN) != 0);
- }
- bool getCanISUse (void)
- {
- return ((uses & COMPONENT_USE_INNERSPHERE) != 0);
- }
- bool getCanMechUse (void)
- {
- return ((uses & COMPONENT_USE_MECH) != 0);
- }
- bool getCanVehicleUse (void)
- {
- return ((uses & COMPONENT_USE_VEHICLE) != 0);
- }
- void clearUseFlags (void)
- {
- uses = 0;
- }
- void setCanClanUse (void)
- {
- uses |= COMPONENT_USE_CLAN;
- }
- void setCanISUse (void)
- {
- uses |= COMPONENT_USE_INNERSPHERE;
- }
- void setCanVehicleUse (void)
- {
- uses |= COMPONENT_USE_VEHICLE;
- }
- void setCanMechUse (void)
- {
- uses |= COMPONENT_USE_MECH;
- }
- bool getClanTechBase (void)
- {
- return ((techBase & TECH_BASE_CLAN) != 0);
- }
- bool getISTechBase (void)
- {
- return ((techBase & TECH_BASE_INNERSPHERE) != 0);
- }
- void setClanTechBase (void)
- {
- techBase = TECH_BASE_CLAN;
- }
- void setISTechBase (void)
- {
- techBase = TECH_BASE_INNERSPHERE;
- }
- void setBothTechBase (void)
- {
- techBase = TECH_BASE_INNERSPHERE + TECH_BASE_CLAN;
- }
- // long getWeaponType (void) {
- // return(stats.weapon.type);
- // }
- long getWeaponSpecialEffect (void) {
- return(stats.weapon.specialEffect);
- }
- long getAmmoPerTon (void) {
- return(stats.ammo.ammoPerTon);
- }
- void setAmmoPerTon (long ammoPerTon)
- {
- stats.ammo.ammoPerTon = ammoPerTon;
- }
- float getJumpJetRangeMod (void)
- {
- return (stats.jumpjet.rangeMod);
- }
- void setJumpJetRangeMod (float rangeMod)
- {
- stats.jumpjet.rangeMod = rangeMod;
- }
- float getAmmoExplosiveDamage (void) {
- return(stats.ammo.explosiveDamage);
- }
-
- void setAmmoExplosiveDamage (float ammoDamage)
- {
- stats.ammo.explosiveDamage = ammoDamage;
- }
- float getSensorRange (void) {
- return(stats.sensor.range);
- }
- unsigned char getTechBase (void) {
- return(techBase);
- }
- void setResourcePoints (long points) {
- resourcePoints = points;
- }
-
- void setSensorRange (float range)
- {
- stats.sensor.range = (short)range;
- }
- float getEcmRange (void) {
- return(stats.ecm.range);
- }
- void setEcmRange (float range) {
- stats.ecm.range = range;
- }
- float getEcmEffect (void) {
- return(stats.ecm.effect);
- }
- void setEcmEffect (float effect) {
- stats.ecm.effect = effect;
- }
- float getJammerEffect (void) {
- return(stats.jammer.effect);
- }
- void setJammerEffect (float effect) {
- stats.jammer.effect = effect;
- }
- float getProbeEffect (void) {
- return(stats.probe.effect);
- }
- void setProbeEffect (float effect) {
- stats.probe.effect = effect;
- }
- char *getAbbreviation (void) {
- return (&abbreviation[0]);
- }
-
- bool isOffensiveWeapon (void);
- bool isDefensiveWeapon (void);
- void multiplyWeaponRanges (float factor);
- static long loadMasterList (char* fileName, long numComponents, float baseSensorRange);
- static long saveMasterList (char* fileName, long numComponents,float baseSensorRange);
- static long freeMasterList (void);
- static long multiplyMasterListWeaponRanges (float factor);
- };
- #endif
- //******************************************************************************************
|