UDATA.CPP 68 KB

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