Jump to content

[1.3.1] Cloaking Device (v0.11a Oct 14, 2017)


wasml

Recommended Posts

This mod has been rolled into DoctorDavinci's DCK FutureTech mod and made to work with BDA (see active camouflage) . There are no plans to update this further.

 

 

GZsaWNo.png

While working on another mod I ran across a method named SetOpacity. I couldn't resist - I had to see if I could make this work. It does! well ... sort of. Vessels are partially visible against the near field while transitioning but are invisible (at zero opacity). In the above image opacity was about 0.4 (0:invisible to 1:normal visibility).

Instructions:

  1. Download the appropriate version 0.11a for KSP 1.3.1
  2. Add the “Surface mounted cloaking device" under the Utility tab to your vessel. (Brown slug thing between the solar panels in the image above) from the Utility tab
  3. Fade time and maximum fade can be set in the editor or in flight
  4. In flight toggle the Cloak on/off with the right click menu.
  5. The cloak part its self can be set to leave its self uncloaked - or not.


Notes:

  1. This doesn't hide your craft from BDA radars.
  2. Part model is rather primitive.
  3. Some oddities with visibility and the near field (area close to the craft)
  4. If you set the cloak device to cloak its self make sure to set the “Cloak Off" to an action group other wise you may not be able to find the part to right click again.
  5. I haven't balanced this - it should probably use a lot more electricity. Can be easily changed by editing the config file


Known Problems:

  1. If a craft is cloaked and a piece breaks off it may remain cloaked - solar panels and fairings in particular. Exiting the scene and returning will uncloak the broken piece(s).
  2. Engine shrouds and strut/fuel line end caps don't fade in/out and only disappear at full cloak.
  3. Shadows don't fade in/out and only disappear at full cloak.
  4. If the self cloak is turned off while cloaked it gets confused as to it's state (cloaked/not cloaked). Same problem with particles.
  5. Multiple cloaking devices on the same craft gives odd results. No plans to fix this at this point.
  6. The cloak device its self doesn't fade out - just disappears at full cloak.


Change Log:

Spoiler

0.11a

    1. Fixed file structure and added source to download

0.11

    1. Recompiled for 1.3.1

0.10

    1. Updated and recompiled for 1.3.0
Note: hasn't had much testing - best to try on a temp game first

0.09 9/17/17

    1. Updated and recompiled for 1.2.2
Note: hasn't had much testing - best to try on a temp game first

0.08 6/25/16

    1. Recompiled for 1.1.3
    2. Added "hideParticleEffects" to hide engine exhaust as suggested by Mycroft. defaults to false, add "hideParticleEffects = true" in ModuleCloak to enable (in config file).
    3. Found and added renderer so Grappler will now fully cloak.

0.07 5/7/2016

  1.  Updated for 1.1.2
  2. Changed Low on EC behavior - now will try to do what it can with what it has - results in flickering in and out.

0.06 1/10/16

  1.  Everything now disappears at full cloak.

0.05 11/22/15

  1. Disables renderers at full cloak. This will cloak engine shrouds (but no fade in/out) and (at full cloak) fixes the near field oddities and visible shine off parts such as solar panels.

0.04 11/1/15

  1. Removed shadows on all but engine shrouds.
  2. Added a parameter to the config file and debug right click menu for shadow cut in/out.

0.03 10/25/15

  1. Partially fixed the issue with parts not uncloaking when removed from a vessel.
  2. The energy use calculation now uses surface area instead of mass.
  3. Added an exponent into the calculation for energy use (E = Surf * ECPerSec ^ Exponent). Defaults to 1.0
  4. Added some cfg settings to optionally display and tweak cfg parameters in the right click menu. These are off by default.
  5. Changed the license - dropped the NC so now is CC BY-SA.

0.02 10/18/15

  1. Corrected a cfg file error causing the part not to show up in the editor.

0.01 10/18/15

  1. Initial release.

 


Config file:

 

Spoiler

 


Spoiler

 

 


Type Name = default
bool sandboxMode = false // Show some tweakable parameters in the right click menu
bool debugMode = false // Show even more parameters in the right click menu
float areaExponet = 1.0f // Energy use = (Craft surface area) * ECPerSec ^ areaExponet (where ^ is "to the power of")
float ECPerSec = 4.0f // Electric charge per second
float fadeTime = 5.0f // In seconds
float maxfade = 0.0f // invisible:0 to uncloaked:1
bool selfCloak = true // Will the cloaking part cloak itself
float shadowCutoff = 0.2f // cloak level at which the shadows disappear

bool hideParticleEffects = false // hides exhaust/flames/smoke when fully cloaked

 

 


Download link http://spacedock.info/mod/217/Cloaking%20Device

License CC BY-SA 4.0

Edited by wasml
Link to DCK FutureTech
Link to comment
Share on other sites

Just uploaded a correction - the config for the part had the wrong path for the mesh so the part didn't show up in the editor - corrected. v0.02 should work.

@TrainEngie - it should work with BD Armory - it doesn't care what the parts are (famous last words).

Link to comment
Share on other sites

This is the best mod ever. Why hasn't this existed until now?? The best part is the fact you remembered to remind us the AG the cloak itself when it also is cloaked. XD

If you want help, I'm not all that good with modding itself, but coding I may be able to help (to a small extent). Or at least manage the forum aspect of the mod.

Link to comment
Share on other sites

I was literally working on what I was going to say about adding AG functionality... then I got to the part where you mention setting an action group. My work is done. This does actually have some amazing possibilities. I'm so looking forward to looking at how you implemented this thing.

Link to comment
Share on other sites

3) If you set the cloak device to cloak its self make sure to set the “Cloak Off†to an action group other wise you may not be able to find the part to right click again.

cBzAQ5R.jpg

:D :D :D

Part Commander is a menu-style way to "click" on parts and would be useful in this situation.

Anyways, this is awesome! The cinematic/roleplay use is obvious, but also imagine this in a multiplayer BDarmory session :)

Link to comment
Share on other sites

I say let's develop a special Star Trek version, canon suggests it really uses a lot from the warp&fusion reactor and capacitors. Ideal would be: the bigger the ship, the more energy is needed. Since size is probably difficult to calculate or measure, it could use total mass.

If you look at a classic title like Klingon Academy (the best Star Trek sim ever), energy management was the governing factor over maneuvering, shield control, propulsion, damage control, sensors/ECM/cloak and weapon systems. If you were cloaked, max speed was limited to half or quarter impulse or your energy banks would run out of juice and you'd decloak as a sitting duck without propulsion, shields and weapons.

Link to comment
Share on other sites

AG function included - This was added just after the first time I took it to full invisibility, checked the ship from a number of angles, then realized I had lost the right click menu....

@ZooNamedGames: Thanks for the offer of help. This is my first mod release so I have no experience with remote trouble shooting - I may need help in that area. This was actually a side excursion from some other code I was writing, and while I do have a few more ideas, I wasn't planning on taking this too much further. That said I believe the license I picked (CC BY-NC-SA) allows you to make a copy and take it in any(with a few restrictions) direction you want (more choices for users is a good thing!). I would ask that any forks have a distinct name so as not to cause confusion.

@Gaalidas: The code is fairly short and almost all of it is for the user interaction and fade in/out. Only three or four lines to cycle through the parts and set the opacity.

@Azimech: One of the (few) things that I'm considering adding is factoring ship mass into EC used. I think it should be simple - just, as you said, get the total mass. One thing I don't want to do is make this calculation heavy - but on second thought Unity needs to track mass anyway so the GetTotalMass method shouldn't be re-scanning the entire ship when called. Hmm - no promises but I think I'll give this a shot - Guessing it may be this weekend before I can get around to it.

@LitaAlto: Function already included! In fact you can change with the right click menu from instantaneous up to 30 seconds (Seems like forever in game).

Thanks all for the support!

Edit:

One thing I haven't done is balance this - it started as a experiment with an EC requirement of 1 just to try drawing a resource. Also the reason why max fade and fade time are in the right click menu and cost and tech are left over from what ever cfg file I modified for this part. To use in play I'm thinking EC use, Fade limit and fade time should be set in the cfg file but I'm not sure what would be reasonable values. My only thought is to set to play through values and provide a MM file for those that just want to play with it - thoughts?

Edited by wasml
Link to comment
Share on other sites

You could also not let it consume EC but let it use some kind of exotic photon bending power that you use to generate with a special generator and special tanks

Or you could let it use a single piece of resource once you activate it and let it have a couple of this resource on board so that it has a limited amount of uses

Edited by 129828
Link to comment
Share on other sites

@CliftonM: I'll add it to the improvements list but no promises. If it does happen it will be after 1.1. I hear the current GUI API is less than easy to use and 1.1 will make significant improvements (as well as rendering all existing GUI code non-functional)

@129828: I agree if your going to use this with something like BDA it would give you a huge advantage and it should have a significant drawback/limitation to use. (OK after re-reading what I just wrote I'm thinking the most likely use will be with BDA). That said I might be able to add a cfg file parameter to set the resource used but someone else would need to make the resource/tanks/generators.

@Atatra: I don't know how BDA radar works so it may be possible but I have no idea how. You wouldn't by chance know how BDA radar works would you?

Azimech got me thinking and I've added some cfg file settings to vary EC useage with mass. If I can get some testing done this week I'll try to post the update this weekend. Lesson learned #1 – I should have probably started in the Dev thread until some of the wrinkles were ironed out. Having released it I don't want to break anyone’s saves with an update.

Link to comment
Share on other sites

My best suggestion for testing purposes would be to add a context menu slider to allow in-flight modification of EC-use and fade times, then play around with things until it makes sense. i'd also recommend trying to not only vary these things by part mass, but possibly by the number of parts being affected on the vessel as well.

Breaking saves is highly unlikely unless you remove the part completely and/or reset the internal name of the part itself. changing the part shouldn't cause too much trouble, though it could affect people if they have the same saved with the cloak currently active.

As for GUI, I'm unsure if 1.1 will bring anything easier to use overall, but I hear the designer in Unity is nice. I managed a pretty good GUI for Kerbal Foundries, but it's taken months to get to the point where I can easily add new elements and make them function. Even then, I couldn't properly handle persistent data through that GUI until an individual I know only as *Aqua* created a persistence class for us to use, which I query for most of the global settings for the KF modules. Either way, you need to be prepared for the huge pile of bovine excrement you're diving into when creating a GUI. It's one big pile of... poo.

I do have to wonder if the simple little parameter that makes all this stuff possible could maybe be the origin of what we have not for fairings and service modules and such: the ability to hover over them and get a transparent shell out of what was once an opaque surface.

Link to comment
Share on other sites

It would be really awsome if we could use it to make our ship radar invisible.

you could look at the anti-radar-flares and maybe try to combine them, I dont really know how that works,

you should ask the moderator of BDA for help on the subject

Link to comment
Share on other sites

@Atatra: I don't know how BDA radar works so it may be possible but I have no idea how. You wouldn't by chance know how BDA radar works would you?

MODULE
{
name = ModuleECMJammer
jammerStrength = 1200
}

This is the BDA radar jamming module. Could just put this in the config. EDIT: Maybe add a zero to the jammer strength?

Edited by FungusForge
Link to comment
Share on other sites

I was thinking, do you know what causes the fact that when you look from the top, you see weird things.

on another subject, could je adjust the plugin/part to change the color of the ship?

I would love a black blackbird

Link to comment
Share on other sites

I’d also recommend trying to not only vary these things by part mass, but possibly by the number of parts being affected on the vessel as well.

I think you're right – just tried to cloak a rocket and the mass of the fuel drove the EC usage through the ceiling. I'll look around and see if I can find something else – maybe dry mass if nothing else(if it's available).

Breaking saves – I am considering setting tech node to experimental science and upping the price (this would have to be a complex piece of equipment). I haven't played career enough to know if these would mess someones game up if they already had it installed on some craft.

As for GUI ….

Not what I wanted to hear! I've looked at some other peoples GUI source and turned and ran (not due their code but from trying to figure out how it worked). Oh well – still think I'll wait until 1.1 before making any attempt to tackle this again.

I do have to wonder if the simple little parameter ….

I hadn't though of that but you may have something there.

It would be really awsome if we could use it to make our ship radar invisible.

I'll look at the ModuleECMJammer FungusForge mentioned and see if I can come up with something.

do you know what causes the fact that when you look from the top, you see weird things.

I saw it explained once that the view we see is really two views of the same scene stitched together. One is the immediately surrounding area and the other is the far view. My guess is that we see the weird things when we view the cloaked craft against the immediate surroundings and we don't see the cloaked craft against the far scenery. And of course we see shadows all the time! I found a batch of methods with "Shadow" in them and was hoping to be able to correct this but it didn't pan out.;.;

could je adjust the plugin/part to change the color of the ship?

The core of this mod is a method call called “SetOpacityâ€Â. It only sets the transparency. To change colors I'm thinking I would need to change textures on the fly – beyond me at the moment.

Link to comment
Share on other sites

BahamutoD's videos imply that the radar works by rasterizing the target in hi-contrast black and white and retrieving the radar cross section from it that way. As to how that would be impacted by opacity, well, honestly, I have no idea. I'll download this tommorow onto my BDA install and report back. Also, re: color: Check out KerbPaint. It has the exact functionality you desire.

Link to comment
Share on other sites

If you would allow me, I had a suggestion to use this mod in my BD pack, nothing huge, just a new module on your part and I'd give it my own 3d model. Alternatively, if you'd like, I can give you a 3d model and I can just edit the cfg for my mod.

of course, the cloaking device I add will be different in a few ways.

Link to comment
Share on other sites

Feel free to use the module itself or the code from the module (included in the download). If you use the module as is be aware it's way unbalanced and I still have a few bugs to work out. I hope to have an update out this weekend that will fix a problem with parts that come off (intentionally or not) remaining cloaked. I've also changed the EC usage to query a surfaceArea call instead of the vessel mass.

You say “a new module on my partâ€Â. If you mean adding features or taking this in another direction I'm open to suggestions but won't promise to implement anything. I'm new to modding and still trying to find my way around the API – as such I don't want to commit to anything too ambitious.

Link to comment
Share on other sites

0.03 Update posted.

Partially fixed removed part decloak problem - decoupling and undocking look like they're working. Part breaking off and exploding - sometimes. Not sure how to fix this at the moment.

A few other minor changes - see change log on OP.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...