void ApplyEffectAtWaypoint(string sWaypointTag, int nVFX)
{
    object oWaypoint = GetObjectByTag(sWaypointTag);
    if(GetIsObjectValid(oWaypoint))
    {
        location lWaypoint = GetLocation(oWaypoint);
        ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(nVFX), lWaypoint);
    }
}

void SpawnBoss()
{
    CreateObject(OBJECT_TYPE_CREATURE, "cas_chris_boss", GetLocation(GetWaypointByTag("WP_CAS_BOSSPOINT")));
}


const int REQUIRED_SYMBOLS = 7;


void main()
{
    object oPlaceable = OBJECT_SELF;
    int nSymbolCount = 0;
   

    // Check each item in the placeable's inventory
    object oItem = GetFirstItemInInventory(oPlaceable);
    while(GetIsObjectValid(oItem))
    {
        if(GetLocalInt(oItem, "SYMBOLOFTHEM") == 1)
        {
            nSymbolCount++;
        }
        oItem = GetNextItemInInventory(oPlaceable);
    }

    if(nSymbolCount != REQUIRED_SYMBOLS)
    {
        // Not enough symbols, inform the player
        int nSymbolsNeeded = REQUIRED_SYMBOLS - nSymbolCount;
        SpeakString("The offerings are insufficient... bring forth " + IntToString(nSymbolsNeeded) + " more symbols of the enemy of the One.");
    }
    else
    {
        // Remove all items
        oItem = GetFirstItemInInventory(oPlaceable);
        while(GetIsObjectValid(oItem))
        {
            DestroyObject(oItem);
            oItem = GetNextItemInInventory(oPlaceable);
        }

        // Apply VFX to waypoints
        ApplyEffectAtWaypoint("WP_CAS_INVASIONPOINT1", 1089);
        DelayCommand(1.0, ApplyEffectAtWaypoint("WP_CAS_INVASIONPOINT2", 1089));
        DelayCommand(2.0, ApplyEffectAtWaypoint("WP_CAS_INVASIONPOINT3", 1089));
        DelayCommand(3.0, ApplyEffectAtWaypoint("WP_CAS_INVASIONPOINT4", 1089));
        DelayCommand(7.0, ApplyEffectAtWaypoint("WP_CAS_BOSSPOINT", 1148));

        // Apply VFX to altar after a delay
        DelayCommand(6.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(1148), oPlaceable));

        // Spawn the creature
        DelayCommand(8.0, SpawnBoss()));
    }
}
