{ CE_OTHER_GETS_DIGGED, "player digs" },
{ CE_OTHER_GETS_COLLECTED, "player collects" },
{ CE_OTHER_GETS_DROPPED, "player drops" },
- { CE_OTHER_IS_TOUCHING, "touching" },
+ { CE_TOUCHING_ANY_SIDE_OF, "touching" },
+ { CE_TOUCHING_LEFT_OF, "touching left of" },
+ { CE_TOUCHING_RIGHT_OF, "touching right of" },
+ { CE_TOUCHING_TOP_OF, "touching top of" },
+ { CE_TOUCHING_BOTTOM_OF, "touching bottom of" },
{ CE_OTHER_IS_CHANGING, "change of" },
{ CE_OTHER_IS_EXPLODING, "explosion of" },
{ -1, NULL }
HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DIGGED) ? CE_OTHER_GETS_DIGGED :
HAS_CHANGE_EVENT(element, CE_OTHER_GETS_COLLECTED) ? CE_OTHER_GETS_COLLECTED :
HAS_CHANGE_EVENT(element, CE_OTHER_GETS_DROPPED) ? CE_OTHER_GETS_DROPPED :
- HAS_CHANGE_EVENT(element, CE_OTHER_IS_TOUCHING) ? CE_OTHER_IS_TOUCHING :
+ HAS_CHANGE_EVENT(element, CE_TOUCHING_ANY_SIDE_OF) ? CE_TOUCHING_ANY_SIDE_OF :
+ HAS_CHANGE_EVENT(element, CE_TOUCHING_LEFT_OF) ? CE_TOUCHING_LEFT_OF :
+ HAS_CHANGE_EVENT(element, CE_TOUCHING_RIGHT_OF) ? CE_TOUCHING_RIGHT_OF :
+ HAS_CHANGE_EVENT(element, CE_TOUCHING_TOP_OF) ? CE_TOUCHING_TOP_OF :
+ HAS_CHANGE_EVENT(element, CE_TOUCHING_BOTTOM_OF) ? CE_TOUCHING_BOTTOM_OF :
HAS_CHANGE_EVENT(element, CE_OTHER_IS_CHANGING) ? CE_OTHER_IS_CHANGING :
HAS_CHANGE_EVENT(element, CE_OTHER_IS_EXPLODING) ? CE_OTHER_IS_EXPLODING :
custom_element_change.other_action);
custom_element_change_events[CE_BY_DIRECT_ACTION];
/* set other element action change event from checkbox and selectbox */
- custom_element_change_events[CE_OTHER_IS_TOUCHING] = FALSE;
+ custom_element_change_events[CE_TOUCHING_ANY_SIDE_OF] = FALSE;
+ custom_element_change_events[CE_TOUCHING_LEFT_OF] = FALSE;
+ custom_element_change_events[CE_TOUCHING_RIGHT_OF] = FALSE;
+ custom_element_change_events[CE_TOUCHING_TOP_OF] = FALSE;
+ custom_element_change_events[CE_TOUCHING_BOTTOM_OF] = FALSE;
custom_element_change_events[CE_OTHER_IS_CHANGING] = FALSE;
custom_element_change_events[CE_OTHER_IS_EXPLODING] = FALSE;
custom_element_change_events[CE_OTHER_GETS_TOUCHED] = FALSE;
ei->change_events |= CH_EVENT_BIT(CE_DELAY);
}
+ /* set summarized change event CE_TOUCHING_ANY_SIDE_OF */
+ for (i=0; i < NUM_CUSTOM_ELEMENTS; i++)
+ {
+ struct ElementInfo *ei = &element_info[EL_CUSTOM_START + i];
+
+ for (j=0; j < ei->num_change_pages; j++)
+ {
+ if (!ei->change_page[j].can_change)
+ continue;
+
+ /* check for change event of touching other element on some side */
+ if (ei->change_page[j].events & (CH_EVENT_BIT(CE_TOUCHING_ANY_SIDE_OF |
+ CE_TOUCHING_LEFT_OF |
+ CE_TOUCHING_RIGHT_OF |
+ CE_TOUCHING_TOP_OF |
+ CE_TOUCHING_BOTTOM_OF)))
+ ei->change_page[j].events |= CH_EVENT_BIT(CE_TOUCHING_SOME_SIDE);
+
+ /* add change event for each side when event exists for any side */
+ if (ei->change_page[j].events & CH_EVENT_BIT(CE_TOUCHING_ANY_SIDE_OF))
+ ei->change_page[j].events |= (CH_EVENT_BIT(CE_TOUCHING_LEFT_OF) |
+ CH_EVENT_BIT(CE_TOUCHING_RIGHT_OF) |
+ CH_EVENT_BIT(CE_TOUCHING_TOP_OF) |
+ CH_EVENT_BIT(CE_TOUCHING_BOTTOM_OF));
+ }
+ }
+
#if 1
/* add change events from custom element configuration */
for (i=0; i < NUM_CUSTOM_ELEMENTS; i++)
player->is_digging = FALSE;
player->is_collecting = FALSE;
+ player->show_envelope = FALSE;
+
player->move_delay = game.initial_move_delay;
player->move_delay_value = game.initial_move_delay_value;
JustStopped[x][y] = 0;
Stop[x][y] = FALSE;
Pushed[x][y] = FALSE;
- Changed[x][y] = FALSE;
+
+ Changed[x][y] = CE_BITMASK_DEFAULT;
+ ChangeEvent[x][y] = CE_BITMASK_DEFAULT;
+
ExplodePhase[x][y] = 0;
ExplodeField[x][y] = EX_NO_EXPLOSION;
InitMovDir(x, y);
DrawLevelField(x, y);
+ TestIfElementTouchesCustomElement(x, y);
+
if (CAN_BE_CRUMBLED(element))
DrawLevelFieldCrumbledSandNeighbours(x, y);
/* copy element change control values to new field */
ChangeDelay[newx][newy] = ChangeDelay[x][y];
+ Changed[newx][newy] = Changed[x][y];
+ ChangeEvent[newx][newy] = ChangeEvent[x][y];
+
+ ChangeDelay[x][y] = 0;
+ Changed[x][y] = CE_BITMASK_DEFAULT;
+ ChangeEvent[x][y] = CE_BITMASK_DEFAULT;
/* copy animation control values to new field */
GfxFrame[newx][newy] = GfxFrame[x][y];
if (!IN_LEV_FIELD(nextx, nexty) || !IS_FREE(nextx, nexty))
CheckElementChange(newx, newy, element, CE_COLLISION);
+#if 1
+ TestIfElementTouchesCustomElement(x, y); /* for empty space */
+#endif
+
TestIfPlayerTouchesCustomElement(newx, newy);
TestIfElementTouchesCustomElement(newx, newy);
}
RemoveField(x, y);
Feld[x][y] = target_element;
- Changed[x][y] = TRUE; /* no more changes in this frame */
+ Changed[x][y] |= ChangeEvent[x][y]; /* ignore same changes in this frame */
ResetGfxAnimation(x, y);
ResetRandomAnimationValue(x, y);
{
struct ElementChangeInfo *change = &element_info[element].change_page[page];
- if (Changed[x][y]) /* do not change already changed elements */
+ /* always use default change event to prevent running into a loop */
+ if (ChangeEvent[x][y] == CE_BITMASK_DEFAULT)
+ ChangeEvent[x][y] = CH_EVENT_BIT(CE_DELAY);
+
+ /* do not change already changed elements with same change event */
+#if 0
+ if (Changed[x][y] & ChangeEvent[x][y])
+ return FALSE;
+#else
+ if (Changed[x][y])
return FALSE;
+#endif
- Changed[x][y] = TRUE; /* no more changes in this frame */
+ Changed[x][y] |= ChangeEvent[x][y]; /* ignore same changes in this frame */
CheckTriggeredElementChange(x, y, Feld[x][y], CE_OTHER_IS_CHANGING);
if (Feld[x][y] == element)
{
ChangeDelay[x][y] = 1;
+ ChangeEvent[x][y] = CH_EVENT_BIT(trigger_event);
ChangeElement(x, y, page);
#if 0
Blocked2Moving(x, y, &x, &y);
ChangeDelay[x][y] = 1;
+ ChangeEvent[x][y] = CH_EVENT_BIT(trigger_event);
ChangeElement(x, y, page);
return TRUE;
for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
{
- Changed[x][y] = FALSE;
+ Changed[x][y] = CE_BITMASK_DEFAULT;
+ ChangeEvent[x][y] = CE_BITMASK_DEFAULT;
Stop[x][y] = FALSE;
if (JustStopped[x][y] > 0)
stored_player[i].StepFrame += move_frames;
}
#endif
+
+#if 1
+ if (local_player->show_envelope && local_player->MovPos == 0)
+ {
+ ShowEnvelope();
+
+ local_player->show_envelope = FALSE;
+ }
+#endif
}
static boolean AllPlayersInSight(struct PlayerInfo *player, int x, int y)
DrawPlayer(player); /* needed here only to cleanup last field */
#endif
- if (player->MovPos == 0)
+ if (player->MovPos == 0) /* player reached destination field */
{
if (IS_PASSABLE(Feld[last_jx][last_jy]))
{
{ +1, 0 },
{ 0, +1 }
};
+ static int touching_side[4][2] =
+ {
+ { CE_TOUCHING_TOP_OF, CE_TOUCHING_BOTTOM_OF },
+ { CE_TOUCHING_LEFT_OF, CE_TOUCHING_RIGHT_OF },
+ { CE_TOUCHING_RIGHT_OF, CE_TOUCHING_LEFT_OF },
+ { CE_TOUCHING_BOTTOM_OF, CE_TOUCHING_TOP_OF }
+ };
boolean change_center_element = FALSE;
int center_element_change_page = 0;
+ int center_element_change_event = 0;
int center_element = Feld[x][y];
int i, j;
{
int xx = x + xy[i][0];
int yy = y + xy[i][1];
+ int change_event_center = touching_side[i][0];
+ int change_event_border = touching_side[i][1];
int border_element;
if (!IN_LEV_FIELD(xx, yy))
/* check for change of center element (but change it only once) */
if (IS_CUSTOM_ELEMENT(center_element) &&
- HAS_ANY_CHANGE_EVENT(center_element, CE_OTHER_IS_TOUCHING) &&
+ HAS_ANY_CHANGE_EVENT(center_element, change_event_border) &&
!change_center_element)
{
for (j=0; j < element_info[center_element].num_change_pages; j++)
struct ElementChangeInfo *change =
&element_info[center_element].change_page[j];
- if (change->events & CH_EVENT_BIT(CE_OTHER_IS_TOUCHING) &&
+ if (change->events & CH_EVENT_BIT(change_event_border) &&
change->trigger_element == border_element)
{
change_center_element = TRUE;
center_element_change_page = j;
+ center_element_change_event = change_event_border;
break;
}
/* check for change of border element */
if (IS_CUSTOM_ELEMENT(border_element) &&
- HAS_ANY_CHANGE_EVENT(border_element, CE_OTHER_IS_TOUCHING))
+ HAS_ANY_CHANGE_EVENT(border_element, change_event_center))
{
for (j=0; j < element_info[border_element].num_change_pages; j++)
{
struct ElementChangeInfo *change =
&element_info[border_element].change_page[j];
- if (change->events & CH_EVENT_BIT(CE_OTHER_IS_TOUCHING) &&
+ if (change->events & CH_EVENT_BIT(change_event_center) &&
change->trigger_element == center_element)
{
- CheckElementChangeExt(xx,yy, border_element,CE_OTHER_IS_TOUCHING, j);
+ CheckElementChangeExt(xx,yy, border_element, change_event_center, j);
break;
}
}
}
if (change_center_element)
- CheckElementChangeExt(x, y, center_element, CE_OTHER_IS_TOUCHING,
+ CheckElementChangeExt(x, y, center_element, center_element_change_event,
center_element_change_page);
#if 0
CheckTriggeredElementChange(x, y, element, CE_OTHER_GETS_DIGGED);
- TestIfElementTouchesCustomElement(x, y);
+ TestIfElementTouchesCustomElement(x, y); /* for empty space */
break;
}
}
else if (element == EL_ENVELOPE)
{
+#if 1
+ player->show_envelope = TRUE;
+#else
ShowEnvelope();
+#endif
}
else if (IS_DROPPABLE(element)) /* can be collected and dropped */
{
CheckTriggeredElementChange(x, y, element, CE_OTHER_GETS_COLLECTED);
- TestIfElementTouchesCustomElement(x, y);
+ TestIfElementTouchesCustomElement(x, y); /* for empty space */
break;
}