This should work for you, as long as the creature tags and blueprint resrefs match up to what's in the script. If "bandit" and "corruptguard" are not the blueprint resref of the creatures, they won't spawn in.
// Checks for 1st creature (bandit) in same area as PC, if not present, spawn one in.
// Checks for 2nd creature (corrupt guard) in same area as PC, if not present, spawn one in.
void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) { return; } // Do nothing if not a PC entering trigger/area
object oArea = GetArea(oPC);
object oCreature1 = GetNearestObjectByTag("bandit", oPC);
if (GetIsObjectValid(oCreature1) == TRUE && GetArea(oCreature1) == oArea) { } // do nothing
else
{
object oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "bandit", GetLocation(GetNearestObjectByTag("SP_001")));
}
object oCreature2 = GetNearestObjectByTag("corruptguard", oPC);
if (GetIsObjectValid(oCreature2) == TRUE && GetArea(oCreature2) == oArea) { } // do nothing
else
{
object oSpawns = CreateObject(OBJECT_TYPE_CREATURE, "corruptguard", GetLocation(GetNearestObjectByTag("SP_002")));
}
}
Your previous code was checking the entire module for an object tagged "bandit", and if one was found
anywhere, it stopped the script from doing anything else.
It then did the same thing when checking for a "corruptguard".
Also, sometimes scripts work better if the object that is being spawned is defined in the script, rather than just running the CreateObject.
I also changed the search for a waypoint to a nearest object, to better have a chance for spawning in the right place if you happen to have the same waypoint tag elsewhere in the module.
Modifié par The Amethyst Dragon, 07 juin 2013 - 07:57 .