{
for (y=0; y<lev_fieldy; y++)
{
- Feld[x][y] = Ur[x][y];
+ Feld[x][y] = level.field[x][y];
MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0;
ChangeDelay[x][y] = 0;
Store[x][y] = Store2[x][y] = StorePlayer[x][y] = Back[x][y] = 0;
JustStopped[x][y] = 0;
Stop[x][y] = FALSE;
Pushed[x][y] = FALSE;
+ Changing[x][y] = FALSE;
ExplodePhase[x][y] = 0;
ExplodeField[x][y] = EX_NO_EXPLOSION;
{
int center_element = Feld[ex][ey];
+#if 0
+ /* --- This is only really needed (and now handled) in "Impact()". --- */
+ /* do not explode moving elements that left the explode field in time */
+ if (game.engine_version >= RELEASE_IDENT(2,2,0,7) &&
+ center_element == EL_EMPTY && (mode == EX_NORMAL || mode == EX_CENTER))
+ return;
+#endif
+
+ if (mode == EX_NORMAL || mode == EX_CENTER)
+ PlaySoundLevelAction(ex, ey, ACTION_EXPLODING);
+
/* remove things displayed in background while burning dynamite */
- if (!IS_INDESTRUCTIBLE(Back[ex][ey]))
+ if (Back[ex][ey] != EL_EMPTY && !IS_INDESTRUCTIBLE(Back[ex][ey]))
Back[ex][ey] = 0;
if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
for (y = ey - 1; y <= ey + 1; y++) for(x = ex - 1; x <= ex + 1; x++)
{
+ int xx = x - ex + 1;
+ int yy = y - ey + 1;
int element;
if (!IN_LEV_FIELD(x, y) ||
if (IS_MOVING(x, y) || IS_BLOCKED(x, y))
{
element = MovingOrBlocked2Element(x, y);
- RemoveMovingField(x, y);
+
+ if (!IS_EXPLOSION_PROOF(element))
+ RemoveMovingField(x, y);
}
#if 1
+
+#if 0
if (IS_EXPLOSION_PROOF(element))
continue;
+#else
+ /* indestructible elements can only explode in center (but not flames) */
+ if ((IS_EXPLOSION_PROOF(element) && (x != ex || y != ey)) ||
+ element == EL_FLAMES)
+ continue;
+#endif
+
#else
if ((IS_INDESTRUCTIBLE(element) &&
(game.engine_version < VERSION_IDENT(2,2,0) ||
}
/* save walkable background elements while explosion on same tile */
+#if 0
if (IS_INDESTRUCTIBLE(element))
Back[x][y] = element;
+#else
+ if (IS_WALKABLE(element) && IS_INDESTRUCTIBLE(element))
+ Back[x][y] = element;
+#endif
/* ignite explodable elements reached by other explosion */
if (element == EL_EXPLOSION)
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];
+ Store[x][y] = level.yamyam_content[game.yamyam_content_nr][xx][yy];
+ else if (IS_CUSTOM_ELEMENT(center_element) &&
+ element_info[center_element].content[xx][yy] != EL_EMPTY)
+ Store[x][y] = element_info[center_element].content[xx][yy];
else if (element == EL_WALL_EMERALD)
Store[x][y] = EL_EMERALD;
else if (element == EL_WALL_DIAMOND)
Store[x][y] = EL_PEARL;
else if (element == EL_WALL_CRYSTAL)
Store[x][y] = EL_CRYSTAL;
+ else if (IS_CUSTOM_ELEMENT(element))
+ Store[x][y] = element_info[element].content[1][1];
else
Store[x][y] = EL_EMPTY;
InitMovDir(x, y);
DrawLevelField(x, y);
+ if (CAN_BE_CRUMBLED(element))
+ DrawLevelFieldCrumbledSandNeighbours(x, y);
+
if (IS_PLAYER(x, y) && !PLAYERINFO(x,y)->present)
StorePlayer[x][y] = 0;
}
Explode(x, y, EX_PHASE_START, EX_BORDER);
+ /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */
if (element != EL_EMPTY &&
element != EL_SAND &&
element != EL_EXPLOSION &&
player->element_nr);
}
+#if 0
#if 1
PlaySoundLevelAction(x, y, ACTION_EXPLODING);
#else
else
PlaySoundLevel(x, y, SND_ELEMENT_EXPLODING);
#endif
+#endif
#if 0
if (IS_PLAYER(x, y)) /* remove objects that might cause smaller explosion */
{
return (element == EL_INVISIBLE_STEELWALL ? EL_INVISIBLE_STEELWALL_ACTIVE :
element == EL_INVISIBLE_WALL ? EL_INVISIBLE_WALL_ACTIVE :
- EL_INVISIBLE_SAND_ACTIVE);
+ element == EL_INVISIBLE_SAND ? EL_INVISIBLE_SAND_ACTIVE :
+ element);
}
static int getInvisibleFromInvisibleActiveElement(int element)
{
return (element == EL_INVISIBLE_STEELWALL_ACTIVE ? EL_INVISIBLE_STEELWALL :
element == EL_INVISIBLE_WALL_ACTIVE ? EL_INVISIBLE_WALL :
- EL_INVISIBLE_SAND);
+ element == EL_INVISIBLE_SAND_ACTIVE ? EL_INVISIBLE_SAND :
+ element);
}
static void RedrawAllLightSwitchesAndInvisibleElements()
Feld[x][y] = EL_TIMEGATE_SWITCH_ACTIVE;
}
+inline static int getElementMoveStepsize(int x, int y)
+{
+ int element = Feld[x][y];
+ int direction = MovDir[x][y];
+ int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
+ int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
+ int horiz_move = (dx != 0);
+ int sign = (horiz_move ? dx : dy);
+ int step = sign * element_info[element].move_stepsize;
+
+ /* special values for move stepsize for spring and things on conveyor belt */
+ if (horiz_move)
+ {
+ if (CAN_FALL(element) &&
+ y < lev_fieldy - 1 && IS_BELT_ACTIVE(Feld[x][y + 1]))
+ step = sign * MOVE_STEPSIZE_NORMAL / 2;
+ else if (element == EL_SPRING)
+ step = sign * MOVE_STEPSIZE_NORMAL * 2;
+ }
+
+ return step;
+}
+
void Impact(int x, int y)
{
boolean lastline = (y == lev_fieldy-1);
object_hit = (!IS_FREE(x, y + 1) && (!IS_MOVING(x, y + 1) ||
MovDir[x][y + 1] != MV_DOWN ||
MovPos[x][y + 1] <= TILEY / 2));
+
+ /* do not smash moving elements that left the smashed field in time */
+ if (game.engine_version >= RELEASE_IDENT(2,2,0,7) && IS_MOVING(x, y + 1) &&
+ ABS(MovPos[x][y + 1] + getElementMoveStepsize(x, y + 1)) >= TILEX)
+ object_hit = FALSE;
+
if (object_hit)
smashed = MovingOrBlocked2Element(x, y + 1);
return;
}
#if 1
- else if (impact && CheckElementChange(x, y, element, ACTION_IMPACT))
+ else if (impact && CheckElementChange(x, y, element, CE_IMPACT))
{
PlaySoundLevelElementAction(x, y, element, ACTION_IMPACT);
Bang(x, y + 1);
return;
}
+#if 0
+ else if (CAN_SMASH_ENEMIES(element) && IS_CLASSIC_ENEMY(smashed))
+ {
+ Bang(x, y + 1);
+ return;
+ }
+#endif
else if (CAN_SMASH_EVERYTHING(element))
{
if (IS_CLASSIC_ENEMY(smashed) ||
if (Stop[x][y])
return;
- GfxAction[x][y] = ACTION_DEFAULT;
+ /* !!! this should be handled more generic (not only for mole) !!! */
+ if (element != EL_MOLE && GfxAction[x][y] != ACTION_DIGGING)
+ GfxAction[x][y] = ACTION_DEFAULT;
if (CAN_FALL(element) && y < lev_fieldy - 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));
- boolean right = (x<lev_fieldx-1 && IS_FREE(x+1, y) &&
- (IS_FREE(x+1, y + 1) || Feld[x+1][y + 1] == EL_ACID));
+ boolean can_fall_left = (x > 0 && IS_FREE(x - 1, y) &&
+ (IS_FREE(x - 1, y + 1) ||
+ Feld[x - 1][y + 1] == EL_ACID));
+ boolean can_fall_right = (x < lev_fieldx - 1 && IS_FREE(x + 1, y) &&
+ (IS_FREE(x + 1, y + 1) ||
+ Feld[x + 1][y + 1] == EL_ACID));
+ boolean can_fall_any = (can_fall_left || can_fall_right);
+ boolean can_fall_both = (can_fall_left && can_fall_right);
- if (left || right)
+ if (can_fall_any && IS_CUSTOM_ELEMENT(Feld[x][y + 1]))
{
- if (left && right &&
+ int slippery_type = element_info[Feld[x][y + 1]].slippery_type;
+
+ if (slippery_type == SLIPPERY_ONLY_LEFT)
+ can_fall_right = FALSE;
+ else if (slippery_type == SLIPPERY_ONLY_RIGHT)
+ can_fall_left = FALSE;
+ else if (slippery_type == SLIPPERY_ANY_LEFT_RIGHT && can_fall_both)
+ can_fall_right = FALSE;
+ else if (slippery_type == SLIPPERY_ANY_RIGHT_LEFT && can_fall_both)
+ can_fall_left = FALSE;
+
+ can_fall_any = (can_fall_left || can_fall_right);
+ can_fall_both = (can_fall_left && can_fall_right);
+ }
+
+ if (can_fall_any)
+ {
+ if (can_fall_both &&
(game.emulation != EMU_BOULDERDASH &&
element != EL_BD_ROCK && element != EL_BD_DIAMOND))
- left = !(right = RND(2));
+ can_fall_left = !(can_fall_right = RND(2));
- InitMovingField(x, y, left ? MV_LEFT : MV_RIGHT);
+ InitMovingField(x, y, can_fall_left ? MV_LEFT : MV_RIGHT);
started_moving = TRUE;
-
-#if 0
- if (element == EL_BOMB)
- printf("::: SLIP DOWN [%d]\n", FrameCounter);
-#endif
}
}
else if (IS_BELT_ACTIVE(Feld[x][y + 1]))
{
- boolean left_is_free = (x>0 && IS_FREE(x-1, y));
- boolean right_is_free = (x<lev_fieldx-1 && IS_FREE(x+1, y));
+ boolean left_is_free = (x > 0 && IS_FREE(x - 1, y));
+ boolean right_is_free = (x < lev_fieldx - 1 && IS_FREE(x + 1, y));
int belt_nr = getBeltNrFromBeltActiveElement(Feld[x][y + 1]);
int belt_dir = game.belt_dir[belt_nr];
return;
}
+#if 0
GfxAction[x][y] = ACTION_MOVING;
+#endif
}
/* now make next step */
{
Feld[newx][newy] = EL_AMOEBA_SHRINKING;
PlaySoundLevel(x, y, SND_MOLE_DIGGING);
+
+ ResetGfxAnimation(x, y);
+ GfxAction[x][y] = ACTION_DIGGING;
+ DrawLevelField(x, y);
+
MovDelay[newx][newy] = 0; /* start amoeba shrinking delay */
return; /* wait for shrinking amoeba */
}
TurnRound(x, y);
#if 1
- DrawLevelElementAnimation(x, y, element);
+ if (GFX_ELEMENT(element) != EL_SAND) /* !!! FIX THIS (crumble) !!! */
+ DrawLevelElementAnimation(x, y, element);
#else
if (element == EL_BUG ||
element == EL_SPACESHIP ||
int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
int newx = x + dx, newy = y + dy;
int nextx = newx + dx, nexty = newy + dy;
- int horiz_move = (dx != 0);
- int sign = (horiz_move ? dx : dy);
- int step = sign * element_info[element].move_stepsize;
boolean pushed = Pushed[x][y];
- /* special values for move stepsize for spring and things on conveyor belt */
- if (horiz_move)
- {
- if (CAN_FALL(element) &&
- y < lev_fieldy - 1 && IS_BELT_ACTIVE(Feld[x][y + 1]))
- step = sign * MOVE_STEPSIZE_NORMAL / 2;
- else if (element == EL_SPRING)
- step = sign * MOVE_STEPSIZE_NORMAL * 2;
- }
-
- MovPos[x][y] += step;
+ MovPos[x][y] += getElementMoveStepsize(x, y);
if (pushed) /* special case: moving object pushed by player */
MovPos[x][y] = SIGN(MovPos[x][y]) * (TILEX - ABS(PLAYERINFO(x,y)->MovPos));
if (!IN_LEV_FIELD(x, y))
return;
+ /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */
if (IS_FREE(x, y) ||
Feld[x][y] == EL_SAND || Feld[x][y] == EL_QUICKSAND_EMPTY)
{
if (!IN_LEV_FIELD(x, y))
continue;
+ /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */
if (IS_FREE(x, y) ||
Feld[x][y] == EL_SAND || Feld[x][y] == EL_QUICKSAND_EMPTY)
{
changed = TRUE;
}
}
+ /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */
else if (IS_FREE(xx, yy) || Feld[xx][yy] == EL_SAND)
{ /* free border field */
if (nachbarn >= life[2] && nachbarn <= life[3])
if (CAN_BE_CRUMBLED(Feld[x][y]))
DrawLevelFieldCrumbledSandNeighbours(x, y);
+
+ TestIfBadThingTouchesHero(x, y);
+ TestIfPlayerTouchesCustomElement(x, y);
+ TestIfElementTouchesCustomElement(x, y);
}
static void ChangeElementNow(int x, int y, int element)
{
struct ElementChangeInfo *change = &element_info[element].change;
+ /* prevent CheckTriggeredElementChange() from looping */
+ Changing[x][y] = TRUE;
+
CheckTriggeredElementChange(x, y, Feld[x][y], CE_OTHER_IS_CHANGING);
+ Changing[x][y] = FALSE;
+
if (change->explode)
{
Bang(x, y);
e = Feld[ex][ey];
+ if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
+ e = MovingOrBlocked2Element(ex, ey);
+
half_destructible = (IS_FREE(ex, ey) || IS_DIGGABLE(e));
if ((change->power <= CP_NON_DESTRUCTIVE && !IS_FREE(ex, ey)) ||
if (!change->only_complete || complete_change)
{
+ boolean something_has_changed = FALSE;
+
if (change->only_complete && change->use_random_change &&
- RND(change->random) != 0)
+ RND(100) < change->random)
return;
for (yy = 0; yy < 3; yy++) for(xx = 0; xx < 3 ; xx++)
int ey = y + yy - 1;
if (can_change[xx][yy] && (!change->use_random_change ||
- RND(change->random) == 0))
+ RND(100) < change->random))
{
+ if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
+ RemoveMovingField(ex, ey);
+
ChangeElementNowExt(ex, ey, change->content[xx][yy]);
+ something_has_changed = TRUE;
+
/* for symmetry reasons, stop newly created border elements */
if (ex != x || ey != y)
Stop[ex][ey] = TRUE;
}
}
- return;
+ if (something_has_changed)
+ PlaySoundLevelElementAction(x, y, element, ACTION_CHANGING);
}
}
+ else
+ {
+ ChangeElementNowExt(x, y, change->target_element);
- ChangeElementNowExt(x, y, change->target_element);
+ PlaySoundLevelElementAction(x, y, element, ACTION_CHANGING);
+ }
}
static void ChangeElement(int x, int y)
if (x == lx && y == ly) /* do not change trigger element itself */
continue;
+ if (Changing[x][y]) /* do not change just changing elements */
+ continue;
+
if (Feld[x][y] == i)
{
ChangeDelay[x][y] = 1;
GfxFrame[x][y]++;
+#if 1
+ /* reset finished pushing action (not done in ContinueMoving() to allow
+ continous pushing animation for elements without push delay) */
+ if (GfxAction[x][y] == ACTION_PUSHING && !IS_MOVING(x, y))
+ {
+ ResetGfxAnimation(x, y);
+ DrawLevelField(x, y);
+ }
+#endif
+
#if DEBUG
if (IS_BLOCKED(x, y))
{
#if 1
graphic = el_act_dir2img(element, GfxAction[x][y], MovDir[x][y]);
#if 0
- if (element == EL_PACMAN)
- printf("::: %d, %d, %d\n",
- IS_ANIMATED(graphic), IS_MOVING(x, y), Stop[x][y]);
+ if (element == EL_MOLE)
+ printf("::: %d, %d, %d [%d]\n",
+ IS_ANIMATED(graphic), IS_MOVING(x, y), Stop[x][y],
+ GfxAction[x][y]);
#endif
#if 0
if (element == EL_YAMYAM)
DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
#if 0
- if (element == EL_YAMYAM)
+ if (element == EL_MOLE)
printf("::: %d, %d\n", graphic, GfxFrame[x][y]);
#endif
}
#endif
element = Feld[x][y];
+ /* !!! extend EL_SAND to anything diggable (but maybe not SP_BASE) !!! */
if (!IS_PLAYER(x,y) &&
(element == EL_EMPTY ||
element == EL_SAND ||
(IN_LEV_FIELD(new_jx, new_jy) &&
(Feld[new_jx][new_jy] == EL_SP_BASE ||
Feld[new_jx][new_jy] == EL_SAND));
+ /* !!! extend EL_SAND to anything diggable !!! */
if (field_under_player_is_free &&
!player_is_moving_to_valid_field &&
if (Feld[last_jx][last_jy] == EL_EMPTY)
Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
+#if 0
DrawPlayer(player);
+#endif
return;
}
else if (!FrameReached(&player->actual_frame_counter, 1))
if (player->MovPos == 0)
CheckGravityMovement(player);
- DrawPlayer(player);
+#if 0
+ DrawPlayer(player); /* needed here only to cleanup last field */
+#endif
if (player->MovPos == 0)
{
void TestIfPlayerTouchesCustomElement(int x, int y)
{
+ static boolean check_changing = FALSE;
static int xy[4][2] =
{
{ 0, -1 },
boolean center_is_player = (IS_PLAYER(x, y));
int i;
+ /* prevent TestIfPlayerTouchesCustomElement() from looping */
+ if (check_changing)
+ return;
+
+ check_changing = TRUE;
+
for (i=0; i<4; i++)
{
int xx = x + xy[i][0];
break;
}
}
+
+ check_changing = FALSE;
}
void TestIfElementTouchesCustomElement(int x, int y)
{
+ static boolean check_changing = FALSE;
static int xy[4][2] =
{
{ 0, -1 },
boolean center_is_custom = (IS_CUSTOM_ELEMENT(Feld[x][y]));
int i;
+ /* prevent TestIfElementTouchesCustomElement() from looping */
+ if (check_changing)
+ return;
+
+ check_changing = TRUE;
+
for (i=0; i<4; i++)
{
int xx = x + xy[i][0];
CheckElementChange(xx, yy, Feld[xx][yy], CE_OTHER_IS_TOUCHING);
}
}
+
+ check_changing = FALSE;
}
void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir)
!IS_FREE(nextx, nexty))
return MF_NO_ACTION;
+ if (element == EL_SP_GRAVITY_PORT_LEFT ||
+ element == EL_SP_GRAVITY_PORT_RIGHT ||
+ element == EL_SP_GRAVITY_PORT_UP ||
+ element == EL_SP_GRAVITY_PORT_DOWN)
+ level.gravity = !level.gravity;
+
/* automatically move to the next field with double speed */
player->programmed_action = move_direction;
DOUBLE_PLAYER_SPEED(player);
if (mode != DF_SNAP)
{
+#if 1
+ GfxElement[x][y] = GFX_ELEMENT(element);
+#else
GfxElement[x][y] =
(CAN_BE_CRUMBLED(element) ? EL_SAND : GFX_ELEMENT(element));
+#endif
player->is_digging = TRUE;
}
PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING);
InitMovingField(x, y, move_direction);
+ GfxAction[x][y] = ACTION_PUSHING;
if (mode == DF_SNAP)
ContinueMoving(x, y);
else if (audio.music_available)
{
setup.sound = setup.sound_music = TRUE;
+
+ SetAudioMode(setup.sound);
PlayMusic(level_nr);
}
break;
if (setup.sound_loops)
setup.sound_loops = FALSE;
else if (audio.loops_available)
+ {
setup.sound = setup.sound_loops = TRUE;
+ SetAudioMode(setup.sound);
+ }
break;
case SOUND_CTRL_ID_SIMPLE:
if (setup.sound_simple)
setup.sound_simple = FALSE;
else if (audio.sound_available)
+ {
setup.sound = setup.sound_simple = TRUE;
+ SetAudioMode(setup.sound);
+ }
break;
default: