Jump to content

Home

Warp script


Mindtwistah

Recommended Posts

A script that warps the PC withing 10 meters. So when the script is activated you will warp anywhere withing 10 meters.

 

Errr, like a random location within 10 meters where the PC is already?

 

I don't think it's possible to warp somewhere in the current module at random, i may be wrong, I'm sure Stoffe would know.

Link to comment
Share on other sites

This would be very similar to the action ActionRandomWalk(). The only difference is that here the character would warp to location instead of walking. I don't think there is a function for warping to random location though or even for generating a random location near the caller. It might be possible to script one using random numbers and the function vector GetPosition(object oTarget) but it would be difficult.

Link to comment
Share on other sites

Yes, a random location within 10 meters. Stoffe, if you see this, please tell me if it is possible or not.

 

Something like this should probably work to "teleport" the player to a random location within a 10 meter radius. Keep in mind that it doesn't care if you have line of sight to the target location, so it might warp you through walls and doors if used in a tight indoor location.

 

void main() {
   object oPC = GetFirstPC();
   float fAngle = IntToFloat(Random(360));
   float fDist = IntToFloat(Random(101)) / 10.0;
   location lRand = Location(GetPosition(oPC) + AngleToVector(fAngle) * fDist, GetFacing(oPC));        
   DelayCommand(0.5, AssignCommand(oPC, JumpToLocation(lRand)));
}

Link to comment
Share on other sites

  • 3 weeks later...

If I want myself to teleport withing 100 meters radius, would the script be this:

 

void main() {

object oPC = GetFirstPC();

float fAngle = IntToFloat(Random(360));

float fDist = IntToFloat(Random(101)) / 100.0;

location lRand = Location(GetPosition(oPC) + AngleToVector(fAngle) * fDist, GetFacing(oPC));

DelayCommand(0.5, AssignCommand(oPC, JumpToLocation(lRand)));

}

 

?

Link to comment
Share on other sites

In TSL you can also use

void main() {
 object oPC=GetFirstPC();
 int nRange = 100;  // 100 meters
 vector vNew=GetRandomDestination(GetFirstPC(), nRange);
 location lRand=Location(vNew, GetFacing(oPC));
 DelayCommand(0.5, AssignCommand(oPC, JumpToLocation(lRand)));
}

 

If you wanted a line-of-sight check (in TSL only):

void main() {
 object oPC=GetFirstPC();
 int nRange = 100;  // 100 meters
 int nCount=0;
 vector vOld=GetPosition(oPC);
 vector vNew;
 location lRand;
 while (nCount<20) {
vNew=GetRandomDestination(GetFirstPC(), nRange);
       if (HasLineOfSight(vOld, vNew)) {
          break;
       }
       nCount++;
 }
 if (nCount<20) {
    lRand=Location(vNew,GetFacing(oPC));
    DelayCommand(0.5, AssignCommand(oPC, JumpToLocation(lRand)));
 }
 else {
    SendMessageToPC(oPC,"Random warp failed to find a suitable destination.");
 }
}

Link to comment
Share on other sites

If you wanted a line-of-sight check (in TSL only):

(snip)

 

Be warned though that the HasLineOfSight() function is extremely unreliable. Sometimes it can return FALSE for something that's right in front of you, or TRUE for something that's behind closed doors or behind walls. It also seems to have trouble determining if placeables on the path is blocking the line of sight.

Link to comment
Share on other sites

  • 4 weeks later...
What if I want to warp the PC 10 meters forward? Is there a script for that?

 

Something like this would probably work:

void main() {
   object oPC = GetFirstPC();
   float fFace = GetFacing(oPC);
   location lForward = Location(GetPosition(oPC) + AngleToVector(fFace) * 10.0, fFace);
   DelayCommand(0.5, AssignCommand(oPC, JumpToLocation(lForward)));
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...