+ }
+ }
+
+ if (kill_x != -1 || kill_y != -1)
+ {
+ if (IS_PLAYER(good_x, good_y))
+ {
+ struct PlayerInfo *player = PLAYERINFO(good_x, good_y);
+
+ if (player->shield_deadly_time_left > 0)
+ Bang(kill_x, kill_y);
+ else if (!PLAYER_PROTECTED(good_x, good_y))
+ KillHero(player);
+ }
+ else
+ Bang(good_x, good_y);
+ }
+}
+
+void TestIfBadThingHitsGoodThing(int bad_x, int bad_y, int bad_move_dir)
+{
+ int i, kill_x = -1, kill_y = -1;
+ int bad_element = Feld[bad_x][bad_y];
+ static int test_xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+ static int touch_dir[4] =
+ {
+ MV_LEFT | MV_RIGHT,
+ MV_UP | MV_DOWN,
+ MV_UP | MV_DOWN,
+ MV_LEFT | MV_RIGHT
+ };
+ static int test_dir[4] =
+ {
+ MV_UP,
+ MV_LEFT,
+ MV_RIGHT,
+ MV_DOWN
+ };
+
+ if (bad_element == EL_EXPLOSION) /* skip just exploding bad things */
+ return;
+
+ for (i = 0; i < 4; i++)
+ {
+ int test_x, test_y, test_move_dir, test_element;
+
+ test_x = bad_x + test_xy[i][0];
+ test_y = bad_y + test_xy[i][1];
+ if (!IN_LEV_FIELD(test_x, test_y))
+ continue;
+
+ test_move_dir =
+ (IS_MOVING(test_x, test_y) ? MovDir[test_x][test_y] : MV_NO_MOVING);
+
+ test_element = Feld[test_x][test_y];
+
+ /* 1st case: good thing is moving towards DONT_RUN_INTO style bad thing;
+ 2nd case: DONT_TOUCH style bad thing does not move away from good thing
+ */
+ if ((DONT_RUN_INTO(bad_element) && bad_move_dir == test_dir[i]) ||
+ (DONT_TOUCH(bad_element) && test_move_dir != test_dir[i]))
+ {
+ /* good thing is player or penguin that does not move away */
+ if (IS_PLAYER(test_x, test_y))
+ {
+ struct PlayerInfo *player = PLAYERINFO(test_x, test_y);
+
+ if (bad_element == EL_ROBOT && player->is_moving)
+ continue; /* robot does not kill player if he is moving */
+
+ if (game.engine_version >= VERSION_IDENT(3,0,7,0))
+ {
+ if (player->MovPos != 0 && !(player->MovDir & touch_dir[i]))
+ continue; /* center and border element do not touch */
+ }
+
+ kill_x = test_x;
+ kill_y = test_y;
+ break;
+ }
+ else if (test_element == EL_PENGUIN)
+ {
+ kill_x = test_x;
+ kill_y = test_y;
+ break;
+ }
+ }
+ }
+
+ if (kill_x != -1 || kill_y != -1)
+ {
+ if (IS_PLAYER(kill_x, kill_y))
+ {
+ struct PlayerInfo *player = PLAYERINFO(kill_x, kill_y);
+
+ if (player->shield_deadly_time_left > 0)
+ Bang(bad_x, bad_y);
+ else if (!PLAYER_PROTECTED(kill_x, kill_y))
+ KillHero(player);
+ }
+ else
+ Bang(kill_x, kill_y);
+ }
+}
+
+void TestIfHeroTouchesBadThing(int x, int y)
+{
+ TestIfGoodThingHitsBadThing(x, y, MV_NO_MOVING);
+}
+
+void TestIfHeroRunsIntoBadThing(int x, int y, int move_dir)
+{
+ TestIfGoodThingHitsBadThing(x, y, move_dir);
+}
+
+void TestIfBadThingTouchesHero(int x, int y)
+{
+ TestIfBadThingHitsGoodThing(x, y, MV_NO_MOVING);
+}
+
+void TestIfBadThingRunsIntoHero(int x, int y, int move_dir)
+{
+ TestIfBadThingHitsGoodThing(x, y, move_dir);
+}
+
+void TestIfFriendTouchesBadThing(int x, int y)
+{
+ TestIfGoodThingHitsBadThing(x, y, MV_NO_MOVING);
+}
+
+void TestIfBadThingTouchesFriend(int x, int y)
+{
+ TestIfBadThingHitsGoodThing(x, y, MV_NO_MOVING);
+}
+
+void TestIfBadThingTouchesOtherBadThing(int bad_x, int bad_y)
+{
+ int i, kill_x = bad_x, kill_y = bad_y;
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };