Page 1 of 1

Positioning Laser

Posted: Sat Sep 13, 2008 9:02 pm
by Cpt Haddock
Hello all,

Long time listener, first time caller! I'm just discovering what Oolite has to offer. I started out with FE2 on an Atari 520ST and it's been a long time since I hopped into my Cobra MkIII. I'm amazed at what you have achieved with Oolite (even more amazed it's free!)

In all my years of gaming I've always harboured an ambition to add something to the games I've played and Oolite (along with Wings3D, GiMP, ViM and Python) is letting me do just that.

I've found a lot of really great info on the BB and Wiki without which I wouldn't have managed to get my first model up and away, but I've hit upon a snag and I can't find an answer.

I've pretty much copied the CobraMkIII shipdata.plist entry from the Oolite resources and I've tweaked it for my vessel, however I cannot get the laser position to move. I've also deleted the lines for the starboard and port weapon placement but I can still fit and fire lasers from these positions.

heres the entry:

weapon_position_aft = "0.0 10.98 -51.72";
weapon_position_forward = "100.0 100.0 100.00";

I know the forward weapon position looks rediculous but I was testing it to see if it would move and it remains firmly centered. I had it set to a sensible location but that hadn't worked either.

I'm running V1.72.1 with only my own ship oxp installed. Any advice would be greatly appreciated.

Also how do I post a screenshot?

Re: Positioning Laser

Posted: Sat Sep 13, 2008 9:27 pm
by JohnnyBoy
Cpt Haddock wrote:
Also how do I post a screenshot?
You put the web address of the image between [img]and[/img] tags.

Posted: Sat Sep 13, 2008 9:29 pm
by DaddyHoggy
Hi Cpt Haddock - welcome to the forums.

Have you run Oolite with the shift key held down during start up? You need to hold the key down until the spinning Cobby3 appears.

The shift key forces Oolite to refresh - this I think includes new ships - others have reported buying new ships and still have the views of their old ships this may be related?

re screenshots - you need to have the shot hosted on the web i.e. somewhere like photobucket (free and easy to register) then you put the link from photobucket between some 'img' quotes and Robert's your mother's brother - your screenshot will appear.

HTH

DH

Re: Positioning Laser

Posted: Sat Sep 13, 2008 10:04 pm
by Eric Walch
Cpt Haddock wrote:
I know the forward weapon position looks rediculous but I was testing it to see if it would move and it remains firmly centered. I had it set to a sensible location but that hadn't worked either.

I'm running V1.72.1 with only my own ship oxp installed. Any advice would be greatly appreciated.
This is a bug in the later oolite versions. somewhere introduced with version 1.68 or 1.69. since then the laser stays centred and ignores the keys. The only thing you can play with is the view positions.

Re: Positioning Laser

Posted: Sat Sep 13, 2008 11:54 pm
by Cpt Haddock
Thanks for the quick responses, you've saved me from some code bashing! I'll try uploading some screenshots to FlickR and see if I can get them on here. Thanks for the 'Shift Key' tip, though I had already gleaned that and many more pearls of wisdom from the BB. I'm very grateful to all those who have gone before!
Eric Walch wrote:
This is a bug in the later oolite versions. somewhere introduced with version 1.68 or 1.69. since then the laser stays centred and ignores the keys. The only thing you can play with is the view positions.
D'oh! I don't suppose there is any way aound this? What would I be missing out on if I revert to Oolite 1.65? Supposing I do revert to 1.65 in order to adjust the laser position is it possible to change the direction of the laser beam? What I'd like to create is a mining ship with a forward facing mining laser on either the port or starboard mount.

Thanks again guys.

Posted: Sun Sep 14, 2008 4:34 am
by Gunney_Plym
The only way that I've found to move the laser around is using sub-entities. I'm working on a group of ships that use this but they aren't ready for publishing yet.

An excellent example of using sub-entities, indeed it's where I borrowed the 'how it's done' is the Imperial Courier OXP On the wiki here

PS Welcome :D

Posted: Sun Sep 14, 2008 7:07 am
by Cpt Haddock
Gunney_Plym wrote:
The only way that I've found to move the laser around is using sub-entities. I'm working on a group of ships that use this but they aren't ready for publishing yet.

An excellent example of using sub-entities, indeed it's where I borrowed the 'how it's done' is the Imperial Courier OXP On the wiki here

PS Welcome :D

Wow! I would like to see this fleet! Thanks for the ImpCourier link, I'll be butchering that code in the not too distant future! In the meantime I'll keep my fingers crossed for a patch to fix the bug. I guess you are effectively adding a turret in order to move the position of the forward laser? With NullAI the turret will fire upon the player selected target, is that correct? How does the turret actually work, I can see the code to provide rotation for the IC engines so is there a similar code that allows the turret to move freely to follow a target? I'm designing a ship with trader and mining variants and I think a turret/s would be useful for self defense.

Posted: Sun Sep 14, 2008 8:08 am
by Thargoid
Maybe I'm missing something here, but exactly what are you trying to do? Move the cross-hairs (the target sight) within the screen, or move the original position where the laser comes from?

The former is not possible (to my knowledge), the sights are always centre-screen. But the latter is do-able, although the origin point of the laser beam (the weapon mount position, the figures you quoted in your first post) as Eric says seem to be somewhat broken. In my experience to get a beam either coming from off-screen at the top or the bottom (as in a "standard" Cobra Mk III for the latter) the laser mount position needs to be situated somewhere in space above or below the ship (or at least relative to the view position location, essentially where the ship's windows are). The bug "makes it work" in 1.65, but in 1.71 if the keys aren't set you end up looking down the laser (the weapon_position defaults to the view_position), so you end up with a very weird laser effect).

For example these positions are the ones I use in my Manta Ray ship:

Code: Select all

	view_position_aft = "0.0 5.5 -12.5";
		weapon_position_aft = "0.0 0.0 17.29";
		view_position_forward = "0.0 2.0 16.1";
		weapon_position_forward = "0.0 -1.0 36.1";
		view_position_port = "-9.43 5.0 -1.95";
		view_position_starboard = "9.43 5.0 -1.94";
and they work visually, even if as I say technically they're actually outside the main body of the ship :wink: Note that the Manta Ray only has front and rear weapons fittable (see below), hence no weapon_position_port or weapon_position_starboard.

As for lasers appearing in all windows when you don't have them installed, you'll notice that the cross-hairs change design depending on what weapon is installed (via the key forward_weapon_type = "WEAPON_BEAM_LASER"; and equivalent, or in the player case what weapons are purchased). If there is no weapon installed in the view, you get the simple sight (just left and right marks iirc), and you get different variations on the crosshair design for the other lasers.

You will always have the 4 views available, but it can be that you cannot mount weapons on them (and you can limit which weapons, and indeed any equipment, that a given ship can use). Both of those are done with the ship's entry in the shipyard.plist. The former is done via the weapon_facing key (via a little binary-type summation, see the wiki entry for shipyard.plist for details), and the latter by whether the item is set within the array for "standard_equipment" (ie the ship comes with it when purchased) or "optional_equipment" (you can fit it after purchase). Trunk tems should be in one or the other only (not both), but if they're in neither then that item is not available for that ship. It's slightly different for OXP-introduced items, availability there is set within their coding.

Posted: Sun Sep 14, 2008 8:50 am
by Cpt Haddock
Hello Thargoid,

What I am trying to do is move the point of origin for the laser, but as you and Eric have pointed out this function is broken. As for he starboard and port weapon positions, I have removed the line from the code in an attempt to make port and starboard viewing positions only (as in your Manat Ray). However the option to mount a laser is still available in the shipyard. Am I missing something?

I'm going to have a crack at some turrets and I anticipate having some coding crisis so I'll no doubt be posting back! I assume that the laser point of origin for the sub-entity is central too? Also, I noted this on the Wiki:

setup_actions

Arranges a process that may be necessary for some objects, like ball turrets.

Example:

<key>setup_actions</key>
<array>
<string>initialiseTurret</string>
</array>


Is a ball turret the standard setup for a turret? Does this mean that a ball turret will swivel around its centre?

Posted: Sun Sep 14, 2008 9:02 am
by Thargoid
For the weapons available in views, to quote the wiki:
In the wiki, someone wrote:
weapon_facings
What weapon mounts are available on the ship. This is a bit-mask, so pick the mounts and add the numbers:

1 - Forward
2 - Aft
4 - Port
8 - Starboard

Example:
Fore and aft weapon mounts only.

<key>weapon_facings</key>
<integer>3</integer>

Example:
All weapon mounts.

<key>weapon_facings</key>
<integer>15</integer>
which I think is clear enough. In the shipyard.plist you can say which weapons are available to the ship (pulse, beam, military etc) but when you actually use the ship (as a player ship in-game), the weapons_facing setting defines which views you can fit those weapons onto (or not as the case may be). It sounds like you've not put the weapons_facing key into the ship's shipyard.plist entry (note it's shipyard.plist where that one goes, not shipdata.plist).

To clarify the difference, the shipdata.plist file is the basic ship design and functionality itself (now it looks and flies, it's characteristics, energy levels, view/weapon locations and so forth). The shipyard.plist file is how that ship is available for purchase (via the F3 then F3 screen when docked - what tech level system is needed and how much it costs), and how you can equip it once you have purchased it (via the F3 screen when docked). I suspect in your case you've either only set shipdata.plist but not shipyard.plist, or you've put weapon_facings in the wrong file.

I'll be honest that I've never tried to use turrets on a player ship, so I don't know if it's possible or not, and what coding hiccups you may or may not encounter. But sub-entity lasers work in much the same way as main body laser entries work (although player ships cannot have multiple weapons firing in the same view).

Posted: Sun Sep 14, 2008 11:21 am
by Cpt Haddock
Thanks Thargoid,

I haven't changed the weapon_facings in the shipyard.plist. That should solve that particular problem. :D