#ifndef COMPILE_H
#include "COMPILE.H"
#endif
#ifdef MEDIA676_F31E_F31J_X31J_P31J_AU1E_AU2E_AU3E
unsigned char G2270_ObjectInfoIndexToIconIndex[180] = {
        30,
        144,
        148,
        149,
        150,
        151,
        152,
        153,
        154,
        155,
        156,
        157,
        158,
        159,
        160,
        161,
        162,
        163,
        164,
        165,
        166,
        167,
        195,
        16,
        18,
        4,
        14,
        20,
        23,
        25,
        27,
        32,
        33,
        34,
        35,
        36,
        37,
        38,
        39,
        40,
        41,
        42,
        43,
        44,
        45,
        46,
        47,
        48,
        49,
        50,
        51,
        52,
        53,
        54,
        55,
        56,
        57,
        58,
        59,
        60,
        61,
        62,
        63,
        64,
        65,
        66,
        135,
        143,
        28,
        80,
        81,
        82,
        112,
        114,
        67,
        83,
        68,
        84,
        69,
        70,
        85,
        86,
        71,
        87,
        119,
        72,
        88,
        113,
        89,
        73,
        74,
        90,
        103,
        104,
        96,
        97,
        98,
        105,
        106,
        108,
        107,
        75,
        91,
        76,
        92,
        99,
        115,
        100,
        77,
        93,
        116,
        109,
        101,
        78,
        94,
        117,
        110,
        102,
        79,
        95,
        118,
        111,
        140,
        141,
        142,
        194,
        196,
        0,
        8,
        10,
        12,
        146,
        147,
        125,
        126,
        127,
        176,
        177,
        178,
        179,
        180,
        181,
        182,
        183,
        184,
        185,
        186,
        187,
        188,
        189,
        190,
        191,
        128,
        129,
        130,
        131,
        168,
        169,
        170,
        171,
        172,
        173,
        174,
        175,
        120,
        121,
        122,
        123,
        124,
        132,
        133,
        134,
        136,
        137,
        138,
        139,
        192,
        193,
        197,
        198
};

int16_t F7017_GetIconIndex(REGISTER GAME* P3658_ps_, THING P3659_T_)
{
        REGISTER int16_t L3853_i_;


        if (P3659_T_ == C0xFFFF_THING_NONE) {
                return C0xFFFF_ICON_NONE;
        }
        L3853_i_ = F7019_GetObjectInfoIndex(P3658_ps_, P3659_T_);
        if (L3853_i_ != -1) {
                L3853_i_ = G2270_ObjectInfoIndexToIconIndex[L3853_i_];
        }
        return L3853_i_;
}

unsigned char* F7018_GetThingData(REGISTER GAME* P3660_ps_, REGISTER THING P3661_i_)
{
        REGISTER GAME* L3854_ps_;


        L3854_ps_ = P3660_ps_;
        return L3854_ps_->Dungeon.ThingData[M012_TYPE(P3661_i_)] + (M013_INDEX(P3661_i_) * G0235_auc_Graphic559_ThingDataByteCount[M012_TYPE(P3661_i_)]);
}

THING F7019_GetObjectInfoIndex(REGISTER GAME* P3662_ps_, THING P3663_T_)
{
        REGISTER GENERIC* L0240_ps_Generic;
        int16_t L3855_i_;
        int16_t L3856_i_;


        L0240_ps_Generic = (GENERIC*)F7018_GetThingData(P3662_ps_, P3663_T_);
        switch (M012_TYPE(P3663_T_)) {
                case C07_THING_TYPE_SCROLL:
                        L3855_i_ = C000_OBJECT_INFO_INDEX_FIRST_SCROLL;
                        L3856_i_ = 0;
                        break;
                case C09_THING_TYPE_CONTAINER:
                        L3855_i_ = C001_OBJECT_INFO_INDEX_FIRST_CONTAINER;
                        L3856_i_ = ((CONTAINER*)L0240_ps_Generic)->Type;
                        break;
                case C10_THING_TYPE_JUNK:
                        L3855_i_ = C127_OBJECT_INFO_INDEX_FIRST_JUNK;
                        L3856_i_ = ((JUNK*)L0240_ps_Generic)->Type;
                        break;
                case C05_THING_TYPE_WEAPON:
                        L3855_i_ = C023_OBJECT_INFO_INDEX_FIRST_WEAPON;
                        L3856_i_ = ((WEAPON*)L0240_ps_Generic)->Type;
                        break;
                case C06_THING_TYPE_ARMOUR:
                        L3855_i_ = C069_OBJECT_INFO_INDEX_FIRST_ARMOUR;
                        L3856_i_ = ((ARMOUR*)L0240_ps_Generic)->Type;
                        break;
                case C08_THING_TYPE_POTION:
                        L3855_i_ = C002_OBJECT_INFO_INDEX_FIRST_POTION;
                        L3856_i_ = ((POTION*)L0240_ps_Generic)->Type;
                        break;
                default:
                        L3855_i_ = -1;
                        L3856_i_ = 0;
        }
        return L3855_i_ + L3856_i_;
}

#ifdef MEDIA697_X31J_AU1E_AU2E_AU3E
void F7020_RemoveObjectModifiersFromStatistics(register GAME* P3664_ps_, register unsigned int16_t P3665_ui_ChampionIndex, register unsigned int16_t P0624_ui_SlotIndex, THING P3666_T_Thing)
#endif
#ifdef MEDIA671_F31E_F31J_P31J
void F7020_RemoveObjectModifiersFromStatistics(REGISTER GAME* P3664_ps_, unsigned int16_t P3665_ui_ChampionIndex, unsigned int16_t P0624_ui_SlotIndex, THING P3666_T_Thing)
#endif
{
#define AP0624_ui_StatisticValueIndex P0624_ui_SlotIndex
        REGISTER WEAPON* L0893_ps_Weapon;
#ifdef MEDIA697_X31J_AU1E_AU2E_AU3E
        register int16_t L0892_i_Modifier;
#endif
#ifdef MEDIA671_F31E_F31J_P31J
        int16_t L0892_i_Modifier;
#endif
        REGISTER int16_t L0891_i_Multiple;
#define AL0891_i_StatisticIndex L0891_i_Multiple
#define AL0891_i_ThingType      L0891_i_Multiple
        REGISTER unsigned int16_t P0625_ui_IconIndex;
        unsigned int16_t L3857_ui_;
        unsigned char (*L3858_paauc_)[7][3];


        L0892_i_Modifier = 0;
        if (P3666_T_Thing != C0xFFFF_THING_NONE) {
                P0625_ui_IconIndex = F7017_GetIconIndex(P3664_ps_, P3666_T_Thing);
                if ((((AL0891_i_ThingType = M012_TYPE(P3666_T_Thing)) == C05_THING_TYPE_WEAPON) || (AL0891_i_ThingType == C06_THING_TYPE_ARMOUR)) && (P0624_ui_SlotIndex >= C00_SLOT_READY_HAND) && (P0624_ui_SlotIndex <= C12_SLOT_QUIVER_LINE1_1)) {
                        L0893_ps_Weapon = (WEAPON*)F7018_GetThingData(P3664_ps_, P3666_T_Thing);
                        if (((AL0891_i_ThingType == C05_THING_TYPE_WEAPON) && L0893_ps_Weapon->Cursed) || ((AL0891_i_ThingType == C06_THING_TYPE_ARMOUR) && ((ARMOUR*)L0893_ps_Weapon)->Cursed)) {
                                AL0891_i_StatisticIndex = C0_STATISTIC_LUCK;
                                L0892_i_Modifier = -3;
                                goto T299_044_ApplyModifier;
                        }
                }
                if ((P0625_ui_IconIndex == C137_ICON_JUNK_RABBITS_FOOT) && (P0624_ui_SlotIndex < C30_SLOT_CHEST_1)) {
                        AL0891_i_StatisticIndex = C0_STATISTIC_LUCK;
                        L0892_i_Modifier = 10;
                } else {
                        if (P0624_ui_SlotIndex == C01_SLOT_ACTION_HAND) {
                                if (P0625_ui_IconIndex == C045_ICON_WEAPON_MACE_OF_ORDER) {
                                        AL0891_i_StatisticIndex = C1_STATISTIC_STRENGTH;
                                        L0892_i_Modifier = 5;
                                } else {
                                        AL0891_i_StatisticIndex = C8_STATISTIC_MANA;
                                        if ((P0625_ui_IconIndex >= C020_ICON_WEAPON_STAFF_OF_CLAWS_EMPTY) && (P0625_ui_IconIndex <= C022_ICON_WEAPON_STAFF_OF_CLAWS_FULL)) {
                                                L0892_i_Modifier = 4;
                                        } else {
                                                if ((P0625_ui_IconIndex >= C058_ICON_WEAPON_STAFF) && (P0625_ui_IconIndex <= C066_ICON_WEAPON_SCEPTRE_OF_LYF)) {
                                                        switch (P0625_ui_IconIndex) {
                                                                case C058_ICON_WEAPON_STAFF:
                                                                        L0892_i_Modifier = 2;
                                                                        break;
                                                                case C059_ICON_WEAPON_WAND:
                                                                        L0892_i_Modifier = 1;
                                                                        break;
                                                                case C060_ICON_WEAPON_TEOWAND:
                                                                        L0892_i_Modifier = 6;
                                                                        break;
                                                                case C061_ICON_WEAPON_YEW_STAFF:
                                                                        L0892_i_Modifier = 4;
                                                                        break;
                                                                case C062_ICON_WEAPON_STAFF_OF_MANAR_STAFF_OF_IRRA:
                                                                        L0892_i_Modifier = 10;
                                                                        break;
                                                                case C063_ICON_WEAPON_SNAKE_STAFF_CROSS_OF_NETA:
                                                                        L0892_i_Modifier = 8;
                                                                        break;
                                                                case C064_ICON_WEAPON_THE_CONDUIT_SERPENT_STAFF:
                                                                        L0892_i_Modifier = 16;
                                                                        break;
                                                                case C065_ICON_WEAPON_DRAGON_SPIT:
                                                                        L0892_i_Modifier = 7;
                                                                        break;
                                                                case C066_ICON_WEAPON_SCEPTRE_OF_LYF:
                                                                        L0892_i_Modifier = 5;
                                                        }
                                                } else {
                                                        switch (P0625_ui_IconIndex) {
                                                                case C038_ICON_WEAPON_DELTA_SIDE_SPLITTER:
                                                                        L0892_i_Modifier = 1;
                                                                        break;
                                                                case C041_ICON_WEAPON_THE_INQUISITOR_DRAGON_FANG:
                                                                        L0892_i_Modifier = 2;
                                                                        break;
                                                                case C040_ICON_WEAPON_VORPAL_BLADE:
                                                                        L0892_i_Modifier = 4;
                                                        }
                                                }
                                        }
                                }
                        } else {
                                if (P0624_ui_SlotIndex == C04_SLOT_LEGS) {
                                        if (P0625_ui_IconIndex == C142_ICON_ARMOUR_POWERTOWERS) {
                                                AL0891_i_StatisticIndex = C1_STATISTIC_STRENGTH;
                                                L0892_i_Modifier = 10;
                                        }
                                } else {
                                        if (P0624_ui_SlotIndex == C02_SLOT_HEAD) {
                                                if (P0625_ui_IconIndex == C104_ICON_ARMOUR_CROWN_OF_NERRA) {
                                                        AL0891_i_StatisticIndex = C3_STATISTIC_WISDOM;
                                                        L0892_i_Modifier = 10;
                                                } else {
                                                        if (P0625_ui_IconIndex == C140_ICON_ARMOUR_DEXHELM) {
                                                                AL0891_i_StatisticIndex = C2_STATISTIC_DEXTERITY;
                                                                L0892_i_Modifier = 10;
                                                        }
                                                }
                                        } else {
                                                if (P0624_ui_SlotIndex == C03_SLOT_TORSO) {
                                                        if (P0625_ui_IconIndex == C141_ICON_ARMOUR_FLAMEBAIN) {
                                                                AL0891_i_StatisticIndex = C6_STATISTIC_ANTIFIRE;
                                                                L0892_i_Modifier = 12;
                                                        } else {
                                                                if (P0625_ui_IconIndex == C081_ICON_ARMOUR_CLOAK_OF_NIGHT) {
                                                                        AL0891_i_StatisticIndex = C2_STATISTIC_DEXTERITY;
                                                                        L0892_i_Modifier = 8;
                                                                }
                                                        }
                                                } else {
                                                        if (P0624_ui_SlotIndex == C10_SLOT_NECK) {
                                                                if ((P0625_ui_IconIndex >= C010_ICON_JUNK_JEWEL_SYMAL_UNEQUIPPED) && (P0625_ui_IconIndex <= C011_ICON_JUNK_JEWEL_SYMAL_EQUIPPED)) {
                                                                        AL0891_i_StatisticIndex = C5_STATISTIC_ANTIMAGIC;
                                                                        L0892_i_Modifier = 15;
                                                                } else {
                                                                        if (P0625_ui_IconIndex == C081_ICON_ARMOUR_CLOAK_OF_NIGHT) {
                                                                                AL0891_i_StatisticIndex = C2_STATISTIC_DEXTERITY;
                                                                                L0892_i_Modifier = 8;
                                                                        } else {
                                                                                if (P0625_ui_IconIndex == C122_ICON_JUNK_MOONSTONE) {
                                                                                        AL0891_i_StatisticIndex = C8_STATISTIC_MANA;
                                                                                        L0892_i_Modifier = 3;
                                                                                }
                                                                        }
                                                                }
                                                        }
                                                }
                                        }
                                }
                        }
                }
                T299_044_ApplyModifier:
                if (L0892_i_Modifier) {
                        L0892_i_Modifier = -L0892_i_Modifier;
                        if (AL0891_i_StatisticIndex == C8_STATISTIC_MANA) {
                                L3857_ui_ = F7067_GetChampionInfo(P3664_ps_, P3665_ui_ChampionIndex, C22_CHAMPION_INFO_MAXIMUMMANA);
                                L3857_ui_ += L0892_i_Modifier;
                                F7068_SetChampionInfo(P3664_ps_, P3665_ui_ChampionIndex, C22_CHAMPION_INFO_MAXIMUMMANA, (long)L3857_ui_);
                                L3857_ui_ = F7067_GetChampionInfo(P3664_ps_, P3665_ui_ChampionIndex, C21_CHAMPION_INFO_CURRENTMANA);
                                L3857_ui_ += L0892_i_Modifier;
                                F7068_SetChampionInfo(P3664_ps_, P3665_ui_ChampionIndex, C21_CHAMPION_INFO_CURRENTMANA, (long)L3857_ui_);
                        } else {
                                if (AL0891_i_StatisticIndex < C6_STATISTIC_ANTIFIRE + 1) {
                                        L3858_paauc_ = (unsigned char (*)[7][3])F7067_GetChampionInfo(P3664_ps_, P3665_ui_ChampionIndex, C26_CHAMPION_INFO_STATISTICS);
                                        for (AP0624_ui_StatisticValueIndex = C0_MAXIMUM; AP0624_ui_StatisticValueIndex <= C2_MINIMUM; (*L3858_paauc_)[AL0891_i_StatisticIndex][AP0624_ui_StatisticValueIndex++] += L0892_i_Modifier);
                                }
                        }
                }
        }
}
#endif
