1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef UNIT_DEF_H 4 #define UNIT_DEF_H 5 6 #include <string> 7 #include <vector> 8 #include <map> 9 10 #include "System/float3.h" 11 12 13 namespace springLegacyAI { 14 15 struct MoveData; 16 struct WeaponDef; 17 18 struct UnitModelDef 19 { UnitModelDefUnitModelDef20 UnitModelDef() {} 21 22 std::string modelPath; 23 std::string modelName; 24 std::map<std::string, std::string> modelTextures; 25 }; 26 27 28 struct UnitDef 29 { 30 public: 31 UnitDef(); 32 ~UnitDef(); 33 DontLandUnitDef34 bool DontLand() const { return dlHoverFactor >= 0.0f; } 35 36 bool valid; 37 std::string name; 38 std::string humanName; 39 std::string filename; 40 int id; // unique id for this type of unit 41 42 std::string decoyName; 43 const UnitDef* decoyDef; 44 45 int aihint; 46 int cobID; // associated with the COB <GET COB_ID unitID> call 47 48 int techLevel; 49 std::string gaia; 50 51 float metalUpkeep; 52 float energyUpkeep; 53 float metalMake; // metal will always be created 54 float makesMetal; // metal will be created when unit is on and enough energy can be drained 55 float energyMake; 56 float metalCost; 57 float energyCost; 58 float buildTime; 59 float extractsMetal; 60 float extractRange; 61 float windGenerator; 62 float tidalGenerator; 63 float metalStorage; 64 float energyStorage; 65 66 bool extractSquare; 67 68 float autoHeal; // amount autohealed 69 float idleAutoHeal; // amount autohealed only during idling 70 int idleTime; // time a unit needs to idle before its considered idling 71 72 float power; 73 float health; 74 unsigned int category; 75 76 float speed; // maximum forward speed the unit can attain (elmos/sec) 77 float rSpeed; // maximum reverse speed the unit can attain (elmos/sec) 78 float turnRate; 79 bool turnInPlace; 80 float turnInPlaceDistance; //!< units above this distance to goal will try to turn while keeping 81 //!< some of their speed. 0 to disable 82 float turnInPlaceSpeedLimit; //!< units below this speed will turn in place regardless of their 83 //!< turnInPlace setting 84 85 bool upright; 86 bool collide; 87 88 float losRadius; 89 float airLosRadius; 90 float losHeight; 91 92 int radarRadius; 93 int sonarRadius; 94 int jammerRadius; 95 int sonarJamRadius; 96 int seismicRadius; 97 float seismicSignature; 98 bool stealth; 99 bool sonarStealth; 100 101 bool buildRange3D; 102 float buildDistance; 103 float buildSpeed; 104 float reclaimSpeed; 105 float repairSpeed; 106 float maxRepairSpeed; 107 float resurrectSpeed; 108 float captureSpeed; 109 float terraformSpeed; 110 111 float mass; 112 113 bool pushResistant; 114 bool strafeToAttack; /// should the unit move sideways when it can't shoot? 115 float minCollisionSpeed; 116 float slideTolerance; 117 float maxSlope; 118 float maxHeightDif; /// maximum terraform height this building allows 119 float minWaterDepth; 120 float waterline; 121 122 float maxWaterDepth; 123 124 float armoredMultiple; 125 int armorType; 126 127 int flankingBonusMode; // 0: no flanking bonus 128 // 1: global coords, mobile 129 // 2: unit coords, mobile 130 // 3: unit coords, locked 131 float3 flankingBonusDir; // units takes less damage when attacked from this dir (encourage flanking fire) 132 float flankingBonusMax; // damage factor for the least protected direction 133 float flankingBonusMin; // damage factor for the most protected direction 134 float flankingBonusMobilityAdd; // how much the ability of the flanking bonus direction to move builds up each frame 135 136 UnitModelDef modelDef; 137 138 std::string objectName; // raw name of the unit's model without objects3d prefix, eg. "armjeth.s3o" 139 std::string scriptName; // the name of the unit's script, e.g. "armjeth.cob" 140 std::string scriptPath; // the path of the unit's script, e.g. "scripts/armjeth.cob" 141 142 float3 modelCenterOffset; // offset from the unit model's default center point (unit-space) 143 144 bool usePieceCollisionVolumes; // if true, collisions are checked per-piece 145 146 147 struct UnitDefWeapon { 148 UnitDefWeapon(); 149 UnitDefWeapon(std::string name, const WeaponDef* def, int slavedTo, 150 float3 mainDir, float maxAngleDif, unsigned int badTargetCat, 151 unsigned int onlyTargetCat, float fuelUse); 152 std::string name; 153 const WeaponDef* def; 154 int slavedTo; 155 float3 mainDir; 156 float maxAngleDif; 157 float fuelUsage; /// How many seconds of fuel it costs for the owning unit to fire this weapon 158 unsigned int badTargetCat; 159 unsigned int onlyTargetCat; 160 }; 161 std::vector<UnitDefWeapon> weapons; 162 const WeaponDef* shieldWeaponDef; 163 const WeaponDef* stockpileWeaponDef; 164 float maxWeaponRange; 165 float maxCoverage; 166 167 std::map<int, std::string> buildOptions; 168 169 std::string type; 170 std::string tooltip; 171 std::string wreckName; 172 173 std::string deathExplosion; 174 std::string selfDExplosion; 175 176 std::string categoryString; 177 178 std::string buildPicName; 179 180 bool canSelfD; 181 int selfDCountdown; 182 183 bool canSubmerge; 184 bool canfly; 185 bool canmove; 186 bool canhover; 187 bool floater; 188 bool builder; 189 bool activateWhenBuilt; 190 bool onoffable; 191 bool fullHealthFactory; 192 bool factoryHeadingTakeoff; 193 194 bool reclaimable; 195 bool capturable; 196 bool repairable; 197 198 bool canRestore; 199 bool canRepair; 200 bool canSelfRepair; 201 bool canReclaim; 202 bool canAttack; 203 bool canPatrol; 204 bool canFight; 205 bool canGuard; 206 bool canAssist; 207 bool canBeAssisted; 208 bool canRepeat; 209 bool canFireControl; 210 211 int fireState; 212 int moveState; 213 214 //aircraft stuff 215 float wingDrag; 216 float wingAngle; 217 float drag; 218 float frontToSpeed; 219 float speedToFront; 220 float myGravity; 221 222 float maxBank; 223 float maxPitch; 224 float turnRadius; 225 float wantedHeight; 226 float verticalSpeed; 227 bool useSmoothMesh; 228 bool canCrash; 229 bool hoverAttack; 230 bool airStrafe; 231 float dlHoverFactor; // < 0 means it can land, >= 0 indicates how much the unit will move during hovering on the spot 232 bool bankingAllowed; 233 234 float maxAcc; 235 float maxDec; 236 float maxAileron; 237 float maxElevator; 238 float maxRudder; 239 float crashDrag; 240 241 MoveData* movedata; 242 unsigned char* yardmaps[4]; // Iterations of the Ymap for building rotation 243 244 int xsize; // each size is 8 units 245 int zsize; // each size is 8 units 246 247 int buildangle; 248 249 float loadingRadius; // for transports 250 float unloadSpread; 251 int transportCapacity; 252 int transportSize; 253 int minTransportSize; 254 bool isAirBase; 255 bool isFirePlatform; // should the carried units still be able to shoot? 256 float transportMass; 257 float minTransportMass; 258 bool holdSteady; 259 bool releaseHeld; 260 bool cantBeTransported; 261 bool transportByEnemy; 262 int transportUnloadMethod; // 0 - land unload, 1 - flyover drop, 2 - land flood 263 float fallSpeed; // dictates fall speed of all transported units 264 float unitFallSpeed; // sets the transported units fbi, overrides fallSpeed 265 266 bool canCloak; // if the unit can cloak 267 bool startCloaked; // if the units want to start out cloaked 268 float cloakCost; // energy cost per second to stay cloaked when stationary 269 float cloakCostMoving; // energy cost per second when moving 270 float decloakDistance; // if enemy unit come within this range decloaking is forced 271 bool decloakSpherical; // use a spherical test instead of a cylindrical test? 272 bool decloakOnFire; // should the unit decloak upon firing 273 int cloakTimeout; // minimum time between decloak and subsequent cloak 274 275 bool canKamikaze; //self destruct if enemy come to close 276 float kamikazeDist; 277 bool kamikazeUseLOS; 278 279 bool targfac; 280 bool canDGun; 281 bool needGeo; 282 bool isFeature; 283 bool hideDamage; 284 bool isCommander; 285 bool showPlayerName; 286 287 bool canResurrect; 288 bool canCapture; 289 int highTrajectoryType; // 0 (default) = only low, 1 = only high, 2 = choose 290 291 unsigned int noChaseCategory; 292 293 bool leaveTracks; 294 std::string trackTypeName; 295 float trackWidth; 296 float trackOffset; 297 float trackStrength; 298 float trackStretch; 299 int trackType; 300 301 bool canDropFlare; 302 float flareReloadTime; 303 float flareEfficiency; 304 float flareDelay; 305 float3 flareDropVector; 306 int flareTime; 307 int flareSalvoSize; 308 int flareSalvoDelay; 309 310 bool smoothAnim; // True if the unit should use interpolated animation 311 bool canLoopbackAttack; // only matters for fighter aircraft 312 bool levelGround; // only matters for buildings 313 314 bool useBuildingGroundDecal; 315 std::string buildingDecalTypeName; 316 int buildingDecalType; 317 int buildingDecalSizeX; 318 int buildingDecalSizeY; 319 float buildingDecalDecaySpeed; 320 321 bool showNanoFrame; // Does the nano frame animation get shown during construction? 322 bool showNanoSpray; // Does nano spray get shown at all? 323 float3 nanoColor; // If nano spray is displayed what color is it? 324 325 float maxFuel; // max flight time in seconds before the aircraft needs to return to a air repair bay to refuel 326 float refuelTime; // time to fully refuel unit 327 float minAirBasePower; // min build power for airbases that this aircraft can land on 328 329 std::vector<std::string> sfxExplGenNames; 330 331 std::string pieceTrailCEGTag; // base tag (eg. "flame") of CEG attached to pieces of exploding units 332 int pieceTrailCEGRange; // range of piece CEGs (0-based, range 8 ==> tags "flame0", ..., "flame7") 333 334 int maxThisUnit; // number of units of this type allowed simultaneously in the game 335 336 std::map<std::string, std::string> customParams; 337 338 private: 339 // float realMetalCost; 340 // float realEnergyCost; 341 // float realMetalUpkeep; 342 // float realEnergyUpkeep; 343 // float realBuildTime; 344 }; 345 346 } // namespace springLegacyAI 347 348 #endif /* UNIT_DEF_H */ 349