#include "x0_i0_anims"
#include "ms_name_inc"

//#include "x0_i0_walkway" - in x0_i0_anims
//#include "x0_i0_treasure"

void EquipBest();
int GetIsInTown();

void main()
    {
    if (!GetIsInTown())
        SetAILevel(OBJECT_SELF,AI_LEVEL_HIGH);
    if (!GetIsInTown())
        {
        SetSpawnInCondition(NW_FLAG_FAST_BUFF_ENEMY);
        DelayCommand(6.0,EquipBest());
        }
    if (!GetIsInTown())
        SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);

    if (!GetIsInTown())
        SetSpawnInCondition(NW_FLAG_STEALTH);

    if (!GetIsInTown())
        SetAnimationCondition(NW_ANIM_FLAG_CONSTANT);

    if (GetIsInTown())
        SetAnimationCondition(NW_ANIM_FLAG_IS_MOBILE_CLOSE_RANGE);

    if (GetHasSkill(SKILL_HIDE)>=5 && !GetIsInTown())
        SetCombatCondition(X0_COMBAT_FLAG_AMBUSHER);

    if (GetLocalInt(OBJECT_SELF,"X2_L_IS_INCORPOREAL"))
        SetSpawnInCondition(NW_FLAG_END_COMBAT_ROUND_EVENT);

	ms_Nomenclature(OBJECT_SELF);

    // ***** ADD ANY SPECIAL ON-SPAWN CODE HERE ***** //
    string sTag = GetTag(OBJECT_SELF);
    int iRace = GetRacialType(OBJECT_SELF);
    int iAppearance = GetAppearanceType(OBJECT_SELF);
    if (iRace == RACIAL_TYPE_ELEMENTAL)
        {
        if (iAppearance == APPEARANCE_TYPE_ELEMENTAL_FIRE
         || iAppearance == APPEARANCE_TYPE_ELEMENTAL_FIRE_ELDER
         || iAppearance == APPEARANCE_TYPE_BALOR
         || iAppearance == APPEARANCE_TYPE_DEVIL)
            ApplyEffectToObject(DURATION_TYPE_PERMANENT,SupernaturalEffect(EffectVisualEffect(VFX_DUR_LIGHT_RED_20)),OBJECT_SELF);
        }
    if (GetLocalInt(OBJECT_SELF,"X2_L_IS_INCORPOREAL"))
        {
        ApplyEffectToObject(DURATION_TYPE_PERMANENT,SupernaturalEffect(EffectConcealment(50,MISS_CHANCE_TYPE_NORMAL)),OBJECT_SELF);
        }
    }

void EquipBest()
    {
    ClearAllActions();
    ActionEquipMostEffectiveArmor();
    ActionEquipMostDamagingRanged();
    ActionRandomWalk();
    }

int GetIsInTown()
    {
    return GetLocalInt(GetArea(OBJECT_SELF),"Town");
    }
