//Created by Genisys / Guile 5/23/08
//This script is fired from the script in the OnEnter Event of the tracks
//trigger in the party jail (script name "overspawnmsg") it basically
//creates a portals for the PC's to escape (the portal is self destructive)
void main()
{

object oTarget;
object oSpawn;
location lTarget;
oTarget = GetWaypointByTag("jailportway");
lTarget = GetLocation(oTarget);

if(GetObjectByTag("jailportal") == OBJECT_INVALID)
{
oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "jailportal", lTarget);

oTarget = oSpawn;


int nInt;
nInt = GetObjectType(oTarget);

if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HARM), oTarget));
else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_HARM), GetLocation(oTarget)));

}
//Otherwise kill the exit!!!
else
{
SetPlotFlag(GetObjectByTag("jailportal"), FALSE);
DestroyObject(GetObjectByTag("jailportal"), 0.0f);
}

}