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);
{
Feld[x][y] = Ur[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;
AmoebaNr[x][y] = 0;
JustStopped[x][y] = 0;
MovPos[x][y] = 0;
MovDir[x][y] = 0;
MovDelay[x][y] = 0;
+ ChangeDelay[x][y] = 0;
}
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;
+ ChangeDelay[oldx][oldy] = ChangeDelay[newx][newy] = 0;
GfxAction[oldx][oldy] = GfxAction[newx][newy] = ACTION_DEFAULT;
DrawLevelField(oldx, oldy);
element = Feld[x][y] = Back[x][y];
Back[x][y] = 0;
- MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0;
+ MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = ChangeDelay[x][y] = 0;
InitField(x, y, FALSE);
if (CAN_MOVE(element))
InitMovDir(x, y);
if (!lastline) /* check if element below was hit */
{
- if (Feld[x][y+1] == EL_PLAYER_IS_LEAVING)
+ if (Feld[x][y + 1] == EL_PLAYER_IS_LEAVING)
return;
- object_hit = (!IS_FREE(x, y+1) && (!IS_MOVING(x, y+1) ||
- MovDir[x][y+1] != MV_DOWN ||
- MovPos[x][y+1] <= TILEY / 2));
+ object_hit = (!IS_FREE(x, y + 1) && (!IS_MOVING(x, y + 1) ||
+ MovDir[x][y + 1] != MV_DOWN ||
+ MovPos[x][y + 1] <= TILEY / 2));
if (object_hit)
- smashed = MovingOrBlocked2Element(x, y+1);
+ smashed = MovingOrBlocked2Element(x, y + 1);
+
+ impact = (lastline || object_hit);
}
if (!lastline && smashed == EL_ACID) /* element falls into acid */
Bang(x, y);
return;
}
- else if (element == EL_PEARL)
+ else if (impact && element == EL_PEARL)
{
Feld[x][y] = EL_PEARL_BREAKING;
PlaySoundLevel(x, y, SND_PEARL_BREAKING);
return;
}
+ else if (impact && CAN_CHANGE(element) &&
+ HAS_CHANGE_EVENT(element, CE_IMPACT))
+ {
+ PlaySoundLevelElementAction(x, y, element, ACTION_IMPACT);
+
+ ChangeElementDoIt(x, y, element_info[element].change.successor);
+
+ return;
+ }
if (impact && element == EL_AMOEBA_DROP)
{
- if (object_hit && IS_PLAYER(x, y+1))
- KillHeroUnlessProtected(x, y+1);
+ if (object_hit && IS_PLAYER(x, y + 1))
+ KillHeroUnlessProtected(x, y + 1);
else if (object_hit && smashed == EL_PENGUIN)
Bang(x, y + 1);
else
return;
}
+#if 1
+ if (object_hit) /* check which object was hit */
+#else
if (!lastline && object_hit) /* check which object was hit */
+#endif
{
if (CAN_PASS_MAGIC_WALL(element) &&
(smashed == EL_MAGIC_WALL ||
if (IS_PLAYER(x, y + 1))
{
- KillHeroUnlessProtected(x, y+1);
- return;
+ if (CAN_SMASH_PLAYER(element))
+ {
+ KillHeroUnlessProtected(x, y + 1);
+ return;
+ }
}
else if (smashed == EL_PENGUIN)
{
- Bang(x, y + 1);
- return;
+ if (CAN_SMASH_PLAYER(element))
+ {
+ Bang(x, y + 1);
+ return;
+ }
}
else if (element == EL_BD_DIAMOND)
{
Bang(x, y + 1);
return;
}
+#if 1
+ else if (CAN_SMASH_EVERYTHING(element))
+#else
else if (element == EL_ROCK ||
element == EL_SP_ZONK ||
element == EL_BD_ROCK)
+#endif
{
if (IS_CLASSIC_ENEMY(smashed) ||
+#if 1
+ CAN_EXPLODE_SMASHED(smashed))
+#else
smashed == EL_BOMB ||
smashed == EL_SP_DISK_ORANGE ||
smashed == EL_DX_SUPABOMB ||
smashed == EL_PIG ||
smashed == EL_DRAGON ||
smashed == EL_MOLE)
+#endif
{
Bang(x, y + 1);
return;
}
+#if 1
+ else if (!IS_MOVING(x, y + 1) && !IS_BLOCKED(x, y + 1))
+#else
else if (!IS_MOVING(x, y + 1))
+#endif
{
if (smashed == EL_LAMP ||
smashed == EL_LAMP_ACTIVE)
}
else if (smashed == EL_NUT)
{
- Feld[x][y+1] = EL_NUT_BREAKING;
+ Feld[x][y + 1] = EL_NUT_BREAKING;
PlaySoundLevel(x, y, SND_NUT_BREAKING);
RaiseScoreElement(EL_NUT);
return;
}
else if (smashed == EL_PEARL)
{
- Feld[x][y+1] = EL_PEARL_BREAKING;
+ Feld[x][y + 1] = EL_PEARL_BREAKING;
PlaySoundLevel(x, y, SND_PEARL_BREAKING);
return;
}
else if (smashed == EL_DIAMOND)
{
- Feld[x][y+1] = EL_EMPTY;
+#if 1
+ Feld[x][y + 1] = EL_DIAMOND_BREAKING;
+#else
+ Feld[x][y + 1] = EL_EMPTY;
+#endif
PlaySoundLevel(x, y, SND_DIAMOND_BREAKING);
return;
}
else if (IS_BELT_SWITCH(smashed))
{
- ToggleBeltSwitch(x, y+1);
+ ToggleBeltSwitch(x, y + 1);
}
else if (smashed == EL_SWITCHGATE_SWITCH_UP ||
smashed == EL_SWITCHGATE_SWITCH_DOWN)
{
- ToggleSwitchgateSwitch(x, y+1);
+ ToggleSwitchgateSwitch(x, y + 1);
}
else if (smashed == EL_LIGHT_SWITCH ||
smashed == EL_LIGHT_SWITCH_ACTIVE)
{
- ToggleLightSwitch(x, y+1);
+ ToggleLightSwitch(x, y + 1);
+ }
+ else if (CAN_CHANGE(smashed) &&
+ HAS_CHANGE_EVENT(smashed, CE_SMASHED))
+ {
+ ChangeElementDoIt(x, y + 1, element_info[smashed].change.successor);
}
}
}
/* play sound of magic wall / mill */
if (!lastline &&
- (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ||
- Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE))
+ (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE ||
+ Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE))
{
- if (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE)
+ if (Feld[x][y + 1] == EL_MAGIC_WALL_ACTIVE)
PlaySoundLevel(x, y, SND_MAGIC_WALL_FILLING);
- else if (Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE)
+ else if (Feld[x][y + 1] == EL_BD_MAGIC_WALL_ACTIVE)
PlaySoundLevel(x, y, SND_BD_MAGIC_WALL_FILLING);
return;
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;
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;
}
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;
#if 1
PlaySoundLevelAction(x, y, ACTION_FILLING);
}
}
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;
}
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;
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;
}
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;
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;
}
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_PASS_MAGIC_WALL(element) &&
- (Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ||
- Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE))
+ (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;
}
#if 0
- else if (CAN_SMASH(element) && Feld[x][y+1] == EL_ACID)
+ else if (CAN_SMASH(element) && Feld[x][y + 1] == EL_ACID)
#else
- else if (CAN_FALL(element) && Feld[x][y+1] == EL_ACID)
+ else if (CAN_FALL(element) && Feld[x][y + 1] == EL_ACID)
#endif
{
SplashAcid(x, y);
Store[x][y] = EL_ACID;
#if 0
/* !!! TEST !!! better use "_FALLING" etc. !!! */
- GfxAction[x][y+1] = ACTION_ACTIVE;
+ 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)
{
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;
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 = (x<lev_fieldx-1 && 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));
if (left || right)
{
started_moving = TRUE;
}
}
- else if (IS_BELT_ACTIVE(Feld[x][y+1]))
+ 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));
- int belt_nr = getBeltNrFromBeltActiveElement(Feld[x][y+1]);
+ int belt_nr = getBeltNrFromBeltActiveElement(Feld[x][y + 1]);
int belt_dir = game.belt_dir[belt_nr];
if ((belt_dir == MV_LEFT && left_is_free) ||
{
Feld[x][y] = EL_EMPTY;
Feld[newx][newy] = element;
+ MovPos[x][y] = 0; /* force "not moving" for "crumbled sand" */
if (element == EL_MOLE)
{
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 */
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)))
Impact(x, newy);
+#endif
}
else /* still moving on */
{
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)
static void InitTimegateWheel(int x, int y)
{
- MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND;
+ ChangeDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND;
}
static void RunTimegateWheel(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 ?
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)
DrawLevelFieldCrumbledSand(x, y);
}
+static void ChangeElementDoIt(int x, int y, int element)
+{
+ RemoveField(x, y);
+ Feld[x][y] = element;
+
+ 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);
+ }
+ }
+}
+
static void ChangeElement(int x, int y)
{
int element = Feld[x][y];
- if (IS_MOVING(x, y)) /* never change a running system :-) */
- return;
-
- if (MovDelay[x][y] == 0) /* initialize element change */
+ if (ChangeDelay[x][y] == 0) /* initialize element change */
{
- MovDelay[x][y] = changing_element[element].change_delay + 1;
+ ChangeDelay[x][y] = changing_element[element].change_delay + 1;
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;
- MovDelay[x][y] += RND(max_random_delay * delay_frames);
+ ChangeDelay[x][y] += RND(max_random_delay * delay_frames);
}
ResetGfxAnimation(x, y);
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)))
- DrawLevelElementAnimationIfNeeded(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;
ResetGfxAnimation(x, y);
ResetRandomAnimationValue(x, y);
-#if 1
InitField(x, y, FALSE);
- if (CAN_MOVE(element))
+ if (CAN_MOVE(Feld[x][y]))
InitMovDir(x, y);
-#endif
+
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);
}
continue;
}
+#if 1
+ /* this may take place after moving, so 'element' may have changed */
+ if (IS_AUTO_CHANGING(element))
+ {
+ ChangeElement(x, y);
+ element = Feld[x][y];
+ graphic = el_act_dir2img(element, GfxAction[x][y], MovDir[x][y]);
+ }
+#endif
+
if (!IS_MOVING(x, y) && (CAN_FALL(element) || CAN_MOVE(element)))
{
StartMoving(x, y);
else if (IS_ANIMATED(graphic) && !IS_AUTO_CHANGING(element))
DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
-#if 1
- /* this may take place after moving, therefore element may have changed */
+#if 0
+ /* this may take place after moving, so 'element' may have changed */
if (IS_AUTO_CHANGING(Feld[x][y]))
ChangeElement(x, y);
#endif