(condition) || \
(DONT_COLLIDE_WITH(e) && \
IS_PLAYER(x, y) && \
- !PLAYER_PROTECTED(x, y))))
+ !PLAYER_ENEMY_PROTECTED(x, y))))
#else
#define ELEMENT_CAN_ENTER_FIELD_GENERIC(e, x, y, condition) \
(IN_LEV_FIELD(x, y) && (IS_FREE(x, y) || \
static void InitBeltMovement(void);
static void CloseAllOpenTimegates(void);
static void CheckGravityMovement(struct PlayerInfo *);
-static void KillHeroUnlessProtected(int, int);
+static void KillHeroUnlessEnemyProtected(int, int);
+static void KillHeroUnlessExplosionProtected(int, int);
static void TestIfPlayerTouchesCustomElement(int, int);
static void TestIfElementTouchesCustomElement(int, int);
ChangeEvent[x][y] = CE_BITMASK_DEFAULT;
ExplodePhase[x][y] = 0;
+ ExplodeDelay[x][y] = 0;
ExplodeField[x][y] = EX_NO_EXPLOSION;
RunnerVisit[x][y] = 0;
emulate_sb ? EMU_SOKOBAN :
emulate_sp ? EMU_SUPAPLEX : EMU_NONE);
+ /* initialize explosion and ignition delay */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ if (!IS_CUSTOM_ELEMENT(i))
+ {
+ int num_phase = 9;
+ int delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2);
+ int last_phase = num_phase * delay;
+ int half_phase = (num_phase / 2) * delay;
+
+ element_info[i].explosion_delay = last_phase;
+ element_info[i].ignition_delay = half_phase;
+
+ if (i == EL_BLACK_ORB)
+ element_info[i].ignition_delay = 1;
+ }
+
+ if (element_info[i].explosion_delay < 2) /* !!! check again !!! */
+ element_info[i].explosion_delay = 2;
+
+ if (element_info[i].ignition_delay < 1) /* !!! check again !!! */
+ element_info[i].ignition_delay = 1;
+ }
+
/* correct non-moving belts to start moving left */
for (i = 0; i < 4; i++)
if (game.belt_dir[i] == MV_NO_MOVING)
int last_phase = num_phase * delay;
int half_phase = (num_phase / 2) * delay;
int first_phase_after_start = EX_PHASE_START + 1;
+ int border_element;
+
+ int last_phase_TEST = last_phase;
if (game.explosions_delayed)
{
Feld[ex][ey] = center_element;
}
+#if 1
+ last_phase = element_info[center_element].explosion_delay;
+#endif
+
for (y = ey - 1; y <= ey + 1; y++) for (x = ex - 1; x <= ex + 1; x++)
{
int xx = x - ex + 1;
RemoveField(x, y);
#endif
- if (IS_PLAYER(ex, ey) && !PLAYER_PROTECTED(ex, ey))
+ if (IS_PLAYER(ex, ey) && !PLAYER_EXPLOSION_PROTECTED(ex, ey))
{
switch(StorePlayer[ex][ey])
{
#endif
ExplodePhase[x][y] = 1;
+#if 1
+ ExplodeDelay[x][y] = last_phase;
+#endif
Stop[x][y] = TRUE;
}
x = ex;
y = ey;
+#if 1
+ last_phase = ExplodeDelay[x][y];
+#endif
+
ExplodePhase[x][y] = (phase < last_phase ? phase + 1 : 0);
#ifdef DEBUG
}
#endif
+#if 1
+
+ border_element = Store2[x][y];
+ if (IS_PLAYER(x, y))
+ border_element = StorePlayer[x][y];
+
+ if (phase == element_info[border_element].ignition_delay ||
+ phase == last_phase)
+ {
+ if (IS_PLAYER(x, y))
+ {
+ if (phase == 2)
+ printf("::: IS_PLAYER\n");
+
+ KillHeroUnlessExplosionProtected(x, y);
+ return;
+ }
+ else if (CAN_EXPLODE_BY_FIRE(border_element))
+ {
+ if (phase == 2)
+ printf("::: CAN_EXPLODE_BY_FIRE\n");
+
+ Feld[x][y] = Store2[x][y];
+ Store2[x][y] = 0;
+ Bang(x, y);
+ return;
+ }
+ else if (border_element == EL_AMOEBA_TO_DIAMOND)
+ {
+ if (phase == 2)
+ printf("::: EL_AMOEBA_TO_DIAMOND\n");
+
+ AmoebeUmwandeln(x, y);
+ return;
+ }
+ }
+
+ if (phase == last_phase)
+ {
+ int element;
+
+ element = Feld[x][y] = Store[x][y];
+ Store[x][y] = Store2[x][y] = 0;
+ GfxElement[x][y] = EL_UNDEFINED;
+
+ /* player can escape from explosions and might therefore be still alive */
+ if (element >= EL_PLAYER_IS_EXPLODING_1 &&
+ element <= EL_PLAYER_IS_EXPLODING_4)
+ Feld[x][y] = (stored_player[element - EL_PLAYER_IS_EXPLODING_1].active ?
+ EL_EMPTY :
+ element == EL_PLAYER_IS_EXPLODING_1 ? EL_EMERALD_YELLOW :
+ element == EL_PLAYER_IS_EXPLODING_2 ? EL_EMERALD_RED :
+ element == EL_PLAYER_IS_EXPLODING_3 ? EL_EMERALD :
+ EL_EMERALD_PURPLE);
+
+ /* restore probably existing indestructible background element */
+ 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] = 0;
+ GfxDir[x][y] = MV_NO_MOVING;
+ ChangeDelay[x][y] = 0;
+ ChangePage[x][y] = -1;
+
+ InitField(x, y, FALSE);
+#if 1
+ /* !!! not needed !!! */
+ if (CAN_MOVE(element))
+ InitMovDir(x, y);
+#endif
+ DrawLevelField(x, y);
+
+ TestIfElementTouchesCustomElement(x, y);
+
+ if (GFX_CRUMBLED(element))
+ DrawLevelFieldCrumbledSandNeighbours(x, y);
+
+ if (IS_PLAYER(x, y) && !PLAYERINFO(x,y)->present)
+ StorePlayer[x][y] = 0;
+
+ if (ELEM_IS_PLAYER(element))
+ RelocatePlayer(x, y, element);
+ }
+ else if (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 0
+ printf("::: %d ['%s'] -> %d\n", GfxElement[x][y],
+ element_info[GfxElement[x][y]].token_name,
+ graphic);
+#endif
+
+ if (phase == delay)
+ DrawLevelFieldCrumbledSand(x, y);
+
+ if (IS_WALKABLE_OVER(Back[x][y]) && Back[x][y] != EL_EMPTY)
+ {
+ DrawLevelElement(x, y, Back[x][y]);
+ DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame);
+ }
+ 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);
+ }
+
+#else
+
if (phase == first_phase_after_start)
{
int element = Store2[x][y];
int element = Store2[x][y];
if (IS_PLAYER(x, y))
- KillHeroUnlessProtected(x, y);
+ KillHeroUnlessExplosionProtected(x, y);
else if (CAN_EXPLODE_BY_FIRE(element))
{
Feld[x][y] = Store2[x][y];
else if (!IS_WALKABLE_INSIDE(Back[x][y]))
DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
}
+#endif
}
void DynaExplode(int ex, int ey)
#endif
#if 1
- if (IS_PLAYER(x, y) && !PLAYER_PROTECTED(x, y))
+ if (IS_PLAYER(x, y) && !PLAYER_EXPLOSION_PROTECTED(x, y))
#else
if (IS_PLAYER(x, y))
#endif
if (impact && element == EL_AMOEBA_DROP)
{
if (object_hit && IS_PLAYER(x, y + 1))
- KillHeroUnlessProtected(x, y + 1);
+ KillHeroUnlessEnemyProtected(x, y + 1);
else if (object_hit && smashed == EL_PENGUIN)
Bang(x, y + 1);
else
{
if (CAN_SMASH_PLAYER(element))
{
- KillHeroUnlessProtected(x, y + 1);
+ KillHeroUnlessEnemyProtected(x, y + 1);
return;
}
}
if (DONT_COLLIDE_WITH(element) &&
IN_LEV_FIELD(newx, newy) && IS_PLAYER(newx, newy) &&
- !PLAYER_PROTECTED(newx, newy))
+ !PLAYER_ENEMY_PROTECTED(newx, newy))
{
#if 1
TestIfBadThingRunsIntoHero(x, y, MovDir[x][y]);
#if 0
if (IN_LEV_FIELD(nextx, nexty))
{
- static int opposite_directions[] =
- {
- MV_RIGHT,
- MV_LEFT,
- MV_DOWN,
- MV_UP
- };
- int move_dir_bit = MV_DIR_BIT(direction);
- int opposite_direction = opposite_directions[move_dir_bit];
+ int opposite_direction = MV_DIR_OPPOSITE(direction);
int hitting_side = direction;
int touched_side = opposite_direction;
int touched_element = MovingOrBlocked2Element(nextx, nexty);
/* check if element under player changes from accessible to unaccessible
(needed for special case of dropping element which then changes) */
- if (IS_PLAYER(x, y) && !PLAYER_PROTECTED(x, y) &&
+ if (IS_PLAYER(x, y) && !PLAYER_EXPLOSION_PROTECTED(x, y) &&
IS_ACCESSIBLE(Feld[x][y]) && !IS_ACCESSIBLE(target_element))
{
Bang(x, y);
if (IN_LEV_FIELD(hitx, hity))
{
- static int opposite_directions[] =
- {
- MV_RIGHT,
- MV_LEFT,
- MV_DOWN,
- MV_UP
- };
- int move_dir_bit = MV_DIR_BIT(direction);
- int opposite_direction = opposite_directions[move_dir_bit];
+ int opposite_direction = MV_DIR_OPPOSITE(direction);
int hitting_side = direction;
int touched_side = opposite_direction;
int touched_element = MovingOrBlocked2Element(hitx, hity);
if (player->shield_deadly_time_left > 0)
Bang(kill_x, kill_y);
- else if (!PLAYER_PROTECTED(good_x, good_y))
+ else if (!PLAYER_ENEMY_PROTECTED(good_x, good_y))
KillHero(player);
}
else
if (player->shield_deadly_time_left > 0)
Bang(bad_x, bad_y);
- else if (!PLAYER_PROTECTED(kill_x, kill_y))
+ else if (!PLAYER_ENEMY_PROTECTED(kill_x, kill_y))
KillHero(player);
}
else
BuryHero(player);
}
-static void KillHeroUnlessProtected(int x, int y)
+static void KillHeroUnlessEnemyProtected(int x, int y)
+{
+ if (!PLAYER_ENEMY_PROTECTED(x, y))
+ KillHero(PLAYERINFO(x, y));
+}
+
+static void KillHeroUnlessExplosionProtected(int x, int y)
{
- if (!PLAYER_PROTECTED(x, y))
+ if (!PLAYER_EXPLOSION_PROTECTED(x, y))
KillHero(PLAYERINFO(x, y));
}