Here's what I'd do.
First, you'd need some way to identify if a player has the quest. If it's a normal quest, you'd use a qglobal. If it's a task, you can just check the task step on the player. Create an invisible NPC, make sure to mark it to check qglobals, and spawn it right in the middle of the trigger area. This NPC will handle the bulk of the work. The script would look similar to this:
Code:
sub EVENT_SPAWN
{
$x = $npc->GetX();
$y = $npc->GetY();
quest::set_proximity($x - 40, $x + 40, $y - 40, $y + 40);
}
sub EVENT_ENTER
{
if(defined $qglobals{hasquest} && $qglobals{hasquestl} == 1)
{
quest::spawn_condition($zonesn,1,1);
}
}
Next, Create the NPC-A and 3 guards. Create spawnpoints for each of the 3 guards (but NOT NPC-A), and add them to the same spawngroup. Set their _condition to 1. You'll also need to add an entry to spawn_conditions for the current zone and condition id (which in this case is just 1.) The NPC above will already spawn the guards when a player with the appropriate progress comes near. (You can change the qglobal check for a level check, item check, task step check, etc.) On each of the guards, add the following script:
Code:
sub EVENT_DEATH
{
my $random_result = int(rand(100));
if($random_result <= 1)
{
quest::unique_spawn(NPC-A_ID,0,0,$x,$y,$z)
}
}
That will give NPC-A a 1% chance to spawn on the death of one of the guards. You can fiddle with the number if you want, or you can add a $entity_list->GetMobByNpcTypeID($id); if you need all 3 guards to be down before you even roll for NPC-A. Since the spawn_condition has not been toggled off, those guards will continue to spawn over and over, based on their timer set in spawn2.
Last, for the NPC-A create the following script:
Code:
sub EVENT_DEATH
{
quest::spawn_condition($zonesn,1,0);
}
That will turn the spawn_condition off when he is killed. These are just quick examples, but will do the basic job.