tractor beams query

Freeform discussion about anything related to modding Transcendence.
Post Reply
relanat
Militia Captain
Militia Captain
Posts: 800
Joined: Tue Nov 05, 2013 9:56 am

Wed Aug 28, 2019 1:29 am

I love the idea of having a tractor beam which could drag objects behind the playership. So many applications spring to mind.

Pirate other NPC ships and sell them to the Black market.
Drag wrecks to tinkers or a shipyard for salvage.
squalus10 had a great idea for a mission using tractor beams as well.

But several comments I have seen (which I now can't find) indicate this can't be done.
Is this correct?

I was thinking of an event which set the position of the dragged object every tick or so at a certain distance from the playership with a small effect linking the two objects. Compensating for mass and direction would be required but that would seem to be only a maths problem not a mod killing problem. Would this work?

The tractor beam mods on xelerus don't seem to work.
Stupid code. Do what I want, not what I typed in!

Ferdinand
Militia Lieutenant
Militia Lieutenant
Posts: 171
Joined: Mon Feb 23, 2015 2:35 pm
Location: Dancing in the universe
Contact:

Wed Aug 28, 2019 7:43 am

How about creating a gravity well on the playership, that would drag in nearby ships? That code should be relatively simple looking at existing gravity sources in the game (Sirius) This is not really a tractor beam, but could be fun to try.

AdmiralZo
Militia Lieutenant
Militia Lieutenant
Posts: 209
Joined: Wed Feb 11, 2015 10:32 am
Location: Scouring Dantalion System for CSC Antarctica...

Wed Aug 28, 2019 8:44 am

Hmm, a gravity well would be interesting...but it would rip apart the ship you're trying to drag :D


I've managed to make the tractor beam by using (objSetPos ...) and a recurring timer event.

It sets the position of the object to be 10 light-seconds away from the player. The angle of the object is 180 degrees plus the angle that the player is travelling, using (sysVectorAngle (objGetVel gPlayerShip)) to make it behind the player.

At the moment, the mass of the object is not taken into consideration, but I might implement it later (so the player slows down when dragging heavy objects).


Make sure you have the "Tractor Beam" item in your cargo hold. Target an object (ship or station), that is within 20 light-seconds of your ship, then use the "Tractor Beam" item. Voila! To disable the beam, deselect the target, then use the item again.

The beam is so strong it can even drag stations and stargates!!! :D :o

Currently there are still a few problems though. The tractor beam gets stuck when the player leaves the system. I've tried using <OnPlayerLeftSystem> but it doesn't seem to work. Not sure if that is even a thing... Fixed using <OnGlobalPlayerLeftSystem>

Thanks Relanat for your godships, they are very helpful!!!
TractorBeam.zip
(1.63 KiB) Downloaded 9 times
Attachments
TractorBeam1.png
TractorBeam1.png (630.73 KiB) Viewed 207 times
TractorBeam2.png
TractorBeam2.png (773.09 KiB) Viewed 207 times

relanat
Militia Captain
Militia Captain
Posts: 800
Joined: Tue Nov 05, 2013 9:56 am

Fri Aug 30, 2019 3:57 am

Awesome. Thanks. Downloaded.
I love it when someone else writes the code! :)
Stupid code. Do what I want, not what I typed in!

relanat
Militia Captain
Militia Captain
Posts: 800
Joined: Tue Nov 05, 2013 9:56 am

Mon Sep 02, 2019 3:42 am

Excellent mod, AdmiralZo.
Nice work getting the angle that the playership is heading to as opposed to pointing at. Very clever.
And thanks because I now know a bit about effects too (well, OK, I just searched the source and tried every style I could find :lol:).

I fiddled around with the mod a bit but made it a bit glitchy.
No dragging stargates around anymore. Although that is a really handy escape hatch!

Rather than compensating for mass (too hard) the playership's max speed is halved when beaming.

marsrocks has some timer event code in the Target Lock mod which is also used in the Ship Pointing mods. This adds delays when resetting angles. I will try and get it working in this mod. ATM the angle is only decreasing when the playership thrusts. In theory marsrocks' code could keep it decreasing as long as the playership is moving.

It would be good to have an effect that varied in length to match the distance between the playership and target.

And my brain hurts from trying to work out the code that tells if the playership is moving towards the target. Yikes! A "vector/angle function explanation please" topic could be coming up! :?

My pirate mod where the player hijacks ships and drags them to tinkers or shipyards to sell is now possible. Yay. You are a legend!

Also does anyone know where the gravity code is?
Attachments
TractorBeamButchered.xml
(7.84 KiB) Downloaded 6 times
Stupid code. Do what I want, not what I typed in!

AdmiralZo
Militia Lieutenant
Militia Lieutenant
Posts: 209
Joined: Wed Feb 11, 2015 10:32 am
Location: Scouring Dantalion System for CSC Antarctica...

Wed Sep 04, 2019 1:40 pm

Wow!!! The 'butchered' code looks so advanced! :shock: :shock: It seems to be working pretty well too!

The length of the effect can be varied using <GetParameters>

Code: Select all

<EffectType UNID="&efTractorBeam;"
        instance="owner"
		>
		<Effect>
			<Ray	
				style=		"grainy"
				shape=		"tapered"
				width=		"20"
				intensity=		"9"
				lifetime=		"2"

				primaryColor=	"#1ddb30"
				secondaryColor=	"#39dbd6"
				>
          	</Ray>

      	</Effect>

	<Events>
		<GetParameters>
			(block Nil
				{
					; length is (200*dist)/10, where 200 is the max length of the beam, and 10 being the max distance
					; of the player from the target
					length: (divide (multiply 200 (objGetDistance gPlayerShip (sysFindObject Nil "N*+data:tractorBeamTarget"))) 10)
					}
				)
		</GetParameters>
	</Events>
   </EffectType>
Gravity code can be found under the "White Dwarf Star" in Stars.xml. All it does is specify a gravity radius and mass. Note that gravity will only work if the station has scale="star". Don't think gravity works for ships, though I haven't tried it yet.

Post Reply