Move to position with speed limit

The place to discuss scripting and game modifications for X³: Reunion.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Move to position with speed limit

Post by Gazz » Sat, 14. Jun 08, 09:16

The actual speed varies with the object (size, acceleration - did not inquire) but it is possible to have an object fly to XYZ at a specific speed.

I tried this with a fighter drone and any entered speed between 30 and 370 is almost exactly on the mark.
Arguments
1: Speed.Limit , Var/Number , 'Speed Limit'

001 $Target = get player tracking aim
003 $Sector = [PLAYERSHIP] -> get sector
004
005 while $Target -> exists
006 $X = $Target -> get x position
007 $Y = $Target -> get y position
008 $Z = $Target -> get z position
009 $X = $X + $Speed.Limit * 4
010 @ START $Target -> call script '!move.movetoposition' : sector=$Sector position x=$X position y=$Y position z=$Z precision=5
011 @ = wait 150 ms
012 end
Unlike attack run with speed limit this does not require a target object.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

jlehtone
Posts: 17259
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone » Sat, 14. Jun 08, 09:40

Interesting, what makes it "tick"?
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Sat, 14. Jun 08, 11:44

You know that ships automatically slow down when approaching the move.to destination.

Like a carrot on a stick I keep this destination a short distance in front of the ship so it slowly follows my carrot.
The length of the stick defines the speed.

I'm making a ship "tow" something but the heavier the load, the slower the ship moves.
Cool effect and technically impossible with regular commands but... why limit myself to regular commands? =)

As a result I can liberally move the target with force position because the tow ship has the speed limit built in. Doing a useful speed simulation with force position is very ardous and inaccurate.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Cash'Lu
Posts: 82
Joined: Mon, 2. Apr 07, 00:32
x3tc

Post by Cash'Lu » Sat, 14. Jun 08, 19:39

Good call Gaz, good call.

You have no idea of how much time I spent pondering trying to find an elegant (meaning not exceeding 100 lines of code mostly mathematical equations) for such a system.

Was writing an "Maintain Orbit script" but had to make sure the ship was a 0m/s and just simulate velocity with the forced move command.
Image

Lancefighter
Posts: 2936
Joined: Sun, 19. Dec 04, 03:41
xr

Post by Lancefighter » Sat, 14. Jun 08, 20:32

rather interesting little snippet you have there.
in the market for a new sig, willing to pay 1 billion credits for a proper sig...

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Sat, 14. Jun 08, 20:41

The real thing is used for the MARS goblins when they bring things back to their master so you can see how it works. =)
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

jlehtone
Posts: 17259
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone » Sat, 14. Jun 08, 21:13

Gazz wrote:Like a carrot on a stick I keep this destination a short distance in front of the ship so it slowly follows my carrot.
The length of the stick defines the speed.
Ok, I get that now, so the example in the OP shows "how to hold the carrot if you want to go East".

If you do want to go to a specified point, then naturally you have to add the "Are we there yet?" test, and use unit-lenght direction vector instead of (1,0,0). Floating point math?
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Sun, 15. Jun 08, 04:33

Basically, yes.
This example was my first test for it and it's a lot easier to read than the real thing with proper vectors and checks.

Doesn't require floating point math, though. A few meters give or take won't matter since I do not use a 1 ms wait.
The higher the timing delay the higher the fluctuation in ship speed. 3-8 m/s in this example.
If you use this on the playership you might want to use a 1 ms wait but not for every ship.

If you want to see the complete script, look at the goblin.control and flyto scripts. Since a goblin runs 3 simultaneous tasks to tow something it's not for the faint of heart. =)
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

DaveyP
Posts: 982
Joined: Mon, 7. Nov 05, 20:06
x3tc

Post by DaveyP » Mon, 16. Jun 08, 15:27

This would be great for an "attack in a pack" type of command

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20600
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Tue, 17. Jun 08, 05:01

the main problem is that X is not always forward, u will need to compute the forward vector then increase the position down that vector at a set speed amount.

which basically what my warp drive does. Althou the step is much better making it move much faster.

there are a few other problems, the player can mess things up when they try to move the ship.

u'll have to adjust the direction vector to match the players current heading.

or, like my Advanced Thruster control script, fix the direction allowing the player to look in a different direction.

which reminds me, i should fix that, with the new commands added it should now be fully working with a small edit

Post Reply

Return to “X³: Reunion - Scripts and Modding”