Page 1 of 1

Single-Use Witchdrive OXP

Posted: Thu Nov 19, 2015 2:09 pm
by ocz
Here's a little something for owners of ships without a Witchdrive. "Without a Witchdrive?", I sense you thinking, but yupp. There are means to get hold of such a vessel. With the help of [wiki]Illicit Unlock OXP[/wiki] for example or other OXP Ships. Gecko, Kraid and some others just don't have it. But they have a bit cargo space in most cases. For this few occasions, when you need it, I present the "Single-Use Witchdrive" to you.

As the name implies it can only be used one time before it kicks the bucket, but you can repair it at a suited station. It also takes up 2t of cargo space, which is also quite a lot on most of those ships. "Wait.", I sense you again, "What if the Thargoids pull me out of Witchspace in-between systems?" Well, then you are pretty scre*ed. The drive did its job and won't let you escape, but you can also buy a second set of spare coils, which can be use to make 2 jumps into Witchspace before you have to repair them(, at the price of credits naturally and another ton of cargo space.)

This little beast can't be fitted into a ship, that already has a Witchdrive (good ol' Cobra MK.III for example) and why would you want to? It's also quite hightech. You can only buy it at systems with at least Techlevel (TL) 10, but you can repair it in systems with TL 3 and sell it everywhere. (You can't buy it back there though, so be careful when selling it.) "Wait, what about systems with TL 1 or 2?" You again, huh? Guess what. Hitch-hike by using other wormholes, like you would do without it anyway. :D

And here's the link to the wiki:
[wiki]Single-Use Witchdrive[/wiki]

And the download link:
Singel-Use_Witchdrive-0.9.2.oxz

Licence:
This work is licensed under CC BY-NC-SA 4.0
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.

Re: Single-Use Witchdrive OXP

Posted: Thu Nov 19, 2015 2:34 pm
by Smivs
Congratulations on the release, and welcome to the Dark Side - have a cookie :)

Re: Single-Use Witchdrive OXP

Posted: Thu Nov 19, 2015 3:22 pm
by spara
Great news, ocz. Miners' Guild thanks you 8) .

Re: Single-Use Witchdrive OXP

Posted: Fri Nov 20, 2015 1:55 pm
by ocz
Thanks again. I like cookies. Everything for the miners guild.

I hope this OXP won't turn out be such a troublemaker like my other one. Its scripts should be simple enough to be compatible with nearly any thinkable OXP and to stay that way for a long time. If you still find something, please don't hesitate and post it.

Re: Single-Use Witchdrive OXP

Posted: Fri Nov 20, 2015 6:30 pm
by phkb
Although in normal circumstances you won't need a spare hyperdrive in a Cobbie Mk III, by using Capt Murphy's Breakable witchdrive (which I've replicated in "Ship Configuration") there might be times it could be handy to have a spare. Swap out the damaged item for the pristine one.

Re: Single-Use Witchdrive OXP

Posted: Fri Nov 20, 2015 7:10 pm
by ocz
I didn't consider Breakable 'Standard' Equipment OXPs - Breakable Witch Drive v1.3.1. I take a look into it.
Under normal circumstances you shouldn't be able to buy it for your Cobra. As it stands now, I have no means of checking, if the ship had or hadn't have got a drive before buying the SU-Witchdrive. Once it is aboard it has a Hyperspacemotor. Only the fact, that it's there makes it distinguishable. When it's removed or damaged the ship loses all Witchjump capability until the gamestate is saved and restored. (This restores it from shipdata.plist.) Is there a script method that allows to read data directly from plists? (player.ship.hasHyperspaceMotor flips its value, when the ship gains a Witchdrive.) Guess I have to use a missionVariable when it comes to it. :lol: Ahh, but then player.ship.hasHyperspaceMotor would still be false, when the drive is broken.

Edit: As I see it "Breakable 'Standard' Equipment OXPs" doesn't use player.ship.hyperspaceSpinTime to set a value, as this use of the method is too new. In this case it can't set a Hyperspaceable ship to player.ship.hasHyperspaceMotor === false. Therefore my OXP is spared, but my OXP sets player.ship.hasHyperspaceMotor === true for ships without a normal W-drive, which should lead to a automatic installation of the breakable W-drive without any function, when the SU-W-drive gets removed, even if the breakable W-drive is repaired.

An example: A Cobra Mk.III automaticly gains the breakable W-drive, when a savegame is loaded, but can't be outfitted with a SU-W-drive even when the breakable W-drive is broken. (Until a newer version comes out, which makes use of the player.ship.hyperspaceSpinTime to en-/disable the drive. Then all hell breaks loose.)
A second example: A Gecko won't gain the breakable W-drive, when a savegame is loaded, unless it gained a SU-W-Drive before saving. Then Breakable Witch Drive v1.3.1 will detect it with player.ship.hasHyperspaceMotor and "think" is would be a standard W-drive and install the breakable one onto the Gecko, which should not happen.

I'll check if my assumption are true will implement a workaround, that removes the br. W-drive from ships without normal W-drives after loading.

Re: Single-Use Witchdrive OXP

Posted: Fri Nov 20, 2015 7:34 pm
by Norby
ocz wrote:
Is there a script method that allows to read data directly from plists?
There is not a general way for all plists, just for shipdata.plist:

Ship.[url=http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Ship#shipDataForKey]shipDataForKey[/url]("cobra3-player")["hyperspace_motor"]

Note the capital "S" at start, this is a must due to it is a static method.

Re: Single-Use Witchdrive OXP

Posted: Fri Nov 20, 2015 7:51 pm
by ocz
Norby wrote:
ocz wrote:
Is there a script method that allows to read data directly from plists?
There is not a general way for all plists, just for shipdata.plist:

Ship.[url=http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Ship#shipDataForKey]shipDataForKey[/url]("cobra3-player")["hyperspace_motor"]

Note the capital "S" at start, this is a must due to it is a static method.
Ahhhhaaaa!!! That might become very handy. Thanks.



Edit:
Ohhh, this is rich. Both OXP missed each other just by pure luck. The breakable W-drive OXP checks in this.startUp if there is a hyperdrive and my OXP add it afterward in "this.startUpComplete".

Just relying on player.ship.hasHyperspaceMotor is too risky. I'll try to implement shipDataForKey.

Edit2: Both OXPs do clash at least at one point. The breakable W-drive gets buy-able when my SU-W-drive is fitted.
On the bright side, for everyone who found this thread and is interested in the data read-out out of the shipdata.plist. Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] will return a "yes" or "no" for the ship you're currently sitting in. Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] will return a "yes" or "no" for the ship you're currently sitting in, if there is the "hyperspace_motor" entry. Other keys instead of "hyperspace_motor" like "name" or "max_flight_pitch" are usable, too. (Just take a look into the shipdata.plist to see the different kinds of keys.)

Edit3: Not every ship that has been specified in the shipdata.plist has a "hyperspace_motor" entry! If it hasn't one the ship just gains one, but Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] === "yes" will still be false!!! If you want to replace "player.ship.hasHyperspaceMotor" please use "!(Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] === "no")". That does look oddly complicated, but just says, "If there is a "hyperspace_motor" entry, that isn't "no", or non at all, that ship has a drive and I return true."

Re: Single-Use Witchdrive OXP

Posted: Tue May 17, 2016 1:11 pm
by vsfc
Hi All,

Breakable Witchdrive oxp is updated to 1.3.2 version.

Where can I find code for Ship Configuration?

Cheers,

VSFC

Re: Single-Use Witchdrive OXP

Posted: Tue May 17, 2016 2:27 pm
by phkb
What needs to change in Ship Configuration? I've got a minor patch in the works so if a change is needed I'm happy to add it in.

(Incidentally, the links for the OXP/OXZ for Ship Configuration are in the first post of the Ship Config thread).

Re: Single-Use Witchdrive OXP

Posted: Tue May 17, 2016 11:46 pm
by vsfc
Phkb,

As you mentioned above in this thread that Breakable_Witch_Drive from Capt Murphy is replicated in Ship Configuration. Is the separate oxp for this drive is still relevant?
phkb wrote:
Although in normal circumstances you won't need a spare hyperdrive in a Cobbie Mk III, by using Capt Murphy's Breakable witchdrive (which I've replicated in "Ship Configuration") there might be times it could be handy to have a spare. Swap out the damaged item for the pristine one.
Thanks,
Vsfc

Re: Single-Use Witchdrive OXP

Posted: Wed May 18, 2016 2:04 am
by phkb
vsfc wrote:
Is the separate oxp for this drive is still relevant?
Absolutely. I don't think Ship Configuration will be to everyone's taste - some players will prefer to have a uber-ship with everything-including-the-kitchen-sink installed. So for those players having a separate OXP is still valuable. I've flagged Ship Config to be incompatible with the various "Breakable" OXP's that are impacted.

I've had a very brief look at the code changes you've made to the other OXP, but I'm not sure I understand the reason behind it. You've essentially changed "player.ship.hasHyperspaceMotor" with "Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"]". Is this because you want to distinguish between a witchspace drive that comes with the ship to one that is installed via the single-use drive, in order to restrict the damage control options to one or the other, so the Breakable witchdrive OXP doesn't break and/or repair the Single-use witchdrive?

Re: Single-Use Witchdrive OXP

Posted: Wed May 18, 2016 3:39 am
by vsfc
Looks like it is, the code change was done by ocz, he sent the code to me to make this oxp compatible with his single use witch drive. This will still need to be tested. Any suggestions please let me know.

Re: Single-Use Witchdrive OXP

Posted: Thu May 19, 2016 2:22 pm
by ocz
Sorry for the late answer. I'm kinda occupied.

Pffftooabbb..."Why" is what you are asking? That's 6 months ago. Frankly, all that is left in my mind of the reasoning behind "Why did I write the code, the way I did?" by now, is a faint blur of a memorysmear. :)

I remember, that there were compatibility issues. My Single-Use Witchdrive should only be installable onto ships without an own standardfitted witchdrive, such as a Krait or a Gecko. To check this I first used player.ship.hasHyperspaceMotor, but that didn't work well, as player.ship.hyperspaceSpinTime was able to flip that value. I needed a reliable way to check if a given ship has a drive fitted. !(Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] === "no" does a good job to determine, if one is installed per shipdata.plist.

As far As I remember vsfc's Breakable Whitchdrive, was written to break the Standarddrive (called Throudrive in the OXP). My S-U Witchdrive OXP was new and interfered with the way Breakable Whitchdrive worked. It made the Throudrive somehow purchasable for exsample. Another thing it messed up was, that SUWitchdrive set the hyperspace capability of a ship to true, which Breakable Whitchdrive would interpret as if a standard Throudrive is installed (which wasn't the case) as it only checked for player.ship.hasHyperspaceMotor being true (, if I recall correctly).

I believed I changed player.ship.hasHyperspaceMotor to Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"] for that later reason, so that my OXP and no other OXP messing with the hyperspace capability of a ship might break the Breakable Whitchdrive OXP again.
phkb wrote:
I've had a very brief look at the code changes you've made to the other OXP, but I'm not sure I understand the reason behind it. You've essentially changed "player.ship.hasHyperspaceMotor" with "Ship.shipDataForKey(player.ship.dataKey)["hyperspace_motor"]". Is this because you want to distinguish between a witchspace drive that comes with the ship to one that is installed via the single-use drive, in order to restrict the damage control options to one or the other, so the Breakable witchdrive OXP doesn't break and/or repair the Single-use witchdrive?
ÖÖhhh...Yah. Yah. Exactly. That sounds good. I go with that.

Re: Single-Use Witchdrive OXP

Posted: Thu Jul 22, 2021 1:57 pm
by Cholmondely
Typos in the Equipment plist:

Singel-Use Witchdrive & Repair: Singel-Use Witchdrive