BWAPI
|
00001 #pragma once 00002 00003 #include <Util/Types.h> 00004 #include <BW/Sprite.h> 00005 #include <BW/Order.h> 00006 #include <BW/Path.h> 00007 #include <BW/Position.h> 00008 00009 #include <BWAPI/UnitType.h> 00010 #include <BW/Offsets.h> 00011 00012 namespace BW { class Sprite; }; 00013 namespace BW { struct Order; }; 00014 namespace BW { struct Path; }; 00015 00016 namespace BW 00017 { 00024 #pragma pack(1) // Note: alignment is probably default 4, not 1 00025 class Unit 00026 { 00027 public: 00028 BWAPI::UnitType type() const; 00029 bool movementFlag(u8 flags) const; 00030 bool statusFlag(u32 flags) const; 00031 00032 // v-- POSSIBLE SHARED BULLET/UNIT STRUCTURE BEGIN 00033 /*0x000*/ BW::Unit *prev; 00034 /*0x004*/ BW::Unit *next; 00038 /*0x008*/ s32 hitPoints; 00041 /*0x00C*/ BW::Sprite *sprite; 00042 /*0x010*/ BW::Position moveToPos; 00043 /*0x014*/ BW::Unit *moveToUnit; // The original description "target unit" was incorrect 00044 /*0x018*/ BW::Position nextMovementWaypoint; 00048 /*0x01C*/ BW::Position nextTargetWaypoint; 00049 /*0x020*/ u8 movementFlags; 00050 /*0x021*/ u8 currentDirection1; 00051 /*0x022*/ u8 flingyTurnRadius; 00052 /*0x023*/ u8 velocityDirection1; 00056 /*0x024*/ u16 flingyID; 00057 /*0x026*/ u8 _unknown_0x026; 00058 /*0x027*/ u8 flingyMovementType; 00059 /*0x028*/ BW::Position position; 00060 /*0x02C*/ POINT halt; 00061 /*0x034*/ u32 flingyTopSpeed; 00062 /*0x038*/ s32 current_speed1; 00063 /*0x03C*/ s32 current_speed2; 00064 /*0x040*/ POINT current_speed; 00065 00066 /*0x048*/ u16 flingyAcceleration; 00067 /*0x04A*/ u8 currentDirection2; 00068 /*0x04B*/ u8 velocityDirection2; // pathing related, gets this value from Path::unk_1A? 00069 /*0x04C*/ u8 playerID; 00070 /*0x04D*/ u8 orderID; 00071 /*0x04E*/ u8 orderState; 00072 /* 0x01 Moving/Following Order 00073 0x02 No collide (Larva)? 00074 0x04 Harvesting? Working? 00075 0x08 Constructing Stationary 00076 Note: I don't actually think these are flags 00077 */ 00078 /*0x04F*/ u8 orderSignal; 00079 /* 00080 0x01 Update building graphic/state 00081 0x02 Casting spell 00082 0x04 Reset collision? Always enabled for hallucination... 00083 0x10 Lift/Land state 00084 */ 00085 /*0x050*/ u16 orderUnitType; 00086 /*0x052*/ u16 _unused_0x052; // possible alignment 00087 /*0x054*/ u8 mainOrderTimer; // A timer for orders, example: time left before minerals are harvested 00088 /*0x055*/ u8 groundWeaponCooldown; 00089 /*0x056*/ u8 airWeaponCooldown; 00090 /*0x057*/ u8 spellCooldown; 00091 /*0x058*/ BW::Position orderTargetPos; 00092 /*0x05C*/ BW::Unit *orderTargetUnit; 00093 // ^-- POSSIBLE SHARED BULLET/UNIT STRUCTURE END 00094 00095 /*0x060*/ u32 shieldPoints; 00096 /*0x064*/ u16 unitType; 00097 /*0x066*/ u16 _padding_0x066; 00098 /*0x068*/ BW::Unit *previousPlayerUnit; 00099 /*0x06C*/ BW::Unit *nextPlayerUnit; 00100 /*0x070*/ BW::Unit *subUnit; 00101 /*0x074*/ BW::Order *orderQueueHead; 00102 /*0x078*/ BW::Order *orderQueueTail; 00103 /*0x07C*/ BW::Unit *AutoTargetUnit; // The auto-acquired target 00104 /*0x080*/ BW::Unit *connectedUnit; 00105 /*0x084*/ u8 orderQueueCount; 00106 /*0x085*/ u8 orderQueueTimer; /* counts/cycles down from from 8 to 0 (inclusive). See also 0x122. */ 00107 /*0x086*/ u8 _unknown_0x086; // pathing related? 00108 /*0x087*/ u8 attackNotifyTimer; // Prevent "Your forces are under attack." on every attack 00109 /*0x088*/ u16 displayedUnitID; 00110 /*0x08A*/ u8 lastEventTimer; // countdown that stops being recent when it hits 0 00111 /*0x08B*/ u8 lastEventColor; // 17 = was completed (train, morph), 174 = was attacked 00112 /*0x08C*/ u16 _unused_0x08C; // might have originally been RGB from lastEventColor 00113 /*0x08E*/ u8 rankIncrease; 00114 /*0x08F*/ u8 killCount; 00115 /*0x090*/ u8 lastAttackingPlayer; // the player that last attacked this unit 00116 /*0x091*/ u8 secondaryOrderTimer; 00117 /*0x092*/ u8 _unknown_0x091; 00118 /*0x093*/ u8 userActionFlags; // some flags that change when the user interacts with the unit 00119 // 2 = issued an order, 3 = interrupted an order, 4 = self destructing 00120 /*0x094*/ u16 currentButtonSet; // The u16 is a guess, used to be u8 00121 /*0x096*/ u8 cloaked; // 1 for cloaked 00122 /*0x097*/ u8 movementState; // A value based on conditions related to pathing, see Path.h for info 00123 /*0x098*/ u16 buildQueue[5]; 00124 /*0x0A2*/ u16 energy; 00125 /*0x0A4*/ u8 buildQueueSlot; 00126 /*0x0A5*/ u8 targetOrderSpecial; 00127 /*0x0A6*/ u8 secondaryOrderID; 00128 /*0x0A7*/ u8 buildingOverlayState; // 0 means the building has the largest amount of fire/blood 00129 /*0x0A8*/ u16 hpGainDuringRepair; 00130 /*0x0AA*/ u16 _unknown_0x0AA; 00131 /*0x0AC*/ u16 remainingBuildTime; 00132 /*0x0AE*/ u16 previousHP; // The HP of the unit before it changed (example Drone->Hatchery, the Drone's HP will be stored here) 00133 /*0x0B0*/ u16 loadedUnitIndex[8]; 00134 /*0x0C0*/ union 00135 { 00136 struct 00137 { 00138 u8 spiderMineCount; // 0 00139 } vulture; 00140 00141 struct 00142 { 00143 BW::Unit *inHangerChild; // 0 first child inside the hanger 00144 BW::Unit *outHangerChild; // 4 first child outside the hanger 00145 u8 inHangerCount; // 8 number inside the hanger 00146 u8 outHangerCount; // 9 number outside the hanger 00147 } carrier; // also applies to reaver 00148 00149 struct 00150 { 00151 BW::Unit *parent; // 0 00152 BW::Unit *prev; // 4 00153 BW::Unit *next; // 8 00154 u8 inHanger; // C 00155 } interceptor; // also applies to scarab 00156 00157 struct 00158 { 00159 u32 _unknown_00; 00160 u32 _unknown_04; 00161 u32 flagSpawnFrame; // flag beacons, the frame that the flag will spawn 00162 } beacon; 00163 00164 struct 00165 { 00166 BW::Unit *addon; // 0 00167 u16 addonBuildType; // 4 00168 u16 upgradeResearchTime; // 6 00169 u8 techType; // 8 00170 u8 upgradeType; // 9 00171 u8 larvaTimer; // A 00172 u8 landingTimer; // B 00173 u8 creepTimer; // C 00174 u8 upgradeLevel; // D 00175 u16 _padding_0E; // E // possible alignment 00176 union // 10 00177 { 00178 struct 00179 { u16 resourceCount; // amount of resources 00180 u8 resourceIscript; 00181 u8 gatherQueueCount; 00182 BW::Unit *nextGatherer; // 14 // pointer to the next workerunit waiting in line to gather 00183 u8 resourceGroup; // 18 00184 u8 resourceBelongsToAI; 00185 } resource; 00186 struct { BW::Unit *exit; } nydus; 00187 struct { BW::Sprite *nukeDot; } ghost; 00188 struct { BW::Sprite *pylonAura; } pylon; 00189 struct 00190 { BW::Unit *nuke; // attached nuke 00191 u32 hasNuke; // 14 00192 } silo; 00193 struct 00194 { u16 harvestValue1; 00195 u16 harvestValue2; 00196 u16 _unknown_14; // 14 00197 u16 harvestValue3; 00198 } hatchery; // wtf??? 00199 struct { POINTS origin; } powerup; 00200 }; 00201 } building; 00202 00203 struct 00204 { 00205 BW::Unit *powerup; // 0 00206 POINTS targetResource; // 4 00207 BW::Unit *targetResourceUnit; // 8 00208 u16 repairResourceLossTimer; // C 00209 u8 isCarryingSomething; // E 00210 u8 resourceCarryCount; // F 00211 BW::Unit *harvestTarget; // 10 00212 BW::Unit *prevHarvestUnit; // 14 // When there is a gather conflict 00213 BW::Unit *nextHarvestUnit; // 18 00214 } worker; 00215 }; 00216 /*0x0DC*/ u32 statusFlags; 00217 /*0x0E0*/ u8 resourceType; 00218 /*0x0E1*/ u8 wireframeRandomizer; 00219 /*0x0E2*/ u8 secondaryOrderState; 00220 /*0x0E3*/ u8 recentOrderTimer; // Counts down from 15 to 0 when most orders are given, 00221 // or when the unit moves after reaching a patrol location 00222 /*0x0E4*/ s32 visibilityStatus; // Flags specifying which players can detect this unit (cloaked/burrowed) 00223 /*0x0E8*/ u16 _unknown_0x0E8; // ?? 00224 /*0x0EA*/ u16 _unknown_0x0EA; // possible alignment 00225 /*0x0EC*/ BW::Unit *currentBuildUnit; 00226 /*0x0F0*/ BW::Unit *previousBurrowedUnit; 00227 /*0x0F4*/ BW::Unit *nextBurrowedUnit; 00228 /*0x0F8*/ union 00229 { struct 00230 { POINTS position; 00231 BW::Unit *unit; 00232 } rally; 00234 struct 00235 { BW::Unit *prevPsiProvider; 00236 BW::Unit *nextPsiProvider; 00237 } pylon; 00238 }; 00239 /*0x100*/ BW::Path *path; 00240 /*0x104*/ u8 pathingCollisionInterval; // unknown 00241 /*0x105*/ u8 pathingFlags; // 0x01 = uses pathing; 0x02 = ?; 0x04 = ? 00242 /*0x106*/ u8 _unused_0x106; 00243 /*0x107*/ u8 isBeingHealed; // 1 if a medic is currently healing this unit 00244 /*0x108*/ rect contourBounds; // a rect that specifies the closest contour (collision) points 00245 struct 00246 { 00247 /*0x110*/ u16 removeTimer; 00248 /*0x112*/ u16 defenseMatrixDamage; 00249 /*0x114*/ u8 defenseMatrixTimer; 00250 /*0x115*/ u8 stimTimer; 00251 /*0x116*/ u8 ensnareTimer; 00252 /*0x117*/ u8 lockdownTimer; 00253 /*0x118*/ u8 irradiateTimer; 00254 /*0x119*/ u8 stasisTimer; 00255 /*0x11A*/ u8 plagueTimer; 00256 /*0x11B*/ u8 isUnderStorm; 00257 /*0x11C*/ BW::Unit *irradiatedBy; 00258 /*0x120*/ u8 irradiatePlayerID; 00259 /*0x121*/ u8 parasiteFlags; 00260 /*0x122*/ u8 cycleCounter; /* counts/cycles up from 0 to 7 (inclusive). See also 0x85. */ 00261 /*0x123*/ u8 isBlind; 00262 /*0x124*/ u8 maelstromTimer; 00263 /*0x125*/ u8 _unused_0x125; // ?? Might be afterburner timer or ultralisk roar timer 00264 /*0x126*/ u8 acidSporeCount; 00265 /*0x127*/ u8 acidSporeTime[9]; 00266 } status; 00267 /*0x130*/ u16 bulletBehaviour3by3AttackSequence; // Counts up for the number of bullets shot by a unit using 00268 // this weapon behaviour and resets after it reaches 12 00269 /*0x132*/ u16 _padding_0x132; 00270 /*0x134*/ void *CAIControl; // pointer to AI class, we're not using this though 00271 /*0x138*/ u16 airStrength; 00272 /*0x13A*/ u16 groundStrength; 00273 /*0x13C*/ u32 unitFinderIndexLeft; // Order for the unit's left boundry 00274 /*0x140*/ u32 unitFinderIndexRight; // Order for the unit's right boundry 00275 /*0x144*/ u32 unitFinderIndexTop; // Order for the unit's top boundry 00276 /*0x148*/ u32 unitFinderIndexBottom; // Order for the unit's bottom boundry 00277 /*0x14C*/ u8 _repulseUnknown; 00278 /*0x14D*/ u8 repulseAngle; // updated only when air unit is being pushed 00279 /*0x14E*/ u8 driftPosX; 00280 /*0x14F*/ u8 driftPosY; 00281 }; 00282 #pragma pack() 00283 00284 CTASSERT( sizeof(Unit) == 336 ); 00285 }; 00286