Station Movement Help Wanted

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
PKodon
Militia Lieutenant
Militia Lieutenant
Posts: 127
Joined: Sat Apr 18, 2009 6:03 pm
Location: "Minocs. I've got a baaad feeling about this.... This is no cave!"

Without spoiling a surprise, I'd like some help with writing some generic code for acquiring a vector, then moving a station, one pixel at a time, slowly, along that vector.

The idea is, the station slowly moves around the outside of a group of objects. I know stations can move, it's just that I'm, rather new to Transcendence coding, and need help with vectors, especially.

Thanks in advance, please only reply if truly interested in helping.

PK
"Don't ask ..., I don't wanna know, and I don't wanna care!" - PK
Meet us on IRC --> Image
"... the hornet battlepod is the closest we have ingame to flying into battle in a wheelbarrow
with a bathtub nailed upside down to the top of it to provide armor."
- The Shrike
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

I'm not good at squiring a vector, but I can help move the station.

EDIT: my first attempt at a helper function is producing massively high speeds, it will need some refinement.
User avatar
PKodon
Militia Lieutenant
Militia Lieutenant
Posts: 127
Joined: Sat Apr 18, 2009 6:03 pm
Location: "Minocs. I've got a baaad feeling about this.... This is no cave!"

Just the man I was looking for, thanks for responding.

Out of curiosity, what command are you using to move the station?

I was thinking of using objMoveTo with a vector to get it under 1 ls.

Oh, and try doing the moving in an <onUpdate></onUpdate>

You know, I hang out on the IRC channel, if you want to discuss this in "real time".

:)

PK
"Don't ask ..., I don't wanna know, and I don't wanna care!" - PK
Meet us on IRC --> Image
"... the hornet battlepod is the closest we have ingame to flying into battle in a wheelbarrow
with a bathtub nailed upside down to the top of it to provide armor."
- The Shrike
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

I haven't gotten very far, here's what I have: a function that moves an object a specified speed and direction

Code: Select all

	<globals>
		(setq objSetVel (lambda (obj dir speed option)
			(block (currVel)
				(setq currVel (objGetVel obj))
				(objMoveTo obj (objGetPos obj))
				(if (eq 1 option)
					(objIncVel obj currVel)
				)
				(objIncVel obj (sysVectorPolarOffset Nil dir speed))
			)
		))
	</globals>
obj= the object
dir= direction
speed= the speed to move it
option= if 1 the object retains it's current momentum in addition to the new acceleration.

I don't know of a way to get less than 1ls resolution with anything, so objMoveTo for moving is out of the question, too choppy.


The code will work on a moveable station too, I tried it on my ship, a corsair, and a cargo crate, all of them moved but...

It seems objIncVel is broken in rc6, it only does high speed when used with sysVectorPolarOffset, in the code above with speed=1 I went light-speed, when it was less I went 0...

Somehow restoring the object's previous velocity vector works perfectly, so I could just be missing how to make a proper velocity vector.
User avatar
PKodon
Militia Lieutenant
Militia Lieutenant
Posts: 127
Joined: Sat Apr 18, 2009 6:03 pm
Location: "Minocs. I've got a baaad feeling about this.... This is no cave!"

Okay, first off, supposedly, you can feed a vector to objMoveTo, which should mean that, if the vector is short enough, it should move one pixel.

Second, if the station has momentum, then a kinetic or blast weapon could move it out of it's planned course, and code would need to be included to bring it back on course.

Thus, I'm hoping to make the station not be mobile, normally, unless moved with objMoveTo.

I'll have to do some research on objMoveTo regarding the vector input, and get back to you.

The first step, I think, is to figure out how to set a waypoint, then move toward that waypoint along a short vector in the general direction of the waypoint.

PK
"Don't ask ..., I don't wanna know, and I don't wanna care!" - PK
Meet us on IRC --> Image
"... the hornet battlepod is the closest we have ingame to flying into battle in a wheelbarrow
with a bathtub nailed upside down to the top of it to provide armor."
- The Shrike
schilcote
Militia Captain
Militia Captain
Posts: 726
Joined: Sat Feb 02, 2008 7:22 pm

PKodon wrote:Okay, first off, supposedly, you can feed a vector to objMoveTo, which should mean that, if the vector is short enough, it should move one pixel.
Unless I'm very mistaken, such a function would take a position vector, which is an absolute position in space (usually relative to some permanent immobile object, in Source, more or less an arbitrary point in space. If I were making Transcendence I'd use the Sun) as opposed to a direction vector, which conveys velocity (direction of movement, i.e. 1,0 would move up the X axis, and speed as magnitude, like 4,1 would go up the X axis four units and the Y one every tick).
[schilcote] It doesn't have to be good, it just has to not be "wow is that the only thing you could think of" bad
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

I don't know if this will help you in your station moving problems but we got

(sysVectorPolarVelocity angle speed) -> velVector

in one of the RCs.
Crying is not a proper retort!
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

That's it, thanks Betelgeuse.

here's a fully functional object moving global helper function.

Code: Select all

<globals>
		(setq fnSetVel (lambda (obj dir speed option)
			(block (currVel)
				(setq currVel (objGetVel obj))
				(objMoveTo obj (objGetPos obj))
				(if (eq 1 option)
					(objIncVel obj currVel)
				)
				(objIncVel obj (sysVectorPolarVelocity dir speed))

			)
		))
	</globals>
[/size]

The station being blown off course won't be so bad when the station stops itself over time anyway (unlike ships, which drift forever), particularly if the mass is high(which won't affect objIncVel) and since the function can also stop any drifting when it is called in the onUpdate (omit the "option" parameter).

I don't think "jumping" a smaller than 1ls, but non-zero distance is possible with objMoveTo, it will be very jerky.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I did some trials with objMoveTo in 0.99c, and you can actually get a pretty smooth animation going *until* you hit some heavy fighting or other cpu consuming task... then it looks horrible. The timer to move the station has to be run every tick, which is hardly recommended for any non critical task.
User avatar
PKodon
Militia Lieutenant
Militia Lieutenant
Posts: 127
Joined: Sat Apr 18, 2009 6:03 pm
Location: "Minocs. I've got a baaad feeling about this.... This is no cave!"

Bobby,

Thanks for the code, and the research. I'm glad I posted here, as it seems others are interested in this as well.

PK
"Don't ask ..., I don't wanna know, and I don't wanna care!" - PK
Meet us on IRC --> Image
"... the hornet battlepod is the closest we have ingame to flying into battle in a wheelbarrow
with a bathtub nailed upside down to the top of it to provide armor."
- The Shrike
User avatar
PKodon
Militia Lieutenant
Militia Lieutenant
Posts: 127
Joined: Sat Apr 18, 2009 6:03 pm
Location: "Minocs. I've got a baaad feeling about this.... This is no cave!"

alterecco,

How fast were you trying to move your space object? The targeted object in this case should only be moving one pixel every 30 ticks (1 second), as onUpdate runs once every 30 ticks (or so I understand it).

PK
"Don't ask ..., I don't wanna know, and I don't wanna care!" - PK
Meet us on IRC --> Image
"... the hornet battlepod is the closest we have ingame to flying into battle in a wheelbarrow
with a bathtub nailed upside down to the top of it to provide armor."
- The Shrike
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I was moving it very often, as I tried to get a fluid motion.

Running at 30 ticks would help a lot... Worth trying for sure
User avatar
PKodon
Militia Lieutenant
Militia Lieutenant
Posts: 127
Joined: Sat Apr 18, 2009 6:03 pm
Location: "Minocs. I've got a baaad feeling about this.... This is no cave!"

alterecco:

Could you post your code, for comparison?

Also, pretend what I'm moving is the space-equivalent of the Goodyear (TM) Blimp.

PK
"Don't ask ..., I don't wanna know, and I don't wanna care!" - PK
Meet us on IRC --> Image
"... the hornet battlepod is the closest we have ingame to flying into battle in a wheelbarrow
with a bathtub nailed upside down to the top of it to provide armor."
- The Shrike
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Sorry, the code has been lost to the mists. It would not have served you anyways, since it did not do what you need (it was continuously placing a spaceobject relative to the playership... a futile attempt to make hud elements)
Post Reply