1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id: p_chex.c 1436 2019-04-26 10:37:06Z wesleyjohnson $
5 //
6 // Copyright (C) 2003-2015 by DooM Legacy Team.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // DESCRIPTION:
19 // Chex Quest support.
20 //
21 //-----------------------------------------------------------------------------
22
23
24 #include "doomincl.h"
25 #include "g_game.h"
26 #include "p_local.h"
27 #include "r_main.h"
28 #include "r_state.h"
29 #include "s_sound.h"
30 #include "m_random.h"
31 #include "m_cheat.h"
32 #include "dstrings.h"
33 #include "w_wad.h"
34 #include "z_zone.h"
35 #include "p_chex.h"
36
37 #ifdef HWRENDER
38 #include "hardware/hw_light.h"
39 // lspr
40 #endif
41
42 extern byte cheat_mus_seq[];
43 extern byte cheat_choppers_seq[];
44 extern byte cheat_god_seq[];
45 extern byte cheat_ammo_seq[];
46 extern byte cheat_ammonokey_seq[];
47 extern byte cheat_noclip_seq[];
48 extern byte cheat_commercial_noclip_seq[];
49 extern byte cheat_powerup_seq[7][10];
50 extern byte cheat_clev_seq[];
51 extern byte cheat_mypos_seq[];
52 extern byte cheat_amap_seq[];
53
54
Chex1_PatchEngine(void)55 void Chex1_PatchEngine(void)
56 {
57
58 //patch new text
59 char* NEW_QUIT1 = "Don't give up now...do\nyou still wish to quit?";
60 char* NEW_QUIT2 = "please don't leave we\nneed your help!";
61
62 text[QUITMSG_NUM] = NEW_QUIT1;
63 text[QUITMSG1_NUM] = NEW_QUIT2;
64 text[QUITMSG2_NUM] = NEW_QUIT2;
65 text[QUITMSG3_NUM] = NEW_QUIT2;
66 text[QUITMSG4_NUM] = NEW_QUIT2;
67 text[QUITMSG5_NUM] = NEW_QUIT2;
68 text[QUITMSG6_NUM] = NEW_QUIT2;
69 text[QUITMSG7_NUM] = NEW_QUIT2;
70
71 text[QUIT2MSG_NUM] = NEW_QUIT1;
72 text[QUIT2MSG1_NUM] = NEW_QUIT2;
73 text[QUIT2MSG2_NUM] = NEW_QUIT2;
74 text[QUIT2MSG3_NUM] = NEW_QUIT2;
75 text[QUIT2MSG4_NUM] = NEW_QUIT2;
76 text[QUIT2MSG5_NUM] = NEW_QUIT2;
77 text[QUIT2MSG6_NUM] = NEW_QUIT2;
78
79 text[HUSTR_E1M1_NUM] = "E1M1: Landing Zone";
80 text[HUSTR_E1M2_NUM] = "E1M2: Storage Facility";
81 text[HUSTR_E1M3_NUM] = "E1M3: Experimental Lab";
82 text[HUSTR_E1M4_NUM] = "E1M4: Arboretum";
83 text[HUSTR_E1M5_NUM] = "E1M5: Caverns of Bazoik";
84
85 text[GOTARMBONUS_NUM] = "picked up slime repellant.";
86 text[GOTSTIM_NUM] = "picked up bowl of fruit.";
87 text[GOTHTHBONUS_NUM] = "picked up glass of water.";
88 text[GOTMEDIKIT_NUM] = "picked up bowl of vegetables.";
89 text[GOTMEDINEED_NUM] = "vegetables are REALLY good for you!";
90 text[GOTARMOR_NUM] = "Picked up the Chex(R) Armor.";
91 text[GOTMEGA_NUM] = "Picked up the Super Chex(R) Armor!";
92 text[GOTSUPER_NUM] = "Supercharge Breakfast!";
93 text[GOTSUIT_NUM] = "Slimeproof Suit";
94 text[GOTBERSERK_NUM] = "SPOOOON!!!!";
95 text[GOTINVIS_NUM] = "Semi-invisibility suit.";
96 text[GOTVISOR_NUM] = "Light amplification goggles";
97
98 text[GOTBLUECARD_NUM] = "picked up a blue key.";
99 text[GOTYELWCARD_NUM] = "picked up a yellow key.";
100 text[GOTREDCARD_NUM] = "picked up a red key.";
101
102 text[GOTCLIP_NUM] = "picked up mini zorch recharge.";
103 text[GOTCLIPBOX_NUM] = "Picked up a mini zorch pack.";
104 text[GOTROCKET_NUM] = "Picked up a Propulsor recharge.";
105 text[GOTROCKBOX_NUM] = "Picked up a 5 pack of propulsor zorch.";
106 text[GOTCELL_NUM] = "Picked up a Phasing zorcher recharge.";
107 text[GOTCELLBOX_NUM] = "Picked up a phasing zorcher pack.";
108 text[GOTSHELLS_NUM] = "Picked up 4 large zorcher recharges.";
109 text[GOTSHELLBOX_NUM] = "Picked up a large zorcher pack (20)";
110 text[GOTBACKPACK_NUM] = "Picked up a zorchpack.";
111 text[GOTBFG9000_NUM] = "Oh, yes.You got the LAZ device!";
112 text[GOTCHAINGUN_NUM] = "You got a rapid zorcher!";
113 text[GOTCHAINSAW_NUM] = "You got the super bootspork!";
114 text[GOTLAUNCHER_NUM] = "You got the zorch propulsor!";
115 text[GOTPLASMA_NUM] = "You got the phasing zorcher!";
116 text[GOTSHOTGUN_NUM] = "You got the large zorcher!";
117
118 text[STSTR_DQDON_NUM] = "Invincible mode on.";
119 text[STSTR_DQDOFF_NUM] = "Invincible mode off.";
120 text[STSTR_FAADDED_NUM] = "Zorch Added.";
121 text[STSTR_KFAADDED_NUM] = "Zorch and keys added.";
122 text[STSTR_CHOPPERS_NUM] = "Eat Chex!";
123
124 text[E1TEXT_NUM] = "mission accomplished.\n\nare you prepared for the next mission?\n\n\n\n\n\n\npress the escape key to continue...\n";
125 text[NIGHTMARE_NUM] = "careful. this will be tough.\ndo you wish to continue?\n\npress y or n.";
126
127 text[DEATHMSG_SUICIDE] = "%s needs to be more careful\n";
128 text[DEATHMSG_TELEFRAG] = "%s was standing in the wrong spot\n";
129 text[DEATHMSG_FIST] = "%s ate from the spoon of %s\n";
130 text[DEATHMSG_GUN] = "%s was zorched by %s\n";
131 text[DEATHMSG_SHOTGUN] = "%s took a large zorch from %s\n";
132 text[DEATHMSG_MACHGUN] = "%s was rapidly zorched by %s\n";
133 text[DEATHMSG_ROCKET] = "%s almost dodged %'s propulsor\n";
134 text[DEATHMSG_GIBROCKET] = "%s was hit by %'s propulsor\n";
135 text[DEATHMSG_PLASMA] = "%s was phased by %s\n";
136 text[DEATHMSG_BFGBALL] = "%s couldn't escape %'s LAZ either\n";
137 text[DEATHMSG_CHAINSAW] = "%s was fed from %'s bootspork\n";
138 text[DEATHMSG_PLAYUNKNOW] = "%s was zorched by %s\n";
139 text[DEATHMSG_HELLSLIME] = "%s can't swim in slime\n";
140 text[DEATHMSG_NUKE] = "%s can't swim in slime\n";
141 text[DEATHMSG_SUPHELLSLIME] = "%s can't swim in slime\n";
142 text[DEATHMSG_SPECUNKNOW] = "%s needs to be more careful\n";
143 text[DEATHMSG_BARRELFRAG] = "%s was zorched by %s\n";
144 text[DEATHMSG_BARREL] = "%s needs to be more careful\n";
145 text[DEATHMSG_POSSESSED] = "A felmoid slimed %s\n";
146 text[DEATHMSG_SHOTGUY] = "%s was slimed by a bipedicus\n";
147 text[DEATHMSG_TROOP] = "%s was slimed by an armored bipedicus\n";
148 text[DEATHMSG_SERGEANT] = "%s was slimed by a cycloptis\n";
149 text[DEATHMSG_BRUISER] = "%s fell victim to the flembrane\n";
150 text[DEATHMSG_DEAD] = "%s was slimed\n";
151
152
153 //patch monster changes
154 mobjinfo[MT_POSSESSED].missilestate = 0;
155 mobjinfo[MT_POSSESSED].meleestate = S_POSS_ATK1;
156
157 mobjinfo[MT_SHOTGUY].missilestate = 0;
158 mobjinfo[MT_SHOTGUY].meleestate = S_SPOS_ATK1;
159
160 mobjinfo[MT_BRUISER].speed = 0;
161 mobjinfo[MT_BRUISER].radius = 48*FRACUNIT; //let's try 48
162
163 //coronas
164 // Alter Doom sprite light tables.
165 // sprite_light[1].dynamic_color = 0xff000050;
166 sprite_light[1].dynamic_color.rgba = RGBA(0x50,0x0,0x0,0xff);
167 // sprite_light[2].dynamic_color = 0xff000050;
168 sprite_light[2].dynamic_color.rgba = RGBA(0x50,0x0,0x0,0xff);
169 // sprite_light[3].dynamic_color = 0xff4040f7;
170 sprite_light[3].dynamic_color.rgba = RGBA(0xf7,0x40,0x40,0xff);
171 // sprite_light[4].dynamic_color = 0xff4040f7;
172 sprite_light[4].dynamic_color.rgba = RGBA(0xf7,0x40,0x40,0xff);
173 // sprite_light[5].dynamic_color = 0xff4040f7;
174 sprite_light[5].dynamic_color.rgba = RGBA(0xf7,0x40,0x40,0xff);
175 // sprite_light[6].dynamic_color = 0xff4040a0;
176 sprite_light[6].dynamic_color.rgba = RGBA(0xa0,0x40,0x40,0xff);
177 sprite_light[7].splgt_flags = 0;
178 sprite_light[8].splgt_flags = 0;
179 sprite_light[9].splgt_flags = 0;
180 sprite_light[10].splgt_flags = 0;
181 sprite_light[11].splgt_flags = 0;
182 sprite_light[12].splgt_flags = 0;
183 sprite_light[15].light_yoffset = 3.0f; //light
184 sprite_light[16].splgt_flags = 0;
185 sprite_light[17].splgt_flags = 0;
186
187 #ifdef HWRENDER
188 // These changes were executed after HWR_StartupEngine(), so reinit.
189 HWR_Init_Light();
190 #endif
191
192 //cheat codes
193
194 }
195
196 typedef struct {
197 char * orig_name;
198 char * replace_name;
199 uint64_t checksum;
200 } chex_picture_replace_t;
201
202 #define NUM_CHEX_REPLACEMENTS 6
203 static chex_picture_replace_t chex_repl[ NUM_CHEX_REPLACEMENTS ] =
204 {
205 {"PFUB1", "CREDIT", 0x00B251DC }, // bunny
206 {"PFUB2", "CREDIT", 0x007B517E }, // bunny
207 {"VICTORY2", "CREDIT", 0x002F5EE5 }, // spikes
208 {"ENDPIC", "TITLEPIC", 0x006BFE6B }, // bloody marine
209 {"INTERPIC", "M_DOOM", 0x004C2CBE }, // wall
210 {"M_EPI1", NULL, 0x000A5FF0 }, // wall
211 };
212
213
214 // Detect Doom graphics and prevent their display while chexquest mode.
Chex_safe_pictures(const char * name,void * lumpptr)215 void* Chex_safe_pictures( const char* name, void* lumpptr )
216 {
217 int i;
218
219 if( lumpptr == NULL )
220 {
221 lumpptr = W_CachePatchName ( name, PU_CACHE);
222 if( lumpptr == NULL ) goto done;
223 }
224
225 for( i=0; i<NUM_CHEX_REPLACEMENTS; i++ )
226 {
227 if( strncmp( name, chex_repl[i].orig_name, 8 ) == 0 )
228 {
229 // found a matching entry name
230 uint64_t c_checksum = W_lump_checksum( lumpptr );
231 // [WDJ] Uncomment the next line to get the checksums of pictures.
232 // debug_Printf( "Chex_safe_pictures: %8.8s checksum=%16lX\n", name, (long)c_checksum);
233 if( chex_repl[i].checksum == c_checksum )
234 {
235 // it is the original, replace it
236 char * replname = chex_repl[i].replace_name;
237 if( replname )
238 {
239 lumpptr = W_CachePatchName ( replname, PU_LEVEL );
240 }
241 else
242 {
243 lumpptr = NULL; // return NULL to indicate detection
244 }
245 }
246 goto done;
247 }
248 }
249 // not found, do nothing
250 done: // other returns
251 return lumpptr;
252 }
253
254