Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Warp script

Page: 1 of 1
 Mindtwistah
06-28-2007, 3:16 AM
#1
Is there a script that warps the PC anywhere within 10 meters? I would like the script for K1 and if possible for TSL.
 Master Zionosis
06-28-2007, 7:31 AM
#2
I guess you need to clarify a bit, warp the PC 10 meters within what?
 Mindtwistah
06-28-2007, 12:32 PM
#3
A script that warps the PC withing 10 meters. So when the script is activated you will warp anywhere withing 10 meters.
 Master Zionosis
06-28-2007, 12:38 PM
#4
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.
 Mindtwistah
06-28-2007, 1:00 PM
#5
Yes, a random location within 10 meters. Stoffe, if you see this, please tell me if it is possible or not.
 swfan28
06-28-2007, 1:38 PM
#6
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.
 stoffe
06-28-2007, 2:59 PM
#7
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)));
}
 Mindtwistah
06-28-2007, 3:57 PM
#8
Thank you Stoffe. You always save the day :)

EDIT: Is this for K1 or TSL?
 stoffe
06-28-2007, 5:22 PM
#9
EDIT: Is this for K1 or TSL?

It should work for both games, none of the functions used are TSL exclusive.
 Mindtwistah
07-19-2007, 9:52 AM
#10
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)));
}

?
 tk102
07-19-2007, 9:58 AM
#11
That would be 0-1 meter range.

Try
float fDist=IntToFloat(Random(1001))/10.0;
 Mindtwistah
07-19-2007, 10:07 AM
#12
Thanks tk for the fast answer.
 tk102
07-19-2007, 11:26 AM
#13
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.");
}
}
 stoffe
07-19-2007, 12:25 PM
#14
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.
 tk102
07-19-2007, 12:54 PM
#15
Yeah I saw the programmer's notes on that too. He said something like 60% success rate...
 Mindtwistah
08-12-2007, 5:17 PM
#16
What if I want to warp the PC 10 meters forward? Is there a script for that?
 stoffe
08-12-2007, 9:06 PM
#17
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)));
}
 Mindtwistah
08-13-2007, 7:01 AM
#18
Wow, thank you Stoffe :)
Now I may be able to warp to the place where the ship lands and goes on Taris Upper City :D
Page: 1 of 1