I wan't a script that would allow me to travel
in outdoor areas and keep the players proper coordinates when loading a new
area. For Example: Puting one long area transition on the edge of a map,
entering it at the bottom of one map, and then arriving at the bottom of the
next map with the same X or Y coordinate depending on which way your
traveling. So I made this. I am new to scripting, I don't know much but I do
know a little bit. I'm sure there are probably a million easier and better
ways to do this but with my limited knowledge I couldn't find them. The
instructions are at the top of the script
NWScript: :
void TraveltoLocation(object oArea,int iMapSizeX,int iMapSizeY,int iDirection);
void main()
{
object oArea = GetArea(GetObjectByTag("TagOfArea",0));
TraveltoLocation(oArea,8,8,8);
}
void TraveltoLocation(object oArea,int iMapSizeX,int iMapSizeY,int iDirection)
{
object oPC = GetEnteringObject();
if(GetIsPC(oPC) || GetIsDM(oPC))
{
vector vCurrentPosition = GetPosition(oPC);
float fXpos = vCurrentPosition.x;
float fYpos = vCurrentPosition.y;
float fZpos = vCurrentPosition.z;
float fNewXpos;
float fNewYpos;
switch(iDirection)
{
case 8:
{
fNewYpos = 5.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,90.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 6:
{
fNewXpos = 5.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,0.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 2:
{
switch(iMapSizeY)
{
case 1:
{
fNewYpos = 4.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 2:
{
fNewYpos = 14.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 3:
{
fNewYpos = 24.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 4:
{
fNewYpos = 34.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 5:
{
fNewYpos = 44.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 6:
{
fNewYpos = 54.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 7:
{
fNewYpos = 64.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 8:
{
fNewYpos = 74.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 9:
{
fNewYpos = 84.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 10:
{
fNewYpos = 94.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 11:
{
fNewYpos = 104.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 12:
{
fNewYpos = 114.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 13:
{
fNewYpos = 124.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 14:
{
fNewYpos = 134.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 15:
{
fNewYpos = 144.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 16:
{
fNewYpos = 154.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 17:
{
fNewYpos = 164.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 18:
{
fNewYpos = 174.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 19:
{
fNewYpos = 184.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 20:
{
fNewYpos = 194.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 21:
{
fNewYpos = 204.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 22:
{
fNewYpos = 214.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 23:
{
fNewYpos = 224.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 24:
{
fNewYpos = 234.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 25:
{
fNewYpos = 244.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 26:
{
fNewYpos = 254.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 27:
{
fNewYpos = 264.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 28:
{
fNewYpos = 274.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 29:
{
fNewYpos = 284.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 30:
{
fNewYpos = 294.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 31:
{
fNewYpos = 304.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 32:
{
fNewYpos = 314.0;
vector vNewPosition = Vector(fXpos,fNewYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,270.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
}
}
case 4:
{
switch(iMapSizeX)
{
case 1:
{
fNewXpos = 4.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 2:
{
fNewXpos = 14.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 3:
{
fNewXpos = 24.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 4:
{
fNewXpos = 34.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 5:
{
fNewXpos = 44.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 6:
{
fNewXpos = 54.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 7:
{
fNewXpos = 64.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 8:
{
fNewXpos = 74.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 9:
{
fNewXpos = 84.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 10:
{
fNewXpos = 94.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 11:
{
fNewXpos = 104.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 12:
{
fNewXpos = 114.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 13:
{
fNewXpos = 124.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 14:
{
fNewXpos = 134.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 15:
{
fNewXpos = 144.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 16:
{
fNewXpos = 154.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 17:
{
fNewXpos = 164.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 18:
{
fNewXpos = 174.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 19:
{
fNewXpos = 184.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 20:
{
fNewXpos = 194.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 21:
{
fNewXpos = 204.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 22:
{
fNewXpos = 214.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 23:
{
fNewXpos = 224.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 24:
{
fNewXpos = 234.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 25:
{
fNewXpos = 244.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 26:
{
fNewXpos = 254.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 27:
{
fNewXpos = 264.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 28:
{
fNewXpos = 274.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 29:
{
fNewXpos = 284.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 30:
{
fNewXpos = 294.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 31:
{
fNewXpos = 304.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
case 32:
{
fNewXpos = 314.0;
vector vNewPosition = Vector(fNewXpos,fYpos,fZpos);
location lNewLocation = Location(oArea,vNewPosition,180.0);
AssignCommand(oPC,ActionJumpToLocation(lNewLocation));
break;
}
}
}
}
}
}
I've tested it and it seems to work. Please let me know if you see any
problems or have any suggestions, Thanks
_________________
Follow the Kender
|