void huxley_mode_init (void) { huxley_suspend = FALSE; ball_search_monitor_stop (); flag_off (FLAG_IS_HUXLEY_ENABLED); task_kill_gid(GID_HUXLEY_REMINDER); huxley_mode_shots_made = 0; score_zero(huxley_mode_score); score_zero(huxley_mode_last_score); score_zero(huxley_mode_next_score); score(HUXLEY_START_SCORE); score_add(huxley_mode_score, score_table[HUXLEY_START_SCORE]); score_add(huxley_mode_next_score, score_table[HUXLEY_MODE_HIT_SCORE]); huxley_counter = 0; //reset for next time deff_start_sync (DEFF_HUXLEY_START_EFFECT);//under /kernel/deff.c ballsave_add_time (system_config.mode_ballsave); leff_start(LEFF_EYEBALL); sol_request_async (SOL_EJECT); //request to fire the eject sol task_sleep (TIME_300MS); set_normal_eject_killed_status (FALSE); ball_search_monitor_start (); set_dm_mode(HUXLEY_COMPLETED); //for BONUS }//end of function
void superjets_mode_init (void) { //the claw mode can expire on its own and since it is a lower priority it will not display // callset_invoke (end_claw_mode); // this seemed to cause occasional crashes clawmagnet_off (); global_flag_off(GLOBAL_FLAG_IS_BALL_ON_CLAW); flipper_enable (); //reset counter if first time run, otherwise do not - player may restart acmag while currently running sound_start (ST_SPEECH, SPCH_SUPERJETS_ACTIVATED, SL_4S, PRI_GAME_QUICK3); ballsave_add_time (system_config.mode_ballsave); //flash lamp for a time lamp_tristate_flash(LM_CLAW_SUPER_JETS); task_sleep(TIME_500MS); lamp_tristate_on(LM_CLAW_SUPER_JETS); if (get_dm_mode(SJETS_COMPLETED)) { score_add(superjets_mode_next_score, score_table[SUPERJETS_HIT_SCORE2]); score_add(superjets_mode_score, score_table[SUPERJETS_START_SCORE2]); score(SUPERJETS_START_SCORE2); } else { superjets_mode_shots_made = 0; score_zero(superjets_mode_score); score_zero(superjets_mode_next_score); score_add(superjets_mode_next_score, score_table[SUPERJETS_HIT_SCORE1]); score_add(superjets_mode_score, score_table[SUPERJETS_START_SCORE1]); score(SUPERJETS_START_SCORE1); } }//end of function
CALLSET_ENTRY (clock_millions, sw_clock_target) { if (timed_mode_running_p (&clock_millions_mode)) { leff_start (LEFF_CLOCK_TARGET); /* Award bonus if hit 6 times */ if (++clock_mode_hits > 5) { sound_send (SND_EXPLOSION_3); score (SC_20M); score_add (clock_mode_score, score_table[SC_20M]); deff_start (DEFF_CLOCK_MILLIONS_EXPLODE); timed_mode_end (&clock_millions_mode); } else { sound_send (SND_CLOCK_BELL); score (SC_5M); score_add (clock_mode_score, score_table[SC_5M]); deff_start (DEFF_CLOCK_MILLIONS_HIT); } if (!global_flag_test (GLOBAL_FLAG_CHAOSMB_RUNNING)) tz_clock_reverse_direction (); tz_clock_set_speed (clock_mode_hits); } else if (!global_flag_test (GLOBAL_FLAG_CHAOSMB_RUNNING)) { callset_invoke (sw_jet_noflash); score (SC_50K); sound_send (SND_NO_CREDITS); } }
CALLSET_ENTRY (superjets, sw_jet) { if (in_game && !in_tilt && timed_mode_running_p(&superjets_mode) ) { ++superjets_mode_shots_made; leff_start (LEFF_FLASH_UR_GI); //score higher if mode done more than once if (get_dm_mode(SJETS_COMPLETED)) { score (SUPERJETS_HIT_SCORE2); score_add (superjets_mode_score, score_table[SUPERJETS_HIT_SCORE2]); } else { score (SUPERJETS_HIT_SCORE1); score_add (superjets_mode_score, score_table[SUPERJETS_HIT_SCORE1]); } if (superjets_mode_shots_made >= superjets_goal) superjets_goal_award(); else { U8 superjets_SoundCounter; superjets_SoundCounter = random_scaled(3);//from kernal/random.c - pick number from 0 to 2 if ( (superjets_SoundCounter) == 0 ) sound_start (ST_SPEECH, SPCH_DULCH, SL_2S, PRI_GAME_QUICK2); else if ( (superjets_SoundCounter) == 1 ) sound_start (ST_SPEECH, SPCH_WOOH, SL_2S, PRI_GAME_QUICK2); else sound_start (ST_SPEECH, SPCH_WOW, SL_2S, PRI_GAME_QUICK2); } }//end of if }//end of function
void prison_break_made (void) { ++prison_break_mode_shots_made; score_add(prison_break_mode_score, prison_break_mode_last_score); score_add (prison_break_mode_score_total_score, prison_break_mode_last_score); score_long (prison_break_mode_last_score); deff_start (DEFF_PRISON_BREAK_HIT_EFFECT);//under /kernel/deff.c }//end of function
void prison_break_mode_init (void) { prison_break_suspend = FALSE; //the claw mode can expire on its own and since it is a lower priority it will not display //callset_invoke (end_claw_mode); // this seemed to cause occasional crashes clawmagnet_off (); global_flag_off(GLOBAL_FLAG_IS_BALL_ON_CLAW); flipper_enable (); ballsave_add_time (system_config.mode_ballsave); //reset counter if first time run, otherwise do not - player may restart prison_break while currently running if (! get_dm_mode(BREAKOUT_COMPLETED) ) { prison_break_mode_shots_made = 0; score_zero(prison_break_mode_score); score_zero(prison_break_mode_last_score); } sound_start (ST_SPEECH, SPCH_CRYO_PRISON_BREAKOUT, SL_4S, PRI_GAME_QUICK3); //flash lamp for a time lamp_tristate_flash(LM_CLAW_PRISON_BREAK); task_sleep(TIME_500MS); lamp_tristate_on(LM_CLAW_PRISON_BREAK); score_add(prison_break_mode_last_score, score_table[PRIS_BREAK_HIT_SCORE]); score_zero(prison_break_mode_next_score); if (get_dm_mode(BREAKOUT_COMPLETED)) { score(PRIS_BREAK_START_SCORE2); score_add(prison_break_mode_score, score_table[PRIS_BREAK_START_SCORE2]); } else { score(PRIS_BREAK_START_SCORE1); score_add(prison_break_mode_score, score_table[PRIS_BREAK_START_SCORE1]); } set_dm_mode(BREAKOUT_COMPLETED); //for next time }//end of function
void huxley_mode_init (void) { ball_search_monitor_stop (); task_kill_gid(GID_HUXLEY_REMINDER); flag_on (FLAG_IS_HUXLEY_RUNNING); huxley_mode_shots_made = 0; ++huxley_modes_achieved; score_zero(huxley_mode_score); score_zero(huxley_mode_last_score); score_zero(huxley_mode_next_score); score(HUXLEY_START_SCORE); score_add(huxley_mode_score, score_table[HUXLEY_START_SCORE]); score_add(huxley_mode_next_score, score_table[HUXLEY_MODE_HIT_SCORE]); huxley_goal += (HUXLEY_EASY_GOAL * 2); flag_off(FLAG_IS_HUXLEY_ENABLED); deff_start_sync (DEFF_HUXLEY_START_EFFECT);//under /kernel/deff.c ballsave_add_time (5); leff_start(LEFF_HUXLEY); sol_request_async (SOL_EJECT); //request to fire the eject sol task_sleep (TIME_300MS); flag_off(FLAG_KILL_NORMAL_EJECT); ball_search_monitor_start (); }//end of function
//shot made during huxley mode void huxley_mode_shot_made(void) { deff_start (DEFF_HUXLEY_HIT_EFFECT);//under /kernel/deff.c ++huxley_mode_shots_made; score (HUXLEY_MODE_HIT_SCORE); score_add (huxley_mode_score, score_table[HUXLEY_MODE_HIT_SCORE]); score_add (huxley_mode_score_total_score, score_table[HUXLEY_MODE_HIT_SCORE]); }//end of function
CALLSET_ENTRY (jet, sw_jet) { task_create_gid1 (GID_JET_SOUND, sw_jet_sound); if (global_flag_test(GLOBAL_FLAG_POWERBALL_IN_PLAY)) jets_scored += 2; else jets_scored++; if (jets_scored >= jets_for_bonus) { jets_level_up (); } if (timed_mode_running_p (&tsm_mode)) { score (SC_500K); score_add (tsm_mode_total, score_table[SC_500K]); callset_invoke (respawn_dollar); } else { score (SC_150K); /* Stop deff from restarting whilst we * are showing the level up deff * or when the hitch anim is running */ if (!timer_find_gid (GID_HITCHHIKER) && !task_find_gid (GID_JETS_LEVEL_UP)) deff_restart (DEFF_JETS_HIT); } /* Hack for when mpf_exit switch breaks */ if (!multi_ball_play () && mpf_timer > 0) callset_invoke (sw_mpf_exit); }
/******************* * start with all jackpot shots lit and as shots are made decrease # of lights lit ******************/ void fortress_jackpot_made(void) { ++fortress_jackpot_shots_made; score_add (fortress_score, score_table[FORTRESS_JP_MB_SCORE]); score (FORTRESS_JP_MB_SCORE); if (system_config.disable_shaker == NO) { if (system_config.extra_shaker == YES) shaker_start (SHAKER_HALF_ON, 2); else shaker_start (SHAKER_ONE_QUARTER_ON, 2); }//end of shaker call switch (fortress_jackpot_shots_made % 5) { case 1: leff_start (LEFF_JACKPOT1); break; case 2: leff_start (LEFF_JACKPOT2); break; case 3: leff_start (LEFF_JACKPOT3); break; case 4: leff_start (LEFF_JACKPOT4); break; default: leff_start (LEFF_JACKPOT); break; } deff_start (DEFF_FORTRESS_JACKPOT_EFFECT); if (fortress_jackpot_shots_made < 2) choose_multiple_random_jackpot (3); //after 1 made, at most 3 lit else if (fortress_jackpot_shots_made < 4) choose_multiple_random_jackpot (2); //for 2nd and 3rd, at most 2 lit else choose_random_jackpot (); //for rest, only 1 lit if (DM_IN_CAB_TEST) { start_super_jackpot_reminder(); } else if (fortress_jackpot_shots_made % 5 == 0) start_super_jackpot_reminder(); }//end of function
void superjets_goal_award (void) { sound_start (ST_SPEECH, SPCH_SUPERJETS_COMPLETED, SL_4S, PRI_GAME_QUICK3); score (SUPERJETS_GOAL_SCORE); score_add (superjets_mode_score, score_table[SUPERJETS_GOAL_SCORE]); if (superjets_goal < SUPERJETS_GOAL_MAX) superjets_goal += SUPERJETS_GOAL_STEP; timed_mode_end (&superjets_mode); }//END OF FUNCTION
CALLSET_ENTRY (tnf, sw_left_button, sw_right_button) { if (deff_get_active () == DEFF_TNF) { bounded_increment (tnf_buttons_pressed, 255); score_add (tnf_score, score_table[SC_100K + tnf_level]); tnf_x = random_scaled(10); tnf_y = random_scaled(3); task_recreate_gid (GID_TNF_SOUND, tnf_sound_task); if (tnf_buttons_pressed > tnf_target) { score_add (tnf_score, score_table[SC_5M]); task_kill_gid (GID_TNF_TIMER); } } }
/** Increments a binary-coded decimal score by another value * in which only one byte is nonzero (e.g. 40K = 04 00 00). * 'offset' identifies the position of the nonzero byte, with * zero always meaning the 'ones' byte, and higher values * referring to larger place values. 'val' gives the byte * value. */ void score_add_byte (score_t s1, U8 offset, bcd_t val) { score_t s2; memset (s2, 0, sizeof (score_t)); s2[BYTES_PER_SCORE - offset] = val; score_add (s1, s2); }
static void brick_damage (int8_t in_x, int8_t in_y) { if ((*playfield)[in_x][in_y] >= bs || (*playfield)[in_x][in_y] == 0) return; (*playfield)[in_x][in_y] -= 1; score_add (1); }
CALLSET_ENTRY (jets, jet_hit) { // task_recreate_gid (GID_JETS, jet_hit_task); //score_copy (temp_score, current_score); flasher_pulse (FLASH_RIGHT_HELMET); /* Make a sound, based on level */ if (!free_timer_test (timer_jets_level_up)) sound_send (jet_sounds[jets_level][jets_sound_index]); jets_sound_index++; if (jets_sound_index > 2) jets_sound_index = 0; if (timed_mode_running_p (&jets_frenzy_mode)) { score (SC_500K); } else if (score_compare (total_jets_score, score_table[SC_500K]) >= 0) { timed_mode_begin (&jets_frenzy_mode); score (SC_500K); score_add (jets_frenzy_total, score_table[SC_500K]); } else { /* Score the hit, based on level */ score_add (total_jets_score, score_table[jets_hit_scores[jets_level]]); score_long (score_table[jets_hit_scores[jets_level]]); bounded_increment (jets_hit, 255); /* Level up if needed */ if (jets_hit >= jets_needed[jets_level]) { bounded_increment (jets_level, 4); score_long (score_table[jets_level_up_scores[jets_level]]); jets_hit = 0; free_timer_restart (timer_jets_level_up, TIME_2S); sound_send (SND_WHOOSH_UP_1); } if ((score_compare (total_jets_score, score_table[SC_250K]) >= 0) && !flag_test (FLAG_250K_JETS)) callset_invoke (wheel_award_jets); deff_restart (DEFF_JET_HIT); } }
CALLSET_ENTRY (jet, sw_jet) { /* Hack for when mpf_exit switch breaks */ if (!multi_ball_play () && mpf_timer > 0) callset_invoke (sw_mpf_exit); if (global_flag_test(GLOBAL_FLAG_POWERBALL_IN_PLAY)) jets_scored += 2; else jets_scored++; if (jets_scored >= jets_for_bonus) { bounded_increment (jets_bonus_level, 50); jets_for_bonus += 5; award_unlit_shot (SW_BOTTOM_JET); sound_send (SND_GLASS_BREAKS); task_sleep (TIME_500MS); /* jetscore is used rather than score_deff_get * because it's likely another score would of * happened */ if (jets_bonus_level < 3) { score (SC_1M); jetscore = 1; } else if (jets_bonus_level < 5) { score (SC_5M); jetscore = 5; } else if (jets_bonus_level < 7) { score (SC_10M); jetscore = 10; } if (!timer_find_gid (GID_HITCHHIKER)) deff_start (DEFF_JETS_LEVEL_UP); } if (timed_mode_running_p (&tsm_mode)) { score (SC_500K); score_add (tsm_mode_total, score_table[SC_500K]); } else { score (SC_150K); /* Stop deff from restarting whilst we * are showing the level up deff * or when the hitch anim is running */ if ((jets_scored <= jets_for_bonus) && (!timer_find_gid (GID_HITCHHIKER))) deff_restart (DEFF_JETS_HIT); } task_create_gid1 (GID_JET_SOUND, sw_jet_sound); }
//jackpot shot void cryoprison_jackpot_made(void) { score_add (cryoprison_score, score_table[CRYOPRISON_JP_MB_SCORE]); score (CRYOPRISON_JP_MB_SCORE); deff_start (DEFF_CRYOPRISON_JACKPOT_EFFECT); choose_multiple_random_jackpot(3); if (IN_TEST) { start_super_jackpot_reminder(); } else if (cryoprison_jackpot_shots_made % 5 == 0) start_super_jackpot_reminder(); }//end of function
void fortress_start(U8 num) { computer_light_temp_off(); is_fortress_running = TRUE; task_create_gid1 (GID_FORTRESS_START_NOISE, fortress_start_sounds); fortress_display_counter = 0; FORT_TOGGLE = 0; fortress_ballsave = system_config.mb_ballsave; mb_mode_start(&fortress_mode); score_add (fortress_score, score_table[FORTRESS_MB_SCORE]); score (FORTRESS_MB_SCORE); if (!in_tilt) deff_start (DEFF_FORTRESS_START_EFFECT); multiball_started();//reset all MB start criteria for next time diverter_stop();//defined in divhold2.ct //LIGHTS if (!in_tilt) { leff_start (LEFF_MB_START); lamp_tristate_flash(LM_FORTRESS_MULTIBALL); task_sleep (TIME_2S); lamp_tristate_on (LM_FORTRESS_MULTIBALL); lamp_tristate_off (LM_FREEZE_1); lamp_tristate_off (LM_FREEZE_2); lamp_tristate_off (LM_FREEZE_3); lamp_tristate_off (LM_FREEZE_4); } //SOUNDS if (!in_tilt) { U8 fortress_SoundCounter; fortress_SoundCounter = random_scaled(2);//from kernal/random.c - pick number from 0 to 2 if (fortress_SoundCounter == 0) sound_start (ST_SPEECH, SPCH_SOMETHING_RIGHT_PREV_LIFE, SL_4S, PRI_GAME_QUICK3); else sound_start (ST_SPEECH, SPCH_SEND_MANIAC, SL_4S, PRI_GAME_QUICK3); task_sleep (TIME_3S); } //serve balls if (!in_tilt) { if (num + live_balls >= 5) set_ball_count (5); else set_ball_count (num + live_balls); //task_sleep (TIME_3S); set_all_jackpots(); //all 6 lit //start the ball save timer task_create_gid1 (GID_FORTRESS_BALLSAVE_TIMER, fortress_ballsave_task); //recount the trough every 5 secs - this is to handle situations //where too many drains in rapid succession cause the game to lose //count of live balls - this only happens during MB callset_invoke (mb_trough_recount_timer_start); } //just in case - make sure this is running ball_search_monitor_start (); set_dm_mode2(FORTRESS_COMPLETED); //for BONUS }//end of function
void wasteland_start(U8 num) { // kill_combos(); computer_light_temp_off(); task_create_gid1 (GID_WASTELAND_START_NOISE, wasteland_start_sounds); is_wasteland_running = TRUE; mb_mode_start(&wasteland_mode); score_add (wasteland_score, score_table[WASTELAND_MB_SCORE]); score (WASTELAND_MB_SCORE); wasteland_display_counter = 0; WL_TOGGLE = 0; wasteland_ballsave = TRUE; multiball_started();//reset all MB start criteria for next time deff_start (DEFF_WASTELAND_START_EFFECT); diverter_stop();//defined in divhold2.ct //LIGHTS leff_start (LEFF_MB_START); lamp_tristate_flash(LM_WASTELAND_MULTIBALL); task_sleep (TIME_2S); lamp_tristate_on (LM_WASTELAND_MULTIBALL); lamp_tristate_off (LM_FREEZE_1); lamp_tristate_off (LM_FREEZE_2); lamp_tristate_off (LM_FREEZE_3); lamp_tristate_off (LM_FREEZE_4); //SOUNDS U8 wasteland_SoundCounter; wasteland_SoundCounter = random_scaled(2);//from kernal/random.c - pick number from 0 to 2 if (wasteland_SoundCounter == 0) sound_start (ST_SPEECH, SPCH_IN_THIS_CENTURY, SL_4S, PRI_GAME_QUICK2); else sound_start (ST_SPEECH, SPCH_FEEL_GOOD_TOO, SL_4S, PRI_GAME_QUICK2); task_sleep (TIME_3S); wasteland_start_music = FALSE; //for to kill the music //serve balls if (num + live_balls >= 5) set_ball_count (5); else set_ball_count (num + live_balls); task_create_gid1 (GID_WASTELAND_BALL_SAVE, wasteland_ballsave_task); //task_sleep (TIME_3S); set_all_jackpots(); //all 6 lit //recount the trough every 5 secs - this is to handle situations //where too many drains in rapid succession cause the game to lose //count of live balls - this only happens during MB callset_invoke (mb_trough_recount_timer_start); //just in case - make sure this is running ball_search_monitor_start (); set_dm_mode2(WASTELAND_COMPLETED); //for BONUS }//end of function
void fortress_award_super_jackpot(void) { score_add (fortress_score, score_table[FORTRESS_SUPER_JP_MB_SCORE]); score (FORTRESS_SUPER_JP_MB_SCORE); if (system_config.disable_shaker == NO) { if (system_config.extra_shaker == YES) shaker_start (SHAKER_HALF_ON, 2); else shaker_start (SHAKER_ONE_QUARTER_ON, 2); }//end of shaker call deff_start(DEFF_FORTRESS_SUPER_JACKPOT); }//end of function
CALLSET_ENTRY (tnf, tnf_end) { music_enable (); deff_start_sync (DEFF_TNF_EXIT); score_add (current_score, tnf_score); if (tnf_buttons_pressed >= tnf_target) tnf_increase_level (); flipper_enable (); music_refresh (); magnet_enable_catch_and_throw (MAG_LEFT); }
void wasteland_award_super_jackpot(void) { score_add (wasteland_score, score_table[WASTELAND_SUPER_JP_MB_SCORE]); score (WASTELAND_SUPER_JP_MB_SCORE); if (system_config.disable_shaker == NO) { if (system_config.extra_shaker == YES) shaker_start (SHAKER_HALF_ON, 2); else shaker_start (SHAKER_ONE_QUARTER_ON, 2); }//end of shaker call leff_start (LEFF_SUPER_JACKPOT); deff_start(DEFF_WASTELAND_SUPER_JACKPOT); }//end of function
/** Adds to the current score. The input score is given as a BCD-string. */ static void score_award (const bcd_t *s) { if (in_tilt) return; if (!in_game) { nonfatal (ERR_SCORE_NOT_IN_GAME); return; } score_add (current_score, s); score_update_request (); replay_check_current (); }
void car_chase_ramp_made(void) { ++car_chase_mode_shots_made; deff_start (DEFF_CAR_CHASE_HIT_EFFECT); score_zero(car_chase_mode_temp_score); switch (car_chase_modes_achieved ){ case 1: score (CARCHASE_HIT_SCORE_1); score_add(car_chase_mode_temp_score, score_table[CARCHASE_HIT_SCORE_1]); break; case 2: //2nd time we are in car_chase - score differently score (CARCHASE_HIT_SCORE_2); score_add(car_chase_mode_temp_score, score_table[CARCHASE_HIT_SCORE_2]); break; default: //all cases past 3rd time we are in car_chase case 3: //3rd time we are in car_chase - score differently score (CARCHASE_HIT_SCORE_3); score_add(car_chase_mode_temp_score, score_table[CARCHASE_HIT_SCORE_3]); break; }//end of switch score_add (car_chase_mode_score, car_chase_mode_temp_score); score_add (car_chase_mode_score_total_score, car_chase_mode_temp_score); }//end of function
void cryoprison_start(U8 num) { kill_combos(); // cryoprison_start_music = TRUE; //for to play the helicopter instead of the music task_create_gid1 (GID_CRYOPRISON_START_NOISE, cryoprison_start_sounds); flag_on(FLAG_IS_CRYOPRISON_MB_RUNNING); cryoprison_display_counter = 0; CRYO_TOGGLE = 0; snake_pos = 0; cryoprison_ballsave = TRUE; mb_mode_start(&cryoprison_mode); multiball_started();//reset all MB start criteria for next time score_add (cryoprison_score, score_table[CRYOPRISON_MB_SCORE]); score (CRYOPRISON_MB_SCORE); deff_start (DEFF_CRYOPRISON_START_EFFECT); diverter_stop();//defined in divhold2.ct task_kill_gid (GID_CR_LIGHTS); //LIGHTS lamp_tristate_flash(LM_CRYOPRISON_MULTIBALL); task_sleep (TIME_2S); lamp_tristate_on (LM_CRYOPRISON_MULTIBALL); lamp_tristate_off (LM_FREEZE_1); lamp_tristate_off (LM_FREEZE_2); lamp_tristate_off (LM_FREEZE_3); lamp_tristate_off (LM_FREEZE_4); //SOUNDS U8 cryoprison_SoundCounter; cryoprison_SoundCounter = random_scaled(2);//from kernal/random.c - pick number from 0 to 2 if (cryoprison_SoundCounter == 0) sound_start (ST_SPEECH, SPCH_SIMON_SAYS_SLY, SL_4S, PRI_GAME_QUICK5); else sound_start (ST_SPEECH, SPCH_PHOENIX_SHORT, SL_4S, PRI_GAME_QUICK5); task_sleep (TIME_3S); sound_start (ST_SPEECH, SPCH_SIMON_SAYS, SL_4S, PRI_GAME_QUICK5); cryoprison_start_music = FALSE; //for to kill the music //serve balls set_ball_count (5); task_create_gid1 (GID_CRYOPRISON_BALL_SAVE, cryoprison_ballsave_task); task_sleep (TIME_3S); set_all_jackpots(); //all 6 lit }//end of function
/** Multiply a score (in place) by the given integer. * Zero is not supported, as it should never be called this * way. */ void score_mul (score_t s, U8 multiplier) { /* If multiplier is 1, nothing needs to be done. */ if (multiplier > 1) { /* Otherwise, we need to perform 'multiplier-1' * additions of the value into itself. This is * not the most elegant way, but multiplications * are not common, and the multipliers are often * going to be small. */ score_t copy; score_copy (copy, s); do { score_add (s, copy); } while (--multiplier > 1); } }
//jackpot shot void wasteland_jackpot_made(void) { score_add (wasteland_score, score_table[WASTELAND_JP_MB_SCORE]); score (WASTELAND_JP_MB_SCORE); wasteland_jackpot_shots_made++; if (system_config.disable_shaker == NO) { if (system_config.extra_shaker == YES) shaker_start (SHAKER_HALF_ON, 2); else shaker_start (SHAKER_ONE_QUARTER_ON, 2); }//end of shaker call switch (wasteland_jackpot_shots_made % 5) { case 1: leff_start (LEFF_JACKPOT1); break; case 2: leff_start (LEFF_JACKPOT2); break; case 3: leff_start (LEFF_JACKPOT3); break; case 4: leff_start (LEFF_JACKPOT4); break; default: leff_start (LEFF_JACKPOT); break; } deff_start (DEFF_WASTELAND_JACKPOT_EFFECT); choose_multiple_random_jackpot(3); if (DM_IN_CAB_TEST) { start_super_jackpot_reminder(); } else if (wasteland_jackpot_shots_made % 5 == 0) start_super_jackpot_reminder(); }//end of function
void CGI_prefork_server(const char *host, int port, const char *pidfile, int maxproc, int minidle, int maxidle, int maxreq, void (*callback)(void)) { int i, sock, fd; struct score_state message; struct score_board *scb; pid_t pid; FILE *fp; int pfd[2]; char **realenv, **tmpenv; char *tmpbuf; extern char **environ; /* sanity check arguments */ if (callback == 0) { syslog(LOG_ERR, "CGI_prefork_server(): null callback " "function pointer"); return; } if (minidle <= 0) { minidle = 2; } if (maxidle <= minidle) { maxidle = minidle + 2; } if (maxproc <= 0) { maxproc = maxidle; } if (maxproc > SCORE_MAX_PROC) { maxproc = SCORE_MAX_PROC; } syslog(LOG_INFO, "CGI_prefork_server(): maxproc = %d, minidle = %d, " "maxidle = %d, maxreq = %d", maxproc, minidle, maxidle, maxreq); /* parent puts self into the background */ if (fork() != 0) { _exit(0); } setsid(); set_handler(SIGTERM, terminate); set_handler(SIGCHLD, child_handler); if ( freopen("/dev/null", "r", stdin) != 0 ) printf("freopen error\n"); if ( freopen("/dev/null", "w", stdout) != 0 ) printf("freopen2 error\n"); /* write our pid to pidfile */ if (pidfile != 0 && *pidfile != 0 && (fp = fopen(pidfile, "w")) != 0) { fprintf(fp, "%d\n", getpid()); fclose(fp); } /* create child process scoreboard */ scb = score_new(maxproc, minidle, maxidle); /* parent opens the listen socket, children accept() connections */ if ((sock = setup_sock(host, port)) < 0) { syslog(LOG_ERR, "CGI_prefork_server(): setup_sock() failed: %m"); return; } /* open pipe to receive messages from child processes */ if ( pipe(pfd) != 0 ) printf("pipe error\n"); /* parent manages child processes */ for (;;) { /* fork child if necessary */ if (scb->numidle < scb->minidle && scb->numproc < scb->maxproc) { if ((pid = fork()) == 0) { break; } else if (pid > 0) { score_add(scb, pid); continue; } else { syslog(LOG_ERR, "CGI_prefork_server(): fork() failed: %m"); if (scb->numproc == 0) { return; } } } /* * read status message from child. The read() call returns with * an error if we catch SIGCHLD or SIGTERM. */ if (child_exited == 0 && terminate_flag == 0 && read(pfd[0], &message, sizeof(message)) == sizeof(message)) { score_update(scb, &message); } /* kill everything and exit if we got SIGTERM */ if (terminate_flag != 0) { set_handler(SIGTERM, SIG_IGN); kill(0, SIGTERM); /* kill process group */ while(wait(0) >= 0) ; exit(0); } /* kill idle child if necessary */ if (scb->numidle > scb->maxidle) { score_kill(scb); } /* wait for exited children */ child_exited = 0; while ((pid = waitpid(-1, 0, WNOHANG)) > 0) { score_remove(scb, pid); } } /* child handles maxreq requests and exits */ set_handler(SIGTERM, SIG_DFL); set_handler(SIGCHLD, SIG_DFL); close(pfd[0]); message.pid = getpid(); realenv = environ; for (i = 0; i < maxreq || maxreq <= 0; i++) { /* accept connection from SCGI client (httpd) */ if ((fd = accept(sock, 0, 0)) < 0) { syslog(LOG_ERR, "CGI_prefork_server(): accept() failed: %m"); break; } /* notify parent we are busy */ message.state = SCORE_BUSY; if ( write(pfd[1], &message, sizeof(message)) != sizeof(message) ) printf("write error\n"); /* redirect stdin and stdout to socket */ dup2(fd, 0); dup2(fd, 1); close(fd); /* read environment and call callback */ if ((tmpenv = read_env()) != 0) { tmpbuf = tmpenv[0]; environ = tmpenv; callback(); } else { fputs("Content-type: text/plain\r\n\r\n" "CGI_prefork_server() could not read environment.\r\n", stdout); syslog(LOG_ERR, "CGI_prefork_server(): could not read " "environment"); } /* close socket and restore environment */ if ( freopen("/dev/null", "r", stdin) != 0 ) printf("freopen3 error\n"); if ( freopen("/dev/null", "w", stdout) != 0 ) printf("freopen4 error\n"); environ = realenv; if (tmpenv != 0) { free(tmpbuf); free(tmpenv); } /* notify parent we are idle */ message.state = SCORE_IDLE; if ( write(pfd[1], &message, sizeof(message)) != sizeof(message) ) printf("write2 error\n"); } _exit(0); }
void fixed_ladder_score_multiple (const struct fixed_ladder *ladder, U8 multiplier) { score_long_multiple (ladder->current, multiplier); if (score_compare (ladder->current, ladder->max) == -1) score_add (ladder->current, ladder->increment); }
CALLSET_ENTRY (bop_spinner, sw_spinner_slow) { score (SC_1K); score_add (spinner_total, score_table[SC_1K]); sound_send (SND_SPINNER1 + random_scaled (4)); }