2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
24 //#define DOOR_DEBUGGING
54 #include "editor/editor.h"
57 //#define TEST_TIMER 1 //if this is set, do checking on timer
59 #define SHOW_EXIT_PATH 1
65 #if __WATCOMC__ < 1000
66 #include <wsample.h> //should come after inferno.h to get mark setting
71 extern void full_palette_save(void);
72 extern void object_goto_prev_viewer(void);
74 // Global Variables -----------------------------------------------------------
76 int redbook_volume = 255;
79 // External Variables ---------------------------------------------------------
81 extern int Speedtest_on; // Speedtest global adapted from game.c
82 extern char WaitForRefuseAnswer,RefuseThisPlayer,RefuseTeam;
85 extern int Mark_count;
86 extern int Speedtest_start_time;
87 extern int Speedtest_segnum;
88 extern int Speedtest_sidenum;
89 extern int Speedtest_frame_start;
90 extern int Speedtest_count;
93 extern int Global_missile_firing_count;
94 extern int Automap_flag;
95 extern int Config_menu_flag;
96 extern int EscortHotKeys;
99 extern int Game_aborted;
100 extern int *Toggle_var;
102 extern int Physics_cheat_flag;
104 extern int last_drawn_cockpit[2];
106 extern int Debug_spew;
107 extern int Debug_pause;
108 extern cvar_t r_framerate;
110 extern fix Show_view_text_timer;
112 extern ubyte DefiningMarkerMessage;
114 // Function prototypes --------------------------------------------------------
117 extern void CyclePrimary(void);
118 extern void CycleSecondary(void);
119 extern void InitMarkerInput(void);
120 extern void MarkerInputMessage (int);
121 extern int allowed_to_fire_missile(void);
122 extern int allowed_to_fire_flare(void);
123 extern void check_rear_view(void);
124 extern int create_special_path(void);
125 extern void move_player_2_segment(segment *seg, int side);
126 extern void kconfig_center_headset(void);
127 extern void game_render_frame_mono(void);
128 extern void newdemo_strip_frames(char *, int);
129 extern void toggle_cockpit(void);
130 extern int dump_used_textures_all(void);
131 extern void DropMarker(void);
132 extern void DropSecondaryWeapon(void);
133 extern void DropCurrentWeapon(void);
135 void FinalCheats(int key);
138 void do_cheat_menu(void);
141 void HandleGameKey(int key);
142 int HandleSystemKey(int key);
143 void HandleTestKey(int key);
144 void HandleVRKey(int key);
146 void speedtest_init(void);
147 void speedtest_frame(void);
148 void advance_sound(void);
149 void play_test_sound(void);
151 #define key_isfunc(k) (((k&0xff)>=KEY_F1 && (k&0xff)<=KEY_F10) || (k&0xff)==KEY_F11 || (k&0xff)==KEY_F12)
152 #define key_ismod(k) ((k&0xff)==KEY_LALT || (k&0xff)==KEY_RALT || (k&0xff)==KEY_LSHIFT || (k&0xff)==KEY_RSHIFT || (k&0xff)==KEY_LCTRL || (k&0xff)==KEY_RCTRL)
154 // Functions ------------------------------------------------------------------
156 #define CONVERTER_RATE 20 //10 units per second xfer rate
157 #define CONVERTER_SCALE 2 //2 units energy -> 1 unit shields
159 #define CONVERTER_SOUND_DELAY (f1_0/2) //play every half second
161 void transfer_energy_to_shield(fix time)
163 fix e; //how much energy gets transfered
164 static fix last_play_time=0;
166 e = min(min(time*CONVERTER_RATE,Players[Player_num].energy - INITIAL_ENERGY),(MAX_SHIELDS-Players[Player_num].shields)*CONVERTER_SCALE);
170 if (Players[Player_num].energy <= INITIAL_ENERGY)
171 HUD_init_message("Need more than %i energy to enable transfer", f2i(INITIAL_ENERGY));
173 HUD_init_message("No transfer: Shields already at max");
177 Players[Player_num].energy -= e;
178 Players[Player_num].shields += e/CONVERTER_SCALE;
180 if (last_play_time > GameTime)
183 if (GameTime > last_play_time+CONVERTER_SOUND_DELAY) {
184 digi_play_sample_once(SOUND_CONVERT_ENERGY, F1_0);
185 last_play_time = GameTime;
190 void update_vcr_state(void);
191 void do_weapon_stuff(void);
196 fix newdemo_single_frame_time;
198 void update_vcr_state(void)
200 if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_RIGHT])
201 Newdemo_vcr_state = ND_STATE_FASTFORWARD;
202 else if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_LEFT])
203 Newdemo_vcr_state = ND_STATE_REWINDING;
204 else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_RIGHT] && ((timer_get_fixed_seconds() - newdemo_single_frame_time) >= F1_0))
205 Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
206 else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_LEFT] && ((timer_get_fixed_seconds() - newdemo_single_frame_time) >= F1_0))
207 Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
208 else if ((Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_REWINDING))
209 Newdemo_vcr_state = ND_STATE_PLAYBACK;
212 //returns which bomb will be dropped next time the bomb key is pressed
217 //use the last one selected, unless there aren't any, in which case use
218 //the other if there are any
221 // If hoard game, only let the player drop smart mines
222 if (Game_mode & GM_HOARD)
223 return SMART_MINE_INDEX;
225 bomb = Secondary_last_was_super[PROXIMITY_INDEX]?SMART_MINE_INDEX:PROXIMITY_INDEX;
227 if (Players[Player_num].secondary_ammo[bomb] == 0 &&
228 Players[Player_num].secondary_ammo[SMART_MINE_INDEX+PROXIMITY_INDEX-bomb] != 0) {
229 bomb = SMART_MINE_INDEX+PROXIMITY_INDEX-bomb;
230 Secondary_last_was_super[bomb%SUPER_WEAPON] = (bomb == SMART_MINE_INDEX);
239 void do_weapon_stuff(void)
243 if (Controls.count[fire_flare])
244 if (allowed_to_fire_flare())
245 Flare_create(ConsoleObject);
247 if (allowed_to_fire_missile())
248 Global_missile_firing_count += Weapon_info[Secondary_weapon_to_weapon_info[Secondary_weapon]].fire_count * (Controls.state[fire_secondary] || Controls.count[fire_secondary]);
250 if (Global_missile_firing_count) {
251 do_missile_firing(1); //always enable autoselect for normal missile firing
252 Global_missile_firing_count--;
255 if (Controls.count[cycle_primary])
256 for (i = 0; i < Controls.count[cycle_primary]; i++)
258 if (Controls.count[cycle_secondary])
259 for (i = 0; i < Controls.count[cycle_secondary]; i++)
261 if (Controls.count[headlight])
262 for (i = 0; i < Controls.count[headlight]; i++)
263 toggle_headlight_active ();
265 if (Global_missile_firing_count < 0)
266 Global_missile_firing_count = 0;
268 // Drop proximity bombs.
269 if (Controls.count[drop_bomb]) {
270 int ssw_save = Secondary_weapon;
272 while (Controls.count[drop_bomb]--) {
275 ssw_save2 = Secondary_weapon = which_bomb();
277 do_missile_firing(Secondary_weapon == ssw_save); //only allow autoselect if bomb is actually selected
279 if (Secondary_weapon != ssw_save2 && ssw_save == ssw_save2)
280 ssw_save = Secondary_weapon; //if bomb was selected, and we ran out & autoselect, then stick with new selection
283 Secondary_weapon = ssw_save;
291 extern void game_render_frame(void);
292 extern void show_extra_views(void);
293 extern fix Flash_effect;
295 void apply_modified_palette(void)
298 //@@ grs_bitmap *sbp;
299 //@@ grs_canvas *save_canv;
300 //@@ int color_xlate[256];
303 //@@ if (!Flash_effect && ((PaletteRedAdd < 10) || (PaletteRedAdd < (PaletteGreenAdd + PaletteBlueAdd))))
306 //@@ reset_cockpit();
308 //@@ save_canv = grd_curcanv;
309 //@@ gr_set_current_canvas(&grd_curscreen->sc_canvas);
311 //@@ sbp = &grd_curscreen->sc_canvas.cv_bitmap;
313 //@@ for (x=0; x<256; x++)
314 //@@ color_xlate[x] = -1;
316 //@@ for (k=0; k<4; k++) {
317 //@@ for (y=0; y<grd_curscreen->sc_h; y+= 4) {
318 //@@ for (x=0; x<grd_curscreen->sc_w; x++) {
319 //@@ int color, new_color;
326 //@@ color = gr_ugpixel(sbp, xcrd, ycrd);
328 //@@ if (color_xlate[color] == -1) {
329 //@@ r = gr_palette[color*3+0];
330 //@@ g = gr_palette[color*3+1];
331 //@@ b = gr_palette[color*3+2];
333 //@@ r += PaletteRedAdd; if (r > 63) r = 63;
334 //@@ g += PaletteGreenAdd; if (g > 63) g = 63;
335 //@@ b += PaletteBlueAdd; if (b > 63) b = 63;
337 //@@ color_xlate[color] = gr_find_closest_color_current(r, g, b);
341 //@@ new_color = color_xlate[color];
343 //@@ gr_setcolor(new_color);
344 //@@ gr_upixel(xcrd, ycrd);
350 void format_time(char *str, int secs_int)
358 sprintf(str, "%1d:%02d:%02d", h, m, s );
361 extern int Redbook_playing;
362 void do_show_netgame_help(void);
364 //Process selected keys until game unpaused. returns key that left pause (p or esc)
369 char total_time[9],level_time[9];
373 if (Game_paused) { //unpause!
375 #if defined (TACTILE)
383 if (Game_mode & GM_NETWORK)
385 do_show_netgame_help();
388 else if (Game_mode & GM_MULTI)
390 HUD_init_message ("You cannot pause in a modem/serial game!");
400 apply_modified_palette();
403 // -- Matt: This is a hacked-in test for the stupid menu/flash problem.
404 // We need a new brightening primitive if we want to make this not horribly ugly.
405 // Gr_scanline_darkening_level = 2;
406 // gr_rect(0, 0, 319, 199);
412 #if defined (TACTILE)
418 // set_screen_mode( SCREEN_MENU );
420 gr_palette_load( gr_palette );
422 format_time(total_time, f2i(Players[Player_num].time_total) + Players[Player_num].hours_total*3600);
423 format_time(level_time, f2i(Players[Player_num].time_level) + Players[Player_num].hours_level*3600);
425 if (Newdemo_state!=ND_STATE_PLAYBACK)
426 sprintf(msg,"PAUSE\n\nSkill level: %s\nHostages on board: %d\nTime on level: %s\nTotal time in game: %s",(*(&TXT_DIFFICULTY_1 + (Difficulty_level))),Players[Player_num].hostages_on_board,level_time,total_time);
428 sprintf(msg,"PAUSE\n\nSkill level: %s\nHostages on board: %d\n",(*(&TXT_DIFFICULTY_1 + (Difficulty_level))),Players[Player_num].hostages_on_board);
430 show_boxed_message(Pause_msg=msg); //TXT_PAUSE);
437 key = newmenu_getch();
443 screen_changed = HandleSystemKey(key);
447 if (screen_changed) {
448 // game_render_frame();
449 WIN(set_popup_screen());
450 show_boxed_message(msg);
451 //show_extra_views();
452 if (Cockpit_mode.intval == CM_FULL_COCKPIT || Cockpit_mode.intval == CM_STATUS_BAR)
457 if (VR_screen_flags & VRF_COMPATIBLE_MENUS) {
458 clear_boxed_message();
459 mouse_set_mode(Config_control_mouse.intval);
460 newmenu_hide_cursor();
475 MAC(delay(500);) // delay 1/2 second because of dumb redbook problem
480 extern int newmenu_dotiny2( char * title, char * subtitle, int nitems, newmenu_item * item, void (*subfunction)(int nitems,newmenu_item * items, int * last_key, int citem) );
481 extern int network_who_is_master(void), network_how_many_connected(void), GetMyNetRanking(void);
482 extern int TotalMissedPackets,TotalPacketsGot;
483 extern char Pauseable_menu;
484 char *NetworkModeNames[]={"Anarchy","Team Anarchy","Robo Anarchy","Cooperative","Capture the Flag","Hoard","Team Hoard","Unknown"};
485 extern char *RankStrings[];
486 extern int PhallicLimit,PhallicMan;
489 void do_show_netgame_help()
497 char *eff_strings[]={"trashing","really hurting","seriously effecting","hurting",
498 "effecting","tarnishing"};
502 m[i].text=(char *)&mtext[i];
503 m[i].type=NM_TYPE_TEXT;
506 sprintf (mtext[num],"Game: %s",Netgame.game_name); num++;
507 sprintf (mtext[num],"Mission: %s",Netgame.mission_title); num++;
508 sprintf (mtext[num],"Current Level: %d",Netgame.levelnum); num++;
509 sprintf (mtext[num],"Difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty)); num++;
510 sprintf (mtext[num],"Game Mode: %s",NetworkModeNames[Netgame.gamemode]); num++;
511 sprintf (mtext[num],"Game Master: %s",Players[network_who_is_master()].callsign); num++;
512 sprintf (mtext[num],"Number of players: %d/%d",network_how_many_connected(),Netgame.max_numplayers); num++;
513 sprintf (mtext[num],"Packets per second: %d",Netgame.PacketsPerSec); num++;
514 sprintf (mtext[num],"Short Packets: %s",Netgame.ShortPackets?"Yes":"No"); num++;
517 pl=(int)(((float)TotalMissedPackets/(float)TotalPacketsGot)*100.0);
520 sprintf (mtext[num],"Packets lost: %d (%d%%)",TotalMissedPackets,pl); num++;
523 if (Netgame.KillGoal)
524 { sprintf (mtext[num],"Kill goal: %d",Netgame.KillGoal*5); num++; }
526 sprintf (mtext[num]," "); num++;
527 sprintf (mtext[num],"Connected players:"); num++;
529 NetPlayers.players[Player_num].rank=GetMyNetRanking();
531 for (i=0;i<N_players;i++)
532 if (Players[i].connected)
534 if (!FindArg ("-norankings"))
537 sprintf (mtext[num],"%s%s (%d/%d)",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,Netlife_kills,Netlife_killed);
539 sprintf (mtext[num],"%s%s %d/%d",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,kill_matrix[Player_num][i],
540 kill_matrix[i][Player_num]);
544 sprintf (mtext[num++],"%s",Players[i].callsign);
548 sprintf (mtext[num]," "); num++;
550 eff=(int)((float)((float)Netlife_kills/((float)Netlife_killed+(float)Netlife_kills))*100.0);
555 if (Game_mode & GM_HOARD)
558 sprintf (mtext[num],"There is no record yet for this level.");
560 sprintf (mtext[num],"%s has the record at %d points.",Players[PhallicMan].callsign,PhallicLimit);
563 else if (!FindArg ("-norankings"))
567 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
568 sprintf (mtext[num],"is %s your ranking.",eff_strings[eff/10]); num++;
572 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
573 sprintf (mtext[num],"is serving you well."); num++;
581 newmenu_dotiny2( NULL, "Netgame Information", num, m, NULL);
587 void HandleEndlevelKey(int key)
589 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) )
592 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
595 if (key==KEY_PRINT_SCREEN)
598 if ( key == (KEY_COMMAND+KEY_P) )
599 key = do_game_pause();
601 if (key == KEY_PAUSE)
602 key = do_game_pause(); //so esc from pause will end level
604 if (key == KEY_ESC) {
605 stop_endlevel_sequence();
606 last_drawn_cockpit[0]=-1;
607 last_drawn_cockpit[1]=-1;
611 if (key == KEY_BACKSP)
615 void HandleDeathKey(int key)
618 Commented out redundant calls because the key used here typically
619 will be passed to HandleSystemKey later. Note that I do this to pause
620 which is supposed to pass the ESC key to leave the level. This
621 doesn't work in the DOS version anyway. -Samir
624 if (Player_exploded && !key_isfunc(key) && !key_ismod(key))
625 Death_sequence_aborted = 1; //Any key but func or modifier aborts
627 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) ) {
628 // save_screen_shot(0);
629 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
632 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
635 if (key==KEY_PRINT_SCREEN) {
636 // save_screen_shot(0);
637 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
640 if ( key == (KEY_COMMAND+KEY_P) ) {
641 // key = do_game_pause();
642 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
645 if (key == KEY_PAUSE) {
646 // key = do_game_pause(); //so esc from pause will end level
647 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
650 if (key == KEY_ESC) {
651 if (ConsoleObject->flags & OF_EXPLODING)
652 Death_sequence_aborted = 1;
655 if (key == KEY_BACKSP) {
656 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
660 //don't abort death sequence for netgame join/refuse keys
661 if ( (key == KEY_ALTED + KEY_1) ||
662 (key == KEY_ALTED + KEY_2))
663 Death_sequence_aborted = 0;
665 if (Death_sequence_aborted)
670 void HandleDemoKey(int key)
675 if (!(Guided_missile[Player_num] &&
676 Guided_missile[Player_num]->type == OBJ_WEAPON &&
677 Guided_missile[Player_num]->id == GUIDEDMISS_ID &&
678 Guided_missile[Player_num]->signature == Guided_missile_sig[Player_num] &&
679 Guided_in_big_window.intval))
683 case KEY_COMMAND+KEY_2:
684 case KEY_F2: Config_menu_flag = 1; break;
686 case KEY_COMMAND+KEY_7:
689 Show_kill_list = (Show_kill_list+1) % ((Newdemo_game_mode & GM_TEAM) ? 4 : 3);
693 Function_mode = FMODE_MENU;
696 Newdemo_vcr_state = ND_STATE_PLAYBACK;
699 Newdemo_vcr_state = ND_STATE_PAUSED;
702 newdemo_single_frame_time = timer_get_fixed_seconds();
703 Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
706 newdemo_single_frame_time = timer_get_fixed_seconds();
707 Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
709 case KEY_CTRLED + KEY_RIGHT:
712 case KEY_CTRLED + KEY_LEFT:
713 newdemo_goto_beginning();
716 case KEY_COMMAND+KEY_P:
721 case KEY_COMMAND + KEY_SHIFTED + KEY_3:
722 case KEY_PRINT_SCREEN: {
725 old_state = Newdemo_vcr_state;
726 Newdemo_vcr_state = ND_STATE_PRINTSCREEN;
727 game_render_frame_mono();
729 Newdemo_vcr_state = old_state;
733 case KEY_COMMAND+KEY_Q:
734 if ( !(Game_mode & GM_MULTI) )
742 case KEY_DEBUGGED + KEY_I:
743 Newdemo_do_interpolate = !Newdemo_do_interpolate;
744 if (Newdemo_do_interpolate)
745 mprintf ((0, "demo playback interpolation now on\n"));
747 mprintf ((0, "demo playback interpolation now off\n"));
749 case KEY_DEBUGGED + KEY_K: {
751 char filename[FILENAME_LEN], num[16];
755 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "output file name";
756 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 8; m[1].text = filename;
757 c = newmenu_do( NULL, NULL, 2, m, NULL );
760 strcat(filename, ".dem");
762 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "strip how many bytes";
763 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 16; m[1].text = num;
764 c = newmenu_do( NULL, NULL, 2, m, NULL );
767 how_many = atoi(num);
770 newdemo_strip_frames(filename, how_many);
779 //switch a cockpit window to the next function
780 int select_next_window_function(int w)
782 Assert(w==0 || w==1);
784 switch (Cockpit_3d_view[w].intval) {
786 cvar_setint(&Cockpit_3d_view[w], CV_REAR);
790 cvar_setint(&Cockpit_3d_view[w], CV_ESCORT);
793 //if no ecort, fall through
795 Coop_view_player[w] = -1; //force first player
799 Marker_viewer_num[w] = -1;
800 if ((Game_mode & GM_MULTI_COOP) || (Game_mode & GM_TEAM)) {
801 cvar_setint(&Cockpit_3d_view[w], CV_COOP);
803 Coop_view_player[w]++;
804 if (Coop_view_player[w] == N_players) {
805 cvar_setint(&Cockpit_3d_view[w], CV_MARKER);
808 if (Coop_view_player[w]==Player_num)
811 if (Game_mode & GM_MULTI_COOP)
813 else if (get_team(Coop_view_player[w]) == get_team(Player_num))
818 //if not multi, fall through
821 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) && Netgame.Allow_marker_view) { //anarchy only
822 cvar_setint(&Cockpit_3d_view[w], CV_MARKER);
823 if (Marker_viewer_num[w] == -1)
824 Marker_viewer_num[w] = Player_num * 2;
825 else if (Marker_viewer_num[w] == Player_num * 2)
826 Marker_viewer_num[w]++;
828 cvar_setint(&Cockpit_3d_view[w], CV_NONE);
832 cvar_setint(&Cockpit_3d_view[w], CV_NONE);
837 return 1; //screen_changed
840 extern int Game_paused;
842 void songs_goto_next_song(void);
843 void songs_goto_prev_song(void);
845 #ifdef DOOR_DEBUGGING
846 dump_door_debugging_info()
856 obj = &Objects[Players[Player_num].objnum];
857 vm_vec_scale_add(&new_pos,&obj->pos,&obj->orient.fvec,i2f(100));
860 fq.startseg = obj->segnum;
863 fq.thisobjnum = Players[Player_num].objnum;
864 fq.ignore_obj_list = NULL;
867 fate = find_vector_intersection(&fq,&hit_info);
869 dfile = fopen("door.out","at");
871 fprintf(dfile,"FVI hit_type = %d\n",fate);
872 fprintf(dfile," hit_seg = %d\n",hit_info.hit_seg);
873 fprintf(dfile," hit_side = %d\n",hit_info.hit_side);
874 fprintf(dfile," hit_side_seg = %d\n",hit_info.hit_side_seg);
877 if (fate == HIT_WALL) {
879 wall_num = Segments[hit_info.hit_seg].sides[hit_info.hit_side].wall_num;
880 fprintf(dfile,"wall_num = %d\n",wall_num);
882 if (wall_num != -1) {
883 wall *wall = &Walls[wall_num];
887 fprintf(dfile," segnum = %d\n",wall->segnum);
888 fprintf(dfile," sidenum = %d\n",wall->sidenum);
889 fprintf(dfile," hps = %x\n",wall->hps);
890 fprintf(dfile," linked_wall = %d\n",wall->linked_wall);
891 fprintf(dfile," type = %d\n",wall->type);
892 fprintf(dfile," flags = %x\n",wall->flags);
893 fprintf(dfile," state = %d\n",wall->state);
894 fprintf(dfile," trigger = %d\n",wall->trigger);
895 fprintf(dfile," clip_num = %d\n",wall->clip_num);
896 fprintf(dfile," keys = %x\n",wall->keys);
897 fprintf(dfile," controlling_trigger = %d\n",wall->controlling_trigger);
898 fprintf(dfile," cloak_value = %d\n",wall->cloak_value);
902 for (i=0;i<Num_open_doors;i++) { //find door
904 if (d->front_wallnum[0] == WALL_NUMBER(wall) ||
905 d->back_wallnum[0] == WALL_NUMBER(wall) ||
906 (d->n_parts==2 && (d->front_wallnum[1] == WALL_NUMBER(wall) ||
907 d->back_wallnum[1] == WALL_NUMBER(wall))))
911 if (i>=Num_open_doors)
912 fprintf(dfile,"No active door.\n");
914 fprintf(dfile,"Active door %d:\n",i);
915 fprintf(dfile," n_parts = %d\n",d->n_parts);
916 fprintf(dfile," front_wallnum = %d,%d\n",d->front_wallnum[0],d->front_wallnum[1]);
917 fprintf(dfile," back_wallnum = %d,%d\n",d->back_wallnum[0],d->back_wallnum[1]);
918 fprintf(dfile," time = %x\n",d->time);
933 //this is for system-level keys, such as help, etc.
934 //returns 1 if screen changed
935 int HandleSystemKey(int key)
937 int screen_changed=0;
942 #ifdef DOOR_DEBUGGING
943 case KEY_LAPOSTRO+KEY_SHIFTED:
944 dump_door_debugging_info();
953 Function_mode = FMODE_MENU;
957 // fleshed these out because F1 and F2 aren't sequenctial keycodes on mac -- MWA
959 case KEY_COMMAND+KEY_SHIFTED+KEY_1:
960 case KEY_SHIFTED+KEY_F1:
961 screen_changed = select_next_window_function(0);
963 case KEY_COMMAND+KEY_SHIFTED+KEY_2:
964 case KEY_SHIFTED+KEY_F2:
965 screen_changed = select_next_window_function(1);
972 case KEY_SHIFTED + KEY_ESC:
976 case KEY_SHIFTED + KEY_ESC: //quick exit
978 if (! SafetyCheck()) break;
979 close_editor_screen();
983 Function_mode=FMODE_EXIT;
987 case KEY_COMMAND+KEY_P:
989 do_game_pause(); break;
991 case KEY_COMMAND + KEY_SHIFTED + KEY_3:
992 case KEY_PRINT_SCREEN: save_screen_shot(0); break;
994 case KEY_COMMAND+KEY_1:
995 case KEY_F1: do_show_help(); break;
997 case KEY_COMMAND+KEY_2:
998 case KEY_F2: //Config_menu_flag = 1; break;
1000 if (!(Game_mode&GM_MULTI)) {palette_save(); apply_modified_palette(); reset_palette_add(); gr_palette_load(gr_palette); }
1002 if (!(Game_mode&GM_MULTI)) palette_restore();
1006 case KEY_COMMAND+KEY_3:
1008 if (!(Guided_missile[Player_num] &&
1009 Guided_missile[Player_num]->type == OBJ_WEAPON &&
1010 Guided_missile[Player_num]->id == GUIDEDMISS_ID &&
1011 Guided_missile[Player_num]->signature == Guided_missile_sig[Player_num] &&
1012 Guided_in_big_window.intval))
1014 toggle_cockpit(); screen_changed=1;
1018 case KEY_COMMAND+KEY_SHIFTED+KEY_7:
1019 case KEY_F7+KEY_SHIFTED: palette_save(); joydefs_calibrate(); palette_restore(); break;
1021 case KEY_COMMAND+KEY_5:
1023 if ( Newdemo_state == ND_STATE_RECORDING )
1024 newdemo_stop_recording();
1025 else if ( Newdemo_state == ND_STATE_NORMAL )
1026 if (!Game_paused) //can't start demo while paused
1027 newdemo_start_recording();
1030 case KEY_COMMAND+KEY_ALTED+KEY_4:
1031 case KEY_ALTED+KEY_F4:
1033 Show_reticle_name = (Show_reticle_name+1)%2;
1037 case KEY_COMMAND + KEY_6:
1039 if (!Player_is_dead && !(Game_mode & GM_MULTI))
1041 int rsave, gsave, bsave;
1042 rsave = PaletteRedAdd;
1043 gsave = PaletteGreenAdd;
1044 bsave = PaletteBlueAdd;
1046 full_palette_save();
1047 PaletteRedAdd = rsave;
1048 PaletteGreenAdd = gsave;
1049 PaletteBlueAdd = bsave;
1050 state_save_all(0, 0, NULL, 1); // 0 means not between levels.
1056 case KEY_COMMAND+KEY_7:
1058 Show_kill_list = (Show_kill_list+1) % ((Game_mode & GM_TEAM) ? 4 : 3);
1059 if (Game_mode & GM_MULTI)
1060 multi_sort_kill_list();
1063 case KEY_COMMAND+KEY_8:
1065 multi_send_message_start();
1072 multi_send_macro(key);
1073 break; // send taunt macros
1075 case KEY_9 + KEY_COMMAND:
1076 multi_send_macro(KEY_F9);
1078 case KEY_0 + KEY_COMMAND:
1079 multi_send_macro(KEY_F10);
1081 case KEY_1 + KEY_COMMAND + KEY_CTRLED:
1082 multi_send_macro(KEY_F11);
1084 case KEY_2 + KEY_COMMAND + KEY_CTRLED:
1085 multi_send_macro(KEY_F12);
1088 case KEY_SHIFTED + KEY_F9:
1089 case KEY_SHIFTED + KEY_F10:
1090 case KEY_SHIFTED + KEY_F11:
1091 case KEY_SHIFTED + KEY_F12:
1092 multi_define_macro(key);
1093 break; // redefine taunt macros
1095 case KEY_9 + KEY_SHIFTED + KEY_COMMAND:
1096 multi_define_macro(KEY_F9);
1098 case KEY_0 + KEY_SHIFTED + KEY_COMMAND:
1099 multi_define_macro(KEY_F10);
1101 case KEY_1 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1102 multi_define_macro(KEY_F11);
1104 case KEY_2 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1105 multi_define_macro(KEY_F12);
1109 case KEY_COMMAND+KEY_S:
1110 case KEY_COMMAND+KEY_ALTED+KEY_2:
1111 case KEY_ALTED+KEY_F2:
1112 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1113 int rsave, gsave, bsave;
1114 rsave = PaletteRedAdd;
1115 gsave = PaletteGreenAdd;
1116 bsave = PaletteBlueAdd;
1118 full_palette_save();
1119 PaletteRedAdd = rsave;
1120 PaletteGreenAdd = gsave;
1121 PaletteBlueAdd = bsave;
1122 state_save_all(0, 0, NULL, 0); // 0 means not between levels.
1127 case KEY_COMMAND+KEY_O:
1128 case KEY_COMMAND+KEY_ALTED+KEY_3:
1129 case KEY_ALTED+KEY_F3:
1130 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1131 full_palette_save();
1132 state_restore_all(1, 0, NULL);
1138 case KEY_COMMAND+KEY_SHIFTED+KEY_4:
1139 case KEY_F4 + KEY_SHIFTED:
1143 case KEY_COMMAND+KEY_SHIFTED+KEY_ALTED+KEY_4:
1144 case KEY_F4 + KEY_SHIFTED + KEY_ALTED:
1145 change_guidebot_name();
1148 case KEY_MINUS + KEY_ALTED: songs_goto_prev_song(); break;
1149 case KEY_EQUAL + KEY_ALTED: songs_goto_next_song(); break;
1153 case KEY_COMMAND+KEY_M:
1154 if ( (Game_mode & GM_MULTI) ) // don't process in multiplayer games
1157 key_close(); // no processing of keys with keyboard handler.. jeez
1159 show_boxed_message ("Mounting CD\nESC to quit");
1160 RBAMountDisk(); // OS has totaly control of the CD.
1161 if (Function_mode == FMODE_MENU)
1162 songs_play_song(SONG_TITLE,1);
1163 else if (Function_mode == FMODE_GAME)
1164 songs_play_level_song( Current_level_num );
1165 clear_boxed_message();
1171 case KEY_COMMAND+KEY_E:
1172 songs_stop_redbook();
1176 case KEY_COMMAND+KEY_RIGHT:
1177 songs_goto_next_song();
1179 case KEY_COMMAND+KEY_LEFT:
1180 songs_goto_prev_song();
1182 case KEY_COMMAND+KEY_UP:
1183 songs_play_level_song(1);
1185 case KEY_COMMAND+KEY_DOWN:
1186 songs_stop_redbook();
1190 case KEY_COMMAND+KEY_Q:
1191 if ( !(Game_mode & GM_MULTI) )
1195 //added 8/23/99 by Matt Mueller for hot key res/fullscreen changing, and menu access
1196 case KEY_CTRLED+KEY_SHIFTED+KEY_PADDIVIDE:
1197 case KEY_ALTED+KEY_CTRLED+KEY_PADDIVIDE:
1198 case KEY_ALTED+KEY_SHIFTED+KEY_PADDIVIDE:
1202 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMULTIPLY:
1203 case KEY_ALTED+KEY_CTRLED+KEY_PADMULTIPLY:
1204 case KEY_ALTED+KEY_SHIFTED+KEY_PADMULTIPLY:
1207 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMINUS:
1208 case KEY_ALTED+KEY_CTRLED+KEY_PADMINUS:
1209 case KEY_ALTED+KEY_SHIFTED+KEY_PADMINUS:
1211 //should we just cycle through the list that is displayed in the res change menu?
1212 // what if their card/X/etc can't handle that mode? hrm.
1213 //well, the quick access to the menu is good enough for now.
1215 case KEY_CTRLED+KEY_SHIFTED+KEY_PADPLUS:
1216 case KEY_ALTED+KEY_CTRLED+KEY_PADPLUS:
1217 case KEY_ALTED+KEY_SHIFTED+KEY_PADPLUS:
1221 case KEY_COMMAND+KEY_SHIFTED+KEY_F:
1222 case KEY_ALTED+KEY_ENTER:
1223 case KEY_ALTED+KEY_PADENTER:
1224 game_toggle_fullscreen();
1228 //added 11/01/98 Matt Mueller
1230 case KEY_CTRLED+KEY_ALTED+KEY_LAPOSTRO:
1241 return screen_changed;
1245 void HandleVRKey(int key)
1249 case KEY_ALTED+KEY_F5:
1250 if ( VR_render_mode != VR_NONE ) {
1252 HUD_init_message( "-Stereoscopic Parameters Reset-" );
1253 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1254 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1258 case KEY_ALTED+KEY_F6:
1259 if ( VR_render_mode != VR_NONE ) {
1261 if ( VR_low_res > 3 ) VR_low_res = 0;
1262 switch( VR_low_res ) {
1263 case 0: HUD_init_message( "Normal Resolution" ); break;
1264 case 1: HUD_init_message( "Low Vertical Resolution" ); break;
1265 case 2: HUD_init_message( "Low Horizontal Resolution" ); break;
1266 case 3: HUD_init_message( "Low Resolution" ); break;
1271 case KEY_ALTED+KEY_F7:
1272 if ( VR_render_mode != VR_NONE ) {
1273 VR_eye_switch = !VR_eye_switch;
1274 HUD_init_message( "-Eyes toggled-" );
1275 if ( VR_eye_switch )
1276 HUD_init_message( "Right Eye -- Left Eye" );
1278 HUD_init_message( "Left Eye -- Right Eye" );
1282 case KEY_ALTED+KEY_F8:
1283 if ( VR_render_mode != VR_NONE ) {
1285 if (VR_sensitivity > 2 )
1287 HUD_init_message( "Head tracking sensitivy = %d", VR_sensitivity );
1290 case KEY_ALTED+KEY_F9:
1291 if ( VR_render_mode != VR_NONE ) {
1292 VR_eye_width -= F1_0/10;
1293 if ( VR_eye_width < 0 ) VR_eye_width = 0;
1294 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1295 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1298 case KEY_ALTED+KEY_F10:
1299 if ( VR_render_mode != VR_NONE ) {
1300 VR_eye_width += F1_0/10;
1301 if ( VR_eye_width > F1_0*4 ) VR_eye_width = F1_0*4;
1302 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1303 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1307 case KEY_ALTED+KEY_F11:
1308 if ( VR_render_mode != VR_NONE ) {
1310 if ( VR_eye_offset < -30 ) VR_eye_offset = -30;
1311 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1312 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1313 VR_eye_offset_changed = 2;
1316 case KEY_ALTED+KEY_F12:
1317 if ( VR_render_mode != VR_NONE ) {
1319 if ( VR_eye_offset > 30 ) VR_eye_offset = 30;
1320 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1321 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1322 VR_eye_offset_changed = 2;
1329 extern void DropFlag(void);
1331 void HandleGameKey(int key)
1335 #if !defined(RELEASE)
1336 case KEY_COMMAND+KEY_F:
1337 cvar_toggle( &r_framerate );
1341 case KEY_1 + KEY_SHIFTED:
1342 case KEY_2 + KEY_SHIFTED:
1343 case KEY_3 + KEY_SHIFTED:
1344 case KEY_4 + KEY_SHIFTED:
1345 case KEY_5 + KEY_SHIFTED:
1346 case KEY_6 + KEY_SHIFTED:
1347 case KEY_7 + KEY_SHIFTED:
1348 case KEY_8 + KEY_SHIFTED:
1349 case KEY_9 + KEY_SHIFTED:
1350 case KEY_0 + KEY_SHIFTED:
1353 if (!(Game_mode & GM_MULTI))
1354 set_escort_special_goal(key);
1356 HUD_init_message ("No Guide-Bot in Multiplayer!");
1360 case KEY_COMMAND+KEY_SHIFTED+KEY_5:
1361 case KEY_F5 + KEY_SHIFTED:
1362 DropCurrentWeapon();
1365 case KEY_COMMAND+KEY_SHIFTED+KEY_6:
1366 case KEY_F6 + KEY_SHIFTED:
1367 DropSecondaryWeapon();
1371 case KEY_0 + KEY_ALTED:
1376 case KEY_COMMAND+KEY_4:
1378 if (!DefiningMarkerMessage)
1383 case KEY_COMMAND+KEY_6:
1385 if (Netgame.RefusePlayers && WaitForRefuseAnswer && !(Game_mode & GM_TEAM))
1388 HUD_init_message ("Player accepted!");
1391 case KEY_ALTED + KEY_1:
1392 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1395 HUD_init_message ("Player accepted!");
1399 case KEY_ALTED + KEY_2:
1400 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1403 HUD_init_message ("Player accepted!");
1415 void kill_all_robots(void)
1417 int i, dead_count=0;
1418 //int boss_index = -1;
1420 // Kill all bots except for Buddy bot and boss. However, if only boss and buddy left, kill boss.
1421 for (i=0; i<=Highest_object_index; i++)
1422 if (Objects[i].type == OBJ_ROBOT) {
1423 if (!Robot_info[Objects[i].id].companion && !Robot_info[Objects[i].id].boss_flag) {
1425 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1429 // -- // Now, if more than boss and buddy left, un-kill boss.
1430 // -- if ((dead_count > 2) && (boss_index != -1)) {
1431 // -- Objects[boss_index].flags &= ~(OF_EXPLODING|OF_SHOULD_BE_DEAD);
1433 // -- } else if (boss_index != -1)
1434 // -- HUD_init_message("Toasted the BOSS!");
1436 // Toast the buddy if nothing else toasted!
1437 if (dead_count == 0)
1438 for (i=0; i<=Highest_object_index; i++)
1439 if (Objects[i].type == OBJ_ROBOT)
1440 if (Robot_info[Objects[i].id].companion) {
1441 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1442 HUD_init_message("Toasted the Buddy! *sniff*");
1446 HUD_init_message("%i robots toasted!", dead_count);
1449 // --------------------------------------------------------------------------
1450 // Detonate reactor.
1451 // Award player all powerups in mine.
1452 // Place player just outside exit.
1453 // Kill all bots in mine.
1455 void kill_and_so_forth(void)
1459 HUD_init_message("Killing, awarding, etc.!");
1461 for (i=0; i<=Highest_object_index; i++) {
1462 switch (Objects[i].type) {
1464 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1467 do_powerup(&Objects[i]);
1472 do_controlcen_destroyed_stuff(NULL);
1474 for (i=0; i<Num_triggers; i++) {
1475 if (Triggers[i].type == TT_EXIT) {
1476 for (j=0; j<Num_walls; j++) {
1477 if (Walls[j].trigger == i) {
1478 compute_segment_center(&ConsoleObject->pos, &Segments[Walls[j].segnum]);
1479 obj_relink(OBJECT_NUMBER(ConsoleObject), Walls[j].segnum);
1492 void kill_all_snipers(void)
1494 int i, dead_count=0;
1496 // Kill all snipers.
1497 for (i=0; i<=Highest_object_index; i++)
1498 if (Objects[i].type == OBJ_ROBOT)
1499 if (Objects[i].ctype.ai_info.behavior == AIB_SNIPE) {
1501 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1504 HUD_init_message("%i robots toasted!", dead_count);
1507 void kill_thief(void)
1512 for (i=0; i<=Highest_object_index; i++)
1513 if (Objects[i].type == OBJ_ROBOT)
1514 if (Robot_info[Objects[i].id].thief) {
1515 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1516 HUD_init_message("Thief toasted!");
1520 void kill_buddy(void)
1525 for (i=0; i<=Highest_object_index; i++)
1526 if (Objects[i].type == OBJ_ROBOT)
1527 if (Robot_info[Objects[i].id].companion) {
1528 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1529 HUD_init_message("Buddy toasted!");
1534 void gamecntl_cmd_kill(int argc, char **argv)
1536 if (!Cheats_enabled.intval)
1541 ConsoleObject->flags |= OF_SHOULD_BE_DEAD;
1545 if (!stricmp(argv[1], "all"))
1547 else if (!stricmp(argv[1], "snipers"))
1549 else if (!stricmp(argv[1], "thief"))
1551 else if (!stricmp(argv[1], "buddy"))
1557 void toggle_movie_saving(void);
1558 extern char Language[];
1560 void HandleTestKey(int key)
1564 case KEY_DEBUGGED+KEY_0: show_weapon_status(); break;
1566 #ifdef SHOW_EXIT_PATH
1567 case KEY_DEBUGGED+KEY_1: create_special_path(); break;
1570 case KEY_DEBUGGED+KEY_Y:
1571 do_controlcen_destroyed_stuff(NULL);
1575 case KEY_DEBUGGED+KEY_ALTED+KEY_D:
1576 Netlife_kills=4000; Netlife_killed=5;
1577 multi_add_lifetime_kills();
1582 case KEY_CTRLED+KEY_BACKSP:
1583 case KEY_ALTED+KEY_BACKSP:
1584 case KEY_SHIFTED+KEY_BACKSP:
1585 case KEY_SHIFTED+KEY_ALTED+KEY_BACKSP:
1586 case KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1587 case KEY_SHIFTED+KEY_CTRLED+KEY_BACKSP:
1588 case KEY_SHIFTED+KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1592 case KEY_DEBUGGED+KEY_S: digi_reset(); break;
1594 case KEY_DEBUGGED+KEY_P:
1595 if (Game_suspended & SUSP_ROBOTS)
1596 Game_suspended &= ~SUSP_ROBOTS; //robots move
1598 Game_suspended |= SUSP_ROBOTS; //robots don't move
1603 case KEY_DEBUGGED+KEY_K: Players[Player_num].shields = 1; break; // a virtual kill
1604 case KEY_DEBUGGED+KEY_SHIFTED + KEY_K: Players[Player_num].shields = -1; break; // an actual kill
1605 case KEY_DEBUGGED+KEY_X: Players[Player_num].lives++; break; // Extra life cheat key.
1606 case KEY_DEBUGGED+KEY_H:
1607 // if (!(Game_mode & GM_MULTI) ) {
1608 Players[Player_num].flags ^= PLAYER_FLAGS_CLOAKED;
1609 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
1611 if (Game_mode & GM_MULTI)
1614 ai_do_cloak_stuff();
1615 Players[Player_num].cloak_time = GameTime;
1616 mprintf((0, "You are cloaked!\n"));
1618 mprintf((0, "You are DE-cloaked!\n"));
1623 case KEY_DEBUGGED+KEY_R:
1624 Robot_firing_enabled = !Robot_firing_enabled;
1627 case KEY_DEBUGGED+KEY_R+KEY_SHIFTED:
1631 #ifdef EDITOR //editor-specific functions
1633 case KEY_E + KEY_DEBUGGED:
1635 network_leave_game();
1637 Function_mode = FMODE_EDITOR;
1639 case KEY_Q + KEY_SHIFTED + KEY_DEBUGGED:
1642 memcpy(pal_save,gr_palette,768);
1643 init_subtitles("end.tex"); //ingore errors
1644 PlayMovie ("end.mve",MOVIE_ABORT_ON);
1647 set_screen_mode(SCREEN_GAME);
1649 memcpy(gr_palette,pal_save,768);
1650 gr_palette_load(gr_palette);
1653 case KEY_C + KEY_SHIFTED + KEY_DEBUGGED:
1654 if (!( Game_mode & GM_MULTI ))
1655 move_player_2_segment(Cursegp,Curside);
1656 break; //move eye to curseg
1659 case KEY_DEBUGGED+KEY_W: draw_world_from_game(); break;
1661 #endif //#ifdef EDITOR
1664 // case KEY_DEBUGGED+KEY_SHIFTED+KEY_F: toggle_flythrough(); break;
1665 // case KEY_LEFT: ft_preference=FP_LEFT; break;
1666 // case KEY_RIGHT: ft_preference=FP_RIGHT; break;
1667 // case KEY_UP: ft_preference=FP_UP; break;
1668 // case KEY_DOWN: ft_preference=FP_DOWN; break;
1671 case KEY_DEBUGGED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_next_viewer(); break;
1672 case KEY_DEBUGGED+KEY_CTRLED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_prev_viewer(); break;
1674 case KEY_DEBUGGED+KEY_SHIFTED+KEY_LAPOSTRO: Viewer=ConsoleObject; break;
1677 case KEY_DEBUGGED+KEY_O: toggle_outline_mode(); break;
1679 case KEY_DEBUGGED+KEY_T:
1680 *Toggle_var = !*Toggle_var;
1681 mprintf((0, "Variable at %08x set to %i\n", Toggle_var, *Toggle_var));
1683 case KEY_DEBUGGED + KEY_L:
1684 if (++Lighting_on >= 2) Lighting_on = 0; break;
1685 case KEY_DEBUGGED + KEY_SHIFTED + KEY_L:
1686 Beam_brightness=0x38000-Beam_brightness; break;
1687 case KEY_PAD5: slew_stop(); break;
1690 case KEY_DEBUGGED + KEY_F11: play_test_sound(); break;
1691 case KEY_DEBUGGED + KEY_SHIFTED+KEY_F11: advance_sound(); play_test_sound(); break;
1694 case KEY_DEBUGGED +KEY_F4: {
1695 //fvi_info hit_data;
1696 //vms_vector p0 = {-0x1d99a7,-0x1b20000,0x186ab7f};
1697 //vms_vector p1 = {-0x217865,-0x1b20000,0x187de3e};
1698 //find_vector_intersection(&hit_data,&p0,0x1b9,&p1,0x40000,0x0,NULL,-1);
1702 case KEY_DEBUGGED + KEY_M:
1703 Debug_spew = !Debug_spew;
1705 mopen( 0, 8, 1, 78, 16, "Debug Spew");
1706 HUD_init_message( "Debug Spew: ON" );
1709 HUD_init_message( "Debug Spew: OFF" );
1713 case KEY_DEBUGGED + KEY_C:
1715 full_palette_save();
1719 case KEY_DEBUGGED + KEY_SHIFTED + KEY_A:
1720 do_megawow_powerup(10);
1722 case KEY_DEBUGGED + KEY_A: {
1723 do_megawow_powerup(200);
1724 // if ( Game_mode & GM_MULTI ) {
1725 // nm_messagebox( NULL, 1, "Damn", "CHEATER!\nYou cannot use the\nmega-thing in network mode." );
1726 // Network_message_reciever = 100; // Send to everyone...
1727 // sprintf( Network_message, "%s cheated!", Players[Player_num].callsign);
1729 // do_megawow_powerup();
1734 case KEY_DEBUGGED+KEY_F:
1735 cvar_toggle( &r_framerate );
1738 case KEY_DEBUGGED+KEY_SPACEBAR: //KEY_F7: // Toggle physics flying
1740 game_flush_inputs();
1741 if ( ConsoleObject->control_type != CT_FLYING ) {
1742 fly_init(ConsoleObject);
1743 Game_suspended &= ~SUSP_ROBOTS; //robots move
1745 slew_init(ConsoleObject); //start player slewing
1746 Game_suspended |= SUSP_ROBOTS; //robots don't move
1750 case KEY_DEBUGGED+KEY_COMMA: Render_zoom = fixmul(Render_zoom,62259); break;
1751 case KEY_DEBUGGED+KEY_PERIOD: Render_zoom = fixmul(Render_zoom,68985); break;
1753 case KEY_DEBUGGED+KEY_P+KEY_SHIFTED: Debug_pause = 1; break;
1757 // sprintf(mystr,"mark %i start",Mark_count);
1761 //case KEY_SHIFTED+KEY_F7: {
1763 // sprintf(mystr,"mark %i end",Mark_count);
1771 case KEY_DEBUGGED+KEY_F8: speedtest_init(); Speedtest_count = 1; break;
1772 case KEY_DEBUGGED+KEY_F9: speedtest_init(); Speedtest_count = 10; break;
1774 case KEY_DEBUGGED+KEY_D:
1775 if ((Game_double_buffer = !Game_double_buffer)!=0)
1781 case KEY_DEBUGGED+KEY_Q:
1783 dump_used_textures_all();
1788 case KEY_DEBUGGED+KEY_B: {
1790 char text[FILENAME_LEN]="";
1792 m.type=NM_TYPE_INPUT; m.text_len = FILENAME_LEN; m.text = text;
1793 item = newmenu_do( NULL, "Briefing to play?", 1, &m, NULL );
1795 do_briefing_screens(text,1);
1801 case KEY_DEBUGGED+KEY_F5:
1802 toggle_movie_saving();
1805 case KEY_DEBUGGED+KEY_SHIFTED+KEY_F5: {
1806 extern int Movie_fixed_frametime;
1807 Movie_fixed_frametime = !Movie_fixed_frametime;
1811 case KEY_DEBUGGED+KEY_ALTED+KEY_F5:
1812 GameTime = i2f(0x7fff - 840); //will overflow in 14 minutes
1813 mprintf((0,"GameTime bashed to %d secs\n",f2i(GameTime)));
1816 case KEY_DEBUGGED+KEY_SHIFTED+KEY_B:
1817 kill_and_so_forth();
1821 #endif //#ifndef RELEASE
1823 // Cheat functions ------------------------------------------------------------
1826 // check of cheats are, or can be, enabled
1827 static int check_cheat_enable(void)
1829 // cheats have to be enabled explicitly
1830 if (EMULATING_D1 || Game_mode & GM_MULTI)
1831 return Cheats_enabled.intval;
1837 void do_cheat_penalty ()
1839 digi_play_sample( SOUND_CHEATER, F1_0);
1840 cvar_setint(&Cheats_enabled, 1);
1841 Players[Player_num].score=0;
1847 char john_head_on=0;
1850 char OldHomingState[20];
1851 extern char Monster_mode;
1853 void fill_background(void);
1854 void load_background_bitmap(void);
1856 extern int Robots_kill_robots_cheat;
1859 static void gamecntl_cmd_LamerCheat(int argc, char **argv)
1862 Players[Player_num].shields = i2f(1);
1863 Players[Player_num].energy = i2f(1);
1865 if (Game_mode & GM_MULTI)
1867 Network_message_reciever = 100; // Send to everyone...
1868 sprintf(Network_message, "%s is crippled...get him!", Players[Player_num].callsign);
1871 HUD_init_message("Take that...cheater!");
1875 static void gamecntl_cmd_EnableCheats(int argc, char **argv)
1877 if (Game_mode & GM_MULTI)
1882 gamecntl_cmd_LamerCheat(argc, argv);
1887 HUD_init_message(TXT_CHEATS_ENABLED);
1891 static void gamecntl_cmd_JohnHeadCheat(int argc, char **argv)
1893 john_head_on = !john_head_on;
1894 load_background_bitmap();
1896 HUD_init_message(john_head_on?"Hi John!!":"Bye John!!");
1900 static void gamecntl_cmd_AcidCheat(int argc, char **argv)
1905 Interpolation_method = old_IntMethod;
1906 HUD_init_message("Coming down...");
1911 old_IntMethod = Interpolation_method;
1912 Interpolation_method = 1;
1913 HUD_init_message("Going up!");
1918 static void gamecntl_cmd_FramerateCheat(int argc, char **argv)
1920 cvar_toggle(&r_framerate);
1924 static void gamecntl_cmd_BlueOrbCheat(int argc, char **argv)
1926 if (!check_cheat_enable())
1929 if (Players[Player_num].shields < MAX_SHIELDS)
1931 fix boost = 3*F1_0 + 3*F1_0*(NDL - Difficulty_level);
1933 if (Difficulty_level == 0)
1935 Players[Player_num].shields += boost;
1936 if (Players[Player_num].shields > MAX_SHIELDS)
1937 Players[Player_num].shields = MAX_SHIELDS;
1938 powerup_basic(0, 0, 15, SHIELD_SCORE, "%s %s %d", TXT_SHIELD, TXT_BOOSTED_TO, f2ir(Players[Player_num].shields));
1942 HUD_init_message(TXT_MAXED_OUT,TXT_SHIELD);
1946 static void gamecntl_cmd_BuddyLifeCheat(int argc, char **argv)
1948 if (!check_cheat_enable())
1952 HUD_init_message("What's this? Another buddy bot!");
1957 static void gamecntl_cmd_BuddyDudeCheat(int argc, char **argv)
1959 if (!check_cheat_enable())
1963 cvar_toggle(&Buddy_dude_cheat);
1964 if (Buddy_dude_cheat.intval)
1966 HUD_init_message("%s gets angry!", guidebot_name);
1967 strcpy(guidebot_name, "Wingnut");
1971 strncpy(guidebot_name, real_guidebot_name.string, GUIDEBOT_NAME_LEN);
1972 guidebot_name[GUIDEBOT_NAME_LEN] = 0;
1973 HUD_init_message("%s calms down", guidebot_name);
1978 static void gamecntl_cmd_MonsterCheat(int argc, char **argv)
1980 if (!check_cheat_enable())
1983 Monster_mode = 1 - Monster_mode;
1985 HUD_init_message(Monster_mode?"Oh no, there goes Tokyo!":"What have you done, I'm shrinking!!");
1989 static void gamecntl_cmd_BouncyCheat(int argc, char **argv)
1991 if (!check_cheat_enable())
1994 if (!is_SHAREWARE && !stricmp(argv[0], "ericaanne"))
1996 gamecntl_cmd_LamerCheat(argc, argv);
2001 HUD_init_message("Bouncing weapons!");
2006 static void gamecntl_cmd_LevelWarpCheat(int argc, char **argv)
2013 if (!check_cheat_enable())
2016 if (!is_SHAREWARE && !stricmp(argv[0], "whammazoom"))
2018 gamecntl_cmd_LamerCheat(argc, argv);
2022 //digi_play_sample(SOUND_CHEATER, F1_0);
2023 m.type = NM_TYPE_INPUT; m.text_len = 10; m.text = text;
2024 item = newmenu_do( NULL, TXT_WARP_TO_LEVEL, 1, &m, NULL );
2027 new_level_num = atoi(m.text);
2028 if (new_level_num != 0 && new_level_num >= 0 && new_level_num <= Last_level)
2030 StartNewLevel(new_level_num, 0);
2037 static void gamecntl_cmd_PhysicsCheat(int argc, char **argv)
2039 if (!check_cheat_enable())
2043 if ( Physics_cheat_flag == 0xBADA55 )
2045 Physics_cheat_flag = 0;
2049 Physics_cheat_flag = 0xBADA55;
2051 HUD_init_message("%s %s!", "Ghosty mode", Physics_cheat_flag == 0xBADA55?TXT_ON:TXT_OFF);
2055 static void gamecntl_cmd_TurboCheat(int argc, char **argv)
2057 if (!check_cheat_enable())
2061 Game_turbo_mode ^= 1;
2062 HUD_init_message("%s %s!", "Turbo mode", Game_turbo_mode?TXT_ON:TXT_OFF);
2066 static void gamecntl_cmd_NewLifeCheat(int argc, char **argv)
2068 if (!check_cheat_enable())
2071 if (Players[Player_num].lives >= 50)
2075 Players[Player_num].lives++;
2076 HUD_init_message("Extra life!");
2080 static void gamecntl_cmd_WowieCheat(int argc, char **argv)
2084 if (!check_cheat_enable())
2087 if (!is_SHAREWARE && !stricmp(argv[0], "motherlode"))
2089 gamecntl_cmd_LamerCheat(argc, argv);
2094 HUD_init_message("%s%s", !stricmp(argv[0], "bigred")?"SUPER ":"", TXT_WOWIE_ZOWIE);
2096 Players[Player_num].primary_weapon_flags = HAS_LASER_FLAG | HAS_VULCAN_FLAG | HAS_SPREADFIRE_FLAG;
2097 Players[Player_num].secondary_weapon_flags = HAS_CONCUSSION_FLAG | HAS_HOMING_FLAG | HAS_PROXIMITY_FLAG;
2099 if (!stricmp(argv[0], "bigred"))
2101 Players[Player_num].primary_weapon_flags |= HAS_PLASMA_FLAG | HAS_FUSION_FLAG;
2102 Players[Player_num].secondary_weapon_flags |= HAS_SMART_FLAG | HAS_MEGA_FLAG;
2104 else if (!stricmp(argv[0], "motherlode"))
2106 Players[Player_num].primary_weapon_flags = ~(HAS_FLAG(PHOENIX_INDEX) | HAS_FLAG(OMEGA_INDEX) | HAS_FLAG(FUSION_INDEX));
2107 Players[Player_num].secondary_weapon_flags = ~(HAS_FLAG(SMISSILE4_INDEX) | HAS_FLAG(MEGA_INDEX) | HAS_FLAG(SMISSILE5_INDEX));
2109 else if (!stricmp(argv[0], "honestbob"))
2111 Players[Player_num].primary_weapon_flags = 0xffff;
2112 Players[Player_num].secondary_weapon_flags = 0xffff;
2115 Players[Player_num].primary_weapon_flags &= ~HAS_FLAG(SUPER_LASER_INDEX); // no super laser
2117 for (i = 0; i < (MAX_PRIMARY_WEAPONS); i++)
2118 if (Players[Player_num].primary_weapon_flags & HAS_FLAG(i))
2119 Players[Player_num].primary_ammo[i] = Primary_ammo_max[i];
2121 for (i = 0; i < (EMULATING_D1?5:MAX_SECONDARY_WEAPONS); i++)
2122 if (Players[Player_num].secondary_weapon_flags & HAS_FLAG(i))
2123 Players[Player_num].secondary_ammo[i] = Secondary_ammo_max[i];
2125 if (Game_mode & GM_HOARD)
2126 Players[Player_num].secondary_ammo[PROXIMITY_INDEX] = 12;
2128 if (Newdemo_state == ND_STATE_RECORDING)
2129 newdemo_record_laser_level(Players[Player_num].laser_level, MAX_LASER_LEVEL);
2131 Players[Player_num].energy = EMULATING_D1?INITIAL_ENERGY:MAX_ENERGY;
2132 Players[Player_num].laser_level = EMULATING_D1?MAX_LASER_LEVEL:MAX_SUPER_LASER_LEVEL;
2133 Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS;
2134 update_laser_weapon_info();
2138 static void gamecntl_cmd_AllKeysCheat(int argc, char **argv)
2140 if (!check_cheat_enable())
2143 if (!is_SHAREWARE && !stricmp(argv[0], "currygoat"))
2145 gamecntl_cmd_LamerCheat(argc, argv);
2150 HUD_init_message(TXT_ALL_KEYS);
2151 Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2155 static void gamecntl_cmd_InvulCheat(int argc, char **argv)
2157 if (!check_cheat_enable())
2160 if (!is_SHAREWARE && !stricmp(argv[0], "zingermans"))
2162 gamecntl_cmd_LamerCheat(argc, argv);
2167 Players[Player_num].flags ^= PLAYER_FLAGS_INVULNERABLE;
2168 HUD_init_message("%s %s!", TXT_INVULNERABILITY, (Players[Player_num].flags&PLAYER_FLAGS_INVULNERABLE)?TXT_ON:TXT_OFF);
2169 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2173 static void gamecntl_cmd_CloakCheat(int argc, char **argv)
2175 if (!check_cheat_enable())
2179 Players[Player_num].flags ^= PLAYER_FLAGS_CLOAKED;
2180 HUD_init_message("%s %s!", TXT_CLOAK, (Players[Player_num].flags&PLAYER_FLAGS_CLOAKED)?TXT_ON:TXT_OFF);
2181 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
2182 ai_do_cloak_stuff();
2183 Players[Player_num].cloak_time = GameTime;
2188 static void gamecntl_cmd_ShieldCheat(int argc, char **argv)
2190 if (!check_cheat_enable())
2194 HUD_init_message(TXT_FULL_SHIELDS);
2195 Players[Player_num].shields = INITIAL_SHIELDS;
2199 static void gamecntl_cmd_ExitPathCheat(int argc, char **argv)
2201 if (!check_cheat_enable())
2204 #ifdef SHOW_EXIT_PATH
2205 if (!create_special_path())
2209 HUD_init_message("Exit path illuminated!");
2214 static void gamecntl_cmd_AccessoryCheat(int argc, char **argv)
2216 if (!check_cheat_enable())
2220 Players[Player_num].flags |= PLAYER_FLAGS_HEADLIGHT;
2221 Players[Player_num].flags |= PLAYER_FLAGS_AFTERBURNER;
2222 Players[Player_num].flags |= PLAYER_FLAGS_AMMO_RACK;
2223 Players[Player_num].flags |= PLAYER_FLAGS_CONVERTER;
2225 HUD_init_message ("Accessories!!");
2229 static void gamecntl_cmd_FullMapCheat(int argc, char **argv)
2231 if (!check_cheat_enable())
2234 if (!is_SHAREWARE && !stricmp(argv[0], "joshuaakira"))
2236 gamecntl_cmd_LamerCheat(argc, argv);
2241 Players[Player_num].flags |= PLAYER_FLAGS_MAP_ALL;
2243 HUD_init_message ("Full Map!!");
2247 static void gamecntl_cmd_HomingCheat(int argc, char **argv)
2249 if (!check_cheat_enable())
2252 if (!is_SHAREWARE && !stricmp(argv[0], "eatangelos"))
2254 gamecntl_cmd_LamerCheat(argc, argv);
2263 for (i = 0; i < 20; i++)
2265 OldHomingState[i] = Weapon_info[i].homing_flag;
2266 Weapon_info[i].homing_flag = 1;
2268 HUD_init_message ("Homing weapons!");
2273 static void gamecntl_cmd_KillRobotsCheat(int argc, char **argv)
2275 if (!check_cheat_enable())
2283 static void gamecntl_cmd_FinishLevelCheat(int argc, char **argv)
2285 if (!check_cheat_enable())
2288 kill_and_so_forth();
2292 static void gamecntl_cmd_RobotsKillRobotsCheat(int argc, char **argv)
2294 if (!check_cheat_enable())
2297 Robots_kill_robots_cheat = !Robots_kill_robots_cheat;
2298 if (Robots_kill_robots_cheat)
2300 HUD_init_message("Rabid robots!");
2304 HUD_init_message("Kill the player!");
2308 static void gamecntl_cmd_RobotFiringCheat(int argc, char **argv)
2310 if (!check_cheat_enable())
2313 Robot_firing_enabled = !Robot_firing_enabled;
2314 if (!Robot_firing_enabled)
2316 HUD_init_message("%s", "Robot firing OFF!");
2320 HUD_init_message("%s", "Robot firing ON!");
2324 static void gamecntl_cmd_RapidFireCheat(int argc, char **argv)
2326 if (!check_cheat_enable())
2329 if (Laser_rapid_fire)
2331 Laser_rapid_fire = 0;
2332 HUD_init_message("%s", "Rapid fire OFF!");
2336 Laser_rapid_fire = 0xbada55;
2338 HUD_init_message("%s", "Rapid fire ON!");
2343 static void gamecntl_cmd_JohnCheat1(int argc, char **argv)
2345 if (!check_cheat_enable())
2349 do_controlcen_destroyed_stuff(NULL);
2353 static void gamecntl_cmd_JohnCheat2(int argc, char **argv)
2355 if (!check_cheat_enable())
2359 Laser_rapid_fire = 0xbada55;
2360 do_megawow_powerup(200);
2365 extern void do_lunacy_on(void);
2366 extern void do_lunacy_off(void);
2369 static void gamecntl_cmd_JohnCheat3(int argc, char **argv)
2371 if (!check_cheat_enable())
2376 HUD_init_message( TXT_NO_LUNACY );
2380 HUD_init_message( TXT_LUNACY );
2385 extern int Ugly_robot_cheat, Ugly_robot_texture;
2387 static void gamecntl_cmd_JohnCheat4(int argc, char **argv)
2389 if (!check_cheat_enable())
2395 Ugly_robot_texture = atoi(argv[1]);
2397 if (Ugly_robot_texture == 999)
2399 Ugly_robot_cheat = 0;
2400 HUD_init_message( TXT_ROBOT_PAINTING_OFF );
2404 HUD_init_message( TXT_ROBOT_PAINTING_ON, Ugly_robot_texture );
2405 Ugly_robot_cheat = 0xbada55;
2407 mprintf((0, "Paint value = %i\n", Ugly_robot_texture));
2411 #define CHEATSPOT 14
2416 const char string[CHEATEND];
2417 cmd_handler_t cheat_cmd;
2420 static const struct cheat_code Cheats[] = {
2421 { "gabbagabbahey", gamecntl_cmd_EnableCheats },
2422 { "scourge", gamecntl_cmd_WowieCheat },
2423 { "mitzi", gamecntl_cmd_AllKeysCheat },
2424 { "racerx", gamecntl_cmd_InvulCheat },
2425 { "guile", gamecntl_cmd_CloakCheat },
2426 { "twilight", gamecntl_cmd_ShieldCheat },
2427 { "farmerjoe", gamecntl_cmd_LevelWarpCheat },
2428 { "astral", gamecntl_cmd_PhysicsCheat },
2430 { "buggin", gamecntl_cmd_TurboCheat },
2431 { "bigred", gamecntl_cmd_WowieCheat },
2432 { "bruin", gamecntl_cmd_NewLifeCheat },
2433 { "flash", gamecntl_cmd_ExitPathCheat },
2434 { "ahimsa", gamecntl_cmd_RobotFiringCheat },
2436 { "poboys", gamecntl_cmd_JohnCheat1 },
2437 { "porgys", gamecntl_cmd_JohnCheat2 },
2438 { "lunacy", gamecntl_cmd_JohnCheat3 },
2439 { "pletch", gamecntl_cmd_JohnCheat4 },
2441 { "motherlode", gamecntl_cmd_WowieCheat },
2442 { "currygoat", gamecntl_cmd_AllKeysCheat },
2443 { "zingermans", gamecntl_cmd_InvulCheat },
2444 { "eatangelos", gamecntl_cmd_HomingCheat },
2445 { "ericaanne", gamecntl_cmd_BouncyCheat },
2446 { "joshuaakira", gamecntl_cmd_FullMapCheat },
2447 { "whammazoom", gamecntl_cmd_LevelWarpCheat },
2449 { "pigfarmer", gamecntl_cmd_JohnHeadCheat },
2450 { "bittersweet", gamecntl_cmd_AcidCheat },
2451 { "frametime", gamecntl_cmd_FramerateCheat },
2452 { "blueorb", gamecntl_cmd_BlueOrbCheat },
2453 { "helpvishnu", gamecntl_cmd_BuddyLifeCheat },
2454 { "gowingnut", gamecntl_cmd_BuddyDudeCheat },
2455 { "godzilla", gamecntl_cmd_MonsterCheat },
2456 { "duddaboo", gamecntl_cmd_BouncyCheat },
2457 { "freespace", gamecntl_cmd_LevelWarpCheat },
2458 { "honestbob", gamecntl_cmd_WowieCheat },
2459 { "oralgroove", gamecntl_cmd_AllKeysCheat },
2460 { "almighty", gamecntl_cmd_InvulCheat },
2461 { "alifalafel", gamecntl_cmd_AccessoryCheat },
2462 { "rockrgrl", gamecntl_cmd_FullMapCheat },
2463 { "lpnlizard", gamecntl_cmd_HomingCheat },
2464 { "spaniard", gamecntl_cmd_KillRobotsCheat },
2465 { "delshiftb", gamecntl_cmd_FinishLevelCheat },
2466 { "silkwing", gamecntl_cmd_RobotsKillRobotsCheat },
2467 { "imagespace", gamecntl_cmd_RobotFiringCheat },
2468 { "wildfire", gamecntl_cmd_RapidFireCheat },
2470 #define N_CHEATS (sizeof(Cheats) / sizeof(struct cheat_code))
2473 // Main Cheat function
2475 char CheatBuffer[]="AAAAAAAAAAAAAAA";
2477 void FinalCheats(int key)
2481 key = key_to_ascii(key);
2483 for (i = 0; i < 15; i++)
2484 CheatBuffer[i] = CheatBuffer[i+1];
2486 CheatBuffer[CHEATSPOT] = key;
2488 if (!strnicmp(&CheatBuffer[CHEATEND-9], "pletch", 6))
2489 cmd_appendf("pletch %d", atoi(&CheatBuffer[CHEATEND-3]));
2491 for (i = 0; i < N_CHEATS; i++)
2492 if (!stricmp(&CheatBuffer[CHEATEND-strlen(Cheats[i].string)], Cheats[i].string))
2493 cmd_append(&CheatBuffer[CHEATEND-strlen(Cheats[i].string)]);
2497 // Internal Cheat Menu
2499 void do_cheat_menu()
2502 newmenu_item mm[16];
2503 char score_text[21];
2505 sprintf( score_text, "%d", Players[Player_num].score );
2507 mm[0].type=NM_TYPE_CHECK; mm[0].value=Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE; mm[0].text="Invulnerability";
2508 mm[1].type=NM_TYPE_CHECK; mm[1].value=Players[Player_num].flags & PLAYER_FLAGS_CLOAKED; mm[1].text="Cloaked";
2509 mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="All keys";
2510 mm[3].type=NM_TYPE_NUMBER; mm[3].value=f2i(Players[Player_num].energy); mm[3].text="% Energy"; mm[3].min_value=0; mm[3].max_value=200;
2511 mm[4].type=NM_TYPE_NUMBER; mm[4].value=f2i(Players[Player_num].shields); mm[4].text="% Shields"; mm[4].min_value=0; mm[4].max_value=200;
2512 mm[5].type=NM_TYPE_TEXT; mm[5].text = "Score:";
2513 mm[6].type=NM_TYPE_INPUT; mm[6].text_len = 10; mm[6].text = score_text;
2514 //mm[7].type=NM_TYPE_RADIO; mm[7].value=(Players[Player_num].laser_level==0); mm[7].group=0; mm[7].text="Laser level 1";
2515 //mm[8].type=NM_TYPE_RADIO; mm[8].value=(Players[Player_num].laser_level==1); mm[8].group=0; mm[8].text="Laser level 2";
2516 //mm[9].type=NM_TYPE_RADIO; mm[9].value=(Players[Player_num].laser_level==2); mm[9].group=0; mm[9].text="Laser level 3";
2517 //mm[10].type=NM_TYPE_RADIO; mm[10].value=(Players[Player_num].laser_level==3); mm[10].group=0; mm[10].text="Laser level 4";
2519 mm[7].type=NM_TYPE_NUMBER; mm[7].value=Players[Player_num].laser_level+1; mm[7].text="Laser Level"; mm[7].min_value=0; mm[7].max_value=MAX_SUPER_LASER_LEVEL+1;
2520 mm[8].type=NM_TYPE_NUMBER; mm[8].value=Players[Player_num].secondary_ammo[CONCUSSION_INDEX]; mm[8].text="Missiles"; mm[8].min_value=0; mm[8].max_value=200;
2522 mmn = newmenu_do("Wimp Menu",NULL,9, mm, NULL );
2525 if ( mm[0].value ) {
2526 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
2527 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2529 Players[Player_num].flags &= ~PLAYER_FLAGS_INVULNERABLE;
2530 if ( mm[1].value ) {
2531 Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
2533 if (Game_mode & GM_MULTI)
2536 ai_do_cloak_stuff();
2537 Players[Player_num].cloak_time = GameTime;
2540 Players[Player_num].flags &= ~PLAYER_FLAGS_CLOAKED;
2542 if (mm[2].value) Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2543 Players[Player_num].energy=i2f(mm[3].value);
2544 Players[Player_num].shields=i2f(mm[4].value);
2545 Players[Player_num].score = atoi(mm[6].text);
2546 //if (mm[7].value) Players[Player_num].laser_level=0;
2547 //if (mm[8].value) Players[Player_num].laser_level=1;
2548 //if (mm[9].value) Players[Player_num].laser_level=2;
2549 //if (mm[10].value) Players[Player_num].laser_level=3;
2550 Players[Player_num].laser_level = mm[7].value-1;
2551 Players[Player_num].secondary_ammo[CONCUSSION_INDEX] = mm[8].value;
2559 // Testing functions ----------------------------------------------------------
2562 void speedtest_init(void)
2564 Speedtest_start_time = timer_get_fixed_seconds();
2566 Speedtest_segnum = 0;
2567 Speedtest_sidenum = 0;
2568 Speedtest_frame_start = FrameCount;
2570 mprintf((0, "Starting speedtest. Will be %i frames. Each . = 10 frames.\n", Highest_segment_index+1));
2573 void speedtest_frame(void)
2575 vms_vector view_dir, center_point;
2577 Speedtest_sidenum=Speedtest_segnum % MAX_SIDES_PER_SEGMENT;
2579 compute_segment_center(&Viewer->pos, &Segments[Speedtest_segnum]);
2580 Viewer->pos.x += 0x10; Viewer->pos.y -= 0x10; Viewer->pos.z += 0x17;
2582 obj_relink(OBJECT_NUMBER(Viewer), Speedtest_segnum);
2583 compute_center_point_on_side(¢er_point, &Segments[Speedtest_segnum], Speedtest_sidenum);
2584 vm_vec_normalized_dir_quick(&view_dir, ¢er_point, &Viewer->pos);
2585 vm_vector_2_matrix(&Viewer->orient, &view_dir, NULL, NULL);
2587 if (((FrameCount - Speedtest_frame_start) % 10) == 0)
2592 if (Speedtest_segnum > Highest_segment_index) {
2595 sprintf(msg, "\nSpeedtest done: %i frames, %7.3f seconds, %7.3f frames/second.\n",
2596 FrameCount-Speedtest_frame_start,
2597 f2fl(timer_get_fixed_seconds() - Speedtest_start_time),
2598 (float) (FrameCount-Speedtest_frame_start) / f2fl(timer_get_fixed_seconds() - Speedtest_start_time));
2600 mprintf((0, "%s", msg));
2601 HUD_init_message(msg);
2604 if (Speedtest_count == 0)
2613 // Sounds for testing
2615 int test_sound_num = 0;
2616 int sound_nums[] = {10,11,20,21,30,31,32,33,40,41,50,51,60,61,62,70,80,81,82,83,90,91};
2618 #define N_TEST_SOUNDS (sizeof(sound_nums) / sizeof(*sound_nums))
2621 void advance_sound()
2623 if (++test_sound_num == N_TEST_SOUNDS)
2629 int Test_sound = 251;
2631 void play_test_sound()
2634 // -- digi_play_sample(sound_nums[test_sound_num], F1_0);
2635 digi_play_sample(Test_sound, F1_0);
2638 #endif //ifndef NDEBUG
2648 static ubyte exploding_flag=0;
2650 Player_fired_laser_this_frame=-1;
2652 if (!Endlevel_sequence) // && !Player_is_dead //this was taken out of the if statement by WraithX
2655 if ( (Newdemo_state == ND_STATE_PLAYBACK) || DefiningMarkerMessage
2657 || multi_sending_message || multi_defining_message
2659 ) // WATCH OUT!!! WEIRD CODE ABOVE!!!
2660 memset( &Controls, 0, sizeof(control_info) );
2662 controls_read_all();
2666 // If automap key pressed, enable automap unless you are in network mode, control center destroyed and < 10 seconds left
2667 if ( Controls.count[automap] && !((Game_mode & GM_MULTI) && Control_center_destroyed && (Countdown_seconds_left < 10)))
2674 if (Player_exploded) { //Player_is_dead && (ConsoleObject->flags & OF_EXPLODING) ) {
2676 if (exploding_flag==0) {
2677 exploding_flag = 1; // When player starts exploding, clear all input devices...
2678 game_flush_inputs();
2681 //if (key_down_count(KEY_BACKSP))
2683 //if (key_down_count(KEY_PRINT_SCREEN))
2684 // save_screen_shot(0);
2687 for (i = 0; i < 4; i++)
2688 // the following "if" added by WraithX, 4/17/00
2689 if (1) //isJoyRotationKey(i) != 1)
2691 if (joy_get_button_down_cnt(i) > 0)
2692 Death_sequence_aborted = 1;
2693 }// end "if" added by WraithX
2695 if (joy_get_any_button_down_cnt() > 0)
2696 Death_sequence_aborted = 1;
2698 for (i = 0; i < 3; i++)
2699 // the following "if" added by WraithX, 4/17/00
2700 if (1) //isMouseRotationKey(i) != 1)
2702 if (mouse_button_down_count(i) > 0)
2703 Death_sequence_aborted = 1;
2704 }// end "if" added by WraithX
2706 //for (i = 0; i < 256; i++)
2707 // // the following "if" added by WraithX, 4/17/00
2708 // if (isKeyboardRotationKey(i) != 1)
2710 // if (!key_isfunc(i) && !key_ismod(i) && key_down_count(i) > 0)
2711 // Death_sequence_aborted = 1;
2712 // }// end "if" added by WraithX
2714 if (Death_sequence_aborted)
2715 game_flush_inputs();
2721 if (Newdemo_state == ND_STATE_PLAYBACK )
2724 while ((key=key_inkey_time(&key_time)) != 0) {
2726 if (DefiningMarkerMessage)
2728 MarkerInputMessage (key);
2733 if ( (Game_mode&GM_MULTI) && (multi_sending_message || multi_defining_message )) {
2734 multi_message_input_sub( key );
2735 continue; //get next key
2741 if ((key&KEY_DEBUGGED)&&(Game_mode&GM_MULTI)) {
2742 Network_message_reciever = 100; // Send to everyone...
2743 sprintf( Network_message, "%s %s", TXT_I_AM_A, TXT_CHEATER);
2748 if(!con_key_handler(key))
2752 HandleDeathKey(key);
2754 if (Endlevel_sequence)
2755 HandleEndlevelKey(key);
2756 else if (Newdemo_state == ND_STATE_PLAYBACK ) {
2765 HandleSystemKey(key);
2776 // if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[KEY_F8] && (keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT]))
2777 // transfer_energy_to_shield(key_down_time(KEY_F8));
2781 void gamecntl_init(void)
2785 for (i = 0; i < N_CHEATS; i++)
2786 cmd_addcommand(Cheats[i].string, Cheats[i].cheat_cmd, "");
2789 cmd_addcommand("kill", gamecntl_cmd_kill, "");
2792 cvar_registervariable(&Buddy_dude_cheat);