SB_BAR.C 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457
  1. // SB_bar.c
  2. #include "DoomDef.h"
  3. #include "P_local.h"
  4. #include "soundst.h"
  5. // Macros
  6. #define CHEAT_ENCRYPT(a) \
  7. ((((a)&1)<<5)+ \
  8. (((a)&2)<<1)+ \
  9. (((a)&4)<<4)+ \
  10. (((a)&8)>>3)+ \
  11. (((a)&16)>>3)+ \
  12. (((a)&32)<<2)+ \
  13. (((a)&64)>>2)+ \
  14. (((a)&128)>>4))
  15. // Types
  16. typedef struct Cheat_s
  17. {
  18. void (*func)(player_t *player, struct Cheat_s *cheat);
  19. byte *sequence;
  20. byte *pos;
  21. int args[2];
  22. int currentArg;
  23. } Cheat_t;
  24. // Private Functions
  25. static void DrawSoundInfo(void);
  26. static void ShadeLine(int x, int y, int height, int shade);
  27. static void ShadeChain(void);
  28. static void DrINumber(signed int val, int x, int y);
  29. static void DrBNumber(signed int val, int x, int y);
  30. static void DrawCommonBar(void);
  31. static void DrawMainBar(void);
  32. static void DrawInventoryBar(void);
  33. static void DrawFullScreenStuff(void);
  34. static boolean HandleCheats(byte key);
  35. static boolean CheatAddKey(Cheat_t *cheat, byte key, boolean *eat);
  36. static void CheatGodFunc(player_t *player, Cheat_t *cheat);
  37. static void CheatNoClipFunc(player_t *player, Cheat_t *cheat);
  38. static void CheatWeaponsFunc(player_t *player, Cheat_t *cheat);
  39. static void CheatPowerFunc(player_t *player, Cheat_t *cheat);
  40. static void CheatHealthFunc(player_t *player, Cheat_t *cheat);
  41. static void CheatKeysFunc(player_t *player, Cheat_t *cheat);
  42. static void CheatSoundFunc(player_t *player, Cheat_t *cheat);
  43. static void CheatTickerFunc(player_t *player, Cheat_t *cheat);
  44. static void CheatArtifact1Func(player_t *player, Cheat_t *cheat);
  45. static void CheatArtifact2Func(player_t *player, Cheat_t *cheat);
  46. static void CheatArtifact3Func(player_t *player, Cheat_t *cheat);
  47. static void CheatWarpFunc(player_t *player, Cheat_t *cheat);
  48. static void CheatChickenFunc(player_t *player, Cheat_t *cheat);
  49. static void CheatMassacreFunc(player_t *player, Cheat_t *cheat);
  50. static void CheatIDKFAFunc(player_t *player, Cheat_t *cheat);
  51. static void CheatIDDQDFunc(player_t *player, Cheat_t *cheat);
  52. // Public Data
  53. boolean DebugSound; // debug flag for displaying sound info
  54. boolean inventory;
  55. int curpos;
  56. int inv_ptr;
  57. int ArtifactFlash;
  58. // Private Data
  59. static int HealthMarker;
  60. static int ChainWiggle;
  61. static player_t *CPlayer;
  62. int playpalette;
  63. patch_t *PatchLTFACE;
  64. patch_t *PatchRTFACE;
  65. patch_t *PatchBARBACK;
  66. patch_t *PatchCHAIN;
  67. patch_t *PatchSTATBAR;
  68. patch_t *PatchLIFEGEM;
  69. //patch_t *PatchEMPWEAP;
  70. //patch_t *PatchLIL4BOX;
  71. patch_t *PatchLTFCTOP;
  72. patch_t *PatchRTFCTOP;
  73. //patch_t *PatchARMORBOX;
  74. //patch_t *PatchARTIBOX;
  75. patch_t *PatchSELECTBOX;
  76. //patch_t *PatchKILLSPIC;
  77. //patch_t *PatchMANAPIC;
  78. //patch_t *PatchPOWERICN;
  79. patch_t *PatchINVLFGEM1;
  80. patch_t *PatchINVLFGEM2;
  81. patch_t *PatchINVRTGEM1;
  82. patch_t *PatchINVRTGEM2;
  83. patch_t *PatchINumbers[10];
  84. patch_t *PatchNEGATIVE;
  85. patch_t *PatchSmNumbers[10];
  86. patch_t *PatchBLACKSQ;
  87. patch_t *PatchINVBAR;
  88. patch_t *PatchARMCLEAR;
  89. patch_t *PatchCHAINBACK;
  90. //byte *ShadeTables;
  91. extern byte *screen;
  92. int FontBNumBase;
  93. int spinbooklump;
  94. int spinflylump;
  95. static byte CheatLookup[256];
  96. // Toggle god mode
  97. static byte CheatGodSeq[] =
  98. {
  99. CHEAT_ENCRYPT('q'),
  100. CHEAT_ENCRYPT('u'),
  101. CHEAT_ENCRYPT('i'),
  102. CHEAT_ENCRYPT('c'),
  103. CHEAT_ENCRYPT('k'),
  104. CHEAT_ENCRYPT('e'),
  105. CHEAT_ENCRYPT('n'),
  106. 0xff
  107. };
  108. // Toggle no clipping mode
  109. static byte CheatNoClipSeq[] =
  110. {
  111. CHEAT_ENCRYPT('k'),
  112. CHEAT_ENCRYPT('i'),
  113. CHEAT_ENCRYPT('t'),
  114. CHEAT_ENCRYPT('t'),
  115. CHEAT_ENCRYPT('y'),
  116. 0xff
  117. };
  118. // Get all weapons and ammo
  119. static byte CheatWeaponsSeq[] =
  120. {
  121. CHEAT_ENCRYPT('r'),
  122. CHEAT_ENCRYPT('a'),
  123. CHEAT_ENCRYPT('m'),
  124. CHEAT_ENCRYPT('b'),
  125. CHEAT_ENCRYPT('o'),
  126. 0xff
  127. };
  128. // Toggle tome of power
  129. static byte CheatPowerSeq[] =
  130. {
  131. CHEAT_ENCRYPT('s'),
  132. CHEAT_ENCRYPT('h'),
  133. CHEAT_ENCRYPT('a'),
  134. CHEAT_ENCRYPT('z'),
  135. CHEAT_ENCRYPT('a'),
  136. CHEAT_ENCRYPT('m'),
  137. 0xff, 0
  138. };
  139. // Get full health
  140. static byte CheatHealthSeq[] =
  141. {
  142. CHEAT_ENCRYPT('p'),
  143. CHEAT_ENCRYPT('o'),
  144. CHEAT_ENCRYPT('n'),
  145. CHEAT_ENCRYPT('c'),
  146. CHEAT_ENCRYPT('e'),
  147. 0xff
  148. };
  149. // Get all keys
  150. static byte CheatKeysSeq[] =
  151. {
  152. CHEAT_ENCRYPT('s'),
  153. CHEAT_ENCRYPT('k'),
  154. CHEAT_ENCRYPT('e'),
  155. CHEAT_ENCRYPT('l'),
  156. 0xff, 0
  157. };
  158. // Toggle sound debug info
  159. static byte CheatSoundSeq[] =
  160. {
  161. CHEAT_ENCRYPT('n'),
  162. CHEAT_ENCRYPT('o'),
  163. CHEAT_ENCRYPT('i'),
  164. CHEAT_ENCRYPT('s'),
  165. CHEAT_ENCRYPT('e'),
  166. 0xff
  167. };
  168. // Toggle ticker
  169. static byte CheatTickerSeq[] =
  170. {
  171. CHEAT_ENCRYPT('t'),
  172. CHEAT_ENCRYPT('i'),
  173. CHEAT_ENCRYPT('c'),
  174. CHEAT_ENCRYPT('k'),
  175. CHEAT_ENCRYPT('e'),
  176. CHEAT_ENCRYPT('r'),
  177. 0xff, 0
  178. };
  179. // Get an artifact 1st stage (ask for type)
  180. static byte CheatArtifact1Seq[] =
  181. {
  182. CHEAT_ENCRYPT('g'),
  183. CHEAT_ENCRYPT('i'),
  184. CHEAT_ENCRYPT('m'),
  185. CHEAT_ENCRYPT('m'),
  186. CHEAT_ENCRYPT('e'),
  187. 0xff
  188. };
  189. // Get an artifact 2nd stage (ask for count)
  190. static byte CheatArtifact2Seq[] =
  191. {
  192. CHEAT_ENCRYPT('g'),
  193. CHEAT_ENCRYPT('i'),
  194. CHEAT_ENCRYPT('m'),
  195. CHEAT_ENCRYPT('m'),
  196. CHEAT_ENCRYPT('e'),
  197. 0, 0xff, 0
  198. };
  199. // Get an artifact final stage
  200. static byte CheatArtifact3Seq[] =
  201. {
  202. CHEAT_ENCRYPT('g'),
  203. CHEAT_ENCRYPT('i'),
  204. CHEAT_ENCRYPT('m'),
  205. CHEAT_ENCRYPT('m'),
  206. CHEAT_ENCRYPT('e'),
  207. 0, 0, 0xff
  208. };
  209. // Warp to new level
  210. static byte CheatWarpSeq[] =
  211. {
  212. CHEAT_ENCRYPT('e'),
  213. CHEAT_ENCRYPT('n'),
  214. CHEAT_ENCRYPT('g'),
  215. CHEAT_ENCRYPT('a'),
  216. CHEAT_ENCRYPT('g'),
  217. CHEAT_ENCRYPT('e'),
  218. 0, 0, 0xff, 0
  219. };
  220. // Save a screenshot
  221. static byte CheatChickenSeq[] =
  222. {
  223. CHEAT_ENCRYPT('c'),
  224. CHEAT_ENCRYPT('o'),
  225. CHEAT_ENCRYPT('c'),
  226. CHEAT_ENCRYPT('k'),
  227. CHEAT_ENCRYPT('a'),
  228. CHEAT_ENCRYPT('d'),
  229. CHEAT_ENCRYPT('o'),
  230. CHEAT_ENCRYPT('o'),
  231. CHEAT_ENCRYPT('d'),
  232. CHEAT_ENCRYPT('l'),
  233. CHEAT_ENCRYPT('e'),
  234. CHEAT_ENCRYPT('d'),
  235. CHEAT_ENCRYPT('o'),
  236. CHEAT_ENCRYPT('o'),
  237. 0xff, 0
  238. };
  239. // Kill all monsters
  240. static byte CheatMassacreSeq[] =
  241. {
  242. CHEAT_ENCRYPT('m'),
  243. CHEAT_ENCRYPT('a'),
  244. CHEAT_ENCRYPT('s'),
  245. CHEAT_ENCRYPT('s'),
  246. CHEAT_ENCRYPT('a'),
  247. CHEAT_ENCRYPT('c'),
  248. CHEAT_ENCRYPT('r'),
  249. CHEAT_ENCRYPT('e'),
  250. 0xff, 0
  251. };
  252. static byte CheatIDKFASeq[] =
  253. {
  254. CHEAT_ENCRYPT('i'),
  255. CHEAT_ENCRYPT('d'),
  256. CHEAT_ENCRYPT('k'),
  257. CHEAT_ENCRYPT('f'),
  258. CHEAT_ENCRYPT('a'),
  259. 0xff, 0
  260. };
  261. static byte CheatIDDQDSeq[] =
  262. {
  263. CHEAT_ENCRYPT('i'),
  264. CHEAT_ENCRYPT('d'),
  265. CHEAT_ENCRYPT('d'),
  266. CHEAT_ENCRYPT('q'),
  267. CHEAT_ENCRYPT('d'),
  268. 0xff, 0
  269. };
  270. static Cheat_t Cheats[] =
  271. {
  272. { CheatGodFunc, CheatGodSeq, NULL, 0, 0, 0 },
  273. { CheatNoClipFunc, CheatNoClipSeq, NULL, 0, 0, 0 },
  274. { CheatWeaponsFunc, CheatWeaponsSeq, NULL, 0, 0, 0 },
  275. { CheatPowerFunc, CheatPowerSeq, NULL, 0, 0, 0 },
  276. { CheatHealthFunc, CheatHealthSeq, NULL, 0, 0, 0 },
  277. { CheatKeysFunc, CheatKeysSeq, NULL, 0, 0, 0 },
  278. { CheatSoundFunc, CheatSoundSeq, NULL, 0, 0, 0 },
  279. { CheatTickerFunc, CheatTickerSeq, NULL, 0, 0, 0 },
  280. { CheatArtifact1Func, CheatArtifact1Seq, NULL, 0, 0, 0 },
  281. { CheatArtifact2Func, CheatArtifact2Seq, NULL, 0, 0, 0 },
  282. { CheatArtifact3Func, CheatArtifact3Seq, NULL, 0, 0, 0 },
  283. { CheatWarpFunc, CheatWarpSeq, NULL, 0, 0, 0 },
  284. { CheatChickenFunc, CheatChickenSeq, NULL, 0, 0, 0 },
  285. { CheatMassacreFunc, CheatMassacreSeq, NULL, 0, 0, 0 },
  286. { CheatIDKFAFunc, CheatIDKFASeq, NULL, 0, 0, 0 },
  287. { CheatIDDQDFunc, CheatIDDQDSeq, NULL, 0, 0, 0 },
  288. { NULL, NULL, NULL, 0, 0, 0 } // Terminator
  289. };
  290. //---------------------------------------------------------------------------
  291. //
  292. // PROC SB_Init
  293. //
  294. //---------------------------------------------------------------------------
  295. void SB_Init(void)
  296. {
  297. int i;
  298. int startLump;
  299. PatchLTFACE = W_CacheLumpName("LTFACE", PU_STATIC);
  300. PatchRTFACE = W_CacheLumpName("RTFACE", PU_STATIC);
  301. PatchBARBACK = W_CacheLumpName("BARBACK", PU_STATIC);
  302. PatchINVBAR = W_CacheLumpName("INVBAR", PU_STATIC);
  303. PatchCHAIN = W_CacheLumpName("CHAIN", PU_STATIC);
  304. if(deathmatch)
  305. {
  306. PatchSTATBAR = W_CacheLumpName("STATBAR", PU_STATIC);
  307. }
  308. else
  309. {
  310. PatchSTATBAR = W_CacheLumpName("LIFEBAR", PU_STATIC);
  311. }
  312. if(!netgame)
  313. { // single player game uses red life gem
  314. PatchLIFEGEM = W_CacheLumpName("LIFEGEM2", PU_STATIC);
  315. }
  316. else
  317. {
  318. PatchLIFEGEM = W_CacheLumpNum(W_GetNumForName("LIFEGEM0")
  319. + consoleplayer, PU_STATIC);
  320. }
  321. PatchLTFCTOP = W_CacheLumpName("LTFCTOP", PU_STATIC);
  322. PatchRTFCTOP = W_CacheLumpName("RTFCTOP", PU_STATIC);
  323. PatchSELECTBOX = W_CacheLumpName("SELECTBOX", PU_STATIC);
  324. PatchINVLFGEM1 = W_CacheLumpName("INVGEML1", PU_STATIC);
  325. PatchINVLFGEM2 = W_CacheLumpName("INVGEML2", PU_STATIC);
  326. PatchINVRTGEM1 = W_CacheLumpName("INVGEMR1", PU_STATIC);
  327. PatchINVRTGEM2 = W_CacheLumpName("INVGEMR2", PU_STATIC);
  328. PatchBLACKSQ = W_CacheLumpName("BLACKSQ", PU_STATIC);
  329. PatchARMCLEAR = W_CacheLumpName("ARMCLEAR", PU_STATIC);
  330. PatchCHAINBACK = W_CacheLumpName("CHAINBACK", PU_STATIC);
  331. startLump = W_GetNumForName("IN0");
  332. for(i = 0; i < 10; i++)
  333. {
  334. PatchINumbers[i] = W_CacheLumpNum(startLump+i, PU_STATIC);
  335. }
  336. PatchNEGATIVE = W_CacheLumpName("NEGNUM", PU_STATIC);
  337. FontBNumBase = W_GetNumForName("FONTB16");
  338. startLump = W_GetNumForName("SMALLIN0");
  339. for(i = 0; i < 10; i++)
  340. {
  341. PatchSmNumbers[i] = W_CacheLumpNum(startLump+i, PU_STATIC);
  342. }
  343. playpalette = W_GetNumForName("PLAYPAL");
  344. spinbooklump = W_GetNumForName("SPINBK0");
  345. spinflylump = W_GetNumForName("SPFLY0");
  346. for(i = 0; i < 256; i++)
  347. {
  348. CheatLookup[i] = CHEAT_ENCRYPT(i);
  349. }
  350. }
  351. //---------------------------------------------------------------------------
  352. //
  353. // PROC SB_Ticker
  354. //
  355. //---------------------------------------------------------------------------
  356. void SB_Ticker(void)
  357. {
  358. int delta;
  359. int curHealth;
  360. if(leveltime&1)
  361. {
  362. ChainWiggle = P_Random()&1;
  363. }
  364. curHealth = players[consoleplayer].mo->health;
  365. if(curHealth < 0)
  366. {
  367. curHealth = 0;
  368. }
  369. if(curHealth < HealthMarker)
  370. {
  371. delta = (HealthMarker-curHealth)>>2;
  372. if(delta < 1)
  373. {
  374. delta = 1;
  375. }
  376. else if(delta > 8)
  377. {
  378. delta = 8;
  379. }
  380. HealthMarker -= delta;
  381. }
  382. else if(curHealth > HealthMarker)
  383. {
  384. delta = (curHealth-HealthMarker)>>2;
  385. if(delta < 1)
  386. {
  387. delta = 1;
  388. }
  389. else if(delta > 8)
  390. {
  391. delta = 8;
  392. }
  393. HealthMarker += delta;
  394. }
  395. }
  396. //---------------------------------------------------------------------------
  397. //
  398. // PROC DrINumber
  399. //
  400. // Draws a three digit number.
  401. //
  402. //---------------------------------------------------------------------------
  403. static void DrINumber(signed int val, int x, int y)
  404. {
  405. patch_t *patch;
  406. int oldval;
  407. oldval = val;
  408. if(val < 0)
  409. {
  410. if(val < -9)
  411. {
  412. V_DrawPatch(x+1, y+1, W_CacheLumpName("LAME", PU_CACHE));
  413. }
  414. else
  415. {
  416. val = -val;
  417. V_DrawPatch(x+18, y, PatchINumbers[val]);
  418. V_DrawPatch(x+9, y, PatchNEGATIVE);
  419. }
  420. return;
  421. }
  422. if(val > 99)
  423. {
  424. patch = PatchINumbers[val/100];
  425. V_DrawPatch(x, y, patch);
  426. }
  427. val = val%100;
  428. if(val > 9 || oldval > 99)
  429. {
  430. patch = PatchINumbers[val/10];
  431. V_DrawPatch(x+9, y, patch);
  432. }
  433. val = val%10;
  434. patch = PatchINumbers[val];
  435. V_DrawPatch(x+18, y, patch);
  436. }
  437. //---------------------------------------------------------------------------
  438. //
  439. // PROC DrBNumber
  440. //
  441. // Draws a three digit number using FontB
  442. //
  443. //---------------------------------------------------------------------------
  444. static void DrBNumber(signed int val, int x, int y)
  445. {
  446. patch_t *patch;
  447. int xpos;
  448. int oldval;
  449. oldval = val;
  450. xpos = x;
  451. if(val < 0)
  452. {
  453. val = 0;
  454. }
  455. if(val > 99)
  456. {
  457. patch = W_CacheLumpNum(FontBNumBase+val/100, PU_CACHE);
  458. V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);
  459. }
  460. val = val%100;
  461. xpos += 12;
  462. if(val > 9 || oldval > 99)
  463. {
  464. patch = W_CacheLumpNum(FontBNumBase+val/10, PU_CACHE);
  465. V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);
  466. }
  467. val = val%10;
  468. xpos += 12;
  469. patch = W_CacheLumpNum(FontBNumBase+val, PU_CACHE);
  470. V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch);
  471. }
  472. //---------------------------------------------------------------------------
  473. //
  474. // PROC DrSmallNumber
  475. //
  476. // Draws a small two digit number.
  477. //
  478. //---------------------------------------------------------------------------
  479. static void DrSmallNumber(int val, int x, int y)
  480. {
  481. patch_t *patch;
  482. if(val == 1)
  483. {
  484. return;
  485. }
  486. if(val > 9)
  487. {
  488. patch = PatchSmNumbers[val/10];
  489. V_DrawPatch(x, y, patch);
  490. }
  491. val = val%10;
  492. patch = PatchSmNumbers[val];
  493. V_DrawPatch(x+4, y, patch);
  494. }
  495. //---------------------------------------------------------------------------
  496. //
  497. // PROC ShadeLine
  498. //
  499. //---------------------------------------------------------------------------
  500. static void ShadeLine(int x, int y, int height, int shade)
  501. {
  502. byte *dest;
  503. byte *shades;
  504. shades = colormaps+9*256+shade*2*256;
  505. dest = screen+y*SCREENWIDTH+x;
  506. while(height--)
  507. {
  508. *(dest) = *(shades+*dest);
  509. dest += SCREENWIDTH;
  510. }
  511. }
  512. //---------------------------------------------------------------------------
  513. //
  514. // PROC ShadeChain
  515. //
  516. //---------------------------------------------------------------------------
  517. static void ShadeChain(void)
  518. {
  519. int i;
  520. for(i = 0; i < 16; i++)
  521. {
  522. ShadeLine(277+i, 190, 10, i/2);
  523. ShadeLine(19+i, 190, 10, 7-(i/2));
  524. }
  525. }
  526. //---------------------------------------------------------------------------
  527. //
  528. // PROC DrawSoundInfo
  529. //
  530. // Displays sound debugging information.
  531. //
  532. //---------------------------------------------------------------------------
  533. static void DrawSoundInfo(void)
  534. {
  535. int i;
  536. SoundInfo_t s;
  537. ChanInfo_t *c;
  538. char text[32];
  539. int x;
  540. int y;
  541. int xPos[7] = {1, 75, 112, 156, 200, 230, 260};
  542. if(leveltime&16)
  543. {
  544. MN_DrTextA("*** SOUND DEBUG INFO ***", xPos[0], 20);
  545. }
  546. S_GetChannelInfo(&s);
  547. if(s.channelCount == 0)
  548. {
  549. return;
  550. }
  551. x = 0;
  552. MN_DrTextA("NAME", xPos[x++], 30);
  553. MN_DrTextA("MO.T", xPos[x++], 30);
  554. MN_DrTextA("MO.X", xPos[x++], 30);
  555. MN_DrTextA("MO.Y", xPos[x++], 30);
  556. MN_DrTextA("ID", xPos[x++], 30);
  557. MN_DrTextA("PRI", xPos[x++], 30);
  558. MN_DrTextA("DIST", xPos[x++], 30);
  559. for(i = 0; i < s.channelCount; i++)
  560. {
  561. c = &s.chan[i];
  562. x = 0;
  563. y = 40+i*10;
  564. if(c->mo == NULL)
  565. { // Channel is unused
  566. MN_DrTextA("------", xPos[0], y);
  567. continue;
  568. }
  569. sprintf(text, "%s", c->name);
  570. M_ForceUppercase(text);
  571. MN_DrTextA(text, xPos[x++], y);
  572. sprintf(text, "%d", c->mo->type);
  573. MN_DrTextA(text, xPos[x++], y);
  574. sprintf(text, "%d", c->mo->x>>FRACBITS);
  575. MN_DrTextA(text, xPos[x++], y);
  576. sprintf(text, "%d", c->mo->y>>FRACBITS);
  577. MN_DrTextA(text, xPos[x++], y);
  578. sprintf(text, "%d", c->id);
  579. MN_DrTextA(text, xPos[x++], y);
  580. sprintf(text, "%d", c->priority);
  581. MN_DrTextA(text, xPos[x++], y);
  582. sprintf(text, "%d", c->distance);
  583. MN_DrTextA(text, xPos[x++], y);
  584. }
  585. UpdateState |= I_FULLSCRN;
  586. BorderNeedRefresh = true;
  587. }
  588. //---------------------------------------------------------------------------
  589. //
  590. // PROC SB_Drawer
  591. //
  592. //---------------------------------------------------------------------------
  593. char patcharti[][10] =
  594. {
  595. {"ARTIBOX"}, // none
  596. {"ARTIINVU"}, // invulnerability
  597. {"ARTIINVS"}, // invisibility
  598. {"ARTIPTN2"}, // health
  599. {"ARTISPHL"}, // superhealth
  600. {"ARTIPWBK"}, // tomeofpower
  601. {"ARTITRCH"}, // torch
  602. {"ARTIFBMB"}, // firebomb
  603. {"ARTIEGGC"}, // egg
  604. {"ARTISOAR"}, // fly
  605. {"ARTIATLP"} // teleport
  606. };
  607. char ammopic[][10] =
  608. {
  609. {"INAMGLD"},
  610. {"INAMBOW"},
  611. {"INAMBST"},
  612. {"INAMRAM"},
  613. {"INAMPNX"},
  614. {"INAMLOB"}
  615. };
  616. int SB_state = -1;
  617. static int oldarti = 0;
  618. static int oldartiCount = 0;
  619. static int oldfrags = -9999;
  620. static int oldammo = -1;
  621. static int oldarmor = -1;
  622. static int oldweapon = -1;
  623. static int oldhealth = -1;
  624. static int oldlife = -1;
  625. static int oldkeys = -1;
  626. int playerkeys = 0;
  627. extern boolean automapactive;
  628. void SB_Drawer(void)
  629. {
  630. int frame;
  631. static boolean hitCenterFrame;
  632. // Sound info debug stuff
  633. if(DebugSound == true)
  634. {
  635. DrawSoundInfo();
  636. }
  637. CPlayer = &players[consoleplayer];
  638. if(viewheight == SCREENHEIGHT && !automapactive)
  639. {
  640. DrawFullScreenStuff();
  641. SB_state = -1;
  642. }
  643. else
  644. {
  645. if(SB_state == -1)
  646. {
  647. V_DrawPatch(0, 158, PatchBARBACK);
  648. if(players[consoleplayer].cheats&CF_GODMODE)
  649. {
  650. V_DrawPatch(16, 167, W_CacheLumpName("GOD1", PU_CACHE));
  651. V_DrawPatch(287, 167, W_CacheLumpName("GOD2", PU_CACHE));
  652. }
  653. oldhealth = -1;
  654. }
  655. DrawCommonBar();
  656. if(!inventory)
  657. {
  658. if(SB_state != 0)
  659. {
  660. // Main interface
  661. V_DrawPatch(34, 160, PatchSTATBAR);
  662. oldarti = 0;
  663. oldammo = -1;
  664. oldarmor = -1;
  665. oldweapon = -1;
  666. oldfrags = -9999; //can't use -1, 'cuz of negative frags
  667. oldlife = -1;
  668. oldkeys = -1;
  669. }
  670. DrawMainBar();
  671. SB_state = 0;
  672. }
  673. else
  674. {
  675. if(SB_state != 1)
  676. {
  677. V_DrawPatch(34, 160, PatchINVBAR);
  678. }
  679. DrawInventoryBar();
  680. SB_state = 1;
  681. }
  682. }
  683. SB_PaletteFlash();
  684. // Flight icons
  685. if(CPlayer->powers[pw_flight])
  686. {
  687. if(CPlayer->powers[pw_flight] > BLINKTHRESHOLD
  688. || !(CPlayer->powers[pw_flight]&16))
  689. {
  690. frame = (leveltime/3)&15;
  691. if(CPlayer->mo->flags2&MF2_FLY)
  692. {
  693. if(hitCenterFrame && (frame != 15 && frame != 0))
  694. {
  695. V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+15,
  696. PU_CACHE));
  697. }
  698. else
  699. {
  700. V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+frame,
  701. PU_CACHE));
  702. hitCenterFrame = false;
  703. }
  704. }
  705. else
  706. {
  707. if(!hitCenterFrame && (frame != 15 && frame != 0))
  708. {
  709. V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+frame,
  710. PU_CACHE));
  711. hitCenterFrame = false;
  712. }
  713. else
  714. {
  715. V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+15,
  716. PU_CACHE));
  717. hitCenterFrame = true;
  718. }
  719. }
  720. BorderTopRefresh = true;
  721. UpdateState |= I_MESSAGES;
  722. }
  723. else
  724. {
  725. BorderTopRefresh = true;
  726. UpdateState |= I_MESSAGES;
  727. }
  728. }
  729. if(CPlayer->powers[pw_weaponlevel2] && !CPlayer->chickenTics)
  730. {
  731. if(CPlayer->powers[pw_weaponlevel2] > BLINKTHRESHOLD
  732. || !(CPlayer->powers[pw_weaponlevel2]&16))
  733. {
  734. frame = (leveltime/3)&15;
  735. V_DrawPatch(300, 17, W_CacheLumpNum(spinbooklump+frame, PU_CACHE));
  736. BorderTopRefresh = true;
  737. UpdateState |= I_MESSAGES;
  738. }
  739. else
  740. {
  741. BorderTopRefresh = true;
  742. UpdateState |= I_MESSAGES;
  743. }
  744. }
  745. /*
  746. if(CPlayer->powers[pw_weaponlevel2] > BLINKTHRESHOLD
  747. || (CPlayer->powers[pw_weaponlevel2]&8))
  748. {
  749. V_DrawPatch(291, 0, W_CacheLumpName("ARTIPWBK", PU_CACHE));
  750. }
  751. else
  752. {
  753. BorderTopRefresh = true;
  754. }
  755. }
  756. */
  757. }
  758. // sets the new palette based upon current values of player->damagecount
  759. // and player->bonuscount
  760. void SB_PaletteFlash(void)
  761. {
  762. static int sb_palette = 0;
  763. int palette;
  764. byte *pal;
  765. CPlayer = &players[consoleplayer];
  766. if(CPlayer->damagecount)
  767. {
  768. palette = (CPlayer->damagecount+7)>>3;
  769. if(palette >= NUMREDPALS)
  770. {
  771. palette = NUMREDPALS-1;
  772. }
  773. palette += STARTREDPALS;
  774. }
  775. else if(CPlayer->bonuscount)
  776. {
  777. palette = (CPlayer->bonuscount+7)>>3;
  778. if(palette >= NUMBONUSPALS)
  779. {
  780. palette = NUMBONUSPALS-1;
  781. }
  782. palette += STARTBONUSPALS;
  783. }
  784. else
  785. {
  786. palette = 0;
  787. }
  788. if(palette != sb_palette)
  789. {
  790. sb_palette = palette;
  791. pal = (byte *)W_CacheLumpNum(playpalette, PU_CACHE)+palette*768;
  792. I_SetPalette(pal);
  793. }
  794. }
  795. //---------------------------------------------------------------------------
  796. //
  797. // PROC DrawCommonBar
  798. //
  799. //---------------------------------------------------------------------------
  800. void DrawCommonBar(void)
  801. {
  802. int chainY;
  803. int healthPos;
  804. V_DrawPatch(0, 148, PatchLTFCTOP);
  805. V_DrawPatch(290, 148, PatchRTFCTOP);
  806. if(oldhealth != HealthMarker)
  807. {
  808. oldhealth = HealthMarker;
  809. healthPos = HealthMarker;
  810. if(healthPos < 0)
  811. {
  812. healthPos = 0;
  813. }
  814. if(healthPos > 100)
  815. {
  816. healthPos = 100;
  817. }
  818. healthPos = (healthPos*256)/100;
  819. chainY = (HealthMarker == CPlayer->mo->health) ? 191 : 191+ChainWiggle;
  820. V_DrawPatch(0, 190, PatchCHAINBACK);
  821. V_DrawPatch(2+(healthPos%17), chainY, PatchCHAIN);
  822. V_DrawPatch(17+healthPos, chainY, PatchLIFEGEM);
  823. V_DrawPatch(0, 190, PatchLTFACE);
  824. V_DrawPatch(276, 190, PatchRTFACE);
  825. ShadeChain();
  826. UpdateState |= I_STATBAR;
  827. }
  828. }
  829. //---------------------------------------------------------------------------
  830. //
  831. // PROC DrawMainBar
  832. //
  833. //---------------------------------------------------------------------------
  834. void DrawMainBar(void)
  835. {
  836. int i;
  837. int temp;
  838. // Ready artifact
  839. if(ArtifactFlash)
  840. {
  841. V_DrawPatch(180, 161, PatchBLACKSQ);
  842. V_DrawPatch(182, 161, W_CacheLumpNum(W_GetNumForName("useartia")
  843. + ArtifactFlash - 1, PU_CACHE));
  844. ArtifactFlash--;
  845. oldarti = -1; // so that the correct artifact fills in after the flash
  846. UpdateState |= I_STATBAR;
  847. }
  848. else if(oldarti != CPlayer->readyArtifact
  849. || oldartiCount != CPlayer->inventory[inv_ptr].count)
  850. {
  851. V_DrawPatch(180, 161, PatchBLACKSQ);
  852. if(CPlayer->readyArtifact > 0)
  853. {
  854. V_DrawPatch(179,160, W_CacheLumpName(patcharti[CPlayer->readyArtifact],
  855. PU_CACHE));
  856. DrSmallNumber(CPlayer->inventory[inv_ptr].count, 201, 182);
  857. }
  858. oldarti = CPlayer->readyArtifact;
  859. oldartiCount = CPlayer->inventory[inv_ptr].count;
  860. UpdateState |= I_STATBAR;
  861. }
  862. // Frags
  863. if(deathmatch)
  864. {
  865. temp = 0;
  866. for(i = 0; i < MAXPLAYERS; i++)
  867. {
  868. temp += CPlayer->frags[i];
  869. }
  870. if(temp != oldfrags)
  871. {
  872. V_DrawPatch(57, 171, PatchARMCLEAR);
  873. DrINumber(temp, 61, 170);
  874. oldfrags = temp;
  875. UpdateState |= I_STATBAR;
  876. }
  877. }
  878. else
  879. {
  880. temp = HealthMarker;
  881. if(temp < 0)
  882. {
  883. temp = 0;
  884. }
  885. else if(temp > 100)
  886. {
  887. temp = 100;
  888. }
  889. if(oldlife != temp)
  890. {
  891. oldlife = temp;
  892. V_DrawPatch(57, 171, PatchARMCLEAR);
  893. DrINumber(temp, 61, 170);
  894. UpdateState |= I_STATBAR;
  895. }
  896. }
  897. // Keys
  898. if(oldkeys != playerkeys)
  899. {
  900. if(CPlayer->keys[key_yellow])
  901. {
  902. V_DrawPatch(153, 164, W_CacheLumpName("ykeyicon", PU_CACHE));
  903. }
  904. if(CPlayer->keys[key_green])
  905. {
  906. V_DrawPatch(153, 172, W_CacheLumpName("gkeyicon", PU_CACHE));
  907. }
  908. if(CPlayer->keys[key_blue])
  909. {
  910. V_DrawPatch(153, 180, W_CacheLumpName("bkeyicon", PU_CACHE));
  911. }
  912. oldkeys = playerkeys;
  913. UpdateState |= I_STATBAR;
  914. }
  915. // Ammo
  916. temp = CPlayer->ammo[wpnlev1info[CPlayer->readyweapon].ammo];
  917. if(oldammo != temp || oldweapon != CPlayer->readyweapon)
  918. {
  919. V_DrawPatch(108, 161, PatchBLACKSQ);
  920. if(temp && CPlayer->readyweapon > 0 && CPlayer->readyweapon < 7)
  921. {
  922. DrINumber(temp, 109, 162);
  923. V_DrawPatch(111, 172, W_CacheLumpName(
  924. ammopic[CPlayer->readyweapon-1], PU_CACHE));
  925. }
  926. oldammo = temp;
  927. oldweapon = CPlayer->readyweapon;
  928. UpdateState |= I_STATBAR;
  929. }
  930. // Armor
  931. if(oldarmor != CPlayer->armorpoints)
  932. {
  933. V_DrawPatch(224, 171, PatchARMCLEAR);
  934. DrINumber(CPlayer->armorpoints, 228, 170);
  935. oldarmor = CPlayer->armorpoints;
  936. UpdateState |= I_STATBAR;
  937. }
  938. }
  939. //---------------------------------------------------------------------------
  940. //
  941. // PROC DrawInventoryBar
  942. //
  943. //---------------------------------------------------------------------------
  944. void DrawInventoryBar(void)
  945. {
  946. int i;
  947. int x;
  948. x = inv_ptr-curpos;
  949. UpdateState |= I_STATBAR;
  950. V_DrawPatch(34, 160, PatchINVBAR);
  951. for(i = 0; i < 7; i++)
  952. {
  953. //V_DrawPatch(50+i*31, 160, W_CacheLumpName("ARTIBOX", PU_CACHE));
  954. if(CPlayer->inventorySlotNum > x+i
  955. && CPlayer->inventory[x+i].type != arti_none)
  956. {
  957. V_DrawPatch(50+i*31, 160, W_CacheLumpName(
  958. patcharti[CPlayer->inventory[x+i].type], PU_CACHE));
  959. DrSmallNumber(CPlayer->inventory[x+i].count, 69+i*31, 182);
  960. }
  961. }
  962. V_DrawPatch(50+curpos*31, 189, PatchSELECTBOX);
  963. if(x != 0)
  964. {
  965. V_DrawPatch(38, 159,!(leveltime&4) ? PatchINVLFGEM1 :
  966. PatchINVLFGEM2);
  967. }
  968. if(CPlayer->inventorySlotNum-x > 7)
  969. {
  970. V_DrawPatch(269, 159,!(leveltime&4) ?
  971. PatchINVRTGEM1 : PatchINVRTGEM2);
  972. }
  973. }
  974. void DrawFullScreenStuff(void)
  975. {
  976. int i;
  977. int x;
  978. int temp;
  979. UpdateState |= I_FULLSCRN;
  980. if(CPlayer->mo->health > 0)
  981. {
  982. DrBNumber(CPlayer->mo->health, 5, 180);
  983. }
  984. else
  985. {
  986. DrBNumber(0, 5, 180);
  987. }
  988. if(deathmatch)
  989. {
  990. temp = 0;
  991. for(i=0; i<MAXPLAYERS; i++)
  992. {
  993. if(playeringame[i])
  994. {
  995. temp += CPlayer->frags[i];
  996. }
  997. }
  998. DrINumber(temp, 45, 185);
  999. }
  1000. if(!inventory)
  1001. {
  1002. if(CPlayer->readyArtifact > 0)
  1003. {
  1004. V_DrawFuzzPatch(286, 170, W_CacheLumpName("ARTIBOX",
  1005. PU_CACHE));
  1006. V_DrawPatch(286, 170,
  1007. W_CacheLumpName(patcharti[CPlayer->readyArtifact], PU_CACHE));
  1008. DrSmallNumber(CPlayer->inventory[inv_ptr].count, 307, 192);
  1009. }
  1010. }
  1011. else
  1012. {
  1013. x = inv_ptr-curpos;
  1014. for(i = 0; i < 7; i++)
  1015. {
  1016. V_DrawFuzzPatch(50+i*31, 168, W_CacheLumpName("ARTIBOX",
  1017. PU_CACHE));
  1018. if(CPlayer->inventorySlotNum > x+i
  1019. && CPlayer->inventory[x+i].type != arti_none)
  1020. {
  1021. V_DrawPatch(50+i*31, 168, W_CacheLumpName(
  1022. patcharti[CPlayer->inventory[x+i].type], PU_CACHE));
  1023. DrSmallNumber(CPlayer->inventory[x+i].count, 69+i*31, 190);
  1024. }
  1025. }
  1026. V_DrawPatch(50+curpos*31, 197, PatchSELECTBOX);
  1027. if(x != 0)
  1028. {
  1029. V_DrawPatch(38, 167, !(leveltime&4) ? PatchINVLFGEM1 :
  1030. PatchINVLFGEM2);
  1031. }
  1032. if(CPlayer->inventorySlotNum-x > 7)
  1033. {
  1034. V_DrawPatch(269, 167, !(leveltime&4) ?
  1035. PatchINVRTGEM1 : PatchINVRTGEM2);
  1036. }
  1037. }
  1038. }
  1039. //--------------------------------------------------------------------------
  1040. //
  1041. // FUNC SB_Responder
  1042. //
  1043. //--------------------------------------------------------------------------
  1044. boolean SB_Responder(event_t *event)
  1045. {
  1046. if(event->type == ev_keydown)
  1047. {
  1048. if(HandleCheats(event->data1))
  1049. { // Need to eat the key
  1050. return(true);
  1051. }
  1052. }
  1053. return(false);
  1054. }
  1055. //--------------------------------------------------------------------------
  1056. //
  1057. // FUNC HandleCheats
  1058. //
  1059. // Returns true if the caller should eat the key.
  1060. //
  1061. //--------------------------------------------------------------------------
  1062. static boolean HandleCheats(byte key)
  1063. {
  1064. int i;
  1065. boolean eat;
  1066. if(netgame || gameskill == sk_nightmare)
  1067. { // Can't cheat in a net-game, or in nightmare mode
  1068. return(false);
  1069. }
  1070. if(players[consoleplayer].health <= 0)
  1071. { // Dead players can't cheat
  1072. return(false);
  1073. }
  1074. eat = false;
  1075. for(i = 0; Cheats[i].func != NULL; i++)
  1076. {
  1077. if(CheatAddKey(&Cheats[i], key, &eat))
  1078. {
  1079. Cheats[i].func(&players[consoleplayer], &Cheats[i]);
  1080. S_StartSound(NULL, sfx_dorcls);
  1081. }
  1082. }
  1083. return(eat);
  1084. }
  1085. //--------------------------------------------------------------------------
  1086. //
  1087. // FUNC CheatAddkey
  1088. //
  1089. // Returns true if the added key completed the cheat, false otherwise.
  1090. //
  1091. //--------------------------------------------------------------------------
  1092. static boolean CheatAddKey(Cheat_t *cheat, byte key, boolean *eat)
  1093. {
  1094. if(!cheat->pos)
  1095. {
  1096. cheat->pos = cheat->sequence;
  1097. cheat->currentArg = 0;
  1098. }
  1099. if(*cheat->pos == 0)
  1100. {
  1101. *eat = true;
  1102. cheat->args[cheat->currentArg++] = key;
  1103. cheat->pos++;
  1104. }
  1105. else if(CheatLookup[key] == *cheat->pos)
  1106. {
  1107. cheat->pos++;
  1108. }
  1109. else
  1110. {
  1111. cheat->pos = cheat->sequence;
  1112. cheat->currentArg = 0;
  1113. }
  1114. if(*cheat->pos == 0xff)
  1115. {
  1116. cheat->pos = cheat->sequence;
  1117. cheat->currentArg = 0;
  1118. return(true);
  1119. }
  1120. return(false);
  1121. }
  1122. //--------------------------------------------------------------------------
  1123. //
  1124. // CHEAT FUNCTIONS
  1125. //
  1126. //--------------------------------------------------------------------------
  1127. static void CheatGodFunc(player_t *player, Cheat_t *cheat)
  1128. {
  1129. player->cheats ^= CF_GODMODE;
  1130. if(player->cheats&CF_GODMODE)
  1131. {
  1132. P_SetMessage(player, TXT_CHEATGODON, false);
  1133. }
  1134. else
  1135. {
  1136. P_SetMessage(player, TXT_CHEATGODOFF, false);
  1137. }
  1138. SB_state = -1;
  1139. }
  1140. static void CheatNoClipFunc(player_t *player, Cheat_t *cheat)
  1141. {
  1142. player->cheats ^= CF_NOCLIP;
  1143. if(player->cheats&CF_NOCLIP)
  1144. {
  1145. P_SetMessage(player, TXT_CHEATNOCLIPON, false);
  1146. }
  1147. else
  1148. {
  1149. P_SetMessage(player, TXT_CHEATNOCLIPOFF, false);
  1150. }
  1151. }
  1152. static void CheatWeaponsFunc(player_t *player, Cheat_t *cheat)
  1153. {
  1154. int i;
  1155. //extern boolean *WeaponInShareware;
  1156. player->armorpoints = 200;
  1157. player->armortype = 2;
  1158. if(!player->backpack)
  1159. {
  1160. for(i = 0; i < NUMAMMO; i++)
  1161. {
  1162. player->maxammo[i] *= 2;
  1163. }
  1164. player->backpack = true;
  1165. }
  1166. for(i = 0; i < NUMWEAPONS-1; i++)
  1167. {
  1168. player->weaponowned[i] = true;
  1169. }
  1170. if(shareware)
  1171. {
  1172. player->weaponowned[wp_skullrod] = false;
  1173. player->weaponowned[wp_phoenixrod] = false;
  1174. player->weaponowned[wp_mace] = false;
  1175. }
  1176. for(i = 0; i < NUMAMMO; i++)
  1177. {
  1178. player->ammo[i] = player->maxammo[i];
  1179. }
  1180. P_SetMessage(player, TXT_CHEATWEAPONS, false);
  1181. }
  1182. static void CheatPowerFunc(player_t *player, Cheat_t *cheat)
  1183. {
  1184. if(player->powers[pw_weaponlevel2])
  1185. {
  1186. player->powers[pw_weaponlevel2] = 0;
  1187. P_SetMessage(player, TXT_CHEATPOWEROFF, false);
  1188. }
  1189. else
  1190. {
  1191. P_UseArtifact(player, arti_tomeofpower);
  1192. P_SetMessage(player, TXT_CHEATPOWERON, false);
  1193. }
  1194. }
  1195. static void CheatHealthFunc(player_t *player, Cheat_t *cheat)
  1196. {
  1197. if(player->chickenTics)
  1198. {
  1199. player->health = player->mo->health = MAXCHICKENHEALTH;
  1200. }
  1201. else
  1202. {
  1203. player->health = player->mo->health = MAXHEALTH;
  1204. }
  1205. P_SetMessage(player, TXT_CHEATHEALTH, false);
  1206. }
  1207. static void CheatKeysFunc(player_t *player, Cheat_t *cheat)
  1208. {
  1209. extern int playerkeys;
  1210. player->keys[key_yellow] = true;
  1211. player->keys[key_green] = true;
  1212. player->keys[key_blue] = true;
  1213. playerkeys = 7; // Key refresh flags
  1214. P_SetMessage(player, TXT_CHEATKEYS, false);
  1215. }
  1216. static void CheatSoundFunc(player_t *player, Cheat_t *cheat)
  1217. {
  1218. DebugSound = !DebugSound;
  1219. if(DebugSound)
  1220. {
  1221. P_SetMessage(player, TXT_CHEATSOUNDON, false);
  1222. }
  1223. else
  1224. {
  1225. P_SetMessage(player, TXT_CHEATSOUNDOFF, false);
  1226. }
  1227. }
  1228. static void CheatTickerFunc(player_t *player, Cheat_t *cheat)
  1229. {
  1230. extern int DisplayTicker;
  1231. DisplayTicker = !DisplayTicker;
  1232. if(DisplayTicker)
  1233. {
  1234. P_SetMessage(player, TXT_CHEATTICKERON, false);
  1235. }
  1236. else
  1237. {
  1238. P_SetMessage(player, TXT_CHEATTICKEROFF, false);
  1239. }
  1240. }
  1241. static void CheatArtifact1Func(player_t *player, Cheat_t *cheat)
  1242. {
  1243. P_SetMessage(player, TXT_CHEATARTIFACTS1, false);
  1244. }
  1245. static void CheatArtifact2Func(player_t *player, Cheat_t *cheat)
  1246. {
  1247. P_SetMessage(player, TXT_CHEATARTIFACTS2, false);
  1248. }
  1249. static void CheatArtifact3Func(player_t *player, Cheat_t *cheat)
  1250. {
  1251. int i;
  1252. int j;
  1253. artitype_t type;
  1254. int count;
  1255. type = cheat->args[0]-'a'+1;
  1256. count = cheat->args[1]-'0';
  1257. if(type == 26 && count == 0)
  1258. { // All artifacts
  1259. for(i = arti_none+1; i < NUMARTIFACTS; i++)
  1260. {
  1261. if(shareware && (i == arti_superhealth
  1262. || i == arti_teleport))
  1263. {
  1264. continue;
  1265. }
  1266. for(j = 0; j < 16; j++)
  1267. {
  1268. P_GiveArtifact(player, i, NULL);
  1269. }
  1270. }
  1271. P_SetMessage(player, TXT_CHEATARTIFACTS3, false);
  1272. }
  1273. else if(type > arti_none && type < NUMARTIFACTS
  1274. && count > 0 && count < 10)
  1275. {
  1276. if(shareware && (type == arti_superhealth || type == arti_teleport))
  1277. {
  1278. P_SetMessage(player, TXT_CHEATARTIFACTSFAIL, false);
  1279. return;
  1280. }
  1281. for(i = 0; i < count; i++)
  1282. {
  1283. P_GiveArtifact(player, type, NULL);
  1284. }
  1285. P_SetMessage(player, TXT_CHEATARTIFACTS3, false);
  1286. }
  1287. else
  1288. { // Bad input
  1289. P_SetMessage(player, TXT_CHEATARTIFACTSFAIL, false);
  1290. }
  1291. }
  1292. static void CheatWarpFunc(player_t *player, Cheat_t *cheat)
  1293. {
  1294. int episode;
  1295. int map;
  1296. episode = cheat->args[0]-'0';
  1297. map = cheat->args[1]-'0';
  1298. if(M_ValidEpisodeMap(episode, map))
  1299. {
  1300. G_DeferedInitNew(gameskill, episode, map);
  1301. P_SetMessage(player, TXT_CHEATWARP, false);
  1302. }
  1303. }
  1304. static void CheatChickenFunc(player_t *player, Cheat_t *cheat)
  1305. {
  1306. extern boolean P_UndoPlayerChicken(player_t *player);
  1307. if(player->chickenTics)
  1308. {
  1309. if(P_UndoPlayerChicken(player))
  1310. {
  1311. P_SetMessage(player, TXT_CHEATCHICKENOFF, false);
  1312. }
  1313. }
  1314. else if(P_ChickenMorphPlayer(player))
  1315. {
  1316. P_SetMessage(player, TXT_CHEATCHICKENON, false);
  1317. }
  1318. }
  1319. static void CheatMassacreFunc(player_t *player, Cheat_t *cheat)
  1320. {
  1321. P_Massacre();
  1322. P_SetMessage(player, TXT_CHEATMASSACRE, false);
  1323. }
  1324. static void CheatIDKFAFunc(player_t *player, Cheat_t *cheat)
  1325. {
  1326. int i;
  1327. if(player->chickenTics)
  1328. {
  1329. return;
  1330. }
  1331. for(i = 1; i < 8; i++)
  1332. {
  1333. player->weaponowned[i] = false;
  1334. }
  1335. player->pendingweapon = wp_staff;
  1336. P_SetMessage(player, TXT_CHEATIDKFA, true);
  1337. }
  1338. static void CheatIDDQDFunc(player_t *player, Cheat_t *cheat)
  1339. {
  1340. P_DamageMobj(player->mo, NULL, player->mo, 10000);
  1341. P_SetMessage(player, TXT_CHEATIDDQD, true);
  1342. }