UDATA.CPP 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/UDATA.CPP 1 3/03/97 10:26a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : UDATA.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : September 10, 1993 *
  30. * *
  31. * Last Update : July 19, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * UnitTypeClass::As_Reference -- Fetches a reference to the unit type class specified. *
  36. * UnitTypeClass::Create_And_Place -- Creates and places a unit object onto the map. *
  37. * UnitTypeClass::Create_One_Of -- Creates a unit in limbo. *
  38. * UnitTypeClass::Dimensions -- Determines the unit's pixel dimensions. *
  39. * UnitTypeClass::Display -- Displays a generic unit shape. *
  40. * UnitTypeClass::From_Name -- Fetch class pointer from specified name. *
  41. * UnitTypeClass::Init_Heap -- Initialize the unit type class heap. *
  42. * UnitTypeClass::Max_Pips -- Fetches the maximum pips allowed for this unit. *
  43. * UnitTypeClass::One_Time -- Performs one time processing for unit type class objects. *
  44. * UnitTypeClass::Prep_For_Add -- Prepares scenario editor to add unit. *
  45. * UnitTypeClass::Read_INI -- Fetch the unit type data from the INI database. *
  46. * UnitTypeClass::Turret_Adjust -- Turret adjustment routine for MLRS and MSAM units. *
  47. * UnitTypeClass::UnitTypeClass -- Constructor for unit types. *
  48. * UnitTypeClass::operator delete -- Return a unit type class object back to the pool. *
  49. * UnitTypeClass::operator new -- Allocates an object from the unit type class heap. *
  50. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  51. #include "function.h"
  52. /*
  53. ** This is the list of animation stages to use when the harvester
  54. ** is to dump its load into the refinery. The offsets are based from the
  55. ** start of the dump animation.
  56. */
  57. const int UnitTypeClass::Harvester_Dump_List[22] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,6,5,4,3,2,1,0};
  58. const int UnitTypeClass::Harvester_Load_List[9] = {0, 1, 2, 3, 4, 5, 6, 7, 0};
  59. const int UnitTypeClass::Harvester_Load_Count = 8;
  60. // V2 rocket launcher
  61. static UnitTypeClass const UnitV2Launcher(
  62. UNIT_V2_LAUNCHER,
  63. TXT_V2_LAUNCHER, // NAME: Text name of this unit type.
  64. "V2RL", // NAME: Text name of this unit type.
  65. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  66. REMAP_NORMAL, // Sidebar remap logic.
  67. 0x0000, // Vertical offset.
  68. 0x0000, // Primary weapon offset along turret centerline.
  69. 0x0000, // Primary weapon lateral offset along turret centerline.
  70. 0x0000, // Secondary weapon offset along turret centerline.
  71. 0x0000, // Secondary weapon lateral offset along turret centerling.
  72. true, // Can this be a goodie surprise from a crate?
  73. false, // Always use the given name for the vehicle?
  74. true, // Can this unit squash infantry?
  75. false, // Does this unit harvest Tiberium?
  76. false, // Is invisible to radar?
  77. false, // Is it insignificant (won't be announced)?
  78. false, // Is it equipped with a combat turret?
  79. false, // Does it have a rotating radar dish?
  80. false, // Is there an associated firing animation?
  81. false, // Must the turret be in a locked down position while moving?
  82. true, // Is this a gigundo-rotund-enormous unit?
  83. false, // Does the unit have a constant animation?
  84. false, // Is the unit capable of jamming radar?
  85. false, // Is the unit a mobile gap generator?
  86. 32, // Rotation stages.
  87. 0, // Turret center offset along body centerline.
  88. MISSION_HUNT // ORDERS: Default order to give new unit.
  89. );
  90. // Light tank
  91. static UnitTypeClass const UnitLTank(
  92. UNIT_LTANK,
  93. TXT_LTANK, // NAME: Text name of this unit type.
  94. "1TNK", // NAME: Text name of this unit type.
  95. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  96. REMAP_NORMAL, // Sidebar remap logic.
  97. 0x0020, // Vertical offset.
  98. 0x00C0, // Primary weapon offset along turret centerline.
  99. 0x0000, // Primary weapon lateral offset along turret centerline.
  100. 0x0000, // Secondary weapon offset along turret centerline.
  101. 0x0000, // Secondary weapon lateral offset along turret centerling.
  102. true, // Can this be a goodie surprise from a crate?
  103. false, // Always use the given name for the vehicle?
  104. true, // Can this unit squash infantry?
  105. false, // Does this unit harvest Tiberium?
  106. false, // Is invisible to radar?
  107. false, // Is it insignificant (won't be announced)?
  108. true, // Is it equipped with a combat turret?
  109. false, // Does it have a rotating radar dish?
  110. false, // Is there an associated firing animation?
  111. false, // Must the turret be in a locked down position while moving?
  112. false, // Is this a gigundo-rotund-enormous unit?
  113. false, // Does the unit have a constant animation?
  114. false, // Is the unit capable of jamming radar?
  115. false, // Is the unit a mobile gap generator?
  116. 32, // Rotation stages.
  117. 0, // Turret center offset along body centerline.
  118. MISSION_HUNT // ORDERS: Default order to give new unit.
  119. );
  120. // Heavy tank
  121. static UnitTypeClass const UnitMTank(
  122. UNIT_MTANK,
  123. TXT_MTANK, // NAME: Text name of this unit type.
  124. "3TNK", // NAME: Text name of this unit type.
  125. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  126. REMAP_NORMAL, // Sidebar remap logic.
  127. 0x0040, // Vertical offset.
  128. 0x0080, // Primary weapon offset along turret centerline.
  129. 0x0018, // Primary weapon lateral offset along turret centerline.
  130. 0x0080, // Secondary weapon offset along turret centerline.
  131. 0x0018, // Secondary weapon lateral offset along turret centerling.
  132. true, // Can this be a goodie surprise from a crate?
  133. false, // Always use the given name for the vehicle?
  134. true, // Can this unit squash infantry?
  135. false, // Does this unit harvest Tiberium?
  136. false, // Is invisible to radar?
  137. false, // Is it insignificant (won't be announced)?
  138. true, // Is it equipped with a combat turret?
  139. false, // Does it have a rotating radar dish?
  140. false, // Is there an associated firing animation?
  141. false, // Must the turret be in a locked down position while moving?
  142. true, // Is this a gigundo-rotund-enormous unit?
  143. false, // Does the unit have a constant animation?
  144. false, // Is the unit capable of jamming radar?
  145. false, // Is the unit a mobile gap generator?
  146. 32, // Rotation stages.
  147. 0, // Turret center offset along body centerline.
  148. MISSION_HUNT // ORDERS: Default order to give new unit.
  149. );
  150. // Medium tank
  151. static UnitTypeClass const UnitMTank2(
  152. UNIT_MTANK2,
  153. TXT_MTANK2, // NAME: Text name of this unit type.
  154. "2TNK", // NAME: Text name of this unit type.
  155. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  156. REMAP_NORMAL, // Sidebar remap logic.
  157. 0x0030, // Vertical offset.
  158. 0x00C0, // Primary weapon offset along turret centerline.
  159. 0x0000, // Primary weapon lateral offset along turret centerline.
  160. 0x00C0, // Secondary weapon offset along turret centerline.
  161. 0x0000, // Secondary weapon lateral offset along turret centerling.
  162. true, // Can this be a goodie surprise from a crate?
  163. false, // Always use the given name for the vehicle?
  164. true, // Can this unit squash infantry?
  165. false, // Does this unit harvest Tiberium?
  166. false, // Is invisible to radar?
  167. false, // Is it insignificant (won't be announced)?
  168. true, // Is it equipped with a combat turret?
  169. false, // Does it have a rotating radar dish?
  170. false, // Is there an associated firing animation?
  171. false, // Must the turret be in a locked down position while moving?
  172. true, // Is this a gigundo-rotund-enormous unit?
  173. false, // Does the unit have a constant animation?
  174. false, // Is the unit capable of jamming radar?
  175. false, // Is the unit a mobile gap generator?
  176. 32, // Rotation stages.
  177. 0, // Turret center offset along body centerline.
  178. MISSION_HUNT // ORDERS: Default order to give new unit.
  179. );
  180. // Mastadon tank
  181. static UnitTypeClass const UnitHTank(
  182. UNIT_HTANK,
  183. TXT_HTANK, // NAME: Text name of this unit type.
  184. "4TNK", // NAME: Text name of this unit type.
  185. ANIM_ART_EXP1, // EXPLOSION: Type of explosion when destroyed.
  186. REMAP_NORMAL, // Sidebar remap logic.
  187. 0x0020, // Vertical offset.
  188. 0x00C0, // Primary weapon offset along turret centerline.
  189. 0x0028, // Primary weapon lateral offset along turret centerline.
  190. 0x0008, // Secondary weapon offset along turret centerline.
  191. 0x0040, // Secondary weapon lateral offset along turret centerling.
  192. true, // Can this be a goodie surprise from a crate?
  193. false, // Always use the given name for the vehicle?
  194. true, // Can this unit squash infantry?
  195. false, // Does this unit harvest Tiberium?
  196. false, // Is invisible to radar?
  197. false, // Is it insignificant (won't be announced)?
  198. true, // Is it equipped with a combat turret?
  199. false, // Does it have a rotating radar dish?
  200. false, // Is there an associated firing animation?
  201. false, // Must the turret be in a locked down position while moving?
  202. true, // Is this a gigundo-rotund-enormous unit?
  203. false, // Does the unit have a constant animation?
  204. false, // Is the unit capable of jamming radar?
  205. false, // Is the unit a mobile gap generator?
  206. 32, // Rotation stages.
  207. 0, // Turret center offset along body centerline.
  208. MISSION_HUNT // ORDERS: Default order to give new unit.
  209. );
  210. // Mobile Radar Jammer
  211. static UnitTypeClass const UnitMRJammer(
  212. UNIT_MRJ,
  213. TXT_MRJ, // NAME: Text name of this unit type.
  214. "MRJ", // NAME: Text name of this unit type.
  215. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  216. REMAP_NORMAL, // Sidebar remap logic.
  217. 0x0000, // Vertical offset.
  218. 0x0000, // Primary weapon offset along turret centerline.
  219. 0x0000, // Primary weapon lateral offset along turret centerline.
  220. 0x0000, // Secondary weapon offset along turret centerline.
  221. 0x0000, // Secondary weapon lateral offset along turret centerling.
  222. false, // Can this be a goodie surprise from a crate?
  223. false, // Always use the given name for the vehicle?
  224. true, // Can this unit squash infantry?
  225. false, // Does this unit harvest Tiberium?
  226. true, // Is invisible to radar?
  227. false, // Is it insignificant (won't be announced)?
  228. false, // Is it equipped with a combat turret?
  229. true, // Does it have a rotating radar dish?
  230. false, // Is there an associated firing animation?
  231. false, // Must the turret be in a locked down position while moving?
  232. false, // Is this a gigundo-rotund-enormous unit?
  233. false, // Does the unit have a constant animation?
  234. true, // Is the unit capable of jamming radar?
  235. false, // Is the unit a mobile gap generator?
  236. 32, // Rotation stages.
  237. 0, // Turret center offset along body centerline.
  238. MISSION_HUNT // ORDERS: Default order to give new unit.
  239. );
  240. // Mobile Gap Generator
  241. static UnitTypeClass const UnitMGG(
  242. UNIT_MGG,
  243. TXT_MGG, // NAME: Text name of this unit type.
  244. "MGG", // NAME: Text name of this unit type.
  245. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  246. REMAP_NORMAL, // Sidebar remap logic.
  247. 0x0000, // Vertical offset.
  248. 0x0000, // Primary weapon offset along turret centerline.
  249. 0x0000, // Primary weapon lateral offset along turret centerline.
  250. 0x0000, // Secondary weapon offset along turret centerline.
  251. 0x0000, // Secondary weapon lateral offset along turret centerling.
  252. false, // Can this be a goodie surprise from a crate?
  253. false, // Always use the given name for the vehicle?
  254. true, // Can this unit squash infantry?
  255. false, // Does this unit harvest Tiberium?
  256. false, // Is invisible to radar?
  257. false, // Is it insignificant (won't be announced)?
  258. false, // Is it equipped with a combat turret?
  259. true, // Does it have a rotating radar dish?
  260. false, // Is there an associated firing animation?
  261. false, // Must the turret be in a locked down position while moving?
  262. true, // Is this a gigundo-rotund-enormous unit?
  263. false, // Does the unit have a constant animation?
  264. false, // Is the unit capable of jamming radar?
  265. true, // Is the unit a mobile gap generator?
  266. 32, // Rotation stages.
  267. 0, // Turret center offset along body centerline.
  268. MISSION_HUNT // ORDERS: Default order to give new unit.
  269. );
  270. // Artillery
  271. static UnitTypeClass const UnitArty(
  272. UNIT_ARTY,
  273. TXT_ARTY, // NAME: Text name of this unit type.
  274. "ARTY", // NAME: Text name of this unit type.
  275. ANIM_ART_EXP1, // EXPLOSION: Type of explosion when destroyed.
  276. REMAP_NORMAL, // Sidebar remap logic.
  277. 0x0040, // Vertical offset.
  278. 0x0060, // Primary weapon offset along turret centerline.
  279. 0x0000, // Primary weapon lateral offset along turret centerline.
  280. 0x0000, // Secondary weapon offset along turret centerline.
  281. 0x0000, // Secondary weapon lateral offset along turret centerling.
  282. true, // Can this be a goodie surprise from a crate?
  283. false, // Always use the given name for the vehicle?
  284. false, // Can this unit squash infantry?
  285. false, // Does this unit harvest Tiberium?
  286. false, // Is invisible to radar?
  287. false, // Is it insignificant (won't be announced)?
  288. false, // Is it equipped with a combat turret?
  289. false, // Does it have a rotating radar dish?
  290. false, // Is there an associated firing animation?
  291. false, // Must the turret be in a locked down position while moving?
  292. false, // Is this a gigundo-rotund-enormous unit?
  293. false, // Does the unit have a constant animation?
  294. false, // Is the unit capable of jamming radar?
  295. false, // Is the unit a mobile gap generator?
  296. 32, // Rotation stages.
  297. 0, // Turret center offset along body centerline.
  298. MISSION_HUNT // ORDERS: Default order to give new unit.
  299. );
  300. // Harvester
  301. static UnitTypeClass const UnitHarvester(
  302. UNIT_HARVESTER,
  303. TXT_HARVESTER, // NAME: Text name of this unit type.
  304. "HARV", // NAME: Text name of this unit type.
  305. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  306. REMAP_ALTERNATE, // Sidebar remap logic.
  307. 0x0000, // Vertical offset.
  308. 0x0000, // Primary weapon offset along turret centerline.
  309. 0x0000, // Primary weapon lateral offset along turret centerline.
  310. 0x0000, // Secondary weapon offset along turret centerline.
  311. 0x0000, // Secondary weapon lateral offset along turret centerling.
  312. true, // Can this be a goodie surprise from a crate?
  313. true, // Always use the given name for the vehicle?
  314. true, // Can this unit squash infantry?
  315. true, // Does this unit harvest Tiberium?
  316. false, // Is invisible to radar?
  317. false, // Is it insignificant (won't be announced)?
  318. false, // Is it equipped with a combat turret?
  319. false, // Does it have a rotating radar dish?
  320. false, // Is there an associated firing animation?
  321. false, // Must the turret be in a locked down position while moving?
  322. true, // Is this a gigundo-rotund-enormous unit?
  323. false, // Does the unit have a constant animation?
  324. false, // Is the unit capable of jamming radar?
  325. false, // Is the unit a mobile gap generator?
  326. 32, // Rotation stages.
  327. 0, // Turret center offset along body centerline.
  328. MISSION_HARVEST // ORDERS: Default order to give new unit.
  329. );
  330. // Mobile construction vehicle
  331. static UnitTypeClass const UnitMCV(
  332. UNIT_MCV,
  333. TXT_MCV, // NAME: Text name of this unit type.
  334. "MCV", // NAME: Text name of this unit type.
  335. ANIM_FBALL1, // EXPLOSION: Type of explosion when destroyed.
  336. REMAP_ALTERNATE, // Sidebar remap logic.
  337. 0x0000, // Vertical offset.
  338. 0x0000, // Primary weapon offset along turret centerline.
  339. 0x0000, // Primary weapon lateral offset along turret centerline.
  340. 0x0000, // Secondary weapon offset along turret centerline.
  341. 0x0000, // Secondary weapon lateral offset along turret centerling.
  342. true, // Can this be a goodie surprise from a crate?
  343. false, // Always use the given name for the vehicle?
  344. true, // Can this unit squash infantry?
  345. false, // Does this unit harvest Tiberium?
  346. false, // Is invisible to radar?
  347. false, // Is it insignificant (won't be announced)?
  348. false, // Is it equipped with a combat turret?
  349. false, // Does it have a rotating radar dish?
  350. false, // Is there an associated firing animation?
  351. false, // Must the turret be in a locked down position while moving?
  352. true, // Is this a gigundo-rotund-enormous unit?
  353. false, // Does the unit have a constant animation?
  354. false, // Is the unit capable of jamming radar?
  355. false, // Is the unit a mobile gap generator?
  356. 32, // Rotation stages.
  357. 0, // Turret center offset along body centerline.
  358. MISSION_HUNT // ORDERS: Default order to give new unit.
  359. );
  360. // Jeep (hummer)
  361. static UnitTypeClass const UnitJeep(
  362. UNIT_JEEP,
  363. TXT_JEEP, // NAME: Text name of this unit type.
  364. "JEEP", // NAME: Text name of this unit type.
  365. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  366. REMAP_NORMAL, // Sidebar remap logic.
  367. 0x0030, // Vertical offset.
  368. 0x0030, // Primary weapon offset along turret centerline.
  369. 0x0000, // Primary weapon lateral offset along turret centerline.
  370. 0x0030, // Secondary weapon offset along turret centerline.
  371. 0x0000, // Secondary weapon lateral offset along turret centerling.
  372. true, // Can this be a goodie surprise from a crate?
  373. false, // Always use the given name for the vehicle?
  374. false, // Can this unit squash infantry?
  375. false, // Does this unit harvest Tiberium?
  376. false, // Is invisible to radar?
  377. false, // Is it insignificant (won't be announced)?
  378. true, // Is it equipped with a combat turret?
  379. false, // Does it have a rotating radar dish?
  380. false, // Is there an associated firing animation?
  381. false, // Must the turret be in a locked down position while moving?
  382. false, // Is this a gigundo-rotund-enormous unit?
  383. false, // Does the unit have a constant animation?
  384. false, // Is the unit capable of jamming radar?
  385. false, // Is the unit a mobile gap generator?
  386. 32, // Rotation stages.
  387. 0, // Turret center offset along body centerline.
  388. MISSION_HUNT // ORDERS: Default order to give new unit.
  389. );
  390. // Armored personnel carrier
  391. static UnitTypeClass const UnitAPC(
  392. UNIT_APC,
  393. TXT_APC, // NAME: Text name of this unit type.
  394. "APC", // NAME: Text name of this unit type.
  395. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  396. REMAP_NORMAL, // Sidebar remap logic.
  397. 0x0030, // Vertical offset.
  398. 0x0030, // Primary weapon offset along turret centerline.
  399. 0x0000, // Primary weapon lateral offset along turret centerline.
  400. 0x0030, // Secondary weapon offset along turret centerline.
  401. 0x0000, // Secondary weapon lateral offset along turret centerling.
  402. true, // Can this be a goodie surprise from a crate?
  403. false, // Always use the given name for the vehicle?
  404. true, // Can this unit squash infantry?
  405. false, // Does this unit harvest Tiberium?
  406. false, // Is invisible to radar?
  407. false, // Is it insignificant (won't be announced)?
  408. false, // Is it equipped with a combat turret?
  409. false, // Does it have a rotating radar dish?
  410. false, // Is there an associated firing animation?
  411. false, // Must the turret be in a locked down position while moving?
  412. false, // Is this a gigundo-rotund-enormous unit?
  413. false, // Does the unit have a constant animation?
  414. false, // Is the unit capable of jamming radar?
  415. false, // Is the unit a mobile gap generator?
  416. 32, // Rotation stages.
  417. 0, // Turret center offset along body centerline.
  418. MISSION_HUNT // ORDERS: Default order to give new unit.
  419. );
  420. // Mine laying truck
  421. static UnitTypeClass const UnitMineLayer(
  422. UNIT_MINELAYER,
  423. TXT_MINE_LAYER, // NAME: Text name of this unit type.
  424. "MNLY", // NAME: Text name of this unit type.
  425. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  426. REMAP_NORMAL, // Sidebar remap logic.
  427. 0x0000, // Vertical offset.
  428. 0x0000, // Primary weapon offset along turret centerline.
  429. 0x0000, // Primary weapon lateral offset along turret centerline.
  430. 0x0000, // Secondary weapon offset along turret centerline.
  431. 0x0000, // Secondary weapon lateral offset along turret centerling.
  432. true, // Can this be a goodie surprise from a crate?
  433. false, // Always use the given name for the vehicle?
  434. true, // Can this unit squash infantry?
  435. false, // Does this unit harvest Tiberium?
  436. false, // Is invisible to radar?
  437. false, // Is it insignificant (won't be announced)?
  438. false, // Is it equipped with a combat turret?
  439. false, // Does it have a rotating radar dish?
  440. false, // Is there an associated firing animation?
  441. false, // Must the turret be in a locked down position while moving?
  442. false, // Is this a gigundo-rotund-enormous unit?
  443. false, // Does the unit have a constant animation?
  444. false, // Is the unit capable of jamming radar?
  445. false, // Is the unit a mobile gap generator?
  446. 32, // Rotation stages.
  447. 0, // Turret center offset along body centerline.
  448. MISSION_HUNT // ORDERS: Default order to give new unit.
  449. );
  450. // Convoy Truck
  451. static UnitTypeClass const UnitConvoyTruck(
  452. UNIT_TRUCK,
  453. TXT_TRUCK, // NAME: Text name of this unit type.
  454. "TRUK", // NAME: Text name of this unit type.
  455. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  456. REMAP_NORMAL, // Sidebar remap logic.
  457. 0x0000, // Vertical offset.
  458. 0x0000, // Primary weapon offset along turret centerline.
  459. 0x0000, // Primary weapon lateral offset along turret centerline.
  460. 0x0000, // Secondary weapon offset along turret centerline.
  461. 0x0000, // Secondary weapon lateral offset along turret centerling.
  462. false, // Can this be a goodie surprise from a crate?
  463. false, // Always use the given name for the vehicle?
  464. false, // Can this unit squash infantry?
  465. false, // Does this unit harvest Tiberium?
  466. false, // Is invisible to radar?
  467. false, // Is it insignificant (won't be announced)?
  468. false, // Is it equipped with a combat turret?
  469. false, // Does it have a rotating radar dish?
  470. false, // Is there an associated firing animation?
  471. false, // Must the turret be in a locked down position while moving?
  472. false, // Is this a gigundo-rotund-enormous unit?
  473. false, // Does the unit have a constant animation?
  474. false, // Is the unit capable of jamming radar?
  475. false, // Is the unit a mobile gap generator?
  476. 32, // Rotation stages.
  477. 0, // Turret center offset along body centerline.
  478. MISSION_GUARD // ORDERS: Default order to give new unit.
  479. );
  480. #ifdef FIXIT_ANTS
  481. /*
  482. [ANT]
  483. Name=Warrior Ant
  484. Primary=Mandible
  485. Strength=150
  486. Armor=light
  487. TechLevel=-1
  488. Sight=2
  489. Speed=5
  490. Cost=700
  491. Points=40
  492. ROT=5
  493. Tracked=yes
  494. Crewed=no
  495. NoMovingFire=yes
  496. ; Ant mandible
  497. [Mandible]
  498. Damage=50
  499. ROF=5
  500. Range=1.5
  501. Projectile=Invisible
  502. Speed=100
  503. Warhead=HollowPoint
  504. Report=none
  505. */
  506. // Warrior ant
  507. static UnitTypeClass const UnitAnt1(
  508. UNIT_ANT1,
  509. TXT_NONE, // NAME: Text name of this unit type.
  510. "ANT1", // NAME: Text name of this unit type.
  511. ANIM_ANT_DEATH, // EXPLOSION: Type of explosion when destroyed.
  512. REMAP_NORMAL, // Sidebar remap logic.
  513. 0x0000, // Vertical offset.
  514. 0x0000, // Primary weapon offset along turret centerline.
  515. 0x0000, // Primary weapon lateral offset along turret centerline.
  516. 0x0000, // Secondary weapon offset along turret centerline.
  517. 0x0000, // Secondary weapon lateral offset along turret centerling.
  518. false, // Can this be a goodie surprise from a crate?
  519. true, // Always use the given name for the vehicle?
  520. false, // Can this unit squash infantry?
  521. false, // Does this unit harvest Tiberium?
  522. false, // Is invisible to radar?
  523. true, // Is it insignificant (won't be announced)?
  524. false, // Is it equipped with a combat turret?
  525. false, // Does it have a rotating radar dish?
  526. false, // Is there an associated firing animation?
  527. false, // Must the turret be in a locked down position while moving?
  528. true, // Is this a gigundo-rotund-enormous unit?
  529. false, // Does the unit have a constant animation?
  530. false, // Is the unit capable of jamming radar?
  531. false, // Is the unit a mobile gap generator?
  532. 8, // Rotation stages.
  533. 0, // Turret center offset along body centerline.
  534. MISSION_HUNT // ORDERS: Default order to give new unit.
  535. );
  536. static UnitTypeClass const UnitAnt2(
  537. UNIT_ANT2,
  538. TXT_NONE, // NAME: Text name of this unit type.
  539. "ANT2", // NAME: Text name of this unit type.
  540. ANIM_ANT_DEATH, // EXPLOSION: Type of explosion when destroyed.
  541. REMAP_NORMAL, // Sidebar remap logic.
  542. 0x0000, // Vertical offset.
  543. 0x0000, // Primary weapon offset along turret centerline.
  544. 0x0000, // Primary weapon lateral offset along turret centerline.
  545. 0x0000, // Secondary weapon offset along turret centerline.
  546. 0x0000, // Secondary weapon lateral offset along turret centerling.
  547. false, // Can this be a goodie surprise from a crate?
  548. true, // Always use the given name for the vehicle?
  549. false, // Can this unit squash infantry?
  550. false, // Does this unit harvest Tiberium?
  551. false, // Is invisible to radar?
  552. true, // Is it insignificant (won't be announced)?
  553. false, // Is it equipped with a combat turret?
  554. false, // Does it have a rotating radar dish?
  555. false, // Is there an associated firing animation?
  556. false, // Must the turret be in a locked down position while moving?
  557. true, // Is this a gigundo-rotund-enormous unit?
  558. false, // Does the unit have a constant animation?
  559. false, // Is the unit capable of jamming radar?
  560. false, // Is the unit a mobile gap generator?
  561. 8, // Rotation stages.
  562. 0, // Turret center offset along body centerline.
  563. MISSION_HUNT // ORDERS: Default order to give new unit.
  564. );
  565. static UnitTypeClass const UnitAnt3(
  566. UNIT_ANT3,
  567. TXT_NONE, // NAME: Text name of this unit type.
  568. "ANT3", // NAME: Text name of this unit type.
  569. ANIM_ANT_DEATH, // EXPLOSION: Type of explosion when destroyed.
  570. REMAP_NORMAL, // Sidebar remap logic.
  571. 0x0000, // Vertical offset.
  572. 0x0000, // Primary weapon offset along turret centerline.
  573. 0x0000, // Primary weapon lateral offset along turret centerline.
  574. 0x0000, // Secondary weapon offset along turret centerline.
  575. 0x0000, // Secondary weapon lateral offset along turret centerling.
  576. false, // Can this be a goodie surprise from a crate?
  577. true, // Always use the given name for the vehicle?
  578. false, // Can this unit squash infantry?
  579. false, // Does this unit harvest Tiberium?
  580. false, // Is invisible to radar?
  581. true, // Is it insignificant (won't be announced)?
  582. false, // Is it equipped with a combat turret?
  583. false, // Does it have a rotating radar dish?
  584. false, // Is there an associated firing animation?
  585. false, // Must the turret be in a locked down position while moving?
  586. true, // Is this a gigundo-rotund-enormous unit?
  587. false, // Does the unit have a constant animation?
  588. false, // Is the unit capable of jamming radar?
  589. false, // Is the unit a mobile gap generator?
  590. 8, // Rotation stages.
  591. 0, // Turret center offset along body centerline.
  592. MISSION_HUNT // ORDERS: Default order to give new unit.
  593. );
  594. #endif
  595. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  596. // Chrono Tank
  597. static UnitTypeClass const UnitChrono(
  598. UNIT_CHRONOTANK,
  599. TXT_CHRONOTANK, // NAME: Text name of this unit type.
  600. "CTNK", // NAME: Text name of this unit type.
  601. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  602. REMAP_NORMAL, // Sidebar remap logic.
  603. 0x0000, // Vertical offset.
  604. 0x0000, // Primary weapon offset along turret centerline.
  605. 0x0000, // Primary weapon lateral offset along turret centerline.
  606. 0x0000, // Secondary weapon offset along turret centerline.
  607. 0x0000, // Secondary weapon lateral offset along turret centerling.
  608. false, // Can this be a goodie surprise from a crate?
  609. false, // Always use the given name for the vehicle?
  610. true, // Can this unit squash infantry?
  611. false, // Does this unit harvest Tiberium?
  612. false, // Is invisible to radar?
  613. false, // Is it insignificant (won't be announced)?
  614. false, // Is it equipped with a combat turret?
  615. false, // Does it have a rotating radar dish?
  616. false, // Is there an associated firing animation?
  617. false, // Must the turret be in a locked down position while moving?
  618. true, // Is this a gigundo-rotund-enormous unit?
  619. false, // Does the unit have a constant animation?
  620. false, // Is the unit capable of jamming radar?
  621. false, // Is the unit a mobile gap generator?
  622. 32, // Rotation stages.
  623. 0, // Turret center offset along body centerline.
  624. MISSION_HUNT // ORDERS: Default order to give new unit.
  625. );
  626. // Tesla Tank
  627. static UnitTypeClass const UnitTesla(
  628. UNIT_TESLATANK,
  629. TXT_TESLATANK, // NAME: Text name of this unit type.
  630. "TTNK", // NAME: Text name of this unit type.
  631. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  632. REMAP_NORMAL, // Sidebar remap logic.
  633. 0x0000, // Vertical offset.
  634. 0x0000, // Primary weapon offset along turret centerline.
  635. 0x0000, // Primary weapon lateral offset along turret centerline.
  636. 0x0000, // Secondary weapon offset along turret centerline.
  637. 0x0000, // Secondary weapon lateral offset along turret centerling.
  638. false, // Can this be a goodie surprise from a crate?
  639. false, // Always use the given name for the vehicle?
  640. true, // Can this unit squash infantry?
  641. false, // Does this unit harvest Tiberium?
  642. true, // Is invisible to radar?
  643. false, // Is it insignificant (won't be announced)?
  644. false, // Is it equipped with a combat turret?
  645. true, // Does it have a rotating radar dish?
  646. false, // Is there an associated firing animation?
  647. false, // Must the turret be in a locked down position while moving?
  648. true, // Is this a gigundo-rotund-enormous unit?
  649. false, // Does the unit have a constant animation?
  650. true, // Is the unit capable of jamming radar?
  651. false, // Is the unit a mobile gap generator?
  652. 32, // Rotation stages.
  653. 0, // Turret center offset along body centerline.
  654. MISSION_HUNT // ORDERS: Default order to give new unit.
  655. );
  656. // M.A.D. Tank
  657. static UnitTypeClass const UnitMAD(
  658. UNIT_MAD,
  659. TXT_MAD, // NAME: Text name of this unit type.
  660. "QTNK", // NAME: Text name of this unit type.
  661. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  662. REMAP_NORMAL, // Sidebar remap logic.
  663. 0x0000, // Vertical offset.
  664. 0x0000, // Primary weapon offset along turret centerline.
  665. 0x0000, // Primary weapon lateral offset along turret centerline.
  666. 0x0000, // Secondary weapon offset along turret centerline.
  667. 0x0000, // Secondary weapon lateral offset along turret centerling.
  668. false, // Can this be a goodie surprise from a crate?
  669. false, // Always use the given name for the vehicle?
  670. true, // Can this unit squash infantry?
  671. false, // Does this unit harvest Tiberium?
  672. false, // Is invisible to radar?
  673. false, // Is it insignificant (won't be announced)?
  674. false, // Is it equipped with a combat turret?
  675. false, // Does it have a rotating radar dish?
  676. false, // Is there an associated firing animation?
  677. false, // Must the turret be in a locked down position while moving?
  678. true, // Is this a gigundo-rotund-enormous unit?
  679. false, // Does the unit have a constant animation?
  680. false, // Is the unit capable of jamming radar?
  681. false, // Is the unit a mobile gap generator?
  682. 32, // Rotation stages.
  683. 0, // Turret center offset along body centerline.
  684. MISSION_HUNT // ORDERS: Default order to give new unit.
  685. );
  686. // Demolition Truck
  687. static UnitTypeClass const UnitDemoTruck(
  688. UNIT_DEMOTRUCK,
  689. TXT_DEMOTRUCK, // NAME: Text name of this unit type.
  690. "DTRK", // NAME: Text name of this unit type.
  691. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  692. REMAP_NORMAL, // Sidebar remap logic.
  693. 0x0000, // Vertical offset.
  694. 0x0000, // Primary weapon offset along turret centerline.
  695. 0x0000, // Primary weapon lateral offset along turret centerline.
  696. 0x0000, // Secondary weapon offset along turret centerline.
  697. 0x0000, // Secondary weapon lateral offset along turret centerling.
  698. false, // Can this be a goodie surprise from a crate?
  699. false, // Always use the given name for the vehicle?
  700. false, // Can this unit squash infantry?
  701. false, // Does this unit harvest Tiberium?
  702. false, // Is invisible to radar?
  703. false, // Is it insignificant (won't be announced)?
  704. false, // Is it equipped with a combat turret?
  705. false, // Does it have a rotating radar dish?
  706. false, // Is there an associated firing animation?
  707. false, // Must the turret be in a locked down position while moving?
  708. false, // Is this a gigundo-rotund-enormous unit?
  709. false, // Does the unit have a constant animation?
  710. false, // Is the unit capable of jamming radar?
  711. false, // Is the unit a mobile gap generator?
  712. 32, // Rotation stages.
  713. 0, // Turret center offset along body centerline.
  714. MISSION_GUARD // ORDERS: Default order to give new unit.
  715. );
  716. #ifdef FIXIT_PHASETRANSPORT // checked - ajw 9/28/98
  717. static UnitTypeClass const UnitPhase(
  718. UNIT_PHASE,
  719. TXT_PHASETRANSPORT, // NAME: Text name of this unit type.
  720. "STNK", // NAME: Text name of this unit type.
  721. ANIM_FRAG1, // EXPLOSION: Type of explosion when destroyed.
  722. REMAP_NORMAL, // Sidebar remap logic.
  723. 0x0030, // Vertical offset.
  724. 0x0030, // Primary weapon offset along turret centerline.
  725. 0x0000, // Primary weapon lateral offset along turret centerline.
  726. 0x0030, // Secondary weapon offset along turret centerline.
  727. 0x0000, // Secondary weapon lateral offset along turret centerling.
  728. false, // Can this be a goodie surprise from a crate?
  729. false, // Always use the given name for the vehicle?
  730. true, // Can this unit squash infantry?
  731. false, // Does this unit harvest Tiberium?
  732. false, // Is invisible to radar?
  733. false, // Is it insignificant (won't be announced)?
  734. true, // Is it equipped with a combat turret?
  735. false, // Does it have a rotating radar dish?
  736. false, // Is there an associated firing animation?
  737. false, // Must the turret be in a locked down position while moving?
  738. true,// false, // Is this a gigundo-rotund-enormous unit?
  739. false, // Does the unit have a constant animation?
  740. false, // Is the unit capable of jamming radar?
  741. false, // Is the unit a mobile gap generator?
  742. 32, // Rotation stages.
  743. 0, // Turret center offset along body centerline.
  744. MISSION_HUNT // ORDERS: Default order to give new unit.
  745. );
  746. #endif
  747. #endif
  748. /***********************************************************************************************
  749. * UnitTypeClass::UnitTypeClass -- Constructor for unit types. *
  750. * *
  751. * This is the constructor for the unit types. It is used to initialize the unit type class *
  752. * structure. The unit type class is used to control the behavior of the various types *
  753. * of units in the game. This constructor is called for every unique unit type as it *
  754. * exists in the array of unit types. *
  755. * *
  756. * INPUT: bla bla bla... see below *
  757. * *
  758. * OUTPUT: none *
  759. * *
  760. * WARNINGS: none *
  761. * *
  762. * HISTORY: *
  763. * 06/20/1994 JLB : Created. *
  764. *=============================================================================================*/
  765. UnitTypeClass::UnitTypeClass(
  766. UnitType type,
  767. int name,
  768. char const * ininame,
  769. AnimType exp,
  770. RemapType remap,
  771. int verticaloffset,
  772. int primaryoffset,
  773. int primarylateral,
  774. int secondaryoffset,
  775. int secondarylateral,
  776. bool is_goodie,
  777. bool is_nominal,
  778. bool is_crusher,
  779. bool is_harvest,
  780. bool is_stealthy,
  781. bool is_insignificant,
  782. bool is_turret_equipped,
  783. bool is_radar_equipped,
  784. bool is_fire_anim,
  785. bool is_lock_turret,
  786. bool is_gigundo,
  787. bool is_animating,
  788. bool is_jammer,
  789. bool is_gapper,
  790. int rotation,
  791. int toffset,
  792. MissionType order) :
  793. TechnoTypeClass(RTTI_UNITTYPE,
  794. int(type),
  795. name,
  796. ininame,
  797. remap,
  798. verticaloffset,
  799. primaryoffset,
  800. primarylateral,
  801. secondaryoffset,
  802. secondarylateral,
  803. is_nominal,
  804. is_stealthy,
  805. true,
  806. true,
  807. is_insignificant,
  808. false,
  809. false,
  810. is_turret_equipped,
  811. true,
  812. true,
  813. rotation,
  814. SPEED_TRACK),
  815. IsCrateGoodie(is_goodie),
  816. IsCrusher(is_crusher),
  817. IsToHarvest(is_harvest),
  818. IsRadarEquipped(is_radar_equipped),
  819. IsFireAnim(is_fire_anim),
  820. IsLockTurret(is_lock_turret),
  821. IsGigundo(is_gigundo),
  822. IsAnimating(is_animating),
  823. IsJammer(is_jammer),
  824. IsGapper(is_gapper),
  825. IsNoFireWhileMoving(false),
  826. Type(type),
  827. TurretOffset(toffset),
  828. Mission(order),
  829. Explosion(exp),
  830. MaxSize(0)
  831. {
  832. /*
  833. ** Forced unit overrides form the default.
  834. */
  835. Speed = SPEED_WHEEL;
  836. }
  837. /***********************************************************************************************
  838. * UnitTypeClass::operator new -- Allocates an object from the unit type class heap. *
  839. * *
  840. * Use this routine to allocate a unit type class object from the special heap that is *
  841. * maintained for this purpose. *
  842. * *
  843. * INPUT: none *
  844. * *
  845. * OUTPUT: Returns with a pointer to the newly allocated unit type class object. If there is *
  846. * no more room to allocate another unit type class object, then NULL will be *
  847. * returned. *
  848. * *
  849. * WARNINGS: none *
  850. * *
  851. * HISTORY: *
  852. * 07/09/1996 JLB : Created. *
  853. *=============================================================================================*/
  854. void * UnitTypeClass::operator new(size_t)
  855. {
  856. return(UnitTypes.Alloc());
  857. }
  858. /***********************************************************************************************
  859. * UnitTypeClass::operator delete -- Return a unit type class object back to the pool. *
  860. * *
  861. * This will return a previously allocated unit to the memory pool from whence it came. *
  862. * *
  863. * INPUT: pointer -- A Pointer to the unit type class object to return to the memory pool. *
  864. * *
  865. * OUTPUT: none *
  866. * *
  867. * WARNINGS: none *
  868. * *
  869. * HISTORY: *
  870. * 07/09/1996 JLB : Created. *
  871. *=============================================================================================*/
  872. void UnitTypeClass::operator delete(void * pointer)
  873. {
  874. UnitTypes.Free((UnitTypeClass *)pointer);
  875. }
  876. /***********************************************************************************************
  877. * UnitTypeClass::Init_Heap -- Initialize the unit type class heap. *
  878. * *
  879. * This initializes the unit type class heap by pre-allocated all the known unit types. *
  880. * *
  881. * INPUT: none *
  882. * *
  883. * OUTPUT: none *
  884. * *
  885. * WARNINGS: Only call this once and call it before processing the rules.ini file. *
  886. * *
  887. * HISTORY: *
  888. * 07/09/1996 JLB : Created. *
  889. *=============================================================================================*/
  890. void UnitTypeClass::Init_Heap(void)
  891. {
  892. /*
  893. ** These unit type class objects must be allocated in the exact order that they
  894. ** are specified in the UnitType enumeration. This is necessary because the heap
  895. ** allocation block index serves double duty as the type number index.
  896. */
  897. new UnitTypeClass(UnitHTank); // UNIT_HTANK
  898. new UnitTypeClass(UnitMTank); // UNIT_MTANK
  899. new UnitTypeClass(UnitMTank2); // UNIT_MTANK2
  900. new UnitTypeClass(UnitLTank); // UNIT_LTANK
  901. new UnitTypeClass(UnitAPC); // UNIT_APC
  902. new UnitTypeClass(UnitMineLayer); // UNIT_MINELAYER
  903. new UnitTypeClass(UnitJeep); // UNIT_JEEP
  904. new UnitTypeClass(UnitHarvester); // UNIT_HARVESTER
  905. new UnitTypeClass(UnitArty); // UNIT_ARTY
  906. new UnitTypeClass(UnitMRJammer); // UNIT_MRJ
  907. new UnitTypeClass(UnitMGG); // UNIT_MGG
  908. new UnitTypeClass(UnitMCV); // UNIT_MCV
  909. new UnitTypeClass(UnitV2Launcher); // UNIT_V2_LAUNCHER
  910. new UnitTypeClass(UnitConvoyTruck); // UNIT_TRUCK
  911. #ifdef FIXIT_ANTS
  912. new UnitTypeClass(UnitAnt1); // UNIT_ANT1
  913. new UnitTypeClass(UnitAnt2); // UNIT_ANT2
  914. new UnitTypeClass(UnitAnt3); // UNIT_ANT3
  915. #endif
  916. #ifdef FIXIT_CSII // checked - ajw 9/28/98
  917. new UnitTypeClass(UnitChrono); // UNIT_CHRONOTANK
  918. new UnitTypeClass(UnitTesla); // UNIT_TESLATANK
  919. new UnitTypeClass(UnitMAD); // UNIT_MAD
  920. new UnitTypeClass(UnitDemoTruck); // UNIT_DEMOTRUCK
  921. #ifdef FIXIT_PHASETRANSPORT // checked - ajw 9/28/98
  922. new UnitTypeClass(UnitPhase); // UNIT_PHASETRANSPORT
  923. #endif
  924. #endif
  925. }
  926. /***********************************************************************************************
  927. * UnitTypeClass::From_Name -- Fetch class pointer from specified name. *
  928. * *
  929. * This routine converts an ASCII representation of a unit class and *
  930. * converts it into a real unit class number. *
  931. * *
  932. * INPUT: name -- ASCII name representing a unit class. *
  933. * *
  934. * OUTPUT: Returns with the actual unit class number that the string *
  935. * represents. *
  936. * *
  937. * WARNINGS: none *
  938. * *
  939. * HISTORY: *
  940. * 10/07/1992 JLB : Created. *
  941. * 05/02/1994 JLB : Converted to member function. *
  942. *=============================================================================================*/
  943. UnitType UnitTypeClass::From_Name(char const * name)
  944. {
  945. if (name != NULL) {
  946. for (UnitType classid = UNIT_FIRST; classid < UNIT_COUNT; classid++) {
  947. if (stricmp(As_Reference(classid).IniName, name) == 0) {
  948. return(classid);
  949. }
  950. }
  951. }
  952. return(UNIT_NONE);
  953. }
  954. #ifdef SCENARIO_EDITOR
  955. /***********************************************************************************************
  956. * UnitTypeClass::Display -- Displays a generic unit shape. *
  957. * *
  958. * This routine displays a generic representation of a unit of this *
  959. * type. Typically, it is used when adding objects to the game map. *
  960. * *
  961. * INPUT: x,y -- Coordinate to render the unit shape. *
  962. * *
  963. * window-- Window to render within. *
  964. * *
  965. * house -- House to render the unit colors. *
  966. * *
  967. * OUTPUT: none *
  968. * *
  969. * WARNINGS: none *
  970. * *
  971. * HISTORY: *
  972. * 05/14/1994 JLB : Created. *
  973. * 11/08/1994 JLB : Handles chunky type vehicles now. *
  974. *=============================================================================================*/
  975. void UnitTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const
  976. {
  977. int shape = 0;
  978. void const * ptr = Get_Cameo_Data();
  979. if (ptr == NULL) {
  980. ptr = Get_Image_Data();
  981. shape = Rotation/6;
  982. }
  983. CC_Draw_Shape(ptr, shape, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL);
  984. }
  985. /***********************************************************************************************
  986. * UnitTypeClass::Prep_For_Add -- Prepares scenario editor to add unit. *
  987. * *
  988. * This routine is used to prepare the generic object adder dialog *
  989. * box so that it will be able to add a unit object. *
  990. * *
  991. * INPUT: none *
  992. * *
  993. * OUTPUT: none *
  994. * *
  995. * WARNINGS: none *
  996. * *
  997. * HISTORY: *
  998. * 05/23/1994 JLB : Created. *
  999. * 06/04/1994 JLB : Uses map editing interface functions. *
  1000. *=============================================================================================*/
  1001. void UnitTypeClass::Prep_For_Add(void)
  1002. {
  1003. for (UnitType index = UNIT_FIRST; index < UNIT_COUNT; index++) {
  1004. if (As_Reference(index).Get_Image_Data() != NULL) {
  1005. Map.Add_To_List(&As_Reference(index));
  1006. }
  1007. }
  1008. }
  1009. #endif
  1010. /***********************************************************************************************
  1011. * UnitTypeClass::One_Time -- Performs one time processing for unit type class objects. *
  1012. * *
  1013. * This routine is used to perform the action necessary only once for the unit type class. *
  1014. * It loads unit shapes and brain files. This routine should only be called once. *
  1015. * *
  1016. * INPUT: none *
  1017. * *
  1018. * OUTPUT: none *
  1019. * *
  1020. * WARNINGS: Only call this routine once. *
  1021. * *
  1022. * HISTORY: *
  1023. * 05/28/1994 JLB : Created. *
  1024. *=============================================================================================*/
  1025. void UnitTypeClass::One_Time(void)
  1026. {
  1027. for (UnitType index = UNIT_FIRST; index < UNIT_COUNT; index++) {
  1028. char fullname[_MAX_FNAME+_MAX_EXT];
  1029. char buffer[_MAX_FNAME];
  1030. UnitTypeClass const & uclass = As_Reference(index);
  1031. CCFileClass file;
  1032. void const * ptr; // Shape pointer and set pointer.
  1033. int largest = 0;
  1034. // if (uclass.Level != -1) {
  1035. // if (uclass.IsBuildable) {
  1036. /*
  1037. ** Fetch the supporting data files for the unit.
  1038. */
  1039. sprintf(buffer, "%sICON", uclass.Graphic_Name());
  1040. _makepath(fullname, NULL, NULL, buffer, ".SHP");
  1041. #ifndef NDEBUG
  1042. RawFileClass datafile(fullname);
  1043. if (datafile.Is_Available()) {
  1044. ((void const *&)uclass.CameoData) = Load_Alloc_Data(datafile);
  1045. } else {
  1046. ((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
  1047. }
  1048. #else
  1049. ((void const *&)uclass.CameoData) = MFCD::Retrieve(fullname);
  1050. #endif
  1051. // }
  1052. /*
  1053. ** Fetch a pointer to the unit's shape data.
  1054. */
  1055. _makepath(fullname, NULL, NULL, uclass.Graphic_Name(), ".SHP");
  1056. #ifndef NDEBUG
  1057. RawFileClass shpfile(fullname);
  1058. if (shpfile.Is_Available()) {
  1059. ptr = Load_Alloc_Data(shpfile);
  1060. } else {
  1061. ptr = MFCD::Retrieve(fullname);
  1062. }
  1063. #else
  1064. ptr = MFCD::Retrieve(fullname);
  1065. #endif
  1066. ((void const *&)uclass.ImageData) = ptr;
  1067. if (ptr != NULL) {
  1068. largest = max(largest, (int)Get_Build_Frame_Width(ptr));
  1069. largest = max(largest, (int)Get_Build_Frame_Height(ptr));
  1070. }
  1071. ((int &)uclass.MaxSize) = max(largest, 8);
  1072. }
  1073. /*
  1074. ** Load any custom shapes at this time.
  1075. */
  1076. if (WakeShapes == NULL) {
  1077. WakeShapes = MFCD::Retrieve("WAKE.SHP");
  1078. }
  1079. if (TurretShapes == NULL) {
  1080. TurretShapes = MFCD::Retrieve("TURR.SHP");
  1081. }
  1082. if (SamShapes == NULL) {
  1083. SamShapes = MFCD::Retrieve("SSAM.SHP");
  1084. }
  1085. if (MGunShapes == NULL) {
  1086. MGunShapes = MFCD::Retrieve("MGUN.SHP");
  1087. }
  1088. }
  1089. /***********************************************************************************************
  1090. * UnitTypeClass::Create_And_Place -- Creates and places a unit object onto the map. *
  1091. * *
  1092. * This routine is used by the scenario editor to create and place a unit object of this *
  1093. * type onto the map. *
  1094. * *
  1095. * INPUT: cell -- The cell that the unit is to be placed into. *
  1096. * *
  1097. * house -- The house that the unit belongs to. *
  1098. * *
  1099. * OUTPUT: bool; Was the unit created and placed successfully? *
  1100. * *
  1101. * WARNINGS: none *
  1102. * *
  1103. * HISTORY: *
  1104. * 05/28/1994 JLB : Created. *
  1105. *=============================================================================================*/
  1106. bool UnitTypeClass::Create_And_Place(CELL cell, HousesType house) const
  1107. {
  1108. UnitClass * unit = new UnitClass(Type, house);
  1109. if (unit != NULL) {
  1110. return(unit->Unlimbo(Cell_Coord(cell), Random_Pick(DIR_N, DIR_MAX)));
  1111. }
  1112. return(false);
  1113. }
  1114. /***********************************************************************************************
  1115. * UnitTypeClass::Create_One_Of -- Creates a unit in limbo. *
  1116. * *
  1117. * This function creates a unit of this type and keeps it in limbo. A pointer to the *
  1118. * created unit object is returned. It is presumed that this object will later be *
  1119. * unlimboed at the correct time and place. *
  1120. * *
  1121. * INPUT: house -- Pointer to the house that is to own the unit. *
  1122. * *
  1123. * OUTPUT: Returns with a pointer to the created unit object. If the unit object *
  1124. * could not be created, then NULL is returned. *
  1125. * *
  1126. * WARNINGS: none *
  1127. * *
  1128. * HISTORY: *
  1129. * 06/07/1994 JLB : Created. *
  1130. *=============================================================================================*/
  1131. ObjectClass * UnitTypeClass::Create_One_Of(HouseClass * house) const
  1132. {
  1133. return(new UnitClass(Type, house->Class->House));
  1134. }
  1135. /***********************************************************************************************
  1136. * UnitTypeClass::As_Reference -- Fetches a reference to the unit type class specified. *
  1137. * *
  1138. * Use this routine to return a reference to the UnitTypeClass object as indicated by *
  1139. * the unit type number specified. *
  1140. * *
  1141. * INPUT: type -- The unit type number to convert into a UnitTypeClass object reference. *
  1142. * *
  1143. * OUTPUT: Returns with a reference to the unit type class object specified. *
  1144. * *
  1145. * WARNINGS: none *
  1146. * *
  1147. * HISTORY: *
  1148. * 01/23/1995 JLB : Created. *
  1149. *=============================================================================================*/
  1150. UnitTypeClass & UnitTypeClass::As_Reference(UnitType type)
  1151. {
  1152. return(*UnitTypes.Ptr(type));
  1153. }
  1154. /***********************************************************************************************
  1155. * UnitTypeClass::Dimensions -- Determines the unit's pixel dimensions. *
  1156. * *
  1157. * This routine will fill in the width and height for this unit type. This width and *
  1158. * height are used to render the selection rectangle and the positioning of the health *
  1159. * bargraph. *
  1160. * *
  1161. * INPUT: width -- Reference to the width of the unit (to be filled in). *
  1162. * *
  1163. * height -- Reference to the height of the unit (to be filled in). *
  1164. * *
  1165. * OUTPUT: none *
  1166. * *
  1167. * WARNINGS: none *
  1168. * *
  1169. * HISTORY: *
  1170. * 01/23/1995 JLB : Created. *
  1171. *=============================================================================================*/
  1172. void UnitTypeClass::Dimensions(int &width, int &height) const
  1173. {
  1174. width = MaxSize-(MaxSize/4);
  1175. width = min(width, 48);
  1176. height = MaxSize-(MaxSize/4);
  1177. height = min(height, 48);
  1178. }
  1179. /***********************************************************************************************
  1180. * UnitTypeClass::Max_Pips -- Fetches the maximum pips allowed for this unit. *
  1181. * *
  1182. * This routine will determine the number of pips (maximum) allowed for this unit type. *
  1183. * Typically, this is the number of passengers allowed, but for harvesters, it is the *
  1184. * number of credits it holds divided by 100. *
  1185. * *
  1186. * INPUT: none *
  1187. * *
  1188. * OUTPUT: Returns with the maximum number of pips allowed for this unit type. *
  1189. * *
  1190. * WARNINGS: none *
  1191. * *
  1192. * HISTORY: *
  1193. * 06/26/1995 JLB : Created. *
  1194. *=============================================================================================*/
  1195. int UnitTypeClass::Max_Pips(void) const
  1196. {
  1197. if (Type == UNIT_HARVESTER) {
  1198. return(7);
  1199. }
  1200. if (Type == UNIT_MINELAYER) {
  1201. return(MaxAmmo);
  1202. }
  1203. return(Max_Passengers());
  1204. }
  1205. /***********************************************************************************************
  1206. * UnitTypeClass::Turret_Adjust -- Turret adjustment routine for MLRS and MSAM units. *
  1207. * *
  1208. * This routine adjusts the pixel coordinates specified to account for the displacement of *
  1209. * the turret on the MLRS and MSAM vehicles. *
  1210. * *
  1211. * INPUT: dir -- The direction of the body of the vehicle. *
  1212. * *
  1213. * x,y -- References to the turret center pixel position. These will be modified as *
  1214. * necessary. *
  1215. * *
  1216. * OUTPUT: none *
  1217. * *
  1218. * WARNINGS: none *
  1219. * *
  1220. * HISTORY: *
  1221. * 05/08/1995 JLB : Created. *
  1222. *=============================================================================================*/
  1223. void UnitTypeClass::Turret_Adjust(DirType dir, int &x, int &y) const
  1224. {
  1225. static struct {
  1226. signed char X,Y;
  1227. } _adjust[32] = {
  1228. {1,2}, // N
  1229. {-1,1},
  1230. {-2,0},
  1231. {-3,0},
  1232. {-3,1}, // NW
  1233. {-4,-1},
  1234. {-4,-1},
  1235. {-5,-2},
  1236. {-5,-3}, // W
  1237. {-5,-3},
  1238. {-3,-3},
  1239. {-3,-4},
  1240. {-3,-4}, // SW
  1241. {-3,-5},
  1242. {-2,-5},
  1243. {-1,-5},
  1244. {0,-5}, // S
  1245. {1,-6},
  1246. {2,-5},
  1247. {3,-5},
  1248. {4,-5}, // SE
  1249. {6,-4},
  1250. {6,-3},
  1251. {6,-3},
  1252. {6,-3}, // E
  1253. {5,-1},
  1254. {5,-1},
  1255. {4,0},
  1256. {3,0}, // NE
  1257. {2,0},
  1258. {2,1},
  1259. {1,2}
  1260. };
  1261. int index = 0;
  1262. switch (Type) {
  1263. case UNIT_JEEP:
  1264. y -= 4;
  1265. break;
  1266. case UNIT_MGG:
  1267. index = Dir_To_32(dir);
  1268. x += _adjust[index].X;
  1269. y += _adjust[index].Y;
  1270. break;
  1271. default:
  1272. break;
  1273. }
  1274. }
  1275. /***********************************************************************************************
  1276. * UnitTypeClass::Read_INI -- Fetch the unit type data from the INI database. *
  1277. * *
  1278. * This routine will find the section in the INI database for this unit type object and *
  1279. * then fill in the override values specified. *
  1280. * *
  1281. * INPUT: ini -- Reference to the INI database that will be examined. *
  1282. * *
  1283. * OUTPUT: bool; Was the section for this unit found in the database and the data extracted? *
  1284. * *
  1285. * WARNINGS: none *
  1286. * *
  1287. * HISTORY: *
  1288. * 07/19/1996 JLB : Created. *
  1289. *=============================================================================================*/
  1290. bool UnitTypeClass::Read_INI(CCINIClass & ini)
  1291. {
  1292. if (TechnoTypeClass::Read_INI(ini)) {
  1293. IsNoFireWhileMoving = ini.Get_Bool(IniName, "NoMovingFire", IsNoFireWhileMoving);
  1294. Speed = ini.Get_Bool(IniName, "Tracked", (Speed == SPEED_TRACK)) ? SPEED_TRACK : SPEED_WHEEL;
  1295. /*
  1296. ** If this unit can drive over walls, then mark it as recognizing the crusher zone.
  1297. */
  1298. if (MZone < MZONE_CRUSHER && IsCrusher) {
  1299. MZone = MZONE_CRUSHER;
  1300. }
  1301. return(true);
  1302. }
  1303. return(false);
  1304. }