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 snprintf(str, 8, "%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 if (Newdemo_state != ND_STATE_PLAYBACK)
460 mouse_set_mode(Config_control_mouse.intval);
461 newmenu_hide_cursor();
476 MAC(delay(500);) // delay 1/2 second because of dumb redbook problem
481 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) );
482 extern int network_who_is_master(void), network_how_many_connected(void), GetMyNetRanking(void);
483 extern int TotalMissedPackets,TotalPacketsGot;
484 extern char Pauseable_menu;
485 char *NetworkModeNames[]={"Anarchy","Team Anarchy","Robo Anarchy","Cooperative","Capture the Flag","Hoard","Team Hoard","Unknown"};
486 extern char *RankStrings[];
487 extern int PhallicLimit,PhallicMan;
490 void do_show_netgame_help()
498 char *eff_strings[]={"trashing","really hurting","seriously effecting","hurting",
499 "effecting","tarnishing"};
503 m[i].text=(char *)&mtext[i];
504 m[i].type=NM_TYPE_TEXT;
507 sprintf (mtext[num],"Game: %s",Netgame.game_name); num++;
508 sprintf (mtext[num],"Mission: %s",Netgame.mission_title); num++;
509 sprintf (mtext[num],"Current Level: %d",Netgame.levelnum); num++;
510 sprintf (mtext[num],"Difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty)); num++;
511 sprintf (mtext[num],"Game Mode: %s",NetworkModeNames[Netgame.gamemode]); num++;
512 sprintf (mtext[num],"Game Master: %s",Players[network_who_is_master()].callsign); num++;
513 sprintf (mtext[num],"Number of players: %d/%d",network_how_many_connected(),Netgame.max_numplayers); num++;
514 sprintf (mtext[num],"Packets per second: %d",Netgame.PacketsPerSec); num++;
515 sprintf (mtext[num],"Short Packets: %s",Netgame.ShortPackets?"Yes":"No"); num++;
518 pl=(int)(((float)TotalMissedPackets/(float)TotalPacketsGot)*100.0);
521 sprintf (mtext[num],"Packets lost: %d (%d%%)",TotalMissedPackets,pl); num++;
524 if (Netgame.KillGoal)
525 { sprintf (mtext[num],"Kill goal: %d",Netgame.KillGoal*5); num++; }
527 sprintf (mtext[num]," "); num++;
528 sprintf (mtext[num],"Connected players:"); num++;
530 NetPlayers.players[Player_num].rank=GetMyNetRanking();
532 for (i=0;i<N_players;i++)
533 if (Players[i].connected)
535 if (!FindArg ("-norankings"))
538 sprintf (mtext[num],"%s%s (%d/%d)",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,Netlife_kills,Netlife_killed);
540 sprintf (mtext[num],"%s%s %d/%d",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,kill_matrix[Player_num][i],
541 kill_matrix[i][Player_num]);
545 sprintf (mtext[num++],"%s",Players[i].callsign);
549 sprintf (mtext[num]," "); num++;
551 eff=(int)((float)((float)Netlife_kills/((float)Netlife_killed+(float)Netlife_kills))*100.0);
556 if (Game_mode & GM_HOARD)
559 sprintf (mtext[num],"There is no record yet for this level.");
561 sprintf (mtext[num],"%s has the record at %d points.",Players[PhallicMan].callsign,PhallicLimit);
564 else if (!FindArg ("-norankings"))
568 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
569 sprintf (mtext[num],"is %s your ranking.",eff_strings[eff/10]); num++;
573 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
574 sprintf (mtext[num],"is serving you well."); num++;
582 newmenu_dotiny2( NULL, "Netgame Information", num, m, NULL);
588 void HandleEndlevelKey(int key)
590 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) )
593 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
596 if (key==KEY_PRINT_SCREEN)
599 if ( key == (KEY_COMMAND+KEY_P) )
600 key = do_game_pause();
602 if (key == KEY_PAUSE)
603 key = do_game_pause(); //so esc from pause will end level
605 if (key == KEY_ESC) {
606 stop_endlevel_sequence();
607 last_drawn_cockpit[0]=-1;
608 last_drawn_cockpit[1]=-1;
612 if (key == KEY_BACKSP)
616 void HandleDeathKey(int key)
619 Commented out redundant calls because the key used here typically
620 will be passed to HandleSystemKey later. Note that I do this to pause
621 which is supposed to pass the ESC key to leave the level. This
622 doesn't work in the DOS version anyway. -Samir
625 if (Player_exploded && !key_isfunc(key) && !key_ismod(key))
626 Death_sequence_aborted = 1; //Any key but func or modifier aborts
628 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) ) {
629 // save_screen_shot(0);
630 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
633 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
636 if (key==KEY_PRINT_SCREEN) {
637 // save_screen_shot(0);
638 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
641 if ( key == (KEY_COMMAND+KEY_P) ) {
642 // key = do_game_pause();
643 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
646 if (key == KEY_PAUSE) {
647 // key = do_game_pause(); //so esc from pause will end level
648 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
651 if (key == KEY_ESC) {
652 if (ConsoleObject->flags & OF_EXPLODING)
653 Death_sequence_aborted = 1;
656 if (key == KEY_BACKSP) {
657 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
661 //don't abort death sequence for netgame join/refuse keys
662 if ( (key == KEY_ALTED + KEY_1) ||
663 (key == KEY_ALTED + KEY_2))
664 Death_sequence_aborted = 0;
666 if (Death_sequence_aborted)
671 void HandleDemoKey(int key)
676 if (!(Guided_missile[Player_num] &&
677 Guided_missile[Player_num]->type == OBJ_WEAPON &&
678 Guided_missile[Player_num]->id == GUIDEDMISS_ID &&
679 Guided_missile[Player_num]->signature == Guided_missile_sig[Player_num] &&
680 Guided_in_big_window.intval))
684 case KEY_COMMAND+KEY_2:
685 case KEY_F2: Config_menu_flag = 1; break;
687 case KEY_COMMAND+KEY_7:
690 Show_kill_list = (Show_kill_list+1) % ((Newdemo_game_mode & GM_TEAM) ? 4 : 3);
694 Function_mode = FMODE_MENU;
697 Newdemo_vcr_state = ND_STATE_PLAYBACK;
700 Newdemo_vcr_state = ND_STATE_PAUSED;
703 newdemo_single_frame_time = timer_get_fixed_seconds();
704 Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
707 newdemo_single_frame_time = timer_get_fixed_seconds();
708 Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
710 case KEY_CTRLED + KEY_RIGHT:
713 case KEY_CTRLED + KEY_LEFT:
714 newdemo_goto_beginning();
717 case KEY_COMMAND+KEY_P:
722 case KEY_COMMAND + KEY_SHIFTED + KEY_3:
723 case KEY_PRINT_SCREEN: {
726 old_state = Newdemo_vcr_state;
727 Newdemo_vcr_state = ND_STATE_PRINTSCREEN;
728 game_render_frame_mono();
730 Newdemo_vcr_state = old_state;
734 case KEY_COMMAND+KEY_Q:
735 if ( !(Game_mode & GM_MULTI) )
743 case KEY_DEBUGGED + KEY_I:
744 Newdemo_do_interpolate = !Newdemo_do_interpolate;
745 if (Newdemo_do_interpolate)
746 mprintf ((0, "demo playback interpolation now on\n"));
748 mprintf ((0, "demo playback interpolation now off\n"));
750 case KEY_DEBUGGED + KEY_K: {
752 char filename[FILENAME_LEN], num[16];
756 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "output file name";
757 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 8; m[1].text = filename;
758 c = newmenu_do( NULL, NULL, 2, m, NULL );
761 strcat(filename, ".dem");
763 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "strip how many bytes";
764 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 16; m[1].text = num;
765 c = newmenu_do( NULL, NULL, 2, m, NULL );
768 how_many = atoi(num);
771 newdemo_strip_frames(filename, how_many);
780 //switch a cockpit window to the next function
781 int select_next_window_function(int w)
783 Assert(w==0 || w==1);
785 switch (Cockpit_3d_view[w].intval) {
787 cvar_setint(&Cockpit_3d_view[w], CV_REAR);
791 cvar_setint(&Cockpit_3d_view[w], CV_ESCORT);
794 //if no ecort, fall through
796 Coop_view_player[w] = -1; //force first player
800 Marker_viewer_num[w] = -1;
801 if ((Game_mode & GM_MULTI_COOP) || (Game_mode & GM_TEAM)) {
802 cvar_setint(&Cockpit_3d_view[w], CV_COOP);
804 Coop_view_player[w]++;
805 if (Coop_view_player[w] == N_players) {
806 cvar_setint(&Cockpit_3d_view[w], CV_MARKER);
809 if (Coop_view_player[w]==Player_num)
812 if (Game_mode & GM_MULTI_COOP)
814 else if (get_team(Coop_view_player[w]) == get_team(Player_num))
819 //if not multi, fall through
822 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) && Netgame.Allow_marker_view) { //anarchy only
823 cvar_setint(&Cockpit_3d_view[w], CV_MARKER);
824 if (Marker_viewer_num[w] == -1)
825 Marker_viewer_num[w] = Player_num * 2;
826 else if (Marker_viewer_num[w] == Player_num * 2)
827 Marker_viewer_num[w]++;
829 cvar_setint(&Cockpit_3d_view[w], CV_NONE);
833 cvar_setint(&Cockpit_3d_view[w], CV_NONE);
838 return 1; //screen_changed
841 extern int Game_paused;
843 void songs_goto_next_song(void);
844 void songs_goto_prev_song(void);
846 #ifdef DOOR_DEBUGGING
847 dump_door_debugging_info()
857 obj = &Objects[Players[Player_num].objnum];
858 vm_vec_scale_add(&new_pos,&obj->pos,&obj->orient.fvec,i2f(100));
861 fq.startseg = obj->segnum;
864 fq.thisobjnum = Players[Player_num].objnum;
865 fq.ignore_obj_list = NULL;
868 fate = find_vector_intersection(&fq,&hit_info);
870 dfile = fopen("door.out","at");
872 fprintf(dfile,"FVI hit_type = %d\n",fate);
873 fprintf(dfile," hit_seg = %d\n",hit_info.hit_seg);
874 fprintf(dfile," hit_side = %d\n",hit_info.hit_side);
875 fprintf(dfile," hit_side_seg = %d\n",hit_info.hit_side_seg);
878 if (fate == HIT_WALL) {
880 wall_num = Segments[hit_info.hit_seg].sides[hit_info.hit_side].wall_num;
881 fprintf(dfile,"wall_num = %d\n",wall_num);
883 if (wall_num != -1) {
884 wall *wall = &Walls[wall_num];
888 fprintf(dfile," segnum = %d\n",wall->segnum);
889 fprintf(dfile," sidenum = %d\n",wall->sidenum);
890 fprintf(dfile," hps = %x\n",wall->hps);
891 fprintf(dfile," linked_wall = %d\n",wall->linked_wall);
892 fprintf(dfile," type = %d\n",wall->type);
893 fprintf(dfile," flags = %x\n",wall->flags);
894 fprintf(dfile," state = %d\n",wall->state);
895 fprintf(dfile," trigger = %d\n",wall->trigger);
896 fprintf(dfile," clip_num = %d\n",wall->clip_num);
897 fprintf(dfile," keys = %x\n",wall->keys);
898 fprintf(dfile," controlling_trigger = %d\n",wall->controlling_trigger);
899 fprintf(dfile," cloak_value = %d\n",wall->cloak_value);
903 for (i=0;i<Num_open_doors;i++) { //find door
905 if (d->front_wallnum[0] == WALL_NUMBER(wall) ||
906 d->back_wallnum[0] == WALL_NUMBER(wall) ||
907 (d->n_parts==2 && (d->front_wallnum[1] == WALL_NUMBER(wall) ||
908 d->back_wallnum[1] == WALL_NUMBER(wall))))
912 if (i>=Num_open_doors)
913 fprintf(dfile,"No active door.\n");
915 fprintf(dfile,"Active door %d:\n",i);
916 fprintf(dfile," n_parts = %d\n",d->n_parts);
917 fprintf(dfile," front_wallnum = %d,%d\n",d->front_wallnum[0],d->front_wallnum[1]);
918 fprintf(dfile," back_wallnum = %d,%d\n",d->back_wallnum[0],d->back_wallnum[1]);
919 fprintf(dfile," time = %x\n",d->time);
934 //this is for system-level keys, such as help, etc.
935 //returns 1 if screen changed
936 int HandleSystemKey(int key)
938 int screen_changed=0;
943 #ifdef DOOR_DEBUGGING
944 case KEY_LAPOSTRO+KEY_SHIFTED:
945 dump_door_debugging_info();
954 Function_mode = FMODE_MENU;
958 // fleshed these out because F1 and F2 aren't sequenctial keycodes on mac -- MWA
960 case KEY_COMMAND+KEY_SHIFTED+KEY_1:
961 case KEY_SHIFTED+KEY_F1:
962 screen_changed = select_next_window_function(0);
964 case KEY_COMMAND+KEY_SHIFTED+KEY_2:
965 case KEY_SHIFTED+KEY_F2:
966 screen_changed = select_next_window_function(1);
973 case KEY_SHIFTED + KEY_ESC:
977 case KEY_SHIFTED + KEY_ESC: //quick exit
979 if (! SafetyCheck()) break;
980 close_editor_screen();
984 Function_mode=FMODE_EXIT;
988 case KEY_COMMAND+KEY_P:
990 do_game_pause(); break;
992 case KEY_COMMAND + KEY_SHIFTED + KEY_3:
993 case KEY_PRINT_SCREEN: save_screen_shot(0); break;
995 case KEY_COMMAND+KEY_1:
996 case KEY_F1: do_show_help(); break;
998 case KEY_COMMAND+KEY_2:
999 case KEY_F2: //Config_menu_flag = 1; break;
1001 if (!(Game_mode&GM_MULTI)) {palette_save(); apply_modified_palette(); reset_palette_add(); gr_palette_load(gr_palette); }
1003 if (!(Game_mode&GM_MULTI)) palette_restore();
1007 case KEY_COMMAND+KEY_3:
1009 if (!(Guided_missile[Player_num] &&
1010 Guided_missile[Player_num]->type == OBJ_WEAPON &&
1011 Guided_missile[Player_num]->id == GUIDEDMISS_ID &&
1012 Guided_missile[Player_num]->signature == Guided_missile_sig[Player_num] &&
1013 Guided_in_big_window.intval))
1015 toggle_cockpit(); screen_changed=1;
1019 case KEY_COMMAND+KEY_SHIFTED+KEY_7:
1020 case KEY_F7+KEY_SHIFTED: palette_save(); joydefs_calibrate(); palette_restore(); break;
1022 case KEY_COMMAND+KEY_5:
1024 if ( Newdemo_state == ND_STATE_RECORDING )
1025 newdemo_stop_recording();
1026 else if ( Newdemo_state == ND_STATE_NORMAL )
1027 if (!Game_paused) //can't start demo while paused
1028 newdemo_start_recording();
1031 case KEY_COMMAND+KEY_ALTED+KEY_4:
1032 case KEY_ALTED+KEY_F4:
1034 Show_reticle_name = (Show_reticle_name+1)%2;
1038 case KEY_COMMAND + KEY_6:
1040 if (!Player_is_dead && !(Game_mode & GM_MULTI))
1042 int rsave, gsave, bsave;
1043 rsave = PaletteRedAdd;
1044 gsave = PaletteGreenAdd;
1045 bsave = PaletteBlueAdd;
1047 full_palette_save();
1048 PaletteRedAdd = rsave;
1049 PaletteGreenAdd = gsave;
1050 PaletteBlueAdd = bsave;
1051 state_save_all(0, 0, NULL, 1); // 0 means not between levels.
1057 case KEY_COMMAND+KEY_7:
1059 Show_kill_list = (Show_kill_list+1) % ((Game_mode & GM_TEAM) ? 4 : 3);
1060 if (Game_mode & GM_MULTI)
1061 multi_sort_kill_list();
1064 case KEY_COMMAND+KEY_8:
1066 multi_send_message_start();
1073 multi_send_macro(key);
1074 break; // send taunt macros
1076 case KEY_9 + KEY_COMMAND:
1077 multi_send_macro(KEY_F9);
1079 case KEY_0 + KEY_COMMAND:
1080 multi_send_macro(KEY_F10);
1082 case KEY_1 + KEY_COMMAND + KEY_CTRLED:
1083 multi_send_macro(KEY_F11);
1085 case KEY_2 + KEY_COMMAND + KEY_CTRLED:
1086 multi_send_macro(KEY_F12);
1089 case KEY_SHIFTED + KEY_F9:
1090 case KEY_SHIFTED + KEY_F10:
1091 case KEY_SHIFTED + KEY_F11:
1092 case KEY_SHIFTED + KEY_F12:
1093 multi_define_macro(key);
1094 break; // redefine taunt macros
1096 case KEY_9 + KEY_SHIFTED + KEY_COMMAND:
1097 multi_define_macro(KEY_F9);
1099 case KEY_0 + KEY_SHIFTED + KEY_COMMAND:
1100 multi_define_macro(KEY_F10);
1102 case KEY_1 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1103 multi_define_macro(KEY_F11);
1105 case KEY_2 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1106 multi_define_macro(KEY_F12);
1110 case KEY_COMMAND+KEY_S:
1111 case KEY_COMMAND+KEY_ALTED+KEY_2:
1112 case KEY_ALTED+KEY_F2:
1113 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1114 int rsave, gsave, bsave;
1115 rsave = PaletteRedAdd;
1116 gsave = PaletteGreenAdd;
1117 bsave = PaletteBlueAdd;
1119 full_palette_save();
1120 PaletteRedAdd = rsave;
1121 PaletteGreenAdd = gsave;
1122 PaletteBlueAdd = bsave;
1123 state_save_all(0, 0, NULL, 0); // 0 means not between levels.
1128 case KEY_COMMAND+KEY_O:
1129 case KEY_COMMAND+KEY_ALTED+KEY_3:
1130 case KEY_ALTED+KEY_F3:
1131 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1132 full_palette_save();
1133 state_restore_all(1, 0, NULL);
1139 case KEY_COMMAND+KEY_SHIFTED+KEY_4:
1140 case KEY_F4 + KEY_SHIFTED:
1144 case KEY_COMMAND+KEY_SHIFTED+KEY_ALTED+KEY_4:
1145 case KEY_F4 + KEY_SHIFTED + KEY_ALTED:
1146 change_guidebot_name();
1149 case KEY_MINUS + KEY_ALTED: songs_goto_prev_song(); break;
1150 case KEY_EQUAL + KEY_ALTED: songs_goto_next_song(); break;
1154 case KEY_COMMAND+KEY_M:
1155 if ( (Game_mode & GM_MULTI) ) // don't process in multiplayer games
1158 key_close(); // no processing of keys with keyboard handler.. jeez
1160 show_boxed_message ("Mounting CD\nESC to quit");
1161 RBAMountDisk(); // OS has totaly control of the CD.
1162 if (Function_mode == FMODE_MENU)
1163 songs_play_song(SONG_TITLE,1);
1164 else if (Function_mode == FMODE_GAME)
1165 songs_play_level_song( Current_level_num );
1166 clear_boxed_message();
1172 case KEY_COMMAND+KEY_E:
1173 songs_stop_redbook();
1177 case KEY_COMMAND+KEY_RIGHT:
1178 songs_goto_next_song();
1180 case KEY_COMMAND+KEY_LEFT:
1181 songs_goto_prev_song();
1183 case KEY_COMMAND+KEY_UP:
1184 songs_play_level_song(1);
1186 case KEY_COMMAND+KEY_DOWN:
1187 songs_stop_redbook();
1191 case KEY_COMMAND+KEY_Q:
1192 if ( !(Game_mode & GM_MULTI) )
1196 //added 8/23/99 by Matt Mueller for hot key res/fullscreen changing, and menu access
1197 case KEY_CTRLED+KEY_SHIFTED+KEY_PADDIVIDE:
1198 case KEY_ALTED+KEY_CTRLED+KEY_PADDIVIDE:
1199 case KEY_ALTED+KEY_SHIFTED+KEY_PADDIVIDE:
1203 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMULTIPLY:
1204 case KEY_ALTED+KEY_CTRLED+KEY_PADMULTIPLY:
1205 case KEY_ALTED+KEY_SHIFTED+KEY_PADMULTIPLY:
1208 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMINUS:
1209 case KEY_ALTED+KEY_CTRLED+KEY_PADMINUS:
1210 case KEY_ALTED+KEY_SHIFTED+KEY_PADMINUS:
1212 //should we just cycle through the list that is displayed in the res change menu?
1213 // what if their card/X/etc can't handle that mode? hrm.
1214 //well, the quick access to the menu is good enough for now.
1216 case KEY_CTRLED+KEY_SHIFTED+KEY_PADPLUS:
1217 case KEY_ALTED+KEY_CTRLED+KEY_PADPLUS:
1218 case KEY_ALTED+KEY_SHIFTED+KEY_PADPLUS:
1222 case KEY_COMMAND+KEY_SHIFTED+KEY_F:
1223 case KEY_ALTED+KEY_ENTER:
1224 case KEY_ALTED+KEY_PADENTER:
1225 game_toggle_fullscreen();
1229 //added 11/01/98 Matt Mueller
1231 case KEY_CTRLED+KEY_ALTED+KEY_LAPOSTRO:
1242 return screen_changed;
1246 void HandleVRKey(int key)
1250 case KEY_ALTED+KEY_F5:
1251 if ( VR_render_mode != VR_NONE ) {
1253 HUD_init_message( "-Stereoscopic Parameters Reset-" );
1254 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1255 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1259 case KEY_ALTED+KEY_F6:
1260 if ( VR_render_mode != VR_NONE ) {
1262 if ( VR_low_res > 3 ) VR_low_res = 0;
1263 switch( VR_low_res ) {
1264 case 0: HUD_init_message( "Normal Resolution" ); break;
1265 case 1: HUD_init_message( "Low Vertical Resolution" ); break;
1266 case 2: HUD_init_message( "Low Horizontal Resolution" ); break;
1267 case 3: HUD_init_message( "Low Resolution" ); break;
1272 case KEY_ALTED+KEY_F7:
1273 if ( VR_render_mode != VR_NONE ) {
1274 VR_eye_switch = !VR_eye_switch;
1275 HUD_init_message( "-Eyes toggled-" );
1276 if ( VR_eye_switch )
1277 HUD_init_message( "Right Eye -- Left Eye" );
1279 HUD_init_message( "Left Eye -- Right Eye" );
1283 case KEY_ALTED+KEY_F8:
1284 if ( VR_render_mode != VR_NONE ) {
1286 if (VR_sensitivity > 2 )
1288 HUD_init_message( "Head tracking sensitivy = %d", VR_sensitivity );
1291 case KEY_ALTED+KEY_F9:
1292 if ( VR_render_mode != VR_NONE ) {
1293 VR_eye_width -= F1_0/10;
1294 if ( VR_eye_width < 0 ) VR_eye_width = 0;
1295 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1296 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1299 case KEY_ALTED+KEY_F10:
1300 if ( VR_render_mode != VR_NONE ) {
1301 VR_eye_width += F1_0/10;
1302 if ( VR_eye_width > F1_0*4 ) VR_eye_width = F1_0*4;
1303 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1304 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1308 case KEY_ALTED+KEY_F11:
1309 if ( VR_render_mode != VR_NONE ) {
1311 if ( VR_eye_offset < -30 ) VR_eye_offset = -30;
1312 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1313 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1314 VR_eye_offset_changed = 2;
1317 case KEY_ALTED+KEY_F12:
1318 if ( VR_render_mode != VR_NONE ) {
1320 if ( VR_eye_offset > 30 ) VR_eye_offset = 30;
1321 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1322 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1323 VR_eye_offset_changed = 2;
1330 extern void DropFlag(void);
1332 void HandleGameKey(int key)
1336 #if !defined(RELEASE)
1337 case KEY_COMMAND+KEY_F:
1338 cvar_toggle( &r_framerate );
1342 case KEY_1 + KEY_SHIFTED:
1343 case KEY_2 + KEY_SHIFTED:
1344 case KEY_3 + KEY_SHIFTED:
1345 case KEY_4 + KEY_SHIFTED:
1346 case KEY_5 + KEY_SHIFTED:
1347 case KEY_6 + KEY_SHIFTED:
1348 case KEY_7 + KEY_SHIFTED:
1349 case KEY_8 + KEY_SHIFTED:
1350 case KEY_9 + KEY_SHIFTED:
1351 case KEY_0 + KEY_SHIFTED:
1354 if (!(Game_mode & GM_MULTI))
1355 set_escort_special_goal(key);
1357 HUD_init_message ("No Guide-Bot in Multiplayer!");
1361 case KEY_COMMAND+KEY_SHIFTED+KEY_5:
1362 case KEY_F5 + KEY_SHIFTED:
1363 DropCurrentWeapon();
1366 case KEY_COMMAND+KEY_SHIFTED+KEY_6:
1367 case KEY_F6 + KEY_SHIFTED:
1368 DropSecondaryWeapon();
1372 case KEY_0 + KEY_ALTED:
1377 case KEY_COMMAND+KEY_4:
1379 if (!DefiningMarkerMessage)
1384 case KEY_COMMAND+KEY_6:
1386 if (Netgame.RefusePlayers && WaitForRefuseAnswer && !(Game_mode & GM_TEAM))
1389 HUD_init_message ("Player accepted!");
1392 case KEY_ALTED + KEY_1:
1393 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1396 HUD_init_message ("Player accepted!");
1400 case KEY_ALTED + KEY_2:
1401 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1404 HUD_init_message ("Player accepted!");
1416 void kill_all_robots(void)
1418 int i, dead_count=0;
1419 //int boss_index = -1;
1421 // Kill all bots except for Buddy bot and boss. However, if only boss and buddy left, kill boss.
1422 for (i=0; i<=Highest_object_index; i++)
1423 if (Objects[i].type == OBJ_ROBOT) {
1424 if (!Robot_info[Objects[i].id].companion && !Robot_info[Objects[i].id].boss_flag) {
1426 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1430 // -- // Now, if more than boss and buddy left, un-kill boss.
1431 // -- if ((dead_count > 2) && (boss_index != -1)) {
1432 // -- Objects[boss_index].flags &= ~(OF_EXPLODING|OF_SHOULD_BE_DEAD);
1434 // -- } else if (boss_index != -1)
1435 // -- HUD_init_message("Toasted the BOSS!");
1437 // Toast the buddy if nothing else toasted!
1438 if (dead_count == 0)
1439 for (i=0; i<=Highest_object_index; i++)
1440 if (Objects[i].type == OBJ_ROBOT)
1441 if (Robot_info[Objects[i].id].companion) {
1442 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1443 HUD_init_message("Toasted the Buddy! *sniff*");
1447 HUD_init_message("%i robots toasted!", dead_count);
1450 // --------------------------------------------------------------------------
1451 // Detonate reactor.
1452 // Award player all powerups in mine.
1453 // Place player just outside exit.
1454 // Kill all bots in mine.
1456 void kill_and_so_forth(void)
1460 HUD_init_message("Killing, awarding, etc.!");
1462 for (i=0; i<=Highest_object_index; i++) {
1463 switch (Objects[i].type) {
1465 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1468 do_powerup(&Objects[i]);
1473 do_controlcen_destroyed_stuff(NULL);
1475 for (i=0; i<Num_triggers; i++) {
1476 if (Triggers[i].type == TT_EXIT) {
1477 for (j=0; j<Num_walls; j++) {
1478 if (Walls[j].trigger == i) {
1479 compute_segment_center(&ConsoleObject->pos, &Segments[Walls[j].segnum]);
1480 obj_relink(OBJECT_NUMBER(ConsoleObject), Walls[j].segnum);
1493 void kill_all_snipers(void)
1495 int i, dead_count=0;
1497 // Kill all snipers.
1498 for (i=0; i<=Highest_object_index; i++)
1499 if (Objects[i].type == OBJ_ROBOT)
1500 if (Objects[i].ctype.ai_info.behavior == AIB_SNIPE) {
1502 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1505 HUD_init_message("%i robots toasted!", dead_count);
1508 void kill_thief(void)
1513 for (i=0; i<=Highest_object_index; i++)
1514 if (Objects[i].type == OBJ_ROBOT)
1515 if (Robot_info[Objects[i].id].thief) {
1516 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1517 HUD_init_message("Thief toasted!");
1521 void kill_buddy(void)
1526 for (i=0; i<=Highest_object_index; i++)
1527 if (Objects[i].type == OBJ_ROBOT)
1528 if (Robot_info[Objects[i].id].companion) {
1529 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1530 HUD_init_message("Buddy toasted!");
1535 void gamecntl_cmd_kill(int argc, char **argv)
1537 if (!Cheats_enabled.intval)
1542 ConsoleObject->flags |= OF_SHOULD_BE_DEAD;
1546 if (!stricmp(argv[1], "all"))
1548 else if (!stricmp(argv[1], "snipers"))
1550 else if (!stricmp(argv[1], "thief"))
1552 else if (!stricmp(argv[1], "buddy"))
1558 void toggle_movie_saving(void);
1559 extern char Language[];
1561 void HandleTestKey(int key)
1565 case KEY_DEBUGGED+KEY_0: show_weapon_status(); break;
1567 #ifdef SHOW_EXIT_PATH
1568 case KEY_DEBUGGED+KEY_1: create_special_path(); break;
1571 case KEY_DEBUGGED+KEY_Y:
1572 do_controlcen_destroyed_stuff(NULL);
1576 case KEY_DEBUGGED+KEY_ALTED+KEY_D:
1577 Netlife_kills=4000; Netlife_killed=5;
1578 multi_add_lifetime_kills();
1583 case KEY_CTRLED+KEY_BACKSP:
1584 case KEY_ALTED+KEY_BACKSP:
1585 case KEY_SHIFTED+KEY_BACKSP:
1586 case KEY_SHIFTED+KEY_ALTED+KEY_BACKSP:
1587 case KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1588 case KEY_SHIFTED+KEY_CTRLED+KEY_BACKSP:
1589 case KEY_SHIFTED+KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1593 case KEY_DEBUGGED+KEY_S: digi_reset(); break;
1595 case KEY_DEBUGGED+KEY_P:
1596 if (Game_suspended & SUSP_ROBOTS)
1597 Game_suspended &= ~SUSP_ROBOTS; //robots move
1599 Game_suspended |= SUSP_ROBOTS; //robots don't move
1604 case KEY_DEBUGGED+KEY_K: Players[Player_num].shields = 1; break; // a virtual kill
1605 case KEY_DEBUGGED+KEY_SHIFTED + KEY_K: Players[Player_num].shields = -1; break; // an actual kill
1606 case KEY_DEBUGGED+KEY_X: Players[Player_num].lives++; break; // Extra life cheat key.
1607 case KEY_DEBUGGED+KEY_H:
1608 // if (!(Game_mode & GM_MULTI) ) {
1609 Players[Player_num].flags ^= PLAYER_FLAGS_CLOAKED;
1610 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
1612 if (Game_mode & GM_MULTI)
1615 ai_do_cloak_stuff();
1616 Players[Player_num].cloak_time = GameTime;
1617 mprintf((0, "You are cloaked!\n"));
1619 mprintf((0, "You are DE-cloaked!\n"));
1624 case KEY_DEBUGGED+KEY_R:
1625 Robot_firing_enabled = !Robot_firing_enabled;
1628 case KEY_DEBUGGED+KEY_R+KEY_SHIFTED:
1632 #ifdef EDITOR //editor-specific functions
1634 case KEY_E + KEY_DEBUGGED:
1636 network_leave_game();
1638 Function_mode = FMODE_EDITOR;
1640 case KEY_Q + KEY_SHIFTED + KEY_DEBUGGED:
1643 memcpy(pal_save,gr_palette,768);
1644 init_subtitles("end.tex"); //ingore errors
1645 PlayMovie ("end.mve",MOVIE_ABORT_ON);
1648 set_screen_mode(SCREEN_GAME);
1650 memcpy(gr_palette,pal_save,768);
1651 gr_palette_load(gr_palette);
1654 case KEY_C + KEY_SHIFTED + KEY_DEBUGGED:
1655 if (!( Game_mode & GM_MULTI ))
1656 move_player_2_segment(Cursegp,Curside);
1657 break; //move eye to curseg
1660 case KEY_DEBUGGED+KEY_W: draw_world_from_game(); break;
1662 #endif //#ifdef EDITOR
1665 // case KEY_DEBUGGED+KEY_SHIFTED+KEY_F: toggle_flythrough(); break;
1666 // case KEY_LEFT: ft_preference=FP_LEFT; break;
1667 // case KEY_RIGHT: ft_preference=FP_RIGHT; break;
1668 // case KEY_UP: ft_preference=FP_UP; break;
1669 // case KEY_DOWN: ft_preference=FP_DOWN; break;
1672 case KEY_DEBUGGED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_next_viewer(); break;
1673 case KEY_DEBUGGED+KEY_CTRLED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_prev_viewer(); break;
1675 case KEY_DEBUGGED+KEY_SHIFTED+KEY_LAPOSTRO: Viewer=ConsoleObject; break;
1678 case KEY_DEBUGGED+KEY_O: toggle_outline_mode(); break;
1680 case KEY_DEBUGGED+KEY_T:
1681 *Toggle_var = !*Toggle_var;
1682 mprintf((0, "Variable at %08x set to %i\n", Toggle_var, *Toggle_var));
1684 case KEY_DEBUGGED + KEY_L:
1685 if (++Lighting_on >= 2) { Lighting_on = 0; } break;
1686 case KEY_DEBUGGED + KEY_SHIFTED + KEY_L:
1687 Beam_brightness=0x38000-Beam_brightness; break;
1688 case KEY_PAD5: slew_stop(); break;
1691 case KEY_DEBUGGED + KEY_F11: play_test_sound(); break;
1692 case KEY_DEBUGGED + KEY_SHIFTED+KEY_F11: advance_sound(); play_test_sound(); break;
1695 case KEY_DEBUGGED +KEY_F4: {
1696 //fvi_info hit_data;
1697 //vms_vector p0 = {-0x1d99a7,-0x1b20000,0x186ab7f};
1698 //vms_vector p1 = {-0x217865,-0x1b20000,0x187de3e};
1699 //find_vector_intersection(&hit_data,&p0,0x1b9,&p1,0x40000,0x0,NULL,-1);
1703 case KEY_DEBUGGED + KEY_M:
1704 Debug_spew = !Debug_spew;
1706 mopen( 0, 8, 1, 78, 16, "Debug Spew");
1707 HUD_init_message( "Debug Spew: ON" );
1710 HUD_init_message( "Debug Spew: OFF" );
1714 case KEY_DEBUGGED + KEY_C:
1716 full_palette_save();
1720 case KEY_DEBUGGED + KEY_SHIFTED + KEY_A:
1721 do_megawow_powerup(10);
1723 case KEY_DEBUGGED + KEY_A: {
1724 do_megawow_powerup(200);
1725 // if ( Game_mode & GM_MULTI ) {
1726 // nm_messagebox( NULL, 1, "Damn", "CHEATER!\nYou cannot use the\nmega-thing in network mode." );
1727 // Network_message_reciever = 100; // Send to everyone...
1728 // sprintf( Network_message, "%s cheated!", Players[Player_num].callsign);
1730 // do_megawow_powerup();
1735 case KEY_DEBUGGED+KEY_F:
1736 cvar_toggle( &r_framerate );
1739 case KEY_DEBUGGED+KEY_SPACEBAR: //KEY_F7: // Toggle physics flying
1741 game_flush_inputs();
1742 if ( ConsoleObject->control_type != CT_FLYING ) {
1743 fly_init(ConsoleObject);
1744 Game_suspended &= ~SUSP_ROBOTS; //robots move
1746 slew_init(ConsoleObject); //start player slewing
1747 Game_suspended |= SUSP_ROBOTS; //robots don't move
1751 case KEY_DEBUGGED+KEY_COMMA: Render_zoom = fixmul(Render_zoom,62259); break;
1752 case KEY_DEBUGGED+KEY_PERIOD: Render_zoom = fixmul(Render_zoom,68985); break;
1754 case KEY_DEBUGGED+KEY_P+KEY_SHIFTED: Debug_pause = 1; break;
1758 // sprintf(mystr,"mark %i start",Mark_count);
1762 //case KEY_SHIFTED+KEY_F7: {
1764 // sprintf(mystr,"mark %i end",Mark_count);
1772 case KEY_DEBUGGED+KEY_F8: speedtest_init(); Speedtest_count = 1; break;
1773 case KEY_DEBUGGED+KEY_F9: speedtest_init(); Speedtest_count = 10; break;
1775 case KEY_DEBUGGED+KEY_D:
1776 if ((Game_double_buffer = !Game_double_buffer)!=0)
1782 case KEY_DEBUGGED+KEY_Q:
1784 dump_used_textures_all();
1789 case KEY_DEBUGGED+KEY_B: {
1791 char text[FILENAME_LEN]="";
1793 m.type=NM_TYPE_INPUT; m.text_len = FILENAME_LEN; m.text = text;
1794 item = newmenu_do( NULL, "Briefing to play?", 1, &m, NULL );
1796 do_briefing_screens(text,1);
1802 case KEY_DEBUGGED+KEY_F5:
1803 toggle_movie_saving();
1806 case KEY_DEBUGGED+KEY_SHIFTED+KEY_F5: {
1807 extern int Movie_fixed_frametime;
1808 Movie_fixed_frametime = !Movie_fixed_frametime;
1812 case KEY_DEBUGGED+KEY_ALTED+KEY_F5:
1813 GameTime = i2f(0x7fff - 840); //will overflow in 14 minutes
1814 mprintf((0,"GameTime bashed to %d secs\n",f2i(GameTime)));
1817 case KEY_DEBUGGED+KEY_SHIFTED+KEY_B:
1818 kill_and_so_forth();
1822 #endif //#ifndef RELEASE
1824 // Cheat functions ------------------------------------------------------------
1827 // check of cheats are, or can be, enabled
1828 static int check_cheat_enable(void)
1830 // cheats have to be enabled explicitly
1831 if (EMULATING_D1 || Game_mode & GM_MULTI)
1832 return Cheats_enabled.intval;
1838 void do_cheat_penalty ()
1840 digi_play_sample( SOUND_CHEATER, F1_0);
1841 cvar_setint(&Cheats_enabled, 1);
1842 Players[Player_num].score=0;
1848 char john_head_on=0;
1851 char OldHomingState[20];
1852 extern char Monster_mode;
1854 void fill_background(void);
1855 void load_background_bitmap(void);
1857 extern int Robots_kill_robots_cheat;
1860 static void gamecntl_cmd_LamerCheat(int argc, char **argv)
1863 Players[Player_num].shields = i2f(1);
1864 Players[Player_num].energy = i2f(1);
1866 if (Game_mode & GM_MULTI)
1868 Network_message_reciever = 100; // Send to everyone...
1869 sprintf(Network_message, "%s is crippled...get him!", Players[Player_num].callsign);
1872 HUD_init_message("Take that...cheater!");
1876 static void gamecntl_cmd_EnableCheats(int argc, char **argv)
1878 if (Game_mode & GM_MULTI)
1883 gamecntl_cmd_LamerCheat(argc, argv);
1888 HUD_init_message(TXT_CHEATS_ENABLED);
1892 static void gamecntl_cmd_JohnHeadCheat(int argc, char **argv)
1894 john_head_on = !john_head_on;
1895 load_background_bitmap();
1897 HUD_init_message(john_head_on?"Hi John!!":"Bye John!!");
1901 static void gamecntl_cmd_AcidCheat(int argc, char **argv)
1906 Interpolation_method = old_IntMethod;
1907 HUD_init_message("Coming down...");
1912 old_IntMethod = Interpolation_method;
1913 Interpolation_method = 1;
1914 HUD_init_message("Going up!");
1919 static void gamecntl_cmd_FramerateCheat(int argc, char **argv)
1921 cvar_toggle(&r_framerate);
1925 static void gamecntl_cmd_BlueOrbCheat(int argc, char **argv)
1927 if (!check_cheat_enable())
1930 if (Players[Player_num].shields < MAX_SHIELDS)
1932 fix boost = 3*F1_0 + 3*F1_0*(NDL - Difficulty_level);
1934 if (Difficulty_level == 0)
1936 Players[Player_num].shields += boost;
1937 if (Players[Player_num].shields > MAX_SHIELDS)
1938 Players[Player_num].shields = MAX_SHIELDS;
1939 powerup_basic(0, 0, 15, SHIELD_SCORE, "%s %s %d", TXT_SHIELD, TXT_BOOSTED_TO, f2ir(Players[Player_num].shields));
1943 HUD_init_message(TXT_MAXED_OUT,TXT_SHIELD);
1947 static void gamecntl_cmd_BuddyLifeCheat(int argc, char **argv)
1949 if (!check_cheat_enable())
1953 HUD_init_message("What's this? Another buddy bot!");
1958 static void gamecntl_cmd_BuddyDudeCheat(int argc, char **argv)
1960 if (!check_cheat_enable())
1964 cvar_toggle(&Buddy_dude_cheat);
1965 if (Buddy_dude_cheat.intval)
1967 HUD_init_message("%s gets angry!", guidebot_name);
1968 strcpy(guidebot_name, "Wingnut");
1972 strncpy(guidebot_name, real_guidebot_name.string, GUIDEBOT_NAME_LEN);
1973 guidebot_name[GUIDEBOT_NAME_LEN] = 0;
1974 HUD_init_message("%s calms down", guidebot_name);
1979 static void gamecntl_cmd_MonsterCheat(int argc, char **argv)
1981 if (!check_cheat_enable())
1984 Monster_mode = 1 - Monster_mode;
1986 HUD_init_message(Monster_mode?"Oh no, there goes Tokyo!":"What have you done, I'm shrinking!!");
1990 static void gamecntl_cmd_BouncyCheat(int argc, char **argv)
1992 if (!check_cheat_enable())
1995 if (!is_SHAREWARE && !stricmp(argv[0], "ericaanne"))
1997 gamecntl_cmd_LamerCheat(argc, argv);
2002 HUD_init_message("Bouncing weapons!");
2007 static void gamecntl_cmd_LevelWarpCheat(int argc, char **argv)
2014 if (!check_cheat_enable())
2017 if (!is_SHAREWARE && !stricmp(argv[0], "whammazoom"))
2019 gamecntl_cmd_LamerCheat(argc, argv);
2023 //digi_play_sample(SOUND_CHEATER, F1_0);
2024 m.type = NM_TYPE_INPUT; m.text_len = 10; m.text = text;
2025 item = newmenu_do( NULL, TXT_WARP_TO_LEVEL, 1, &m, NULL );
2028 new_level_num = atoi(m.text);
2029 if (new_level_num != 0 && new_level_num >= 0 && new_level_num <= Last_level)
2031 StartNewLevel(new_level_num, 0);
2038 static void gamecntl_cmd_PhysicsCheat(int argc, char **argv)
2040 if (!check_cheat_enable())
2044 if ( Physics_cheat_flag == 0xBADA55 )
2046 Physics_cheat_flag = 0;
2050 Physics_cheat_flag = 0xBADA55;
2052 HUD_init_message("%s %s!", "Ghosty mode", Physics_cheat_flag == 0xBADA55?TXT_ON:TXT_OFF);
2056 static void gamecntl_cmd_TurboCheat(int argc, char **argv)
2058 if (!check_cheat_enable())
2062 Game_turbo_mode ^= 1;
2063 HUD_init_message("%s %s!", "Turbo mode", Game_turbo_mode?TXT_ON:TXT_OFF);
2067 static void gamecntl_cmd_NewLifeCheat(int argc, char **argv)
2069 if (!check_cheat_enable())
2072 if (Players[Player_num].lives >= 50)
2076 Players[Player_num].lives++;
2077 HUD_init_message("Extra life!");
2081 static void gamecntl_cmd_WowieCheat(int argc, char **argv)
2085 if (!check_cheat_enable())
2088 if (!is_SHAREWARE && !stricmp(argv[0], "motherlode"))
2090 gamecntl_cmd_LamerCheat(argc, argv);
2095 HUD_init_message("%s%s", !stricmp(argv[0], "bigred")?"SUPER ":"", TXT_WOWIE_ZOWIE);
2097 Players[Player_num].primary_weapon_flags = HAS_LASER_FLAG | HAS_VULCAN_FLAG | HAS_SPREADFIRE_FLAG;
2098 Players[Player_num].secondary_weapon_flags = HAS_CONCUSSION_FLAG | HAS_HOMING_FLAG | HAS_PROXIMITY_FLAG;
2100 if (!stricmp(argv[0], "bigred"))
2102 Players[Player_num].primary_weapon_flags |= HAS_PLASMA_FLAG | HAS_FUSION_FLAG;
2103 Players[Player_num].secondary_weapon_flags |= HAS_SMART_FLAG | HAS_MEGA_FLAG;
2105 else if (!stricmp(argv[0], "motherlode"))
2107 Players[Player_num].primary_weapon_flags = ~(HAS_FLAG(PHOENIX_INDEX) | HAS_FLAG(OMEGA_INDEX) | HAS_FLAG(FUSION_INDEX));
2108 Players[Player_num].secondary_weapon_flags = ~(HAS_FLAG(SMISSILE4_INDEX) | HAS_FLAG(MEGA_INDEX) | HAS_FLAG(SMISSILE5_INDEX));
2110 else if (!stricmp(argv[0], "honestbob"))
2112 Players[Player_num].primary_weapon_flags = 0xffff;
2113 Players[Player_num].secondary_weapon_flags = 0xffff;
2116 Players[Player_num].primary_weapon_flags &= ~HAS_FLAG(SUPER_LASER_INDEX); // no super laser
2118 for (i = 0; i < (MAX_PRIMARY_WEAPONS); i++)
2119 if (Players[Player_num].primary_weapon_flags & HAS_FLAG(i))
2120 Players[Player_num].primary_ammo[i] = Primary_ammo_max[i];
2122 for (i = 0; i < (EMULATING_D1?5:MAX_SECONDARY_WEAPONS); i++)
2123 if (Players[Player_num].secondary_weapon_flags & HAS_FLAG(i))
2124 Players[Player_num].secondary_ammo[i] = Secondary_ammo_max[i];
2126 if (Game_mode & GM_HOARD)
2127 Players[Player_num].secondary_ammo[PROXIMITY_INDEX] = 12;
2129 if (Newdemo_state == ND_STATE_RECORDING)
2130 newdemo_record_laser_level(Players[Player_num].laser_level, MAX_LASER_LEVEL);
2132 Players[Player_num].energy = EMULATING_D1?INITIAL_ENERGY:MAX_ENERGY;
2133 Players[Player_num].laser_level = EMULATING_D1?MAX_LASER_LEVEL:MAX_SUPER_LASER_LEVEL;
2134 Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS;
2135 update_laser_weapon_info();
2139 static void gamecntl_cmd_AllKeysCheat(int argc, char **argv)
2141 if (!check_cheat_enable())
2144 if (!is_SHAREWARE && !stricmp(argv[0], "currygoat"))
2146 gamecntl_cmd_LamerCheat(argc, argv);
2151 HUD_init_message(TXT_ALL_KEYS);
2152 Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2156 static void gamecntl_cmd_InvulCheat(int argc, char **argv)
2158 if (!check_cheat_enable())
2161 if (!is_SHAREWARE && !stricmp(argv[0], "zingermans"))
2163 gamecntl_cmd_LamerCheat(argc, argv);
2168 Players[Player_num].flags ^= PLAYER_FLAGS_INVULNERABLE;
2169 HUD_init_message("%s %s!", TXT_INVULNERABILITY, (Players[Player_num].flags&PLAYER_FLAGS_INVULNERABLE)?TXT_ON:TXT_OFF);
2170 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2174 static void gamecntl_cmd_CloakCheat(int argc, char **argv)
2176 if (!check_cheat_enable())
2180 Players[Player_num].flags ^= PLAYER_FLAGS_CLOAKED;
2181 HUD_init_message("%s %s!", TXT_CLOAK, (Players[Player_num].flags&PLAYER_FLAGS_CLOAKED)?TXT_ON:TXT_OFF);
2182 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
2183 ai_do_cloak_stuff();
2184 Players[Player_num].cloak_time = GameTime;
2189 static void gamecntl_cmd_ShieldCheat(int argc, char **argv)
2191 if (!check_cheat_enable())
2195 HUD_init_message(TXT_FULL_SHIELDS);
2196 Players[Player_num].shields = INITIAL_SHIELDS;
2200 static void gamecntl_cmd_ExitPathCheat(int argc, char **argv)
2202 if (!check_cheat_enable())
2205 #ifdef SHOW_EXIT_PATH
2206 if (!create_special_path())
2210 HUD_init_message("Exit path illuminated!");
2215 static void gamecntl_cmd_AccessoryCheat(int argc, char **argv)
2217 if (!check_cheat_enable())
2221 Players[Player_num].flags |= PLAYER_FLAGS_HEADLIGHT;
2222 Players[Player_num].flags |= PLAYER_FLAGS_AFTERBURNER;
2223 Players[Player_num].flags |= PLAYER_FLAGS_AMMO_RACK;
2224 Players[Player_num].flags |= PLAYER_FLAGS_CONVERTER;
2226 HUD_init_message ("Accessories!!");
2230 static void gamecntl_cmd_FullMapCheat(int argc, char **argv)
2232 if (!check_cheat_enable())
2235 if (!is_SHAREWARE && !stricmp(argv[0], "joshuaakira"))
2237 gamecntl_cmd_LamerCheat(argc, argv);
2242 Players[Player_num].flags |= PLAYER_FLAGS_MAP_ALL;
2244 HUD_init_message ("Full Map!!");
2248 static void gamecntl_cmd_HomingCheat(int argc, char **argv)
2250 if (!check_cheat_enable())
2253 if (!is_SHAREWARE && !stricmp(argv[0], "eatangelos"))
2255 gamecntl_cmd_LamerCheat(argc, argv);
2264 for (i = 0; i < 20; i++)
2266 OldHomingState[i] = Weapon_info[i].homing_flag;
2267 Weapon_info[i].homing_flag = 1;
2269 HUD_init_message ("Homing weapons!");
2274 static void gamecntl_cmd_KillRobotsCheat(int argc, char **argv)
2276 if (!check_cheat_enable())
2284 static void gamecntl_cmd_FinishLevelCheat(int argc, char **argv)
2286 if (!check_cheat_enable())
2289 kill_and_so_forth();
2293 static void gamecntl_cmd_RobotsKillRobotsCheat(int argc, char **argv)
2295 if (!check_cheat_enable())
2298 Robots_kill_robots_cheat = !Robots_kill_robots_cheat;
2299 if (Robots_kill_robots_cheat)
2301 HUD_init_message("Rabid robots!");
2305 HUD_init_message("Kill the player!");
2309 static void gamecntl_cmd_RobotFiringCheat(int argc, char **argv)
2311 if (!check_cheat_enable())
2314 Robot_firing_enabled = !Robot_firing_enabled;
2315 if (!Robot_firing_enabled)
2317 HUD_init_message("%s", "Robot firing OFF!");
2321 HUD_init_message("%s", "Robot firing ON!");
2325 static void gamecntl_cmd_RapidFireCheat(int argc, char **argv)
2327 if (!check_cheat_enable())
2330 if (Laser_rapid_fire)
2332 Laser_rapid_fire = 0;
2333 HUD_init_message("%s", "Rapid fire OFF!");
2337 Laser_rapid_fire = 0xbada55;
2339 HUD_init_message("%s", "Rapid fire ON!");
2344 static void gamecntl_cmd_JohnCheat1(int argc, char **argv)
2346 if (!check_cheat_enable())
2350 do_controlcen_destroyed_stuff(NULL);
2354 static void gamecntl_cmd_JohnCheat2(int argc, char **argv)
2356 if (!check_cheat_enable())
2360 Laser_rapid_fire = 0xbada55;
2361 do_megawow_powerup(200);
2366 extern void do_lunacy_on(void);
2367 extern void do_lunacy_off(void);
2370 static void gamecntl_cmd_JohnCheat3(int argc, char **argv)
2372 if (!check_cheat_enable())
2377 HUD_init_message( TXT_NO_LUNACY );
2381 HUD_init_message( TXT_LUNACY );
2386 extern int Ugly_robot_cheat, Ugly_robot_texture;
2388 static void gamecntl_cmd_JohnCheat4(int argc, char **argv)
2390 if (!check_cheat_enable())
2396 Ugly_robot_texture = atoi(argv[1]);
2398 if (Ugly_robot_texture == 999)
2400 Ugly_robot_cheat = 0;
2401 HUD_init_message( TXT_ROBOT_PAINTING_OFF );
2405 HUD_init_message( TXT_ROBOT_PAINTING_ON, Ugly_robot_texture );
2406 Ugly_robot_cheat = 0xbada55;
2408 mprintf((0, "Paint value = %i\n", Ugly_robot_texture));
2412 #define CHEATSPOT 14
2417 const char string[CHEATEND];
2418 cmd_handler_t cheat_cmd;
2421 static const struct cheat_code Cheats[] = {
2422 { "gabbagabbahey", gamecntl_cmd_EnableCheats },
2423 { "scourge", gamecntl_cmd_WowieCheat },
2424 { "mitzi", gamecntl_cmd_AllKeysCheat },
2425 { "racerx", gamecntl_cmd_InvulCheat },
2426 { "guile", gamecntl_cmd_CloakCheat },
2427 { "twilight", gamecntl_cmd_ShieldCheat },
2428 { "farmerjoe", gamecntl_cmd_LevelWarpCheat },
2429 { "astral", gamecntl_cmd_PhysicsCheat },
2431 { "buggin", gamecntl_cmd_TurboCheat },
2432 { "bigred", gamecntl_cmd_WowieCheat },
2433 { "bruin", gamecntl_cmd_NewLifeCheat },
2434 { "flash", gamecntl_cmd_ExitPathCheat },
2435 { "ahimsa", gamecntl_cmd_RobotFiringCheat },
2437 { "poboys", gamecntl_cmd_JohnCheat1 },
2438 { "porgys", gamecntl_cmd_JohnCheat2 },
2439 { "lunacy", gamecntl_cmd_JohnCheat3 },
2440 { "pletch", gamecntl_cmd_JohnCheat4 },
2442 { "motherlode", gamecntl_cmd_WowieCheat },
2443 { "currygoat", gamecntl_cmd_AllKeysCheat },
2444 { "zingermans", gamecntl_cmd_InvulCheat },
2445 { "eatangelos", gamecntl_cmd_HomingCheat },
2446 { "ericaanne", gamecntl_cmd_BouncyCheat },
2447 { "joshuaakira", gamecntl_cmd_FullMapCheat },
2448 { "whammazoom", gamecntl_cmd_LevelWarpCheat },
2450 { "pigfarmer", gamecntl_cmd_JohnHeadCheat },
2451 { "bittersweet", gamecntl_cmd_AcidCheat },
2452 { "frametime", gamecntl_cmd_FramerateCheat },
2453 { "blueorb", gamecntl_cmd_BlueOrbCheat },
2454 { "helpvishnu", gamecntl_cmd_BuddyLifeCheat },
2455 { "gowingnut", gamecntl_cmd_BuddyDudeCheat },
2456 { "godzilla", gamecntl_cmd_MonsterCheat },
2457 { "duddaboo", gamecntl_cmd_BouncyCheat },
2458 { "freespace", gamecntl_cmd_LevelWarpCheat },
2459 { "honestbob", gamecntl_cmd_WowieCheat },
2460 { "oralgroove", gamecntl_cmd_AllKeysCheat },
2461 { "almighty", gamecntl_cmd_InvulCheat },
2462 { "alifalafel", gamecntl_cmd_AccessoryCheat },
2463 { "rockrgrl", gamecntl_cmd_FullMapCheat },
2464 { "lpnlizard", gamecntl_cmd_HomingCheat },
2465 { "spaniard", gamecntl_cmd_KillRobotsCheat },
2466 { "delshiftb", gamecntl_cmd_FinishLevelCheat },
2467 { "silkwing", gamecntl_cmd_RobotsKillRobotsCheat },
2468 { "imagespace", gamecntl_cmd_RobotFiringCheat },
2469 { "wildfire", gamecntl_cmd_RapidFireCheat },
2471 #define N_CHEATS (sizeof(Cheats) / sizeof(struct cheat_code))
2474 // Main Cheat function
2476 char CheatBuffer[]="AAAAAAAAAAAAAAA";
2478 void FinalCheats(int key)
2482 key = key_to_ascii(key);
2484 for (i = 0; i < 15; i++)
2485 CheatBuffer[i] = CheatBuffer[i+1];
2487 CheatBuffer[CHEATSPOT] = key;
2489 if (!strnicmp(&CheatBuffer[CHEATEND-9], "pletch", 6))
2490 cmd_appendf("pletch %d", atoi(&CheatBuffer[CHEATEND-3]));
2492 for (i = 0; i < N_CHEATS; i++)
2493 if (!stricmp(&CheatBuffer[CHEATEND-strlen(Cheats[i].string)], Cheats[i].string))
2494 cmd_append(&CheatBuffer[CHEATEND-strlen(Cheats[i].string)]);
2498 // Internal Cheat Menu
2500 void do_cheat_menu()
2503 newmenu_item mm[16];
2504 char score_text[21];
2506 sprintf( score_text, "%d", Players[Player_num].score );
2508 mm[0].type=NM_TYPE_CHECK; mm[0].value=Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE; mm[0].text="Invulnerability";
2509 mm[1].type=NM_TYPE_CHECK; mm[1].value=Players[Player_num].flags & PLAYER_FLAGS_CLOAKED; mm[1].text="Cloaked";
2510 mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="All keys";
2511 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;
2512 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;
2513 mm[5].type=NM_TYPE_TEXT; mm[5].text = "Score:";
2514 mm[6].type=NM_TYPE_INPUT; mm[6].text_len = 10; mm[6].text = score_text;
2515 //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";
2516 //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";
2517 //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";
2518 //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";
2520 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;
2521 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;
2523 mmn = newmenu_do("Wimp Menu",NULL,9, mm, NULL );
2526 if ( mm[0].value ) {
2527 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
2528 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2530 Players[Player_num].flags &= ~PLAYER_FLAGS_INVULNERABLE;
2531 if ( mm[1].value ) {
2532 Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
2534 if (Game_mode & GM_MULTI)
2537 ai_do_cloak_stuff();
2538 Players[Player_num].cloak_time = GameTime;
2541 Players[Player_num].flags &= ~PLAYER_FLAGS_CLOAKED;
2543 if (mm[2].value) Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2544 Players[Player_num].energy=i2f(mm[3].value);
2545 Players[Player_num].shields=i2f(mm[4].value);
2546 Players[Player_num].score = atoi(mm[6].text);
2547 //if (mm[7].value) Players[Player_num].laser_level=0;
2548 //if (mm[8].value) Players[Player_num].laser_level=1;
2549 //if (mm[9].value) Players[Player_num].laser_level=2;
2550 //if (mm[10].value) Players[Player_num].laser_level=3;
2551 Players[Player_num].laser_level = mm[7].value-1;
2552 Players[Player_num].secondary_ammo[CONCUSSION_INDEX] = mm[8].value;
2560 // Testing functions ----------------------------------------------------------
2563 void speedtest_init(void)
2565 Speedtest_start_time = timer_get_fixed_seconds();
2567 Speedtest_segnum = 0;
2568 Speedtest_sidenum = 0;
2569 Speedtest_frame_start = FrameCount;
2571 mprintf((0, "Starting speedtest. Will be %i frames. Each . = 10 frames.\n", Highest_segment_index+1));
2574 void speedtest_frame(void)
2576 vms_vector view_dir, center_point;
2578 Speedtest_sidenum=Speedtest_segnum % MAX_SIDES_PER_SEGMENT;
2580 compute_segment_center(&Viewer->pos, &Segments[Speedtest_segnum]);
2581 Viewer->pos.x += 0x10; Viewer->pos.y -= 0x10; Viewer->pos.z += 0x17;
2583 obj_relink(OBJECT_NUMBER(Viewer), Speedtest_segnum);
2584 compute_center_point_on_side(¢er_point, &Segments[Speedtest_segnum], Speedtest_sidenum);
2585 vm_vec_normalized_dir_quick(&view_dir, ¢er_point, &Viewer->pos);
2586 vm_vector_2_matrix(&Viewer->orient, &view_dir, NULL, NULL);
2588 if (((FrameCount - Speedtest_frame_start) % 10) == 0)
2593 if (Speedtest_segnum > Highest_segment_index) {
2596 sprintf(msg, "\nSpeedtest done: %i frames, %7.3f seconds, %7.3f frames/second.\n",
2597 FrameCount-Speedtest_frame_start,
2598 f2fl(timer_get_fixed_seconds() - Speedtest_start_time),
2599 (float) (FrameCount-Speedtest_frame_start) / f2fl(timer_get_fixed_seconds() - Speedtest_start_time));
2601 mprintf((0, "%s", msg));
2602 HUD_init_message(msg);
2605 if (Speedtest_count == 0)
2614 // Sounds for testing
2616 int test_sound_num = 0;
2617 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};
2619 #define N_TEST_SOUNDS (sizeof(sound_nums) / sizeof(*sound_nums))
2622 void advance_sound()
2624 if (++test_sound_num == N_TEST_SOUNDS)
2630 int Test_sound = 251;
2632 void play_test_sound()
2635 // -- digi_play_sample(sound_nums[test_sound_num], F1_0);
2636 digi_play_sample(Test_sound, F1_0);
2639 #endif //ifndef NDEBUG
2649 static ubyte exploding_flag=0;
2651 Player_fired_laser_this_frame=-1;
2653 if (!Endlevel_sequence) // && !Player_is_dead //this was taken out of the if statement by WraithX
2656 if ( (Newdemo_state == ND_STATE_PLAYBACK) || DefiningMarkerMessage
2658 || multi_sending_message || multi_defining_message
2660 ) // WATCH OUT!!! WEIRD CODE ABOVE!!!
2661 memset( &Controls, 0, sizeof(control_info) );
2663 controls_read_all();
2667 // If automap key pressed, enable automap unless you are in network mode, control center destroyed and < 10 seconds left
2668 if ( Controls.count[automap] && !((Game_mode & GM_MULTI) && Control_center_destroyed && (Countdown_seconds_left < 10)))
2675 if (Player_exploded) { //Player_is_dead && (ConsoleObject->flags & OF_EXPLODING) ) {
2677 if (exploding_flag==0) {
2678 exploding_flag = 1; // When player starts exploding, clear all input devices...
2679 game_flush_inputs();
2682 //if (key_down_count(KEY_BACKSP))
2684 //if (key_down_count(KEY_PRINT_SCREEN))
2685 // save_screen_shot(0);
2688 for (i = 0; i < 4; i++)
2689 // the following "if" added by WraithX, 4/17/00
2690 if (1) //isJoyRotationKey(i) != 1)
2692 if (joy_get_button_down_cnt(i) > 0)
2693 Death_sequence_aborted = 1;
2694 }// end "if" added by WraithX
2696 if (joy_get_any_button_down_cnt() > 0)
2697 Death_sequence_aborted = 1;
2699 for (i = 0; i < 3; i++)
2700 // the following "if" added by WraithX, 4/17/00
2701 if (1) //isMouseRotationKey(i) != 1)
2703 if (mouse_button_down_count(i) > 0)
2704 Death_sequence_aborted = 1;
2705 }// end "if" added by WraithX
2707 //for (i = 0; i < 256; i++)
2708 // // the following "if" added by WraithX, 4/17/00
2709 // if (isKeyboardRotationKey(i) != 1)
2711 // if (!key_isfunc(i) && !key_ismod(i) && key_down_count(i) > 0)
2712 // Death_sequence_aborted = 1;
2713 // }// end "if" added by WraithX
2715 if (Death_sequence_aborted)
2716 game_flush_inputs();
2722 if (Newdemo_state == ND_STATE_PLAYBACK )
2725 while ((key=key_inkey_time(&key_time)) != 0) {
2727 if (DefiningMarkerMessage)
2729 MarkerInputMessage (key);
2734 if ( (Game_mode&GM_MULTI) && (multi_sending_message || multi_defining_message )) {
2735 multi_message_input_sub( key );
2736 continue; //get next key
2742 if ((key&KEY_DEBUGGED)&&(Game_mode&GM_MULTI)) {
2743 Network_message_reciever = 100; // Send to everyone...
2744 sprintf( Network_message, "%s %s", TXT_I_AM_A, TXT_CHEATER);
2749 if(!con_key_handler(key))
2753 HandleDeathKey(key);
2755 if (Endlevel_sequence)
2756 HandleEndlevelKey(key);
2757 else if (Newdemo_state == ND_STATE_PLAYBACK ) {
2766 HandleSystemKey(key);
2777 // if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[KEY_F8] && (keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT]))
2778 // transfer_energy_to_shield(key_down_time(KEY_F8));
2782 void gamecntl_init(void)
2786 for (i = 0; i < N_CHEATS; i++)
2787 cmd_addcommand(Cheats[i].string, Cheats[i].cheat_cmd, "");
2790 cmd_addcommand("kill", gamecntl_cmd_kill, "");
2793 cvar_registervariable(&Buddy_dude_cheat);