void main()
{
    // Check if the trigger has already fired
    if (GetLocalInt(OBJECT_SELF, "iFiredAlready") == 1)
    {
        return; // Exit if the script has already run once
    }
    
    // Mark the trigger as fired to prevent re-execution
    SetLocalInt(OBJECT_SELF, "iFiredAlready", 1);

    // Retrieve the waypoint tag from a local string variable
    string sWaypointTag = GetLocalString(OBJECT_SELF, "TAGOFWAYPOINT");
    
    // Find the first waypoint with the specified tag
    object oWaypoint = GetWaypointByTag(sWaypointTag);
    
    // Loop through all waypoints with the specified tag and spawn the placeable at each one
    while (GetIsObjectValid(oWaypoint))
    {
        // Get the location of the waypoint
        location lWaypointLoc = GetLocation(oWaypoint);
        
        // Spawn the "cas_flamecyric" placeable at the waypoint's location
        object oFlame = CreateObject(OBJECT_TYPE_PLACEABLE, "cas_flamecyric", lWaypointLoc);
        
        // Optional: Make the flame perform an emote immediately
        AssignCommand(oFlame, SpeakString("bursts into life in a blaze of evil glory", TALKVOLUME_TALK));
        
        // Find the next waypoint with the same tag
        oWaypoint = GetWaypointByTag(sWaypointTag);
    }
}
