From c906ad88b3fc0442db3d3490c377b699a8206a8a Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 14 Jun 2003 14:18:40 +0200 Subject: [PATCH] rnd-20030614-2-src --- src/conftime.h | 2 +- src/editor.c | 30 +++++++-- src/game.c | 176 ++++++++++++++++++++++++++++++++++--------------- src/init.c | 8 +++ 4 files changed, 155 insertions(+), 61 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index a416ad13..c59d979b 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-06-14 02:58]" +#define COMPILE_DATE_STRING "[2003-06-14 14:14]" diff --git a/src/editor.c b/src/editor.c index 72042752..b9e1bd0a 100644 --- a/src/editor.c +++ b/src/editor.c @@ -3531,6 +3531,13 @@ static void CopyCustomElementPropertiesToEditor(int element) (HAS_CHANGE_EVENT(element, CE_SMASHED) ? CE_SMASHED : HAS_CHANGE_EVENT(element, CE_IMPACT) ? CE_IMPACT : CE_IMPACT); + + /* set change by other element action selectbox help value */ + value_change_other_action = + (HAS_CHANGE_EVENT(element, CE_OTHER_CHANGING) ? CE_OTHER_CHANGING : + HAS_CHANGE_EVENT(element, CE_OTHER_PUSHING) ? CE_OTHER_PUSHING : + HAS_CHANGE_EVENT(element, CE_OTHER_COLLECTING) ? CE_OTHER_COLLECTING : + CE_OTHER_COLLECTING); } static void CopyCustomElementPropertiesToGame(int element) @@ -3574,15 +3581,24 @@ static void CopyCustomElementPropertiesToGame(int element) custom_element_properties[EP_WALKABLE]; /* set player change event from checkbox and selectbox */ - custom_element.change.events &= ~CE_TOUCHED_BY_PLAYER; - custom_element.change.events &= ~CE_PRESSED_BY_PLAYER; - custom_element.change.events &= ~CE_PUSHED_BY_PLAYER; - custom_element.change.events |= value_change_player_action; + custom_element_change_events[CE_TOUCHED_BY_PLAYER] = FALSE; + custom_element_change_events[CE_PRESSED_BY_PLAYER] = FALSE; + custom_element_change_events[CE_PUSHED_BY_PLAYER] = FALSE; + custom_element_change_events[value_change_player_action] = + custom_element_change_events[CE_BY_PLAYER]; /* set player change event from checkbox and selectbox */ - custom_element.change.events &= ~CE_IMPACT; - custom_element.change.events &= ~CE_SMASHED; - custom_element.change.events |= value_change_impact_action; + custom_element_change_events[CE_IMPACT] = FALSE; + custom_element_change_events[CE_SMASHED] = FALSE; + custom_element_change_events[value_change_impact_action] = + custom_element_change_events[CE_IMPACT_SMASHED]; + + /* set other element action change event from checkbox and selectbox */ + custom_element_change_events[CE_OTHER_COLLECTING] = FALSE; + custom_element_change_events[CE_OTHER_PUSHING] = FALSE; + custom_element_change_events[CE_OTHER_CHANGING] = FALSE; + custom_element_change_events[value_change_other_action] = + custom_element_change_events[CE_BY_OTHER]; for (i=0; i < NUM_ELEMENT_PROPERTIES; i++) SET_PROPERTY(element, i, custom_element_properties[i]); diff --git a/src/game.c b/src/game.c index d0ffb3d2..2f6eb82f 100644 --- a/src/game.c +++ b/src/game.c @@ -114,6 +114,8 @@ static void CloseAllOpenTimegates(void); 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); @@ -2325,14 +2327,14 @@ void Impact(int x, int 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); } @@ -2367,11 +2369,20 @@ void Impact(int x, int y) 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 @@ -2417,7 +2428,7 @@ void Impact(int x, int y) { if (CAN_SMASH_PLAYER(element)) { - KillHeroUnlessProtected(x, y+1); + KillHeroUnlessProtected(x, y + 1); return; } } @@ -2484,40 +2495,45 @@ void Impact(int x, int y) } 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) { #if 1 - Feld[x][y+1] = EL_DIAMOND_BREAKING; + Feld[x][y + 1] = EL_DIAMOND_BREAKING; #else - Feld[x][y+1] = EL_EMPTY; + 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); } } } @@ -2525,12 +2541,12 @@ void Impact(int x, int y) /* 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; @@ -3145,7 +3161,7 @@ void StartMoving(int x, int y) 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; @@ -3158,7 +3174,7 @@ void StartMoving(int x, int y) 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; @@ -3171,8 +3187,8 @@ void StartMoving(int x, int y) } 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); @@ -3182,7 +3198,7 @@ void StartMoving(int x, int y) } } 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; @@ -3197,7 +3213,7 @@ void StartMoving(int x, int y) } 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; @@ -3205,7 +3221,7 @@ void StartMoving(int x, int y) 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; @@ -3218,14 +3234,14 @@ void StartMoving(int x, int y) } 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; @@ -3233,7 +3249,7 @@ void StartMoving(int x, int y) 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; @@ -3246,27 +3262,27 @@ void StartMoving(int x, int y) } 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); @@ -3277,15 +3293,15 @@ void StartMoving(int x, int 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) { @@ -3293,7 +3309,7 @@ void StartMoving(int x, int y) started_moving = TRUE; } } - else if (IS_FREE(x, y+1) || Feld[x][y+1] == EL_DIAMOND_BREAKING) + 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; @@ -3306,28 +3322,28 @@ void StartMoving(int x, int y) 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 = (x0 && IS_FREE(x-1, y)); boolean right_is_free = (x