Yes, it should definitely be possible. Do you want to detect when the player sees any enemy building for the first time, or just a particular one? If it's every unit, it would be possible but I don't know how quickly triggers would preform. Either way no regions should be needed.
Here's the idea of what you'd want. This should work in multiplayer with every unit, but I don't know if would run slow or not... It's hard to tell ;)
For each unit u in unit group (Units owned by player P)
{
x = Vision radius for unit U //I don't know if there's a function to get this. If not, you should be able to get it via a catalog field value lookup
for each unit e in unit group (Units with filter (structure=required) in region (circle with radius x centered around unit U) owned by enemy players of P)
{
wait 0.0 game seconds // To avoid an execution time error
if distance between position of unit e and position of unit U < x
{
// Unit U can see unit E. But is it the first time?
if custom value #P of unit (E) == 0.0
{
// First-time sighting of this unit
Set custom value #P of unit (E) to 1.0
// Do whatever else you want to do now that it's been seen for the first time. This is the spot you would put the message or whatever it is you want to happen when you see a unit
}
}
}
}
Basically, it does this: Loop through every unit that you own, and then loop through every enemy unit that's within it's vision radius. If it's never seen an enemy before, mark it as "already seen" by setting it's custom value to 1 instead of 0.
I want to detect when a player sees an enemy building for the first time. Is this possible with triggers without doing something crazy with regions?
Yes, it should definitely be possible. Do you want to detect when the player sees any enemy building for the first time, or just a particular one? If it's every unit, it would be possible but I don't know how quickly triggers would preform. Either way no regions should be needed.
Here's the idea of what you'd want. This should work in multiplayer with every unit, but I don't know if would run slow or not... It's hard to tell ;)
Basically, it does this: Loop through every unit that you own, and then loop through every enemy unit that's within it's vision radius. If it's never seen an enemy before, mark it as "already seen" by setting it's custom value to 1 instead of 0.