There is no limit to the trigger, but the spell may fail
Please stop being evil's answer shows well that there is no actual distance limit to the triggering event. This answer argues that there is still a practical distance limit for most purposes.
I assume in this answer that the spell is being cast from the glyph's space for the purpose of targeting.
The text is fairly clear that the effect of explosive runes is centered on the glyph. A spell glyph is a little less straightforward, but there are still limitations.
Spell Glyph: You can store a prepared spell of 3rd level or lower in the glyph by casting it as part of creating the glyph. The spell must target a single creature or an area. The spell being stored has no immediate effect when cast in this way. When the glyph is triggered, the stored spell is cast. If the spell has a target, it targets the creature that triggered the glyph. If the spell affects an area, the area is centered on that creature. If the spell summons hostile creatures or creates harmful objects or traps, they appear as close as possible to the intruder and attack it. If the spell requires concentration, it lasts until the end of its full duration.
Lets use this in the context of your Drow alarm example. We know that the spell is cast immediately when the triggering condition is met, and since the spell doesn't say otherwise, one mile is a viable distance. However, the area of effect must be centered on the creature, and there is no point of origin that can accomplish this within the spell's range. Thus, even though the glyph is triggered, when the spell is cast, the necessary target is not in range. When there is no valid target, the spell usually fails and is wasted, see this answer for details.
Your plan is clever, and though I would allow it at my table, there is no RAW reason for the glyph to 'aim' as close as possible, so by the rules, the glyph would be spent, with no boom. Note that an explosive rune does not target anything, so an explosive rune using thunder magic could reasonably still provide an audible alarm, due to the sound based nature of thunder damage. By monitoring a summons glyph, you could identify the direction of the Drow by where the summons appear, since they are specifically stated to appear "as close as possible" to the triggering creature.
By contrast, in your Fireball example, the triggering creature is within the spell's range. The area 'chosen' by the glyph (centered on triggering creature) and the area possible from the Fireball spell (point of origin within 150 ft of the spell's casting) do not contradict each other, so the spell succeeds.
Any additional triggering conditions are completely up to the DM
The only limits to the spell are what is written in the spell itself, so let's look at what the spell says:
You decide what triggers the glyph when you cast the spell.
and then goes on to list some things that can be used to trigger can definitely detect giving "typical" examples of triggers. However, the text doesn't in any way imply that the list is exhaustive. The spell lists as examples of possible things that the trigger can detect:
- physical contact with the glyph
- if the glyph is covered/uncovered
- proximity of creatures
- status of the object on which it is inscribed
- if it can be seen or not and if it is being/has been read
Note that all of these triggers seem to hinge on a direct relation to the area around the physical glyph or manipulating the glyph itself (though it's not clear if that is an intentional restriction or just a coincidence in the examples they chose).
The listing of trigger refinements is less clear on whether it is exhaustive or just listing examples however:
- "circumstances" surrounding the trigger
- physical characteristics
- creature kind
- alignment
Specifically, the "circumstances" option seems to have pretty much unlimited power when interpreted broadly.
DM ruling is needed
In 5e, any kind of ambiguity or unclarity of a spell and any additional effects beyond what is written in a spell is up to the DM to clarify. Thus, any other triggers that aren't listed as examples (or very similar to them) would need to be ruled on specifically by your DM with little help from the rules (for better or worse).
If you are a DM in a position where you are trying to decide on the limits of the triggers I recommend reading several other Q&As here where specific aspects of it are discussed:
Your specific example of hostility
Basing a trigger refinement off of hostility towards the caster seems to me personally to be a bit of a tough sell in general. This would, at times, require the glyph to essentially read the mind or intentions of a creature which would be a very powerful ability to grant it, possibly even trodding on the toes of other spells and abilities in a bad way. If I were DMing this and you asked me about it, I would recommend the trigger be rephrased to say "take hostile action against the caster" because at least that is observable. That would seem to fit into the nebulous category of "circumstances" by my reading at least. Another DM might disagree with either of these interpretations, but I think this is a reasonable ruling.
Best Answer
The maximum damage you can deliver is 732 per day of preparation
The Glyphs
As indicated in Matthieu's answer, we are better off using Explosive Runes rather than Spell Glyphs as Spell Glyphs expend an extra spell slot.
To get as many Explosive Runes as possible, we will follow a procedure that alternates between days:
Day One
Day Two
Over the course of two days, we get the following Explosive Runes:
...totaling 183d8 for a maximum of 1464 damage over two days, yielding 732 per one day.
Note: If we have an odd number of days to prepare, we should just use all of our spell slots to cast Explosive Runes on the final day rather than casting simulacrum. This will give us more runes on that last day, since we won't have another day for where the simulacrum pays off.
Effective Damage
This initial damage calulcation assumes that the target fails their Dexterity saving throws, and that we roll the maximum damage for every d8. We can also calculate the effective damage based on the expected result of each d8 (4.5), and a couple of Dexterity saving throw benchmarks:
However, there are a few potential ways to improve this result with Spell Glyphs depending on the other ability scores of the target. I first tried other spells such as:
...but it was almost never worth sacrificing the rune count unless there were absurdly high Dexterity saves, and absurdly low alternate stats.
The successful method, however involved debuffs. There are two main debuffs that can help us get more damage: bestow curse and slow (polymorph would lower Dexterity considerably, but unfortunately the spell ends once the new form takes any amount of damage, rendering it wasteful).
Bestow Curse
If our target has lower Wisdom saves than Dexterity saves, bestow curse may be able to give us more effective damage by causing disadvantage on the Dexterity saves. We would be sacrificing a 4th and 3rd level Explosive Rune for this Spell Glyph, but in some cases, that is worth it for the extra effective damage on the rest of our runes.
Here are the damage adjustments for a couple Dexterity and Wisdom save values:
In summary, bestow curse is worth putting in a Spell Glyph on the second day if the targets Wisdom save is particularly low (under 5), and the Dexterity save isn't particular high, nor particularly low (in the 5-10 range).
For all pairs of days following the first, the damage bonus doesn't come at the cost of those 2 runes, and we get the following damage adjustments:
If we are spending enough days, it is always worth it, and you can find out if it's worth it by multiplying the bonus we get by the number of extra days, and comparing it to the loss from the first two days (I'll show some examples later).
Slow
Slow is only worth it if you are going to be preparing for an extended period of time. Here is the adjustment table for the first two days:
...and here are the damage adjustment tables for the proceeding pairs of days (notice the exact Dexterity save doesn't matter since it is a flat reduction):
Examples
One big elephant in the room, however, is that with damages of this calibur, most of our targets will have Magic Resistance. This makes bestow curse all the more valuable to cancel out that advantage the targets would normally get on the saving throws.
For these examples, I'll just be doubling the amount of runes needed to account for this advantage, because the extra spreadsheet math would take quite some time (and I've already done a lot to get this far).
The procedure has gotten a bit complicated at this point, so I am going to show three examples. I have chosen the Tarrasque (for something with a lot of HP but not all that great of saves), Zariel (for some realy good saves) and an ancient red dragon (for a middle ground).
Note: for the sake of comparison I am granting this ancient red dragon advantage on saving throws too.
The Tarrasque
The Tarrasque has the following relevant stats:
First let's see if bestow curse and slow are worth it:
Let's estimate our Tarrasque at +10 Wisdom so we can use are tables from above.
Since the tarrasque has 676 hit points, and our runes accumulate 380.87 damage per day, we are covered after just 4 days accounting for Magic Resistance. Therfore, we do want to incorporate bestow curse, but not slow.
We spend our four days making 51 Explosive Runes and 1 Spell Glyph alongside our simulacra and after one big non-fire explosion, the Tarrasque is defeated.
An Ancient Red Dragon affected by foresight
An ancient red dragon has the following relevant stats:
First let's see if bestow curse and slow are worth it:
Let's estimate our dragon at +5 Dexterity and +10 Wisdom so we can use are tables from above.
Since the dragon has 546 hit points, and our runes accumulate 329.40 damage per day, we are covered after just 4 days accounting for Magic Resistance. Therefore, we want to incorporate bestow curse and slow.
We spend our four days making 50 Explosive Runes and 2 Spell Glyph alongside our simulacra and after one big... also non-fire explosion, the dragon is slain.
Zariel, Ruler of Avernus
Zariel has the following relevant stats:
First let's see if bestow curse and slow are worth it:
Let's estimate Zariel at +5 Dexterity and +15 Wisdom so we can use are tables from above.
Since Zariel has 580 hit points, and our runes accumulate 329.40 damage per day, we are covered after just 4 days accounting for Magic Resistance. Therefore, we do not want to incorporate bestow curse nor slow.
We spend our four days making 52 Explosive Runes alongside our simulacra and after a we never get to use fire explosion, Zariel is gone.
In conclusion
By using simulacrum every other day, you can accumulate quite a bit of Explosive Runes in a very short amount of time. Typically you are better off just making tons of runes, but occasionally Spell Glyphs like bestow curse and slow may be worth it.
Just about everything you would be up against can be taken out with 4 days of preparation. That being said, it will cost you a pretty penny since simulacrum and glyph of warding both have expensive components. All in all it will cost about 6900 gp per day if you follow my steps.