Problem with subentities

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Problem with subentities

Post by UK_Eliter »

Dear all

The turrets on my Fer-de-Lance 3G+(t) keep getting shot off, almost no matter how tough I make them (for I designed the ship in question). Now, I'm presuming that subentities get repaired automatically when docked - but is that true? If not, perhaps it should be - but a workaround is possible.

Here's my relevant code.

Code: Select all


"ferdelance3-playerPlusModelWithTurrets" = {
		like_ship = "ferdelance3-playerPlusModel";
		energy_recharge_rate = 5.05;
		frangible = yes;
		max_flight_speed = 504;
		model = "ferdelance3G+.dat";
		name = "Fer-de-Lance 3G+(t)";
		subentities = (
         		"3G-turret -17 -4.0 10.5 0.906141 0.180249 0.375336 0.0746615",
         		"3G-turret 17 -4.0 10.5 -0.906141 -0.180249 0.375336 0.0746615"
      		); 
		// Turret entity itself is defined below.
		thrust = 56; // One less than the normal 'Plus' model.
	};


	// TURRET ENTITY

	"3G-turret" =
	{
		accuracy = 4.4;
		ai_type = "nullAI.plist";
		energy_recharge_rate = 130; // make 'em tough, in accordance with Fer-de-Lance build quality!
		laser_color = "purpleColor";
		max_energy = 2000; // Ditto previous comment
		max_flight_pitch = 1;
		max_flight_yaw = 1;
		max_flight_roll = 1;
		model = "3G_turret.dat";
		name = "3G Turret";
		roles = "3G-turret ballturret";
		setup_actions = ("initialiseTurret");
		smooth = true;
		thrust = 1;
		weapon_energy = 12;
	};

User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Problem with subentities

Post by Commander McLane »

UK_Eliter wrote:
The turrets on my Fer-de-Lance 3G+(t) keep getting shot off, almost no matter how tough I make them (for I designed the ship in question). Now, I'm presuming that subentities get repaired automatically when docked - but is that true?
No. They get repaired when you do a maintenance overhaul. Hence I presume that you're offered one fairly often, which is fairly costly.

In order to make up for the not-yet-satisfactory subentity-handling subentities on player ships shouldn't be able to get shot off in the first place. As it is now, the ability to have them shot off is almost a bug in the OXP.

The only thing you need to do to correct this is to change the line

Code: Select all

      frangible = yes;
to

Code: Select all

      frangible = no;
Afterwards you should return the turrets' energy levels to their original values, or all damage done to your ship will be diverted to your subentities, turning them almost into an indestructibility-cheat.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Problem with subentities

Post by Eric Walch »

UK_Eliter wrote:
Now, I'm presuming that subentities get repaired automatically when docked - but is that true?
On the contrary, since 1.75 these missing bits are even stored in your save file to make sure they are not magically restored after reloading a commander.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Problem with subentities

Post by UK_Eliter »

Dear both

Thanks for the information.

However: I want the turrets to be damageable, only I don't want the damage to accumulate between trips. Or rather, I think, now, that having the damage accumulate would be a good idea, but I don't want that accumulation to mean that the turrets always get damaged instead of the ship itself. Is there some fairly easy (script?) way of achieving this behaviour, please?
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Problem with subentities

Post by Commander McLane »

Not trivially, I am afraid.

I have to admit that I know zilch about the distribution of damage over main entity and subentities. But often it seems to me that the subentities tend to get damaged first, and that's also true for NPCs. It gets to the point where subentities effectively act as a shield to the main entity. This is especially noticeable for ships with many subentities.

What you can do is to restore the subentities every time you dock, or even instantly. But that would only mean an even more efficient deflection of damage away from your ship's main entity.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Problem with subentities

Post by UK_Eliter »

There is the 'this.shipTakingDamage' routine. But to use that to distribute damage as I want it (to the shields or the energy or the turret . . ) I'd have to (1) know whether the damage has penetrated whichever shield is relevant, (2) know how Oolite would automatically, and despite my script(?) distribute the damage, (3) get around the fact that (lacking a certain OXP) NPCs lack shields. And 1 and 3 seem like nightmares. Perhaps I'd better just send frangible to false.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Problem with subentities

Post by UK_Eliter »

I've set frangibility to false - and still my turrets are getting blown off. This has got my goat now. Relevant shipdata code below.

Code: Select all

"ferdelance3-playerPlusModelWithTurrets" = {
		like_ship = "ferdelance3-playerPlusModel";
		frangible = no;
		energy_recharge_rate = 5.05;
		max_flight_speed = 504;
		model = "ferdelance3G+.dat";
		name = "Fer-de-Lance 3G+(t)";
		subentities = (
         		"3G-turret -17 -4.0 10.5 0.906141 0.180249 0.375336 0.0746615",
         		"3G-turret 17 -4.0 10.5 -0.906141 -0.180249 0.375336 0.0746615"
      		); 
		// Turret entity itself is defined below.
		thrust = 56; // One less than the normal 'Plus' model.
	};


	// TURRET ENTITY

	"3G-turret" =
	{
		accuracy = 4.4;
		ai_type = "nullAI.plist";
		energy_recharge_rate = 1;
		laser_color = "purpleColor";
		max_energy = 25;
		max_flight_pitch = 1;
		max_flight_yaw = 1;
		max_flight_roll = 1;
		model = "3G_turret.dat";
		name = "3G Turret";
		roles = "3G-turret ballturret";
		setup_actions = ("initialiseTurret");
		smooth = true;
		thrust = 1;
		weapon_energy = 12;
	};
Please help!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Problem with subentities

Post by Commander McLane »

Have you pressed and held the SHIFT-key while re-starting Oolite?
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Problem with subentities

Post by UK_Eliter »

McLane: I thought, for a while, that you were right and that I'd neglected to do that. But then, on exiting a superbulk hauler, I noticed that, AGAIN, I'd lost my turrets. . Argh!
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Problem with subentities

Post by Commander McLane »

Just an idea: at the time you set frangible to no, were the turrets there or shot off? If they were shot off at the time, it is possible that this is the problem. Shot-off subentities are stored in your save-game, therefore maybe the save-game is overriding the new setting.

What is the value of subentities_status in your save-file?

Also, just to be sure, I hope that you didn't use Notepad for editing the shipdata. That would give a fair chance that the file got screwed-up in the process.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Problem with subentities

Post by UK_Eliter »

Just an idea: at the time you set frangible to no, were the turrets there or shot off? If they were shot off at the time, it is possible that this is the problem. Shot-off subentities are stored in your save-game, therefore maybe the save-game is overriding the new setting.
I can't recall; but I have re-saved my ship, post disabling frangibility, when it had it turrets.
What is the value of subentities_status in your save-file?
It's here:

Code: Select all

<key>subentities_status</key>
    <string>00</string>
I've using 'Editpad pro'.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Problem with subentities

Post by Commander McLane »

UK_Eliter wrote:
It's here:

Code: Select all

<key>subentities_status</key>
    <string>00</string>
If I'm not completely wrong this means that your saved commander has two subentities, both of which are currently not on the ship. Try setting the value to <string>11</string> and restart your game. If I'm right the subentities should reappear (and stay!) from thereon.

In order to not screw anything up if I happen to be wrong I suggest you make a copy of your save-file before the edit.
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Problem with subentities

Post by UK_Eliter »

That change to the save file restored both turrets. But - I checked - they can still get shot off! (For I flew out of the station, attacked it, took lots of damage and lost a turret.) What's going on? :shock: Is there a mistake in the code I posted above?
User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 546
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: Problem with subentities

Post by Lone_Wolf »

By default any given object is already frangible, so the use of this line must be to negate that.
copied from frangible entry in shipdata.plist.

Try adding 'frangible = no' to the definition of the turrets.
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

Retired, reachable at [email protected]
UK_Eliter
---- E L I T E ----
---- E L I T E ----
Posts: 1246
Joined: Sat Sep 12, 2009 11:58 pm
Location: Essex (mainly industrial and occasionally anarchic)

Re: Problem with subentities

Post by UK_Eliter »

Mr Wolf

Preliminary testing seems to show that to work. I didn't think it was *supposed* to work, though. .

EDIT: secondary testing reveals that it does NOT work. Oh dear.
Last edited by UK_Eliter on Sat May 21, 2011 2:39 am, edited 1 time in total.
Post Reply