X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=99cbfbbdfdf76adb0848ece543ecf5eda3ddf29c;hb=c9bb6e0a6eecbf84320be79b121bd957a938a08c;hp=3d13c184f2be2ae415c3821c977024e9175e0667;hpb=18c6de22b68eae843865c82b2def4f2a25cf738f;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 3d13c184..99cbfbbd 100644 --- a/src/game.c +++ b/src/game.c @@ -14,9 +14,9 @@ #include "libgame/libgame.h" #include "game.h" +#include "init.h" #include "tools.h" #include "screens.h" -#include "init.h" #include "files.h" #include "tape.h" #include "network.h" @@ -89,6 +89,13 @@ #define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY((p)->move_delay_value)) #define HALVE_PLAYER_SPEED(p) (DOUBLE_MOVE_DELAY((p)->move_delay_value)) +#define INIT_GFX_RANDOM() (SimpleRND(1000000)) + +#define GET_NEW_PUSH_DELAY(e) ( (element_info[e].push_delay_fixed) + \ + RND(element_info[e].push_delay_random)) +#define GET_NEW_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \ + RND(element_info[e].move_delay_random)) + /* game button identifiers */ #define GAME_CTRL_ID_STOP 0 #define GAME_CTRL_ID_PAUSE 1 @@ -99,77 +106,34 @@ #define NUM_GAME_BUTTONS 6 + /* forward declaration for internal use */ + static void InitBeltMovement(void); static void CloseAllOpenTimegates(void); static void CheckGravityMovement(struct PlayerInfo *); static void KillHeroUnlessProtected(int, int); +static void ChangeElementDoIt(int, int, int); + static void PlaySoundLevel(int, int, int); static void PlaySoundLevelNearest(int, int, int); static void PlaySoundLevelAction(int, int, int); static void PlaySoundLevelElementAction(int, int, int, int); +static void PlaySoundLevelActionIfLoop(int, int, int); +static void StopSoundLevelActionIfLoop(int, int, int); static void MapGameButtons(); static void HandleGameButtons(struct GadgetInfo *); static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; -#define IS_ANIMATED(g) (new_graphic_info[g].anim_frames > 1) - /* ------------------------------------------------------------------------- */ -/* sound definitions */ +/* definition of elements that automatically change to other elements after */ +/* a specified time, eventually calling a function when changing */ /* ------------------------------------------------------------------------- */ -#define SND_ACTION_UNKNOWN 0 -#define SND_ACTION_WAITING 1 -#define SND_ACTION_MOVING 2 -#define SND_ACTION_DIGGING 3 -#define SND_ACTION_COLLECTING 4 -#define SND_ACTION_PASSING 5 -#define SND_ACTION_IMPACT 6 -#define SND_ACTION_PUSHING 7 -#define SND_ACTION_ACTIVATING 8 -#define SND_ACTION_ACTIVE 9 - -#define NUM_SND_ACTIONS 10 - -static struct -{ - char *text; - int value; - boolean is_loop; -} sound_action_properties[] = -{ - /* insert _all_ loop sound actions here */ - { ".waiting", SND_ACTION_WAITING, TRUE }, - { ".moving", SND_ACTION_MOVING, TRUE }, /* continuos moving */ - { ".active", SND_ACTION_ACTIVE, TRUE }, - { ".growing", SND_ACTION_UNKNOWN, TRUE }, - { ".attacking", SND_ACTION_UNKNOWN, TRUE }, - - /* other (non-loop) sound actions are optional */ - { ".stepping", SND_ACTION_MOVING, FALSE }, /* discrete moving */ - { ".digging", SND_ACTION_DIGGING, FALSE }, - { ".collecting", SND_ACTION_COLLECTING, FALSE }, - { ".passing", SND_ACTION_PASSING, FALSE }, - { ".impact", SND_ACTION_IMPACT, FALSE }, - { ".pushing", SND_ACTION_PUSHING, FALSE }, - { ".activating", SND_ACTION_ACTIVATING, FALSE }, - { NULL, 0, 0 }, -}; -static int element_action_sound[MAX_NUM_ELEMENTS][NUM_SND_ACTIONS]; -static boolean is_loop_sound[NUM_SOUND_FILES]; - -#define IS_LOOP_SOUND(x) (is_loop_sound[x]) - - -/* ------------------------------------------------------------------------- - definition of elements that automatically change to other elements after - a specified time, eventually calling a function when changing - ------------------------------------------------------------------------- */ - /* forward declaration for changer functions */ static void InitBuggyBase(int x, int y); static void WarnBuggyBase(int x, int y); @@ -197,35 +161,144 @@ struct ChangingElementInfo static struct ChangingElementInfo changing_element_list[] = { - { EL_NUT_CRACKING, EL_EMERALD, 6, NULL, NULL, NULL }, - { EL_PEARL_BREAKING, EL_EMPTY, 8, NULL, NULL, NULL }, - { EL_EXIT_OPENING, EL_EXIT_OPEN, 29, NULL, NULL, NULL }, - - { EL_SWITCHGATE_OPENING, EL_SWITCHGATE_OPEN, 29, NULL, NULL, NULL }, - { EL_SWITCHGATE_CLOSING, EL_SWITCHGATE_CLOSED, 29, NULL, NULL, NULL }, - - { EL_TIMEGATE_OPENING, EL_TIMEGATE_OPEN, 29, NULL, NULL, NULL }, - { EL_TIMEGATE_CLOSING, EL_TIMEGATE_CLOSED, 29, NULL, NULL, NULL }, - - { EL_SP_BUGGY_BASE, EL_SP_BUGGY_BASE_ACTIVATING, 0, - InitBuggyBase, NULL, NULL }, - { EL_SP_BUGGY_BASE_ACTIVATING,EL_SP_BUGGY_BASE_ACTIVE, 0, - InitBuggyBase, NULL, NULL }, - { EL_SP_BUGGY_BASE_ACTIVE, EL_SP_BUGGY_BASE, 0, - InitBuggyBase, WarnBuggyBase, NULL }, - - { EL_TRAP, EL_TRAP_ACTIVE, 0, - InitTrap, NULL, ActivateTrap }, - { EL_TRAP_ACTIVE, EL_TRAP, 32, - NULL, ChangeActiveTrap, NULL }, - - { EL_ROBOT_WHEEL_ACTIVE, EL_ROBOT_WHEEL, 0, - InitRobotWheel, RunRobotWheel, StopRobotWheel }, + { + EL_NUT_BREAKING, + EL_EMERALD, + 6, + NULL, + NULL, + NULL + }, + { + EL_PEARL_BREAKING, + EL_EMPTY, + 8, + NULL, + NULL, + NULL + }, + { + EL_EXIT_OPENING, + EL_EXIT_OPEN, + 29, + NULL, + NULL, + NULL + }, + { + EL_SWITCHGATE_OPENING, + EL_SWITCHGATE_OPEN, + 29, + NULL, + NULL, + NULL + }, + { + EL_SWITCHGATE_CLOSING, + EL_SWITCHGATE_CLOSED, + 29, + NULL, + NULL, + NULL + }, + { + EL_TIMEGATE_OPENING, + EL_TIMEGATE_OPEN, + 29, + NULL, + NULL, + NULL + }, + { + EL_TIMEGATE_CLOSING, + EL_TIMEGATE_CLOSED, + 29, + NULL, + NULL, + NULL + }, - { EL_TIMEGATE_SWITCH_ACTIVE, EL_TIMEGATE_SWITCH, 0, - InitTimegateWheel, RunTimegateWheel, NULL }, + { + EL_ACID_SPLASH_LEFT, + EL_EMPTY, + 8, + NULL, + NULL, + NULL + }, + { + EL_ACID_SPLASH_RIGHT, + EL_EMPTY, + 8, + NULL, + NULL, + NULL + }, + { + EL_SP_BUGGY_BASE, + EL_SP_BUGGY_BASE_ACTIVATING, + 0, + InitBuggyBase, + NULL, + NULL + }, + { + EL_SP_BUGGY_BASE_ACTIVATING, + EL_SP_BUGGY_BASE_ACTIVE, + 0, + InitBuggyBase, + NULL, + NULL + }, + { + EL_SP_BUGGY_BASE_ACTIVE, + EL_SP_BUGGY_BASE, + 0, + InitBuggyBase, + WarnBuggyBase, + NULL + }, + { + EL_TRAP, + EL_TRAP_ACTIVE, + 0, + InitTrap, + NULL, + ActivateTrap + }, + { + EL_TRAP_ACTIVE, + EL_TRAP, + 31, + NULL, + ChangeActiveTrap, + NULL + }, + { + EL_ROBOT_WHEEL_ACTIVE, + EL_ROBOT_WHEEL, + 0, + InitRobotWheel, + RunRobotWheel, + StopRobotWheel + }, + { + EL_TIMEGATE_SWITCH_ACTIVE, + EL_TIMEGATE_SWITCH, + 0, + InitTimegateWheel, + RunTimegateWheel, + NULL + }, - { EL_UNDEFINED, EL_UNDEFINED, -1, NULL } + { + EL_UNDEFINED, + EL_UNDEFINED, + -1, + NULL, + NULL, + NULL + } }; static struct ChangingElementInfo changing_element[MAX_NUM_ELEMENTS]; @@ -233,60 +306,6 @@ static struct ChangingElementInfo changing_element[MAX_NUM_ELEMENTS]; #define IS_AUTO_CHANGING(e) (changing_element[e].base_element != EL_UNDEFINED) - -#ifdef DEBUG -#if 0 -static unsigned int getStateCheckSum(int counter) -{ - int x, y; - unsigned int mult = 1; - unsigned int checksum = 0; - /* - static short lastFeld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; - */ - static boolean first_game = TRUE; - - for (y=0; yjx, jy = player->jy; player->present = TRUE; @@ -412,15 +437,15 @@ static void InitField(int x, int y, boolean init_game) case EL_STONEBLOCK: if (x < lev_fieldx-1 && Feld[x+1][y] == EL_ACID) - Feld[x][y] = EL_ACIDPOOL_TOPLEFT; + Feld[x][y] = EL_ACID_POOL_TOPLEFT; else if (x > 0 && Feld[x-1][y] == EL_ACID) - Feld[x][y] = EL_ACIDPOOL_TOPRIGHT; - else if (y > 0 && Feld[x][y-1] == EL_ACIDPOOL_TOPLEFT) - Feld[x][y] = EL_ACIDPOOL_BOTTOMLEFT; + Feld[x][y] = EL_ACID_POOL_TOPRIGHT; + else if (y > 0 && Feld[x][y-1] == EL_ACID_POOL_TOPLEFT) + Feld[x][y] = EL_ACID_POOL_BOTTOMLEFT; else if (y > 0 && Feld[x][y-1] == EL_ACID) - Feld[x][y] = EL_ACIDPOOL_BOTTOM; - else if (y > 0 && Feld[x][y-1] == EL_ACIDPOOL_TOPRIGHT) - Feld[x][y] = EL_ACIDPOOL_BOTTOMRIGHT; + Feld[x][y] = EL_ACID_POOL_BOTTOM; + else if (y > 0 && Feld[x][y-1] == EL_ACID_POOL_TOPRIGHT) + Feld[x][y] = EL_ACID_POOL_BOTTOMRIGHT; break; case EL_BUG_RIGHT: @@ -469,7 +494,7 @@ static void InitField(int x, int y, boolean init_game) case EL_AMOEBA_DROP: if (y == lev_fieldy - 1) { - Feld[x][y] = EL_AMOEBA_CREATING; + Feld[x][y] = EL_AMOEBA_GROWING; Store[x][y] = EL_AMOEBA_WET; } break; @@ -499,31 +524,31 @@ static void InitField(int x, int y, boolean init_game) Feld[x][y] = EL_EMPTY; break; - case EL_EM_KEY1_FILE: - Feld[x][y] = EL_EM_KEY1; + case EL_EM_KEY_1_FILE: + Feld[x][y] = EL_EM_KEY_1; break; - case EL_EM_KEY2_FILE: - Feld[x][y] = EL_EM_KEY2; + case EL_EM_KEY_2_FILE: + Feld[x][y] = EL_EM_KEY_2; break; - case EL_EM_KEY3_FILE: - Feld[x][y] = EL_EM_KEY3; + case EL_EM_KEY_3_FILE: + Feld[x][y] = EL_EM_KEY_3; break; - case EL_EM_KEY4_FILE: - Feld[x][y] = EL_EM_KEY4; + case EL_EM_KEY_4_FILE: + Feld[x][y] = EL_EM_KEY_4; break; - case EL_CONVEYOR_BELT1_SWITCH_LEFT: - case EL_CONVEYOR_BELT1_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT1_SWITCH_RIGHT: - case EL_CONVEYOR_BELT2_SWITCH_LEFT: - case EL_CONVEYOR_BELT2_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT2_SWITCH_RIGHT: - case EL_CONVEYOR_BELT3_SWITCH_LEFT: - case EL_CONVEYOR_BELT3_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT3_SWITCH_RIGHT: - case EL_CONVEYOR_BELT4_SWITCH_LEFT: - case EL_CONVEYOR_BELT4_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT4_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_1_SWITCH_LEFT: + case EL_CONVEYOR_BELT_1_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_1_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_2_SWITCH_LEFT: + case EL_CONVEYOR_BELT_2_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_2_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_3_SWITCH_LEFT: + case EL_CONVEYOR_BELT_3_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_3_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_4_SWITCH_LEFT: + case EL_CONVEYOR_BELT_4_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_4_SWITCH_RIGHT: if (init_game) { int belt_nr = getBeltNrFromBeltSwitchElement(Feld[x][y]); @@ -553,6 +578,8 @@ static void InitField(int x, int y, boolean init_game) break; default: + if (IS_CUSTOM_ELEMENT(element) && CAN_MOVE(element)) + InitMovDir(x, y); break; } } @@ -565,107 +592,16 @@ void DrawGameDoorValues() for (j=0; j<4; j++) if (stored_player[i].key[j]) DrawMiniGraphicExt(drawto, DX_KEYS + j * MINI_TILEX, DY_KEYS, - IMG_KEY1 + j); + el2edimg(EL_KEY_1 + j)); DrawText(DX + XX_EMERALDS, DY + YY_EMERALDS, - int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); + int2str(local_player->gems_still_needed, 3), FONT_TEXT_2); DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, - int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); + int2str(local_player->dynamite, 3), FONT_TEXT_2); DrawText(DX + XX_SCORE, DY + YY_SCORE, - int2str(local_player->score, 5), FS_SMALL, FC_YELLOW); + int2str(local_player->score, 5), FONT_TEXT_2); DrawText(DX + XX_TIME, DY + YY_TIME, - int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); -} - - -/* - ============================================================================= - InitGameSound() - ----------------------------------------------------------------------------- - initialize sound effect lookup table for element actions - ============================================================================= -*/ - -void InitGameSound() -{ - int sound_effect_properties[NUM_SOUND_FILES]; - int i, j; - -#if 0 - debug_print_timestamp(0, NULL); -#endif - - /* initialize sound effect for all elements to "no sound" */ - for (i=0; i VERSION_IDENT(2,0,1)) - Properties2[EL_WALL_GROWING_ACTIVE] |= EP_BIT_EM_SLIPPERY_WALL; - else - Properties2[EL_WALL_GROWING_ACTIVE] &=~EP_BIT_EM_SLIPPERY_WALL; - } - /* initialize changing elements information */ for (i=0; isuccessor; + changing_element[element].change_delay = (change->delay_fixed * + change->delay_frames); + } } @@ -795,7 +722,7 @@ void InitGame() struct PlayerInfo *player = &stored_player[i]; player->index_nr = i; - player->element_nr = EL_PLAYER1 + i; + player->element_nr = EL_PLAYER_1 + i; player->present = FALSE; player->active = FALSE; @@ -824,15 +751,24 @@ void InitGame() player->Pushing = FALSE; player->Switching = FALSE; player->GfxPos = 0; + player->GfxDir = MV_NO_MOVING; + player->GfxAction = ACTION_DEFAULT; player->Frame = 0; + player->StepFrame = 0; - player->actual_frame_counter = 0; + player->use_murphy_graphic = FALSE; + player->use_disk_red_graphic = FALSE; - player->frame_reset_delay = 0; + player->actual_frame_counter = 0; player->last_move_dir = MV_NO_MOVING; player->is_moving = FALSE; + player->is_moving = FALSE; + player->is_waiting = FALSE; + player->is_digging = FALSE; + player->is_collecting = FALSE; + player->move_delay = game.initial_move_delay; player->move_delay_value = game.initial_move_delay_value; @@ -877,7 +813,7 @@ void InitGame() AllPlayersGone = FALSE; - game.yam_content_nr = 0; + game.yamyam_content_nr = 0; game.magic_wall_active = FALSE; game.magic_wall_time_left = 0; game.light_time_left = 0; @@ -901,7 +837,8 @@ void InitGame() { Feld[x][y] = Ur[x][y]; MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; - Store[x][y] = Store2[x][y] = StorePlayer[x][y] = 0; + ChangeDelay[x][y] = 0; + Store[x][y] = Store2[x][y] = StorePlayer[x][y] = Back[x][y] = 0; AmoebaNr[x][y] = 0; JustStopped[x][y] = 0; Stop[x][y] = FALSE; @@ -909,7 +846,9 @@ void InitGame() ExplodeField[x][y] = EX_NO_EXPLOSION; GfxFrame[x][y] = 0; - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; + GfxRandom[x][y] = INIT_GFX_RANDOM(); + GfxElement[x][y] = EL_UNDEFINED; } } @@ -1081,19 +1020,19 @@ void InitGame() FadeToFront(); /* copy default game door content to main double buffer */ - BlitBitmap(new_graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, + BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY); if (level_nr < 100) - DrawText(DX + XX_LEVEL, DY + YY_LEVEL, - int2str(level_nr, 2), FS_SMALL, FC_YELLOW); + DrawText(DX + XX_LEVEL, DY + YY_LEVEL, int2str(level_nr, 2), FONT_TEXT_2); else { DrawTextExt(drawto, DX + XX_EMERALDS, DY + YY_EMERALDS, - int2str(level_nr, 3), FS_SMALL, FC_SPECIAL3, FONT_OPAQUE); + int2str(level_nr, 3), FONT_LEVEL_NUMBER, BLIT_OPAQUE); BlitBitmap(drawto, drawto, DX + XX_EMERALDS, DY + YY_EMERALDS + 1, - FONT5_XSIZE * 3, FONT5_YSIZE - 1, + getFontWidth(FONT_LEVEL_NUMBER) * 3, + getFontHeight(FONT_LEVEL_NUMBER) - 1, DX + XX_LEVEL - 1, DY + YY_LEVEL + 1); } @@ -1113,11 +1052,11 @@ void InitGame() OpenDoor(DOOR_OPEN_ALL); - PlaySoundStereo(SND_GAME_STARTING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_STARTING, SOUND_MIDDLE); if (setup.sound_music) PlayMusic(level_nr); - KeyboardAutoRepeatOff(); + KeyboardAutoRepeatOffUnlessAutoplay(); if (options.debug) { @@ -1203,30 +1142,66 @@ void InitMovDir(int x, int y) break; default: - MovDir[x][y] = 1 << RND(4); - if (element != EL_BUG && - element != EL_SPACESHIP && - element != EL_BD_BUTTERFLY && - element != EL_BD_FIREFLY) - break; - - for (i=0; i<4; i++) + if (IS_CUSTOM_ELEMENT(element)) { - int x1 = x + xy[i][0]; - int y1 = y + xy[i][1]; - - if (!IN_LEV_FIELD(x1, y1) || !IS_FREE(x1, y1)) + if (element_info[element].move_direction_initial != MV_NO_MOVING) + MovDir[x][y] = element_info[element].move_direction_initial; + else if (element_info[element].move_pattern == MV_ALL_DIRECTIONS) + MovDir[x][y] = 1 << RND(4); + else if (element_info[element].move_pattern == MV_HORIZONTAL) + MovDir[x][y] = (RND(2) ? MV_LEFT : MV_RIGHT); + else if (element_info[element].move_pattern == MV_VERTICAL) + MovDir[x][y] = (RND(2) ? MV_UP : MV_DOWN); + else if (element_info[element].move_pattern & MV_ANY_DIRECTION) + MovDir[x][y] = element_info[element].move_pattern; + else if (element_info[element].move_pattern == MV_ALONG_LEFT_SIDE || + element_info[element].move_pattern == MV_ALONG_RIGHT_SIDE) { - if (element == EL_BUG || element == EL_BD_BUTTERFLY) + for (i=0; i<4; i++) { - MovDir[x][y] = direction[0][i]; - break; + int x1 = x + xy[i][0]; + int y1 = y + xy[i][1]; + + if (!IN_LEV_FIELD(x1, y1) || !IS_FREE(x1, y1)) + { + if (element_info[element].move_pattern == MV_ALONG_RIGHT_SIDE) + MovDir[x][y] = direction[0][i]; + else + MovDir[x][y] = direction[1][i]; + + break; + } } - else if (element == EL_SPACESHIP || element == EL_BD_FIREFLY || - element == EL_SP_SNIKSNAK || element == EL_SP_ELECTRON) + } + } + else + { + MovDir[x][y] = 1 << RND(4); + + if (element != EL_BUG && + element != EL_SPACESHIP && + element != EL_BD_BUTTERFLY && + element != EL_BD_FIREFLY) + break; + + for (i=0; i<4; i++) + { + int x1 = x + xy[i][0]; + int y1 = y + xy[i][1]; + + if (!IN_LEV_FIELD(x1, y1) || !IS_FREE(x1, y1)) { - MovDir[x][y] = direction[1][i]; - break; + if (element == EL_BUG || element == EL_BD_BUTTERFLY) + { + MovDir[x][y] = direction[0][i]; + break; + } + else if (element == EL_SPACESHIP || element == EL_BD_FIREFLY || + element == EL_SP_SNIKSNAK || element == EL_SP_ELECTRON) + { + MovDir[x][y] = direction[1][i]; + break; + } } } } @@ -1269,25 +1244,25 @@ void GameWon() local_player->LevelSolved = FALSE; - PlaySoundStereo(SND_GAME_WINNING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_WINNING, SOUND_MIDDLE); if (TimeLeft) { if (!tape.playing && setup.sound_loops) - PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_LOOP); while (TimeLeft > 0) { if (!tape.playing && !setup.sound_loops) - PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MIDDLE); if (TimeLeft > 0 && !(TimeLeft % 10)) - RaiseScore(level.score[SC_ZEITBONUS]); + RaiseScore(level.score[SC_TIME_BONUS]); if (TimeLeft > 100 && !(TimeLeft % 10)) TimeLeft -= 10; else TimeLeft--; - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); BackToFront(); if (!tape.playing) @@ -1300,20 +1275,20 @@ void GameWon() else if (level.time == 0) /* level without time limit */ { if (!tape.playing && setup.sound_loops) - PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_LOOP); while (TimePlayed < 999) { if (!tape.playing && !setup.sound_loops) - PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MIDDLE); if (TimePlayed < 999 && !(TimePlayed % 10)) - RaiseScore(level.score[SC_ZEITBONUS]); + RaiseScore(level.score[SC_TIME_BONUS]); if (TimePlayed < 900 && !(TimePlayed % 10)) TimePlayed += 10; else TimePlayed++; - DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FONT_TEXT_2); BackToFront(); if (!tape.playing) @@ -1324,10 +1299,6 @@ void GameWon() StopSound(SND_GAME_LEVELTIME_BONUS); } -#if 0 - FadeSounds(); -#endif - /* Hero disappears */ DrawLevelField(ExitX, ExitY); BackToFront(); @@ -1356,7 +1327,7 @@ void GameWon() if ((hi_pos = NewHiScore()) >= 0) { - game_status = HALLOFFAME; + game_status = GAME_MODE_SCORES; DrawHallOfFame(hi_pos); if (raise_level) { @@ -1366,7 +1337,7 @@ void GameWon() } else { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; if (raise_level) { level_nr++; @@ -1438,6 +1409,33 @@ int NewHiScore() return position; } +void InitPlayerGfxAnimation(struct PlayerInfo *player, int action, int dir) +{ + if (player->GfxAction != action || player->GfxDir != dir) + { +#if 0 + printf("Player frame reset! (%d => %d, %d => %d)\n", + player->GfxAction, action, player->GfxDir, dir); +#endif + + player->GfxAction = action; + player->GfxDir = dir; + player->Frame = 0; + player->StepFrame = 0; + } +} + +static void ResetRandomAnimationValue(int x, int y) +{ + GfxRandom[x][y] = INIT_GFX_RANDOM(); +} + +static void ResetGfxAnimation(int x, int y) +{ + GfxFrame[x][y] = 0; + GfxAction[x][y] = ACTION_DEFAULT; +} + void InitMovingField(int x, int y, int direction) { int element = Feld[x][y]; @@ -1445,18 +1443,21 @@ void InitMovingField(int x, int y, int direction) int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); if (!JustStopped[x][y] || direction != MovDir[x][y]) - GfxFrame[x][y] = 0; + ResetGfxAnimation(x, y); - MovDir[x][y] = direction; - MovDir[newx][newy] = direction; + MovDir[newx][newy] = MovDir[x][y] = direction; if (Feld[newx][newy] == EL_EMPTY) Feld[newx][newy] = EL_BLOCKED; if (direction == MV_DOWN && CAN_FALL(element)) - GfxAction[x][y] = GFX_ACTION_FALLING; + GfxAction[x][y] = ACTION_FALLING; else - GfxAction[x][y] = GFX_ACTION_MOVING; + GfxAction[x][y] = ACTION_MOVING; + + GfxFrame[newx][newy] = GfxFrame[x][y]; + GfxAction[newx][newy] = GfxAction[x][y]; + GfxRandom[newx][newy] = GfxRandom[x][y]; } void Moving2Blocked(int x, int y, int *goes_to_x, int *goes_to_y) @@ -1528,9 +1529,11 @@ static int MovingOrBlocked2ElementIfNotLeaving(int x, int y) static void RemoveField(int x, int y) { Feld[x][y] = EL_EMPTY; + GfxElement[x][y] = EL_UNDEFINED; MovPos[x][y] = 0; MovDir[x][y] = 0; MovDelay[x][y] = 0; + ChangeDelay[x][y] = 0; } void RemoveMovingField(int x, int y) @@ -1557,7 +1560,7 @@ void RemoveMovingField(int x, int y) (Feld[oldx][oldy] == EL_QUICKSAND_EMPTYING || Feld[oldx][oldy] == EL_MAGIC_WALL_EMPTYING || Feld[oldx][oldy] == EL_BD_MAGIC_WALL_EMPTYING || - Feld[oldx][oldy] == EL_AMOEBA_DRIPPING)) + Feld[oldx][oldy] == EL_AMOEBA_DROPPING)) Feld[oldx][oldy] = get_next_element(Feld[oldx][oldy]); else Feld[oldx][oldy] = EL_EMPTY; @@ -1567,7 +1570,8 @@ void RemoveMovingField(int x, int y) Feld[newx][newy] = EL_EMPTY; MovPos[oldx][oldy] = MovDir[oldx][oldy] = MovDelay[oldx][oldy] = 0; MovPos[newx][newy] = MovDir[newx][newy] = MovDelay[newx][newy] = 0; - GfxAction[oldx][oldy] = GfxAction[newx][newy] = GFX_ACTION_DEFAULT; + ChangeDelay[oldx][oldy] = ChangeDelay[newx][newy] = 0; + GfxAction[oldx][oldy] = GfxAction[newx][newy] = ACTION_DEFAULT; DrawLevelField(oldx, oldy); DrawLevelField(newx, newy); @@ -1582,42 +1586,55 @@ void DrawDynamite(int x, int y) if (!IN_SCR_FIELD(sx, sy) || IS_PLAYER(x, y)) return; - if (Store[x][y]) + if (IS_WALKABLE_INSIDE(Back[x][y])) + return; + + if (Back[x][y]) + DrawGraphic(sx, sy, el2img(Back[x][y]), 0); + else if (Store[x][y]) DrawGraphic(sx, sy, el2img(Store[x][y]), 0); frame = getGraphicAnimationFrame(graphic, GfxFrame[x][y]); +#if 1 + if (Back[x][y] || Store[x][y]) + DrawGraphicThruMask(sx, sy, graphic, frame); + else + DrawGraphic(sx, sy, graphic, frame); +#else if (game.emulation == EMU_SUPAPLEX) DrawGraphic(sx, sy, IMG_SP_DISK_RED, frame); else if (Store[x][y]) DrawGraphicThruMask(sx, sy, graphic, frame); else DrawGraphic(sx, sy, graphic, frame); +#endif } void CheckDynamite(int x, int y) { - int element = Feld[x][y]; - if (MovDelay[x][y] != 0) /* dynamite is still waiting to explode */ { MovDelay[x][y]--; if (MovDelay[x][y] != 0) { - if (checkDrawLevelGraphicAnimation(x, y, el2img(element))) - DrawDynamite(x, y); - - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); + DrawDynamite(x, y); + PlaySoundLevelActionIfLoop(x, y, ACTION_ACTIVE); return; } } - if (Feld[x][y] == EL_DYNAMITE_ACTIVE) +#if 1 + StopSoundLevelActionIfLoop(x, y, ACTION_ACTIVE); +#else + if (Feld[x][y] == EL_DYNAMITE_ACTIVE || + Feld[x][y] == EL_SP_DISK_RED_ACTIVE) StopSound(SND_DYNAMITE_ACTIVE); else StopSound(SND_DYNABOMB_ACTIVE); +#endif Bang(x, y); } @@ -1641,6 +1658,10 @@ void Explode(int ex, int ey, int phase, int mode) { int center_element = Feld[ex][ey]; + /* remove things displayed in background while burning dynamite */ + if (!IS_INDESTRUCTIBLE(Back[ex][ey])) + Back[ex][ey] = 0; + if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey)) { /* put moving element to center field (and let it explode there) */ @@ -1649,7 +1670,7 @@ void Explode(int ex, int ey, int phase, int mode) Feld[ex][ey] = center_element; } - for (y=ey-1; y<=ey+1; y++) for(x=ex-1; x<=ex+1; x++) + for (y = ey - 1; y <= ey + 1; y++) for(x = ex - 1; x <= ex + 1; x++) { int element; @@ -1666,8 +1687,16 @@ void Explode(int ex, int ey, int phase, int mode) RemoveMovingField(x, y); } - if (IS_MASSIVE(element) || element == EL_FLAMES) +#if 1 + if (IS_EXPLOSION_PROOF(element)) continue; +#else + if ((IS_INDESTRUCTIBLE(element) && + (game.engine_version < VERSION_IDENT(2,2,0) || + (!IS_WALKABLE_OVER(element) && !IS_WALKABLE_UNDER(element)))) || + element == EL_FLAMES) + continue; +#endif if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y))) { @@ -1681,6 +1710,11 @@ void Explode(int ex, int ey, int phase, int mode) continue; } + /* save walkable background elements while explosion on same tile */ + if (IS_INDESTRUCTIBLE(element)) + Back[x][y] = element; + + /* ignite explodable elements reached by other explosion */ if (element == EL_EXPLOSION) element = Store2[x][y]; @@ -1688,16 +1722,16 @@ void Explode(int ex, int ey, int phase, int mode) { switch(StorePlayer[ex][ey]) { - case EL_PLAYER2: + case EL_PLAYER_2: Store[x][y] = EL_EMERALD_RED; break; - case EL_PLAYER3: + case EL_PLAYER_3: Store[x][y] = EL_EMERALD; break; - case EL_PLAYER4: + case EL_PLAYER_4: Store[x][y] = EL_EMERALD_PURPLE; break; - case EL_PLAYER1: + case EL_PLAYER_1: default: Store[x][y] = EL_EMERALD_YELLOW; break; @@ -1716,10 +1750,14 @@ void Explode(int ex, int ey, int phase, int mode) Store[x][y] = EL_BD_DIAMOND; else if (center_element == EL_SP_ELECTRON) Store[x][y] = EL_SP_INFOTRON; - else if (center_element == EL_YAMYAM) - Store[x][y] = level.yam_content[game.yam_content_nr][x-ex+1][y-ey+1]; else if (center_element == EL_AMOEBA_TO_DIAMOND) Store[x][y] = level.amoeba_content; + else if (center_element == EL_YAMYAM) + Store[x][y] = + level.yamyam_content[game.yamyam_content_nr][x - ex + 1][y - ey + 1]; + else if (IS_CUSTOM_ELEMENT(center_element)) + Store[x][y] = + element_info[center_element].content[x - ex + 1][y - ey + 1]; else if (element == EL_WALL_EMERALD) Store[x][y] = EL_EMERALD; else if (element == EL_WALL_DIAMOND) @@ -1736,7 +1774,7 @@ void Explode(int ex, int ey, int phase, int mode) Store[x][y] = EL_PEARL; else if (element == EL_WALL_CRYSTAL) Store[x][y] = EL_CRYSTAL; - else if (!IS_PFORTE(Store[x][y])) + else Store[x][y] = EL_EMPTY; if (x != ex || y != ey || @@ -1746,13 +1784,18 @@ void Explode(int ex, int ey, int phase, int mode) if (AmoebaNr[x][y] && (element == EL_AMOEBA_FULL || element == EL_BD_AMOEBA || - element == EL_AMOEBA_CREATING)) + element == EL_AMOEBA_GROWING)) { AmoebaCnt[AmoebaNr[x][y]]--; AmoebaCnt2[AmoebaNr[x][y]]--; } Feld[x][y] = EL_EXPLOSION; +#if 1 + GfxElement[x][y] = center_element; +#else + GfxElement[x][y] = EL_UNDEFINED; +#endif MovDir[x][y] = MovPos[x][y] = 0; AmoebaNr[x][y] = 0; ExplodePhase[x][y] = 1; @@ -1760,7 +1803,8 @@ void Explode(int ex, int ey, int phase, int mode) } if (center_element == EL_YAMYAM) - game.yam_content_nr = (game.yam_content_nr + 1) % level.num_yam_contents; + game.yamyam_content_nr = + (game.yamyam_content_nr + 1) % level.num_yamyam_contents; return; } @@ -1790,7 +1834,7 @@ void Explode(int ex, int ey, int phase, int mode) if (IS_PLAYER(x, y)) KillHeroUnlessProtected(x, y); - else if (IS_EXPLOSIVE(element)) + else if (CAN_EXPLODE_BY_FIRE(element)) { Feld[x][y] = Store2[x][y]; Store2[x][y] = 0; @@ -1806,9 +1850,15 @@ void Explode(int ex, int ey, int phase, int mode) element = Feld[x][y] = Store[x][y]; Store[x][y] = Store2[x][y] = 0; - MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; + GfxElement[x][y] = EL_UNDEFINED; + + if (Back[x][y] && IS_INDESTRUCTIBLE(Back[x][y])) + element = Feld[x][y] = Back[x][y]; + Back[x][y] = 0; + + MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = ChangeDelay[x][y] = 0; InitField(x, y, FALSE); - if (CAN_MOVE(element) || COULD_MOVE(element)) + if (CAN_MOVE(element)) InitMovDir(x, y); DrawLevelField(x, y); @@ -1817,21 +1867,30 @@ void Explode(int ex, int ey, int phase, int mode) } else if (phase >= delay && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { +#if 1 + int graphic = el_act2img(GfxElement[x][y], ACTION_EXPLODING); +#else int stored = Store[x][y]; int graphic = (game.emulation != EMU_SUPAPLEX ? IMG_EXPLOSION : stored == EL_SP_INFOTRON ? IMG_SP_EXPLOSION_INFOTRON : IMG_SP_EXPLOSION); +#endif int frame = getGraphicAnimationFrame(graphic, phase - delay); if (phase == delay) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); + DrawLevelFieldCrumbledSand(x, y); - if (IS_PFORTE(Store[x][y])) + if (IS_WALKABLE_OVER(Back[x][y]) && Back[x][y] != EL_EMPTY) { - DrawLevelElement(x, y, Store[x][y]); + DrawLevelElement(x, y, Back[x][y]); DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame); } - else + else if (IS_WALKABLE_UNDER(Back[x][y])) + { + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); + DrawLevelElementThruMask(x, y, Back[x][y]); + } + else if (!IS_WALKABLE_INSIDE(Back[x][y])) DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); } } @@ -1852,7 +1911,7 @@ void DynaExplode(int ex, int ey) if (IS_ACTIVE_BOMB(Feld[ex][ey])) { - player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_PLAYER1_ACTIVE]; + player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_PLAYER_1_ACTIVE]; dynabomb_size = player->dynabomb_size; dynabomb_xl = player->dynabomb_xl; player->dynabombs_left++; @@ -1868,7 +1927,7 @@ void DynaExplode(int ex, int ey) int y = ey + j * xy[i % 4][1]; int element; - if (!IN_LEV_FIELD(x, y) || IS_MASSIVE(Feld[x][y])) + if (!IN_LEV_FIELD(x, y) || IS_INDESTRUCTIBLE(Feld[x][y])) break; element = Feld[x][y]; @@ -1892,10 +1951,22 @@ void Bang(int x, int y) { int element = Feld[x][y]; + if (IS_PLAYER(x, y)) + { + struct PlayerInfo *player = PLAYERINFO(x, y); + + element = Feld[x][y] = (player->use_murphy_graphic ? EL_SP_MURPHY : + player->element_nr); + } + +#if 1 + PlaySoundLevelAction(x, y, ACTION_EXPLODING); +#else if (game.emulation == EMU_SUPAPLEX) PlaySoundLevel(x, y, SND_SP_ELEMENT_EXPLODING); else PlaySoundLevel(x, y, SND_ELEMENT_EXPLODING); +#endif #if 0 if (IS_PLAYER(x, y)) /* remove objects that might cause smaller explosion */ @@ -1916,13 +1987,13 @@ void Bang(int x, int y) RaiseScoreElement(element); Explode(x, y, EX_PHASE_START, EX_NORMAL); break; - case EL_DYNABOMB_PLAYER1_ACTIVE: - case EL_DYNABOMB_PLAYER2_ACTIVE: - case EL_DYNABOMB_PLAYER3_ACTIVE: - case EL_DYNABOMB_PLAYER4_ACTIVE: - case EL_DYNABOMB_NR: - case EL_DYNABOMB_SZ: - case EL_DYNABOMB_XL: + case EL_DYNABOMB_PLAYER_1_ACTIVE: + case EL_DYNABOMB_PLAYER_2_ACTIVE: + case EL_DYNABOMB_PLAYER_3_ACTIVE: + case EL_DYNABOMB_PLAYER_4_ACTIVE: + case EL_DYNABOMB_INCREASE_NUMBER: + case EL_DYNABOMB_INCREASE_SIZE: + case EL_DYNABOMB_INCREASE_POWER: DynaExplode(x, y); break; case EL_PENGUIN: @@ -1939,73 +2010,45 @@ void Bang(int x, int y) } } -void Blurb(int x, int y) +void SplashAcid(int x, int y) { int element = Feld[x][y]; if (element != EL_ACID_SPLASH_LEFT && - element != EL_ACID_SPLASH_RIGHT) /* start */ + element != EL_ACID_SPLASH_RIGHT) { PlaySoundLevel(x, y, SND_ACID_SPLASHING); + if (IN_LEV_FIELD(x-1, y) && IS_FREE(x-1, y) && (!IN_LEV_FIELD(x-1, y-1) || !CAN_FALL(MovingOrBlocked2Element(x-1, y-1)))) - { Feld[x-1][y] = EL_ACID_SPLASH_LEFT; - } + if (IN_LEV_FIELD(x+1, y) && IS_FREE(x+1, y) && (!IN_LEV_FIELD(x+1, y-1) || !CAN_FALL(MovingOrBlocked2Element(x+1, y-1)))) - { Feld[x+1][y] = EL_ACID_SPLASH_RIGHT; - } } - else /* go on */ +} + +static void InitBeltMovement() +{ + static int belt_base_element[4] = + { + EL_CONVEYOR_BELT_1_LEFT, + EL_CONVEYOR_BELT_2_LEFT, + EL_CONVEYOR_BELT_3_LEFT, + EL_CONVEYOR_BELT_4_LEFT + }; + static int belt_base_active_element[4] = { - int graphic = (element == EL_ACID_SPLASH_LEFT ? - IMG_ACID_SPLASH_LEFT : - IMG_ACID_SPLASH_RIGHT); + EL_CONVEYOR_BELT_1_LEFT_ACTIVE, + EL_CONVEYOR_BELT_2_LEFT_ACTIVE, + EL_CONVEYOR_BELT_3_LEFT_ACTIVE, + EL_CONVEYOR_BELT_4_LEFT_ACTIVE + }; - if (!MovDelay[x][y]) /* initialize animation counter */ - MovDelay[x][y] = 9; - - if (MovDelay[x][y]) /* continue animation */ - { - MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(graphic, 8 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); - } - - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_EMPTY; - DrawLevelField(x, y); - } - } - } -} - -static void InitBeltMovement() -{ - static int belt_base_element[4] = - { - EL_CONVEYOR_BELT1_LEFT, - EL_CONVEYOR_BELT2_LEFT, - EL_CONVEYOR_BELT3_LEFT, - EL_CONVEYOR_BELT4_LEFT - }; - static int belt_base_active_element[4] = - { - EL_CONVEYOR_BELT1_LEFT_ACTIVE, - EL_CONVEYOR_BELT2_LEFT_ACTIVE, - EL_CONVEYOR_BELT3_LEFT_ACTIVE, - EL_CONVEYOR_BELT4_LEFT_ACTIVE - }; - - int x, y, i, j; + int x, y, i, j; /* set frame order for belt animation graphic according to belt direction */ for (i=0; i<4; i++) @@ -2018,9 +2061,9 @@ static void InitBeltMovement() int graphic = el2img(element); if (game.belt_dir[i] == MV_LEFT) - new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; + graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; else - new_graphic_info[graphic].anim_mode |= ANIM_REVERSE; + graphic_info[graphic].anim_mode |= ANIM_REVERSE; } } @@ -2053,24 +2096,24 @@ static void ToggleBeltSwitch(int x, int y) { static int belt_base_element[4] = { - EL_CONVEYOR_BELT1_LEFT, - EL_CONVEYOR_BELT2_LEFT, - EL_CONVEYOR_BELT3_LEFT, - EL_CONVEYOR_BELT4_LEFT + EL_CONVEYOR_BELT_1_LEFT, + EL_CONVEYOR_BELT_2_LEFT, + EL_CONVEYOR_BELT_3_LEFT, + EL_CONVEYOR_BELT_4_LEFT }; static int belt_base_active_element[4] = { - EL_CONVEYOR_BELT1_LEFT_ACTIVE, - EL_CONVEYOR_BELT2_LEFT_ACTIVE, - EL_CONVEYOR_BELT3_LEFT_ACTIVE, - EL_CONVEYOR_BELT4_LEFT_ACTIVE + EL_CONVEYOR_BELT_1_LEFT_ACTIVE, + EL_CONVEYOR_BELT_2_LEFT_ACTIVE, + EL_CONVEYOR_BELT_3_LEFT_ACTIVE, + EL_CONVEYOR_BELT_4_LEFT_ACTIVE }; static int belt_base_switch_element[4] = { - EL_CONVEYOR_BELT1_SWITCH_LEFT, - EL_CONVEYOR_BELT2_SWITCH_LEFT, - EL_CONVEYOR_BELT3_SWITCH_LEFT, - EL_CONVEYOR_BELT4_SWITCH_LEFT + EL_CONVEYOR_BELT_1_SWITCH_LEFT, + EL_CONVEYOR_BELT_2_SWITCH_LEFT, + EL_CONVEYOR_BELT_3_SWITCH_LEFT, + EL_CONVEYOR_BELT_4_SWITCH_LEFT }; static int belt_move_dir[4] = { @@ -2102,9 +2145,9 @@ static void ToggleBeltSwitch(int x, int y) int graphic = el2img(element); if (belt_dir == MV_LEFT) - new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; + graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; else - new_graphic_info[graphic].anim_mode |= ANIM_REVERSE; + graphic_info[graphic].anim_mode |= ANIM_REVERSE; } for (yy=0; yyx) + else if (attr_x > x) MovDir[x][y] |= (AllPlayersGone ? MV_LEFT : MV_RIGHT); - if (attr_yy) + else if (attr_y > y) MovDir[x][y] |= (AllPlayersGone ? MV_UP : MV_DOWN); if (element == EL_ROBOT) { int newx, newy; - if ((MovDir[x][y]&(MV_LEFT|MV_RIGHT)) && (MovDir[x][y]&(MV_UP|MV_DOWN))) - MovDir[x][y] &= (RND(2) ? (MV_LEFT|MV_RIGHT) : (MV_UP|MV_DOWN)); + if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL) + MovDir[x][y] &= (RND(2) ? MV_HORIZONTAL : MV_VERTICAL); Moving2Blocked(x, y, &newx, &newy); if (IN_LEV_FIELD(newx, newy) && IS_FREE_OR_PLAYER(newx, newy)) @@ -2851,13 +2964,13 @@ void TurnRound(int x, int y) MovDelay[x][y] = 1; - if ((MovDir[x][y]&(MV_LEFT|MV_RIGHT)) && (MovDir[x][y]&(MV_UP|MV_DOWN))) + if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL) { boolean first_horiz = RND(2); int new_move_dir = MovDir[x][y]; MovDir[x][y] = - new_move_dir & (first_horiz ? (MV_LEFT|MV_RIGHT) : (MV_UP|MV_DOWN)); + new_move_dir & (first_horiz ? MV_HORIZONTAL : MV_VERTICAL); Moving2Blocked(x, y, &newx, &newy); if (IN_LEV_FIELD(newx, newy) && @@ -2865,11 +2978,11 @@ void TurnRound(int x, int y) Feld[newx][newy] == EL_ACID || (element == EL_PENGUIN && (Feld[newx][newy] == EL_EXIT_OPEN || - IS_MAMPF3(Feld[newx][newy]))))) + IS_FOOD_PENGUIN(Feld[newx][newy]))))) return; MovDir[x][y] = - new_move_dir & (!first_horiz ? (MV_LEFT|MV_RIGHT) : (MV_UP|MV_DOWN)); + new_move_dir & (!first_horiz ? MV_HORIZONTAL : MV_VERTICAL); Moving2Blocked(x, y, &newx, &newy); if (IN_LEV_FIELD(newx, newy) && @@ -2877,7 +2990,7 @@ void TurnRound(int x, int y) Feld[newx][newy] == EL_ACID || (element == EL_PENGUIN && (Feld[newx][newy] == EL_EXIT_OPEN || - IS_MAMPF3(Feld[newx][newy]))))) + IS_FOOD_PENGUIN(Feld[newx][newy]))))) return; MovDir[x][y] = old_move_dir; @@ -2885,6 +2998,148 @@ void TurnRound(int x, int y) } } } + else if (element_info[element].move_pattern == MV_ALL_DIRECTIONS) + { + boolean can_turn_left = FALSE, can_turn_right = FALSE; + + if (IN_LEV_FIELD(left_x, left_y) && + (IS_FREE(left_x, left_y) || + (DONT_COLLIDE_WITH(element) && IS_FREE_OR_PLAYER(left_x, left_y)))) + can_turn_left = TRUE; + if (IN_LEV_FIELD(right_x, right_y) && + (IS_FREE(right_x, right_y) || + (DONT_COLLIDE_WITH(element) && IS_FREE_OR_PLAYER(right_x, right_y)))) + can_turn_right = TRUE; + + if (can_turn_left && can_turn_right) + MovDir[x][y] = (RND(3) ? (RND(2) ? left_dir : right_dir) : back_dir); + else if (can_turn_left) + MovDir[x][y] = (RND(2) ? left_dir : back_dir); + else if (can_turn_right) + MovDir[x][y] = (RND(2) ? right_dir : back_dir); + else + MovDir[x][y] = back_dir; + + MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); + } + else if (element_info[element].move_pattern == MV_HORIZONTAL || + element_info[element].move_pattern == MV_VERTICAL) + { + if (element_info[element].move_pattern & old_move_dir) + MovDir[x][y] = back_dir; + else if (element_info[element].move_pattern == MV_HORIZONTAL) + MovDir[x][y] = (RND(2) ? MV_LEFT : MV_RIGHT); + else if (element_info[element].move_pattern == MV_VERTICAL) + MovDir[x][y] = (RND(2) ? MV_UP : MV_DOWN); + + MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); + } + else if (element_info[element].move_pattern & MV_ANY_DIRECTION) + { + MovDir[x][y] = element_info[element].move_pattern; + MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); + } + else if (element_info[element].move_pattern == MV_ALONG_LEFT_SIDE) + { + if (IN_LEV_FIELD(left_x, left_y) && + (IS_FREE(left_x, left_y) || + (DONT_COLLIDE_WITH(element) && IS_FREE_OR_PLAYER(left_x, left_y)))) + MovDir[x][y] = left_dir; + else if (!IN_LEV_FIELD(move_x, move_y) || + (!IS_FREE(move_x, move_y) && + (!DONT_COLLIDE_WITH(element) || !IS_FREE_OR_PLAYER(move_x, move_y)))) + MovDir[x][y] = right_dir; + + if (MovDir[x][y] != old_move_dir) + MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); + } + else if (element_info[element].move_pattern == MV_ALONG_RIGHT_SIDE) + { + if (IN_LEV_FIELD(right_x, right_y) && + (IS_FREE(right_x, right_y) || + (DONT_COLLIDE_WITH(element) && IS_FREE_OR_PLAYER(right_x, right_y)))) + MovDir[x][y] = right_dir; + else if (!IN_LEV_FIELD(move_x, move_y) || + (!IS_FREE(move_x, move_y) && + (!DONT_COLLIDE_WITH(element) || !IS_FREE_OR_PLAYER(move_x, move_y)))) + MovDir[x][y] = left_dir; + + if (MovDir[x][y] != old_move_dir) + MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); + } + else if (element_info[element].move_pattern == MV_TOWARDS_PLAYER || + element_info[element].move_pattern == MV_AWAY_FROM_PLAYER) + { + int attr_x = -1, attr_y = -1; + int newx, newy; + boolean move_away = + (element_info[element].move_pattern == MV_AWAY_FROM_PLAYER); + + if (AllPlayersGone) + { + attr_x = ExitX; + attr_y = ExitY; + } + else + { + int i; + + for (i=0; ijx, jy = player->jy; + + if (!player->active) + continue; + + if (attr_x == -1 || ABS(jx-x)+ABS(jy-y) < ABS(attr_x-x)+ABS(attr_y-y)) + { + attr_x = jx; + attr_y = jy; + } + } + } + + MovDir[x][y] = MV_NO_MOVING; + if (attr_x < x) + MovDir[x][y] |= (move_away ? MV_RIGHT : MV_LEFT); + else if (attr_x > x) + MovDir[x][y] |= (move_away ? MV_LEFT : MV_RIGHT); + if (attr_y < y) + MovDir[x][y] |= (move_away ? MV_DOWN : MV_UP); + else if (attr_y > y) + MovDir[x][y] |= (move_away ? MV_UP : MV_DOWN); + + MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); + + if (MovDir[x][y] & MV_HORIZONTAL && MovDir[x][y] & MV_VERTICAL) + { + boolean first_horiz = RND(2); + int new_move_dir = MovDir[x][y]; + + MovDir[x][y] = + new_move_dir & (first_horiz ? MV_HORIZONTAL : MV_VERTICAL); + Moving2Blocked(x, y, &newx, &newy); + + if (IN_LEV_FIELD(newx, newy) && (IS_FREE(newx, newy) || + (DONT_COLLIDE_WITH(element) && + IS_FREE_OR_PLAYER(newx, newy)) || + Feld[newx][newy] == EL_ACID)) + return; + + MovDir[x][y] = + new_move_dir & (!first_horiz ? MV_HORIZONTAL : MV_VERTICAL); + Moving2Blocked(x, y, &newx, &newy); + + if (IN_LEV_FIELD(newx, newy) && (IS_FREE(newx, newy) || + (DONT_COLLIDE_WITH(element) && + IS_FREE_OR_PLAYER(newx, newy)) || + Feld[newx][newy] == EL_ACID)) + return; + + MovDir[x][y] = old_move_dir; + } + } } static boolean JustBeingPushed(int x, int y) @@ -2910,14 +3165,14 @@ static boolean JustBeingPushed(int x, int y) void StartMoving(int x, int y) { - static boolean use_spring_bug = TRUE; + boolean use_spring_bug = (game.engine_version < VERSION_IDENT(2,2,0)); boolean started_moving = FALSE; /* some elements can fall _and_ move */ int element = Feld[x][y]; if (Stop[x][y]) return; - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; if (CAN_FALL(element) && y < lev_fieldy - 1) { @@ -2927,16 +3182,20 @@ void StartMoving(int x, int y) if (element == EL_QUICKSAND_FULL) { - if (IS_FREE(x, y+1)) + if (IS_FREE(x, y + 1)) { InitMovingField(x, y, MV_DOWN); started_moving = TRUE; Feld[x][y] = EL_QUICKSAND_EMPTYING; Store[x][y] = EL_ROCK; +#if 1 + PlaySoundLevelAction(x, y, ACTION_EMPTYING); +#else PlaySoundLevel(x, y, SND_QUICKSAND_EMPTYING); +#endif } - else if (Feld[x][y+1] == EL_QUICKSAND_EMPTY) + else if (Feld[x][y + 1] == EL_QUICKSAND_EMPTY) { if (!MovDelay[x][y]) MovDelay[x][y] = TILEY + 1; @@ -2949,25 +3208,33 @@ void StartMoving(int x, int y) } Feld[x][y] = EL_QUICKSAND_EMPTY; - Feld[x][y+1] = EL_QUICKSAND_FULL; - Store[x][y+1] = Store[x][y]; + Feld[x][y + 1] = EL_QUICKSAND_FULL; + Store[x][y + 1] = Store[x][y]; Store[x][y] = 0; - PlaySoundLevel(x, y, SND_QUICKSAND_SLIPPING); +#if 1 + PlaySoundLevelAction(x, y, ACTION_FILLING); +#else + PlaySoundLevel(x, y, SND_QUICKSAND_FILLING); +#endif } } else if ((element == EL_ROCK || element == EL_BD_ROCK) && - Feld[x][y+1] == EL_QUICKSAND_EMPTY) + Feld[x][y + 1] == EL_QUICKSAND_EMPTY) { InitMovingField(x, y, MV_DOWN); started_moving = TRUE; Feld[x][y] = EL_QUICKSAND_FILLING; Store[x][y] = element; +#if 1 + PlaySoundLevelAction(x, y, ACTION_FILLING); +#else PlaySoundLevel(x, y, SND_QUICKSAND_FILLING); +#endif } else if (element == EL_MAGIC_WALL_FULL) { - if (IS_FREE(x, y+1)) + if (IS_FREE(x, y + 1)) { InitMovingField(x, y, MV_DOWN); started_moving = TRUE; @@ -2975,7 +3242,7 @@ void StartMoving(int x, int y) Feld[x][y] = EL_MAGIC_WALL_EMPTYING; Store[x][y] = EL_CHANGED(Store[x][y]); } - else if (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE) + else if (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE) { if (!MovDelay[x][y]) MovDelay[x][y] = TILEY/4 + 1; @@ -2988,14 +3255,14 @@ void StartMoving(int x, int y) } Feld[x][y] = EL_MAGIC_WALL_ACTIVE; - Feld[x][y+1] = EL_MAGIC_WALL_FULL; - Store[x][y+1] = EL_CHANGED(Store[x][y]); + Feld[x][y + 1] = EL_MAGIC_WALL_FULL; + Store[x][y + 1] = EL_CHANGED(Store[x][y]); Store[x][y] = 0; } } else if (element == EL_BD_MAGIC_WALL_FULL) { - if (IS_FREE(x, y+1)) + if (IS_FREE(x, y + 1)) { InitMovingField(x, y, MV_DOWN); started_moving = TRUE; @@ -3003,7 +3270,7 @@ void StartMoving(int x, int y) Feld[x][y] = EL_BD_MAGIC_WALL_EMPTYING; Store[x][y] = EL_CHANGED2(Store[x][y]); } - else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE) + else if (Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE) { if (!MovDelay[x][y]) MovDelay[x][y] = TILEY/4 + 1; @@ -3016,38 +3283,46 @@ void StartMoving(int x, int y) } Feld[x][y] = EL_BD_MAGIC_WALL_ACTIVE; - Feld[x][y+1] = EL_BD_MAGIC_WALL_FULL; - Store[x][y+1] = EL_CHANGED2(Store[x][y]); + Feld[x][y + 1] = EL_BD_MAGIC_WALL_FULL; + Store[x][y + 1] = EL_CHANGED2(Store[x][y]); Store[x][y] = 0; } } - else if (CAN_CHANGE(element) && - (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE || - Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE)) + else if (CAN_PASS_MAGIC_WALL(element) && + (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE || + Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE)) { InitMovingField(x, y, MV_DOWN); started_moving = TRUE; Feld[x][y] = - (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ? EL_MAGIC_WALL_FILLING : + (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE ? EL_MAGIC_WALL_FILLING : EL_BD_MAGIC_WALL_FILLING); Store[x][y] = element; } - else if (CAN_SMASH(element) && Feld[x][y+1] == EL_ACID) +#if 0 + else if (CAN_SMASH(element) && Feld[x][y + 1] == EL_ACID) +#else + else if (CAN_FALL(element) && Feld[x][y + 1] == EL_ACID) +#endif { - Blurb(x, y); + SplashAcid(x, y); InitMovingField(x, y, MV_DOWN); started_moving = TRUE; Store[x][y] = EL_ACID; +#if 0 + /* !!! TEST !!! better use "_FALLING" etc. !!! */ + GfxAction[x][y + 1] = ACTION_ACTIVE; +#endif } - else if (CAN_SMASH(element) && Feld[x][y+1] == EL_BLOCKED && + else if (CAN_SMASH(element) && Feld[x][y + 1] == EL_BLOCKED && JustStopped[x][y]) { Impact(x, y); } - else if (IS_FREE(x, y+1) && element == EL_SPRING && use_spring_bug) + else if (IS_FREE(x, y + 1) && element == EL_SPRING && use_spring_bug) { if (MovDir[x][y] == MV_NO_MOVING) { @@ -3055,38 +3330,41 @@ void StartMoving(int x, int y) started_moving = TRUE; } } - else if (IS_FREE(x, y+1)) + else if (IS_FREE(x, y + 1) || Feld[x][y + 1] == EL_DIAMOND_BREAKING) { + if (JustStopped[x][y]) /* prevent animation from being restarted */ + MovDir[x][y] = MV_DOWN; + InitMovingField(x, y, MV_DOWN); started_moving = TRUE; } else if (element == EL_AMOEBA_DROP) { - Feld[x][y] = EL_AMOEBA_CREATING; + Feld[x][y] = EL_AMOEBA_GROWING; Store[x][y] = EL_AMOEBA_WET; } - /* Store[x][y+1] must be zero, because: - (EL_QUICKSAND_FULL -> EL_ROCK): Store[x][y+1] == EL_QUICKSAND_EMPTY + /* Store[x][y + 1] must be zero, because: + (EL_QUICKSAND_FULL -> EL_ROCK): Store[x][y + 1] == EL_QUICKSAND_EMPTY */ #if 0 #if OLD_GAME_BEHAVIOUR - else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1]) + else if (IS_SLIPPERY(Feld[x][y + 1]) && !Store[x][y + 1]) #else - else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1] && - !IS_FALLING(x, y+1) && !JustStopped[x][y+1] && + else if (IS_SLIPPERY(Feld[x][y + 1]) && !Store[x][y + 1] && + !IS_FALLING(x, y + 1) && !JustStopped[x][y + 1] && element != EL_DX_SUPABOMB) #endif #else - else if ((IS_SLIPPERY(Feld[x][y+1]) || - (IS_EM_SLIPPERY_WALL(Feld[x][y+1]) && IS_GEM(element))) && - !IS_FALLING(x, y+1) && !JustStopped[x][y+1] && + else if ((IS_SLIPPERY(Feld[x][y + 1]) || + (IS_EM_SLIPPERY_WALL(Feld[x][y + 1]) && IS_GEM(element))) && + !IS_FALLING(x, y + 1) && !JustStopped[x][y + 1] && element != EL_DX_SUPABOMB && element != EL_SP_DISK_ORANGE) #endif { boolean left = (x>0 && IS_FREE(x-1, y) && - (IS_FREE(x-1, y+1) || Feld[x-1][y+1] == EL_ACID)); + (IS_FREE(x-1, y + 1) || Feld[x-1][y + 1] == EL_ACID)); boolean right = (x0 && IS_FREE(x-1, y)); boolean right_is_free = (x %d\n", MovDir[x][y]); -#endif TurnRound(x, y); -#if 0 - if (element == EL_SPRING) - printf("2--> %d\n", MovDir[x][y]); -#endif + if (MovDelay[x][y] && (element == EL_BUG || element == EL_SPACESHIP || element == EL_SP_SNIKSNAK || @@ -3173,37 +3445,50 @@ void StartMoving(int x, int y) { MovDelay[x][y]--; - if (element == EL_ROBOT || - element == EL_YAMYAM || element == EL_DARK_YAMYAM) +#if 0 + if (element == EL_YAMYAM) { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int graphic = el2img(element); - int frame = getGraphicAnimationFrame(graphic, MovDelay[x][y] % 8); + printf("::: %d\n", + el_act_dir2img(EL_YAMYAM, ACTION_WAITING, MV_LEFT)); + DrawLevelElementAnimation(x, y, element); + } +#endif - DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); - } + if (MovDelay[x][y]) /* element still has to wait some time */ + { +#if 0 + /* !!! PLACE THIS SOMEWHERE AFTER "TurnRound()" !!! */ + ResetGfxAnimation(x, y); +#endif + GfxAction[x][y] = ACTION_WAITING; + } - if (MovDelay[x][y] % 4 == 3) - { - if (element == EL_YAMYAM) - PlaySoundLevel(x, y, SND_YAMYAM_WAITING); - else if (element == EL_DARK_YAMYAM) - PlaySoundLevel(x, y, SND_DARK_YAMYAM_WAITING); - } + if (element == EL_ROBOT || +#if 0 + element == EL_PACMAN || +#endif + element == EL_YAMYAM || + element == EL_DARK_YAMYAM) + { +#if 0 + DrawLevelElementAnimation(x, y, element); +#else + DrawLevelElementAnimationIfNeeded(x, y, element); +#endif + PlaySoundLevelAction(x, y, ACTION_WAITING); } else if (element == EL_SP_ELECTRON) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); else if (element == EL_DRAGON) { int i; int dir = MovDir[x][y]; int dx = (dir == MV_LEFT ? -1 : dir == MV_RIGHT ? +1 : 0); int dy = (dir == MV_UP ? -1 : dir == MV_DOWN ? +1 : 0); - int graphic = (dir == MV_LEFT ? IMG_FLAMES_LEFT1 : - dir == MV_RIGHT ? IMG_FLAMES_RIGHT1 : - dir == MV_UP ? IMG_FLAMES_UP1 : - dir == MV_DOWN ? IMG_FLAMES_DOWN1 : IMG_EMPTY); + int graphic = (dir == MV_LEFT ? IMG_FLAMES_1_LEFT : + dir == MV_RIGHT ? IMG_FLAMES_1_RIGHT : + dir == MV_UP ? IMG_FLAMES_1_UP : + dir == MV_DOWN ? IMG_FLAMES_1_DOWN : IMG_EMPTY); int frame = getGraphicAnimationFrame(graphic, -1); for (i=1; i<=3; i++) @@ -3212,15 +3497,14 @@ void StartMoving(int x, int y) int sx = SCREENX(xx), sy = SCREENY(yy); int flame_graphic = graphic + (i - 1); - if (!IN_LEV_FIELD(xx, yy) || - IS_SOLID(Feld[xx][yy]) || Feld[xx][yy] == EL_EXPLOSION) + if (!IN_LEV_FIELD(xx, yy) || IS_DRAGONFIRE_PROOF(Feld[xx][yy])) break; if (MovDelay[x][y]) { int flamed = MovingOrBlocked2Element(xx, yy); - if (IS_ENEMY(flamed) || IS_EXPLOSIVE(flamed)) + if (IS_CLASSIC_ENEMY(flamed) || CAN_EXPLODE_BY_FIRE(flamed)) Bang(xx, yy); else RemoveMovingField(xx, yy); @@ -3240,37 +3524,41 @@ void StartMoving(int x, int y) if (MovDelay[x][y]) /* element still has to wait some time */ { - PlaySoundLevelAction(x, y, SND_ACTION_WAITING); + PlaySoundLevelAction(x, y, ACTION_WAITING); return; } + + GfxAction[x][y] = ACTION_MOVING; } /* now make next step */ Moving2Blocked(x, y, &newx, &newy); /* get next screen position */ - if (IS_ENEMY(element) && IS_PLAYER(newx, newy) && + if (DONT_COLLIDE_WITH(element) && IS_PLAYER(newx, newy) && !PLAYER_PROTECTED(newx, newy)) { - #if 1 TestIfBadThingRunsIntoHero(x, y, MovDir[x][y]); return; #else - /* enemy got the player */ + /* player killed by element which is deadly when colliding with */ MovDir[x][y] = 0; KillHero(PLAYERINFO(newx, newy)); return; #endif } - else if ((element == EL_PENGUIN || element == EL_ROBOT || - element == EL_SATELLITE || element == EL_BALLOON) && + else if ((element == EL_PENGUIN || + element == EL_ROBOT || + element == EL_SATELLITE || + element == EL_BALLOON || + IS_CUSTOM_ELEMENT(element)) && IN_LEV_FIELD(newx, newy) && MovDir[x][y] == MV_DOWN && Feld[newx][newy] == EL_ACID) { - Blurb(x, y); + SplashAcid(x, y); Store[x][y] = EL_ACID; } else if (element == EL_PENGUIN && IN_LEV_FIELD(newx, newy)) @@ -3280,7 +3568,7 @@ void StartMoving(int x, int y) Feld[x][y] = EL_EMPTY; DrawLevelField(x, y); - PlaySoundLevel(newx, newy, SND_PENGUIN_PASSING_EXIT); + PlaySoundLevel(newx, newy, SND_PENGUIN_PASSING); if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) DrawGraphicThruMask(SCREENX(newx),SCREENY(newy), el2img(element), 0); @@ -3291,7 +3579,7 @@ void StartMoving(int x, int y) return; } - else if (IS_MAMPF3(Feld[newx][newy])) + else if (IS_FOOD_PENGUIN(Feld[newx][newy])) { if (DigField(local_player, newx, newy, 0, 0, DF_DIG) == MF_MOVING) DrawLevelField(newx, newy); @@ -3300,6 +3588,8 @@ void StartMoving(int x, int y) } else if (!IS_FREE(newx, newy)) { + GfxAction[x][y] = ACTION_WAITING; + if (IS_PLAYER(x, y)) DrawPlayerField(x, y); else @@ -3309,7 +3599,7 @@ void StartMoving(int x, int y) } else if (element == EL_PIG && IN_LEV_FIELD(newx, newy)) { - if (IS_GEM(Feld[newx][newy])) + if (IS_FOOD_PIG(Feld[newx][newy])) { if (IS_MOVING(newx, newy)) RemoveMovingField(newx, newy); @@ -3319,7 +3609,7 @@ void StartMoving(int x, int y) DrawLevelField(newx, newy); } - PlaySoundLevel(x, y, SND_PIG_EATING); + PlaySoundLevel(x, y, SND_PIG_DIGGING); } else if (!IS_FREE(newx, newy)) { @@ -3351,7 +3641,9 @@ void StartMoving(int x, int y) int element2 = (IN_LEV_FIELD(newx2, newy2) ? MovingOrBlocked2Element(newx2, newy2) : EL_STEELWALL); - if ((wanna_flame || IS_ENEMY(element1) || IS_ENEMY(element2)) && + if ((wanna_flame || + IS_CLASSIC_ENEMY(element1) || + IS_CLASSIC_ENEMY(element2)) && element1 != EL_DRAGON && element2 != EL_DRAGON && element1 != EL_FLAMES && element2 != EL_FLAMES) { @@ -3383,10 +3675,10 @@ void StartMoving(int x, int y) DrawLevelField(newx, newy); } - PlaySoundLevel(x, y, SND_YAMYAM_EATING); + PlaySoundLevel(x, y, SND_YAMYAM_DIGGING); } else if (element == EL_DARK_YAMYAM && IN_LEV_FIELD(newx, newy) && - IS_MAMPF2(Feld[newx][newy])) + IS_FOOD_DARK_YAMYAM(Feld[newx][newy])) { if (AmoebaNr[newx][newy]) { @@ -3404,7 +3696,7 @@ void StartMoving(int x, int y) DrawLevelField(newx, newy); } - PlaySoundLevel(x, y, SND_DARK_YAMYAM_EATING); + PlaySoundLevel(x, y, SND_DARK_YAMYAM_DIGGING); } else if ((element == EL_PACMAN || element == EL_MOLE) && IN_LEV_FIELD(newx, newy) && IS_AMOEBOID(Feld[newx][newy])) @@ -3420,7 +3712,7 @@ void StartMoving(int x, int y) if (element == EL_MOLE) { Feld[newx][newy] = EL_AMOEBA_SHRINKING; - PlaySoundLevel(x, y, SND_MOLE_EATING); + PlaySoundLevel(x, y, SND_MOLE_DIGGING); MovDelay[newx][newy] = 0; /* start amoeba shrinking delay */ return; /* wait for shrinking amoeba */ } @@ -3428,7 +3720,7 @@ void StartMoving(int x, int y) { Feld[newx][newy] = EL_EMPTY; DrawLevelField(newx, newy); - PlaySoundLevel(x, y, SND_PACMAN_EATING); + PlaySoundLevel(x, y, SND_PACMAN_DIGGING); } } else if (element == EL_MOLE && IN_LEV_FIELD(newx, newy) && @@ -3444,30 +3736,37 @@ void StartMoving(int x, int y) TurnRound(x, y); - if (element == EL_BUG || element == EL_SPACESHIP || +#if 1 + DrawLevelElementAnimation(x, y, element); +#else + if (element == EL_BUG || + element == EL_SPACESHIP || element == EL_SP_SNIKSNAK) DrawLevelField(x, y); - else if (element == EL_BUG || element == EL_SPACESHIP || - element == EL_SP_SNIKSNAK || element == EL_MOLE) + else if (element == EL_MOLE) DrawLevelField(x, y); - else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY) - DrawLevelElementAnimation(x, y, element); + else if (element == EL_BD_BUTTERFLY || + element == EL_BD_FIREFLY) + DrawLevelElementAnimationIfNeeded(x, y, element); else if (element == EL_SATELLITE) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); else if (element == EL_SP_ELECTRON) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); +#endif if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); - PlaySoundLevelAction(x, y, SND_ACTION_WAITING); +#if 0 + PlaySoundLevelAction(x, y, ACTION_WAITING); +#endif return; } InitMovingField(x, y, MovDir[x][y]); - PlaySoundLevelAction(x, y, SND_ACTION_MOVING); + PlaySoundLevelAction(x, y, ACTION_MOVING); } if (MovDir[x][y]) @@ -3482,9 +3781,9 @@ void ContinueMoving(int x, int y) int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); int horiz_move = (dx != 0); int newx = x + dx, newy = y + dy; - int step = (horiz_move ? dx : dy) * TILEX / 8; + int step = (horiz_move ? dx : dy) * TILEX / MOVE_DELAY_NORMAL_SPEED; - if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DRIPPING) + if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DROPPING) step /= 2; else if (element == EL_QUICKSAND_FILLING || element == EL_QUICKSAND_EMPTYING) @@ -3499,6 +3798,8 @@ void ContinueMoving(int x, int y) step /= 2; else if (element == EL_SPRING && horiz_move) step *= 2; + else if (IS_CUSTOM_ELEMENT(element)) + step = SIGN(step) * element_info[element].move_stepsize; #if OLD_GAME_BEHAVIOUR else if (CAN_FALL(element) && horiz_move && !IS_SP_ELEMENT(element)) @@ -3511,6 +3812,7 @@ void ContinueMoving(int x, int y) { Feld[x][y] = EL_EMPTY; Feld[newx][newy] = element; + MovPos[x][y] = 0; /* force "not moving" for "crumbled sand" */ if (element == EL_MOLE) { @@ -3534,7 +3836,7 @@ void ContinueMoving(int x, int y) yy = y + xy[i][1]; if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_SAND) - DrawLevelField(xx, yy); /* for "DrawCrumbledSand()" */ + DrawLevelField(xx, yy); /* for "crumbled sand" */ } } @@ -3576,7 +3878,7 @@ void ContinueMoving(int x, int y) Feld[x][y] = EL_BD_MAGIC_WALL_DEAD; element = Feld[newx][newy] = Store[x][y]; } - else if (element == EL_AMOEBA_DRIPPING) + else if (element == EL_AMOEBA_DROPPING) { Feld[x][y] = get_next_element(element); element = Feld[newx][newy] = Store[x][y]; @@ -3590,9 +3892,17 @@ void ContinueMoving(int x, int y) MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; MovDelay[newx][newy] = 0; + /* copy element change control values to new field */ + ChangeDelay[newx][newy] = ChangeDelay[x][y]; + + /* copy animation control values to new field */ + GfxFrame[newx][newy] = GfxFrame[x][y]; GfxAction[newx][newy] = GfxAction[x][y]; /* keep action one frame */ - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxRandom[newx][newy] = GfxRandom[x][y]; /* keep same random value */ + ResetGfxAnimation(x, y); /* reset animation values for old field */ + +#if 1 #if 0 if (!CAN_MOVE(element)) MovDir[newx][newy] = 0; @@ -3605,6 +3915,7 @@ void ContinueMoving(int x, int y) if (!CAN_MOVE(element) || (element == EL_SPRING && MovDir[newx][newy] == MV_DOWN)) MovDir[newx][newy] = 0; +#endif #endif DrawLevelField(x, y); @@ -3622,21 +3933,18 @@ void ContinueMoving(int x, int y) else if (element == EL_PENGUIN) TestIfFriendTouchesBadThing(newx, newy); +#if 1 + if (CAN_FALL(element) && direction == MV_DOWN && + (newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1))) + Impact(x, newy); +#else if (CAN_SMASH(element) && direction == MV_DOWN && - (newy == lev_fieldy-1 || !IS_FREE(x, newy+1))) + (newy == lev_fieldy - 1 || !IS_FREE(x, newy + 1))) Impact(x, newy); +#endif } else /* still moving on */ { -#if 0 - if (GfxAction[x][y] == GFX_ACTION_DEFAULT) - { - printf("reset GfxAction...\n"); - - GfxAction[x][y] = GFX_ACTION_MOVING; - } -#endif - DrawLevelField(x, y); } } @@ -3803,7 +4111,7 @@ void AmoebeUmwandelnBD(int ax, int ay, int new_element) if (AmoebaNr[x][y] == group_nr && (Feld[x][y] == EL_AMOEBA_DEAD || Feld[x][y] == EL_BD_AMOEBA || - Feld[x][y] == EL_AMOEBA_CREATING)) + Feld[x][y] == EL_AMOEBA_GROWING)) { AmoebaNr[x][y] = 0; Feld[x][y] = new_element; @@ -3831,10 +4139,14 @@ void AmoebeWaechst(int x, int y) if (DelayReached(&sound_delay, sound_delay_value)) { +#if 1 + PlaySoundLevelElementAction(x, y, Store[x][y], ACTION_GROWING); +#else if (Store[x][y] == EL_BD_AMOEBA) - PlaySoundLevel(x, y, SND_BD_AMOEBA_CREATING); + PlaySoundLevel(x, y, SND_BD_AMOEBA_GROWING); else - PlaySoundLevel(x, y, SND_AMOEBA_CREATING); + PlaySoundLevel(x, y, SND_AMOEBA_GROWING); +#endif sound_delay_value = 30; } } @@ -3844,10 +4156,10 @@ void AmoebeWaechst(int x, int y) MovDelay[x][y]--; if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { - int frame = getGraphicAnimationFrame(IMG_AMOEBA_CREATING, + int frame = getGraphicAnimationFrame(IMG_AMOEBA_GROWING, 6 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_CREATING, frame); + DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_GROWING, frame); } if (!MovDelay[x][y]) @@ -3899,6 +4211,7 @@ void AmoebeAbleger(int ax, int ay) { int i; int element = Feld[ax][ay]; + int graphic = el2img(element); int newax = ax, neway = ay; static int xy[4][2] = { @@ -3915,6 +4228,9 @@ void AmoebeAbleger(int ax, int ay) return; } + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic); + if (!MovDelay[ax][ay]) /* start making new amoeba field */ MovDelay[ax][ay] = RND(FRAMES_PER_SECOND * 25 / (1 + level.amoeba_speed)); @@ -4020,18 +4336,22 @@ void AmoebeAbleger(int ax, int ay) if (element != EL_AMOEBA_WET || neway < ay || !IS_FREE(newax, neway) || (neway == lev_fieldy - 1 && newax != ax)) { - Feld[newax][neway] = EL_AMOEBA_CREATING; /* creation of new amoeba */ + Feld[newax][neway] = EL_AMOEBA_GROWING; /* creation of new amoeba */ Store[newax][neway] = element; } else if (neway == ay) { Feld[newax][neway] = EL_AMOEBA_DROP; /* drop left/right of amoeba */ - PlaySoundLevel(newax, neway, SND_AMOEBA_DROP_CREATING); +#if 1 + PlaySoundLevelAction(newax, neway, ACTION_GROWING); +#else + PlaySoundLevel(newax, neway, SND_AMOEBA_GROWING); +#endif } else { InitMovingField(ax, ay, MV_DOWN); /* drop dripping from amoeba */ - Feld[ax][ay] = EL_AMOEBA_DRIPPING; + Feld[ax][ay] = EL_AMOEBA_DROPPING; Store[ax][ay] = EL_AMOEBA_DROP; ContinueMoving(ax, ay); return; @@ -4046,8 +4366,12 @@ void Life(int ax, int ay) static int life[4] = { 2, 3, 3, 3 }; /* parameters for "game of life" */ int life_time = 40; int element = Feld[ax][ay]; + int graphic = el2img(element); boolean changed = FALSE; + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic); + if (Stop[ax][ay]) return; @@ -4077,7 +4401,7 @@ void Life(int ax, int ay) continue; if (((Feld[x][y] == element || - (element == EL_GAMEOFLIFE && IS_PLAYER(x, y))) && + (element == EL_GAME_OF_LIFE && IS_PLAYER(x, y))) && !Stop[x][y]) || (IS_FREE(x, y) && Stop[x][y])) nachbarn++; @@ -4099,7 +4423,7 @@ void Life(int ax, int ay) if (nachbarn >= life[2] && nachbarn <= life[3]) { Feld[xx][yy] = element; - MovDelay[xx][yy] = (element == EL_GAMEOFLIFE ? 0 : life_time-1); + MovDelay[xx][yy] = (element == EL_GAME_OF_LIFE ? 0 : life_time-1); if (!Stop[xx][yy]) DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; @@ -4109,13 +4433,13 @@ void Life(int ax, int ay) } if (changed) - PlaySoundLevel(ax, ay, element == EL_GAMEOFLIFE ? SND_GAMEOFLIFE_CREATING : - SND_BIOMAZE_CREATING); + PlaySoundLevel(ax, ay, element == EL_BIOMAZE ? SND_BIOMAZE_GROWING : + SND_GAME_OF_LIFE_GROWING); } static void InitRobotWheel(int x, int y) { - MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; + ChangeDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; } static void RunRobotWheel(int x, int y) @@ -4129,332 +4453,53 @@ static void StopRobotWheel(int x, int y) ZX = ZY = -1; } -#if 0 -void RobotWheel(int x, int y) +static void InitTimegateWheel(int x, int y) { - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; + ChangeDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; +} - if (MovDelay[x][y]) /* wait some time before next frame */ +static void RunTimegateWheel(int x, int y) +{ + PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); +} + +void CheckExit(int x, int y) +{ + if (local_player->gems_still_needed > 0 || + local_player->sokobanfields_still_needed > 0 || + local_player->lights_still_needed > 0) { - MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_ROBOT_WHEEL_ACTIVE, -1); + int element = Feld[x][y]; + int graphic = el2img(element); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_ROBOT_WHEEL_ACTIVE, frame); - } - - PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE); - - return; - } - } - - Feld[x][y] = EL_ROBOT_WHEEL; - DrawLevelField(x, y); - - if (ZX == x && ZY == y) - ZX = ZY = -1; -} -#endif - -static void InitTimegateWheel(int x, int y) -{ - MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; -} - -static void RunTimegateWheel(int x, int y) -{ - PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); -} - -#if 0 -void TimegateWheel(int x, int y) -{ - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_TIMEGATE_SWITCH_ACTIVE, -1); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_SWITCH_ACTIVE, frame); - } - - PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); - - return; - } - } - - Feld[x][y] = EL_TIMEGATE_SWITCH; - DrawLevelField(x, y); - - /* THIS HAS NO EFFECT AT ALL! */ -#if 0 - /* !!! THIS LOOKS WRONG !!! */ - if (ZX == x && ZY == y) - ZX = ZY = -1; -#endif - -} -#endif + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); -#if 0 -void NussKnacken(int x, int y) -{ - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 7; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_NUT_CRACKING, - 6 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_NUT_CRACKING, frame); - } - - return; - } - } - - Feld[x][y] = EL_EMERALD; - DrawLevelField(x, y); -} -#endif - -#if 0 -void BreakingPearl(int x, int y) -{ - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 9; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_PEARL_BREAKING, - 8 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_PEARL_BREAKING, frame); - } - - return; - } - } - - Feld[x][y] = EL_EMPTY; - DrawLevelField(x, y); -} -#endif - -void SiebAktivieren(int x, int y, int type) -{ - int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL); - - DrawLevelGraphicAnimation(x, y, graphic); -} - -void CheckExit(int x, int y) -{ - if (local_player->gems_still_needed > 0 || - local_player->sokobanfields_still_needed > 0 || - local_player->lights_still_needed > 0) return; + } Feld[x][y] = EL_EXIT_OPENING; - PlaySoundLevelNearest(x, y, SND_EXIT_OPENING); + PlaySoundLevelNearest(x, y, SND_CLASS_EXIT_OPENING); } void CheckExitSP(int x, int y) { if (local_player->gems_still_needed > 0) - return; - - Feld[x][y] = EL_SP_EXIT_OPEN; - - PlaySoundLevelNearest(x, y, SND_SP_EXIT_OPENING); -} - -#if 0 -void AusgangstuerOeffnen(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - int tuer; - - MovDelay[x][y]--; - tuer = MovDelay[x][y] / delay; - - if (!(MovDelay[x][y] % delay)) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_EXIT_OPENING, - 29 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_EXIT_OPENING, frame); - } - } - - if (MovDelay[x][y]) - return; - } - - Feld[x][y] = EL_EXIT_OPEN; - DrawLevelField(x, y); -} -#endif - -#if 0 -void OpenSwitchgate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_OPENING, - 29 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_OPENING, frame); - } - } - - if (MovDelay[x][y]) - return; - } - - Feld[x][y] = EL_SWITCHGATE_OPEN; - DrawLevelField(x, y); -} -#endif - -#if 0 -void CloseSwitchgate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_CLOSING, - 29 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_CLOSING, frame); - } - } - - if (MovDelay[x][y]) - return; - } - - Feld[x][y] = EL_SWITCHGATE_CLOSED; - DrawLevelField(x, y); -} -#endif - -#if 0 -void OpenTimegate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_TIMEGATE_OPENING, - 29 - MovDelay[x][y]); + int element = Feld[x][y]; + int graphic = el2img(element); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame); - } - } + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); - if (MovDelay[x][y]) - return; + return; } - Feld[x][y] = EL_TIMEGATE_OPEN; - DrawLevelField(x, y); -} -#endif - -#if 0 -void CloseTimegate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_TIMEGATE_CLOSING, - 29 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_CLOSING, frame); - } - } - - if (MovDelay[x][y]) - return; - } + Feld[x][y] = EL_SP_EXIT_OPEN; - Feld[x][y] = EL_TIMEGATE_CLOSED; - DrawLevelField(x, y); + PlaySoundLevelNearest(x, y, SND_CLASS_SP_EXIT_OPENING); } -#endif static void CloseAllOpenTimegates() { @@ -4469,7 +4514,11 @@ static void CloseAllOpenTimegates() if (element == EL_TIMEGATE_OPEN || element == EL_TIMEGATE_OPENING) { Feld[x][y] = EL_TIMEGATE_CLOSING; +#if 1 + PlaySoundLevelAction(x, y, ACTION_CLOSING); +#else PlaySoundLevel(x, y, SND_TIMEGATE_CLOSING); +#endif } } } @@ -4481,47 +4530,37 @@ void EdelsteinFunkeln(int x, int y) return; if (Feld[x][y] == EL_BD_DIAMOND) -#if 0 - DrawLevelElementAnimation(x, y, el2img(Feld[x][y])); -#else return; -#endif - else - { - if (MovDelay[x][y] == 0) /* next animation frame */ - MovDelay[x][y] = 11 * !SimpleRND(500); - if (MovDelay[x][y] != 0) /* wait some time before next frame */ - { - MovDelay[x][y]--; + if (MovDelay[x][y] == 0) /* next animation frame */ + MovDelay[x][y] = 11 * !SimpleRND(500); + + if (MovDelay[x][y] != 0) /* wait some time before next frame */ + { + MovDelay[x][y]--; - if (setup.direct_draw && MovDelay[x][y]) - SetDrawtoField(DRAW_BUFFERED); + if (setup.direct_draw && MovDelay[x][y]) + SetDrawtoField(DRAW_BUFFERED); -#if 0 - DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0); -#else - DrawLevelElementAnimation(x, y, Feld[x][y]); -#endif + DrawLevelElementAnimation(x, y, Feld[x][y]); - if (MovDelay[x][y] != 0) - { - int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE, - 10 - MovDelay[x][y]); + if (MovDelay[x][y] != 0) + { + int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE, + 10 - MovDelay[x][y]); - DrawGraphicThruMask(SCREENX(x), SCREENY(y), IMG_TWINKLE_WHITE, frame); + DrawGraphicThruMask(SCREENX(x), SCREENY(y), IMG_TWINKLE_WHITE, frame); - if (setup.direct_draw) - { - int dest_x, dest_y; + if (setup.direct_draw) + { + int dest_x, dest_y; - dest_x = FX + SCREENX(x) * TILEX; - dest_y = FY + SCREENY(y) * TILEY; + dest_x = FX + SCREENX(x) * TILEX; + dest_y = FY + SCREENY(y) * TILEY; - BlitBitmap(drawto_field, window, - dest_x, dest_y, TILEX, TILEY, dest_x, dest_y); - SetDrawtoField(DRAW_DIRECT); - } + BlitBitmap(drawto_field, window, + dest_x, dest_y, TILEX, TILEY, dest_x, dest_y); + SetDrawtoField(DRAW_DIRECT); } } } @@ -4550,22 +4589,22 @@ void MauerWaechst(int x, int y) { if (MovDir[x][y] == MV_LEFT) { - if (IN_LEV_FIELD(x - 1, y) && IS_MAUER(Feld[x - 1][y])) + if (IN_LEV_FIELD(x - 1, y) && IS_WALL(Feld[x - 1][y])) DrawLevelField(x - 1, y); } else if (MovDir[x][y] == MV_RIGHT) { - if (IN_LEV_FIELD(x + 1, y) && IS_MAUER(Feld[x + 1][y])) + if (IN_LEV_FIELD(x + 1, y) && IS_WALL(Feld[x + 1][y])) DrawLevelField(x + 1, y); } else if (MovDir[x][y] == MV_UP) { - if (IN_LEV_FIELD(x, y - 1) && IS_MAUER(Feld[x][y - 1])) + if (IN_LEV_FIELD(x, y - 1) && IS_WALL(Feld[x][y - 1])) DrawLevelField(x, y - 1); } else { - if (IN_LEV_FIELD(x, y + 1) && IS_MAUER(Feld[x][y + 1])) + if (IN_LEV_FIELD(x, y + 1) && IS_WALL(Feld[x][y + 1])) DrawLevelField(x, y + 1); } @@ -4580,12 +4619,16 @@ void MauerWaechst(int x, int y) void MauerAbleger(int ax, int ay) { int element = Feld[ax][ay]; + int graphic = el2img(element); boolean oben_frei = FALSE, unten_frei = FALSE; boolean links_frei = FALSE, rechts_frei = FALSE; boolean oben_massiv = FALSE, unten_massiv = FALSE; boolean links_massiv = FALSE, rechts_massiv = FALSE; boolean new_wall = FALSE; + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic); + if (!MovDelay[ax][ay]) /* start building new wall */ MovDelay[ax][ay] = 6; @@ -4605,76 +4648,83 @@ void MauerAbleger(int ax, int ay) if (IN_LEV_FIELD(ax+1, ay) && IS_FREE(ax+1, ay)) rechts_frei = TRUE; - if (element == EL_WALL_GROWING_Y || element == EL_WALL_GROWING_XY) + if (element == EL_EXPANDABLE_WALL_VERTICAL || + element == EL_EXPANDABLE_WALL_ANY) { if (oben_frei) { - Feld[ax][ay-1] = EL_WALL_GROWING_ACTIVE; + Feld[ax][ay-1] = EL_EXPANDABLE_WALL_GROWING; Store[ax][ay-1] = element; MovDir[ax][ay-1] = MV_UP; if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay-1))) DrawGraphic(SCREENX(ax), SCREENY(ay - 1), - IMG_WALL_GROWING_ACTIVE_UP, 0); + IMG_EXPANDABLE_WALL_GROWING_UP, 0); new_wall = TRUE; } if (unten_frei) { - Feld[ax][ay+1] = EL_WALL_GROWING_ACTIVE; + Feld[ax][ay+1] = EL_EXPANDABLE_WALL_GROWING; Store[ax][ay+1] = element; MovDir[ax][ay+1] = MV_DOWN; if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay+1))) DrawGraphic(SCREENX(ax), SCREENY(ay + 1), - IMG_WALL_GROWING_ACTIVE_DOWN, 0); + IMG_EXPANDABLE_WALL_GROWING_DOWN, 0); new_wall = TRUE; } } - if (element == EL_WALL_GROWING_X || element == EL_WALL_GROWING_XY || - element == EL_WALL_GROWING) + if (element == EL_EXPANDABLE_WALL_HORIZONTAL || + element == EL_EXPANDABLE_WALL_ANY || + element == EL_EXPANDABLE_WALL) { if (links_frei) { - Feld[ax-1][ay] = EL_WALL_GROWING_ACTIVE; + Feld[ax-1][ay] = EL_EXPANDABLE_WALL_GROWING; Store[ax-1][ay] = element; MovDir[ax-1][ay] = MV_LEFT; if (IN_SCR_FIELD(SCREENX(ax-1), SCREENY(ay))) DrawGraphic(SCREENX(ax - 1), SCREENY(ay), - IMG_WALL_GROWING_ACTIVE_LEFT, 0); + IMG_EXPANDABLE_WALL_GROWING_LEFT, 0); new_wall = TRUE; } if (rechts_frei) { - Feld[ax+1][ay] = EL_WALL_GROWING_ACTIVE; + Feld[ax+1][ay] = EL_EXPANDABLE_WALL_GROWING; Store[ax+1][ay] = element; MovDir[ax+1][ay] = MV_RIGHT; if (IN_SCR_FIELD(SCREENX(ax+1), SCREENY(ay))) DrawGraphic(SCREENX(ax + 1), SCREENY(ay), - IMG_WALL_GROWING_ACTIVE_RIGHT, 0); + IMG_EXPANDABLE_WALL_GROWING_RIGHT, 0); new_wall = TRUE; } } - if (element == EL_WALL_GROWING && (links_frei || rechts_frei)) + if (element == EL_EXPANDABLE_WALL && (links_frei || rechts_frei)) DrawLevelField(ax, ay); - if (!IN_LEV_FIELD(ax, ay-1) || IS_MAUER(Feld[ax][ay-1])) + if (!IN_LEV_FIELD(ax, ay-1) || IS_WALL(Feld[ax][ay-1])) oben_massiv = TRUE; - if (!IN_LEV_FIELD(ax, ay+1) || IS_MAUER(Feld[ax][ay+1])) + if (!IN_LEV_FIELD(ax, ay+1) || IS_WALL(Feld[ax][ay+1])) unten_massiv = TRUE; - if (!IN_LEV_FIELD(ax-1, ay) || IS_MAUER(Feld[ax-1][ay])) + if (!IN_LEV_FIELD(ax-1, ay) || IS_WALL(Feld[ax-1][ay])) links_massiv = TRUE; - if (!IN_LEV_FIELD(ax+1, ay) || IS_MAUER(Feld[ax+1][ay])) + if (!IN_LEV_FIELD(ax+1, ay) || IS_WALL(Feld[ax+1][ay])) rechts_massiv = TRUE; if (((oben_massiv && unten_massiv) || - element == EL_WALL_GROWING_X || element == EL_WALL_GROWING) && + element == EL_EXPANDABLE_WALL_HORIZONTAL || + element == EL_EXPANDABLE_WALL) && ((links_massiv && rechts_massiv) || - element == EL_WALL_GROWING_Y)) + element == EL_EXPANDABLE_WALL_VERTICAL)) Feld[ax][ay] = EL_WALL; if (new_wall) - PlaySoundLevel(ax, ay, SND_WALL_GROWING); +#if 1 + PlaySoundLevelAction(ax, ay, ACTION_GROWING); +#else + PlaySoundLevel(ax, ay, SND_EXPANDABLE_WALL_GROWING); +#endif } void CheckForDragon(int x, int y) @@ -4731,7 +4781,7 @@ static void InitBuggyBase(int x, int y) int element = Feld[x][y]; int activating_delay = FRAMES_PER_SECOND / 4; - MovDelay[x][y] = + ChangeDelay[x][y] = (element == EL_SP_BUGGY_BASE ? 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND) - activating_delay : element == EL_SP_BUGGY_BASE_ACTIVATING ? @@ -4764,82 +4814,9 @@ static void WarnBuggyBase(int x, int y) } } -#if 0 -static void CheckBuggyBase(int x, int y) -{ - int element = Feld[x][y]; - - if (element == EL_SP_BUGGY_BASE) - { - if (MovDelay[x][y] == 0) /* wait some time before activating base */ - { - GfxFrame[x][y] = 0; - - InitBuggyBase(x, y); - } - - MovDelay[x][y]--; - - if (MovDelay[x][y] != 0) - { - DrawLevelElementAnimation(x, y, element); - } - else - { - Feld[x][y] = EL_SP_BUGGY_BASE_ACTIVATING; - DrawLevelField(x, y); - } - } - else if (element == EL_SP_BUGGY_BASE_ACTIVATING) - { - if (MovDelay[x][y] == 0) /* display activation warning of buggy base */ - { - GfxFrame[x][y] = 0; - - InitBuggyBase(x, y); - } - - MovDelay[x][y]--; - - if (MovDelay[x][y] != 0) - { - DrawLevelElementAnimation(x, y, element); - } - else - { - Feld[x][y] = EL_SP_BUGGY_BASE_ACTIVE; - DrawLevelField(x, y); - } - } - else if (element == EL_SP_BUGGY_BASE_ACTIVE) - { - if (MovDelay[x][y] == 0) /* start activating buggy base */ - { - GfxFrame[x][y] = 0; - - InitBuggyBase(x, y); - } - - MovDelay[x][y]--; - - if (MovDelay[x][y] != 0) - { - DrawLevelElementAnimation(x, y, element); - - WarnBuggyBase(x, y); - } - else - { - Feld[x][y] = EL_SP_BUGGY_BASE; - DrawLevelField(x, y); - } - } -} -#endif - static void InitTrap(int x, int y) { - MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); + ChangeDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); } static void ActivateTrap(int x, int y) @@ -4851,107 +4828,144 @@ static void ChangeActiveTrap(int x, int y) { int graphic = IMG_TRAP_ACTIVE; - /* if animation frame already drawn, correct crumbled sand border */ - if (IS_ANIMATED(graphic)) - if (checkDrawLevelGraphicAnimation(x, y, graphic)) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); + /* if new animation frame was drawn, correct crumbled sand border */ + if (IS_NEW_FRAME(GfxFrame[x][y], graphic)) + DrawLevelFieldCrumbledSand(x, y); } -#if 0 -static void CheckTrap(int x, int y) +static void ChangeElementDoIt(int x, int y, int element) { - int element = Feld[x][y]; + RemoveField(x, y); + Feld[x][y] = element; - if (element == EL_TRAP) - { - if (MovDelay[x][y] == 0) /* wait some time before activating trap */ - MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); + ResetGfxAnimation(x, y); + ResetRandomAnimationValue(x, y); - MovDelay[x][y]--; + InitField(x, y, FALSE); + if (CAN_MOVE(Feld[x][y])) + InitMovDir(x, y); - if (MovDelay[x][y] != 0) - { - /* do nothing while waiting */ - } - else - { - Feld[x][y] = EL_TRAP_ACTIVE; - PlaySoundLevel(x, y, SND_TRAP_ACTIVATING); - } - } - else if (element == EL_TRAP_ACTIVE) + DrawLevelField(x, y); + + if (CAN_BE_CRUMBLED(Feld[x][y])) { - int delay = 4; - int num_frames = 8; + int sx = SCREENX(x), sy = SCREENY(y); + static int xy[4][2] = + { + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } + }; + int i; - if (MovDelay[x][y] == 0) /* start activating trap */ + for(i=0; i<4; i++) { - MovDelay[x][y] = num_frames * delay; - GfxFrame[x][y] = 0; - } + int xx = x + xy[i][0]; + int yy = y + xy[i][1]; + int sxx = sx + xy[i][0]; + int syy = sy + xy[i][1]; - MovDelay[x][y]--; + if (!IN_LEV_FIELD(xx, yy) || + !IN_SCR_FIELD(sxx, syy) || + !CAN_BE_CRUMBLED(Feld[xx][yy]) || + IS_MOVING(xx, yy)) + continue; - if (MovDelay[x][y] != 0) - { - if (DrawLevelElementAnimation(x, y, element)) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); - } - else - { - Feld[x][y] = EL_TRAP; - DrawLevelField(x, y); + DrawLevelField(xx, yy); } } } -#endif -#if 0 -static void DrawBeltAnimation(int x, int y, int element) +static void ChangeElement(int x, int y) { - int belt_nr = getBeltNrFromBeltActiveElement(element); - int belt_dir = game.belt_dir[belt_nr]; + int element = Feld[x][y]; - if (belt_dir != MV_NO_MOVING) + if (ChangeDelay[x][y] == 0) /* initialize element change */ { - DrawLevelElementAnimation(x, y, element); + ChangeDelay[x][y] = changing_element[element].change_delay + 1; - if (!(FrameCounter % 2)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); - } -} -#endif + if (IS_CUSTOM_ELEMENT(element) && HAS_CHANGE_EVENT(element, CE_DELAY)) + { + int max_random_delay = element_info[element].change.delay_random; + int delay_frames = element_info[element].change.delay_frames; -static void ChangeElement(int x, int y) -{ - int element = Feld[x][y]; + ChangeDelay[x][y] += RND(max_random_delay * delay_frames); + } - if (MovDelay[x][y] == 0) /* initialize element change */ - { - MovDelay[x][y] = changing_element[element].change_delay + 1; - GfxFrame[x][y] = 0; + ResetGfxAnimation(x, y); + ResetRandomAnimationValue(x, y); if (changing_element[element].pre_change_function) changing_element[element].pre_change_function(x, y); } - MovDelay[x][y]--; + ChangeDelay[x][y]--; - if (MovDelay[x][y] != 0) /* continue element change */ + if (ChangeDelay[x][y] != 0) /* continue element change */ { - if (IS_ANIMATED(el2img(element))) - DrawLevelElementAnimation(x, y, element); + int graphic = el_act_dir2img(element, GfxAction[x][y], MovDir[x][y]); + + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); if (changing_element[element].change_function) changing_element[element].change_function(x, y); } else /* finish element change */ { + if (IS_MOVING(x, y)) /* never change a running system ;-) */ + { + ChangeDelay[x][y] = 1; /* try change after next move step */ + + return; + } + +#if 1 + ChangeElementDoIt(x, y, changing_element[element].next_element); +#else + RemoveField(x, y); Feld[x][y] = changing_element[element].next_element; - GfxFrame[x][y] = 0; + + ResetGfxAnimation(x, y); + ResetRandomAnimationValue(x, y); + + InitField(x, y, FALSE); + if (CAN_MOVE(Feld[x][y])) + InitMovDir(x, y); DrawLevelField(x, y); + if (CAN_BE_CRUMBLED(Feld[x][y])) + { + int sx = SCREENX(x), sy = SCREENY(y); + static int xy[4][2] = + { + { 0, -1 }, + { -1, 0 }, + { +1, 0 }, + { 0, +1 } + }; + int i; + + for(i=0; i<4; i++) + { + int xx = x + xy[i][0]; + int yy = y + xy[i][1]; + int sxx = sx + xy[i][0]; + int syy = sy + xy[i][1]; + + if (!IN_LEV_FIELD(xx, yy) || + !IN_SCR_FIELD(sxx, syy) || + !CAN_BE_CRUMBLED(Feld[xx][yy]) || + IS_MOVING(xx, yy)) + continue; + + DrawLevelField(xx, yy); + } + } +#endif + if (changing_element[element].post_change_function) changing_element[element].post_change_function(x, y); } @@ -4961,9 +4975,6 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) { static byte stored_player_action[MAX_PLAYERS]; static int num_stored_actions = 0; -#if 0 - static boolean save_tape_entry = FALSE; -#endif boolean moved = FALSE, snapped = FALSE, bombed = FALSE; int left = player_action & JOY_LEFT; int right = player_action & JOY_RIGHT; @@ -4982,11 +4993,6 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) if (player_action) { -#if 0 - save_tape_entry = TRUE; -#endif - player->frame_reset_delay = 0; - if (button1) snapped = SnapField(player, dx, dy); else @@ -5005,20 +5011,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) } } -#if 0 - if (tape.recording && (moved || snapped || bombed)) - { - if (bombed && !moved) - player_action &= JOY_BUTTON; - - stored_player_action[player->index_nr] = player_action; - save_tape_entry = TRUE; - } - else if (tape.playing && snapped) - SnapField(player, 0, 0); /* stop snapping */ -#else stored_player_action[player->index_nr] = player_action; -#endif } else { @@ -5028,86 +5021,36 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) SnapField(player, 0, 0); CheckGravityMovement(player); -#if 1 - if (player->MovPos == 0) /* needed for tape.playing */ - player->is_moving = FALSE; -#endif + if (player->MovPos == 0) + { #if 0 - if (player->MovPos == 0) /* needed for tape.playing */ - player->last_move_dir = MV_NO_MOVING; - - /* !!! CHECK THIS AGAIN !!! - (Seems to be needed for some EL_ROBOT stuff, but breaks - tapes when walking through pipes!) - */ + printf("Trying... Player frame reset\n"); +#endif - /* it seems that "player->last_move_dir" is misused as some sort of - "player->is_just_moving_in_this_moment", which is needed for the - robot stuff (robots don't kill players when they are moving) - */ -#endif + InitPlayerGfxAnimation(player, ACTION_DEFAULT, player->MovDir); + } - /* if the player does not move for some time, reset animation to start */ - if (++player->frame_reset_delay > player->move_delay_value) - player->Frame = 0; + if (player->MovPos == 0) /* needed for tape.playing */ + player->is_moving = FALSE; } -#if 0 - if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry) - { - TapeRecordAction(stored_player_action); - num_stored_actions = 0; - save_tape_entry = FALSE; - } -#else if (tape.recording && num_stored_actions >= MAX_PLAYERS) { TapeRecordAction(stored_player_action); num_stored_actions = 0; } -#endif - -#if 0 - if (tape.playing && !tape.pausing && !player_action && - tape.counter < tape.length) - { - int jx = player->jx, jy = player->jy; - int next_joy = - tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT); - - if ((next_joy == JOY_LEFT || next_joy == JOY_RIGHT) && - (player->MovDir != JOY_UP && player->MovDir != JOY_DOWN)) - { - int dx = (next_joy == JOY_LEFT ? -1 : +1); - - if (IN_LEV_FIELD(jx+dx, jy) && IS_PUSHABLE(Feld[jx+dx][jy])) - { - int el = Feld[jx+dx][jy]; - int push_delay = (IS_SB_ELEMENT(el) || el == EL_SATELLITE ? 2 : - (el == EL_BALLOON || el == EL_SPRING) ? 0 : 10); - - if (tape.delay_played + push_delay >= tape.pos[tape.counter].delay) - { - player->MovDir = next_joy; - player->Frame = FrameCounter % 4; - player->Pushing = TRUE; - } - } - } - } -#endif } void GameActions() { static unsigned long action_delay = 0; unsigned long action_delay_value; - int sieb_x = 0, sieb_y = 0; + int magic_wall_x = 0, magic_wall_y = 0; int i, x, y, element, graphic; byte *recorded_player_action; byte summarized_player_action = 0; - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; action_delay_value = @@ -5133,7 +5076,7 @@ void GameActions() HandleNetworking(); #endif - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; if (!network_player_action_received) @@ -5186,30 +5129,14 @@ void GameActions() ScrollScreen(NULL, SCROLL_GO_ON); - - -#ifdef DEBUG #if 0 - if (TimeFrames == 0 && local_player->active) - { - extern unsigned int last_RND(); - - printf("DEBUG: %03d last RND was %d \t [state checksum is %d]\n", - TimePlayed, last_RND(), getStateCheckSum(TimePlayed)); - } -#endif -#endif - -#ifdef DEBUG -#if 0 - if (GameFrameDelay >= 500) - printf("FrameCounter == %d\n", FrameCounter); -#endif -#endif - FrameCounter++; TimeFrames++; + for (i=0; ijx, jy = local_player->jy; - if (element == EL_MAGIC_WALL_FULL || - element == EL_MAGIC_WALL_ACTIVE || - element == EL_MAGIC_WALL_EMPTYING) - { - SiebAktivieren(x, y, 1); - sieb = TRUE; - } - else if (element == EL_BD_MAGIC_WALL_FULL || - element == EL_BD_MAGIC_WALL_ACTIVE || - element == EL_BD_MAGIC_WALL_EMPTYING) - { - SiebAktivieren(x, y, 2); - sieb = TRUE; - } - /* play the element sound at the position nearest to the player */ - if (sieb && ABS(x-jx)+ABS(y-jy) < ABS(sieb_x-jx)+ABS(sieb_y-jy)) + if ((element == EL_MAGIC_WALL_FULL || + element == EL_MAGIC_WALL_ACTIVE || + element == EL_MAGIC_WALL_EMPTYING || + element == EL_BD_MAGIC_WALL_FULL || + element == EL_BD_MAGIC_WALL_ACTIVE || + element == EL_BD_MAGIC_WALL_EMPTYING) && + ABS(x-jx) + ABS(y-jy) < ABS(magic_wall_x-jx) + ABS(magic_wall_y-jy)) { - sieb_x = x; - sieb_y = y; + magic_wall_x = x; + magic_wall_y = y; } } } @@ -5460,14 +5387,14 @@ void GameActions() { if (!(game.magic_wall_time_left % 4)) { - int element = Feld[sieb_x][sieb_y]; + int element = Feld[magic_wall_x][magic_wall_y]; if (element == EL_BD_MAGIC_WALL_FULL || element == EL_BD_MAGIC_WALL_ACTIVE || element == EL_BD_MAGIC_WALL_EMPTYING) - PlaySoundLevel(sieb_x, sieb_y, SND_BD_MAGIC_WALL_ACTIVE); + PlaySoundLevel(magic_wall_x, magic_wall_y, SND_BD_MAGIC_WALL_ACTIVE); else - PlaySoundLevel(sieb_x, sieb_y, SND_MAGIC_WALL_ACTIVE); + PlaySoundLevel(magic_wall_x, magic_wall_y, SND_MAGIC_WALL_ACTIVE); } if (game.magic_wall_time_left > 0) @@ -5553,16 +5480,16 @@ void GameActions() TimeLeft--; if (TimeLeft <= 10 && setup.time_limit) - PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE); - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); if (!TimeLeft && setup.time_limit) for (i=0; iprogrammed_action = MV_DOWN; } } +/* + MoveFigureOneStep() + ----------------------------------------------------------------------------- + dx, dy: direction (non-diagonal) to try to move the player to + real_dx, real_dy: direction as read from input device (can be diagonal) +*/ + boolean MoveFigureOneStep(struct PlayerInfo *player, int dx, int dy, int real_dx, int real_dy) { @@ -5712,12 +5673,12 @@ boolean MoveFigureOneStep(struct PlayerInfo *player, element = MovingOrBlocked2ElementIfNotLeaving(new_jx, new_jy); #endif - if (DONT_GO_TO(element)) + if (DONT_RUN_INTO(element)) { if (element == EL_ACID && dx == 0 && dy == 1) { - Blurb(jx, jy); - Feld[jx][jy] = EL_PLAYER1; + SplashAcid(jx, jy); + Feld[jx][jy] = EL_PLAYER_1; InitMovingField(jx, jy, MV_DOWN); Store[jx][jy] = EL_ACID; ContinueMoving(jx, jy); @@ -5880,15 +5841,17 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) } } - if (!(moved & MF_MOVING) && !player->Pushing) - player->Frame = 0; - else #if 0 - player->Frame = (player->Frame + 1) % 4; +#if 1 + InitPlayerGfxAnimation(player, ACTION_DEFAULT); #else - player->Frame += 1 * 0; + if (!(moved & MF_MOVING) && !player->Pushing) + player->Frame = 0; +#endif #endif + player->StepFrame = 0; + if (moved & MF_MOVING) { if (old_jx != jx && old_jy == jy) @@ -5896,7 +5859,7 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) else if (old_jx == jx && old_jy != jy) player->MovDir = (old_jy < jy ? MV_DOWN : MV_UP); - DrawLevelField(jx, jy); /* for "DrawCrumbledSand()" */ + DrawLevelField(jx, jy); /* for "crumbled sand" */ player->last_move_dir = player->MovDir; player->is_moving = TRUE; @@ -5932,8 +5895,6 @@ void ScrollFigure(struct PlayerInfo *player, int mode) { player->actual_frame_counter = FrameCounter; player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); - if (player->Frame) - player->Frame += 1; if (Feld[last_jx][last_jy] == EL_EMPTY) Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING; @@ -5946,7 +5907,6 @@ void ScrollFigure(struct PlayerInfo *player, int mode) player->MovPos += (player->MovPos > 0 ? -1 : 1) * move_stepsize; player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); - player->Frame += 1; if (Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING) Feld[last_jx][last_jy] = EL_EMPTY; @@ -5959,7 +5919,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) if (player->MovPos == 0) { - if (IS_QUICK_GATE(Feld[last_jx][last_jy])) + if (IS_PASSABLE(Feld[last_jx][last_jy])) { /* continue with normal speed after quickly moving through gate */ HALVE_PLAYER_SPEED(player); @@ -6051,11 +6011,11 @@ void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir) test_element = MovingOrBlocked2ElementIfNotLeaving(test_x, test_y); #endif - /* 1st case: good thing is moving towards DONT_GO_TO style bad thing; + /* 1st case: good thing is moving towards DONT_RUN_INTO style bad thing; 2nd case: DONT_TOUCH style bad thing does not move away from good thing */ - if ((DONT_GO_TO(test_element) && good_move_dir == test_dir[i]) || - (DONT_TOUCH(test_element) && test_move_dir != test_dir[i])) + if ((DONT_RUN_INTO(test_element) && good_move_dir == test_dir[i]) || + (DONT_TOUCH(test_element) && test_move_dir != test_dir[i])) { kill_x = test_x; kill_y = test_y; @@ -6115,11 +6075,11 @@ void TestIfBadThingHitsGoodThing(int bad_x, int bad_y, int bad_move_dir) test_element = Feld[test_x][test_y]; - /* 1st case: good thing is moving towards DONT_GO_TO style bad thing; + /* 1st case: good thing is moving towards DONT_RUN_INTO style bad thing; 2nd case: DONT_TOUCH style bad thing does not move away from good thing */ - if ((DONT_GO_TO(bad_element) && bad_move_dir == test_dir[i]) || - (DONT_TOUCH(bad_element) && test_move_dir != test_dir[i])) + if ((DONT_RUN_INTO(bad_element) && bad_move_dir == test_dir[i]) || + (DONT_TOUCH(bad_element) && test_move_dir != test_dir[i])) { /* good thing is player or penguin that does not move away */ if (IS_PLAYER(test_x, test_y)) @@ -6227,8 +6187,8 @@ void TestIfBadThingTouchesOtherBadThing(int bad_x, int bad_y) continue; element = Feld[x][y]; - if (IS_AMOEBOID(element) || element == EL_GAMEOFLIFE || - element == EL_AMOEBA_CREATING || element == EL_AMOEBA_DROP) + if (IS_AMOEBOID(element) || element == EL_GAME_OF_LIFE || + element == EL_AMOEBA_GROWING || element == EL_AMOEBA_DROP) { kill_x = x; kill_y = y; @@ -6247,8 +6207,8 @@ void KillHero(struct PlayerInfo *player) if (!player->active) return; - if (IS_PFORTE(Feld[jx][jy])) - Feld[jx][jy] = EL_EMPTY; + /* remove accessible field at the player's position */ + Feld[jx][jy] = EL_EMPTY; /* deactivate shield (else Bang()/Explode() would not work right) */ player->shield_normal_time_left = 0; @@ -6271,7 +6231,11 @@ void BuryHero(struct PlayerInfo *player) if (!player->active) return; - PlaySoundLevel(jx, jy, SND_PLAYER_DYING); +#if 1 + PlaySoundLevelElementAction(jx, jy, player->element_nr, ACTION_DYING); +#else + PlaySoundLevel(jx, jy, SND_CLASS_PLAYER_DYING); +#endif PlaySoundLevel(jx, jy, SND_GAME_LOSING); player->GameOver = TRUE; @@ -6300,6 +6264,39 @@ void RemoveHero(struct PlayerInfo *player) ExitY = ZY = jy; } +/* + checkDiagonalPushing() + ----------------------------------------------------------------------------- + check if diagonal input device direction results in pushing of object + (by checking if the alternative direction is walkable, diggable, ...) +*/ + +static boolean checkDiagonalPushing(struct PlayerInfo *player, + int x, int y, int real_dx, int real_dy) +{ + int jx, jy, dx, dy, xx, yy; + + if (real_dx == 0 || real_dy == 0) /* no diagonal direction => push */ + return TRUE; + + /* diagonal direction: check alternative direction */ + jx = player->jx; + jy = player->jy; + dx = x - jx; + dy = y - jy; + xx = jx + (dx == 0 ? real_dx : 0); + yy = jy + (dy == 0 ? real_dy : 0); + + return (!IN_LEV_FIELD(xx, yy) || IS_SOLID_FOR_PUSHING(Feld[xx][yy])); +} + +/* + DigField() + ----------------------------------------------------------------------------- + x, y: field next to player (non-diagonal) to try to dig to + real_dx, real_dy: direction as read from input device (can be diagonal) +*/ + int DigField(struct PlayerInfo *player, int x, int y, int real_dx, int real_dy, int mode) { @@ -6312,24 +6309,37 @@ int DigField(struct PlayerInfo *player, int element; if (player->MovPos == 0) + { + player->is_digging = FALSE; + player->is_collecting = FALSE; + } + + if (player->MovPos == 0) /* last pushing move finished */ player->Pushing = FALSE; - if (mode == DF_NO_PUSH) + if (mode == DF_NO_PUSH) /* player just stopped pushing */ { player->Switching = FALSE; player->push_delay = 0; + return MF_NO_ACTION; } if (IS_MOVING(x, y) || IS_PLAYER(x, y)) return MF_NO_ACTION; - if (IS_TUBE(Feld[jx][jy])) +#if 0 + if (IS_TUBE(Feld[jx][jy]) || IS_TUBE(Back[jx][jy])) +#else + if (IS_TUBE(Feld[jx][jy]) || + (IS_TUBE(Back[jx][jy]) && game.engine_version >= VERSION_IDENT(2,2,0))) +#endif { int i = 0; + int tube_element = (IS_TUBE(Feld[jx][jy]) ? Feld[jx][jy] : Back[jx][jy]); int tube_leave_directions[][2] = { - { EL_TUBE_ALL, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, + { EL_TUBE_ANY, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, { EL_TUBE_VERTICAL, MV_UP | MV_DOWN }, { EL_TUBE_HORIZONTAL, MV_LEFT | MV_RIGHT }, { EL_TUBE_VERTICAL_LEFT, MV_LEFT | MV_UP | MV_DOWN }, @@ -6343,7 +6353,7 @@ int DigField(struct PlayerInfo *player, { -1, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN } }; - while (tube_leave_directions[i][0] != Feld[jx][jy]) + while (tube_leave_directions[i][0] != tube_element) { i++; if (tube_leave_directions[i][0] == -1) /* should not happen */ @@ -6356,6 +6366,12 @@ int DigField(struct PlayerInfo *player, element = Feld[x][y]; +#if 1 + if (mode == DF_SNAP && !IS_SNAPPABLE(element) && + game.engine_version >= VERSION_IDENT(2,2,0)) + return MF_NO_ACTION; +#endif + switch (element) { case EL_EMPTY: @@ -6367,7 +6383,14 @@ int DigField(struct PlayerInfo *player, case EL_SP_BUGGY_BASE: case EL_SP_BUGGY_BASE_ACTIVATING: RemoveField(x, y); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_DIGGING); +#if 1 + if (mode != DF_SNAP && element != EL_EMPTY) + { + GfxElement[x][y] = (CAN_BE_CRUMBLED(element) ? EL_SAND : element); + player->is_digging = TRUE; + } +#endif + PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING); break; case EL_EMERALD: @@ -6380,6 +6403,13 @@ int DigField(struct PlayerInfo *player, case EL_PEARL: case EL_CRYSTAL: RemoveField(x, y); +#if 1 + if (mode != DF_SNAP) + { + GfxElement[x][y] = element; + player->is_collecting = TRUE; + } +#endif local_player->gems_still_needed -= (element == EL_DIAMOND ? 3 : element == EL_PEARL ? 5 : element == EL_CRYSTAL ? 8 : 1); @@ -6387,9 +6417,8 @@ int DigField(struct PlayerInfo *player, local_player->gems_still_needed = 0; RaiseScoreElement(element); DrawText(DX_EMERALDS, DY_EMERALDS, - int2str(local_player->gems_still_needed, 3), - FS_SMALL, FC_YELLOW); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); + int2str(local_player->gems_still_needed, 3), FONT_TEXT_2); + PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING); break; case EL_SPEED_PILL: @@ -6408,9 +6437,9 @@ int DigField(struct PlayerInfo *player, if (level.time > 0) { TimeLeft += 10; - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); } - PlaySoundStereo(SND_EXTRA_TIME_COLLECTING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_EXTRA_TIME_COLLECTING, SOUND_MIDDLE); break; case EL_SHIELD_NORMAL: @@ -6430,68 +6459,70 @@ int DigField(struct PlayerInfo *player, case EL_SP_DISK_RED: RemoveField(x, y); player->dynamite++; + player->use_disk_red_graphic = (element == EL_SP_DISK_RED); RaiseScoreElement(EL_DYNAMITE); - DrawText(DX_DYNAMITE, DY_DYNAMITE, - int2str(local_player->dynamite, 3), - FS_SMALL, FC_YELLOW); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); + DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), + FONT_TEXT_2); + PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING); break; - case EL_DYNABOMB_NR: + case EL_DYNABOMB_INCREASE_NUMBER: RemoveField(x, y); player->dynabomb_count++; player->dynabombs_left++; RaiseScoreElement(EL_DYNAMITE); - PlaySoundLevel(x, y, SND_DYNABOMB_NR_COLLECTING); + PlaySoundLevel(x, y, SND_DYNABOMB_INCREASE_NUMBER_COLLECTING); break; - case EL_DYNABOMB_SZ: + case EL_DYNABOMB_INCREASE_SIZE: RemoveField(x, y); player->dynabomb_size++; RaiseScoreElement(EL_DYNAMITE); - PlaySoundLevel(x, y, SND_DYNABOMB_SZ_COLLECTING); + PlaySoundLevel(x, y, SND_DYNABOMB_INCREASE_SIZE_COLLECTING); break; - case EL_DYNABOMB_XL: + case EL_DYNABOMB_INCREASE_POWER: RemoveField(x, y); player->dynabomb_xl = TRUE; RaiseScoreElement(EL_DYNAMITE); - PlaySoundLevel(x, y, SND_DYNABOMB_XL_COLLECTING); + PlaySoundLevel(x, y, SND_DYNABOMB_INCREASE_POWER_COLLECTING); break; - case EL_KEY1: - case EL_KEY2: - case EL_KEY3: - case EL_KEY4: + case EL_KEY_1: + case EL_KEY_2: + case EL_KEY_3: + case EL_KEY_4: { - int key_nr = element - EL_KEY1; + int key_nr = element - EL_KEY_1; + int graphic = el2edimg(element); RemoveField(x, y); player->key[key_nr] = TRUE; RaiseScoreElement(element); DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); + graphic); DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); - PlaySoundLevel(x, y, SND_KEY_COLLECTING); + graphic); + PlaySoundLevel(x, y, SND_CLASS_KEY_COLLECTING); break; } - case EL_EM_KEY1: - case EL_EM_KEY2: - case EL_EM_KEY3: - case EL_EM_KEY4: + case EL_EM_KEY_1: + case EL_EM_KEY_2: + case EL_EM_KEY_3: + case EL_EM_KEY_4: { - int key_nr = element - EL_EM_KEY1; + int key_nr = element - EL_EM_KEY_1; + int graphic = el2edimg(EL_KEY_1 + key_nr); RemoveField(x, y); player->key[key_nr] = TRUE; RaiseScoreElement(element); DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); + graphic); DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); - PlaySoundLevel(x, y, SND_KEY_COLLECTING); + graphic); + PlaySoundLevel(x, y, SND_CLASS_KEY_COLLECTING); break; } @@ -6525,23 +6556,23 @@ int DigField(struct PlayerInfo *player, } break; - case EL_CONVEYOR_BELT1_SWITCH_LEFT: - case EL_CONVEYOR_BELT1_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT1_SWITCH_RIGHT: - case EL_CONVEYOR_BELT2_SWITCH_LEFT: - case EL_CONVEYOR_BELT2_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT2_SWITCH_RIGHT: - case EL_CONVEYOR_BELT3_SWITCH_LEFT: - case EL_CONVEYOR_BELT3_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT3_SWITCH_RIGHT: - case EL_CONVEYOR_BELT4_SWITCH_LEFT: - case EL_CONVEYOR_BELT4_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT4_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_1_SWITCH_LEFT: + case EL_CONVEYOR_BELT_1_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_1_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_2_SWITCH_LEFT: + case EL_CONVEYOR_BELT_2_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_2_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_3_SWITCH_LEFT: + case EL_CONVEYOR_BELT_3_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_3_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_4_SWITCH_LEFT: + case EL_CONVEYOR_BELT_4_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_4_SWITCH_RIGHT: if (!player->Switching) { player->Switching = TRUE; ToggleBeltSwitch(x, y); - PlaySoundLevel(x, y, SND_CONVEYOR_BELT_SWITCH_ACTIVATING); + PlaySoundLevel(x, y, SND_CLASS_CONVEYOR_BELT_SWITCH_ACTIVATING); } return MF_ACTION; break; @@ -6552,7 +6583,7 @@ int DigField(struct PlayerInfo *player, { player->Switching = TRUE; ToggleSwitchgateSwitch(x, y); - PlaySoundLevel(x, y, SND_SWITCHGATE_SWITCH_ACTIVATING); + PlaySoundLevel(x, y, SND_CLASS_SWITCHGATE_SWITCH_ACTIVATING); } return MF_ACTION; break; @@ -6577,20 +6608,20 @@ int DigField(struct PlayerInfo *player, return MF_ACTION; break; - case EL_BALLOON_SEND_LEFT: - case EL_BALLOON_SEND_RIGHT: - case EL_BALLOON_SEND_UP: - case EL_BALLOON_SEND_DOWN: - case EL_BALLOON_SEND_ANY_DIRECTION: - if (element == EL_BALLOON_SEND_ANY_DIRECTION) + case EL_BALLOON_SWITCH_LEFT: + case EL_BALLOON_SWITCH_RIGHT: + case EL_BALLOON_SWITCH_UP: + case EL_BALLOON_SWITCH_DOWN: + case EL_BALLOON_SWITCH_ANY: + if (element == EL_BALLOON_SWITCH_ANY) game.balloon_dir = move_direction; else - game.balloon_dir = (element == EL_BALLOON_SEND_LEFT ? MV_LEFT : - element == EL_BALLOON_SEND_RIGHT ? MV_RIGHT : - element == EL_BALLOON_SEND_UP ? MV_UP : - element == EL_BALLOON_SEND_DOWN ? MV_DOWN : + game.balloon_dir = (element == EL_BALLOON_SWITCH_LEFT ? MV_LEFT : + element == EL_BALLOON_SWITCH_RIGHT ? MV_RIGHT : + element == EL_BALLOON_SWITCH_UP ? MV_UP : + element == EL_BALLOON_SWITCH_DOWN ? MV_DOWN : MV_NO_MOVING); - PlaySoundLevel(x, y, SND_BALLOON_SWITCH_ACTIVATING); + PlaySoundLevel(x, y, SND_CLASS_BALLOON_SWITCH_ACTIVATING); return MF_ACTION; break; @@ -6606,7 +6637,9 @@ int DigField(struct PlayerInfo *player, case EL_SPRING: if (mode == DF_SNAP) return MF_NO_ACTION; + /* no "break" -- fall through to next case */ + /* the following elements can be pushed by "snapping" */ case EL_BD_ROCK: if (dy) @@ -6614,20 +6647,24 @@ int DigField(struct PlayerInfo *player, player->Pushing = TRUE; +#if 0 + if (element == EL_ROCK) + printf("::: wanna push [%d] [%d]\n", + FrameCounter, player->push_delay_value); +#endif + if (!IN_LEV_FIELD(x+dx, y+dy) || !IS_FREE(x+dx, y+dy)) return MF_NO_ACTION; - if (real_dy) - { - if (IN_LEV_FIELD(jx, jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy])) - return MF_NO_ACTION; - } + if (!checkDiagonalPushing(player, x, y, real_dx, real_dy)) + return MF_NO_ACTION; if (player->push_delay == 0) player->push_delay = FrameCounter; #if 0 if (!FrameReached(&player->push_delay, player->push_delay_value) && - !tape.playing && element != EL_SPRING) + !tape.playing && + element != EL_SPRING) return MF_NO_ACTION; #else if (!FrameReached(&player->push_delay, player->push_delay_value) && @@ -6656,30 +6693,30 @@ int DigField(struct PlayerInfo *player, player->push_delay_value = (element == EL_SPRING ? 0 : 2 + RND(8)); DrawLevelField(x + dx, y + dy); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); break; - case EL_GATE1: - case EL_GATE2: - case EL_GATE3: - case EL_GATE4: - if (!player->key[element - EL_GATE1]) + case EL_GATE_1: + case EL_GATE_2: + case EL_GATE_3: + case EL_GATE_4: + if (!player->key[element - EL_GATE_1]) return MF_NO_ACTION; break; - case EL_GATE1_GRAY: - case EL_GATE2_GRAY: - case EL_GATE3_GRAY: - case EL_GATE4_GRAY: - if (!player->key[element - EL_GATE1_GRAY]) + case EL_GATE_1_GRAY: + case EL_GATE_2_GRAY: + case EL_GATE_3_GRAY: + case EL_GATE_4_GRAY: + if (!player->key[element - EL_GATE_1_GRAY]) return MF_NO_ACTION; break; - case EL_EM_GATE1: - case EL_EM_GATE2: - case EL_EM_GATE3: - case EL_EM_GATE4: - if (!player->key[element - EL_EM_GATE1]) + case EL_EM_GATE_1: + case EL_EM_GATE_2: + case EL_EM_GATE_3: + case EL_EM_GATE_4: + if (!player->key[element - EL_EM_GATE_1]) return MF_NO_ACTION; if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; @@ -6688,14 +6725,14 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_GATE_PASSING); + PlaySoundLevel(x, y, SND_CLASS_GATE_PASSING); break; - case EL_EM_GATE1_GRAY: - case EL_EM_GATE2_GRAY: - case EL_EM_GATE3_GRAY: - case EL_EM_GATE4_GRAY: - if (!player->key[element - EL_EM_GATE1_GRAY]) + case EL_EM_GATE_1_GRAY: + case EL_EM_GATE_2_GRAY: + case EL_EM_GATE_3_GRAY: + case EL_EM_GATE_4_GRAY: + if (!player->key[element - EL_EM_GATE_1_GRAY]) return MF_NO_ACTION; if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; @@ -6704,7 +6741,11 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); +#if 1 + PlaySoundLevelAction(x, y, ACTION_PASSING); +#else PlaySoundLevel(x, y, SND_GATE_PASSING); +#endif break; case EL_SWITCHGATE_OPEN: @@ -6716,40 +6757,40 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PASSING); + PlaySoundLevelElementAction(x, y, element, ACTION_PASSING); break; - case EL_SP_PORT1_LEFT: - case EL_SP_PORT2_LEFT: - case EL_SP_PORT1_RIGHT: - case EL_SP_PORT2_RIGHT: - case EL_SP_PORT1_UP: - case EL_SP_PORT2_UP: - case EL_SP_PORT1_DOWN: - case EL_SP_PORT2_DOWN: - case EL_SP_PORT_X: - case EL_SP_PORT_Y: - case EL_SP_PORT_XY: + case EL_SP_PORT_LEFT: + case EL_SP_PORT_RIGHT: + case EL_SP_PORT_UP: + case EL_SP_PORT_DOWN: + case EL_SP_PORT_HORIZONTAL: + case EL_SP_PORT_VERTICAL: + case EL_SP_PORT_ANY: + case EL_SP_GRAVITY_PORT_LEFT: + case EL_SP_GRAVITY_PORT_RIGHT: + case EL_SP_GRAVITY_PORT_UP: + case EL_SP_GRAVITY_PORT_DOWN: if ((dx == -1 && - element != EL_SP_PORT1_LEFT && - element != EL_SP_PORT2_LEFT && - element != EL_SP_PORT_X && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_LEFT && + element != EL_SP_GRAVITY_PORT_LEFT && + element != EL_SP_PORT_HORIZONTAL && + element != EL_SP_PORT_ANY) || (dx == +1 && - element != EL_SP_PORT1_RIGHT && - element != EL_SP_PORT2_RIGHT && - element != EL_SP_PORT_X && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_RIGHT && + element != EL_SP_GRAVITY_PORT_RIGHT && + element != EL_SP_PORT_HORIZONTAL && + element != EL_SP_PORT_ANY) || (dy == -1 && - element != EL_SP_PORT1_UP && - element != EL_SP_PORT2_UP && - element != EL_SP_PORT_Y && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_UP && + element != EL_SP_GRAVITY_PORT_UP && + element != EL_SP_PORT_VERTICAL && + element != EL_SP_PORT_ANY) || (dy == +1 && - element != EL_SP_PORT1_DOWN && - element != EL_SP_PORT2_DOWN && - element != EL_SP_PORT_Y && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_DOWN && + element != EL_SP_GRAVITY_PORT_DOWN && + element != EL_SP_PORT_VERTICAL && + element != EL_SP_PORT_ANY) || !IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; @@ -6758,10 +6799,10 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_SP_PORT_PASSING); + PlaySoundLevel(x, y, SND_CLASS_SP_PORT_PASSING); break; - case EL_TUBE_ALL: + case EL_TUBE_ANY: case EL_TUBE_VERTICAL: case EL_TUBE_HORIZONTAL: case EL_TUBE_VERTICAL_LEFT: @@ -6776,7 +6817,7 @@ int DigField(struct PlayerInfo *player, int i = 0; int tube_enter_directions[][2] = { - { EL_TUBE_ALL, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, + { EL_TUBE_ANY, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, { EL_TUBE_VERTICAL, MV_UP | MV_DOWN }, { EL_TUBE_HORIZONTAL, MV_LEFT | MV_RIGHT }, { EL_TUBE_VERTICAL_LEFT, MV_RIGHT | MV_UP | MV_DOWN }, @@ -6800,7 +6841,7 @@ int DigField(struct PlayerInfo *player, if (!(tube_enter_directions[i][1] & move_direction)) return MF_NO_ACTION; /* tube has no opening in this direction */ - PlaySoundLevel(x, y, SND_TUBE_PASSING); + PlaySoundLevel(x, y, SND_CLASS_TUBE_PASSING); } break; @@ -6816,9 +6857,9 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; if (element == EL_EXIT_OPEN) - PlaySoundLevel(x, y, SND_EXIT_PASSING); + PlaySoundLevel(x, y, SND_CLASS_EXIT_PASSING); else - PlaySoundLevel(x, y, SND_SP_EXIT_PASSING); + PlaySoundLevel(x, y, SND_CLASS_SP_EXIT_PASSING); break; @@ -6833,9 +6874,9 @@ int DigField(struct PlayerInfo *player, case EL_TIME_ORB_FULL: Feld[x][y] = EL_TIME_ORB_EMPTY; TimeLeft += 10; - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); DrawLevelField(x, y); - PlaySoundStereo(SND_TIME_ORB_FULL_COLLECTING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_TIME_ORB_FULL_COLLECTING, SOUND_MIDDLE); return MF_ACTION; break; @@ -6858,16 +6899,8 @@ int DigField(struct PlayerInfo *player, || !IS_SB_ELEMENT(element)))) return MF_NO_ACTION; - if (dx && real_dy) - { - if (IN_LEV_FIELD(jx, jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy])) - return MF_NO_ACTION; - } - else if (dy && real_dx) - { - if (IN_LEV_FIELD(jx+real_dx, jy) && !IS_SOLID(Feld[jx+real_dx][jy])) - return MF_NO_ACTION; - } + if (!checkDiagonalPushing(player, x, y, real_dx, real_dy)) + return MF_NO_ACTION; if (player->push_delay == 0) player->push_delay = FrameCounter; @@ -6897,24 +6930,40 @@ int DigField(struct PlayerInfo *player, Feld[x+dx][y+dy] = EL_SOKOBAN_FIELD_FULL; local_player->sokobanfields_still_needed--; if (element == EL_SOKOBAN_OBJECT) - PlaySoundLevel(x, y, SND_SOKOBAN_FIELD_FILLING); +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_FILLING); +#else + PlaySoundLevel(x, y, SND_CLASS_SOKOBAN_FIELD_FILLING); +#endif else +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_PUSHING); +#else PlaySoundLevel(x, y, SND_SOKOBAN_OBJECT_PUSHING); +#endif } else { Feld[x+dx][y+dy] = EL_SOKOBAN_OBJECT; if (element == EL_SOKOBAN_FIELD_FULL) +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_EMPTYING); +#else PlaySoundLevel(x, y, SND_SOKOBAN_FIELD_EMPTYING); +#endif else +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_PUSHING); +#else PlaySoundLevel(x, y, SND_SOKOBAN_OBJECT_PUSHING); +#endif } } else { RemoveField(x, y); Feld[x+dx][y+dy] = element; - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); } player->push_delay_value = (element == EL_BALLOON ? 0 : 2); @@ -6927,7 +6976,7 @@ int DigField(struct PlayerInfo *player, game.emulation == EMU_SOKOBAN) { player->LevelSolved = player->GameOver = TRUE; - PlaySoundLevel(x, y, SND_SOKOBAN_GAME_SOLVING); + PlaySoundLevel(x, y, SND_GAME_SOKOBAN_SOLVING); } break; @@ -6938,11 +6987,91 @@ int DigField(struct PlayerInfo *player, break; default: + + if (IS_WALKABLE(element)) + { + break; + } + else if (IS_DIGGABLE(element)) + { + RemoveField(x, y); +#if 1 + if (mode != DF_SNAP) + { + GfxElement[x][y] = + (CAN_BE_CRUMBLED(element) ? EL_SAND : GFX_ELEMENT(element)); + player->is_digging = TRUE; + } +#endif + PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING); + + break; + } + else if (IS_COLLECTIBLE(element)) + { + RemoveField(x, y); +#if 1 + if (mode != DF_SNAP) + { + GfxElement[x][y] = element; + player->is_collecting = TRUE; + } +#endif + PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING); + + break; + } + else if (IS_PUSHABLE(element)) + { + if (mode == DF_SNAP) + return MF_NO_ACTION; + + if (CAN_FALL(element) && dy) + return MF_NO_ACTION; + + if (!player->Pushing && + game.engine_version >= RELEASE_IDENT(2,2,0,7)) + player->push_delay_value = GET_NEW_PUSH_DELAY(element); + + player->Pushing = TRUE; + + if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) + return MF_NO_ACTION; + + if (!checkDiagonalPushing(player, x, y, real_dx, real_dy)) + return MF_NO_ACTION; + + if (player->push_delay == 0) /* new pushing; restart delay */ + player->push_delay = FrameCounter; + + if (!FrameReached(&player->push_delay, player->push_delay_value) && + !(tape.playing && tape.file_version < FILE_VERSION_2_0)) + return MF_NO_ACTION; + + RemoveField(x, y); + Feld[x + dx][y + dy] = element; + +#if 1 + if (game.engine_version < RELEASE_IDENT(2,2,0,7)) + player->push_delay_value = GET_NEW_PUSH_DELAY(element); +#else + player->push_delay_value = 2 + RND(8); +#endif + + DrawLevelField(x + dx, y + dy); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); + + break; + } + return MF_NO_ACTION; } player->push_delay = 0; + if (Feld[x][y] != element) /* really digged/collected something */ + player->is_collecting = !player->is_digging; + return MF_MOVING; } @@ -6951,6 +7080,9 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) int jx = player->jx, jy = player->jy; int x = jx + dx, y = jy + dy; + if (player->MovPos && game.engine_version >= VERSION_IDENT(2,2,0)) + return FALSE; + if (!player->active || !IN_LEV_FIELD(x, y)) return FALSE; @@ -6963,6 +7095,13 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) player->Pushing = FALSE; player->snapped = FALSE; + + if (player->MovPos == 0) + { + player->is_digging = FALSE; + player->is_collecting = FALSE; + } + return FALSE; } @@ -6974,10 +7113,13 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) dy < 0 ? MV_UP : dy > 0 ? MV_DOWN : MV_NO_MOVING); - if (!DigField(player, x, y, 0, 0, DF_SNAP)) + if (DigField(player, x, y, 0, 0, DF_SNAP) == MF_NO_ACTION) return FALSE; player->snapped = TRUE; + player->is_digging = FALSE; + player->is_collecting = FALSE; + DrawLevelField(x, y); BackToFront(); @@ -6998,48 +7140,85 @@ boolean PlaceBomb(struct PlayerInfo *player) IS_ACTIVE_BOMB(element) || element == EL_EXPLOSION) return FALSE; +#if 0 + if (element != EL_EMPTY) + return FALSE; +#endif + if (element != EL_EMPTY) + { +#if 0 Store[jx][jy] = element; +#else + Back[jx][jy] = element; +#endif + } MovDelay[jx][jy] = 96; - GfxFrame[jx][jy] = 0; + + ResetGfxAnimation(jx, jy); + ResetRandomAnimationValue(jx, jy); if (player->dynamite) { - Feld[jx][jy] = EL_DYNAMITE_ACTIVE; + Feld[jx][jy] = (player->use_disk_red_graphic ? EL_SP_DISK_RED_ACTIVE : + EL_DYNAMITE_ACTIVE); player->dynamite--; DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), - FS_SMALL, FC_YELLOW); + FONT_TEXT_2); if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) { +#if 1 + DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0); +#else if (game.emulation == EMU_SUPAPLEX) DrawGraphic(SCREENX(jx), SCREENY(jy), IMG_SP_DISK_RED, 0); else DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), IMG_DYNAMITE_ACTIVE, 0); +#endif } - PlaySoundLevel(jx, jy, SND_DYNAMITE_DROPPING); + PlaySoundLevelAction(jx, jy, ACTION_DROPPING); } else { Feld[jx][jy] = - EL_DYNABOMB_PLAYER1_ACTIVE + (player->element_nr - EL_PLAYER1); + EL_DYNABOMB_PLAYER_1_ACTIVE + (player->element_nr - EL_PLAYER_1); player->dynabombs_left--; if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0); - PlaySoundLevel(jx, jy, SND_DYNABOMB_DROPPING); + PlaySoundLevelAction(jx, jy, ACTION_DROPPING); } return TRUE; } +/* ------------------------------------------------------------------------- */ +/* game sound playing functions */ +/* ------------------------------------------------------------------------- */ + +static int *loop_sound_frame = NULL; +static int *loop_sound_volume = NULL; + +void InitPlaySoundLevel() +{ + int num_sounds = getSoundListSize(); + + if (loop_sound_frame != NULL) + free(loop_sound_frame); + + if (loop_sound_volume != NULL) + free(loop_sound_volume); + + loop_sound_frame = checked_calloc(num_sounds * sizeof(int)); + loop_sound_volume = checked_calloc(num_sounds * sizeof(int)); +} + static void PlaySoundLevel(int x, int y, int nr) { - static int loop_sound_frame[NUM_SOUND_FILES]; - static int loop_sound_volume[NUM_SOUND_FILES]; int sx = SCREENX(x), sy = SCREENY(y); int volume, stereo_position; int max_distance = 8; @@ -7092,25 +7271,39 @@ static void PlaySoundLevelNearest(int x, int y, int sound_action) sound_action); } -static void PlaySoundLevelAction(int x, int y, int sound_action) +static void PlaySoundLevelAction(int x, int y, int action) +{ + PlaySoundLevelElementAction(x, y, Feld[x][y], action); +} + +static void PlaySoundLevelElementAction(int x, int y, int element, int action) { - PlaySoundLevelElementAction(x, y, Feld[x][y], sound_action); + int sound_effect = element_info[element].sound[action]; + + if (sound_effect != SND_UNDEFINED) + PlaySoundLevel(x, y, sound_effect); } -static void PlaySoundLevelElementAction(int x, int y, int element, - int sound_action) +static void PlaySoundLevelActionIfLoop(int x, int y, int action) { - int sound_effect = element_action_sound[element][sound_action]; + int sound_effect = element_info[Feld[x][y]].sound[action]; - if (sound_effect != -1) + if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect)) PlaySoundLevel(x, y, sound_effect); } +static void StopSoundLevelActionIfLoop(int x, int y, int action) +{ + int sound_effect = element_info[Feld[x][y]].sound[action]; + + if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect)) + StopSoundExt(sound_effect, SND_CTRL_STOP_SOUND); +} + void RaiseScore(int value) { local_player->score += value; - DrawText(DX_SCORE, DY_SCORE, int2str(local_player->score, 5), - FS_SMALL, FC_YELLOW); + DrawText(DX_SCORE, DY_SCORE, int2str(local_player->score, 5), FONT_TEXT_2); } void RaiseScoreElement(int element) @@ -7122,22 +7315,31 @@ void RaiseScoreElement(int element) case EL_EMERALD_YELLOW: case EL_EMERALD_RED: case EL_EMERALD_PURPLE: - RaiseScore(level.score[SC_EDELSTEIN]); + case EL_SP_INFOTRON: + RaiseScore(level.score[SC_EMERALD]); break; case EL_DIAMOND: - RaiseScore(level.score[SC_DIAMANT]); + RaiseScore(level.score[SC_DIAMOND]); + break; + case EL_CRYSTAL: + RaiseScore(level.score[SC_CRYSTAL]); + break; + case EL_PEARL: + RaiseScore(level.score[SC_PEARL]); break; case EL_BUG: case EL_BD_BUTTERFLY: - RaiseScore(level.score[SC_KAEFER]); + case EL_SP_ELECTRON: + RaiseScore(level.score[SC_BUG]); break; case EL_SPACESHIP: case EL_BD_FIREFLY: - RaiseScore(level.score[SC_FLIEGER]); + case EL_SP_SNIKSNAK: + RaiseScore(level.score[SC_SPACESHIP]); break; case EL_YAMYAM: case EL_DARK_YAMYAM: - RaiseScore(level.score[SC_MAMPFER]); + RaiseScore(level.score[SC_YAMYAM]); break; case EL_ROBOT: RaiseScore(level.score[SC_ROBOT]); @@ -7146,16 +7348,26 @@ void RaiseScoreElement(int element) RaiseScore(level.score[SC_PACMAN]); break; case EL_NUT: - RaiseScore(level.score[SC_KOKOSNUSS]); + RaiseScore(level.score[SC_NUT]); break; case EL_DYNAMITE: - RaiseScore(level.score[SC_DYNAMIT]); + case EL_DYNABOMB_INCREASE_NUMBER: + case EL_DYNABOMB_INCREASE_SIZE: + case EL_DYNABOMB_INCREASE_POWER: + RaiseScore(level.score[SC_DYNAMITE]); + break; + case EL_SHIELD_NORMAL: + case EL_SHIELD_DEADLY: + RaiseScore(level.score[SC_SHIELD]); + break; + case EL_EXTRA_TIME: + RaiseScore(level.score[SC_TIME_BONUS]); break; - case EL_KEY1: - case EL_KEY2: - case EL_KEY3: - case EL_KEY4: - RaiseScore(level.score[SC_SCHLUESSEL]); + case EL_KEY_1: + case EL_KEY_2: + case EL_KEY_3: + case EL_KEY_4: + RaiseScore(level.score[SC_KEY]); break; default: break; @@ -7176,7 +7388,7 @@ void RequestQuitGame(boolean ask_if_really_quit) else #endif { - game_status = MAINMENU; + game_status = GAME_MODE_MAIN; DrawMainMenu(); } } @@ -7249,7 +7461,7 @@ void CreateGameButtons() for (i=0; icustom_id; - if (game_status != PLAYING) + if (game_status != GAME_MODE_PLAYING) return; switch (id)