1 /* $Id: gamecntl.c,v 1.28 2005-08-02 06:13:56 chris Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
25 //#define DOOR_DEBUGGING
101 #include "multibot.h"
107 //#define TEST_TIMER 1 //if this is set, do checking on timer
109 #define SHOW_EXIT_PATH 1
111 #define Arcade_mode 0
115 #include "editor/editor.h"
120 #if __WATCOMC__ < 1000
121 #include <wsample.h> //should come after inferno.h to get mark setting
129 extern void full_palette_save(void);
130 extern void object_goto_prev_viewer(void);
132 // Global Variables -----------------------------------------------------------
134 int redbook_volume = 255;
137 // External Variables ---------------------------------------------------------
139 extern int Speedtest_on; // Speedtest global adapted from game.c
140 extern int Guided_in_big_window;
141 extern char WaitForRefuseAnswer,RefuseThisPlayer,RefuseTeam;
144 extern int Mark_count;
145 extern int Speedtest_start_time;
146 extern int Speedtest_segnum;
147 extern int Speedtest_sidenum;
148 extern int Speedtest_frame_start;
149 extern int Speedtest_count;
152 extern int Global_missile_firing_count;
153 extern int Automap_flag;
154 extern int Config_menu_flag;
155 extern int EscortHotKeys;
158 extern int Game_aborted;
159 extern int *Toggle_var;
161 extern int Physics_cheat_flag;
163 extern int last_drawn_cockpit[2];
165 extern int Debug_spew;
166 extern int Debug_pause;
167 extern cvar_t r_framerate;
169 extern fix Show_view_text_timer;
171 extern ubyte DefiningMarkerMessage;
173 // Function prototypes --------------------------------------------------------
176 extern void CyclePrimary();
177 extern void CycleSecondary();
178 extern void InitMarkerInput();
179 extern void MarkerInputMessage (int);
180 extern void grow_window(void);
181 extern void shrink_window(void);
182 extern int allowed_to_fire_missile(void);
183 extern int allowed_to_fire_flare(void);
184 extern void check_rear_view(void);
185 extern int create_special_path(void);
186 extern void move_player_2_segment(segment *seg, int side);
187 extern void kconfig_center_headset(void);
188 extern void game_render_frame_mono(void);
189 extern void newdemo_strip_frames(char *, int);
190 extern void toggle_cockpit(void);
191 extern int dump_used_textures_all(void);
192 extern void DropMarker();
193 extern void DropSecondaryWeapon();
194 extern void DropCurrentWeapon();
196 void FinalCheats(int key);
199 void do_cheat_menu(void);
202 void HandleGameKey(int key);
203 int HandleSystemKey(int key);
204 void HandleTestKey(int key);
205 void HandleVRKey(int key);
207 void speedtest_init(void);
208 void speedtest_frame(void);
209 void advance_sound(void);
210 void play_test_sound(void);
213 extern void macintosh_quit(void); // dialog-style quit function
216 #define key_isfunc(k) (((k&0xff)>=KEY_F1 && (k&0xff)<=KEY_F10) || (k&0xff)==KEY_F11 || (k&0xff)==KEY_F12)
217 #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)
219 // Functions ------------------------------------------------------------------
221 #define CONVERTER_RATE 20 //10 units per second xfer rate
222 #define CONVERTER_SCALE 2 //2 units energy -> 1 unit shields
224 #define CONVERTER_SOUND_DELAY (f1_0/2) //play every half second
226 void transfer_energy_to_shield(fix time)
228 fix e; //how much energy gets transfered
229 static fix last_play_time=0;
231 e = min(min(time*CONVERTER_RATE,Players[Player_num].energy - INITIAL_ENERGY),(MAX_SHIELDS-Players[Player_num].shields)*CONVERTER_SCALE);
235 if (Players[Player_num].energy <= INITIAL_ENERGY)
236 HUD_init_message("Need more than %i energy to enable transfer", f2i(INITIAL_ENERGY));
238 HUD_init_message("No transfer: Shields already at max");
242 Players[Player_num].energy -= e;
243 Players[Player_num].shields += e/CONVERTER_SCALE;
245 if (last_play_time > GameTime)
248 if (GameTime > last_play_time+CONVERTER_SOUND_DELAY) {
249 digi_play_sample_once(SOUND_CONVERT_ENERGY, F1_0);
250 last_play_time = GameTime;
255 void update_vcr_state();
256 void do_weapon_stuff(void);
261 fix newdemo_single_frame_time;
263 void update_vcr_state(void)
265 if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_RIGHT])
266 Newdemo_vcr_state = ND_STATE_FASTFORWARD;
267 else if ((keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT]) && keyd_pressed[KEY_LEFT])
268 Newdemo_vcr_state = ND_STATE_REWINDING;
269 else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_RIGHT] && ((timer_get_fixed_seconds() - newdemo_single_frame_time) >= F1_0))
270 Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
271 else if (!(keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL]) && keyd_pressed[KEY_LEFT] && ((timer_get_fixed_seconds() - newdemo_single_frame_time) >= F1_0))
272 Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
273 else if ((Newdemo_vcr_state == ND_STATE_FASTFORWARD) || (Newdemo_vcr_state == ND_STATE_REWINDING))
274 Newdemo_vcr_state = ND_STATE_PLAYBACK;
277 //returns which bomb will be dropped next time the bomb key is pressed
282 //use the last one selected, unless there aren't any, in which case use
283 //the other if there are any
286 // If hoard game, only let the player drop smart mines
287 if (Game_mode & GM_HOARD)
288 return SMART_MINE_INDEX;
290 bomb = Secondary_last_was_super[PROXIMITY_INDEX]?SMART_MINE_INDEX:PROXIMITY_INDEX;
292 if (Players[Player_num].secondary_ammo[bomb] == 0 &&
293 Players[Player_num].secondary_ammo[SMART_MINE_INDEX+PROXIMITY_INDEX-bomb] != 0) {
294 bomb = SMART_MINE_INDEX+PROXIMITY_INDEX-bomb;
295 Secondary_last_was_super[bomb%SUPER_WEAPON] = (bomb == SMART_MINE_INDEX);
304 void do_weapon_stuff(void)
308 if (Controls.fire_flare_down_count)
309 if (allowed_to_fire_flare())
310 Flare_create(ConsoleObject);
312 if (allowed_to_fire_missile())
313 Global_missile_firing_count += Weapon_info[Secondary_weapon_to_weapon_info[Secondary_weapon]].fire_count * (Controls.fire_secondary_state || Controls.fire_secondary_down_count);
315 if (Global_missile_firing_count) {
316 do_missile_firing(1); //always enable autoselect for normal missile firing
317 Global_missile_firing_count--;
320 if (Controls.cycle_primary_count)
322 for (i=0;i<Controls.cycle_primary_count;i++)
325 if (Controls.cycle_secondary_count)
327 for (i=0;i<Controls.cycle_secondary_count;i++)
330 if (Controls.headlight_count)
332 for (i=0;i<Controls.headlight_count;i++)
333 toggle_headlight_active ();
336 if (Global_missile_firing_count < 0)
337 Global_missile_firing_count = 0;
339 // Drop proximity bombs.
340 if (Controls.drop_bomb_down_count) {
341 int ssw_save = Secondary_weapon;
343 while (Controls.drop_bomb_down_count--) {
346 ssw_save2 = Secondary_weapon = which_bomb();
348 do_missile_firing(Secondary_weapon == ssw_save); //only allow autoselect if bomb is actually selected
350 if (Secondary_weapon != ssw_save2 && ssw_save == ssw_save2)
351 ssw_save = Secondary_weapon; //if bomb was selected, and we ran out & autoselect, then stick with new selection
354 Secondary_weapon = ssw_save;
362 extern void game_render_frame();
363 extern void show_extra_views();
364 extern fix Flash_effect;
366 void apply_modified_palette(void)
369 //@@ grs_bitmap *sbp;
370 //@@ grs_canvas *save_canv;
371 //@@ int color_xlate[256];
374 //@@ if (!Flash_effect && ((PaletteRedAdd < 10) || (PaletteRedAdd < (PaletteGreenAdd + PaletteBlueAdd))))
377 //@@ reset_cockpit();
379 //@@ save_canv = grd_curcanv;
380 //@@ gr_set_current_canvas(&grd_curscreen->sc_canvas);
382 //@@ sbp = &grd_curscreen->sc_canvas.cv_bitmap;
384 //@@ for (x=0; x<256; x++)
385 //@@ color_xlate[x] = -1;
387 //@@ for (k=0; k<4; k++) {
388 //@@ for (y=0; y<grd_curscreen->sc_h; y+= 4) {
389 //@@ for (x=0; x<grd_curscreen->sc_w; x++) {
390 //@@ int color, new_color;
397 //@@ color = gr_ugpixel(sbp, xcrd, ycrd);
399 //@@ if (color_xlate[color] == -1) {
400 //@@ r = gr_palette[color*3+0];
401 //@@ g = gr_palette[color*3+1];
402 //@@ b = gr_palette[color*3+2];
404 //@@ r += PaletteRedAdd; if (r > 63) r = 63;
405 //@@ g += PaletteGreenAdd; if (g > 63) g = 63;
406 //@@ b += PaletteBlueAdd; if (b > 63) b = 63;
408 //@@ color_xlate[color] = gr_find_closest_color_current(r, g, b);
412 //@@ new_color = color_xlate[color];
414 //@@ gr_setcolor(new_color);
415 //@@ gr_upixel(xcrd, ycrd);
421 void format_time(char *str, int secs_int)
429 sprintf(str, "%1d:%02d:%02d", h, m, s );
432 extern int Redbook_playing;
433 void do_show_netgame_help();
435 //Process selected keys until game unpaused. returns key that left pause (p or esc)
440 char total_time[9],level_time[9];
444 if (Game_paused) { //unpause!
446 #if defined (TACTILE)
454 if (Game_mode & GM_NETWORK)
456 do_show_netgame_help();
459 else if (Game_mode & GM_MULTI)
461 HUD_init_message ("You cannot pause in a modem/serial game!");
471 apply_modified_palette();
474 // -- Matt: This is a hacked-in test for the stupid menu/flash problem.
475 // We need a new brightening primitive if we want to make this not horribly ugly.
476 // Gr_scanline_darkening_level = 2;
477 // gr_rect(0, 0, 319, 199);
483 #if defined (TACTILE)
489 // set_screen_mode( SCREEN_MENU );
491 gr_palette_load( gr_palette );
493 format_time(total_time, f2i(Players[Player_num].time_total) + Players[Player_num].hours_total*3600);
494 format_time(level_time, f2i(Players[Player_num].time_level) + Players[Player_num].hours_level*3600);
496 if (Newdemo_state!=ND_STATE_PLAYBACK)
497 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);
499 sprintf(msg,"PAUSE\n\nSkill level: %s\nHostages on board: %d\n",(*(&TXT_DIFFICULTY_1 + (Difficulty_level))),Players[Player_num].hostages_on_board);
501 show_boxed_message(Pause_msg=msg); //TXT_PAUSE);
505 /* give control back to the WM */
506 if (FindArg("-grabmouse"))
507 SDL_WM_GrabInput(SDL_GRAB_OFF);
520 screen_changed = HandleSystemKey(key);
524 if (screen_changed) {
525 // game_render_frame();
526 WIN(set_popup_screen());
527 show_boxed_message(msg);
528 //show_extra_views();
529 if (Cockpit_mode==CM_FULL_COCKPIT || Cockpit_mode==CM_STATUS_BAR)
535 /* keep the mouse from wandering in SDL */
536 if (FindArg("-grabmouse"))
537 SDL_WM_GrabInput(SDL_GRAB_ON);
540 if (VR_screen_flags & VRF_COMPATIBLE_MENUS) {
541 clear_boxed_message();
556 MAC(delay(500);) // delay 1/2 second because of dumb redbook problem
561 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) );
562 extern int network_who_is_master(),network_how_many_connected(),GetMyNetRanking();
563 extern int TotalMissedPackets,TotalPacketsGot;
564 extern char Pauseable_menu;
565 char *NetworkModeNames[]={"Anarchy","Team Anarchy","Robo Anarchy","Cooperative","Capture the Flag","Hoard","Team Hoard","Unknown"};
566 extern char *RankStrings[];
567 extern int PhallicLimit,PhallicMan;
570 void do_show_netgame_help()
578 char *eff_strings[]={"trashing","really hurting","seriously effecting","hurting",
579 "effecting","tarnishing"};
583 m[i].text=(char *)&mtext[i];
584 m[i].type=NM_TYPE_TEXT;
587 sprintf (mtext[num],"Game: %s",Netgame.game_name); num++;
588 sprintf (mtext[num],"Mission: %s",Netgame.mission_title); num++;
589 sprintf (mtext[num],"Current Level: %d",Netgame.levelnum); num++;
590 sprintf (mtext[num],"Difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty)); num++;
591 sprintf (mtext[num],"Game Mode: %s",NetworkModeNames[Netgame.gamemode]); num++;
592 sprintf (mtext[num],"Game Master: %s",Players[network_who_is_master()].callsign); num++;
593 sprintf (mtext[num],"Number of players: %d/%d",network_how_many_connected(),Netgame.max_numplayers); num++;
594 sprintf (mtext[num],"Packets per second: %d",Netgame.PacketsPerSec); num++;
595 sprintf (mtext[num],"Short Packets: %s",Netgame.ShortPackets?"Yes":"No"); num++;
598 pl=(int)(((float)TotalMissedPackets/(float)TotalPacketsGot)*100.0);
601 sprintf (mtext[num],"Packets lost: %d (%d%%)",TotalMissedPackets,pl); num++;
604 if (Netgame.KillGoal)
605 { sprintf (mtext[num],"Kill goal: %d",Netgame.KillGoal*5); num++; }
607 sprintf (mtext[num]," "); num++;
608 sprintf (mtext[num],"Connected players:"); num++;
610 NetPlayers.players[Player_num].rank=GetMyNetRanking();
612 for (i=0;i<N_players;i++)
613 if (Players[i].connected)
615 if (!FindArg ("-norankings"))
618 sprintf (mtext[num],"%s%s (%d/%d)",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,Netlife_kills,Netlife_killed);
620 sprintf (mtext[num],"%s%s %d/%d",RankStrings[NetPlayers.players[i].rank],Players[i].callsign,kill_matrix[Player_num][i],
621 kill_matrix[i][Player_num]);
625 sprintf (mtext[num++],"%s",Players[i].callsign);
629 sprintf (mtext[num]," "); num++;
631 eff=(int)((float)((float)Netlife_kills/((float)Netlife_killed+(float)Netlife_kills))*100.0);
636 if (Game_mode & GM_HOARD)
639 sprintf (mtext[num],"There is no record yet for this level.");
641 sprintf (mtext[num],"%s has the record at %d points.",Players[PhallicMan].callsign,PhallicLimit);
644 else if (!FindArg ("-norankings"))
648 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
649 sprintf (mtext[num],"is %s your ranking.",eff_strings[eff/10]); num++;
653 sprintf (mtext[num],"Your lifetime efficiency of %d%%",eff); num++;
654 sprintf (mtext[num],"is serving you well."); num++;
662 newmenu_dotiny2( NULL, "Netgame Information", num, m, NULL);
668 void HandleEndlevelKey(int key)
672 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) )
675 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
679 if (key==KEY_PRINT_SCREEN)
683 if ( key == (KEY_COMMAND+KEY_P) )
684 key = do_game_pause();
686 if (key == KEY_PAUSE)
687 key = do_game_pause(); //so esc from pause will end level
689 if (key == KEY_ESC) {
690 stop_endlevel_sequence();
691 last_drawn_cockpit[0]=-1;
692 last_drawn_cockpit[1]=-1;
696 if (key == KEY_BACKSP)
700 void HandleDeathKey(int key)
703 Commented out redundant calls because the key used here typically
704 will be passed to HandleSystemKey later. Note that I do this to pause
705 which is supposed to pass the ESC key to leave the level. This
706 doesn't work in the DOS version anyway. -Samir
709 if (Player_exploded && !key_isfunc(key) && !key_ismod(key))
710 Death_sequence_aborted = 1; //Any key but func or modifier aborts
713 if ( key == (KEY_COMMAND + KEY_SHIFTED + KEY_3) ) {
714 // save_screen_shot(0);
715 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
718 if ( key == KEY_COMMAND+KEY_Q && !(Game_mode & GM_MULTI) )
722 if (key==KEY_PRINT_SCREEN) {
723 // save_screen_shot(0);
724 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
728 if ( key == (KEY_COMMAND+KEY_P) ) {
729 // key = do_game_pause();
730 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
734 if (key == KEY_PAUSE) {
735 // key = do_game_pause(); //so esc from pause will end level
736 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
739 if (key == KEY_ESC) {
740 if (ConsoleObject->flags & OF_EXPLODING)
741 Death_sequence_aborted = 1;
744 if (key == KEY_BACKSP) {
745 Death_sequence_aborted = 0; // Clear because code above sets this for any key.
749 //don't abort death sequence for netgame join/refuse keys
750 if ( (key == KEY_ALTED + KEY_1) ||
751 (key == KEY_ALTED + KEY_2))
752 Death_sequence_aborted = 0;
754 if (Death_sequence_aborted)
759 void HandleDemoKey(int key)
765 if (!(Guided_missile[Player_num] && Guided_missile[Player_num]->type==OBJ_WEAPON && Guided_missile[Player_num]->id==GUIDEDMISS_ID && Guided_missile[Player_num]->signature==Guided_missile_sig[Player_num] && Guided_in_big_window))
769 case KEY_SHIFTED+KEY_MINUS:
770 case KEY_MINUS: shrink_window(); break;
772 case KEY_SHIFTED+KEY_EQUAL:
773 case KEY_EQUAL: grow_window(); break;
775 MAC(case KEY_COMMAND+KEY_2:)
776 case KEY_F2: Config_menu_flag = 1; break;
778 MAC(case KEY_COMMAND+KEY_7:)
781 Show_kill_list = (Show_kill_list+1) % ((Newdemo_game_mode & GM_TEAM) ? 4 : 3);
785 Function_mode = FMODE_MENU;
788 Newdemo_vcr_state = ND_STATE_PLAYBACK;
791 Newdemo_vcr_state = ND_STATE_PAUSED;
794 newdemo_single_frame_time = timer_get_fixed_seconds();
795 Newdemo_vcr_state = ND_STATE_ONEFRAMEBACKWARD;
798 newdemo_single_frame_time = timer_get_fixed_seconds();
799 Newdemo_vcr_state = ND_STATE_ONEFRAMEFORWARD;
801 case KEY_CTRLED + KEY_RIGHT:
804 case KEY_CTRLED + KEY_LEFT:
805 newdemo_goto_beginning();
808 MAC(case KEY_COMMAND+KEY_P:)
813 MAC(case KEY_COMMAND + KEY_SHIFTED + KEY_3:)
814 case KEY_PRINT_SCREEN: {
817 old_state = Newdemo_vcr_state;
818 Newdemo_vcr_state = ND_STATE_PRINTSCREEN;
819 game_render_frame_mono();
821 Newdemo_vcr_state = old_state;
826 case KEY_COMMAND+KEY_Q:
827 if ( !(Game_mode & GM_MULTI) )
836 case KEY_DEBUGGED + KEY_I:
837 Newdemo_do_interpolate = !Newdemo_do_interpolate;
838 if (Newdemo_do_interpolate)
839 mprintf ((0, "demo playback interpolation now on\n"));
841 mprintf ((0, "demo playback interpolation now off\n"));
843 case KEY_DEBUGGED + KEY_K: {
845 char filename[FILENAME_LEN], num[16];
849 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "output file name";
850 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 8; m[1].text = filename;
851 c = newmenu_do( NULL, NULL, 2, m, NULL );
854 strcat(filename, ".dem");
856 m[ 0].type = NM_TYPE_TEXT; m[ 0].text = "strip how many bytes";
857 m[ 1].type = NM_TYPE_INPUT;m[ 1].text_len = 16; m[1].text = num;
858 c = newmenu_do( NULL, NULL, 2, m, NULL );
861 how_many = atoi(num);
864 newdemo_strip_frames(filename, how_many);
873 //switch a cockpit window to the next function
874 int select_next_window_function(int w)
876 Assert(w==0 || w==1);
878 switch (Cockpit_3d_view[w]) {
880 Cockpit_3d_view[w] = CV_REAR;
884 Cockpit_3d_view[w] = CV_ESCORT;
887 //if no ecort, fall through
889 Coop_view_player[w] = -1; //force first player
893 Marker_viewer_num[w] = -1;
894 if ((Game_mode & GM_MULTI_COOP) || (Game_mode & GM_TEAM)) {
895 Cockpit_3d_view[w] = CV_COOP;
897 Coop_view_player[w]++;
898 if (Coop_view_player[w] == N_players) {
899 Cockpit_3d_view[w] = CV_MARKER;
902 if (Coop_view_player[w]==Player_num)
905 if (Game_mode & GM_MULTI_COOP)
907 else if (get_team(Coop_view_player[w]) == get_team(Player_num))
912 //if not multi, fall through
915 if ((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP) && Netgame.Allow_marker_view) { //anarchy only
916 Cockpit_3d_view[w] = CV_MARKER;
917 if (Marker_viewer_num[w] == -1)
918 Marker_viewer_num[w] = Player_num * 2;
919 else if (Marker_viewer_num[w] == Player_num * 2)
920 Marker_viewer_num[w]++;
922 Cockpit_3d_view[w] = CV_NONE;
926 Cockpit_3d_view[w] = CV_NONE;
931 return 1; //screen_changed
934 extern int Game_paused;
936 void songs_goto_next_song();
937 void songs_goto_prev_song();
939 #ifdef DOOR_DEBUGGING
940 dump_door_debugging_info()
950 obj = &Objects[Players[Player_num].objnum];
951 vm_vec_scale_add(&new_pos,&obj->pos,&obj->orient.fvec,i2f(100));
954 fq.startseg = obj->segnum;
957 fq.thisobjnum = Players[Player_num].objnum;
958 fq.ignore_obj_list = NULL;
961 fate = find_vector_intersection(&fq,&hit_info);
963 dfile = fopen("door.out","at");
965 fprintf(dfile,"FVI hit_type = %d\n",fate);
966 fprintf(dfile," hit_seg = %d\n",hit_info.hit_seg);
967 fprintf(dfile," hit_side = %d\n",hit_info.hit_side);
968 fprintf(dfile," hit_side_seg = %d\n",hit_info.hit_side_seg);
971 if (fate == HIT_WALL) {
973 wall_num = Segments[hit_info.hit_seg].sides[hit_info.hit_side].wall_num;
974 fprintf(dfile,"wall_num = %d\n",wall_num);
976 if (wall_num != -1) {
977 wall *wall = &Walls[wall_num];
981 fprintf(dfile," segnum = %d\n",wall->segnum);
982 fprintf(dfile," sidenum = %d\n",wall->sidenum);
983 fprintf(dfile," hps = %x\n",wall->hps);
984 fprintf(dfile," linked_wall = %d\n",wall->linked_wall);
985 fprintf(dfile," type = %d\n",wall->type);
986 fprintf(dfile," flags = %x\n",wall->flags);
987 fprintf(dfile," state = %d\n",wall->state);
988 fprintf(dfile," trigger = %d\n",wall->trigger);
989 fprintf(dfile," clip_num = %d\n",wall->clip_num);
990 fprintf(dfile," keys = %x\n",wall->keys);
991 fprintf(dfile," controlling_trigger = %d\n",wall->controlling_trigger);
992 fprintf(dfile," cloak_value = %d\n",wall->cloak_value);
996 for (i=0;i<Num_open_doors;i++) { //find door
998 if (d->front_wallnum[0]==wall-Walls || d->back_wallnum[0]==wall-Walls || (d->n_parts==2 && (d->front_wallnum[1]==wall-Walls || d->back_wallnum[1]==wall-Walls)))
1002 if (i>=Num_open_doors)
1003 fprintf(dfile,"No active door.\n");
1005 fprintf(dfile,"Active door %d:\n",i);
1006 fprintf(dfile," n_parts = %d\n",d->n_parts);
1007 fprintf(dfile," front_wallnum = %d,%d\n",d->front_wallnum[0],d->front_wallnum[1]);
1008 fprintf(dfile," back_wallnum = %d,%d\n",d->back_wallnum[0],d->back_wallnum[1]);
1009 fprintf(dfile," time = %x\n",d->time);
1015 fprintf(dfile,"\n");
1016 fprintf(dfile,"\n");
1024 //this is for system-level keys, such as help, etc.
1025 //returns 1 if screen changed
1026 int HandleSystemKey(int key)
1028 int screen_changed=0;
1030 if (!Player_is_dead)
1033 #ifdef DOOR_DEBUGGING
1034 case KEY_LAPOSTRO+KEY_SHIFTED:
1035 dump_door_debugging_info();
1044 Function_mode = FMODE_MENU;
1048 // fleshed these out because F1 and F2 aren't sequenctial keycodes on mac -- MWA
1050 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_1:)
1051 case KEY_SHIFTED+KEY_F1:
1052 screen_changed = select_next_window_function(0);
1054 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_2:)
1055 case KEY_SHIFTED+KEY_F2:
1056 screen_changed = select_next_window_function(1);
1063 case KEY_SHIFTED + KEY_LAPOSTRO:
1067 case KEY_SHIFTED + KEY_ESC: //quick exit
1069 if (! SafetyCheck()) break;
1070 close_editor_screen();
1074 Function_mode=FMODE_EXIT;
1077 MAC( case KEY_COMMAND+KEY_P: )
1079 do_game_pause(); break;
1081 MAC(case KEY_COMMAND + KEY_SHIFTED + KEY_3:)
1082 case KEY_PRINT_SCREEN: save_screen_shot(0); break;
1084 MAC(case KEY_COMMAND+KEY_1:)
1085 case KEY_F1: do_show_help(); break;
1087 MAC(case KEY_COMMAND+KEY_2:)
1088 case KEY_F2: //Config_menu_flag = 1; break;
1090 if (!(Game_mode&GM_MULTI)) {palette_save(); apply_modified_palette(); reset_palette_add(); gr_palette_load(gr_palette); }
1092 if (!(Game_mode&GM_MULTI)) palette_restore();
1097 MAC(case KEY_COMMAND+KEY_3:)
1100 if (!(Guided_missile[Player_num] && Guided_missile[Player_num]->type==OBJ_WEAPON && Guided_missile[Player_num]->id==GUIDEDMISS_ID && Guided_missile[Player_num]->signature==Guided_missile_sig[Player_num] && Guided_in_big_window))
1102 toggle_cockpit(); screen_changed=1;
1106 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_7:)
1107 case KEY_F7+KEY_SHIFTED: palette_save(); joydefs_calibrate(); palette_restore(); break;
1109 case KEY_SHIFTED+KEY_MINUS:
1115 case KEY_SHIFTED+KEY_EQUAL:
1121 MAC(case KEY_COMMAND+KEY_5:)
1123 if ( Newdemo_state == ND_STATE_RECORDING )
1124 newdemo_stop_recording();
1125 else if ( Newdemo_state == ND_STATE_NORMAL )
1126 if (!Game_paused) //can't start demo while paused
1127 newdemo_start_recording();
1130 MAC(case KEY_COMMAND+KEY_ALTED+KEY_4:)
1131 case KEY_ALTED+KEY_F4:
1133 Show_reticle_name = (Show_reticle_name+1)%2;
1137 MAC(case KEY_COMMAND + KEY_6:)
1139 if (!Player_is_dead && !(Game_mode & GM_MULTI))
1141 int rsave, gsave, bsave;
1142 rsave = PaletteRedAdd;
1143 gsave = PaletteGreenAdd;
1144 bsave = PaletteBlueAdd;
1146 full_palette_save();
1147 PaletteRedAdd = rsave;
1148 PaletteGreenAdd = gsave;
1149 PaletteBlueAdd = bsave;
1150 state_save_all(0, 0, NULL, 1); // 0 means not between levels.
1155 MAC(case KEY_COMMAND+KEY_7:)
1158 Show_kill_list = (Show_kill_list+1) % ((Game_mode & GM_TEAM) ? 4 : 3);
1159 if (Game_mode & GM_MULTI)
1160 multi_sort_kill_list();
1164 MAC(case KEY_COMMAND+KEY_8:)
1167 multi_send_message_start();
1176 multi_send_macro(key);
1178 break; // send taunt macros
1181 case KEY_9 + KEY_COMMAND:
1182 multi_send_macro(KEY_F9);
1184 case KEY_0 + KEY_COMMAND:
1185 multi_send_macro(KEY_F10);
1187 case KEY_1 + KEY_COMMAND + KEY_CTRLED:
1188 multi_send_macro(KEY_F11);
1190 case KEY_2 + KEY_COMMAND + KEY_CTRLED:
1191 multi_send_macro(KEY_F12);
1195 case KEY_SHIFTED + KEY_F9:
1196 case KEY_SHIFTED + KEY_F10:
1197 case KEY_SHIFTED + KEY_F11:
1198 case KEY_SHIFTED + KEY_F12:
1200 multi_define_macro(key);
1202 break; // redefine taunt macros
1205 case KEY_9 + KEY_SHIFTED + KEY_COMMAND:
1206 multi_define_macro(KEY_F9);
1208 case KEY_0 + KEY_SHIFTED + KEY_COMMAND:
1209 multi_define_macro(KEY_F10);
1211 case KEY_1 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1212 multi_define_macro(KEY_F11);
1214 case KEY_2 + KEY_SHIFTED + KEY_COMMAND + KEY_CTRLED:
1215 multi_define_macro(KEY_F12);
1220 MAC(case KEY_COMMAND+KEY_S:)
1221 MAC(case KEY_COMMAND+KEY_ALTED+KEY_2:)
1222 case KEY_ALTED+KEY_F2:
1223 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1224 int rsave, gsave, bsave;
1225 rsave = PaletteRedAdd;
1226 gsave = PaletteGreenAdd;
1227 bsave = PaletteBlueAdd;
1229 full_palette_save();
1230 PaletteRedAdd = rsave;
1231 PaletteGreenAdd = gsave;
1232 PaletteBlueAdd = bsave;
1233 state_save_all(0, 0, NULL, 0); // 0 means not between levels.
1238 MAC(case KEY_COMMAND+KEY_O:)
1239 MAC(case KEY_COMMAND+KEY_ALTED+KEY_3:)
1240 case KEY_ALTED+KEY_F3:
1241 if (!Player_is_dead && !((Game_mode & GM_MULTI) && !(Game_mode & GM_MULTI_COOP))) {
1242 full_palette_save();
1243 state_restore_all(1, 0, NULL);
1250 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_4:)
1251 case KEY_F4 + KEY_SHIFTED:
1256 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_ALTED+KEY_4:)
1257 case KEY_F4 + KEY_SHIFTED + KEY_ALTED:
1258 change_guidebot_name();
1261 case KEY_MINUS + KEY_ALTED: songs_goto_prev_song(); break;
1262 case KEY_EQUAL + KEY_ALTED: songs_goto_next_song(); break;
1266 case KEY_COMMAND+KEY_M:
1267 #if !defined(SHAREWARE) || defined(APPLE_DEMO)
1268 if ( (Game_mode & GM_MULTI) ) // don't process in multiplayer games
1271 key_close(); // no processing of keys with keyboard handler.. jeez
1273 show_boxed_message ("Mounting CD\nESC to quit");
1274 RBAMountDisk(); // OS has totaly control of the CD.
1275 if (Function_mode == FMODE_MENU)
1276 songs_play_song(SONG_TITLE,1);
1277 else if (Function_mode == FMODE_GAME)
1278 songs_play_level_song( Current_level_num );
1279 clear_boxed_message();
1286 case KEY_COMMAND+KEY_E:
1287 songs_stop_redbook();
1291 case KEY_COMMAND+KEY_RIGHT:
1292 songs_goto_next_song();
1294 case KEY_COMMAND+KEY_LEFT:
1295 songs_goto_prev_song();
1297 case KEY_COMMAND+KEY_UP:
1298 songs_play_level_song(1);
1300 case KEY_COMMAND+KEY_DOWN:
1301 songs_stop_redbook();
1304 case KEY_COMMAND+KEY_Q:
1305 if ( !(Game_mode & GM_MULTI) )
1310 //added 8/23/99 by Matt Mueller for hot key res/fullscreen changing, and menu access
1311 case KEY_CTRLED+KEY_SHIFTED+KEY_PADDIVIDE:
1312 case KEY_ALTED+KEY_CTRLED+KEY_PADDIVIDE:
1313 case KEY_ALTED+KEY_SHIFTED+KEY_PADDIVIDE:
1317 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMULTIPLY:
1318 case KEY_ALTED+KEY_CTRLED+KEY_PADMULTIPLY:
1319 case KEY_ALTED+KEY_SHIFTED+KEY_PADMULTIPLY:
1322 case KEY_CTRLED+KEY_SHIFTED+KEY_PADMINUS:
1323 case KEY_ALTED+KEY_CTRLED+KEY_PADMINUS:
1324 case KEY_ALTED+KEY_SHIFTED+KEY_PADMINUS:
1326 //should we just cycle through the list that is displayed in the res change menu?
1327 // what if their card/X/etc can't handle that mode? hrm.
1328 //well, the quick access to the menu is good enough for now.
1330 case KEY_CTRLED+KEY_SHIFTED+KEY_PADPLUS:
1331 case KEY_ALTED+KEY_CTRLED+KEY_PADPLUS:
1332 case KEY_ALTED+KEY_SHIFTED+KEY_PADPLUS:
1336 case KEY_ALTED+KEY_ENTER:
1337 case KEY_ALTED+KEY_PADENTER:
1338 gr_toggle_fullscreen_game();
1342 //added 11/01/98 Matt Mueller
1344 case KEY_CTRLED+KEY_ALTED+KEY_LAPOSTRO:
1355 return screen_changed;
1359 void HandleVRKey(int key)
1363 case KEY_ALTED+KEY_F5:
1364 if ( VR_render_mode != VR_NONE ) {
1366 HUD_init_message( "-Stereoscopic Parameters Reset-" );
1367 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1368 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1372 case KEY_ALTED+KEY_F6:
1373 if ( VR_render_mode != VR_NONE ) {
1375 if ( VR_low_res > 3 ) VR_low_res = 0;
1376 switch( VR_low_res ) {
1377 case 0: HUD_init_message( "Normal Resolution" ); break;
1378 case 1: HUD_init_message( "Low Vertical Resolution" ); break;
1379 case 2: HUD_init_message( "Low Horizontal Resolution" ); break;
1380 case 3: HUD_init_message( "Low Resolution" ); break;
1385 case KEY_ALTED+KEY_F7:
1386 if ( VR_render_mode != VR_NONE ) {
1387 VR_eye_switch = !VR_eye_switch;
1388 HUD_init_message( "-Eyes toggled-" );
1389 if ( VR_eye_switch )
1390 HUD_init_message( "Right Eye -- Left Eye" );
1392 HUD_init_message( "Left Eye -- Right Eye" );
1396 case KEY_ALTED+KEY_F8:
1397 if ( VR_render_mode != VR_NONE ) {
1399 if (VR_sensitivity > 2 )
1401 HUD_init_message( "Head tracking sensitivy = %d", VR_sensitivity );
1404 case KEY_ALTED+KEY_F9:
1405 if ( VR_render_mode != VR_NONE ) {
1406 VR_eye_width -= F1_0/10;
1407 if ( VR_eye_width < 0 ) VR_eye_width = 0;
1408 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1409 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1412 case KEY_ALTED+KEY_F10:
1413 if ( VR_render_mode != VR_NONE ) {
1414 VR_eye_width += F1_0/10;
1415 if ( VR_eye_width > F1_0*4 ) VR_eye_width = F1_0*4;
1416 HUD_init_message( "Interaxial Separation = %.2f", f2fl(VR_eye_width) );
1417 HUD_init_message( "(The default value is %.2f)", f2fl(VR_SEPARATION) );
1421 case KEY_ALTED+KEY_F11:
1422 if ( VR_render_mode != VR_NONE ) {
1424 if ( VR_eye_offset < -30 ) VR_eye_offset = -30;
1425 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1426 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1427 VR_eye_offset_changed = 2;
1430 case KEY_ALTED+KEY_F12:
1431 if ( VR_render_mode != VR_NONE ) {
1433 if ( VR_eye_offset > 30 ) VR_eye_offset = 30;
1434 HUD_init_message( "Stereo balance = %.2f", (float)VR_eye_offset/30.0 );
1435 HUD_init_message( "(The default value is %.2f)", (float)VR_PIXEL_SHIFT/30.0 );
1436 VR_eye_offset_changed = 2;
1443 extern void DropFlag();
1445 void HandleGameKey(int key)
1449 #if defined(MACINTOSH) && !defined(RELEASE)
1450 case KEY_COMMAND+KEY_F: r_framerate.value = !r_framerate.value; break;
1453 #ifndef D2X_KEYS // weapon selection handled in controls_read_all, d1x-style
1454 // MWA changed the weapon select cases to have each case call
1455 // do_weapon_select the macintosh keycodes aren't consecutive from 1
1456 // -- 0 on the keyboard -- boy is that STUPID!!!!
1458 // Select primary or secondary weapon.
1460 do_weapon_select(0 , 0);
1463 do_weapon_select(1 , 0);
1466 do_weapon_select(2 , 0);
1469 do_weapon_select(3 , 0);
1472 do_weapon_select(4 , 0);
1476 do_weapon_select(0 , 1);
1479 do_weapon_select(1 , 1);
1482 do_weapon_select(2 , 1);
1485 do_weapon_select(3 , 1);
1488 do_weapon_select(4 , 1);
1492 case KEY_1 + KEY_SHIFTED:
1493 case KEY_2 + KEY_SHIFTED:
1494 case KEY_3 + KEY_SHIFTED:
1495 case KEY_4 + KEY_SHIFTED:
1496 case KEY_5 + KEY_SHIFTED:
1497 case KEY_6 + KEY_SHIFTED:
1498 case KEY_7 + KEY_SHIFTED:
1499 case KEY_8 + KEY_SHIFTED:
1500 case KEY_9 + KEY_SHIFTED:
1501 case KEY_0 + KEY_SHIFTED:
1504 if (!(Game_mode & GM_MULTI))
1505 set_escort_special_goal(key);
1507 HUD_init_message ("No Guide-Bot in Multiplayer!");
1511 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_5:)
1512 case KEY_F5 + KEY_SHIFTED:
1513 DropCurrentWeapon();
1516 MAC(case KEY_COMMAND+KEY_SHIFTED+KEY_6:)
1517 case KEY_F6 + KEY_SHIFTED:
1518 DropSecondaryWeapon();
1522 case KEY_0 + KEY_ALTED:
1527 MAC(case KEY_COMMAND+KEY_4:)
1529 if (!DefiningMarkerMessage)
1534 MAC(case KEY_COMMAND+KEY_6:)
1536 if (Netgame.RefusePlayers && WaitForRefuseAnswer && !(Game_mode & GM_TEAM))
1539 HUD_init_message ("Player accepted!");
1542 case KEY_ALTED + KEY_1:
1543 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1546 HUD_init_message ("Player accepted!");
1550 case KEY_ALTED + KEY_2:
1551 if (Netgame.RefusePlayers && WaitForRefuseAnswer && (Game_mode & GM_TEAM))
1554 HUD_init_message ("Player accepted!");
1566 void kill_all_robots(void)
1568 int i, dead_count=0;
1569 //int boss_index = -1;
1571 // Kill all bots except for Buddy bot and boss. However, if only boss and buddy left, kill boss.
1572 for (i=0; i<=Highest_object_index; i++)
1573 if (Objects[i].type == OBJ_ROBOT) {
1574 if (!Robot_info[Objects[i].id].companion && !Robot_info[Objects[i].id].boss_flag) {
1576 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1580 // -- // Now, if more than boss and buddy left, un-kill boss.
1581 // -- if ((dead_count > 2) && (boss_index != -1)) {
1582 // -- Objects[boss_index].flags &= ~(OF_EXPLODING|OF_SHOULD_BE_DEAD);
1584 // -- } else if (boss_index != -1)
1585 // -- HUD_init_message("Toasted the BOSS!");
1587 // Toast the buddy if nothing else toasted!
1588 if (dead_count == 0)
1589 for (i=0; i<=Highest_object_index; i++)
1590 if (Objects[i].type == OBJ_ROBOT)
1591 if (Robot_info[Objects[i].id].companion) {
1592 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1593 HUD_init_message("Toasted the Buddy! *sniff*");
1597 HUD_init_message("%i robots toasted!", dead_count);
1600 // --------------------------------------------------------------------------
1601 // Detonate reactor.
1602 // Award player all powerups in mine.
1603 // Place player just outside exit.
1604 // Kill all bots in mine.
1606 void kill_and_so_forth(void)
1610 HUD_init_message("Killing, awarding, etc.!");
1612 for (i=0; i<=Highest_object_index; i++) {
1613 switch (Objects[i].type) {
1615 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1618 do_powerup(&Objects[i]);
1623 do_controlcen_destroyed_stuff(NULL);
1625 for (i=0; i<Num_triggers; i++) {
1626 if (Triggers[i].type == TT_EXIT) {
1627 for (j=0; j<Num_walls; j++) {
1628 if (Walls[j].trigger == i) {
1629 compute_segment_center(&ConsoleObject->pos, &Segments[Walls[j].segnum]);
1630 obj_relink(OBJECT_NUMBER(ConsoleObject), Walls[j].segnum);
1643 void kill_all_snipers(void)
1645 int i, dead_count=0;
1647 // Kill all snipers.
1648 for (i=0; i<=Highest_object_index; i++)
1649 if (Objects[i].type == OBJ_ROBOT)
1650 if (Objects[i].ctype.ai_info.behavior == AIB_SNIPE) {
1652 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1655 HUD_init_message("%i robots toasted!", dead_count);
1658 void kill_thief(void)
1663 for (i=0; i<=Highest_object_index; i++)
1664 if (Objects[i].type == OBJ_ROBOT)
1665 if (Robot_info[Objects[i].id].thief) {
1666 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1667 HUD_init_message("Thief toasted!");
1671 void kill_buddy(void)
1676 for (i=0; i<=Highest_object_index; i++)
1677 if (Objects[i].type == OBJ_ROBOT)
1678 if (Robot_info[Objects[i].id].companion) {
1679 Objects[i].flags |= OF_EXPLODING|OF_SHOULD_BE_DEAD;
1680 HUD_init_message("Buddy toasted!");
1684 void toggle_movie_saving(void);
1685 extern char Language[];
1687 void HandleTestKey(int key)
1691 case KEY_DEBUGGED+KEY_0: show_weapon_status(); break;
1693 #ifdef SHOW_EXIT_PATH
1694 case KEY_DEBUGGED+KEY_1: create_special_path(); break;
1697 case KEY_DEBUGGED+KEY_Y:
1698 do_controlcen_destroyed_stuff(NULL);
1702 case KEY_DEBUGGED+KEY_ALTED+KEY_D:
1703 Netlife_kills=4000; Netlife_killed=5;
1704 multi_add_lifetime_kills();
1709 case KEY_CTRLED+KEY_BACKSP:
1710 case KEY_ALTED+KEY_BACKSP:
1711 case KEY_SHIFTED+KEY_BACKSP:
1712 case KEY_SHIFTED+KEY_ALTED+KEY_BACKSP:
1713 case KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1714 case KEY_SHIFTED+KEY_CTRLED+KEY_BACKSP:
1715 case KEY_SHIFTED+KEY_CTRLED+KEY_ALTED+KEY_BACKSP:
1719 case KEY_DEBUGGED+KEY_S: digi_reset(); break;
1721 case KEY_DEBUGGED+KEY_P:
1722 if (Game_suspended & SUSP_ROBOTS)
1723 Game_suspended &= ~SUSP_ROBOTS; //robots move
1725 Game_suspended |= SUSP_ROBOTS; //robots don't move
1730 case KEY_DEBUGGED+KEY_K: Players[Player_num].shields = 1; break; // a virtual kill
1731 case KEY_DEBUGGED+KEY_SHIFTED + KEY_K: Players[Player_num].shields = -1; break; // an actual kill
1732 case KEY_DEBUGGED+KEY_X: Players[Player_num].lives++; break; // Extra life cheat key.
1733 case KEY_DEBUGGED+KEY_H:
1734 // if (!(Game_mode & GM_MULTI) ) {
1735 Players[Player_num].flags ^= PLAYER_FLAGS_CLOAKED;
1736 if (Players[Player_num].flags & PLAYER_FLAGS_CLOAKED) {
1738 if (Game_mode & GM_MULTI)
1741 ai_do_cloak_stuff();
1742 Players[Player_num].cloak_time = GameTime;
1743 mprintf((0, "You are cloaked!\n"));
1745 mprintf((0, "You are DE-cloaked!\n"));
1750 case KEY_DEBUGGED+KEY_R:
1751 Robot_firing_enabled = !Robot_firing_enabled;
1754 case KEY_DEBUGGED+KEY_R+KEY_SHIFTED:
1758 #ifdef EDITOR //editor-specific functions
1760 case KEY_E + KEY_DEBUGGED:
1762 network_leave_game();
1764 Function_mode = FMODE_EDITOR;
1766 case KEY_Q + KEY_SHIFTED + KEY_DEBUGGED:
1769 memcpy(pal_save,gr_palette,768);
1770 init_subtitles("end.tex"); //ingore errors
1771 PlayMovie ("end.mve",MOVIE_ABORT_ON);
1774 set_screen_mode(SCREEN_GAME);
1776 memcpy(gr_palette,pal_save,768);
1777 gr_palette_load(gr_palette);
1780 case KEY_C + KEY_SHIFTED + KEY_DEBUGGED:
1781 if (!( Game_mode & GM_MULTI ))
1782 move_player_2_segment(Cursegp,Curside);
1783 break; //move eye to curseg
1786 case KEY_DEBUGGED+KEY_W: draw_world_from_game(); break;
1788 #endif //#ifdef EDITOR
1791 // case KEY_DEBUGGED+KEY_SHIFTED+KEY_F: toggle_flythrough(); break;
1792 // case KEY_LEFT: ft_preference=FP_LEFT; break;
1793 // case KEY_RIGHT: ft_preference=FP_RIGHT; break;
1794 // case KEY_UP: ft_preference=FP_UP; break;
1795 // case KEY_DOWN: ft_preference=FP_DOWN; break;
1798 case KEY_DEBUGGED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_next_viewer(); break;
1799 case KEY_DEBUGGED+KEY_CTRLED+KEY_LAPOSTRO: Show_view_text_timer = 0x30000; object_goto_prev_viewer(); break;
1801 case KEY_DEBUGGED+KEY_SHIFTED+KEY_LAPOSTRO: Viewer=ConsoleObject; break;
1804 case KEY_DEBUGGED+KEY_O: toggle_outline_mode(); break;
1806 case KEY_DEBUGGED+KEY_T:
1807 *Toggle_var = !*Toggle_var;
1808 mprintf((0, "Variable at %08x set to %i\n", Toggle_var, *Toggle_var));
1810 case KEY_DEBUGGED + KEY_L:
1811 if (++Lighting_on >= 2) Lighting_on = 0; break;
1812 case KEY_DEBUGGED + KEY_SHIFTED + KEY_L:
1813 Beam_brightness=0x38000-Beam_brightness; break;
1814 case KEY_PAD5: slew_stop(); break;
1817 case KEY_DEBUGGED + KEY_F11: play_test_sound(); break;
1818 case KEY_DEBUGGED + KEY_SHIFTED+KEY_F11: advance_sound(); play_test_sound(); break;
1821 case KEY_DEBUGGED +KEY_F4: {
1822 //fvi_info hit_data;
1823 //vms_vector p0 = {-0x1d99a7,-0x1b20000,0x186ab7f};
1824 //vms_vector p1 = {-0x217865,-0x1b20000,0x187de3e};
1825 //find_vector_intersection(&hit_data,&p0,0x1b9,&p1,0x40000,0x0,NULL,-1);
1829 case KEY_DEBUGGED + KEY_M:
1830 Debug_spew = !Debug_spew;
1832 mopen( 0, 8, 1, 78, 16, "Debug Spew");
1833 HUD_init_message( "Debug Spew: ON" );
1836 HUD_init_message( "Debug Spew: OFF" );
1840 case KEY_DEBUGGED + KEY_C:
1842 full_palette_save();
1846 case KEY_DEBUGGED + KEY_SHIFTED + KEY_A:
1847 do_megawow_powerup(10);
1849 case KEY_DEBUGGED + KEY_A: {
1850 do_megawow_powerup(200);
1851 // if ( Game_mode & GM_MULTI ) {
1852 // nm_messagebox( NULL, 1, "Damn", "CHEATER!\nYou cannot use the\nmega-thing in network mode." );
1853 // Network_message_reciever = 100; // Send to everyone...
1854 // sprintf( Network_message, "%s cheated!", Players[Player_num].callsign);
1856 // do_megawow_powerup();
1861 case KEY_DEBUGGED+KEY_F: r_framerate.value = !r_framerate.value; break;
1863 case KEY_DEBUGGED+KEY_SPACEBAR: //KEY_F7: // Toggle physics flying
1865 game_flush_inputs();
1866 if ( ConsoleObject->control_type != CT_FLYING ) {
1867 fly_init(ConsoleObject);
1868 Game_suspended &= ~SUSP_ROBOTS; //robots move
1870 slew_init(ConsoleObject); //start player slewing
1871 Game_suspended |= SUSP_ROBOTS; //robots don't move
1875 case KEY_DEBUGGED+KEY_COMMA: Render_zoom = fixmul(Render_zoom,62259); break;
1876 case KEY_DEBUGGED+KEY_PERIOD: Render_zoom = fixmul(Render_zoom,68985); break;
1878 case KEY_DEBUGGED+KEY_P+KEY_SHIFTED: Debug_pause = 1; break;
1882 // sprintf(mystr,"mark %i start",Mark_count);
1886 //case KEY_SHIFTED+KEY_F7: {
1888 // sprintf(mystr,"mark %i end",Mark_count);
1896 case KEY_DEBUGGED+KEY_F8: speedtest_init(); Speedtest_count = 1; break;
1897 case KEY_DEBUGGED+KEY_F9: speedtest_init(); Speedtest_count = 10; break;
1899 case KEY_DEBUGGED+KEY_D:
1900 if ((Game_double_buffer = !Game_double_buffer)!=0)
1906 case KEY_DEBUGGED+KEY_Q:
1908 dump_used_textures_all();
1913 case KEY_DEBUGGED+KEY_B: {
1915 char text[FILENAME_LEN]="";
1917 m.type=NM_TYPE_INPUT; m.text_len = FILENAME_LEN; m.text = text;
1918 item = newmenu_do( NULL, "Briefing to play?", 1, &m, NULL );
1920 do_briefing_screens(text,1);
1926 case KEY_DEBUGGED+KEY_F5:
1927 toggle_movie_saving();
1930 case KEY_DEBUGGED+KEY_SHIFTED+KEY_F5: {
1931 extern int Movie_fixed_frametime;
1932 Movie_fixed_frametime = !Movie_fixed_frametime;
1936 case KEY_DEBUGGED+KEY_ALTED+KEY_F5:
1937 GameTime = i2f(0x7fff - 840); //will overflow in 14 minutes
1938 mprintf((0,"GameTime bashed to %d secs\n",f2i(GameTime)));
1941 case KEY_DEBUGGED+KEY_SHIFTED+KEY_B:
1942 kill_and_so_forth();
1946 #endif //#ifndef RELEASE
1948 // Cheat functions ------------------------------------------------------------
1949 extern char *jcrypt (char *);
1951 char *LamerCheats[]={ "!UyN#E$I", // gabba-gabbahey
1952 "ei5cQ-ZQ", // mo-therlode
1953 "q^EpZxs8", // c-urrygoat
1954 "mxk(DyyP", // zi-ngermans
1955 "cBo#@y@P", // ea-tangelos
1956 "CLygLBGQ", // e-ricaanne
1957 "xAnHQxZX", // jos-huaakira
1958 "cKc[KUWo", // wh-ammazoom
1961 #define N_LAMER_CHEATS (sizeof(LamerCheats) / sizeof(*LamerCheats))
1963 char *WowieCheat ="F_JMO3CV"; //only Matt knows / h-onestbob
1964 char *AllKeysCheat ="%v%MrgbU"; //only Matt knows / or-algroove
1965 char *InvulCheat ="Wv_\\JJ\\Z"; //only Matt knows / almighty
1966 char *HomingCheatString ="t\\LIhSB["; //only Matt knows / l-pnlizard
1967 char *BouncyCheat ="bGbiChQJ"; //only Matt knows / duddaboo
1968 char *FullMapCheat ="PI<XQHRI"; //only Matt knows / rockrgrl
1969 char *LevelWarpCheat ="ZQHtqbb\""; //only Matt knows / f-reespace
1970 char *MonsterCheat ="nfpEfRQp"; //only Matt knows / godzilla
1971 char *BuddyLifeCheat ="%A-BECuY"; //only Matt knows / he-lpvishnu
1972 char *BuddyDudeCheat ="u#uzIr%e"; //only Matt knows / g-owingnut
1973 char *KillRobotsCheat ="&wxbs:5O"; //only Matt knows / spaniard
1974 char *FinishLevelCheat ="%bG_bZ<D"; //only Matt knows / d-elshiftb
1975 char *RapidFireCheat ="*jLgHi'J"; //only Matt knows / wildfire
1977 char *RobotsKillRobotsCheat ="rT6xD__S"; // New for 1.1 / silkwing
1978 char *AhimsaCheat ="!Uscq_yc"; // New for 1.1 / im-agespace
1980 char *AccessoryCheat ="dWdz[kCK"; // al-ifalafel
1981 char *JohnHeadCheat ="ou]];H:%"; // p-igfarmer
1982 char *AcidCheat ="qPmwxz\"S"; // bit-tersweet
1983 char *FramerateCheat ="rQ60#ZBN"; // f-rametime
1985 char CheatBuffer[]="AAAAAAAAAAAAAAA";
1987 #define CHEATSPOT 14
1990 void do_cheat_penalty ()
1992 digi_play_sample( SOUND_CHEATER, F1_0);
1994 Players[Player_num].score=0;
1998 // Main Cheat function
2002 char john_head_on=0;
2005 char OldHomingState[20];
2006 extern char Monster_mode;
2008 void fill_background();
2009 void load_background_bitmap();
2011 extern int Robots_kill_robots_cheat;
2013 void FinalCheats(int key)
2018 key=key_to_ascii(key);
2021 CheatBuffer[i]=CheatBuffer[i+1];
2023 CheatBuffer[CHEATSPOT]=key;
2025 cryptstring=jcrypt(&CheatBuffer[7]);
2027 for (i=0;i<N_LAMER_CHEATS;i++)
2028 if (!(strcmp (cryptstring,LamerCheats[i])))
2031 Players[Player_num].shields=i2f(1);
2032 Players[Player_num].energy=i2f(1);
2034 if (Game_mode & GM_MULTI)
2036 Network_message_reciever = 100; // Send to everyone...
2037 sprintf( Network_message, "%s is crippled...get him!",Players[Player_num].callsign);
2040 HUD_init_message ("Take that...cheater!");
2043 if (!(strcmp (cryptstring,JohnHeadCheat)))
2045 john_head_on = !john_head_on;
2046 load_background_bitmap();
2048 HUD_init_message (john_head_on?"Hi John!!":"Bye John!!");
2050 if (!(strcmp (cryptstring,AcidCheat)))
2055 Interpolation_method=old_IntMethod;
2056 HUD_init_message ("Coming down...");
2061 old_IntMethod=Interpolation_method;
2062 Interpolation_method=1;
2063 HUD_init_message ("Going up!");
2068 if (!(strcmp (cryptstring,FramerateCheat)))
2070 r_framerate.value = !r_framerate.value;
2073 if (Game_mode & GM_MULTI)
2076 if (!(strcmp (&CheatBuffer[8],"blueorb")))
2078 if (Players[Player_num].shields < MAX_SHIELDS) {
2079 fix boost = 3*F1_0 + 3*F1_0*(NDL - Difficulty_level);
2080 if (Difficulty_level == 0)
2082 Players[Player_num].shields += boost;
2083 if (Players[Player_num].shields > MAX_SHIELDS)
2084 Players[Player_num].shields = MAX_SHIELDS;
2085 powerup_basic(0, 0, 15, SHIELD_SCORE, "%s %s %d",TXT_SHIELD,TXT_BOOSTED_TO,f2ir(Players[Player_num].shields));
2088 HUD_init_message(TXT_MAXED_OUT,TXT_SHIELD);
2091 if (!(strcmp(cryptstring,BuddyLifeCheat)))
2094 HUD_init_message ("What's this? Another buddy bot!");
2099 if (!(strcmp(cryptstring,BuddyDudeCheat)))
2102 Buddy_dude_cheat = !Buddy_dude_cheat;
2103 if (Buddy_dude_cheat) {
2104 HUD_init_message ("%s gets angry!",guidebot_name);
2105 strcpy(guidebot_name,"Wingnut");
2108 strcpy(guidebot_name,real_guidebot_name);
2109 HUD_init_message ("%s calms down",guidebot_name);
2114 if (!(strcmp(cryptstring,MonsterCheat)))
2116 Monster_mode=1-Monster_mode;
2118 HUD_init_message (Monster_mode?"Oh no, there goes Tokyo!":"What have you done, I'm shrinking!!");
2122 if (!(strcmp (cryptstring,BouncyCheat)))
2125 HUD_init_message ("Bouncing weapons!");
2129 if (!(strcmp(cryptstring,LevelWarpCheat)))
2135 //digi_play_sample( SOUND_CHEATER, F1_0);
2136 m.type=NM_TYPE_INPUT; m.text_len = 10; m.text = text;
2137 item = newmenu_do( NULL, TXT_WARP_TO_LEVEL, 1, &m, NULL );
2139 new_level_num = atoi(m.text);
2140 if (new_level_num!=0 && new_level_num>=0 && new_level_num<=Last_level) {
2141 StartNewLevel(new_level_num, 0);
2147 if (!(strcmp (cryptstring,WowieCheat)))
2150 HUD_init_message(TXT_WOWIE_ZOWIE);
2153 if (Piggy_hamfile_version < 3) // SHAREWARE
2155 Players[Player_num].primary_weapon_flags = ~((1<<PHOENIX_INDEX) | (1<<OMEGA_INDEX) | (1<<FUSION_INDEX) | HAS_FLAG(SUPER_LASER_INDEX));
2156 Players[Player_num].secondary_weapon_flags = ~((1<<SMISSILE4_INDEX) | (1<<MEGA_INDEX) | (1<<SMISSILE5_INDEX));
2160 Players[Player_num].primary_weapon_flags = 0xffff ^ HAS_FLAG(SUPER_LASER_INDEX); //no super laser
2161 Players[Player_num].secondary_weapon_flags = 0xffff;
2164 for (i=0; i<MAX_PRIMARY_WEAPONS; i++)
2165 Players[Player_num].primary_ammo[i] = Primary_ammo_max[i];
2167 for (i=0; i<MAX_SECONDARY_WEAPONS; i++)
2168 Players[Player_num].secondary_ammo[i] = Secondary_ammo_max[i];
2170 if (Piggy_hamfile_version < 3) // SHAREWARE
2172 Players[Player_num].secondary_ammo[SMISSILE4_INDEX] = 0;
2173 Players[Player_num].secondary_ammo[SMISSILE5_INDEX] = 0;
2174 Players[Player_num].secondary_ammo[MEGA_INDEX] = 0;
2177 if (Game_mode & GM_HOARD)
2178 Players[Player_num].secondary_ammo[PROXIMITY_INDEX] = 12;
2180 if (Newdemo_state == ND_STATE_RECORDING)
2181 newdemo_record_laser_level(Players[Player_num].laser_level, MAX_LASER_LEVEL);
2183 Players[Player_num].energy = MAX_ENERGY;
2184 Players[Player_num].laser_level = MAX_SUPER_LASER_LEVEL;
2185 Players[Player_num].flags |= PLAYER_FLAGS_QUAD_LASERS;
2186 update_laser_weapon_info();
2190 if (!(strcmp (cryptstring,AllKeysCheat)))
2193 HUD_init_message(TXT_ALL_KEYS);
2194 Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2198 if (!(strcmp (cryptstring,InvulCheat)))
2201 Players[Player_num].flags ^= PLAYER_FLAGS_INVULNERABLE;
2202 HUD_init_message("%s %s!", TXT_INVULNERABILITY, (Players[Player_num].flags&PLAYER_FLAGS_INVULNERABLE)?TXT_ON:TXT_OFF);
2203 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2205 if (!(strcmp (cryptstring,AccessoryCheat)))
2208 Players[Player_num].flags |=PLAYER_FLAGS_HEADLIGHT;
2209 Players[Player_num].flags |=PLAYER_FLAGS_AFTERBURNER;
2210 Players[Player_num].flags |=PLAYER_FLAGS_AMMO_RACK;
2211 Players[Player_num].flags |=PLAYER_FLAGS_CONVERTER;
2213 HUD_init_message ("Accessories!!");
2215 if (!(strcmp (cryptstring,FullMapCheat)))
2218 Players[Player_num].flags |=PLAYER_FLAGS_MAP_ALL;
2220 HUD_init_message ("Full Map!!");
2224 if (!(strcmp (cryptstring,HomingCheatString)))
2231 OldHomingState[i]=Weapon_info[i].homing_flag;
2232 Weapon_info[i].homing_flag=1;
2234 HUD_init_message ("Homing weapons!");
2238 if (!(strcmp (cryptstring,KillRobotsCheat)))
2244 if (!(strcmp (cryptstring,FinishLevelCheat)))
2247 kill_and_so_forth();
2250 if (!(strcmp (cryptstring,RobotsKillRobotsCheat))) {
2251 Robots_kill_robots_cheat = !Robots_kill_robots_cheat;
2252 if (Robots_kill_robots_cheat) {
2253 HUD_init_message ("Rabid robots!");
2257 HUD_init_message ("Kill the player!");
2260 if (!(strcmp (cryptstring,AhimsaCheat))) {
2261 Robot_firing_enabled = !Robot_firing_enabled;
2262 if (!Robot_firing_enabled) {
2263 HUD_init_message("%s", "Robot firing OFF!");
2267 HUD_init_message("%s", "Robot firing ON!");
2270 if (!(strcmp (cryptstring,RapidFireCheat))) {
2271 if (Laser_rapid_fire) {
2272 Laser_rapid_fire = 0;
2273 HUD_init_message("%s", "Rapid fire OFF!");
2276 Laser_rapid_fire = 0xbada55;
2278 HUD_init_message("%s", "Rapid fire ON!");
2285 // Internal Cheat Menu
2287 void do_cheat_menu()
2290 newmenu_item mm[16];
2291 char score_text[21];
2293 sprintf( score_text, "%d", Players[Player_num].score );
2295 mm[0].type=NM_TYPE_CHECK; mm[0].value=Players[Player_num].flags & PLAYER_FLAGS_INVULNERABLE; mm[0].text="Invulnerability";
2296 mm[1].type=NM_TYPE_CHECK; mm[1].value=Players[Player_num].flags & PLAYER_FLAGS_CLOAKED; mm[1].text="Cloaked";
2297 mm[2].type=NM_TYPE_CHECK; mm[2].value=0; mm[2].text="All keys";
2298 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;
2299 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;
2300 mm[5].type=NM_TYPE_TEXT; mm[5].text = "Score:";
2301 mm[6].type=NM_TYPE_INPUT; mm[6].text_len = 10; mm[6].text = score_text;
2302 //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";
2303 //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";
2304 //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";
2305 //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";
2307 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;
2308 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;
2310 mmn = newmenu_do("Wimp Menu",NULL,9, mm, NULL );
2313 if ( mm[0].value ) {
2314 Players[Player_num].flags |= PLAYER_FLAGS_INVULNERABLE;
2315 Players[Player_num].invulnerable_time = GameTime+i2f(1000);
2317 Players[Player_num].flags &= ~PLAYER_FLAGS_INVULNERABLE;
2318 if ( mm[1].value ) {
2319 Players[Player_num].flags |= PLAYER_FLAGS_CLOAKED;
2321 if (Game_mode & GM_MULTI)
2324 ai_do_cloak_stuff();
2325 Players[Player_num].cloak_time = GameTime;
2328 Players[Player_num].flags &= ~PLAYER_FLAGS_CLOAKED;
2330 if (mm[2].value) Players[Player_num].flags |= PLAYER_FLAGS_BLUE_KEY | PLAYER_FLAGS_RED_KEY | PLAYER_FLAGS_GOLD_KEY;
2331 Players[Player_num].energy=i2f(mm[3].value);
2332 Players[Player_num].shields=i2f(mm[4].value);
2333 Players[Player_num].score = atoi(mm[6].text);
2334 //if (mm[7].value) Players[Player_num].laser_level=0;
2335 //if (mm[8].value) Players[Player_num].laser_level=1;
2336 //if (mm[9].value) Players[Player_num].laser_level=2;
2337 //if (mm[10].value) Players[Player_num].laser_level=3;
2338 Players[Player_num].laser_level = mm[7].value-1;
2339 Players[Player_num].secondary_ammo[CONCUSSION_INDEX] = mm[8].value;
2347 // Testing functions ----------------------------------------------------------
2350 void speedtest_init(void)
2352 Speedtest_start_time = timer_get_fixed_seconds();
2354 Speedtest_segnum = 0;
2355 Speedtest_sidenum = 0;
2356 Speedtest_frame_start = FrameCount;
2358 mprintf((0, "Starting speedtest. Will be %i frames. Each . = 10 frames.\n", Highest_segment_index+1));
2361 void speedtest_frame(void)
2363 vms_vector view_dir, center_point;
2365 Speedtest_sidenum=Speedtest_segnum % MAX_SIDES_PER_SEGMENT;
2367 compute_segment_center(&Viewer->pos, &Segments[Speedtest_segnum]);
2368 Viewer->pos.x += 0x10; Viewer->pos.y -= 0x10; Viewer->pos.z += 0x17;
2370 obj_relink(OBJECT_NUMBER(Viewer), Speedtest_segnum);
2371 compute_center_point_on_side(¢er_point, &Segments[Speedtest_segnum], Speedtest_sidenum);
2372 vm_vec_normalized_dir_quick(&view_dir, ¢er_point, &Viewer->pos);
2373 vm_vector_2_matrix(&Viewer->orient, &view_dir, NULL, NULL);
2375 if (((FrameCount - Speedtest_frame_start) % 10) == 0)
2380 if (Speedtest_segnum > Highest_segment_index) {
2383 sprintf(msg, "\nSpeedtest done: %i frames, %7.3f seconds, %7.3f frames/second.\n",
2384 FrameCount-Speedtest_frame_start,
2385 f2fl(timer_get_fixed_seconds() - Speedtest_start_time),
2386 (float) (FrameCount-Speedtest_frame_start) / f2fl(timer_get_fixed_seconds() - Speedtest_start_time));
2388 mprintf((0, "%s", msg));
2389 HUD_init_message(msg);
2392 if (Speedtest_count == 0)
2401 // Sounds for testing
2403 int test_sound_num = 0;
2404 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};
2406 #define N_TEST_SOUNDS (sizeof(sound_nums) / sizeof(*sound_nums))
2409 void advance_sound()
2411 if (++test_sound_num == N_TEST_SOUNDS)
2417 int Test_sound = 251;
2419 void play_test_sound()
2422 // -- digi_play_sample(sound_nums[test_sound_num], F1_0);
2423 digi_play_sample(Test_sound, F1_0);
2426 #endif //ifndef NDEBUG
2436 static ubyte exploding_flag=0;
2438 Player_fired_laser_this_frame=-1;
2440 if (!Endlevel_sequence) // && !Player_is_dead //this was taken out of the if statement by WraithX
2443 if ( (Newdemo_state == ND_STATE_PLAYBACK) || (DefiningMarkerMessage)
2445 || multi_sending_message || multi_defining_message
2447 ) // WATCH OUT!!! WEIRD CODE ABOVE!!!
2448 memset( &Controls, 0, sizeof(control_info) );
2451 controls_read_all_win();
2453 controls_read_all(); //NOTE LINK TO ABOVE!!!
2458 // If automap key pressed, enable automap unless you are in network mode, control center destroyed and < 10 seconds left
2459 if ( Controls.automap_down_count && !((Game_mode & GM_MULTI) && Control_center_destroyed && (Countdown_seconds_left < 10)))
2466 if (Player_exploded) { //Player_is_dead && (ConsoleObject->flags & OF_EXPLODING) ) {
2468 if (exploding_flag==0) {
2469 exploding_flag = 1; // When player starts exploding, clear all input devices...
2470 game_flush_inputs();
2473 //if (key_down_count(KEY_BACKSP))
2475 //if (key_down_count(KEY_PRINT_SCREEN))
2476 // save_screen_shot(0);
2479 for (i = 0; i < 4; i++)
2480 // the following "if" added by WraithX, 4/17/00
2481 if (isJoyRotationKey(i) != 1)
2483 if (joy_get_button_down_cnt(i) > 0)
2484 Death_sequence_aborted = 1;
2485 }// end "if" added by WraithX
2487 if (joy_get_any_button_down_cnt() > 0)
2488 Death_sequence_aborted = 1;
2490 for (i = 0; i < 3; i++)
2491 // the following "if" added by WraithX, 4/17/00
2492 if (isMouseRotationKey(i) != 1)
2494 if (mouse_button_down_count(i) > 0)
2495 Death_sequence_aborted = 1;
2496 }// end "if" added by WraithX
2498 //for (i = 0; i < 256; i++)
2499 // // the following "if" added by WraithX, 4/17/00
2500 // if (isKeyboardRotationKey(i) != 1)
2502 // if (!key_isfunc(i) && !key_ismod(i) && key_down_count(i) > 0)
2503 // Death_sequence_aborted = 1;
2504 // }// end "if" added by WraithX
2506 if (Death_sequence_aborted)
2507 game_flush_inputs();
2513 if (Newdemo_state == ND_STATE_PLAYBACK )
2516 while ((key=key_inkey_time(&key_time)) != 0) {
2518 if (DefiningMarkerMessage)
2520 MarkerInputMessage (key);
2525 if ( (Game_mode&GM_MULTI) && (multi_sending_message || multi_defining_message )) {
2526 multi_message_input_sub( key );
2527 continue; //get next key
2533 if ((key&KEY_DEBUGGED)&&(Game_mode&GM_MULTI)) {
2534 Network_message_reciever = 100; // Send to everyone...
2535 sprintf( Network_message, "%s %s", TXT_I_AM_A, TXT_CHEATER);
2541 if(!con_events(key))
2546 HandleDeathKey(key);
2548 if (Endlevel_sequence)
2549 HandleEndlevelKey(key);
2550 else if (Newdemo_state == ND_STATE_PLAYBACK ) {
2559 HandleSystemKey(key);
2570 // if ((Players[Player_num].flags & PLAYER_FLAGS_CONVERTER) && keyd_pressed[KEY_F8] && (keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT]))
2571 // transfer_energy_to_shield(key_down_time(KEY_F8));