X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=346e1269ce6b77342083efe91436d2e4c4db659a;hb=84f2d2359ecfa6253804b353f92dd9b2ccb55887;hp=4a3f9d39c8feb62bcd728cfe9e7b2ca2acb309cb;hpb=d8865c54181a9375cc0ee0b967d8a709f4044ef8;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 4a3f9d39..346e1269 100644 --- a/src/game.c +++ b/src/game.c @@ -28,11 +28,12 @@ #define USE_NEW_STUFF ( 1) #define USE_NEW_SP_SLIPPERY (USE_NEW_STUFF * 1) -#define USE_NEW_COLLECT_COUNT (USE_NEW_STUFF * 1) +#define USE_NEW_CUSTOM_VALUE (USE_NEW_STUFF * 1) #define USE_NEW_PLAYER_ANIM (USE_NEW_STUFF * 1) #define USE_NEW_ALL_SLIPPERY (USE_NEW_STUFF * 1) #define USE_NEW_PLAYER_SPEED (USE_NEW_STUFF * 1) #define USE_NEW_DELAYED_ACTION (USE_NEW_STUFF * 1) +#define USE_NEW_SNAP_DELAY (USE_NEW_STUFF * 1) /* for DigField() */ #define DF_NO_PUSH 0 @@ -125,6 +126,8 @@ RND(element_info[e].move_delay_random)) #define GET_MAX_MOVE_DELAY(e) ( (element_info[e].move_delay_fixed) + \ (element_info[e].move_delay_random)) +#define GET_NEW_CUSTOM_VALUE(e) ( (element_info[e].ce_value_fixed_initial) +\ + RND(element_info[e].ce_value_random_initial)) #define GET_CHANGE_DELAY(c) ( ((c)->delay_fixed * (c)->delay_frames) + \ RND((c)->delay_random * (c)->delay_frames)) @@ -132,9 +135,6 @@ ((e) == EL_TRIGGER_ELEMENT ? (ch)->actual_trigger_element : \ (e) == EL_TRIGGER_PLAYER ? (ch)->actual_trigger_player : (e)) -#define GET_VALID_PLAYER_ELEMENT(e) \ - ((e) >= EL_PLAYER_1 && (e) <= EL_PLAYER_4 ? (e) : EL_PLAYER_1) - #define CAN_GROW_INTO(e) \ ((e) == EL_SAND || (IS_DIGGABLE(e) && level.grow_into_diggable)) @@ -257,15 +257,15 @@ static void TestIfElementSmashesCustomElement(int, int, int); static void ChangeElement(int, int, int); -static boolean CheckTriggeredElementChangeExt(int, int, int,int,int); -#define CheckTriggeredElementChange(e, ev) \ - CheckTriggeredElementChangeExt(e, ev, CH_PLAYER_ANY, CH_SIDE_ANY, -1) -#define CheckTriggeredElementChangeByPlayer(e, ev, p, s) \ - CheckTriggeredElementChangeExt(e, ev, p, s, -1) -#define CheckTriggeredElementChangeBySide(e, ev, s) \ - CheckTriggeredElementChangeExt(e, ev, CH_PLAYER_ANY, s, -1) -#define CheckTriggeredElementChangeByPage(e, ev, p) \ - CheckTriggeredElementChangeExt(e, ev, CH_PLAYER_ANY, CH_SIDE_ANY, p) +static boolean CheckTriggeredElementChangeExt(int, int, int, int, int,int,int); +#define CheckTriggeredElementChange(x, y, e, ev) \ + CheckTriggeredElementChangeExt(x,y,e,ev, CH_PLAYER_ANY,CH_SIDE_ANY, -1) +#define CheckTriggeredElementChangeByPlayer(x, y, e, ev, p, s) \ + CheckTriggeredElementChangeExt(x, y, e, ev, p, s, -1) +#define CheckTriggeredElementChangeBySide(x, y, e, ev, s) \ + CheckTriggeredElementChangeExt(x, y, e, ev, CH_PLAYER_ANY, s, -1) +#define CheckTriggeredElementChangeByPage(x, y, e, ev, p) \ + CheckTriggeredElementChangeExt(x,y,e,ev, CH_PLAYER_ANY, CH_SIDE_ANY, p) static boolean CheckElementChangeExt(int, int, int, int, int, int, int); #define CheckElementChange(x, y, e, te, ev) \ @@ -582,7 +582,7 @@ access_direction_list[] = { EL_SP_GRAVITY_OFF_PORT_UP, MV_DOWN }, { EL_SP_GRAVITY_OFF_PORT_DOWN, MV_UP }, - { EL_UNDEFINED, MV_NO_MOVING } + { EL_UNDEFINED, MV_NONE } }; static boolean trigger_events[MAX_NUM_ELEMENTS][NUM_CHANGE_EVENTS]; @@ -657,7 +657,7 @@ static int getBeltDirFromBeltSwitchElement(int element) static int belt_move_dir[3] = { MV_LEFT, - MV_NO_MOVING, + MV_NONE, MV_RIGHT }; @@ -890,8 +890,21 @@ static void InitField(int x, int y, boolean init_game) break; default: +#if 1 + if (IS_CUSTOM_ELEMENT(element)) + { + if (CAN_MOVE(element)) + InitMovDir(x, y); + +#if USE_NEW_CUSTOM_VALUE + if (!element_info[element].use_last_ce_value) + CustomValue[x][y] = GET_NEW_CUSTOM_VALUE(Feld[x][y]); +#endif + } +#else if (IS_CUSTOM_ELEMENT(element) && CAN_MOVE(element)) InitMovDir(x, y); +#endif else if (IS_GROUP_ELEMENT(element)) { struct ElementGroupInfo *group = element_info[element].group; @@ -917,8 +930,18 @@ static void InitField(int x, int y, boolean init_game) break; } -#if USE_NEW_COLLECT_COUNT - Count[x][y] = element_info[Feld[x][y]].collect_count_initial; +#if 0 + +#if USE_NEW_CUSTOM_VALUE + +#if 1 + CustomValue[x][y] = GET_NEW_CUSTOM_VALUE(Feld[x][y]); +#else + CustomValue[x][y] = element_info[Feld[x][y]].custom_value_initial; +#endif + +#endif + #endif } @@ -1320,6 +1343,8 @@ static void InitGameEngine() { ei->change_page[j].actual_trigger_element = EL_EMPTY; ei->change_page[j].actual_trigger_player = EL_PLAYER_1; + ei->change_page[j].actual_trigger_side = CH_SIDE_NONE; + ei->change_page[j].actual_trigger_ce_value = 0; } } @@ -1498,10 +1523,10 @@ void InitGame() player->dynabombs_left = 0; player->dynabomb_xl = FALSE; - player->MovDir = MV_NO_MOVING; + player->MovDir = MV_NONE; player->MovPos = 0; player->GfxPos = 0; - player->GfxDir = MV_NO_MOVING; + player->GfxDir = MV_NONE; player->GfxAction = ACTION_DEFAULT; player->Frame = 0; player->StepFrame = 0; @@ -1517,7 +1542,7 @@ void InitGame() player->step_counter = 0; - player->last_move_dir = MV_NO_MOVING; + player->last_move_dir = MV_NONE; player->is_waiting = FALSE; player->is_moving = FALSE; @@ -1532,6 +1557,8 @@ void InitGame() player->is_bored = FALSE; player->is_sleeping = FALSE; + player->cannot_move = FALSE; + player->frame_counter_bored = -1; player->frame_counter_sleeping = -1; @@ -1617,7 +1644,7 @@ void InitGame() #if defined(NETWORK_AVALIABLE) /* initial null action */ if (network_playing) - SendToServer_MovePlayer(MV_NO_MOVING); + SendToServer_MovePlayer(MV_NONE); #endif ZX = ZY = -1; @@ -1629,7 +1656,7 @@ void InitGame() TimeLeft = level.time; TapeTime = 0; - ScreenMovDir = MV_NO_MOVING; + ScreenMovDir = MV_NONE; ScreenMovPos = 0; ScreenGfxPos = 0; @@ -1643,7 +1670,7 @@ void InitGame() game.light_time_left = 0; game.timegate_time_left = 0; game.switchgate_pos = 0; - game.balloon_dir = MV_NO_MOVING; + game.wind_direction = level.wind_direction_initial; game.gravity = level.initial_gravity; game.explosions_delayed = TRUE; @@ -1651,7 +1678,7 @@ void InitGame() for (i = 0; i < NUM_BELTS; i++) { - game.belt_dir[i] = MV_NO_MOVING; + game.belt_dir[i] = MV_NONE; game.belt_dir_nr[i] = 3; /* not moving, next moving left */ } @@ -1666,8 +1693,8 @@ void InitGame() MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; ChangeDelay[x][y] = 0; ChangePage[x][y] = -1; -#if USE_NEW_COLLECT_COUNT - Count[x][y] = 0; /* initialized in InitField() */ +#if USE_NEW_CUSTOM_VALUE + CustomValue[x][y] = 0; /* initialized in InitField() */ #endif Store[x][y] = Store2[x][y] = StorePlayer[x][y] = Back[x][y] = 0; AmoebaNr[x][y] = 0; @@ -1691,7 +1718,7 @@ void InitGame() GfxRandom[x][y] = INIT_GFX_RANDOM(); GfxElement[x][y] = EL_UNDEFINED; GfxAction[x][y] = ACTION_DEFAULT; - GfxDir[x][y] = MV_NO_MOVING; + GfxDir[x][y] = MV_NONE; } } @@ -1766,7 +1793,7 @@ void InitGame() /* correct non-moving belts to start moving left */ for (i = 0; i < NUM_BELTS; i++) - if (game.belt_dir[i] == MV_NO_MOVING) + if (game.belt_dir[i] == MV_NONE) game.belt_dir_nr[i] = 3; /* not moving, next moving left */ /* check if any connected player was not found in playfield */ @@ -1902,6 +1929,7 @@ void InitGame() int start_x = 0, start_y = 0; int found_rating = 0; int found_element = EL_UNDEFINED; + int player_nr = local_player->index_nr; for (y = 0; y < lev_fieldy; y++) for (x = 0; x < lev_fieldx; x++) { @@ -1910,6 +1938,17 @@ void InitGame() int xx, yy; boolean is_player; + if (level.use_start_element[player_nr] && + level.start_element[player_nr] == element && + found_rating < 4) + { + start_x = x; + start_y = y; + + found_rating = 4; + found_element = element; + } + if (!IS_CUSTOM_ELEMENT(element)) continue; @@ -1917,6 +1956,7 @@ void InitGame() { for (i = 0; i < element_info[element].num_change_pages; i++) { + /* check for player created from custom element as single target */ content = element_info[element].change_page[i].target_element; is_player = ELEM_IS_PLAYER(content); @@ -1933,6 +1973,7 @@ void InitGame() for (yy = 0; yy < 3; yy++) for (xx = 0; xx < 3; xx++) { + /* check for player created from custom element as explosion content */ content = element_info[element].content.e[xx][yy]; is_player = ELEM_IS_PLAYER(content); @@ -1950,6 +1991,7 @@ void InitGame() for (i = 0; i < element_info[element].num_change_pages; i++) { + /* check for player created from custom element as extended target */ content = element_info[element].change_page[i].target_content.e[xx][yy]; @@ -2147,7 +2189,7 @@ void InitMovDir(int x, int y) if (move_direction_initial == MV_START_PREVIOUS) { - if (MovDir[x][y] != MV_NO_MOVING) + if (MovDir[x][y] != MV_NONE) return; move_direction_initial = MV_START_AUTOMATIC; @@ -2534,8 +2576,8 @@ void InitMovingField(int x, int y, int direction) MovDir[newx][newy] = MovDir[x][y]; -#if USE_NEW_COLLECT_COUNT - Count[newx][newy] = Count[x][y]; +#if USE_NEW_CUSTOM_VALUE + CustomValue[newx][newy] = CustomValue[x][y]; #endif GfxFrame[newx][newy] = GfxFrame[x][y]; @@ -2619,8 +2661,8 @@ static void RemoveField(int x, int y) MovDir[x][y] = 0; MovDelay[x][y] = 0; -#if USE_NEW_COLLECT_COUNT - Count[x][y] = 0; +#if USE_NEW_CUSTOM_VALUE + CustomValue[x][y] = 0; #endif AmoebaNr[x][y] = 0; @@ -2634,7 +2676,7 @@ static void RemoveField(int x, int y) GfxElement[x][y] = EL_UNDEFINED; GfxAction[x][y] = ACTION_DEFAULT; - GfxDir[x][y] = MV_NO_MOVING; + GfxDir[x][y] = MV_NONE; } void RemoveMovingField(int x, int y) @@ -2832,8 +2874,9 @@ void DrawRelocatePlayer(struct PlayerInfo *player) void RelocatePlayer(int jx, int jy, int el_player_raw) { - int el_player = GET_VALID_PLAYER_ELEMENT(el_player_raw); - struct PlayerInfo *player = &stored_player[el_player - EL_PLAYER_1]; + int el_player = GET_PLAYER_ELEMENT(el_player_raw); + int player_nr = GET_PLAYER_NR(el_player); + struct PlayerInfo *player = &stored_player[player_nr]; boolean ffwd_delay = (tape.playing && tape.fast_forward); boolean no_delay = (tape.warp_forward); int frame_delay_value = (ffwd_delay ? FfwdFrameDelay : GameFrameDelay); @@ -2891,7 +2934,8 @@ void RelocatePlayer(int jx, int jy, int el_player_raw) CE_LEFT_BY_PLAYER, player->index_bit, leave_side); - CheckTriggeredElementChangeByPlayer(old_element, CE_PLAYER_LEAVES_X, + CheckTriggeredElementChangeByPlayer(old_jx, old_jy, old_element, + CE_PLAYER_LEAVES_X, player->index_bit, leave_side); Feld[jx][jy] = el_player; @@ -2913,7 +2957,7 @@ void RelocatePlayer(int jx, int jy, int el_player_raw) CheckElementChangeByPlayer(jx, jy, element, CE_ENTERED_BY_PLAYER, player->index_bit, enter_side); - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_ENTERS_X, + CheckTriggeredElementChangeByPlayer(jx, jy, element, CE_PLAYER_ENTERS_X, player->index_bit, enter_side); } @@ -3205,12 +3249,12 @@ void Explode(int ex, int ey, int phase, int mode) Back[x][y] = 0; MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; - GfxDir[x][y] = MV_NO_MOVING; + GfxDir[x][y] = MV_NONE; ChangeDelay[x][y] = 0; ChangePage[x][y] = -1; -#if USE_NEW_COLLECT_COUNT - Count[x][y] = 0; +#if USE_NEW_CUSTOM_VALUE + CustomValue[x][y] = 0; #endif InitField_WithBug2(x, y, FALSE); @@ -3356,7 +3400,7 @@ void Bang(int x, int y) break; } - CheckTriggeredElementChange(element, CE_EXPLOSION_OF_X); + CheckTriggeredElementChange(x, y, element, CE_EXPLOSION_OF_X); } void SplashAcid(int x, int y) @@ -3418,7 +3462,7 @@ static void InitBeltMovement() for (i = 0; i < NUM_BELTS; i++) { - if (IS_BELT(element) && game.belt_dir[i] != MV_NO_MOVING) + if (IS_BELT(element) && game.belt_dir[i] != MV_NONE) { int e_belt_nr = getBeltNrFromBeltElement(element); int belt_nr = i; @@ -3461,9 +3505,9 @@ static void ToggleBeltSwitch(int x, int y) static int belt_move_dir[4] = { MV_LEFT, - MV_NO_MOVING, + MV_NONE, MV_RIGHT, - MV_NO_MOVING, + MV_NONE, }; int element = Feld[x][y]; @@ -3509,7 +3553,7 @@ static void ToggleBeltSwitch(int x, int y) DrawLevelField(xx, yy); } } - else if (IS_BELT(element) && belt_dir != MV_NO_MOVING) + else if (IS_BELT(element) && belt_dir != MV_NONE) { int e_belt_nr = getBeltNrFromBeltElement(element); @@ -3521,7 +3565,7 @@ static void ToggleBeltSwitch(int x, int y) DrawLevelField(xx, yy); } } - else if (IS_BELT_ACTIVE(element) && belt_dir == MV_NO_MOVING) + else if (IS_BELT_ACTIVE(element) && belt_dir == MV_NONE) { int e_belt_nr = getBeltNrFromBeltActiveElement(element); @@ -3885,7 +3929,7 @@ void Impact(int x, int y) CheckElementChangeBySide(x, y + 1, smashed, element, CE_SWITCHED, CH_SIDE_TOP); - CheckTriggeredElementChangeBySide(smashed, CE_SWITCH_OF_X, + CheckTriggeredElementChangeBySide(x, y + 1, smashed, CE_SWITCH_OF_X, CH_SIDE_TOP); } } @@ -4174,7 +4218,7 @@ inline static void TurnRoundExt(int x, int y) } else if (element == EL_BALLOON) { - MovDir[x][y] = game.balloon_dir; + MovDir[x][y] = game.wind_direction; MovDelay[x][y] = 0; } else if (element == EL_SPRING) @@ -4182,7 +4226,7 @@ inline static void TurnRoundExt(int x, int y) if (MovDir[x][y] & MV_HORIZONTAL && (!SPRING_CAN_ENTER_FIELD(element, move_x, move_y) || SPRING_CAN_ENTER_FIELD(element, x, y + 1))) - MovDir[x][y] = MV_NO_MOVING; + MovDir[x][y] = MV_NONE; MovDelay[x][y] = 0; } @@ -4251,7 +4295,7 @@ inline static void TurnRoundExt(int x, int y) } } - MovDir[x][y] = MV_NO_MOVING; + MovDir[x][y] = MV_NONE; if (attr_x < x) MovDir[x][y] |= (AllPlayersGone ? MV_RIGHT : MV_LEFT); else if (attr_x > x) @@ -4388,6 +4432,11 @@ inline static void TurnRoundExt(int x, int y) MovDir[x][y] = move_pattern; MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); } + else if (move_pattern & MV_WIND_DIRECTION) + { + MovDir[x][y] = game.wind_direction; + MovDelay[x][y] = GET_NEW_MOVE_DELAY(element); + } else if (move_pattern == MV_ALONG_LEFT_SIDE) { if (CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, left_x, left_y)) @@ -4441,7 +4490,7 @@ inline static void TurnRoundExt(int x, int y) } } - MovDir[x][y] = MV_NO_MOVING; + MovDir[x][y] = MV_NONE; if (attr_x < x) MovDir[x][y] |= (move_away ? MV_RIGHT : MV_LEFT); else if (attr_x > x) @@ -4487,7 +4536,7 @@ inline static void TurnRoundExt(int x, int y) move_pattern == MV_WHEN_DROPPED) { if (!CUSTOM_ELEMENT_CAN_ENTER_FIELD(element, move_x, move_y)) - MovDir[x][y] = MV_NO_MOVING; + MovDir[x][y] = MV_NONE; MovDelay[x][y] = 0; } @@ -4515,7 +4564,7 @@ inline static void TurnRoundExt(int x, int y) }; boolean hunter_mode = (move_pattern == MV_MAZE_HUNTER); int move_preference = -1000000; /* start with very low preference */ - int new_move_dir = MV_NO_MOVING; + int new_move_dir = MV_NONE; int start_test = RND(4); int i; @@ -4764,7 +4813,7 @@ void StartMoving(int x, int y) } else if (IS_FREE(x, y + 1) && element == EL_SPRING && level.use_spring_bug) { - if (MovDir[x][y] == MV_NO_MOVING) + if (MovDir[x][y] == MV_NONE) { InitMovingField(x, y, MV_DOWN); started_moving = TRUE; @@ -4906,7 +4955,7 @@ void StartMoving(int x, int y) /* not "else if" because of elements that can fall and move (EL_SPRING) */ #if 0 - if (CAN_MOVE(element) && !started_moving && MovDir[x][y] != MV_NO_MOVING) + if (CAN_MOVE(element) && !started_moving && MovDir[x][y] != MV_NONE) #else if (CAN_MOVE(element) && !started_moving) #endif @@ -4916,7 +4965,7 @@ void StartMoving(int x, int y) #if 0 #if DEBUG - if (MovDir[x][y] == MV_NO_MOVING) + if (MovDir[x][y] == MV_NONE) { printf("StartMoving(): %d,%d: element %d ['%s'] not moving\n", x, y, element, element_info[element].token_name); @@ -5103,7 +5152,7 @@ void StartMoving(int x, int y) if (DigField(local_player, x, y, newx, newy, 0,0, DF_DIG) == MF_MOVING) DrawLevelField(newx, newy); else - GfxDir[x][y] = MovDir[x][y] = MV_NO_MOVING; + GfxDir[x][y] = MovDir[x][y] = MV_NONE; } else if (!IS_FREE(newx, newy)) { @@ -5447,7 +5496,7 @@ void ContinueMoving(int x, int y) Feld[x][y] = EL_MAGIC_WALL_DEAD; element = Feld[newx][newy] = Store[x][y]; -#if USE_NEW_COLLECT_COUNT +#if USE_NEW_CUSTOM_VALUE InitField(newx, newy, FALSE); #endif } @@ -5465,7 +5514,7 @@ void ContinueMoving(int x, int y) Feld[x][y] = EL_BD_MAGIC_WALL_DEAD; element = Feld[newx][newy] = Store[x][y]; -#if USE_NEW_COLLECT_COUNT +#if USE_NEW_CUSTOM_VALUE InitField(newx, newy, FALSE); #endif } @@ -5500,8 +5549,8 @@ void ContinueMoving(int x, int y) Changed[newx][newy] = Changed[x][y]; ChangeEvent[newx][newy] = ChangeEvent[x][y]; -#if USE_NEW_COLLECT_COUNT - Count[newx][newy] = Count[x][y]; +#if USE_NEW_CUSTOM_VALUE + CustomValue[newx][newy] = CustomValue[x][y]; #endif } @@ -5510,8 +5559,8 @@ void ContinueMoving(int x, int y) Changed[x][y] = FALSE; ChangeEvent[x][y] = -1; -#if USE_NEW_COLLECT_COUNT - Count[x][y] = 0; +#if USE_NEW_CUSTOM_VALUE + CustomValue[x][y] = 0; #endif /* copy animation control values to new field */ @@ -5613,7 +5662,7 @@ void ContinueMoving(int x, int y) CheckElementChangeByPlayer(newx, newy, element, CE_PUSHED_BY_PLAYER, player->index_bit, dig_side); - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_PUSHES_X, + CheckTriggeredElementChangeByPlayer(newx,newy, element, CE_PLAYER_PUSHES_X, player->index_bit, dig_side); } @@ -6030,10 +6079,14 @@ void AmoebeAbleger(int ax, int ay) void Life(int ax, int ay) { int x1, y1, x2, y2; +#if 0 static int life[4] = { 2, 3, 3, 3 }; /* parameters for "game of life" */ +#endif int life_time = 40; int element = Feld[ax][ay]; int graphic = el2img(element); + int *life_parameter = (element == EL_GAME_OF_LIFE ? level.game_of_life : + level.biomaze); boolean changed = FALSE; if (IS_ANIMATED(graphic)) @@ -6076,7 +6129,8 @@ void Life(int ax, int ay) if (xx == ax && yy == ay) /* field in the middle */ { - if (nachbarn < life[0] || nachbarn > life[1]) + if (nachbarn < life_parameter[0] || + nachbarn > life_parameter[1]) { Feld[xx][yy] = EL_EMPTY; if (!Stop[xx][yy]) @@ -6087,7 +6141,8 @@ void Life(int ax, int ay) } else if (IS_FREE(xx, yy) || CAN_GROW_INTO(Feld[xx][yy])) { /* free border field */ - if (nachbarn >= life[2] && nachbarn <= life[3]) + if (nachbarn >= life_parameter[2] && + nachbarn <= life_parameter[3]) { Feld[xx][yy] = element; MovDelay[xx][yy] = (element == EL_GAME_OF_LIFE ? 0 : life_time-1); @@ -6280,7 +6335,7 @@ void MauerWaechst(int x, int y) Feld[x][y] = Store[x][y]; Store[x][y] = 0; - GfxDir[x][y] = MovDir[x][y] = MV_NO_MOVING; + GfxDir[x][y] = MovDir[x][y] = MV_NONE; DrawLevelField(x, y); } } @@ -6542,53 +6597,66 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) action_arg == CA_ARG_ELEMENT_TARGET ? change->target_element : EL_EMPTY); + int action_arg_direction = + (action_arg >= CA_ARG_DIRECTION_LEFT && + action_arg <= CA_ARG_DIRECTION_DOWN ? action_arg - CA_ARG_DIRECTION : + action_arg == CA_ARG_DIRECTION_TRIGGER ? + change->actual_trigger_side : + action_arg == CA_ARG_DIRECTION_TRIGGER_BACK ? + MV_DIR_OPPOSITE(change->actual_trigger_side) : + MV_NONE); + int action_arg_number_min = (action_type == CA_SET_PLAYER_SPEED ? MOVE_STEPSIZE_MIN : CA_ARG_MIN); int action_arg_number_max = (action_type == CA_SET_PLAYER_SPEED ? MOVE_STEPSIZE_MAX : - action_type == CA_SET_GEMS ? 999 : - action_type == CA_SET_TIME ? 9999 : - action_type == CA_SET_SCORE ? 99999 : + action_type == CA_SET_LEVEL_GEMS ? 999 : + action_type == CA_SET_LEVEL_TIME ? 9999 : + action_type == CA_SET_LEVEL_SCORE ? 99999 : action_type == CA_SET_CE_SCORE ? 9999 : - action_type == CA_SET_CE_COUNT ? 9999 : + action_type == CA_SET_CE_VALUE ? 9999 : CA_ARG_MAX); int action_arg_number_reset = (action_type == CA_SET_PLAYER_SPEED ? TILEX/game.initial_move_delay_value : - action_type == CA_SET_GEMS ? level.gems_needed : - action_type == CA_SET_TIME ? level.time : - action_type == CA_SET_SCORE ? 0 : + action_type == CA_SET_LEVEL_GEMS ? level.gems_needed : + action_type == CA_SET_LEVEL_TIME ? level.time : + action_type == CA_SET_LEVEL_SCORE ? 0 : action_type == CA_SET_CE_SCORE ? 0 : - action_type == CA_SET_CE_COUNT ? ei->collect_count_initial : +#if 1 + action_type == CA_SET_CE_VALUE ? GET_NEW_CUSTOM_VALUE(element) : +#else + action_type == CA_SET_CE_VALUE ? ei->custom_value_initial : +#endif 0); - int action_arg_number_normal = - (action_type == CA_SET_PLAYER_SPEED ? MOVE_STEPSIZE_NORMAL : - action_arg_number_reset); - int action_arg_number = (action_arg <= CA_ARG_MAX ? action_arg : + action_arg >= CA_ARG_SPEED_NOT_MOVING && + action_arg <= CA_ARG_SPEED_EVEN_FASTER ? (action_arg - CA_ARG_SPEED) : + action_arg == CA_ARG_SPEED_RESET ? action_arg_number_reset : action_arg == CA_ARG_NUMBER_MIN ? action_arg_number_min : action_arg == CA_ARG_NUMBER_MAX ? action_arg_number_max : action_arg == CA_ARG_NUMBER_RESET ? action_arg_number_reset : - action_arg == CA_ARG_NUMBER_NORMAL ? action_arg_number_normal : action_arg == CA_ARG_NUMBER_CE_SCORE ? ei->collect_score : -#if USE_NEW_COLLECT_COUNT - action_arg == CA_ARG_NUMBER_CE_COUNT ? Count[x][y] : +#if USE_NEW_CUSTOM_VALUE + action_arg == CA_ARG_NUMBER_CE_VALUE ? CustomValue[x][y] : #else - action_arg == CA_ARG_NUMBER_CE_COUNT ? ei->collect_count_initial : + action_arg == CA_ARG_NUMBER_CE_VALUE ? ei->custom_value_initial : #endif action_arg == CA_ARG_NUMBER_CE_DELAY ? GET_CHANGE_DELAY(change) : + action_arg == CA_ARG_ELEMENT_TARGET ? GET_NEW_CUSTOM_VALUE(change->target_element) : + action_arg == CA_ARG_ELEMENT_TRIGGER ? change->actual_trigger_ce_value : -1); int action_arg_number_old = - (action_type == CA_SET_GEMS ? local_player->gems_still_needed : - action_type == CA_SET_TIME ? TimeLeft : - action_type == CA_SET_SCORE ? local_player->score : + (action_type == CA_SET_LEVEL_GEMS ? local_player->gems_still_needed : + action_type == CA_SET_LEVEL_TIME ? TimeLeft : + action_type == CA_SET_LEVEL_SCORE ? local_player->score : action_type == CA_SET_CE_SCORE ? ei->collect_score : - action_type == CA_SET_CE_COUNT ? Count[x][y] : + action_type == CA_SET_CE_VALUE ? CustomValue[x][y] : 0); int action_arg_number_new = @@ -6596,23 +6664,18 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) action_mode, action_arg_number, action_arg_number_min, action_arg_number_max); - int action_arg_player_bits = - (action_arg == CA_ARG_PLAYER_ANY ? PLAYER_BITS_ANY : - action_arg >= CA_ARG_PLAYER_1 && - action_arg <= CA_ARG_PLAYER_4 ? action_arg - CA_ARG_PLAYER : - action_arg >= CA_ARG_1 && - action_arg <= CA_ARG_PLAYER_4 ? (1 << (action_arg - CA_ARG_1)) : - action_arg_element >= EL_PLAYER_1 && - action_arg_element <= EL_PLAYER_4 ? - (1 << (action_arg_element - EL_PLAYER_1)) : - PLAYER_BITS_ANY); - int trigger_player_bits = (change->actual_trigger_player >= EL_PLAYER_1 && change->actual_trigger_player <= EL_PLAYER_4 ? (1 << (change->actual_trigger_player - EL_PLAYER_1)) : PLAYER_BITS_ANY); + int action_arg_player_bits = + (action_arg >= CA_ARG_PLAYER_1 && + action_arg <= CA_ARG_PLAYER_4 ? action_arg - CA_ARG_PLAYER : + action_arg == CA_ARG_PLAYER_TRIGGER ? trigger_player_bits : + PLAYER_BITS_ANY); + /* ---------- execute action ---------- */ switch(action_type) @@ -6640,6 +6703,16 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) break; } + case CA_MOVE_PLAYER: + { + /* automatically move to the next field in specified direction */ + for (i = 0; i < MAX_PLAYERS; i++) + if (trigger_player_bits & (1 << i)) + stored_player[i].programmed_action = action_arg_direction; + + break; + } + case CA_RESTART_LEVEL: { game.restart_level = TRUE; @@ -6658,8 +6731,9 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) break; } - case CA_ADD_KEY: + case CA_SET_PLAYER_KEYS: { + int key_state = (action_mode == CA_MODE_ADD ? TRUE : FALSE); int element = getSpecialActionElement(action_arg_element, action_arg_number, EL_KEY_1); @@ -6669,30 +6743,7 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) { if (trigger_player_bits & (1 << i)) { - stored_player[i].key[KEY_NR(element)] = TRUE; - - DrawGameValue_Keys(stored_player[i].key); - - redraw_mask |= REDRAW_DOOR_1; - } - } - } - - break; - } - - case CA_DEL_KEY: - { - int element = getSpecialActionElement(action_arg_element, - action_arg_number, EL_KEY_1); - - if (IS_KEY(element)) - { - for (i = 0; i < MAX_PLAYERS; i++) - { - if (trigger_player_bits & (1 << i)) - { - stored_player[i].key[KEY_NR(element)] = FALSE; + stored_player[i].key[KEY_NR(element)] = key_state; DrawGameValue_Keys(stored_player[i].key); @@ -6712,12 +6763,12 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) { int move_stepsize = TILEX / stored_player[i].move_delay_value; - if (action_mode == CA_MODE_ADD || action_mode == CA_MODE_SUBTRACT) + if (action_arg == CA_ARG_SPEED_SLOWER || + action_arg == CA_ARG_SPEED_FASTER) { - /* translate "+" and "-" to "*" and "/" with powers of two */ - action_arg_number = 1 << action_arg_number; - action_mode = (action_mode == CA_MODE_ADD ? CA_MODE_MULTIPLY : - CA_MODE_DIVIDE); + action_arg_number = 2; + action_mode = (action_arg == CA_ARG_SPEED_SLOWER ? CA_MODE_DIVIDE : + CA_MODE_MULTIPLY); } move_stepsize = @@ -6733,17 +6784,67 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) /* do no immediately change -- the player might just be moving */ stored_player[i].move_delay_value_next = TILEX / move_stepsize; -#if 0 - printf("::: move_delay_value == %d [%d]\n", - stored_player[i].move_delay_value_next, action_arg_number); -#endif + stored_player[i].cannot_move = + (action_arg == CA_ARG_SPEED_NOT_MOVING ? TRUE : FALSE); } } break; } - case CA_SET_GEMS: + case CA_SET_PLAYER_SHIELD: + { + for (i = 0; i < MAX_PLAYERS; i++) + { + if (trigger_player_bits & (1 << i)) + { + if (action_arg == CA_ARG_SHIELD_OFF) + { + stored_player[i].shield_normal_time_left = 0; + stored_player[i].shield_deadly_time_left = 0; + } + else if (action_arg == CA_ARG_SHIELD_NORMAL) + { + stored_player[i].shield_normal_time_left = 999999; + } + else if (action_arg == CA_ARG_SHIELD_DEADLY) + { + stored_player[i].shield_normal_time_left = 999999; + stored_player[i].shield_deadly_time_left = 999999; + } + } + } + + break; + } + + case CA_SET_PLAYER_ARTWORK: + { + for (i = 0; i < MAX_PLAYERS; i++) + { + int element = action_arg_element; + } + + break; + } + + case CA_SET_LEVEL_GRAVITY: + { + game.gravity = (action_arg == CA_ARG_GRAVITY_OFF ? FALSE : + action_arg == CA_ARG_GRAVITY_ON ? TRUE : + action_arg == CA_ARG_GRAVITY_TOGGLE ? !game.gravity : + game.gravity); + break; + } + + case CA_SET_LEVEL_WIND: + { + game.wind_direction = action_arg_direction; + + break; + } + + case CA_SET_LEVEL_GEMS: { local_player->gems_still_needed = action_arg_number_new; @@ -6752,7 +6853,7 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) break; } - case CA_SET_TIME: + case CA_SET_LEVEL_TIME: { if (level.time > 0) /* only modify limited time value */ { @@ -6768,7 +6869,7 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) break; } - case CA_SET_SCORE: + case CA_SET_LEVEL_SCORE: { local_player->score = action_arg_number_new; @@ -6784,73 +6885,31 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page) break; } - case CA_SET_CE_COUNT: + case CA_SET_CE_VALUE: { -#if USE_NEW_COLLECT_COUNT - int count_last = Count[x][y]; +#if USE_NEW_CUSTOM_VALUE + int last_custom_value = CustomValue[x][y]; - Count[x][y] = action_arg_number_new; + CustomValue[x][y] = action_arg_number_new; #if 0 - printf("::: Count == %d\n", Count[x][y]); + printf("::: Count == %d\n", CustomValue[x][y]); #endif - if (Count[x][y] == 0 && count_last > 0) + if (CustomValue[x][y] == 0 && last_custom_value > 0) { #if 0 - printf("::: CE_COUNT_AT_ZERO\n"); + printf("::: CE_VALUE_GETS_ZERO\n"); #endif - CheckElementChange(x, y, element, EL_UNDEFINED, CE_COUNT_AT_ZERO); - CheckTriggeredElementChange(element, CE_COUNT_AT_ZERO_OF_X); + CheckElementChange(x, y, element, EL_UNDEFINED, CE_VALUE_GETS_ZERO); + CheckTriggeredElementChange(x, y, element, CE_VALUE_GETS_ZERO_OF_X); } #endif break; } - case CA_SET_DYNABOMB_NUMBER: - { - printf("::: CA_SET_DYNABOMB_NUMBER -- not yet implemented\n"); - - break; - } - - case CA_SET_DYNABOMB_SIZE: - { - printf("::: CA_SET_DYNABOMB_SIZE -- not yet implemented\n"); - - break; - } - - case CA_SET_DYNABOMB_POWER: - { - printf("::: CA_SET_DYNABOMB_POWER -- not yet implemented\n"); - - break; - } - - case CA_TOGGLE_PLAYER_GRAVITY: - { - game.gravity = !game.gravity; - - break; - } - - case CA_ENABLE_PLAYER_GRAVITY: - { - game.gravity = TRUE; - - break; - } - - case CA_DISABLE_PLAYER_GRAVITY: - { - game.gravity = FALSE; - - break; - } - default: break; } @@ -6860,6 +6919,9 @@ static void ChangeElementNowExt(struct ElementChangeInfo *change, int x, int y, int target_element) { int previous_move_direction = MovDir[x][y]; +#if USE_NEW_CUSTOM_VALUE + int last_ce_value = CustomValue[x][y]; +#endif boolean add_player = (ELEM_IS_PLAYER(target_element) && IS_WALKABLE(Feld[x][y])); @@ -6887,6 +6949,11 @@ static void ChangeElementNowExt(struct ElementChangeInfo *change, if (element_info[Feld[x][y]].move_direction_initial == MV_START_PREVIOUS) MovDir[x][y] = previous_move_direction; +#if USE_NEW_CUSTOM_VALUE + if (element_info[Feld[x][y]].use_last_ce_value) + CustomValue[x][y] = last_ce_value; +#endif + InitField_WithBug1(x, y, FALSE); DrawLevelField(x, y); @@ -6925,6 +6992,8 @@ static boolean ChangeElementNow(int x, int y, int element, int page) /* reset actual trigger element, trigger player and action element */ change->actual_trigger_element = EL_EMPTY; change->actual_trigger_player = EL_PLAYER_1; + change->actual_trigger_side = CH_SIDE_NONE; + change->actual_trigger_ce_value = 0; } #if 1 @@ -7069,7 +7138,7 @@ static boolean ChangeElementNow(int x, int y, int element, int page) } /* this uses direct change before indirect change */ - CheckTriggeredElementChangeByPage(old_element, CE_CHANGE_OF_X, page); + CheckTriggeredElementChangeByPage(x, y, old_element, CE_CHANGE_OF_X, page); return TRUE; } @@ -7247,7 +7316,8 @@ static void ChangeElement(int x, int y, int page) #endif -static boolean CheckTriggeredElementChangeExt(int trigger_element, +static boolean CheckTriggeredElementChangeExt(int x, int y, + int trigger_element, int trigger_event, int trigger_player, int trigger_side, @@ -7283,6 +7353,8 @@ static boolean CheckTriggeredElementChangeExt(int trigger_element, { change->actual_trigger_element = trigger_element; change->actual_trigger_player = EL_PLAYER_1 + log_2(trigger_player); + change->actual_trigger_side = trigger_side; + change->actual_trigger_ce_value = CustomValue[x][y]; if ((change->can_change && !change_done) || change->has_action) { @@ -7368,6 +7440,8 @@ static boolean CheckElementChangeExt(int x, int y, { change->actual_trigger_element = trigger_element; change->actual_trigger_player = EL_PLAYER_1 + log_2(trigger_player); + change->actual_trigger_side = trigger_side; + change->actual_trigger_ce_value = CustomValue[x][y]; if (change->can_change && !change_done) { @@ -7829,6 +7903,18 @@ void GameActions() RemoveField(x, y); } +#if USE_NEW_SNAP_DELAY + if (Feld[x][y] == EL_ELEMENT_SNAPPING) + { + MovDelay[x][y]--; + if (MovDelay[x][y] <= 0) + { + RemoveField(x, y); + DrawLevelField(x, y); + } + } +#endif + #if DEBUG if (ChangePage[x][y] != -1 && ChangeDelay[x][y] != 1) { @@ -7983,6 +8069,14 @@ void GameActions() CheckForDragon(x, y); else if (element == EL_EXPLOSION) ; /* drawing of correct explosion animation is handled separately */ + else if (element == EL_ELEMENT_SNAPPING) + { +#if 1 + graphic = el_act_dir2img(GfxElement[x][y], GfxAction[x][y],GfxDir[x][y]); + + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); +#endif + } else if (IS_ANIMATED(graphic) && !IS_CHANGING(x, y)) DrawLevelGraphicAnimationIfNeeded(x, y, graphic); @@ -8381,11 +8475,19 @@ boolean MovePlayerOneStep(struct PlayerInfo *player, player->MovDir = (dx < 0 ? MV_LEFT : dx > 0 ? MV_RIGHT : dy < 0 ? MV_UP : - dy > 0 ? MV_DOWN : MV_NO_MOVING); + dy > 0 ? MV_DOWN : MV_NONE); if (!IN_LEV_FIELD(new_jx, new_jy)) return MF_NO_ACTION; + if (player->cannot_move) + { + DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH); + SnapField(player, 0, 0); + + return MF_NO_ACTION; + } + if (!options.network && !AllPlayersInSight(player, new_jx, new_jy)) return MF_NO_ACTION; @@ -8470,7 +8572,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) player->move_delay = -1; /* set to "uninitialized" value */ /* store if player is automatically moved to next field */ - player->is_auto_moving = (player->programmed_action != MV_NO_MOVING); + player->is_auto_moving = (player->programmed_action != MV_NONE); /* remove the last programmed player action */ player->programmed_action = 0; @@ -8764,14 +8866,16 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) CE_LEFT_BY_PLAYER, player->index_bit, leave_side); - CheckTriggeredElementChangeByPlayer(old_element, CE_PLAYER_LEAVES_X, + CheckTriggeredElementChangeByPlayer(old_jx, old_jy, old_element, + CE_PLAYER_LEAVES_X, player->index_bit, leave_side); if (IS_CUSTOM_ELEMENT(new_element)) CheckElementChangeByPlayer(jx, jy, new_element, CE_ENTERED_BY_PLAYER, player->index_bit, enter_side); - CheckTriggeredElementChangeByPlayer(new_element, CE_PLAYER_ENTERS_X, + CheckTriggeredElementChangeByPlayer(jx, jy, new_element, + CE_PLAYER_ENTERS_X, player->index_bit, enter_side); } @@ -8843,7 +8947,7 @@ void ScrollScreen(struct PlayerInfo *player, int mode) redraw_mask |= REDRAW_FIELD; } else - ScreenMovDir = MV_NO_MOVING; + ScreenMovDir = MV_NONE; } void TestIfPlayerTouchesCustomElement(int x, int y) @@ -8899,7 +9003,8 @@ void TestIfPlayerTouchesCustomElement(int x, int y) CheckElementChangeByPlayer(xx, yy, border_element, CE_TOUCHED_BY_PLAYER, player->index_bit, border_side); - CheckTriggeredElementChangeByPlayer(border_element, CE_PLAYER_TOUCHES_X, + CheckTriggeredElementChangeByPlayer(xx, yy, border_element, + CE_PLAYER_TOUCHES_X, player->index_bit, border_side); } else if (IS_PLAYER(xx, yy)) @@ -8914,7 +9019,8 @@ void TestIfPlayerTouchesCustomElement(int x, int y) CheckElementChangeByPlayer(x, y, center_element, CE_TOUCHED_BY_PLAYER, player->index_bit, center_side); - CheckTriggeredElementChangeByPlayer(center_element, CE_PLAYER_TOUCHES_X, + CheckTriggeredElementChangeByPlayer(x, y, center_element, + CE_PLAYER_TOUCHES_X, player->index_bit, center_side); break; } @@ -9117,7 +9223,7 @@ void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir) continue; test_move_dir = - (IS_MOVING(test_x, test_y) ? MovDir[test_x][test_y] : MV_NO_MOVING); + (IS_MOVING(test_x, test_y) ? MovDir[test_x][test_y] : MV_NONE); test_element = MovingOrBlocked2ElementIfNotLeaving(test_x, test_y); @@ -9191,7 +9297,7 @@ void TestIfBadThingHitsGoodThing(int bad_x, int bad_y, int bad_move_dir) continue; test_move_dir = - (IS_MOVING(test_x, test_y) ? MovDir[test_x][test_y] : MV_NO_MOVING); + (IS_MOVING(test_x, test_y) ? MovDir[test_x][test_y] : MV_NONE); test_element = Feld[test_x][test_y]; @@ -9247,7 +9353,7 @@ void TestIfBadThingHitsGoodThing(int bad_x, int bad_y, int bad_move_dir) void TestIfPlayerTouchesBadThing(int x, int y) { - TestIfGoodThingHitsBadThing(x, y, MV_NO_MOVING); + TestIfGoodThingHitsBadThing(x, y, MV_NONE); } void TestIfPlayerRunsIntoBadThing(int x, int y, int move_dir) @@ -9257,7 +9363,7 @@ void TestIfPlayerRunsIntoBadThing(int x, int y, int move_dir) void TestIfBadThingTouchesPlayer(int x, int y) { - TestIfBadThingHitsGoodThing(x, y, MV_NO_MOVING); + TestIfBadThingHitsGoodThing(x, y, MV_NONE); } void TestIfBadThingRunsIntoPlayer(int x, int y, int move_dir) @@ -9267,12 +9373,12 @@ void TestIfBadThingRunsIntoPlayer(int x, int y, int move_dir) void TestIfFriendTouchesBadThing(int x, int y) { - TestIfGoodThingHitsBadThing(x, y, MV_NO_MOVING); + TestIfGoodThingHitsBadThing(x, y, MV_NONE); } void TestIfBadThingTouchesFriend(int x, int y) { - TestIfBadThingHitsGoodThing(x, y, MV_NO_MOVING); + TestIfBadThingHitsGoodThing(x, y, MV_NONE); } void TestIfBadThingTouchesOtherBadThing(int bad_x, int bad_y) @@ -9378,6 +9484,27 @@ void RemovePlayer(struct PlayerInfo *player) ExitY = ZY = jy; } +#if USE_NEW_SNAP_DELAY +static void setFieldForSnapping(int x, int y, int element, int direction) +{ + struct ElementInfo *ei = &element_info[element]; + int direction_bit = MV_DIR_BIT(direction); + int graphic_snapping = ei->direction_graphic[ACTION_SNAPPING][direction_bit]; + int action = (graphic_snapping != IMG_EMPTY_SPACE ? ACTION_SNAPPING : + IS_DIGGABLE(element) ? ACTION_DIGGING : ACTION_COLLECTING); + + Feld[x][y] = EL_ELEMENT_SNAPPING; + MovDelay[x][y] = MOVE_DELAY_NORMAL_SPEED + 1 - 1; + + ResetGfxAnimation(x, y); + + GfxElement[x][y] = element; + GfxAction[x][y] = action; + GfxDir[x][y] = direction; + GfxFrame[x][y] = -1; +} +#endif + /* ============================================================================= checkDiagonalPushing() @@ -9424,10 +9551,10 @@ int DigField(struct PlayerInfo *player, int jx = oldx, jy = oldy; int dx = x - jx, dy = y - jy; int nextx = x + dx, nexty = y + dy; - int move_direction = (dx == -1 ? MV_LEFT : + int move_direction = (dx == -1 ? MV_LEFT : dx == +1 ? MV_RIGHT : - dy == -1 ? MV_UP : - dy == +1 ? MV_DOWN : MV_NO_MOVING); + dy == -1 ? MV_UP : + dy == +1 ? MV_DOWN : MV_NONE); int opposite_direction = MV_DIR_OPPOSITE(move_direction); int dig_side = MV_DIR_OPPOSITE(move_direction); int old_element = Feld[jx][jy]; @@ -9472,18 +9599,24 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; /* field has no opening in this direction */ element = Feld[x][y]; -#if USE_NEW_COLLECT_COUNT - collect_count = Count[x][y]; +#if USE_NEW_CUSTOM_VALUE + +#if 1 + collect_count = element_info[element].collect_count_initial; +#else + collect_count = CustomValue[x][y]; +#endif + #else collect_count = element_info[element].collect_count_initial; #endif #if 0 if (element != EL_BLOCKED && - Count[x][y] != element_info[element].collect_count_initial) + CustomValue[x][y] != element_info[element].collect_count_initial) printf("::: %d: %d != %d\n", element, - Count[x][y], + CustomValue[x][y], element_info[element].collect_count_initial); #endif @@ -9592,11 +9725,18 @@ int DigField(struct PlayerInfo *player, PlayLevelSoundElementAction(x, y, element, ACTION_DIGGING); - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_DIGS_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_DIGS_X, player->index_bit, dig_side); if (mode == DF_SNAP) + { TestIfElementTouchesCustomElement(x, y); /* for empty space */ + +#if USE_NEW_SNAP_DELAY + if (level.block_snap_field) + setFieldForSnapping(x, y, element, move_direction); +#endif + } } else if (IS_COLLECTIBLE(element)) { @@ -9614,14 +9754,14 @@ int DigField(struct PlayerInfo *player, } else if (element == EL_EXTRA_TIME && level.time > 0) { - TimeLeft += 10; + TimeLeft += level.extra_time; DrawGameValue_Time(TimeLeft); } else if (element == EL_SHIELD_NORMAL || element == EL_SHIELD_DEADLY) { - player->shield_normal_time_left += 10; + player->shield_normal_time_left += level.shield_normal_time; if (element == EL_SHIELD_DEADLY) - player->shield_deadly_time_left += 10; + player->shield_deadly_time_left += level.shield_deadly_time; } else if (element == EL_DYNAMITE || element == EL_SP_DISK_RED) { @@ -9682,11 +9822,18 @@ int DigField(struct PlayerInfo *player, PlayLevelSoundElementAction(x, y, element, ACTION_COLLECTING); if (is_player) - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_COLLECTS_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_COLLECTS_X, player->index_bit, dig_side); if (mode == DF_SNAP) + { TestIfElementTouchesCustomElement(x, y); /* for empty space */ + +#if USE_NEW_SNAP_DELAY + if (level.block_snap_field) + setFieldForSnapping(x, y, element, move_direction); +#endif + } } else if (IS_PUSHABLE(element)) { @@ -9815,7 +9962,7 @@ int DigField(struct PlayerInfo *player, { CheckElementChangeByPlayer(x, y, element, CE_PUSHED_BY_PLAYER, player->index_bit, dig_side); - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_PUSHES_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_PUSHES_X, player->index_bit, dig_side); } } @@ -9823,7 +9970,7 @@ int DigField(struct PlayerInfo *player, { if (PLAYER_SWITCHING(player, x, y)) { - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_PRESSES_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_PRESSES_X, player->index_bit, dig_side); return MF_ACTION; @@ -9873,20 +10020,19 @@ int DigField(struct PlayerInfo *player, { ActivateTimegateSwitch(x, y); } - else if (element == EL_BALLOON_SWITCH_LEFT || + else if (element == EL_BALLOON_SWITCH_LEFT || element == EL_BALLOON_SWITCH_RIGHT || - element == EL_BALLOON_SWITCH_UP || - element == EL_BALLOON_SWITCH_DOWN || + element == EL_BALLOON_SWITCH_UP || + element == EL_BALLOON_SWITCH_DOWN || + element == EL_BALLOON_SWITCH_NONE || element == EL_BALLOON_SWITCH_ANY) { - if (element == EL_BALLOON_SWITCH_ANY) - game.balloon_dir = move_direction; - else - 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); + game.wind_direction = (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 : + element == EL_BALLOON_SWITCH_NONE ? MV_NONE : + move_direction); } else if (element == EL_LAMP) { @@ -9899,17 +10045,21 @@ int DigField(struct PlayerInfo *player, else if (element == EL_TIME_ORB_FULL) { Feld[x][y] = EL_TIME_ORB_EMPTY; - TimeLeft += 10; - DrawGameValue_Time(TimeLeft); + + if (level.time > 0 || level.use_time_orb_bug) + { + TimeLeft += level.time_orb_time; + DrawGameValue_Time(TimeLeft); + } ResetGfxAnimation(x, y); DrawLevelField(x, y); } - CheckTriggeredElementChangeByPlayer(element, CE_SWITCH_OF_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_SWITCH_OF_X, player->index_bit, dig_side); - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_PRESSES_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_PRESSES_X, player->index_bit, dig_side); return MF_ACTION; @@ -9924,13 +10074,13 @@ int DigField(struct PlayerInfo *player, CheckElementChangeByPlayer(x, y, element, CE_SWITCHED, player->index_bit, dig_side); - CheckTriggeredElementChangeByPlayer(element, CE_SWITCH_OF_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_SWITCH_OF_X, player->index_bit, dig_side); } CheckElementChangeByPlayer(x, y, element, CE_PRESSED_BY_PLAYER, player->index_bit, dig_side); - CheckTriggeredElementChangeByPlayer(element, CE_PLAYER_PRESSES_X, + CheckTriggeredElementChangeByPlayer(x, y, element, CE_PLAYER_PRESSES_X, player->index_bit, dig_side); return MF_NO_ACTION; @@ -9951,10 +10101,10 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) { int jx = player->jx, jy = player->jy; int x = jx + dx, y = jy + dy; - int snap_direction = (dx == -1 ? MV_LEFT : + int snap_direction = (dx == -1 ? MV_LEFT : dx == +1 ? MV_RIGHT : - dy == -1 ? MV_UP : - dy == +1 ? MV_DOWN : MV_NO_MOVING); + dy == -1 ? MV_UP : + dy == +1 ? MV_DOWN : MV_NONE); if (player->MovPos != 0 && game.engine_version >= VERSION_IDENT(2,2,0,0)) return FALSE; @@ -10099,7 +10249,8 @@ boolean DropElement(struct PlayerInfo *player) CheckElementChangeByPlayer(dropx, dropy, new_element, CE_DROPPED_BY_PLAYER, player->index_bit, drop_side); - CheckTriggeredElementChangeByPlayer(new_element, CE_PLAYER_DROPS_X, + CheckTriggeredElementChangeByPlayer(dropx, dropy, new_element, + CE_PLAYER_DROPS_X, player->index_bit, drop_side); TestIfElementTouchesCustomElement(dropx, dropy);