89 lines
3.0 KiB
Plaintext
89 lines
3.0 KiB
Plaintext
//Teleports relatively the objects (creature, placeable, item) within
|
|
//the trigger oPad. On arrival teleport daze is used.
|
|
//All creatures are teleported
|
|
//All items are teleported by destroying the original and
|
|
//creating a copy. Beware!
|
|
//Placeables that have the variable "tele" set to 1 are
|
|
//teleported by destroying the original and creating a
|
|
//new placeable with the Resref of the original
|
|
//
|
|
//Relative teleportation keeps the objects in the same position
|
|
//and facing direction relative to eachother on arrival.
|
|
void Teleport(object oDest, object oPad, object oPost);
|
|
|
|
//finds the relative location using the Post and Dest objects as
|
|
//the relative origin
|
|
location NewLocation(object oCreature, object oPost, object oDest);
|
|
|
|
|
|
void Teleport(object oDest, object oPad, object oPost)
|
|
{
|
|
effect eGlow= EffectVisualEffect(VFX_DUR_GLOW_BLUE);
|
|
effect eArrive= EffectVisualEffect(VFX_IMP_MAGIC_PROTECTION);
|
|
effect eDaze= EffectDazed();
|
|
location lLoc;
|
|
|
|
//first, creatures
|
|
object oCreature= GetFirstInPersistentObject(oPad, OBJECT_TYPE_CREATURE);
|
|
while(GetIsObjectValid(oCreature))
|
|
{
|
|
lLoc= NewLocation(oCreature, oPost, oDest);
|
|
AssignCommand(oCreature, ClearAllActions());
|
|
AssignCommand(oCreature, JumpToLocation(lLoc));
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eGlow, oCreature, 1.0);
|
|
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eArrive, oCreature));
|
|
DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDaze, oCreature, 1.0));
|
|
|
|
oCreature= GetNextInPersistentObject(oPad, OBJECT_TYPE_CREATURE);
|
|
}
|
|
//next, items
|
|
object oItem= GetFirstInPersistentObject(oPad, OBJECT_TYPE_ITEM);
|
|
object oNew;
|
|
while(GetIsObjectValid(oItem))
|
|
{
|
|
lLoc= NewLocation(oItem, oPost, oDest);
|
|
CopyObject(oItem, lLoc);
|
|
SetPlotFlag(oItem, FALSE);
|
|
DestroyObject(oItem);
|
|
DelayCommand(0.2, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eArrive, lLoc));
|
|
oItem= GetNextInPersistentObject(oPad, OBJECT_TYPE_ITEM);
|
|
}
|
|
//finally, placeables
|
|
object oPlc= GetFirstInPersistentObject(oPad, OBJECT_TYPE_PLACEABLE);
|
|
while(GetIsObjectValid(oPlc))
|
|
{
|
|
if(GetLocalInt(oPlc, "tele")==1)
|
|
{
|
|
lLoc= NewLocation(oPlc, oPost, oDest);
|
|
string sNew= GetResRef(oPlc);
|
|
oNew= CreateObject(OBJECT_TYPE_PLACEABLE, sNew, lLoc);
|
|
SetPlotFlag(oPlc, FALSE);
|
|
DestroyObject(oPlc);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eGlow, oNew, 1.0);
|
|
DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_INSTANT, eArrive, oNew));
|
|
}
|
|
oPlc= GetNextInPersistentObject(oPad, OBJECT_TYPE_PLACEABLE);
|
|
}
|
|
|
|
|
|
}
|
|
location NewLocation(object oCreature, object oPost, object oDest)
|
|
{
|
|
vector vPost= GetPosition(oPost);
|
|
object oArea= GetArea(oDest);
|
|
float fFacing= GetFacing(oCreature);
|
|
vector vCre= GetPosition(oCreature);
|
|
vector vDest= GetPosition(oDest);
|
|
vector vComp;
|
|
vComp.x= vCre.x-vPost.x;
|
|
vComp.y= vCre.y-vPost.y;
|
|
vComp.z= vCre.z-vPost.z;
|
|
|
|
vector vNew;
|
|
vNew.x= vComp.x+vDest.x;
|
|
vNew.y= vComp.y+vDest.y;
|
|
vNew.z= vComp.z+vDest.z;
|
|
location lLoc= Location(oArea, vNew, fFacing);
|
|
return lLoc;
|
|
}
|