+ /* copy properties to some elements that are only stored in level file */
+ for (i = 0; i < NUM_ELEMENT_PROPERTIES; i++)
+ for (j = 0; copy_properties[j][0] != -1; j++)
+ if (HAS_PROPERTY(copy_properties[j][0], i))
+ for (k = 1; k <= 4; k++)
+ SET_PROPERTY(copy_properties[j][k], i, TRUE);
+
+ /* set static element properties that are not listed in array definitions */
+ for (i = EL_STEEL_CHAR_START; i <= EL_STEEL_CHAR_END; i++)
+ SET_PROPERTY(i, EP_INDESTRUCTIBLE, TRUE);
+}
+
+void InitElementPropertiesEngine(int engine_version)
+{
+ static int no_wall_properties[] =
+ {
+ EP_DIGGABLE,
+ EP_COLLECTIBLE_ONLY,
+ EP_DONT_RUN_INTO,
+ EP_DONT_COLLIDE_WITH,
+ EP_CAN_MOVE,
+ EP_CAN_FALL,
+ EP_CAN_SMASH_PLAYER,
+ EP_CAN_SMASH_ENEMIES,
+ EP_CAN_SMASH_EVERYTHING,
+ EP_PUSHABLE,
+
+ EP_PLAYER,
+ EP_GEM,
+ EP_FOOD_DARK_YAMYAM,
+ EP_FOOD_PENGUIN,
+ EP_BELT,
+ EP_BELT_ACTIVE,
+ EP_TUBE,
+ EP_AMOEBOID,
+ EP_AMOEBALIVE,
+ EP_ACTIVE_BOMB,
+
+ EP_ACCESSIBLE,
+
+ -1
+ };
+
+ int i, j;
+
+ /* important: after initialization in InitElementPropertiesStatic(), the
+ elements are not again initialized to a default value; therefore all
+ changes have to make sure that they leave the element with a defined
+ property (which means that conditional property changes must be set to
+ a reliable default value before) */
+
+ /* resolve group elements */
+ for (i = 0; i < NUM_GROUP_ELEMENTS; i++)
+ ResolveGroupElement(EL_GROUP_START + i);
+
+ /* set all special, combined or engine dependent element properties */
+ for (i = 0; i < MAX_NUM_ELEMENTS; i++)
+ {
+ /* ---------- INACTIVE ------------------------------------------------- */
+ SET_PROPERTY(i, EP_INACTIVE, ((i >= EL_CHAR_START &&
+ i <= EL_CHAR_END) ||
+ (i >= EL_STEEL_CHAR_START &&
+ i <= EL_STEEL_CHAR_END)));
+
+ /* ---------- WALKABLE, PASSABLE, ACCESSIBLE --------------------------- */
+ SET_PROPERTY(i, EP_WALKABLE, (IS_WALKABLE_OVER(i) ||
+ IS_WALKABLE_INSIDE(i) ||
+ IS_WALKABLE_UNDER(i)));
+
+ SET_PROPERTY(i, EP_PASSABLE, (IS_PASSABLE_OVER(i) ||
+ IS_PASSABLE_INSIDE(i) ||
+ IS_PASSABLE_UNDER(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE_OVER, (IS_WALKABLE_OVER(i) ||
+ IS_PASSABLE_OVER(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE_INSIDE, (IS_WALKABLE_INSIDE(i) ||
+ IS_PASSABLE_INSIDE(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE_UNDER, (IS_WALKABLE_UNDER(i) ||
+ IS_PASSABLE_UNDER(i)));
+
+ SET_PROPERTY(i, EP_ACCESSIBLE, (IS_WALKABLE(i) ||
+ IS_PASSABLE(i)));
+
+ /* ---------- COLLECTIBLE ---------------------------------------------- */
+ SET_PROPERTY(i, EP_COLLECTIBLE, (IS_COLLECTIBLE_ONLY(i) ||
+ IS_DROPPABLE(i) ||
+ IS_THROWABLE(i)));
+
+ /* ---------- SNAPPABLE ------------------------------------------------ */
+ SET_PROPERTY(i, EP_SNAPPABLE, (IS_DIGGABLE(i) ||
+ IS_COLLECTIBLE(i) ||
+ IS_SWITCHABLE(i) ||
+ i == EL_BD_ROCK));
+
+ /* ---------- WALL ----------------------------------------------------- */
+ SET_PROPERTY(i, EP_WALL, TRUE); /* default: element is wall */
+
+ for (j = 0; no_wall_properties[j] != -1; j++)
+ if (HAS_PROPERTY(i, no_wall_properties[j]) ||
+ i >= EL_FIRST_RUNTIME_UNREAL)
+ SET_PROPERTY(i, EP_WALL, FALSE);
+
+ if (IS_HISTORIC_WALL(i))
+ SET_PROPERTY(i, EP_WALL, TRUE);
+
+ /* ---------- SOLID_FOR_PUSHING ---------------------------------------- */
+ if (engine_version < VERSION_IDENT(2,2,0,0))
+ SET_PROPERTY(i, EP_SOLID_FOR_PUSHING, IS_HISTORIC_SOLID(i));
+ else
+ SET_PROPERTY(i, EP_SOLID_FOR_PUSHING, (!IS_WALKABLE(i) &&
+ !IS_DIGGABLE(i) &&
+ !IS_COLLECTIBLE(i)));
+
+ /* ---------- DRAGONFIRE_PROOF ----------------------------------------- */
+ if (IS_HISTORIC_SOLID(i) || i == EL_EXPLOSION)
+ SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, TRUE);
+ else
+ SET_PROPERTY(i, EP_DRAGONFIRE_PROOF, (IS_CUSTOM_ELEMENT(i) &&
+ IS_INDESTRUCTIBLE(i)));
+
+ /* ---------- EXPLOSION_PROOF ------------------------------------------ */
+ if (i == EL_FLAMES)
+ SET_PROPERTY(i, EP_EXPLOSION_PROOF, TRUE);
+ else if (engine_version < VERSION_IDENT(2,2,0,0))
+ SET_PROPERTY(i, EP_EXPLOSION_PROOF, IS_INDESTRUCTIBLE(i));
+ else
+ SET_PROPERTY(i, EP_EXPLOSION_PROOF, (IS_INDESTRUCTIBLE(i) &&
+ (!IS_WALKABLE(i) ||
+ IS_PROTECTED(i))));
+
+ if (IS_CUSTOM_ELEMENT(i))
+ {
+ /* these are additional properties which are initially false when set */
+
+ /* ---------- DONT_COLLIDE_WITH / DONT_RUN_INTO ---------------------- */
+ if (DONT_TOUCH(i))
+ SET_PROPERTY(i, EP_DONT_COLLIDE_WITH, TRUE);
+ if (DONT_COLLIDE_WITH(i))
+ SET_PROPERTY(i, EP_DONT_RUN_INTO, TRUE);
+
+ /* ---------- CAN_SMASH_ENEMIES / CAN_SMASH_PLAYER ------------------- */
+ if (CAN_SMASH_EVERYTHING(i))
+ SET_PROPERTY(i, EP_CAN_SMASH_ENEMIES, TRUE);
+ if (CAN_SMASH_ENEMIES(i))
+ SET_PROPERTY(i, EP_CAN_SMASH_PLAYER, TRUE);
+ }
+
+ /* ---------- CAN_SMASH ------------------------------------------------ */
+ SET_PROPERTY(i, EP_CAN_SMASH, (CAN_SMASH_PLAYER(i) ||
+ CAN_SMASH_ENEMIES(i) ||
+ CAN_SMASH_EVERYTHING(i)));
+
+ /* ---------- CAN_EXPLODE_BY_FIRE -------------------------------------- */
+ SET_PROPERTY(i, EP_CAN_EXPLODE_BY_FIRE, (CAN_EXPLODE(i) &&
+ EXPLODES_BY_FIRE(i)));
+
+ /* ---------- CAN_EXPLODE_SMASHED -------------------------------------- */
+ SET_PROPERTY(i, EP_CAN_EXPLODE_SMASHED, (CAN_EXPLODE(i) &&
+ EXPLODES_SMASHED(i)));
+
+ /* ---------- CAN_EXPLODE_IMPACT --------------------------------------- */
+ SET_PROPERTY(i, EP_CAN_EXPLODE_IMPACT, (CAN_EXPLODE(i) &&
+ EXPLODES_IMPACT(i)));
+
+ /* ---------- CAN_EXPLODE_BY_DRAGONFIRE -------------------------------- */
+ SET_PROPERTY(i, EP_CAN_EXPLODE_BY_DRAGONFIRE, CAN_EXPLODE_BY_FIRE(i));
+
+ /* ---------- CAN_EXPLODE_BY_EXPLOSION --------------------------------- */
+ SET_PROPERTY(i, EP_CAN_EXPLODE_BY_EXPLOSION, (CAN_EXPLODE_BY_FIRE(i) ||
+ i == EL_BLACK_ORB));
+
+ /* ---------- COULD_MOVE_INTO_ACID ------------------------------------- */
+ SET_PROPERTY(i, EP_COULD_MOVE_INTO_ACID, (ELEM_IS_PLAYER(i) ||
+ CAN_MOVE(i) ||
+ IS_CUSTOM_ELEMENT(i)));
+
+ /* ---------- MAYBE_DONT_COLLIDE_WITH ---------------------------------- */
+ SET_PROPERTY(i, EP_MAYBE_DONT_COLLIDE_WITH, (i == EL_SP_SNIKSNAK ||
+ i == EL_SP_ELECTRON));
+
+ /* ---------- CAN_MOVE_INTO_ACID --------------------------------------- */
+ if (COULD_MOVE_INTO_ACID(i) && !IS_CUSTOM_ELEMENT(i))
+ SET_PROPERTY(i, EP_CAN_MOVE_INTO_ACID,
+ getMoveIntoAcidProperty(&level, i));
+
+ /* ---------- DONT_COLLIDE_WITH ---------------------------------------- */
+ if (MAYBE_DONT_COLLIDE_WITH(i))
+ SET_PROPERTY(i, EP_DONT_COLLIDE_WITH,
+ getDontCollideWithProperty(&level, i));
+
+ /* ---------- SP_PORT -------------------------------------------------- */
+ SET_PROPERTY(i, EP_SP_PORT, (IS_SP_ELEMENT(i) &&
+ IS_PASSABLE_INSIDE(i)));
+
+ /* ---------- CAN_BE_CLONED_BY_ANDROID --------------------------------- */
+ for (j = 0; j < level.num_android_clone_elements; j++)
+ SET_PROPERTY(i, EP_CAN_BE_CLONED_BY_ANDROID,
+ (i != EL_EMPTY &&
+ IS_EQUAL_OR_IN_GROUP(i, level.android_clone_element[j])));
+
+ /* ---------- CAN_CHANGE ----------------------------------------------- */
+ SET_PROPERTY(i, EP_CAN_CHANGE, FALSE); /* default: cannot change */
+ for (j = 0; j < element_info[i].num_change_pages; j++)
+ if (element_info[i].change_page[j].can_change)
+ SET_PROPERTY(i, EP_CAN_CHANGE, TRUE);
+
+ /* ---------- HAS_ACTION ----------------------------------------------- */
+ SET_PROPERTY(i, EP_HAS_ACTION, FALSE); /* default: has no action */
+ for (j = 0; j < element_info[i].num_change_pages; j++)
+ if (element_info[i].change_page[j].has_action)
+ SET_PROPERTY(i, EP_HAS_ACTION, TRUE);
+
+ /* ---------- CAN_CHANGE_OR_HAS_ACTION --------------------------------- */
+ SET_PROPERTY(i, EP_CAN_CHANGE_OR_HAS_ACTION, (CAN_CHANGE(i) ||
+ HAS_ACTION(i)));
+
+ /* ---------- GFX_CRUMBLED --------------------------------------------- */
+#if 1
+ SET_PROPERTY(i, EP_GFX_CRUMBLED,
+ element_info[i].crumbled[ACTION_DEFAULT] !=
+ element_info[i].graphic[ACTION_DEFAULT]);
+#else
+ /* !!! THIS LOOKS CRAPPY FOR SAND ETC. WITHOUT CRUMBLED GRAPHICS !!! */
+ SET_PROPERTY(i, EP_GFX_CRUMBLED,
+ element_info[i].crumbled[ACTION_DEFAULT] != IMG_EMPTY);
+#endif
+
+ /* ---------- EDITOR_CASCADE ------------------------------------------- */
+ SET_PROPERTY(i, EP_EDITOR_CASCADE, (IS_EDITOR_CASCADE_ACTIVE(i) ||
+ IS_EDITOR_CASCADE_INACTIVE(i)));
+ }
+
+ /* dynamically adjust element properties according to game engine version */
+ {
+ static int ep_em_slippery_wall[] =
+ {
+ EL_WALL,
+ EL_STEELWALL,
+ EL_EXPANDABLE_WALL,
+ EL_EXPANDABLE_WALL_HORIZONTAL,
+ EL_EXPANDABLE_WALL_VERTICAL,
+ EL_EXPANDABLE_WALL_ANY,
+ EL_EXPANDABLE_STEELWALL_HORIZONTAL,
+ EL_EXPANDABLE_STEELWALL_VERTICAL,
+ EL_EXPANDABLE_STEELWALL_ANY,
+ EL_EXPANDABLE_STEELWALL_GROWING,
+ -1
+ };
+
+ /* special EM style gems behaviour */
+ for (i = 0; ep_em_slippery_wall[i] != -1; i++)
+ SET_PROPERTY(ep_em_slippery_wall[i], EP_EM_SLIPPERY_WALL,
+ level.em_slippery_gems);
+
+ /* "EL_EXPANDABLE_WALL_GROWING" wasn't slippery for EM gems in 2.0.1 */
+ SET_PROPERTY(EL_EXPANDABLE_WALL_GROWING, EP_EM_SLIPPERY_WALL,
+ (level.em_slippery_gems &&
+ engine_version > VERSION_IDENT(2,0,1,0)));
+ }
+
+ /* this is needed because some graphics depend on element properties */
+ if (game_status == GAME_MODE_PLAYING)
+ InitElementGraphicInfo();
+}
+
+void InitElementPropertiesAfterLoading(int engine_version)
+{
+ int i;
+
+ /* set some other uninitialized values of custom elements in older levels */
+ if (engine_version < VERSION_IDENT(3,1,0,0))