#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA042_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
unsigned int16_t G0397_i_MoveResultMapX;
unsigned int16_t G0398_i_MoveResultMapY;
unsigned int16_t G0399_ui_MoveResultMapIndex;
unsigned int16_t G0400_i_MoveResultDirection;
unsigned int16_t G0401_ui_MoveResultCell;
BOOLEAN G0402_B_UseRopeToClimbDownPit;
int16_t G0403_i_SensorRotationEffect = CM1_EFFECT_NONE;
int16_t G0404_i_SensorRotationEffectMapX;
int16_t G0405_i_SensorRotationEffectMapY;
int16_t G0406_i_SensorRotationEffectCell;
#ifdef MEDIA413_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
LEADER_HAND_OBJECT G4055_s_LeaderHandObject;
unsigned int16_t G0415_ui_LeaderEmptyHanded;


#include "COPYPRO8.C"
#endif
#ifdef MEDIA626_A31E_A31M_A33M_A35E_A35M
#include "COPYPRO9.C"
#endif

#ifdef MEDIA007_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E
overlay "timeline"
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
segment "timeline"
#endif

STATICFUNCTION int16_t F0262_MOVE_GetTeleporterRotatedGroupResult(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0541_ps_Teleporter, P0542_T_GroupThing, P0543_ui_MapIndex)
#endif
REGISTER TELEPORTER* P0541_ps_Teleporter SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
register THING       P0542_T_GroupThing  SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
THING                P0542_T_GroupThing  SEPARATOR
#endif
unsigned int16_t     P0543_ui_MapIndex   FINAL_SEPARATOR
{
        REGISTER GROUP* L0686_ps_Group;
        REGISTER unsigned int16_t L0683_ui_Rotation;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER unsigned int16_t L0684_ui_GroupDirections;
#endif
        REGISTER unsigned int16_t L0685_ui_UpdatedGroupDirections;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L0687_ui_UpdatedGroupCells;
        int16_t L0688_i_CreatureIndex;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER unsigned int16_t L0684_ui_GroupDirections;
        REGISTER unsigned int16_t L0687_ui_UpdatedGroupCells;
        REGISTER int16_t L0688_i_CreatureIndex;
        int16_t L0692_i_RelativeRotation;
#endif
        BOOLEAN L0689_B_AbsoluteRotation;
        unsigned int16_t L0690_ui_GroupCells;
        int16_t L0691_i_CreatureSize;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0692_i_RelativeRotation;
#endif


#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
        L0686_ps_Group = &((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0542_T_GroupThing)];
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
        L0686_ps_Group = (GROUP*)F0156_DUNGEON_GetThingData(P0542_T_GroupThing);
#endif
        L0683_ui_Rotation = P0541_ps_Teleporter->Rotation;
        L0684_ui_GroupDirections = F0147_DUNGEON_GetGroupDirections(L0686_ps_Group, P0543_ui_MapIndex);
        if (L0689_B_AbsoluteRotation = P0541_ps_Teleporter->AbsoluteRotation) {
                L0685_ui_UpdatedGroupDirections = L0683_ui_Rotation;
        } else {
                L0685_ui_UpdatedGroupDirections = M021_NORMALIZE(L0684_ui_GroupDirections + L0683_ui_Rotation);
        }
        if ((L0687_ui_UpdatedGroupCells = F0145_DUNGEON_GetGroupCells(L0686_ps_Group, P0543_ui_MapIndex)) != C0xFF_SINGLE_CENTERED_CREATURE) {
                L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
                L0691_i_CreatureSize = M007_GET(G0243_as_Graphic559_CreatureInfo[L0686_ps_Group->Type].Attributes, MASK0x0003_SIZE);
                L0692_i_RelativeRotation = M021_NORMALIZE(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
                for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->Count; L0688_i_CreatureIndex++) { /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE jmp */
                        L0685_ui_UpdatedGroupDirections = F0178_GROUP_GetGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_ui_Rotation : M021_NORMALIZE(L0684_ui_GroupDirections + L0683_ui_Rotation));
                        if ((L0691_i_CreatureSize == C0_SIZE_QUARTER_SQUARE) && (L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation)) {
                                L0692_i_RelativeRotation = L0683_ui_Rotation;
                        }
                        if (L0692_i_RelativeRotation) {
                                L0687_ui_UpdatedGroupCells = F0178_GROUP_GetGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, M021_NORMALIZE(L0690_ui_GroupCells + L0692_i_RelativeRotation));
                        }
                        L0684_ui_GroupDirections >>= 2;
                        L0690_ui_GroupCells >>= 2;
                }
        }
        F0148_DUNGEON_SetGroupDirections(L0686_ps_Group, L0685_ui_UpdatedGroupDirections, P0543_ui_MapIndex);
        F0146_DUNGEON_SetGroupCells(L0686_ps_Group, L0687_ui_UpdatedGroupCells, P0543_ui_MapIndex);
        if ((P0543_ui_MapIndex == G0309_i_PartyMapIndex) && (L0686_ps_Group->Behavior == C6_BEHAVIOR_ATTACK)) {
                return L0686_ps_Group->ActiveGroupIndex + 2;
        }
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* ANOMALY_ST_BRANCH */
        else {
#endif
                return 1;
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        }
#endif
}

STATICFUNCTION THING F0263_MOVE_GetTeleporterRotatedProjectileThing(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0544_ps_Teleporter, P0545_T_ProjectileThing)
#endif
TELEPORTER*    P0544_ps_Teleporter     SEPARATOR
REGISTER THING P0545_T_ProjectileThing FINAL_SEPARATOR
{
        REGISTER int16_t L0693_i_UpdatedDirection;
        REGISTER int16_t L0694_i_Rotation;


        L0693_i_UpdatedDirection = G0400_i_MoveResultDirection;
        L0694_i_Rotation = P0544_ps_Teleporter->Rotation;
        if (P0544_ps_Teleporter->AbsoluteRotation) {
                L0693_i_UpdatedDirection = L0694_i_Rotation;
        } else {
                L0693_i_UpdatedDirection = M021_NORMALIZE(L0693_i_UpdatedDirection + L0694_i_Rotation);
                P0545_T_ProjectileThing = M015_THING_WITH_NEW_CELL(P0545_T_ProjectileThing, M021_NORMALIZE(M011_CELL(P0545_T_ProjectileThing) + L0694_i_Rotation));
        }
        G0400_i_MoveResultDirection = L0693_i_UpdatedDirection;
        return P0545_T_ProjectileThing;
}

BOOLEAN F0264_MOVE_IsLevitating(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0546_T_Thing)
#endif
REGISTER THING P0546_T_Thing FINAL_SEPARATOR
{
        REGISTER int16_t L0695_i_ThingType;


        if ((L0695_i_ThingType = M012_TYPE(P0546_T_Thing)) == C04_THING_TYPE_GROUP) {
                return M007_GET(F0144_DUNGEON_GetCreatureAttributes(P0546_T_Thing), MASK0x0020_LEVITATION);
        }
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* ANOMALY_ST_BRANCH */
        else {
#endif
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
                if (L0695_i_ThingType == C14_THING_TYPE_PROJECTILE) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return C1_TRUE for explosions */
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                if ((L0695_i_ThingType == C14_THING_TYPE_PROJECTILE) || (L0695_i_ThingType == C15_THING_TYPE_EXPLOSION)) {
#endif
                        return C1_TRUE;
                }
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* ANOMALY_ST_BRANCH */
                else {
#endif
                        return C0_FALSE;
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                }
        }
#endif
}

STATICFUNCTION void F0265_MOVE_CreateEvent60To61_MoveGroup(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0547_T_GroupThing, P0548_i_MapX, P0549_i_MapY, P0550_i_MapIndex, P0551_B_Audible)
register THING P0547_T_GroupThing SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
THING          P0547_T_GroupThing SEPARATOR
#endif
int16_t        P0548_i_MapX       SEPARATOR
int16_t        P0549_i_MapY       SEPARATOR
int16_t        P0550_i_MapIndex   SEPARATOR
BOOLEAN        P0551_B_Audible    FINAL_SEPARATOR
{
        EVENT L0696_s_Event;


        M033_SET_MAP_AND_TIME(L0696_s_Event.Map_Time, P0550_i_MapIndex, G0313_ul_GameTime + 5);
        L0696_s_Event.A.A.Type = P0551_B_Audible ? C61_EVENT_MOVE_GROUP_AUDIBLE : C60_EVENT_MOVE_GROUP_SILENT;
        L0696_s_Event.A.A.Priority = 0;
        L0696_s_Event.B.Location.MapX = P0548_i_MapX;
        L0696_s_Event.B.Location.MapY = P0549_i_MapY;
        L0696_s_Event.C.Slot = P0547_T_GroupThing;
        F0238_TIMELINE_AddEvent_GetEventIndex_CPSE(&L0696_s_Event);
}

/* This function processes projectile impacts when moving the party or a group. It return C1_TRUE only if a group was killed by a projectile impact */
STATICFUNCTION BOOLEAN F0266_MOVE_IsKilledByProjectileImpact(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0552_i_SourceMapX, P0553_i_SourceMapY, P0554_i_DestinationMapX, P0555_i_DestinationMapY, P0556_T_Thing)
int16_t          P0552_i_SourceMapX      SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER int16_t P0552_i_SourceMapX      SEPARATOR
#endif
int16_t          P0553_i_SourceMapY      SEPARATOR
int16_t          P0554_i_DestinationMapX SEPARATOR
int16_t          P0555_i_DestinationMapY SEPARATOR
THING            P0556_T_Thing           FINAL_SEPARATOR /* Must be the party or a group */
{
        REGISTER GROUP* L0701_ps_Group;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        register THING L0697_T_Thing;
        register int16_t L0698_i_Unreferenced; /* BUG0_00 Useless code */
#endif
        REGISTER unsigned int16_t L0699_ui_Multiple;
#define AL0699_ui_Cell                      L0699_ui_Multiple
#define AL0699_ui_PrimaryDirection          L0699_ui_Multiple
#define AL0699_ui_ChampionOrCreatureOrdinal L0699_ui_Multiple
        REGISTER int16_t L0700_i_Multiple;
#define AL0700_B_CreatureAlive      L0700_i_Multiple
#define AL0700_i_Distance           L0700_i_Multiple
#define AL0700_i_SecondaryDirection L0700_i_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0702_i_ImpactType;
        BOOLEAN L0703_B_CheckDestinationSquareProjectileImpacts;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER THING L0697_T_Thing;
        REGISTER BOOLEAN L0703_B_CheckDestinationSquareProjectileImpacts;
        int16_t L0702_i_ImpactType;
#endif
        unsigned int16_t L0704_ui_ProjectileMapX;
        unsigned int16_t L0705_ui_ProjectileMapY;
        unsigned char L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[4]; /* This array is used only when moving between two adjacent squares and is used to test projectile impacts when the party or group is in the 'intermediary' step between the two squares. Without this test, in the example below no impact would be detected. In this example, the party moves from the source square on the left (which contains a single champion at cell 2) to the destination square on the right (which contains a single projectile at cell 3).
        Party:      Projectiles on target square:   Incorrect result without the test for the intermediary step (the champion would have passed through the projectile without impact):
        00    ->    00                         00
        01          P0                         P1 */
        unsigned char L0707_auc_ChampionOrCreatureOrdinalInCell[4]; /* This array has an entry for each cell on the source square, containing the ordinal of the champion or creature (0 if there is no champion or creature at this cell) */


        L0703_B_CheckDestinationSquareProjectileImpacts = C0_FALSE;
        F0008_MAIN_ClearBytes(M772_CAST_PC(L0707_auc_ChampionOrCreatureOrdinalInCell), M543_BYTE_COUNT_INT(sizeof(L0707_auc_ChampionOrCreatureOrdinalInCell)));
        if (P0556_T_Thing == C0xFFFF_THING_PARTY) {
                L0702_i_ImpactType = CM2_ELEMENT_CHAMPION;
                for (AL0699_ui_Cell = C00_CELL_NORTHWEST; AL0699_ui_Cell < C03_CELL_SOUTHWEST + 1; AL0699_ui_Cell++) {
                        if (F0285_CHAMPION_GetIndexInCell(AL0699_ui_Cell) >= 0) {
                                L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = M000_INDEX_TO_ORDINAL(AL0699_ui_Cell);
                        }
                }
        } else {
                L0702_i_ImpactType = CM1_ELEMENT_CREATURE;
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                L0701_ps_Group = &((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0556_T_Thing)];
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                L0701_ps_Group = (GROUP*)F0156_DUNGEON_GetThingData(P0556_T_Thing);
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                for (AL0699_ui_Cell = C00_CELL_NORTHWEST, AL0700_B_CreatureAlive = C0_FALSE; AL0699_ui_Cell < C03_CELL_SOUTHWEST + 1; AL0699_ui_Cell++) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                AL0700_B_CreatureAlive = C0_FALSE;
                for (AL0699_ui_Cell = C00_CELL_NORTHWEST; AL0699_ui_Cell < C03_CELL_SOUTHWEST + 1; AL0699_ui_Cell++) {
#endif
                        AL0700_B_CreatureAlive |= L0701_ps_Group->Health[AL0699_ui_Cell];
                        if (F0176_GROUP_GetCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
                                L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = M000_INDEX_TO_ORDINAL(AL0699_ui_Cell);
                        }
                }
                if (!AL0700_B_CreatureAlive) {
                        return C0_FALSE;
                }
        }
        if ((P0554_i_DestinationMapX >= 0) && (((((AL0700_i_Distance = P0552_i_SourceMapX - P0554_i_DestinationMapX) < 0) ? -AL0700_i_Distance : AL0700_i_Distance) + (((AL0700_i_Distance = P0553_i_SourceMapY - P0555_i_DestinationMapY) < 0) ? -AL0700_i_Distance : AL0700_i_Distance)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */
                AL0699_ui_PrimaryDirection = F0228_GROUP_GetDirectionsWhereDestinationIsVisibleFromSource(P0552_i_SourceMapX, P0553_i_SourceMapY, P0554_i_DestinationMapX, P0555_i_DestinationMapY);
                AL0700_i_SecondaryDirection = M017_NEXT(AL0699_ui_PrimaryDirection);
                F0008_MAIN_ClearBytes(M772_CAST_PC(L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell), M543_BYTE_COUNT_INT(sizeof(L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell)));
                if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[M019_PREVIOUS(AL0699_ui_PrimaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
                        L0703_B_CheckDestinationSquareProjectileImpacts = C1_TRUE;
                }
                if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[M017_NEXT(AL0700_i_SecondaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) {
                        L0703_B_CheckDestinationSquareProjectileImpacts = C1_TRUE;
                }
                if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
                        L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[M019_PREVIOUS(AL0699_ui_PrimaryDirection)];
                }
                if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) {
                        L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[M017_NEXT(AL0700_i_SecondaryDirection)];
                }
        }
        L0704_ui_ProjectileMapX = P0552_i_SourceMapX; /* Check impacts with projectiles on the source square */
        L0705_ui_ProjectileMapY = P0553_i_SourceMapY;
        T0266017_CheckProjectileImpacts:
        L0697_T_Thing = F0161_DUNGEON_GetSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
        while (L0697_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                if ((M012_TYPE(L0697_T_Thing) == C14_THING_TYPE_PROJECTILE) &&
                    (G0370_ps_Events[(((PROJECTILE*)G0284_apuc_ThingData[C14_THING_TYPE_PROJECTILE])[M013_INDEX(L0697_T_Thing)]).EventIndex].A.A.Type != C48_EVENT_MOVE_PROJECTILE_IGNORE_IMPACTS) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[M011_CELL(L0697_T_Thing)]) &&
                    F0217_PROJECTILE_HasImpactOccured(L0702_i_ImpactType, P0552_i_SourceMapX, P0553_i_SourceMapY, M001_ORDINAL_TO_INDEX(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
                        F0214_PROJECTILE_DeleteEvent(L0697_T_Thing);
                        if (G0364_i_CreatureDamageOutcome == C2_OUTCOME_KILLED_ALL_CREATURES_IN_GROUP) {
                                return C1_TRUE;
                        }
                        goto T0266017_CheckProjectileImpacts;
                }
                L0697_T_Thing = F0159_DUNGEON_GetNextThing(L0697_T_Thing);
        }
        if (L0703_B_CheckDestinationSquareProjectileImpacts) {
                P0552_i_SourceMapX |= (((L0704_ui_ProjectileMapX = P0554_i_DestinationMapX) + 1) << 8); /* Check impacts with projectiles on the destination square */
                P0553_i_SourceMapY |= ((L0705_ui_ProjectileMapY = P0555_i_DestinationMapY) << 8);
                F0007_MAIN_CopyBytes(M772_CAST_PC(L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell), M772_CAST_PC(L0707_auc_ChampionOrCreatureOrdinalInCell), M543_BYTE_COUNT_INT(sizeof(L0707_auc_ChampionOrCreatureOrdinalInCell)));
                L0703_B_CheckDestinationSquareProjectileImpacts = C0_FALSE;
                goto T0266017_CheckProjectileImpacts;
        }
        return C0_FALSE;
}

/* Returns 0 (C0_FALSE) if the thing was moved successfully. Returns non 0 (C1_TRUE or > 1) if the specified thing is a group and the ACTIVE_GROUP has been refreshed or removed which occurs when the group was blocked by the party (the group is then removed from the dungeon and an event is created to move the group back in the dungeon later), killed during movement or teleported, or entered or leaved the party map */
BOOLEAN F0267_MOVE_GetMoveResult_CPSCE(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0557_T_Thing, P0558_i_SourceMapX, P0559_i_SourceMapY, P0560_i_DestinationMapX, P0561_i_DestinationMapY)
#endif
REGISTER THING   P0557_T_Thing           SEPARATOR
int16_t          P0558_i_SourceMapX      SEPARATOR /* If P0558_i_SourceMapX is negative (CM1_MAPX_NOT_ON_A_SQUARE or CM2_MAPX_PROJECTILE_ASSOCIATED_OBJECT) then place the thing on the destination square. If placing a projectile associated object (CM2_MAPX_PROJECTILE_ASSOCIATED_OBJECT) on a teleporter square with an absolute rotation then ignore the rotation */
int16_t          P0559_i_SourceMapY      SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
int16_t          P0560_i_DestinationMapX SEPARATOR /* If P0560_i_DestinationMapX is negative, then remove the thing from the source square */
int16_t          P0561_i_DestinationMapY FINAL_SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER int16_t P0560_i_DestinationMapX SEPARATOR /* If P0560_i_DestinationMapX is negative, then remove the thing from the source square */
REGISTER int16_t P0561_i_DestinationMapY FINAL_SEPARATOR
#endif
{
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER CHAMPION* L0711_ps_Champion;
#endif
        REGISTER TELEPORTER* L0712_ps_Teleporter;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER CHAMPION* L0711_ps_Champion;
        REGISTER unsigned int16_t L0715_ui_MapIndexDestination;
#endif
        REGISTER int16_t L0708_i_Multiple;
#define AL0708_i_DestinationSquare L0708_i_Multiple
#define AL0708_i_ScentIndex        L0708_i_Multiple
#define AL0708_i_ActiveGroupIndex  L0708_i_Multiple
#define AL0708_i_Checksum          L0708_i_Multiple
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        unsigned int16_t L0714_ui_MapIndexSource;
        REGISTER int16_t L0710_i_ThingType;
        unsigned int16_t L0727_ui_Multiple;
#define AL0727_ui_ThingCell L0727_ui_Multiple
#define AL0727_ui_Outcome   L0727_ui_Multiple
#define AL0727_ui_Backup    L0727_ui_Multiple
        unsigned int16_t L0716_ui_Direction;
#endif
        REGISTER int16_t L0709_i_Multiple;
#define AL0709_i_DestinationSquareType L0709_i_Multiple
#define AL0709_i_ChampionIndex         L0709_i_Multiple
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER int16_t L0710_i_ThingType;
        BOOLEAN L0713_B_ThingLevitates;
        unsigned int16_t L0714_ui_MapIndexSource;
        unsigned int16_t L0715_ui_MapIndexDestination;
        unsigned int16_t L0716_ui_Direction;
        unsigned int16_t L0717_ui_ThingCell;
#endif
        int16_t L0718_i_RequiredTeleporterScope;
#ifdef MEDIA345_S21E_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE8_04_FIX */
        int16_t L0719_i_TraversedPitCount;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        unsigned int16_t L0717_ui_ThingCell;
        unsigned int16_t L0728_i_ChainedMoveCount;
#endif
        unsigned int16_t L0720_ui_MoveGroupResult;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        BOOLEAN L0713_B_ThingLevitates;
#endif
        BOOLEAN L0721_B_GroupOnPartyMap;
        BOOLEAN L0722_B_FallKilledGroup;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        BOOLEAN L0723_B_DrawDungeonViewWhileFalling;
#endif
        BOOLEAN L0724_B_DestinationIsTeleporterTarget;
        BOOLEAN L0725_B_PartySquare;
        BOOLEAN L0726_B_Audible;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L0727_ui_Multiple;
#define AL0727_ui_ThingCell L0727_ui_Multiple
#define AL0727_ui_Outcome   L0727_ui_Multiple
#define AL0727_ui_Backup    L0727_ui_Multiple
        int16_t L0728_i_ChainedMoveCount;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        BOOLEAN L0723_B_DrawDungeonViewWhileFalling;
        int16_t L3022_i_X;
        int16_t L3023_i_Y;
#endif
#ifdef MEDIA749_A36M_A31E_A31M_A33M_A35E_A35M_X31J
        int16_t L3024_i_Unreferenced;
#endif
#ifdef MEDIA353_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L1638_ui_MovementSoundIndex;
#endif


        L0710_i_ThingType = CM1_THING_TYPE_PARTY;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        L0713_B_ThingLevitates = C0_FALSE;
#endif
#ifdef MEDIA345_S21E_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE8_04_FIX */
        L0719_i_TraversedPitCount = 0;
#endif
        L0720_ui_MoveGroupResult = 0;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L0713_B_ThingLevitates = C0_FALSE;
#endif
        L0721_B_GroupOnPartyMap = C0_FALSE;
        L0722_B_FallKilledGroup = C0_FALSE;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        L0723_B_DrawDungeonViewWhileFalling = C0_FALSE;
#endif
        L0724_B_DestinationIsTeleporterTarget = C0_FALSE;
        L0725_B_PartySquare = C0_FALSE;
        L0726_B_Audible = C0_FALSE;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L0723_B_DrawDungeonViewWhileFalling = C0_FALSE;
#endif
        if (P0557_T_Thing != C0xFFFF_THING_PARTY) {
                L0710_i_ThingType = M012_TYPE(P0557_T_Thing);
                L0717_ui_ThingCell = M011_CELL(P0557_T_Thing);
                L0713_B_ThingLevitates = F0264_MOVE_IsLevitating(P0557_T_Thing);
        }
        /* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */
        if ((P0558_i_SourceMapX >= 0) && ((P0557_T_Thing == C0xFFFF_THING_PARTY) || ((L0710_i_ThingType == C04_THING_TYPE_GROUP) && (G0272_i_CurrentMapIndex == G0309_i_PartyMapIndex)))) {
                if (F0266_MOVE_IsKilledByProjectileImpact(P0558_i_SourceMapX, P0559_i_SourceMapY, P0560_i_DestinationMapX, P0561_i_DestinationMapY, P0557_T_Thing)) {
                        return C1_TRUE; /* The specified group thing cannot be moved because it was killed by a projectile impact */
                }
        }
        if (P0560_i_DestinationMapX >= 0) {
                L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = G0272_i_CurrentMapIndex;
                L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == G0309_i_PartyMapIndex) && (P0558_i_SourceMapX >= 0);
                if (P0557_T_Thing == C0xFFFF_THING_PARTY) {
                        G0306_i_PartyMapX = P0560_i_DestinationMapX;
                        G0307_i_PartyMapY = P0561_i_DestinationMapY;
                        L0718_i_RequiredTeleporterScope = MASK0x0002_SCOPE_OBJECTS_OR_PARTY;
#ifdef MEDIA002_S10EA_S10EB_S11E /* CHANGE3_06_FIX The dungeon view is drawn during a fall while the party is resting */
                        L0723_B_DrawDungeonViewWhileFalling = !G0423_i_InventoryChampionOrdinal; /* BUG0_27 If a pit opens under the party while it is resting then the dungeon view is drawn during the fall without the floor and ceiling, even though it should not be visible at all until the party wakes up at the end of the fall */
#endif
#ifdef MEDIA240_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE3_06_FIX The dungeon view is not drawn during a fall while the party is resting */
                        L0723_B_DrawDungeonViewWhileFalling = !G0423_i_InventoryChampionOrdinal && !G0300_B_PartyIsResting;
#endif
                        L0716_ui_Direction = G0308_i_PartyDirection;
                } else {
                        if (L0710_i_ThingType == C04_THING_TYPE_GROUP) {
                                L0718_i_RequiredTeleporterScope = MASK0x0001_SCOPE_CREATURES;
                        } else {
                                L0718_i_RequiredTeleporterScope = (MASK0x0001_SCOPE_CREATURES | MASK0x0002_SCOPE_OBJECTS_OR_PARTY);
                        }
                }
                if (L0710_i_ThingType == C14_THING_TYPE_PROJECTILE) {
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                        G0400_i_MoveResultDirection = (G0370_ps_Events[((PROJECTILE*)G0284_apuc_ThingData[C14_THING_TYPE_PROJECTILE])[M013_INDEX(P0557_T_Thing)].EventIndex]).C.Projectile.Direction;
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                        L0712_ps_Teleporter = (TELEPORTER*)F0156_DUNGEON_GetThingData(P0557_T_Thing);
                        G0400_i_MoveResultDirection = (G0370_ps_Events[((PROJECTILE*)L0712_ps_Teleporter)->EventIndex]).C.Projectile.Direction;
#endif
                }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                for (L0728_i_ChainedMoveCount = 100; --L0728_i_ChainedMoveCount; ) { /* No more than 100 chained moves at once (in a chain of teleporters and pits for example) */
#endif
                        AL0708_i_DestinationSquare = G0271_ppuc_CurrentMapData[P0560_i_DestinationMapX][P0561_i_DestinationMapY];
                        if ((AL0709_i_DestinationSquareType = M034_SQUARE_TYPE(AL0708_i_DestinationSquare)) == C05_ELEMENT_TELEPORTER) {
                                if (!M007_GET(AL0708_i_DestinationSquare, MASK0x0008_TELEPORTER_OPEN))
                                        break;
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                L0712_ps_Teleporter = (TELEPORTER*)F0156_DUNGEON_GetThingData(F0161_DUNGEON_GetSquareFirstThing(P0560_i_DestinationMapX, P0561_i_DestinationMapY));
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                L0712_ps_Teleporter = (TELEPORTER*)F0157_DUNGEON_GetSquareFirstThingData(P0560_i_DestinationMapX, P0561_i_DestinationMapY);
#endif
                                if ((L0712_ps_Teleporter->Scope == MASK0x0001_SCOPE_CREATURES) && (L0710_i_ThingType != C04_THING_TYPE_GROUP))
                                        break;
                                if ((L0718_i_RequiredTeleporterScope != (MASK0x0001_SCOPE_CREATURES | MASK0x0002_SCOPE_OBJECTS_OR_PARTY)) && !M007_GET(L0712_ps_Teleporter->Scope, L0718_i_RequiredTeleporterScope)) /* ANOMALY_ASSEMBLY_COMPILATION_DIFFERENCE test */
                                        break;
                                L0724_B_DestinationIsTeleporterTarget = (P0560_i_DestinationMapX == L0712_ps_Teleporter->TargetMapX) && (P0561_i_DestinationMapY == L0712_ps_Teleporter->TargetMapY) && (L0715_ui_MapIndexDestination == L0712_ps_Teleporter->TargetMapIndex);
                                P0560_i_DestinationMapX = L0712_ps_Teleporter->TargetMapX;
                                P0561_i_DestinationMapY = L0712_ps_Teleporter->TargetMapY;
                                L0726_B_Audible = L0712_ps_Teleporter->Audible;
                                F0173_DUNGEON_SetCurrentMap(L0715_ui_MapIndexDestination = L0712_ps_Teleporter->TargetMapIndex);
                                if (P0557_T_Thing == C0xFFFF_THING_PARTY) {
                                        G0306_i_PartyMapX = P0560_i_DestinationMapX;
                                        G0307_i_PartyMapY = P0561_i_DestinationMapY;
                                        if (L0712_ps_Teleporter->Audible) {
                                                F0064_SOUND_RequestPlay_CPSD(M560_SOUND_BUZZ, G0306_i_PartyMapX, G0307_i_PartyMapY, C00_MODE_PLAY_IMMEDIATELY);
                                        }
#ifdef MEDIA022_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A31E_A31M_A33M_F31E_F31J_X31J_P31J
                                        L0723_B_DrawDungeonViewWhileFalling &= G0661_B_LargeHeapMemory;
#endif
#ifdef MEDIA728_I34E_I34M_A36M_A35E_A35M
                                        L0723_B_DrawDungeonViewWhileFalling &= G2040_auc_MemoryFlags[C0_MEM_];
#endif
                                        if (L0712_ps_Teleporter->AbsoluteRotation) {
                                                F0284_CHAMPION_SetPartyDirection(L0712_ps_Teleporter->Rotation);
                                        } else {
#ifdef PC_FIX_CODE_SIZE
        P0557_T_Thing++;
        P0557_T_Thing++;
        P0557_T_Thing++;
        P0557_T_Thing++;
        P0557_T_Thing++;
        P0557_T_Thing++;
        P0557_T_Thing++;
#endif
                                                F0284_CHAMPION_SetPartyDirection(M021_NORMALIZE(G0308_i_PartyDirection + L0712_ps_Teleporter->Rotation));
                                        }
                                } else {
                                        if (L0710_i_ThingType == C04_THING_TYPE_GROUP) {
                                                if (L0712_ps_Teleporter->Audible) {
                                                        F0064_SOUND_RequestPlay_CPSD(M560_SOUND_BUZZ, P0560_i_DestinationMapX, P0561_i_DestinationMapY, C01_MODE_PLAY_IF_PRIORITIZED);
                                                }
                                                L0720_ui_MoveGroupResult = F0262_MOVE_GetTeleporterRotatedGroupResult(L0712_ps_Teleporter, P0557_T_Thing, L0714_ui_MapIndexSource);
                                        } else {
                                                if (L0710_i_ThingType == C14_THING_TYPE_PROJECTILE) {
                                                        P0557_T_Thing = F0263_MOVE_GetTeleporterRotatedProjectileThing(L0712_ps_Teleporter, P0557_T_Thing);
                                                } else {
                                                        if (!(L0712_ps_Teleporter->AbsoluteRotation) && (P0558_i_SourceMapX != CM2_MAPX_PROJECTILE_ASSOCIATED_OBJECT)) {
                                                                P0557_T_Thing = M015_THING_WITH_NEW_CELL(P0557_T_Thing, M021_NORMALIZE(M011_CELL(P0557_T_Thing) + L0712_ps_Teleporter->Rotation));
                                                        }
                                                }
                                        }
                                }
                                if (L0724_B_DestinationIsTeleporterTarget)
                                        break;
                        } else {
                                if ((AL0709_i_DestinationSquareType == C02_ELEMENT_PIT) && !L0713_B_ThingLevitates && M007_GET(AL0708_i_DestinationSquare, MASK0x0008_PIT_OPEN) && !M007_GET(AL0708_i_DestinationSquare, MASK0x0001_PIT_IMAGINARY)) {
                                        if (L0723_B_DrawDungeonViewWhileFalling) {
                                                if (!G0402_B_UseRopeToClimbDownPit) {
#ifdef MEDIA022_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A31E_A31M_A33M_F31E_F31J_X31J_P31J
                                                        L0723_B_DrawDungeonViewWhileFalling = G0661_B_LargeHeapMemory;
#endif
#ifdef MEDIA728_I34E_I34M_A36M_A35E_A35M
                                                        L0723_B_DrawDungeonViewWhileFalling = G2040_auc_MemoryFlags[C0_MEM_];
#endif
#ifdef MEDIA345_S21E_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE8_04_FIX Graphics for each traversed map are loaded before drawing the dungeon view while falling so that the dungeon view is drawn with appropriate graphics */
                                                        if (L0719_i_TraversedPitCount) {
                                                                F0174_DUNGEON_SetCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
                                                                F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF();
                                                        }
#endif
#ifdef MEDIA344_S21E_F20E_F20J_X30J_P20JA_P20JB
                                                        L0719_i_TraversedPitCount++;
#endif
                                                        F0128_DUNGEONVIEW_Draw_CPSF(G0308_i_PartyDirection, P0560_i_DestinationMapX, P0561_i_DestinationMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
                                                        /* BUG0_71 Some timings are too short on fast computers. When the party falls in a series of pits, the dungeon view is refreshed too quickly because the execution speed is not limited */
                                                        /* BUG0_01 While drawing creatures the engine will read invalid ACTIVE_GROUP data in G0375_ps_ActiveGroups because the data is for the creatures on the source map and not the map being drawn. The only consequence is that creatures may be drawn with incorrect bitmaps and/or directions */
                                                }
#ifdef MEDIA720_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                L0719_i_TraversedPitCount++;
#endif
                                        }
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                        L0715_ui_MapIndexDestination = F0154_DUNGEON_GetLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &P0560_i_DestinationMapX, &P0561_i_DestinationMapY);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                        L3022_i_X = P0560_i_DestinationMapX;
                                        L3023_i_Y = P0561_i_DestinationMapY;
                                        L0715_ui_MapIndexDestination = F0154_DUNGEON_GetLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &L3022_i_X, &L3023_i_Y);
                                        P0560_i_DestinationMapX = L3022_i_X;
                                        P0561_i_DestinationMapY = L3023_i_Y;
#endif
                                        F0173_DUNGEON_SetCurrentMap(L0715_ui_MapIndexDestination);
                                        if (P0557_T_Thing == C0xFFFF_THING_PARTY) {
                                                G0306_i_PartyMapX = P0560_i_DestinationMapX;
                                                G0307_i_PartyMapY = P0561_i_DestinationMapY;
                                                if (G0305_ui_PartyChampionCount > 0) {
                                                        if (G0402_B_UseRopeToClimbDownPit) {
#ifdef MEDIA624_A31E_A31M_A33M_X31J_P31J
                                                                L0723_B_DrawDungeonViewWhileFalling = G0661_B_LargeHeapMemory && !G0423_i_InventoryChampionOrdinal && !G0300_B_PartyIsResting;
#endif
#ifdef MEDIA670_F31E_F31J
                                                                L0723_B_DrawDungeonViewWhileFalling = G0661_B_LargeHeapMemory && G0423_i_InventoryChampionOrdinal && !G0300_B_PartyIsResting;
#endif
#ifdef MEDIA728_I34E_I34M_A36M_A35E_A35M
                                                                L0723_B_DrawDungeonViewWhileFalling = G2040_auc_MemoryFlags[C0_MEM_] && !G0423_i_InventoryChampionOrdinal && !G0300_B_PartyIsResting;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                                                for (AL0709_i_ChampionIndex = C00_CHAMPION_FIRST, L0711_ps_Champion = M516_CHAMPIONS; AL0709_i_ChampionIndex < G0305_ui_PartyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                                L0711_ps_Champion = M516_CHAMPIONS;
                                                                for (AL0709_i_ChampionIndex = C00_CHAMPION_FIRST; AL0709_i_ChampionIndex < G0305_ui_PartyChampionCount; L0711_ps_Champion++, AL0709_i_ChampionIndex++) {
#endif
                                                                        if (L0711_ps_Champion->CurrentHealth) {
                                                                                F0325_CHAMPION_DecrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->Load * 25) / F0309_CHAMPION_GetMaximumLoad(L0711_ps_Champion)) + 1);
                                                                        }
                                                                }
                                                        } else {
                                                                if (F0324_CHAMPION_DamageAll_GetDamagedChampionCount(20, MASK0x0010_WOUND_LEGS | MASK0x0020_WOUND_FEET, C2_ATTACK_SELF)) {
                                                                        F0064_SOUND_RequestPlay_CPSD(M561_SOUND_SCREAM, G0306_i_PartyMapX, G0307_i_PartyMapY, C00_MODE_PLAY_IMMEDIATELY);
                                                                }
                                                        }
                                                }
                                                G0402_B_UseRopeToClimbDownPit = C0_FALSE;
                                        } else {
                                                if (L0710_i_ThingType == C04_THING_TYPE_GROUP) {
                                                        F0173_DUNGEON_SetCurrentMap(L0714_ui_MapIndexSource);
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                                        AL0727_ui_Outcome = F0191_GROUP_GetDamageAllCreaturesOutcome(&((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0557_T_Thing)], P0558_i_SourceMapX, P0559_i_SourceMapY, 20, C0_FALSE);
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                                        AL0727_ui_Outcome = F0191_GROUP_GetDamageAllCreaturesOutcome((GROUP*)F0156_DUNGEON_GetThingData(P0557_T_Thing), P0558_i_SourceMapX, P0559_i_SourceMapY, 20, C0_FALSE);
#endif
                                                        F0173_DUNGEON_SetCurrentMap(L0715_ui_MapIndexDestination);
                                                        if (L0722_B_FallKilledGroup = (AL0727_ui_Outcome == C2_OUTCOME_KILLED_ALL_CREATURES_IN_GROUP))
                                                                break;
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* ANOMALY_ST_BRANCH */
                                                        else {
#endif
                                                                if (AL0727_ui_Outcome == C1_OUTCOME_KILLED_SOME_CREATURES_IN_GROUP) {
                                                                        F0187_GROUP_DropMovingCreatureFixedPossessions(P0557_T_Thing, P0560_i_DestinationMapX, P0561_i_DestinationMapY);
                                                                }
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* ANOMALY_ST_BRANCH */
                                                        }
#endif
                                                }
                                        }
                                } else {
                                        if ((AL0709_i_DestinationSquareType == C03_ELEMENT_STAIRS) && (P0557_T_Thing != C0xFFFF_THING_PARTY) && (L0710_i_ThingType != C14_THING_TYPE_PROJECTILE)) {
                                                if (!M007_GET(AL0708_i_DestinationSquare, MASK0x0004_STAIRS_UP)) {
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                                        L0715_ui_MapIndexDestination = F0154_DUNGEON_GetLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &P0560_i_DestinationMapX, &P0561_i_DestinationMapY);
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                        L3022_i_X = P0560_i_DestinationMapX;
                                                        L3023_i_Y = P0561_i_DestinationMapY;
                                                        L0715_ui_MapIndexDestination = F0154_DUNGEON_GetLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &L3022_i_X, &L3023_i_Y);
                                                        P0560_i_DestinationMapX = L3022_i_X;
                                                        P0561_i_DestinationMapY = L3023_i_Y;
#endif
                                                        F0173_DUNGEON_SetCurrentMap(L0715_ui_MapIndexDestination);
                                                }
                                                L0716_ui_Direction = F0155_DUNGEON_GetStairsExitDirection(P0560_i_DestinationMapX, P0561_i_DestinationMapY);
                                                P0560_i_DestinationMapX += G0233_ai_Graphic559_DirectionToStepEastCount[L0716_ui_Direction], P0561_i_DestinationMapY += G0234_ai_Graphic559_DirectionToStepNorthCount[L0716_ui_Direction];
                                                L0716_ui_Direction = M018_OPPOSITE(L0716_ui_Direction);
                                                AL0727_ui_ThingCell = M011_CELL(P0557_T_Thing);
                                                AL0727_ui_ThingCell = M021_NORMALIZE((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
                                                P0557_T_Thing = M015_THING_WITH_NEW_CELL(P0557_T_Thing, AL0727_ui_ThingCell);
                                        } else
                                                break;
                                }
                        }
                }
                if ((L0710_i_ThingType == C04_THING_TYPE_GROUP) && (L0722_B_FallKilledGroup || !F0139_DUNGEON_IsCreatureAllowedOnMap(P0557_T_Thing, L0715_ui_MapIndexDestination))) {
                        F0187_GROUP_DropMovingCreatureFixedPossessions(P0557_T_Thing, P0560_i_DestinationMapX, P0561_i_DestinationMapY);
                        F0188_GROUP_DropGroupPossessions(P0560_i_DestinationMapX, P0561_i_DestinationMapY, P0557_T_Thing, C02_MODE_PLAY_ONE_TICK_LATER);
                        F0173_DUNGEON_SetCurrentMap(L0714_ui_MapIndexSource);
                        if (P0558_i_SourceMapX >= 0) {
                                F0189_GROUP_Delete(P0558_i_SourceMapX, P0559_i_SourceMapY);
                        }
                        return C1_TRUE; /* The specified group thing cannot be moved because it was killed by a fall or because it is not allowed on the destination map */
                }
#ifdef MEDIA081_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_A31E_A31M_A33M_A35E_A35M
#ifndef NOCOPYPROTECTION
#ifdef MEDIA137_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                if ((L0715_ui_MapIndexDestination > 2) && !(P0560_i_DestinationMapX & 0x0007) && !(P0561_i_DestinationMapY & 0x0003) && (F0413_CPSC_GetChecksumEor(F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF) != CHECKSUM_A)) {
#endif
#ifdef MEDIA351_G14ED_G20E_G21E
                if ((L0715_ui_MapIndexDestination > 2) && !(P0560_i_DestinationMapX & 0x0007) && !(P0561_i_DestinationMapY & 0x0003)
                        && ((F0413_CPSC_GetChecksumEor(F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF, F2191_CPSX) != CHECKSUM_A)
                        || (F0413_CPSC_GetChecksumEor(F2206_CPSX, F2193_CPSX) != CHECKSUM_E)
                        || (F0413_CPSC_GetChecksumEor(F2150_CPSX, F2195_CPSX) != CHECKSUM_F)
                        || !F2152_CPSX(F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF, F2192_CPSX)
                        || !F2152_CPSX(F2150_CPSX, F2196_CPSX)
                        || !F2151_CPSX(F2206_CPSX, F2194_CPSX)
                        || !F2151_CPSX(F2150_CPSX, F2197_CPSX))) {
#endif
#ifdef MEDIA626_A31E_A31M_A33M_A35E_A35M
                if ((L0715_ui_MapIndexDestination > 2) && !(P0560_i_DestinationMapX & 0x000F) && !(P0561_i_DestinationMapY & 0x000F)) {
                        AL0727_ui_Backup = AL0708_i_DestinationSquare;
                        AL0708_i_Checksum = F0413_CPSC_GetChecksumEor(*((long*)((char*)F1057_Pre_F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF + 2)), *((long*)((char*)F1059_Post_F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF + 2)));
                        asm { /* Fake code used to hide the test of the checksum value */
                                @Tloc_1B7CE:
#ifdef MEDIA620_A31E_A31M_A33M
                                        move.w  -4(a6),d1
                                        cmpi.w  #CHECKSUM_A,d1      /* CHECKSUM_A */
                                        bcc.s   @Tloc_1B7DC
                                        moveq   #1,d0
                                        bra.s   @Tloc_1B7DE
                                @Tloc_1B7DC:
                                        moveq   #0,d0
                                @Tloc_1B7DE:
                                        move.w  -10(a6),d1
                                        cmp.w   d0,d1
                                        bcc.s   @Tloc_1B7EA
                                        moveq   #1,d0
                                        bra.s   @Tloc_1B7EC
                                @Tloc_1B7EA:
                                        moveq   #0,d0
#endif
#ifdef MEDIA741_A35E_A35M
                                        move.w        #0xC8,d1
                                        move.w        #CHECKSUM_A,d1
                                        add.w        -4(a6),d1
                                        beq.s        @Tloc_1B7EA
                                        move.w        -10(a6),d1
                                        cmp.w        d0,d1
                                        beq.s        @Tloc_1B7EA
                                        move.w        #0xFFFF,d0
                                        bra.s        @Tloc_1B7EC
                                @Tloc_1B7EA:
                                        asl.w        #1,d0
#endif
                                @Tloc_1B7EC:
                                        lea     @Tloc_1B7CE,a0
                                        move.w  d3,d0
                                        cmp.w   6(a0),d0                /* Actual comparison */
                                        beq.s   @Tloc_1B7FE
                                        move.w  #1,d3
                                        bra.s   @Tloc_1B802
                                @Tloc_1B7FE:
                                        move.w  #0,d3
                                @Tloc_1B802:
                        }
                        if (AL0708_i_Checksum) {
#endif
                                P0560_i_DestinationMapX += P0561_i_DestinationMapY;
                                P0561_i_DestinationMapY -= P0560_i_DestinationMapX;
#ifdef MEDIA626_A31E_A31M_A33M_A35E_A35M
                        }
                        AL0708_i_DestinationSquare = AL0727_ui_Backup;
#endif
                }
#endif
#endif
                G0397_i_MoveResultMapX = P0560_i_DestinationMapX;
                G0398_i_MoveResultMapY = P0561_i_DestinationMapY;
                G0399_ui_MoveResultMapIndex = L0715_ui_MapIndexDestination;
                G0401_ui_MoveResultCell = M011_CELL(P0557_T_Thing);
#ifdef MEDIA067_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_A31E_A31M_A33M_A35E_A35M_X31J
#ifndef NOCOPYPROTECTION
                if (G0022_i_Graphic562_IndirectStopExpiringEvent_CPSE != C00555_FALSE) {
#ifdef MEDIA075_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_A31E_A31M_A33M_A35E_A35M_X31J
                        G0022_i_Graphic562_IndirectStopExpiringEvent_CPSE == C00555_FALSE; /* BUG0_00 Useless code */
#endif
                        G0330_i_StopExpiringEvents_CPSE++;
                }
#endif
#endif
                L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (P0560_i_DestinationMapX == P0558_i_SourceMapX) && (P0561_i_DestinationMapY == P0559_i_SourceMapY);
                if (L0725_B_PartySquare) {
                        if (P0557_T_Thing == C0xFFFF_THING_PARTY) {
                                if (G0308_i_PartyDirection == L0716_ui_Direction) {
                                        return C0_FALSE;
                                }
                        } else {
                                if ((G0401_ui_MoveResultCell == L0717_ui_ThingCell) && (L0710_i_ThingType != C14_THING_TYPE_PROJECTILE)) {
                                        return C0_FALSE;
                                }
                        }
                } else {
                        if ((P0557_T_Thing == C0xFFFF_THING_PARTY) && G0305_ui_PartyChampionCount) {
                                AL0727_ui_Backup = AL0708_i_DestinationSquare;
                                AL0708_i_ScentIndex = G0407_s_Party.ScentCount;
                                while (AL0708_i_ScentIndex >= 24) {
                                        F0316_CHAMPION_DeleteScent(0);
                                        AL0708_i_ScentIndex--;
                                }
                                if (AL0708_i_ScentIndex) {
                                        F0317_CHAMPION_AddScentStrength(P0558_i_SourceMapX, P0559_i_SourceMapY, (int16_t)(G0313_ul_GameTime - G0362_l_LastPartyMovementTime));
                                }
                                G0362_l_LastPartyMovementTime = G0313_ul_GameTime;
                                G0407_s_Party.ScentCount++;
                                if (G0407_s_Party.Event79Count_Footprints) {
                                        G0407_s_Party.LastScentIndex = G0407_s_Party.ScentCount;
                                }
                                G0407_s_Party.Scents[AL0708_i_ScentIndex].Location.MapX = P0560_i_DestinationMapX;
                                G0407_s_Party.Scents[AL0708_i_ScentIndex].Location.MapY = P0561_i_DestinationMapY;
                                G0407_s_Party.Scents[AL0708_i_ScentIndex].Location.MapIndex = L0715_ui_MapIndexDestination;
                                G0407_s_Party.ScentStrengths[AL0708_i_ScentIndex] = 0;
                                F0317_CHAMPION_AddScentStrength(P0560_i_DestinationMapX, P0561_i_DestinationMapY, MASK0x8000_MERGE_CYCLES | 24);
                                AL0708_i_DestinationSquare = AL0727_ui_Backup;
                        }
                        if (L0715_ui_MapIndexDestination != L0714_ui_MapIndexSource) {
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                if ((P0557_T_Thing == C0xFFFF_THING_PARTY) && (G0309_i_PartyMapIndex != L0714_ui_MapIndexSource)) {
                                        F0174_DUNGEON_SetCurrentMapAndPartyMap(L0714_ui_MapIndexSource);
                                } else {
#endif
                                        F0173_DUNGEON_SetCurrentMap(L0714_ui_MapIndexSource);
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                }
#endif
                        }
                }
        }
        if (P0558_i_SourceMapX >= 0) {
                if (P0557_T_Thing == C0xFFFF_THING_PARTY) {
                        F0276_SENSOR_ProcessThingAdditionOrRemoval(P0558_i_SourceMapX, P0559_i_SourceMapY, C0xFFFF_THING_PARTY, L0725_B_PartySquare, C0_FALSE);
                } else {
                        if (L0713_B_ThingLevitates) {
                                F0164_DUNGEON_UnlinkThingFromList(P0557_T_Thing, 0, P0558_i_SourceMapX, P0559_i_SourceMapY);
                        } else {
                                F0276_SENSOR_ProcessThingAdditionOrRemoval(P0558_i_SourceMapX, P0559_i_SourceMapY, P0557_T_Thing, (G0272_i_CurrentMapIndex == G0309_i_PartyMapIndex) && (P0558_i_SourceMapX == G0306_i_PartyMapX) && (P0559_i_SourceMapY == G0307_i_PartyMapY), C0_FALSE);
                        }
                }
        }
        if (P0560_i_DestinationMapX >= 0) {
                if (P0557_T_Thing == C0xFFFF_THING_PARTY) {
                        F0173_DUNGEON_SetCurrentMap(L0715_ui_MapIndexDestination);
                        if ((P0557_T_Thing = F0175_GROUP_GetThing(G0306_i_PartyMapX, G0307_i_PartyMapY)) != C0xFFFE_THING_ENDOFLIST) { /* Delete group if party moves onto its square */
                                F0188_GROUP_DropGroupPossessions(G0306_i_PartyMapX, G0307_i_PartyMapY, P0557_T_Thing, C01_MODE_PLAY_IF_PRIORITIZED);
                                F0189_GROUP_Delete(G0306_i_PartyMapX, G0307_i_PartyMapY);
                        }
                        if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) {
                                F0276_SENSOR_ProcessThingAdditionOrRemoval(G0306_i_PartyMapX, G0307_i_PartyMapY, C0xFFFF_THING_PARTY, L0725_B_PartySquare, C1_TRUE);
                        } else {
                                F0173_DUNGEON_SetCurrentMap(L0714_ui_MapIndexSource);
                                G0327_i_NewPartyMapIndex = L0715_ui_MapIndexDestination;
                        }
                } else {
                        if (L0710_i_ThingType == C04_THING_TYPE_GROUP) {
                                F0173_DUNGEON_SetCurrentMap(L0715_ui_MapIndexDestination);
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                L0712_ps_Teleporter = (TELEPORTER*)F0156_DUNGEON_GetThingData(P0557_T_Thing);
                                AL0708_i_ActiveGroupIndex = ((GROUP*)L0712_ps_Teleporter)->ActiveGroupIndex;
#endif
                                if (((L0715_ui_MapIndexDestination == G0309_i_PartyMapIndex) && (P0560_i_DestinationMapX == G0306_i_PartyMapX) && (P0561_i_DestinationMapY == G0307_i_PartyMapY)) || (F0175_GROUP_GetThing(P0560_i_DestinationMapX, P0561_i_DestinationMapY) != C0xFFFE_THING_ENDOFLIST)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
                                        F0173_DUNGEON_SetCurrentMap(L0714_ui_MapIndexSource);
                                        if (P0558_i_SourceMapX >= 0) {
                                                F0181_GROUP_DeleteEvents(P0558_i_SourceMapX, P0559_i_SourceMapY);
                                        }
                                        if (L0721_B_GroupOnPartyMap) {
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                                F0184_GROUP_RemoveActiveGroup(((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0557_T_Thing)].ActiveGroupIndex);
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                                F0184_GROUP_RemoveActiveGroup(AL0708_i_ActiveGroupIndex);
#endif
                                        }
                                        F0265_MOVE_CreateEvent60To61_MoveGroup(P0557_T_Thing, P0560_i_DestinationMapX, P0561_i_DestinationMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
                                        return C1_TRUE; /* The specified group thing cannot be moved because the party or another group is on the destination square */
                                }
#ifdef MEDIA353_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                L1638_ui_MovementSoundIndex = F0514_MOVE_GetSound(((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0557_T_Thing)].Type);
                                if (L1638_ui_MovementSoundIndex < M513_SOUND_COUNT) {
                                        F0064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, P0560_i_DestinationMapX, P0561_i_DestinationMapY, C01_MODE_PLAY_IF_PRIORITIZED);
                                }
#endif
#ifdef MEDIA485_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                F0064_SOUND_RequestPlay_CPSD(F0514_MOVE_GetSound(((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0557_T_Thing)].Type), P0560_i_DestinationMapX, P0561_i_DestinationMapY, C01_MODE_PLAY_IF_PRIORITIZED);
#endif
                                if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != G0309_i_PartyMapIndex)) { /* If the group leaves the party map */
#ifdef MEDIA001_S10EA_S10EB /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                        F0184_GROUP_RemoveActiveGroup(((GROUP*)G0284_apuc_ThingData[C04_THING_TYPE_GROUP])[M013_INDEX(P0557_T_Thing)].ActiveGroupIndex);
#endif
#ifdef MEDIA227_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                                        F0184_GROUP_RemoveActiveGroup(AL0708_i_ActiveGroupIndex);
#endif
                                        L0720_ui_MoveGroupResult = C1_TRUE;
                                } else {
                                        if ((L0715_ui_MapIndexDestination == G0309_i_PartyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */
                                                F0183_GROUP_AddActiveGroup(P0557_T_Thing, P0560_i_DestinationMapX, P0561_i_DestinationMapY);
                                                L0720_ui_MoveGroupResult = C1_TRUE;
                                        }
                                }
                                if (L0713_B_ThingLevitates) {
                                        F0163_DUNGEON_LinkThingToList(P0557_T_Thing, 0, P0560_i_DestinationMapX, P0561_i_DestinationMapY);
                                } else {
                                        F0276_SENSOR_ProcessThingAdditionOrRemoval(P0560_i_DestinationMapX, P0561_i_DestinationMapY, P0557_T_Thing, C0_FALSE, C1_TRUE);
                                }
                                if (L0720_ui_MoveGroupResult || (P0558_i_SourceMapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
                                        F0180_GROUP_StartWandering(P0560_i_DestinationMapX, P0561_i_DestinationMapY);
                                }
                                F0173_DUNGEON_SetCurrentMap(L0714_ui_MapIndexSource);
                                if (P0558_i_SourceMapX >= 0) {
                                        if (L0720_ui_MoveGroupResult > C1_TRUE) { /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
                                                F0182_GROUP_StopAttacking(&G0375_ps_ActiveGroups[L0720_ui_MoveGroupResult - 2], P0558_i_SourceMapX, P0559_i_SourceMapY);
                                        } else {
                                                if (L0720_ui_MoveGroupResult) { /* If the group was teleported or leaved the party map or entered the party map */
                                                        F0181_GROUP_DeleteEvents(P0558_i_SourceMapX, P0559_i_SourceMapY);
                                                }
                                        }
                                }
                                return L0720_ui_MoveGroupResult;
                        }
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* ANOMALY_ST_BRANCH */
                        else {
#endif
                                F0173_DUNGEON_SetCurrentMap(L0715_ui_MapIndexDestination);
                                if (L0710_i_ThingType == C14_THING_TYPE_PROJECTILE) { /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned C1_TRUE for explosions (see BUG0_26) */
                                        F0163_DUNGEON_LinkThingToList(P0557_T_Thing, 0, P0560_i_DestinationMapX, P0561_i_DestinationMapY);
                                } else {
                                        F0276_SENSOR_ProcessThingAdditionOrRemoval(P0560_i_DestinationMapX, P0561_i_DestinationMapY, P0557_T_Thing, (G0272_i_CurrentMapIndex == G0309_i_PartyMapIndex) && (P0560_i_DestinationMapX == G0306_i_PartyMapX) && (P0561_i_DestinationMapY == G0307_i_PartyMapY), C1_TRUE);
                                }
                                F0173_DUNGEON_SetCurrentMap(L0714_ui_MapIndexSource);
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                        }
#endif
                }
        }
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        return C0_FALSE;
#endif
}


#ifdef MEDIA355_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t F0514_MOVE_GetSound(
#ifdef MEDIA353_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0943_uc_CreatureType)
unsigned char P0943_uc_CreatureType FINAL_SEPARATOR
#endif
#ifdef MEDIA485_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
int16_t P2099_i_Type FINAL_SEPARATOR
#endif
{
#ifdef MEDIA353_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
#ifdef MEDIA393_G20E_G21E_A20E_A20F_A20G_A21E_A22E_A22G
        if (G0300_B_PartyIsResting) {
                return M513_SOUND_COUNT + 1;
        }
#endif
        switch(P0943_uc_CreatureType) {
                case C03_CREATURE_WIZARD_EYE_FLYING_EYE:
                case C08_CREATURE_GHOST_RIVE:
                case C11_CREATURE_BLACK_FLAME:
                case C19_CREATURE_MATERIALIZER_ZYTAZ:
                case C23_CREATURE_LORD_CHAOS:
                case C25_CREATURE_LORD_ORDER:
                case C26_CREATURE_GREY_LORD:
                        return M513_SOUND_COUNT + 1;
                        break;
                case C02_CREATURE_GIGGLER:
#ifdef MEDIA349_G14ED
                case C05_CREATURE_RUSTER:
#endif
                case C09_CREATURE_STONE_GOLEM:
                case C10_CREATURE_MUMMY:
                case C14_CREATURE_VEXIRK:
                case C16_CREATURE_TROLIN_ANTMAN:
                case C22_CREATURE_DEMON:
                        return C24_SOUND_MOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON;
                        break;
                case C00_CREATURE_GIANT_SCORPION_SCORPION:
                case C04_CREATURE_PAIN_RAT_HELLHOUND:
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                case C05_CREATURE_RUSTER:
#endif
                case C06_CREATURE_SCREAMER:
                case C07_CREATURE_ROCK_ROCKPILE:
                case C15_CREATURE_MAGENTA_WORM_WORM:
                case C21_CREATURE_OITU:
#ifdef MEDIA349_G14ED
                case C24_CREATURE_RED_DRAGON:
#endif
                        return C26_SOUND_MOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU;
                        break;
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                case C24_CREATURE_RED_DRAGON:
                        return C32_SOUND_MOVE_RED_DRAGON;
                        break;
#endif
                case C12_CREATURE_SKELETON:
#ifdef MEDIA389_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                        return C33_SOUND_MOVE_SKELETON;
                        break;
#endif
                case C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT:
                        return C22_SOUND_MOVE_ANIMATED_ARMOUR_DETH_KNIGHT;
                        break;
                case C01_CREATURE_SWAMP_SLIME_SLIME_DEVIL:
                case C20_CREATURE_WATER_ELEMENTAL:
                        return C27_SOUND_MOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL;
                        break;
                case C13_CREATURE_COUATL:
                case C17_CREATURE_GIANT_WASP_MUNCHER:
                        return C23_SOUND_MOVE_COUATL_GIANT_WASP_MUNCHER;
                        break;
        }
#endif
#ifdef MEDIA485_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L3025_i_SoundOrdinal;


        if (G0300_B_PartyIsResting) {
                return -1;
        }
        if ((L3025_i_SoundOrdinal = G0243_as_Graphic559_CreatureInfo[P2099_i_Type].AttackSoundOrdinal) != 0) {
                return G2003_aauc_CreatureSounds[M001_ORDINAL_TO_INDEX(L3025_i_SoundOrdinal)][C1_MOVEMENT_SOUND];
        } else {
                return -1;
        }
#endif
}
#endif

void F0268_SENSOR_AddEvent(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0562_uc_Type, P0563_uc_MapX, P0564_uc_MapY, P0565_uc_Cell, P0566_uc_Effect, P0567_l_Time)
#endif
unsigned char P0562_uc_Type   SEPARATOR
unsigned char P0563_uc_MapX   SEPARATOR
unsigned char P0564_uc_MapY   SEPARATOR
unsigned char P0565_uc_Cell   SEPARATOR
unsigned char P0566_uc_Effect SEPARATOR
long          P0567_l_Time    FINAL_SEPARATOR
{
        EVENT L0729_s_Event;


        M033_SET_MAP_AND_TIME(L0729_s_Event.Map_Time, G0272_i_CurrentMapIndex, P0567_l_Time);
        L0729_s_Event.A.A.Type = P0562_uc_Type;
#ifdef MEDIA047_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        L0729_s_Event.A.A.Priority = 0;
#endif
#ifdef MEDIA716_I34E_I34M_A36M
        switch (P0566_uc_Effect) {
                case C01_EFFECT_CLEAR:
                        L0729_s_Event.A.A.Priority = 3;
                        break;
                case C02_EFFECT_TOGGLE:
                        L0729_s_Event.A.A.Priority = 2;
                        break;
                case C00_EFFECT_SET:
                        L0729_s_Event.A.A.Priority = 1;
        }
#endif
        L0729_s_Event.B.Location.MapX = P0563_uc_MapX;
        L0729_s_Event.B.Location.MapY = P0564_uc_MapY;
        L0729_s_Event.C.A.Cell = P0565_uc_Cell;
        L0729_s_Event.C.A.Effect = P0566_uc_Effect;
        F0238_TIMELINE_AddEvent_GetEventIndex_CPSE(&L0729_s_Event);
}

STATICFUNCTION void F0269_SENSOR_AddSkillExperience(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0568_i_SkillIndex, P0569_ui_Experience, P0570_B_LeaderOnly)
#endif
int16_t                   P0568_i_SkillIndex  SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
unsigned int16_t          P0569_ui_Experience SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER unsigned int16_t P0569_ui_Experience SEPARATOR
#endif
BOOLEAN                   P0570_B_LeaderOnly  FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER CHAMPION* L0731_ps_Champion;
#endif
        REGISTER unsigned int16_t L0730_ui_ChampionIndex;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER CHAMPION* L0731_ps_Champion;
#endif


        if (P0570_B_LeaderOnly) {
                if (G0411_i_LeaderIndex != CM1_CHAMPION_NONE) {
                        F0304_CHAMPION_AddSkillExperience(G0411_i_LeaderIndex, P0568_i_SkillIndex, P0569_ui_Experience);
                }
        } else {
                P0569_ui_Experience /= G0305_ui_PartyChampionCount;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                for (L0730_ui_ChampionIndex = C00_CHAMPION_FIRST, L0731_ps_Champion = M516_CHAMPIONS; L0730_ui_ChampionIndex < G0305_ui_PartyChampionCount; L0730_ui_ChampionIndex++, L0731_ps_Champion++) {
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                L0731_ps_Champion = M516_CHAMPIONS;
                for (L0730_ui_ChampionIndex = C00_CHAMPION_FIRST; L0730_ui_ChampionIndex < G0305_ui_PartyChampionCount; L0731_ps_Champion++, L0730_ui_ChampionIndex++) {
#endif
                        if (L0731_ps_Champion->CurrentHealth) {
                                F0304_CHAMPION_AddSkillExperience(L0730_ui_ChampionIndex, P0568_i_SkillIndex, P0569_ui_Experience);
                        }
                }
        }
}

/* While processing a list of sensors, this function may be called several times. The rotation effect of the last processed sensor is stored in global variables. When processing of the list of sensors is complete, a call to F0271_SENSOR_ProcessRotationEffect is made to perform the actual effect (either nothing or a rotation of the list of sensors). This ensures that only one rotation can occur when processing sensors on a given square */
STATICFUNCTION void F0270_SENSOR_TriggerLocalEffect(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0571_i_SensorLocalEffect, P0572_i_SensorLocalEffectX, P0573_i_SensorLocalEffectY, P0574_i_SensorLocalEffectCell)
#endif
int16_t P0571_i_SensorLocalEffect     SEPARATOR
int16_t P0572_i_SensorLocalEffectX    SEPARATOR
int16_t P0573_i_SensorLocalEffectY    SEPARATOR
int16_t P0574_i_SensorLocalEffectCell FINAL_SEPARATOR
{
        if (P0571_i_SensorLocalEffect == C10_EFFECT_ADD_300XP_STEAL_SKILL) {
                F0269_SENSOR_AddSkillExperience(C08_SKILL_STEAL, 300, P0574_i_SensorLocalEffectCell != CM1_CELL_ANY);
                return;
        }
        G0403_i_SensorRotationEffect = P0571_i_SensorLocalEffect;
        G0404_i_SensorRotationEffectMapX = P0572_i_SensorLocalEffectX;
        G0405_i_SensorRotationEffectMapY = P0573_i_SensorLocalEffectY;
        G0406_i_SensorRotationEffectCell = P0574_i_SensorLocalEffectCell;
}

void F0271_SENSOR_ProcessRotationEffect(
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
void
#endif
)
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER SENSOR* L0735_ps_LastSensor;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER THING L0732_T_FirstSensorThing;
#endif
        REGISTER THING L0733_T_LastSensorThing;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER THING L0732_T_FirstSensorThing;
#endif
        REGISTER SENSOR* L0734_ps_FirstSensor;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER SENSOR* L0735_ps_LastSensor;
#endif


        if (G0403_i_SensorRotationEffect == CM1_EFFECT_NONE)
                return;
        switch (G0403_i_SensorRotationEffect) {
                case C01_EFFECT_CLEAR:
                case C02_EFFECT_TOGGLE:
                        L0732_T_FirstSensorThing = F0161_DUNGEON_GetSquareFirstThing(G0404_i_SensorRotationEffectMapX, G0405_i_SensorRotationEffectMapY);
                        while (!((M012_TYPE(L0732_T_FirstSensorThing) == C03_THING_TYPE_SENSOR) && ((G0406_i_SensorRotationEffectCell == CM1_CELL_ANY) || (M011_CELL(L0732_T_FirstSensorThing) == G0406_i_SensorRotationEffectCell)))) {
                                L0732_T_FirstSensorThing = F0159_DUNGEON_GetNextThing(L0732_T_FirstSensorThing);
                        }
                        L0734_ps_FirstSensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0732_T_FirstSensorThing);
                        L0733_T_LastSensorThing = L0734_ps_FirstSensor->Remote.Next;
                        while ((L0733_T_LastSensorThing != C0xFFFE_THING_ENDOFLIST) && !((M012_TYPE(L0733_T_LastSensorThing) == C03_THING_TYPE_SENSOR) && ((G0406_i_SensorRotationEffectCell == CM1_CELL_ANY) || (M011_CELL(L0733_T_LastSensorThing) == G0406_i_SensorRotationEffectCell)))) {
                                L0733_T_LastSensorThing = F0159_DUNGEON_GetNextThing(L0733_T_LastSensorThing);
                        }
                        if (L0733_T_LastSensorThing == C0xFFFE_THING_ENDOFLIST)
                                break;
                        F0164_DUNGEON_UnlinkThingFromList(L0732_T_FirstSensorThing, 0, G0404_i_SensorRotationEffectMapX, G0405_i_SensorRotationEffectMapY);
                        L0735_ps_LastSensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0733_T_LastSensorThing);
                        L0733_T_LastSensorThing = F0159_DUNGEON_GetNextThing(L0733_T_LastSensorThing);
                        while (((L0733_T_LastSensorThing != C0xFFFE_THING_ENDOFLIST) && (M012_TYPE(L0733_T_LastSensorThing) == C03_THING_TYPE_SENSOR))) {
                                if ((G0406_i_SensorRotationEffectCell == CM1_CELL_ANY) || (M011_CELL(L0733_T_LastSensorThing) == G0406_i_SensorRotationEffectCell)) {
                                        L0735_ps_LastSensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0733_T_LastSensorThing);
                                }
                                L0733_T_LastSensorThing = F0159_DUNGEON_GetNextThing(L0733_T_LastSensorThing);
                        }
                        L0734_ps_FirstSensor->Remote.Next = L0735_ps_LastSensor->Remote.Next;
                        L0735_ps_LastSensor->Remote.Next = L0732_T_FirstSensorThing;
                        break;
        }
        G0403_i_SensorRotationEffect = CM1_EFFECT_NONE;
}

void F0272_SENSOR_TriggerEffect(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0575_ps_Sensor, P0576_i_Effect, P0577_i_MapX, P0578_i_MapY, P0579_i_Cell)
#endif
REGISTER SENSOR* P0575_ps_Sensor SEPARATOR
int16_t          P0576_i_Effect  SEPARATOR
int16_t          P0577_i_MapX    SEPARATOR
int16_t          P0578_i_MapY    SEPARATOR
int16_t          P0579_i_Cell    FINAL_SEPARATOR
{
#ifdef MEDIA063_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA
        register int16_t L0736_i_TargetMapX;
        register int16_t L0737_i_TargetMapY;
        register long L0738_l_Time;
#endif
#ifdef MEDIA488_F20E_F20J
        register int16_t L0736_i_TargetMapX;/* ANOMALY_FMT register keyword required */
        register int16_t L0737_i_TargetMapY;/* ANOMALY_FMT register keyword required */
        register long L0738_l_Time; /* ANOMALY_FMT register keyword required  */
#endif
#ifdef MEDIA485_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER int16_t L0736_i_TargetMapX;
        REGISTER int16_t L0737_i_TargetMapY;
#endif
        REGISTER unsigned int16_t L0739_ui_SquareType;
#ifdef MEDIA063_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA
        unsigned int16_t L0740_ui_TargetCell;
#endif
#ifdef MEDIA488_F20E_F20J
        unsigned int16_t L0740_ui_TargetCell;
#endif
#ifdef MEDIA485_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER long L0738_l_Time;
        REGISTER unsigned int16_t L0740_ui_TargetCell;
#endif


        if (P0575_ps_Sensor->Remote.OnceOnly) {
                M044_SET_TYPE_DISABLED(P0575_ps_Sensor);
        }
        L0738_l_Time = G0313_ul_GameTime + P0575_ps_Sensor->Remote.Value;
        if (P0575_ps_Sensor->Remote.LocalEffect) {
                F0270_SENSOR_TriggerLocalEffect(M049_LOCAL_EFFECT(P0575_ps_Sensor), P0577_i_MapX, P0578_i_MapY, P0579_i_Cell);
        } else {
                L0736_i_TargetMapX = P0575_ps_Sensor->Remote.TargetMapX;
                L0737_i_TargetMapY = P0575_ps_Sensor->Remote.TargetMapY;
                L0739_ui_SquareType = M034_SQUARE_TYPE(G0271_ppuc_CurrentMapData[L0736_i_TargetMapX][L0737_i_TargetMapY]);
                if (L0739_ui_SquareType == C00_ELEMENT_WALL) {
                        L0740_ui_TargetCell = P0575_ps_Sensor->Remote.TargetCell;
                } else {
                        L0740_ui_TargetCell = C00_CELL_NORTHWEST;
                }
                F0268_SENSOR_AddEvent(G0059_auc_Graphic562_SquareTypeToEventType[L0739_ui_SquareType], L0736_i_TargetMapX, L0737_i_TargetMapY, L0740_ui_TargetCell, P0576_i_Effect, L0738_l_Time);
        }
}

THING F0273_SENSOR_GetObjectOfTypeInCell(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0580_i_MapX, P0581_i_MapY, P0582_i_Cell, P0583_ui_ObjectType)
#endif
int16_t                   P0580_i_MapX        SEPARATOR
int16_t                   P0581_i_MapY        SEPARATOR
REGISTER int16_t          P0582_i_Cell        SEPARATOR
REGISTER unsigned int16_t P0583_ui_ObjectType FINAL_SEPARATOR
{
        REGISTER THING L0741_T_Thing;


        L0741_T_Thing = F0162_DUNGEON_GetSquareFirstObject(P0580_i_MapX, P0581_i_MapY);
        while (L0741_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                if (F0032_OBJECT_GetType(L0741_T_Thing) == P0583_ui_ObjectType) {
                        if ((P0582_i_Cell == CM1_CELL_ANY) || (M011_CELL(L0741_T_Thing) == P0582_i_Cell)) {
                                return L0741_T_Thing;
                        }
                }
                L0741_T_Thing = F0159_DUNGEON_GetNextThing(L0741_T_Thing);
        }
        return C0xFFFF_THING_NONE;
}

STATICFUNCTION BOOLEAN F0274_SENSOR_IsObjectInPartyPossession(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0584_i_ObjectType)
register int16_t P0584_i_ObjectType FINAL_SEPARATOR
#endif
#ifdef MEDIA595_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_X31J_P31J
int16_t P0584_i_ObjectType FINAL_SEPARATOR
#endif
#ifdef MEDIA551_F20E_F20J_F31E_F31J
register int16_t P0584_i_ObjectType FINAL_SEPARATOR
#endif
{
#ifdef MEDIA069_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER CHAMPION* L0745_ps_Champion;
        REGISTER THING* L0746_pT_Thing;
#endif
#ifdef MEDIA488_F20E_F20J
        register CHAMPION* L0745_ps_Champion; /* ANOMALY_FMT register keyword required */
        register THING* L0746_pT_Thing; /* ANOMALY_FMT register keyword required */
#endif
#ifdef MEDIA014_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J
        REGISTER unsigned int16_t L0742_ui_ChampionIndex;
        REGISTER unsigned int16_t L0743_ui_SlotIndex;
        REGISTER THING L0744_T_Thing;
        int16_t L0747_i_ObjectType;
        BOOLEAN L0748_B_LeaderHandObjectProcessed;
        CONTAINER* L0749_ps_Container;
#endif
#ifdef MEDIA593_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER CONTAINER* L0749_ps_Container;
        REGISTER THING L0744_T_Thing;
        REGISTER unsigned int16_t L0743_ui_SlotIndex;
        REGISTER unsigned int16_t L0742_ui_ChampionIndex;
        REGISTER BOOLEAN L0748_B_LeaderHandObjectProcessed;
        REGISTER int16_t L0747_i_ObjectType;
#endif


        L0748_B_LeaderHandObjectProcessed = C0_FALSE;
        for (L0742_ui_ChampionIndex = C00_CHAMPION_FIRST, L0745_ps_Champion = M516_CHAMPIONS; L0742_ui_ChampionIndex < G0305_ui_PartyChampionCount; L0742_ui_ChampionIndex++, L0745_ps_Champion++) {
                if (L0745_ps_Champion->CurrentHealth) {
                        L0746_pT_Thing = L0745_ps_Champion->Slots;
                        for (L0743_ui_SlotIndex = C00_SLOT_READY_HAND; (L0743_ui_SlotIndex < C30_SLOT_CHEST_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) {
                                L0744_T_Thing = *L0746_pT_Thing++;
                                T0274003:
                                if ((L0747_i_ObjectType = F0032_OBJECT_GetType(L0744_T_Thing)) == P0584_i_ObjectType) {
                                        return C1_TRUE;
                                }
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* ANOMALY_ST_BRANCH */
                                else {
#endif
                                        if (L0747_i_ObjectType == C144_ICON_CONTAINER_CHEST_CLOSED) {
                                                L0749_ps_Container = (CONTAINER*)F0156_DUNGEON_GetThingData(L0744_T_Thing);
                                                L0744_T_Thing = L0749_ps_Container->Slot;
                                                while (L0744_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                                                        if (F0032_OBJECT_GetType(L0744_T_Thing) == P0584_i_ObjectType) {
                                                                return C1_TRUE;
                                                        }
                                                        L0744_T_Thing = F0159_DUNGEON_GetNextThing(L0744_T_Thing);
                                                }
                                        }
#ifdef MEDIA365_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                }
#endif
                        }
                }
        }
        if (!L0748_B_LeaderHandObjectProcessed) {
                L0748_B_LeaderHandObjectProcessed = C1_TRUE;
                L0744_T_Thing = G4055_s_LeaderHandObject.Thing;
                goto T0274003;
        }
        return C0_FALSE;
}

BOOLEAN F0275_SENSOR_IsTriggeredByClickOnWall(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0585_i_MapX, P0586_i_MapY, P0587_ui_Cell)
int16_t          P0585_i_MapX  SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER int16_t P0585_i_MapX  SEPARATOR
#endif
int16_t          P0586_i_MapY  SEPARATOR
unsigned int16_t P0587_ui_Cell FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER SENSOR* L0755_ps_Sensor;
        REGISTER GENERIC* L0754_ps_Generic;
#endif
        REGISTER THING L0750_T_ThingBeingProcessed;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER GENERIC* L0754_ps_Generic;
        REGISTER unsigned int16_t L0751_ui_ThingType;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER THING L0761_T_LeaderHandObject;
#endif
        REGISTER unsigned int16_t L0752_ui_Cell;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        REGISTER SENSOR* L0755_ps_Sensor;
#endif
        REGISTER BOOLEAN L0753_B_DoNotTriggerSensor;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0756_i_SensorEffect;
#endif
        unsigned int16_t L0757_ui_SensorType;
        unsigned int16_t L0758_ui_SensorData;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L0756_i_SensorEffect;
        REGISTER unsigned int16_t L0751_ui_ThingType;
#endif
        BOOLEAN L0759_B_AtLeastOneSensorWasTriggered;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0760_ai_SensorCountToProcessPerCell[4];
        THING L0761_T_LeaderHandObject;
        THING L0762_T_ThingOnSquare;
#endif
        THING L0763_T_LastProcessedThing;
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        THING L0762_T_ThingOnSquare;
#endif
        THING L0764_T_SquareFirstThing;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        SENSOR* L0765_ps_Sensor;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        int16_t L0760_ai_SensorCountToProcessPerCell[4];
#endif


        L0759_B_AtLeastOneSensorWasTriggered = C0_FALSE;
        L0761_T_LeaderHandObject = G4055_s_LeaderHandObject.Thing;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        for (L0752_ui_Cell = C00_CELL_NORTHWEST; L0752_ui_Cell < C03_CELL_SOUTHWEST + 1; L0752_ui_Cell++) {
                L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell] = 0;
        }
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        F0008_MAIN_ClearBytes(M772_CAST_PC(L0760_ai_SensorCountToProcessPerCell), (long)sizeof(L0760_ai_SensorCountToProcessPerCell));
#endif
        L0764_T_SquareFirstThing = L0750_T_ThingBeingProcessed = F0161_DUNGEON_GetSquareFirstThing(P0585_i_MapX, P0586_i_MapY);
        while (L0750_T_ThingBeingProcessed != C0xFFFE_THING_ENDOFLIST) {
                if ((L0751_ui_ThingType = M012_TYPE(L0750_T_ThingBeingProcessed)) == C03_THING_TYPE_SENSOR) {
                        L0760_ai_SensorCountToProcessPerCell[M011_CELL(L0750_T_ThingBeingProcessed)]++;
                } else {
                        if (L0751_ui_ThingType >= C04_THING_TYPE_GROUP)
                                break;
                }
                L0750_T_ThingBeingProcessed = F0159_DUNGEON_GetNextThing(L0750_T_ThingBeingProcessed);
        }
        L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed = L0764_T_SquareFirstThing;
        while (L0750_T_ThingBeingProcessed != C0xFFFE_THING_ENDOFLIST) {
                if ((L0751_ui_ThingType = M012_TYPE(L0750_T_ThingBeingProcessed)) == C03_THING_TYPE_SENSOR) {
                        L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = M011_CELL(L0750_T_ThingBeingProcessed)]--;
                        L0755_ps_Sensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0750_T_ThingBeingProcessed);
                        if ((L0757_ui_SensorType = M039_TYPE(L0755_ps_Sensor)) == C000_SENSOR_DISABLED)
                                goto T0275058_ProceedToNextThing;
                        if ((G0411_i_LeaderIndex == CM1_CHAMPION_NONE) && (L0757_ui_SensorType != C127_SENSOR_WALL_CHAMPION_PORTRAIT))
                                goto T0275058_ProceedToNextThing;
                        if (L0752_ui_Cell != P0587_ui_Cell)
                                goto T0275058_ProceedToNextThing;
                        L0758_ui_SensorData = M040_DATA(L0755_ps_Sensor);
                        L0756_i_SensorEffect = L0755_ps_Sensor->Remote.Effect;
                        switch (L0757_ui_SensorType) {
                                case C001_SENSOR_WALL_ORNAMENT_CLICK:
                                        L0753_B_DoNotTriggerSensor = C0_FALSE;
                                        if (L0755_ps_Sensor->Remote.Effect == C03_EFFECT_HOLD) {
                                                goto T0275058_ProceedToNextThing;
                                        }
                                        break;
                                case C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT:
                                        L0753_B_DoNotTriggerSensor = (G0415_ui_LeaderEmptyHanded != L0755_ps_Sensor->Remote.RevertEffect);
                                        break;
                                case C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR:
                                case C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS:
                                        if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
                                                goto T0275058_ProceedToNextThing;
                                case C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT:
                                case C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED:
                                        L0753_B_DoNotTriggerSensor = ((L0758_ui_SensorData == F0032_OBJECT_GetType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->Remote.RevertEffect);
                                        if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR)) {
                                                if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */
                                                        break;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                                L0765_ps_Sensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0763_T_LastProcessedThing);
                                                L0765_ps_Sensor->Remote.Next = L0755_ps_Sensor->Remote.Next;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                                L0754_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(L0763_T_LastProcessedThing);
                                                ((SENSOR*)L0754_ps_Generic)->Remote.Next = L0755_ps_Sensor->Remote.Next;
#endif
                                                L0755_ps_Sensor->Remote.Next = C0xFFFF_THING_NONE;
                                                L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing;
                                        }
                                        if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS)) {
#ifdef PC_FIX_CODE_SIZE
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
        L0750_T_ThingBeingProcessed++;
#endif
                                                F0270_SENSOR_TriggerLocalEffect(C02_EFFECT_TOGGLE, P0585_i_MapX, P0586_i_MapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
                                        }
                                        break;
                                case C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS:
                                        if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
                                                goto T0275058_ProceedToNextThing;
                                        L0753_B_DoNotTriggerSensor = !G0415_ui_LeaderEmptyHanded;
                                        if (!L0753_B_DoNotTriggerSensor) {
                                                F0270_SENSOR_TriggerLocalEffect(C02_EFFECT_TOGGLE, P0585_i_MapX, P0586_i_MapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
                                        }
                                        break;
                                case C013_SENSOR_WALL_SINGLE_OBJECT_STORAGE_ROTATE_SENSORS:
                                        if (G0415_ui_LeaderEmptyHanded) {
                                                if ((L0761_T_LeaderHandObject = F0273_SENSOR_GetObjectOfTypeInCell(P0585_i_MapX, P0586_i_MapY, L0752_ui_Cell, L0758_ui_SensorData)) == C0xFFFF_THING_NONE)
                                                        goto T0275058_ProceedToNextThing;
                                                F0164_DUNGEON_UnlinkThingFromList(L0761_T_LeaderHandObject, 0, P0585_i_MapX, P0586_i_MapY);
                                                F0297_CHAMPION_PutObjectInLeaderHand(L0761_T_LeaderHandObject, C1_TRUE);
                                        } else {
                                                if ((F0032_OBJECT_GetType(L0761_T_LeaderHandObject) != L0758_ui_SensorData) || (F0273_SENSOR_GetObjectOfTypeInCell(P0585_i_MapX, P0586_i_MapY, L0752_ui_Cell, L0758_ui_SensorData) != C0xFFFF_THING_NONE))
                                                        goto T0275058_ProceedToNextThing;
                                                F0298_CHAMPION_GetObjectRemovedFromLeaderHand();
                                                F0163_DUNGEON_LinkThingToList(M015_THING_WITH_NEW_CELL(L0761_T_LeaderHandObject, L0752_ui_Cell), 0, P0585_i_MapX, P0586_i_MapY);
                                                L0761_T_LeaderHandObject = C0xFFFF_THING_NONE;
                                        }
                                        F0270_SENSOR_TriggerLocalEffect(C02_EFFECT_TOGGLE, P0585_i_MapX, P0586_i_MapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
                                        if ((L0756_i_SensorEffect == C03_EFFECT_HOLD) && !G0415_ui_LeaderEmptyHanded) {
                                                L0753_B_DoNotTriggerSensor = C1_TRUE;
                                        } else {
                                                L0753_B_DoNotTriggerSensor = C0_FALSE;
                                        }
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
                                        L0753_B_DoNotTriggerSensor = (L0756_i_SensorEffect == C03_EFFECT_HOLD) && !G0415_ui_LeaderEmptyHanded;
#endif
                                        break;
                                case C016_SENSOR_WALL_OBJECT_EXCHANGER:
                                        if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
                                                goto T0275058_ProceedToNextThing;
                                        L0762_T_ThingOnSquare = F0162_DUNGEON_GetSquareFirstObject(P0585_i_MapX, P0586_i_MapY);
                                        if ((F0032_OBJECT_GetType(L0761_T_LeaderHandObject) != L0758_ui_SensorData) || (L0762_T_ThingOnSquare == C0xFFFF_THING_NONE))
                                                goto T0275058_ProceedToNextThing;
                                        F0164_DUNGEON_UnlinkThingFromList(L0762_T_ThingOnSquare, 0, P0585_i_MapX, P0586_i_MapY);
                                        F0298_CHAMPION_GetObjectRemovedFromLeaderHand();
                                        F0163_DUNGEON_LinkThingToList(M015_THING_WITH_NEW_CELL(L0761_T_LeaderHandObject, L0752_ui_Cell), 0, P0585_i_MapX, P0586_i_MapY);
                                        F0297_CHAMPION_PutObjectInLeaderHand(L0762_T_ThingOnSquare, C1_TRUE);
                                        L0753_B_DoNotTriggerSensor = C0_FALSE;
                                        break;
                                case C127_SENSOR_WALL_CHAMPION_PORTRAIT:
                                        F0280_CHAMPION_AddCandidateChampionToParty(L0758_ui_SensorData);
                                        goto T0275058_ProceedToNextThing;
#ifdef MEDIA006_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB /* CHANGE7_14_FIX Useless code removed */
                                case C005_SENSOR_WALL_AND_OR_GATE: /* BUG0_00 Useless code */
                                case C006_SENSOR_WALL_COUNTDOWN:
                                case C007_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_NEW_OBJECT:
                                case C008_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_EXPLOSION:
                                case C009_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_NEW_OBJECT:
                                case C010_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_EXPLOSION:
                                case C014_SENSOR_WALL_SINGLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT:
                                case C015_SENSOR_WALL_DOUBLE_PROJECTILE_LAUNCHER_SQUARE_OBJECT:
                                        goto T0275058_ProceedToNextThing;
#endif
                                default:
                                        goto T0275058_ProceedToNextThing;
                        }
                        if (L0756_i_SensorEffect == C03_EFFECT_HOLD) {
                                L0756_i_SensorEffect = L0753_B_DoNotTriggerSensor ? C01_EFFECT_CLEAR : C00_EFFECT_SET;
                                L0753_B_DoNotTriggerSensor = C0_FALSE;
                        }
                        if (!L0753_B_DoNotTriggerSensor) {
                                L0759_B_AtLeastOneSensorWasTriggered = C1_TRUE;
                                if (L0755_ps_Sensor->Remote.Audible) {
                                        F0064_SOUND_RequestPlay_CPSD(C01_SOUND_SWITCH, G0306_i_PartyMapX, G0307_i_PartyMapY, C01_MODE_PLAY_IF_PRIORITIZED);
                                }
                                if (!G0415_ui_LeaderEmptyHanded && ((L0757_ui_SensorType == C004_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED) || (L0757_ui_SensorType == C011_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_ROTATE_SENSORS) || (L0757_ui_SensorType == C017_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT_REMOVED_REMOVE_SENSOR))) {
                                        L0754_ps_Generic = (GENERIC*)F0156_DUNGEON_GetThingData(L0761_T_LeaderHandObject);
                                        L0754_ps_Generic->Next = C0xFFFF_THING_NONE;
                                        F0298_CHAMPION_GetObjectRemovedFromLeaderHand();
                                        L0761_T_LeaderHandObject = C0xFFFF_THING_NONE;
                                } else {
                                        if (G0415_ui_LeaderEmptyHanded &&
                                           (L0757_ui_SensorType == C012_SENSOR_WALL_OBJECT_GENERATOR_ROTATE_SENSORS) &&
                                           ((L0761_T_LeaderHandObject = F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator(L0758_ui_SensorData)) != C0xFFFF_THING_NONE)) {
                                                F0297_CHAMPION_PutObjectInLeaderHand(L0761_T_LeaderHandObject, C1_TRUE);
                                        }
                                }
                                F0272_SENSOR_TriggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, P0585_i_MapX, P0586_i_MapY, L0752_ui_Cell);
                        }
                        goto T0275058_ProceedToNextThing;
                }
                if (L0751_ui_ThingType >= C04_THING_TYPE_GROUP)
                        break;
                T0275058_ProceedToNextThing:
                L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed;
                L0750_T_ThingBeingProcessed = F0159_DUNGEON_GetNextThing(L0750_T_ThingBeingProcessed);
        }
        F0271_SENSOR_ProcessRotationEffect();
        return L0759_B_AtLeastOneSensorWasTriggered;
}

void F0276_SENSOR_ProcessThingAdditionOrRemoval(
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
P0588_ui_MapX, P0589_ui_MapY, P0590_T_Thing, P0591_B_PartySquare, P0592_B_AddThing)
#endif
unsigned int16_t P0588_ui_MapX       SEPARATOR
unsigned int16_t P0589_ui_MapY       SEPARATOR
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
THING            P0590_T_Thing       SEPARATOR
REGISTER BOOLEAN P0591_B_PartySquare SEPARATOR
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
REGISTER THING   P0590_T_Thing       SEPARATOR
BOOLEAN          P0591_B_PartySquare SEPARATOR
#endif
BOOLEAN          P0592_B_AddThing    FINAL_SEPARATOR
{
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER SENSOR* L0769_ps_Sensor;
#endif
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L0770_ui_SensorTriggeredCell;
#endif
        REGISTER THING L0766_T_Thing;
        REGISTER int16_t L0767_i_ThingType;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L0771_ui_ThingType;
        REGISTER SENSOR* L0769_ps_Sensor;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        REGISTER BOOLEAN L0768_B_TriggerSensor;
        REGISTER unsigned int16_t L0771_ui_ThingType;
        int16_t L0779_i_SensorData;
        int16_t L0770_ui_SensorTriggeredCell;
        int16_t L0774_i_ObjectType;
#endif
        BOOLEAN L0772_B_SquareContainsObject;
        BOOLEAN L0773_B_SquareContainsGroup;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0774_i_ObjectType;
#endif
        BOOLEAN L0775_B_SquareContainsThingOfSameType;
        BOOLEAN L0776_B_SquareContainsThingOfDifferentType;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        unsigned int16_t L0777_ui_Square;
        REGISTER BOOLEAN L0768_B_TriggerSensor;
#endif
        int16_t L0778_i_Effect;
#ifdef MEDIA009_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G
        int16_t L0779_i_SensorData;
#endif
#ifdef MEDIA529_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J
        unsigned int16_t L0777_ui_Square;
#endif


        if (P0590_T_Thing != C0xFFFF_THING_PARTY) {
                L0767_i_ThingType = M012_TYPE(P0590_T_Thing);
                L0774_i_ObjectType = F0032_OBJECT_GetType(P0590_T_Thing);
        } else {
                L0767_i_ThingType = CM1_THING_TYPE_PARTY;
                L0774_i_ObjectType = C0xFFFF_ICON_NONE;
        }
        if ((!P0592_B_AddThing) && (L0767_i_ThingType != CM1_THING_TYPE_PARTY)) {
                F0164_DUNGEON_UnlinkThingFromList(P0590_T_Thing, 0, P0588_ui_MapX, P0589_ui_MapY);
        }
        if (M034_SQUARE_TYPE(L0777_ui_Square = G0271_ppuc_CurrentMapData[P0588_ui_MapX][P0589_ui_MapY]) == C00_ELEMENT_WALL) {
                L0770_ui_SensorTriggeredCell = M011_CELL(P0590_T_Thing);
        } else {
                L0770_ui_SensorTriggeredCell = CM1_CELL_ANY;
        }
        L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = C0_FALSE;
        L0766_T_Thing = F0161_DUNGEON_GetSquareFirstThing(P0588_ui_MapX, P0589_ui_MapY);
        if (L0770_ui_SensorTriggeredCell == CM1_CELL_ANY) {
                while (L0766_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                        if ((L0771_ui_ThingType = M012_TYPE(L0766_T_Thing)) == C04_THING_TYPE_GROUP) {
                                L0773_B_SquareContainsGroup = C1_TRUE;
                        } else {
                                if ((L0771_ui_ThingType == C02_THING_TYPE_TEXTSTRING) && (L0767_i_ThingType == CM1_THING_TYPE_PARTY) && P0592_B_AddThing && !P0591_B_PartySquare) {
                                        F0168_DUNGEON_DecodeText(M774_CAST_PUC(G0353_ac_StringBuildBuffer), L0766_T_Thing, C1_TEXT_TYPE_MESSAGE);
                                        F0047_TEXT_MESSAGEAREA_PrintMessage(C15_COLOR_WHITE, G0353_ac_StringBuildBuffer);
                                } else {
                                        if ((L0771_ui_ThingType > C04_THING_TYPE_GROUP) && (L0771_ui_ThingType < C14_THING_TYPE_PROJECTILE)) {
                                                L0772_B_SquareContainsObject = C1_TRUE;
                                                L0775_B_SquareContainsThingOfSameType |= (F0032_OBJECT_GetType(L0766_T_Thing) == L0774_i_ObjectType);
                                                L0776_B_SquareContainsThingOfDifferentType |= (F0032_OBJECT_GetType(L0766_T_Thing) != L0774_i_ObjectType);
                                        }
                                }
                        }
                        L0766_T_Thing = F0159_DUNGEON_GetNextThing(L0766_T_Thing);
                }
        } else {
                while (L0766_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                        if ((L0770_ui_SensorTriggeredCell == M011_CELL(L0766_T_Thing)) && (M012_TYPE(L0766_T_Thing) > C04_THING_TYPE_GROUP)) {
                                L0772_B_SquareContainsObject = C1_TRUE;
                                L0775_B_SquareContainsThingOfSameType |= (F0032_OBJECT_GetType(L0766_T_Thing) == L0774_i_ObjectType);
                                L0776_B_SquareContainsThingOfDifferentType |= (F0032_OBJECT_GetType(L0766_T_Thing) != L0774_i_ObjectType);
                        }
                        L0766_T_Thing = F0159_DUNGEON_GetNextThing(L0766_T_Thing);
                }
        }
        if (P0592_B_AddThing && (L0767_i_ThingType != CM1_THING_TYPE_PARTY)) {
                F0163_DUNGEON_LinkThingToList(P0590_T_Thing, 0, P0588_ui_MapX, P0589_ui_MapY);
        }
        L0766_T_Thing = F0161_DUNGEON_GetSquareFirstThing(P0588_ui_MapX, P0589_ui_MapY);
        while (L0766_T_Thing != C0xFFFE_THING_ENDOFLIST) {
                if ((L0771_ui_ThingType = M012_TYPE(L0766_T_Thing)) == C03_THING_TYPE_SENSOR) {
                        L0769_ps_Sensor = (SENSOR*)F0156_DUNGEON_GetThingData(L0766_T_Thing);
                        if (M039_TYPE(L0769_ps_Sensor) == C000_SENSOR_DISABLED)
                                goto T0276079;
                        L0779_i_SensorData = M040_DATA(L0769_ps_Sensor);
                        L0768_B_TriggerSensor = P0592_B_AddThing;
                        if (L0770_ui_SensorTriggeredCell == CM1_CELL_ANY) {
                                switch (M039_TYPE(L0769_ps_Sensor)) {
                                        case C001_SENSOR_FLOOR_THERON_PARTY_CREATURE_OBJECT:
                                                if (P0591_B_PartySquare || L0772_B_SquareContainsObject || L0773_B_SquareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
                                                        goto T0276079;
                                                break;
                                        case C002_SENSOR_FLOOR_THERON_PARTY_CREATURE:
                                                if ((L0767_i_ThingType > C04_THING_TYPE_GROUP) || P0591_B_PartySquare || L0773_B_SquareContainsGroup)
                                                        goto T0276079;
                                                break;
                                        case C003_SENSOR_FLOOR_PARTY:
                                                if ((L0767_i_ThingType != CM1_THING_TYPE_PARTY) || (G0305_ui_PartyChampionCount == 0))
                                                        goto T0276079;
                                                if (L0779_i_SensorData == 0) {
                                                        if (P0591_B_PartySquare)
                                                                goto T0276079;
                                                } else {
                                                        if (!P0592_B_AddThing) {
                                                                L0768_B_TriggerSensor = C0_FALSE;
                                                        } else {
#ifdef PC_FIX_CODE_SIZE
        L0766_T_Thing++;
#endif
                                                                L0768_B_TriggerSensor = (L0779_i_SensorData == M000_INDEX_TO_ORDINAL(G0308_i_PartyDirection));
                                                        }
                                                }
                                                break;
                                        case C004_SENSOR_FLOOR_OBJECT:
                                                if ((L0779_i_SensorData != F0032_OBJECT_GetType(P0590_T_Thing)) || L0775_B_SquareContainsThingOfSameType)
                                                        goto T0276079;
                                                break;
                                        case C005_SENSOR_FLOOR_PARTY_ON_STAIRS:
#ifdef MEDIA176_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J /* CHANGE8_05_FIX */
                                                if ((L0771_ui_ThingType != CM1_THING_TYPE_PARTY) || (M034_SQUARE_TYPE(L0777_ui_Square) != C03_ELEMENT_STAIRS)) /* BUG0_31 Floor sensors to detect the party on a stairs square are never triggered. A wrong variable is used in a condition in the source code. This has no consequence in the games as this sensor type is not used in the original dungeons. The wrong variable is used in the condition (L0771_ui_ThingType != CM1_THING_TYPE_PARTY) which is always C1_TRUE */
#endif
#ifdef MEDIA346_S21E_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE8_05_FIX The wrong variable is replaced by the correct variable in the condition. The test should not be on L0771_ui_ThingType but on L0767_i_ThingType */
                                                if ((L0767_i_ThingType != CM1_THING_TYPE_PARTY) || (M034_SQUARE_TYPE(L0777_ui_Square) != C03_ELEMENT_STAIRS))
#endif
                                                        goto T0276079;
                                                break;
                                        case C006_SENSOR_FLOOR_GROUP_GENERATOR:
                                                goto T0276079;
                                        case C007_SENSOR_FLOOR_CREATURE:
                                                if ((L0767_i_ThingType > C04_THING_TYPE_GROUP) || (L0767_i_ThingType == CM1_THING_TYPE_PARTY) || L0773_B_SquareContainsGroup)
                                                        goto T0276079;
                                                break;
                                        case C008_SENSOR_FLOOR_PARTY_POSSESSION:
                                                if (L0767_i_ThingType != CM1_THING_TYPE_PARTY)
                                                        goto T0276079;
                                                L0768_B_TriggerSensor = F0274_SENSOR_IsObjectInPartyPossession(L0779_i_SensorData);
                                                break;
#ifdef MEDIA278_S20E_S21E_G14ED_G20E_G21E_A20ED_A20E_A20F_A20G_A21E_A22E_A22G_F20E_F20J_X30J_P20JA_P20JB_I34E_I34M_A36M_A31E_A31M_A33M_A35E_A35M_F31E_F31J_X31J_P31J /* CHANGE7_23_IMPROVEMENT New floor sensor type: version checker. This sensor is triggered only if its data value is smaller than or equal to the game engine version (hard coded as 20 for version 2.0). This sensor type is not used in the original dungeon */
                                        case C009_SENSOR_FLOOR_VERSION_CHECKER:
                                                if ((L0767_i_ThingType != CM1_THING_TYPE_PARTY) || !P0592_B_AddThing || P0591_B_PartySquare)
                                                        goto T0276079;
#ifdef MEDIA349_G14ED
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 14);
#endif
#ifdef MEDIA337_S20E_G20E_A20ED_A20E_A20F_A20G_A22G_F20E_F20J_P20JA_P20JB /* CHANGE8_06_IMPROVEMENT */
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 20);
#endif
#ifdef MEDIA342_S21E_G21E_A21E_A22E /* CHANGE8_06_IMPROVEMENT The hard coded game engine version for the version checker sensor is now 21 for version 2.1 */
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 21);
#endif
#ifdef MEDIA577_X30J
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 30);
#endif
#ifdef MEDIA633_A31E_A31M_F31E_F31J_X31J_P31J
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 31);
#endif
#ifdef MEDIA665_A33M
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 33);
#endif
#ifdef PC_FIX_CODE_SIZE
        L0766_T_Thing++;
        L0766_T_Thing++;
#endif
#ifdef MEDIA707_I34E_I34M
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 34);
#endif
#ifdef MEDIA741_A35E_A35M
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 35);
#endif
#ifdef MEDIA744_A36M
                                                L0768_B_TriggerSensor = (L0779_i_SensorData <= 36);
#endif
                                                break;
#endif
                                        default:
                                                goto T0276079;
                                }
                        } else {
                                if (L0770_ui_SensorTriggeredCell != M011_CELL(L0766_T_Thing))
                                        goto T0276079;
                                switch (M039_TYPE(L0769_ps_Sensor)) {
                                        case C001_SENSOR_WALL_ORNAMENT_CLICK:
                                                if (L0772_B_SquareContainsObject)
                                                        goto T0276079;
                                                break;
                                        case C002_SENSOR_WALL_ORNAMENT_CLICK_WITH_ANY_OBJECT:
                                                if (L0775_B_SquareContainsThingOfSameType || (M040_DATA(L0769_ps_Sensor) != F0032_OBJECT_GetType(P0590_T_Thing)))
                                                        goto T0276079;
                                                break;
                                        case C003_SENSOR_WALL_ORNAMENT_CLICK_WITH_SPECIFIC_OBJECT:
                                                if (L0776_B_SquareContainsThingOfDifferentType || (M040_DATA(L0769_ps_Sensor) == F0032_OBJECT_GetType(P0590_T_Thing)))
                                                        goto T0276079;
                                                break;
                                        default:
                                                goto T0276079;
                                }
                        }
                        L0768_B_TriggerSensor ^= L0769_ps_Sensor->Remote.RevertEffect;
                        if ((L0778_i_Effect = L0769_ps_Sensor->Remote.Effect) == C03_EFFECT_HOLD) {
                                L0778_i_Effect = L0768_B_TriggerSensor ? C00_EFFECT_SET : C01_EFFECT_CLEAR;
                        } else {
                                if (!L0768_B_TriggerSensor)
                                        goto T0276079;
                        }
                        if (L0769_ps_Sensor->Remote.Audible) {
                                F0064_SOUND_RequestPlay_CPSD(C01_SOUND_SWITCH, P0588_ui_MapX, P0589_ui_MapY, C01_MODE_PLAY_IF_PRIORITIZED);
                        }
                        F0272_SENSOR_TriggerEffect(L0769_ps_Sensor, L0778_i_Effect, P0588_ui_MapX, P0589_ui_MapY, CM1_CELL_ANY);
                        goto T0276079;
                }
                if (L0771_ui_ThingType >= C04_THING_TYPE_GROUP)
                        break;
                T0276079:
                L0766_T_Thing = F0159_DUNGEON_GetNextThing(L0766_T_Thing);
        }
        F0271_SENSOR_ProcessRotationEffect();
}
#endif
