[Updated Release] Turret Toggler 1.1

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

Moderators: another_commander, winston

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

Re: [Updated Release] Turret Toggler 1.1

Post by UK_Eliter »

Hmm. I'll investigate.

User avatar
Commander McLane
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: [Test Release] Universal Turret Switcher

Post by Commander McLane »

UK_Eliter wrote:Thanks for the reply. But I think I have

Code: Select all

frangible = no;
in the relevant parts of my shipdata already
Actually, there is only one relevant part in your shipdata (no plural): in the shipdata entry of your ship (player variant, main entity). It does not belong in the subentities' entries. This may be your problem.

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

Re: [Test Release] Universal Turret Switcher

Post by UK_Eliter »

Commander McLane wrote: Actually, there is only one relevant part in your shipdata (no plural): in the shipdata entry of your ship (player variant, main entity). It does not belong in the subentities' entries. This may be your problem.
Thanks McLane, but my definitions of subentities - the turrets - contain no mention of frangibility. Rather the mentions of frangibility are within some (not all) of the ship definitions. Perhaps I misunderstand . .

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: [Test Release] Universal Turret Switcher

Post by Diziet Sma »

UK_Eliter wrote:
Commander McLane wrote: Actually, there is only one relevant part in your shipdata (no plural): in the shipdata entry of your ship (player variant, main entity). It does not belong in the subentities' entries. This may be your problem.
Thanks McLane, but my definitions of subentities - the turrets - contain no mention of frangibility. Rather the mentions of frangibility are within some (not all) of the ship definitions. Perhaps I misunderstand . .
Poking around in the Ferdy3G shipdata.plist, I found something strange.

So far as I can tell, you have four player variants that are supposed to have turrets. However, two of them are like_shipped to templates that have no subentity arrays declared even though those variants do reference your ferdelance3_hackForTurrets.js script.

Code: Select all

	"ferdelance3-playerVariant" =
	{
		like_ship = "ferdelance3GVariantTemplate"; ****Has no subentities declared****
		script = "ferdelance3_hackForTurrets.js";


	"ferdelance3-playerPlusModel" =
	{
		like_ship = "ferdelance3G+Template"; ****Has no subentities declared****
		script = "ferdelance3_hackForTurrets.js";


	"ferdelance3-playerPlusModelWithTurrets" =
	{
		like_ship = "ferdelance3G+(t)Template"; ****Has subentities declared****
		script = "ferdelance3_hackForTurrets.js";


	"ferdelance3-playerPlusModelWithTurretsPoliceDecomissioned" =
	{
		like_ship = "ferdelance3PoliceDecomissionedTemplate"; ****Has subentities declared****
		script = "ferdelance3_hackForTurrets.js";
I'm wondering if this might be the cause of your woes? As in, the reason you have to keep hammering the turrets onto those two ships is because you forgot to declare them in the first place? If they're not supposed to have turrets, then why are they invoking ferdelance3_hackForTurrets.js at all?
Solonar wrote:When using your Fer de Lance 3G+(t) for my prototype, and then later with a Dark Rainbow and a Takinia CX-1, I had to insert a frangible false line into their ship data plist. When I was using the Fer de Lance 3G+(t), I made it frangible false and removed your turret hack script entirely with no problems and the script no longer served a purpose..
Is it, perhaps, worth getting a copy of Solonar's mod of the Fer de Lance 3G+(t) and, after testing it to make sure it works correctly on your machine, compare it with the code in your own version?
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

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

Re: [Test Release] Universal Turret Switcher

Post by UK_Eliter »

Diziet Sma wrote:
I'm wondering if this might be the cause of your woes? As in, the reason you have to keep hammering the turrets onto those two ships is because you forgot to declare them in the first place? If they're not supposed to have turrets, then why are they invoking ferdelance3_hackForTurrets.js at all?
Indeed: they shouldn't invoke that script at all. Well spotted. I've fixed that (and make some considerable improvements to the script itself).

Still, in the OXP as it stood those ships were not, I think, ending up with turrets; and the ships that really were (fully) meant to have turrets (and which did actually get them) were sometimes losing them.

So I don't think we have identified the cause of the (main) problem. But, as I say: thanks. (Disassociating the script from the ships that should not have it will disburden the computers of those flying those ships.)

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: [Updated Release] Turret Toggler 1.1

Post by Diziet Sma »

You're most welcome.

Heheheh.. I was adding to my post as you were replying, so I'll repeat the addition in case you missed it.
Solonar wrote:When using your Fer de Lance 3G+(t) for my prototype, and then later with a Dark Rainbow and a Takinia CX-1, I had to insert a frangible false line into their ship data plist. When I was using the Fer de Lance 3G+(t), I made it frangible false and removed your turret hack script entirely with no problems and the script no longer served a purpose..
Is it, perhaps, worth getting a copy of Solonar's mod of the Fer de Lance 3G+(t) and, after testing it to make sure it works correctly on your machine, compare it with the code in your own version?
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 545
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: [Updated Release] Turret Toggler 1.1

Post by Lone_Wolf »

I've been getting the same friendly fire problems that triggered the making of this oxp.

Although my current ship ( FDL 3G+(t) ) only has turrets as subentities, it feels wrong that TT removes all subentities.

Wiki doesn't have much detail about subentities structures, so i used Object.keys(PS.subEntities[0]) in the debug console to investigate.
I then realised turrets are instances of a ship object, and have all properties/methods of a ship .

This means player.ship.subEntities[x].isTurret can be used to check if a subentity is a turret.

I also don't really like the restoring of subentities on docking / removal at launch, will check if that's still needed.
Is solanar still around ?

P.S.
Object.keys(y) gives a lot of data, but is very useful.
I'll probably try to put into it a macro to improve readability and separate properties and methods.
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

I am subscribed to the threads for my oxps, if you need my attention just post in them or send a pm.

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: [Updated Release] Turret Toggler 1.1

Post by Diziet Sma »

Lone_Wolf wrote:Is solanar still around ?
He last logged in here exactly 11 months ago today.. you could try PMing him.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 545
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: [Updated Release] Turret Toggler 1.1

Post by Lone_Wolf »

Pm'ed solanar on august 20, sofar no response.

I didn't like the restoring upon docking / removing on launch if turrets were deactivated, but found no way to avoid that without getting uneccessary maintenance overhauls in F3 screen.
This means oxps that check for turrets while docked (feudal states does) , will see your ship as having turrets even though you have deactivated them.
Given that you can re-enable turrets at any time in-flight, i think this is correct behaviour.

For those interested, i uploaded TT 1.2 here : https://app.box.com/s/cwr4cxthk7de0byrpdlqqtvv61ivc58w

Changes in version 1.2
no longer removes all subentities, only turrets.
cleanup/restructuring of code, including renaming of scripts, variables and functions
It didn't seem logical to me to have a ship being stuck with deactivated turrets if TT got damaged, so device is now invulnerable.
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

I am subscribed to the threads for my oxps, if you need my attention just post in them or send a pm.

Anonymissimus
---- E L I T E ----
---- E L I T E ----
Posts: 299
Joined: Mon Apr 27, 2015 9:03 pm

Re: [Updated Release] Turret Toggler 1.1

Post by Anonymissimus »

restoreSubEntities() and subEntities.remove() modify the ship's service level when called, the first sets it to full, the second reduces it somewhat. It freed me from needing maintenance overhauls. I fixed it for now by getting and restoring player.ship.serviceLevel at the 4 places where they are called. The restoring/redisabling when docking may no longer be needed then, but other addons may need it maybe ?!
warning sound if a missile is inbound: Missile warning

User avatar
Lone_Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 545
Joined: Wed Aug 08, 2007 10:59 pm
Location: Netherlands

Re: [Updated Release] Turret Toggler 1.1

Post by Lone_Wolf »

Looked up subentites in wiki, and while it doesn't give much info what restore does, subentities appear to be ship objects, so have all properties of a ship.
for player ship that includes serviceLevel .
Your findings suggest that removing/readding turets changes parent serviceLevel, and that triggers the maintenance overhaul.
Could me send me a diff with your changes so i can test them out and check if there other consequences ?

I do know one other way to disable turrets : change an entry in savegame.
Might try to figure out what that does exactly in core code, and replicate that as it seems like a cleaner method.
OS : Arch Linux 64-bit - rolling release

OXPs : My user page

I am subscribed to the threads for my oxps, if you need my attention just post in them or send a pm.

Anonymissimus
---- E L I T E ----
---- E L I T E ----
Posts: 299
Joined: Mon Apr 27, 2015 9:03 pm

Re: [Updated Release] Turret Toggler 1.1

Post by Anonymissimus »

Also added audible messages.
Note that you should create a private function for that do-and-redo and not just apply this patch.

Code: Select all

---
 Scripts/tt_worldscript_events.js | 9 ++++++++-
 Scripts/turret_toggler.js        | 6 ++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Scripts/tt_worldscript_events.js b/Scripts/tt_worldscript_events.js
index e3e4ad9..85b6635 100644
--- a/Scripts/tt_worldscript_events.js
+++ b/Scripts/tt_worldscript_events.js
@@ -26,7 +26,9 @@ this.shipWillDockWithStation = function(station)
     if ( worldScripts["Turret Toggler"]._tt_turret_status == "inactive" )
       {
         // if the turrets are not on the ship on docking, a maintenance overhaul is offered to restore them!
+        var service_level = player.ship.serviceLevel
         player.ship.restoreSubEntities(); 
+        player.ship.serviceLevel = service_level
       };
   };
 	
@@ -39,7 +41,12 @@ this.playerBoughtEquipment = function(equipmentKey)
           missionVariables.uni_turret = "active";
           break;
         case "EQ_UNI_TURRET_REMOVAL":
-          if ( worldScripts["Turret Toggler"]._tt_turret_status == "inactive" ) { player.ship.restoreSubEntities(); };
+          if ( worldScripts["Turret Toggler"]._tt_turret_status == "inactive" )
+          {
+              var service_level = player.ship.serviceLevel
+              player.ship.restoreSubEntities();
+              player.ship.serviceLevel = service_level
+          };
           player.ship.removeEquipment("EQ_UNI_TURRET");
           player.ship.removeEquipment("EQ_UNI_TURRET_REMOVAL");
           player.credits += 1500;
diff --git a/Scripts/turret_toggler.js b/Scripts/turret_toggler.js
index 438082f..34cda2e 100644
--- a/Scripts/turret_toggler.js
+++ b/Scripts/turret_toggler.js
@@ -21,18 +21,24 @@ this._tt_toggle_turret_status = function(set)
     switch (set)
       {
         case "active":
+          var service_level = player.ship.serviceLevel
           player.ship.restoreSubEntities();
+          player.commsMessage("Turrets online!",6);
+          player.ship.serviceLevel = service_level
           // refresh ship target , this should make sure turrets get current target
           var current_target = player.ship.target
           player.ship.target = null;
           player.ship.target = current_target;
           break;
         case "inactive":
+          player.commsMessage("Turrets disabled.",6);
+          var service_level = player.ship.serviceLevel
           var subCounter = 0;
           for ( subCounter = player.ship.subEntities.length - 1;subCounter>=0;subCounter-- )
             { 
               if ( player.ship.subEntities[subCounter].isTurret ) { player.ship.subEntities[subCounter].remove(); };
             };
+          player.ship.serviceLevel = service_level
           break;
         default:
           break;
warning sound if a missile is inbound: Missile warning

Post Reply