Code now.
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
if (GetIsNight() ) // there will be a dusk and a dawn as well
{
if (GetLocalInt(GetArea(oPC), "DAY_SET__") == -1) return; // do only once per day/night
SetLocalInt(GetArea(oPC), "DAY_SET__", -1); //-1 to bypass the initial value of 0
// spawn dryads here
location lLoc1 = GetLocation(GetWaypointByTag("WP_DRYAD_01"));
location lLoc2 = GetLocation(GetWaypointByTag("WP_DRYAD_02"));
location lLoc3 = GetLocation(GetWaypointByTag("WP_DRYAD_03"));
location lLoc4 = GetLocation(GetWaypointByTag("WP_DRYAD_04"));
CreateObject(OBJECT_TYPE_CREATURE, "dryad001", lLoc1);
CreateObject(OBJECT_TYPE_CREATURE, "dryad002", lLoc2);
CreateObject(OBJECT_TYPE_CREATURE, "dryad001", lLoc3);
CreateObject(OBJECT_TYPE_CREATURE, "dryad002", lLoc4);
}
else // and nothing else here
{
if (GetLocalInt(GetArea(oPC), "DAY_SET__") == 1) return; // do only once per day/night
SetLocalInt(GetArea(oPC), "DAY_SET__", 1); // set to area, since there might be more than one area with DN
// destroy dryads here
DestroyObject(GetObjectByTag("NW_DRYAD_001"), 0.5);
DestroyObject(GetObjectByTag("NW_DRYAD_002"), 0.5);
}
}
Always the same problem. The dryads won’t disappear. The code I was currently writing had the same problem, although that code was for OnHeartbeat:
void main()
{
object oPC = GetFirstPC();
if (!GetIsPC(oPC)) return;
if ( GetIsNight() )
{
location lLoc1 = GetLocation(GetWaypointByTag("WP_DRYAD_01"));
location lLoc2 = GetLocation(GetWaypointByTag("WP_DRYAD_02"));
location lLoc3 = GetLocation(GetWaypointByTag("WP_DRYAD_03"));
location lLoc4 = GetLocation(GetWaypointByTag("WP_DRYAD_04"));
CreateObject(OBJECT_TYPE_CREATURE, "dryad001", lLoc1);
CreateObject(OBJECT_TYPE_CREATURE, "dryad002", lLoc2);
CreateObject(OBJECT_TYPE_CREATURE, "dryad001", lLoc3);
CreateObject(OBJECT_TYPE_CREATURE, "dryad002", lLoc4);
if ( GetLocalInt(oPC, "DO_ONCE__" + GetTag(OBJECT_SELF)) )
return;
SetLocalInt(oPC, "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE);
}
else if ( GetIsDay() )
{
object oDryad1 = GetObjectByTag("NW_DRYAD_001");
SetCommandable(TRUE, oDryad1);
AssignCommand(oDryad1, ClearAllActions());
DestroyObject(oDryad1, 0.5);
object oDryad2 = GetObjectByTag("NW_DRYAD_002");
SetCommandable(TRUE, oDryad2);
AssignCommand(oDryad2, ClearAllActions());
DestroyObject(oDryad2, 0.5);
object oDryad3 = GetObjectByTag("NW_DRYAD_003");
SetCommandable(TRUE, oDryad3);
AssignCommand(oDryad3, ClearAllActions());
DestroyObject(oDryad3, 0.5);
object oDryad4 = GetObjectByTag("NW_DRYAD_004");
SetCommandable(TRUE, oDryad4);
AssignCommand(oDryad4, ClearAllActions());
DestroyObject(oDryad4, 0.5);
}
}
At this point I was even toying with SetCommandable, but I think that has no effect on DestroyObject().
Anyway, thanks Mmat…
Edit: Since the dryads spawn with dance animations playing, would it be necessary to ClearAllActions() first, then call DestroyObject()?