/*
    PROJECT Q IV
    (c) 2022 by Pstemarie

    Roper OnUserDefined Event Script

       Sets the appearance of the roper to a suitable skin for the tileset

    Version: 1.0
    Created: 29 May 2022
    Author:  Pstemarie

*/

const int EVENT_USER_DEFINED_PRESPAWN  = 1510;
const int EVENT_USER_DEFINED_POSTSPAWN = 1511;

void main()
{
    if (GetUserDefinedEventNumber() == EVENT_USER_DEFINED_POSTSPAWN)
    {
        object oArea = GetArea(OBJECT_SELF);
        if (GetTilesetResRef(oArea) == TILESET_RESREF_MINES_AND_CAVERNS ||
            GetTilesetResRef(oArea) == TILESET_RESREF_SEA_CAVES)
        {
            if (GetAppearanceType(OBJECT_SELF) != 15110)
            {
                SetCreatureAppearanceType(OBJECT_SELF, 15110);
            }
        }
        else if (GetTilesetResRef(oArea) == TILESET_RESREF_UNDERDARK)
        {
            if (GetAppearanceType(OBJECT_SELF) != 15111 ||
                GetAppearanceType(OBJECT_SELF) != 15112 ||
                GetAppearanceType(OBJECT_SELF) != 15113)
            {
                int nAppear = d3() + 15110;
                SetCreatureAppearanceType(OBJECT_SELF, nAppear);
            }
        }
    }
}
