lfnetwork.com mark read register faq members calendar

Thread: Warp script
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 06-28-2007, 03:16 AM   #1
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
Warp script

Is there a script that warps the PC anywhere within 10 meters? I would like the script for K1 and if possible for TSL.


Mindtwistah is offline   you may: quote & reply,
Old 06-28-2007, 07:31 AM   #2
Master Zionosis
Relax On Air
 
Master Zionosis's Avatar
 
Join Date: Sep 2006
Location: High In The Sky
Posts: 1,280
Current Game: TR 8: Underworld
Contest winner - Modding 
I guess you need to clarify a bit, warp the PC 10 meters within what?

Master Zionosis is offline   you may: quote & reply,
Old 06-28-2007, 12:32 PM   #3
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
A script that warps the PC withing 10 meters. So when the script is activated you will warp anywhere withing 10 meters.


Mindtwistah is offline   you may: quote & reply,
Old 06-28-2007, 12:38 PM   #4
Master Zionosis
Relax On Air
 
Master Zionosis's Avatar
 
Join Date: Sep 2006
Location: High In The Sky
Posts: 1,280
Current Game: TR 8: Underworld
Contest winner - Modding 
Quote:
Originally Posted by Mindtwistah
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.

Master Zionosis is offline   you may: quote & reply,
Old 06-28-2007, 01:00 PM   #5
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
Yes, a random location within 10 meters. Stoffe, if you see this, please tell me if it is possible or not.


Mindtwistah is offline   you may: quote & reply,
Old 06-28-2007, 01:38 PM   #6
swfan28
Rookie
 
Join Date: May 2007
Location: Finland
Posts: 157
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.
swfan28 is offline   you may: quote & reply,
Old 06-28-2007, 02:59 PM   #7
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Mindtwistah
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.

Code:
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)));
}

stoffe is offline   you may: quote & reply,
Old 06-28-2007, 03:57 PM   #8
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
Thank you Stoffe. You always save the day

EDIT: Is this for K1 or TSL?


Mindtwistah is offline   you may: quote & reply,
Old 06-28-2007, 05:22 PM   #9
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Mindtwistah
EDIT: Is this for K1 or TSL?
It should work for both games, none of the functions used are TSL exclusive.
stoffe is offline   you may: quote & reply,
Old 07-19-2007, 09:52 AM   #10
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
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)));
}

?


Mindtwistah is offline   you may: quote & reply,
Old 07-19-2007, 09:58 AM   #11
tk102
Well past expiration date
 
tk102's Avatar
 
Join Date: Jan 2004
Posts: 5,766
Current Game: Fallout 2
Forum Veteran Helpful! Notable contributor 
That would be 0-1 meter range.

Try
float fDist=IntToFloat(Random(1001))/10.0;
tk102 is offline   you may: quote & reply,
Old 07-19-2007, 10:07 AM   #12
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
Thanks tk for the fast answer.


Mindtwistah is offline   you may: quote & reply,
Old 07-19-2007, 11:26 AM   #13
tk102
Well past expiration date
 
tk102's Avatar
 
Join Date: Jan 2004
Posts: 5,766
Current Game: Fallout 2
Forum Veteran Helpful! Notable contributor 
In TSL you can also use
Code:
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):
Code:
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.");
  }
}
tk102 is offline   you may: quote & reply,
Old 07-19-2007, 12:25 PM   #14
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by tk102
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.
stoffe is offline   you may: quote & reply,
Old 07-19-2007, 12:54 PM   #15
tk102
Well past expiration date
 
tk102's Avatar
 
Join Date: Jan 2004
Posts: 5,766
Current Game: Fallout 2
Forum Veteran Helpful! Notable contributor 
Yeah I saw the programmer's notes on that too. He said something like 60% success rate...
tk102 is offline   you may: quote & reply,
Old 08-12-2007, 05:17 PM   #16
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
What if I want to warp the PC 10 meters forward? Is there a script for that?


Mindtwistah is offline   you may: quote & reply,
Old 08-12-2007, 09:06 PM   #17
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by Mindtwistah
What if I want to warp the PC 10 meters forward? Is there a script for that?
Something like this would probably work:
Code:
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)));
}

stoffe is offline   you may: quote & reply,
Old 08-13-2007, 07:01 AM   #18
Mindtwistah
Junior Member
 
Mindtwistah's Avatar
 
Join Date: Apr 2007
Location: Derka Derka
Posts: 470
Wow, thank you Stoffe
Now I may be able to warp to the place where the ship lands and goes on Taris Upper City


Mindtwistah is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Warp script

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:09 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.