Is there a way to tell a script to spawn something identical in every waypoint with a certain tag? So far it appears that what I have will spawn something only in one random waypoint and I actually want it to spawn that something in every waypoint in the area with the assigned tag.
My goal is to give my city a magical look, so there will be pillars all around, that at nightfall, orbs of light along with light effects will appear(and disappear at dawn).
That's exactly what my own 'nightlight' script does. It cycles through the area looking for ipoints with specific tags, then reads local variables off them to determine what special effect to spawn at the spot. It also looks for the nearest light object to the ipoint and turns it on or off (to avoid the bug that causes lights to lose their tags when a saved game is loaded).
void main()
{
object oArea = GetArea(OBJECT_SELF);
if (oArea != GetArea(GetFirstPC()))
return;
int iDay = GetLocalInt(OBJECT_SELF, "Day");
if (iDay == GetIsDay())
return;
object oLight;
object oEffect;
int i = 1;
string sEffect;
if (iDay == 1 && !GetIsDay())
{
oLight = GetNearestObject(OBJECT_TYPE_PLACEABLE, OBJECT_SELF);
while(GetIsObjectValid(oLight))
{
i++;
if (GetTag(oLight) == "nightlight")
{
sEffect = GetLocalString(oLight, "Effect");
oEffect = CreateObject(OBJECT_TYPE_PLACED_EFFECT, sEffect, GetLocation(oLight), 0, "LightEffect");
SetLocalObject(oLight, "EffectObject", oEffect);
SetLightActive(GetNearestObject(OBJECT_TYPE_LIGHT, oLight),1);
}//end if nightlight
oLight = GetNearestObject(OBJECT_TYPE_PLACEABLE, OBJECT_SELF, i);
}//end while
SetLocalInt(OBJECT_SELF, "Day", 0);
}//end if night
else
{
oLight = GetNearestObject(OBJECT_TYPE_PLACEABLE, OBJECT_SELF);
while(GetIsObjectValid(oLight))
{
i++;
if (GetTag(oLight) == "nightlight")
{
oEffect = GetLocalObject(oLight, "EffectObject");
SetLightActive(GetNearestObject(OBJECT_TYPE_LIGHT, oLight),0);
DestroyObject(oEffect);
DeleteLocalObject(oLight, "EffectObject");
}//end if nightlight
oLight = GetNearestObject(OBJECT_TYPE_PLACEABLE, OBJECT_SELF, i);
}//end while
SetLocalInt(OBJECT_SELF, "Day", 1);
//Rooster crows
if (GetTimeHour() < 8)
AssignCommand(GetFirstPC(), PlaySound("al_an_rooster1", TRUE));
}//end if day
}