static void InitBeltMovement(void);
static void CloseAllOpenTimegates(void);
static void CheckGravityMovement(struct PlayerInfo *);
+static void CheckGravityMovementWhenNotMoving(struct PlayerInfo *);
static void KillHeroUnlessEnemyProtected(int, int);
static void KillHeroUnlessExplosionProtected(int, int);
static void TestIfPlayerTouchesCustomElement(int, int);
static void TestIfElementTouchesCustomElement(int, int);
static void TestIfElementHitsCustomElement(int, int, int);
+#if 0
+static void TestIfElementSmashesCustomElement(int, int, int);
+#endif
static void ChangeElement(int, int, int);
player->shield_normal_time_left = 0;
player->shield_deadly_time_left = 0;
+ player->inventory_infinite_element = EL_UNDEFINED;
player->inventory_size = 0;
DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH);
TimeFrames = 0;
TimePlayed = 0;
TimeLeft = level.time;
+ TapeTime = 0;
ScreenMovDir = MV_NO_MOVING;
ScreenMovPos = 0;
some_player->present = FALSE;
some_player->active = FALSE;
+#if 0
+ player->element_nr = some_player->element_nr;
+#endif
+
StorePlayer[jx][jy] = player->element_nr;
player->jx = player->last_jx = jx;
player->jy = player->last_jy = jy;
{
int center_element = Feld[ex][ey];
+#if 0
+ printf("::: start explosion %d,%d [%d]\n", ex, ey, FrameCounter);
+#endif
+
#if 0
/* --- This is only really needed (and now handled) in "Impact()". --- */
/* do not explode moving elements that left the explode field in time */
{
int element;
+#if 0
+ printf("::: explosion %d,%d done [%d]\n", x, y, FrameCounter);
+#endif
+
element = Feld[x][y] = Store[x][y];
Store[x][y] = Store2[x][y] = 0;
GfxElement[x][y] = EL_UNDEFINED;
}
else
{
+#if 0
+ TestIfElementSmashesCustomElement(x, y, MV_DOWN);
+#endif
+
CheckElementChange(x, y + 1, smashed, CE_SMASHED);
CheckTriggeredElementChangeSide(x, y + 1, smashed,
printf("::: player %d acts [%d]\n", player->index_nr, FrameCounter);
#endif
+#if 0
+ /* !!! TEST !!! */
+ CheckGravityMovement(player);
+#endif
if (button1)
snapped = SnapField(player, dx, dy);
else
DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH);
SnapField(player, 0, 0);
- CheckGravityMovement(player);
+ CheckGravityMovementWhenNotMoving(player);
if (player->MovPos == 0)
SetPlayerWaiting(player, TRUE);
DigField(player, 0, 0, 0, 0, 0, 0, DF_NO_PUSH);
SnapField(player, 0, 0);
- CheckGravityMovement(player);
+ CheckGravityMovementWhenNotMoving(player);
if (player->MovPos == 0)
InitPlayerGfxAnimation(player, ACTION_DEFAULT, player->MovDir);
recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
+#if 1
+ if (recorded_player_action != NULL)
+ for (i = 0; i < MAX_PLAYERS; i++)
+ stored_player[i].action = recorded_player_action[i];
+#endif
+
for (i = 0; i < MAX_PLAYERS; i++)
{
summarized_player_action |= stored_player[i].action;
{
int actual_player_action = stored_player[i].effective_action;
+#if 1
+ /* OLD: overwrite programmed action with tape action (BAD!!!) */
if (stored_player[i].programmed_action)
actual_player_action = stored_player[i].programmed_action;
+#endif
if (recorded_player_action)
+ {
+#if 0
+ if (stored_player[i].programmed_action &&
+ stored_player[i].programmed_action != recorded_player_action[i])
+ printf("::: %d: %d <-> %d\n", i,
+ stored_player[i].programmed_action, recorded_player_action[i]);
+#endif
+
+#if 0
actual_player_action = recorded_player_action[i];
+#endif
+ }
+
+#if 0
+ /* NEW: overwrite tape action with programmed action */
+ if (stored_player[i].programmed_action)
+ actual_player_action = stored_player[i].programmed_action;
+#endif
tape_action[i] = PlayerActions(&stored_player[i], actual_player_action);
if (TimeFrames >= FRAMES_PER_SECOND)
{
TimeFrames = 0;
- TimePlayed++;
+ TapeTime++;
- for (i = 0; i < MAX_PLAYERS; i++)
+ if (!level.use_step_counter)
{
- struct PlayerInfo *player = &stored_player[i];
+ TimePlayed++;
- if (SHIELD_ON(player))
+ for (i = 0; i < MAX_PLAYERS; i++)
{
- player->shield_normal_time_left--;
+ struct PlayerInfo *player = &stored_player[i];
- if (player->shield_deadly_time_left > 0)
- player->shield_deadly_time_left--;
- }
- }
+ if (SHIELD_ON(player))
+ {
+ player->shield_normal_time_left--;
- if (tape.recording || tape.playing)
- DrawVideoDisplay(VIDEO_STATE_TIME_ON, TimePlayed);
+ if (player->shield_deadly_time_left > 0)
+ player->shield_deadly_time_left--;
+ }
+ }
- if (TimeLeft > 0)
- {
- TimeLeft--;
+ if (TimeLeft > 0)
+ {
+ TimeLeft--;
- if (TimeLeft <= 10 && setup.time_limit)
- PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE);
+ if (TimeLeft <= 10 && setup.time_limit)
+ PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE);
- DrawGameValue_Time(TimeLeft);
+ DrawGameValue_Time(TimeLeft);
- if (!TimeLeft && setup.time_limit)
- for (i = 0; i < MAX_PLAYERS; i++)
- KillHero(&stored_player[i]);
+ if (!TimeLeft && setup.time_limit)
+ for (i = 0; i < MAX_PLAYERS; i++)
+ KillHero(&stored_player[i]);
+ }
+ else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */
+ DrawGameValue_Time(TimePlayed);
}
- else if (level.time == 0 && !AllPlayersGone) /* level without time limit */
- DrawGameValue_Time(TimePlayed);
+
+ if (tape.recording || tape.playing)
+ DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime);
}
DrawAllPlayers();
{
if (game.gravity && !player->programmed_action)
{
- int move_dir_vertical = player->action & (MV_UP | MV_DOWN);
- int move_dir_horizontal = player->action & (MV_LEFT | MV_RIGHT);
+ int move_dir_horizontal = player->action & MV_HORIZONTAL;
+ int move_dir_vertical = player->action & MV_VERTICAL;
int move_dir =
- (player->last_move_dir & (MV_LEFT | MV_RIGHT) ?
+ (player->last_move_dir & MV_HORIZONTAL ?
(move_dir_vertical ? move_dir_vertical : move_dir_horizontal) :
(move_dir_horizontal ? move_dir_horizontal : move_dir_vertical));
int jx = player->jx, jy = player->jy;
int dx = (move_dir & MV_LEFT ? -1 : move_dir & MV_RIGHT ? +1 : 0);
int dy = (move_dir & MV_UP ? -1 : move_dir & MV_DOWN ? +1 : 0);
int new_jx = jx + dx, new_jy = jy + dy;
- boolean field_under_player_is_free =
- (IN_LEV_FIELD(jx, jy + 1) && IS_FREE(jx, jy + 1));
+ boolean player_is_snapping = player->action & JOY_BUTTON_1;
+#if 0
+ /* !!! MAKE THIS CUSTOMIZABLE !!! */
+ boolean field_under_player_is_free_or_acid =
+ (IN_LEV_FIELD(jx, jy + 1) &&
+ (IS_FREE(jx, jy + 1) || Feld[jx][jy + 1] == EL_ACID));
+#else
+ boolean field_under_player_is_free_or_acid =
+ (IN_LEV_FIELD(jx, jy + 1) &&
+ (IS_FREE(jx, jy + 1)));
+#endif
boolean player_is_moving_to_valid_field =
- (IN_LEV_FIELD(new_jx, new_jy) &&
+ (
+#if 1
+ !player_is_snapping &&
+#endif
+ IN_LEV_FIELD(new_jx, new_jy) &&
(Feld[new_jx][new_jy] == EL_SP_BASE ||
Feld[new_jx][new_jy] == EL_SAND ||
(IS_SP_PORT(Feld[new_jx][new_jy]) &&
(IS_WALKABLE(Feld[jx][jy]) &&
!(element_info[Feld[jx][jy]].access_direction & MV_DOWN)));
- if (field_under_player_is_free &&
+#if 0
+ printf("::: checking gravity NOW [%d, %d, %d] [%d] ...\n",
+ field_under_player_is_free_or_acid,
+ player_is_standing_on_valid_field,
+ player_is_moving_to_valid_field,
+ (player_is_moving_to_valid_field ? Feld[new_jx][new_jy] : -1));
+#endif
+
+ if (field_under_player_is_free_or_acid &&
!player_is_standing_on_valid_field &&
!player_is_moving_to_valid_field)
+ {
+#if 0
+ printf("::: setting programmed_action to MV_DOWN [%d,%d - %d] ...\n",
+ jx, jy, FrameCounter);
+#endif
+
+ player->programmed_action = MV_DOWN;
+ }
+ }
+}
+
+static void CheckGravityMovementWhenNotMoving(struct PlayerInfo *player)
+{
+#if 1
+ return CheckGravityMovement(player);
+#endif
+
+ if (game.gravity && !player->programmed_action)
+ {
+ int jx = player->jx, jy = player->jy;
+ boolean field_under_player_is_free =
+ (IN_LEV_FIELD(jx, jy + 1) && IS_FREE(jx, jy + 1));
+ boolean player_is_standing_on_valid_field =
+ (IS_WALKABLE_INSIDE(Feld[jx][jy]) ||
+ (IS_WALKABLE(Feld[jx][jy]) &&
+ !(element_info[Feld[jx][jy]].access_direction & MV_DOWN)));
+
+ if (field_under_player_is_free && !player_is_standing_on_valid_field)
player->programmed_action = MV_DOWN;
}
}
!tape.playing)
return FALSE;
#else
+
+#if 1
+ if (!FrameReached(&player->move_delay, player->move_delay_value))
+ return FALSE;
+#else
if (!FrameReached(&player->move_delay, player->move_delay_value) &&
!(tape.playing && tape.file_version < FILE_VERSION_2_0))
return FALSE;
+#endif
+
#endif
/* remove the last programmed player action */
player->move_delay_value = original_move_delay_value;
}
- if (player->last_move_dir & (MV_LEFT | MV_RIGHT))
+ if (player->last_move_dir & MV_HORIZONTAL)
{
if (!(moved |= MovePlayerOneStep(player, 0, dy, dx, dy)))
moved |= MovePlayerOneStep(player, dx, 0, dx, dy);
}
else
{
- CheckGravityMovement(player);
+ CheckGravityMovementWhenNotMoving(player);
/*
player->last_move_dir = MV_NO_MOVING;
RemoveHero(player);
}
+ if (level.use_step_counter)
+ {
+ int i;
+
+ TimePlayed++;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+
+ if (SHIELD_ON(player))
+ {
+ player->shield_normal_time_left--;
+
+ if (player->shield_deadly_time_left > 0)
+ player->shield_deadly_time_left--;
+ }
+ }
+
+ if (TimeLeft > 0)
+ {
+ TimeLeft--;
+
+ if (TimeLeft <= 10 && setup.time_limit)
+ PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE);
+
+ DrawGameValue_Time(TimeLeft);
+
+ if (!TimeLeft && setup.time_limit)
+ for (i = 0; i < MAX_PLAYERS; i++)
+ KillHero(&stored_player[i]);
+ }
+ else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */
+ DrawGameValue_Time(TimePlayed);
+ }
+
if (tape.single_step && tape.recording && !tape.pausing &&
!player->programmed_action)
TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
}
}
+#if 0
+void TestIfElementSmashesCustomElement(int x, int y, int direction)
+{
+ int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
+ int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
+ int hitx = x + dx, hity = y + dy;
+ int hitting_element = Feld[x][y];
+#if 0
+ boolean object_hit = (IN_LEV_FIELD(hitx, hity) &&
+ !IS_FREE(hitx, hity) &&
+ (!IS_MOVING(hitx, hity) ||
+ MovDir[hitx][hity] != direction ||
+ ABS(MovPos[hitx][hity]) <= TILEY / 2));
+#endif
+
+ if (IN_LEV_FIELD(hitx, hity) && IS_FREE(hitx, hity))
+ return;
+
+#if 0
+ if (IN_LEV_FIELD(hitx, hity) && !object_hit)
+ return;
+#endif
+
+ CheckElementChangeSide(x, y, hitting_element, EP_CAN_SMASH_EVERYTHING,
+ direction);
+
+ if (IN_LEV_FIELD(hitx, hity))
+ {
+ int opposite_direction = MV_DIR_OPPOSITE(direction);
+ int hitting_side = direction;
+ int touched_side = opposite_direction;
+ int touched_element = MovingOrBlocked2Element(hitx, hity);
+#if 1
+ boolean object_hit = (!IS_MOVING(hitx, hity) ||
+ MovDir[hitx][hity] != direction ||
+ ABS(MovPos[hitx][hity]) <= TILEY / 2);
+
+ object_hit = TRUE;
+#endif
+
+ if (object_hit)
+ {
+ int i;
+
+ CheckElementChangeSide(hitx, hity, touched_element,
+ CE_SMASHED_BY_SOMETHING, opposite_direction);
+
+ if (IS_CUSTOM_ELEMENT(hitting_element) &&
+ HAS_ANY_CHANGE_EVENT(hitting_element, CE_OTHER_IS_SMASHING))
+ {
+ for (i = 0; i < element_info[hitting_element].num_change_pages; i++)
+ {
+ struct ElementChangeInfo *change =
+ &element_info[hitting_element].change_page[i];
+
+ if (change->can_change &&
+ change->events & CH_EVENT_BIT(CE_OTHER_IS_SMASHING) &&
+ change->trigger_side & touched_side &&
+
+#if 1
+ IS_EQUAL_OR_IN_GROUP(touched_element, change->trigger_element)
+#else
+ change->trigger_element == touched_element
+#endif
+ )
+ {
+ CheckElementChangePage(x, y, hitting_element, CE_OTHER_IS_SMASHING,
+ i);
+ break;
+ }
+ }
+ }
+
+ if (IS_CUSTOM_ELEMENT(touched_element) &&
+ HAS_ANY_CHANGE_EVENT(touched_element, CE_OTHER_GETS_SMASHED))
+ {
+ for (i = 0; i < element_info[touched_element].num_change_pages; i++)
+ {
+ struct ElementChangeInfo *change =
+ &element_info[touched_element].change_page[i];
+
+ if (change->can_change &&
+ change->events & CH_EVENT_BIT(CE_OTHER_GETS_SMASHED) &&
+ change->trigger_side & hitting_side &&
+#if 1
+ IS_EQUAL_OR_IN_GROUP(hitting_element, change->trigger_element)
+#else
+ change->trigger_element == hitting_element
+#endif
+ )
+ {
+ CheckElementChangePage(hitx, hity, touched_element,
+ CE_OTHER_GETS_SMASHED, i);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+#endif
+
void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir)
{
int i, kill_x = -1, kill_y = -1;
DOUBLE_PLAYER_SPEED(player);
#endif
+#if 0
+ printf("::: passing port %d,%d [%d]\n", x, y, FrameCounter);
+#endif
+
PlayLevelSound(x, y, SND_CLASS_SP_PORT_PASSING);
break;
{
int i;
- for (i = 0; i < element_info[element].collect_count; i++)
- if (player->inventory_size < MAX_INVENTORY_SIZE)
- player->inventory_element[player->inventory_size++] = element;
+ if (element_info[element].collect_count == 0)
+ player->inventory_infinite_element = element;
+ else
+ for (i = 0; i < element_info[element].collect_count; i++)
+ if (player->inventory_size < MAX_INVENTORY_SIZE)
+ player->inventory_element[player->inventory_size++] = element;
DrawGameValue_Dynamite(local_player->inventory_size);
}
{
int jx = player->jx, jy = player->jy;
int old_element = Feld[jx][jy];
- int new_element;
+ int new_element = (player->inventory_size > 0 ?
+ player->inventory_element[player->inventory_size - 1] :
+ player->inventory_infinite_element != EL_UNDEFINED ?
+ player->inventory_infinite_element :
+ player->dynabombs_left > 0 ?
+ EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr :
+ EL_UNDEFINED);
/* check if player is active, not moving and ready to drop */
if (!player->active || player->MovPos || player->drop_delay > 0)
return FALSE;
/* check if player has anything that can be dropped */
- if (player->inventory_size == 0 && player->dynabombs_left == 0)
+#if 1
+ if (new_element == EL_UNDEFINED)
return FALSE;
+#else
+ if (player->inventory_size == 0 &&
+ player->inventory_infinite_element == EL_UNDEFINED &&
+ player->dynabombs_left == 0)
+ return FALSE;
+#endif
/* check if anything can be dropped at the current position */
if (IS_ACTIVE_BOMB(old_element) || old_element == EL_EXPLOSION)
return FALSE;
/* collected custom elements can only be dropped on empty fields */
+#if 1
+ if (IS_CUSTOM_ELEMENT(new_element) && old_element != EL_EMPTY)
+ return FALSE;
+#else
if (player->inventory_size > 0 &&
IS_CUSTOM_ELEMENT(player->inventory_element[player->inventory_size - 1])
&& old_element != EL_EMPTY)
return FALSE;
+#endif
if (old_element != EL_EMPTY)
Back[jx][jy] = old_element; /* store old element on this field */
ResetGfxAnimation(jx, jy);
ResetRandomAnimationValue(jx, jy);
- if (player->inventory_size > 0)
+ if (player->inventory_size > 0 ||
+ player->inventory_infinite_element != EL_UNDEFINED)
{
- player->inventory_size--;
- new_element = player->inventory_element[player->inventory_size];
+ if (player->inventory_size > 0)
+ {
+ player->inventory_size--;
+
+#if 0
+ new_element = player->inventory_element[player->inventory_size];
+#endif
- if (new_element == EL_DYNAMITE)
- new_element = EL_DYNAMITE_ACTIVE;
- else if (new_element == EL_SP_DISK_RED)
- new_element = EL_SP_DISK_RED_ACTIVE;
+ DrawGameValue_Dynamite(local_player->inventory_size);
- Feld[jx][jy] = new_element;
+ if (new_element == EL_DYNAMITE)
+ new_element = EL_DYNAMITE_ACTIVE;
+ else if (new_element == EL_SP_DISK_RED)
+ new_element = EL_SP_DISK_RED_ACTIVE;
+ }
- DrawGameValue_Dynamite(local_player->inventory_size);
+ Feld[jx][jy] = new_element;
if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))
DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0);
else /* player is dropping a dyna bomb */
{
player->dynabombs_left--;
+
+#if 0
new_element = EL_DYNABOMB_PLAYER_1_ACTIVE + player->index_nr;
+#endif
Feld[jx][jy] = new_element;