Jump to content

Question about explosions ( I swear, it's not about weapons)


Neomatt

Recommended Posts

Hi,

I've just started making a small plug-in/part to remove space debris (basically, a TNT bomb, Wile E. Coyote/ACME style, which triggers 5 seconds after being decoupled).

My issue is not making the part (it's mostly done, except some CFG issues, but I can deal with that later), it's "how to explode the discarded stage with the bomb on it".

If I just explode the pack, nothing explodes around it.

If I decide to explode the pack and its parent, only those two are exploding (and projecting fuel tanks upward. Fun, but not what I expected).

I finally tried what would have been the "best way": explode each and every part of the discarded stage (I used some sort of parent/children algorithm to get them all).

It works fine for 2 tanks, an engine and a decoupler, buuuuuuut KSP crashes if I use it on my 36-tanks, 9-engines, 48-struts stage (since then, I removed the struts from the list; still crashes though) . :)

It also creates deadlocks and the likes, and that's just a dirty, wrong way to make it happen.

Now that I've thought a bit more about it, I'd think the best way to do this would be some sort of "now let's blow this thing and go home": a big, huge explosion, and other parts destroyed without exploding (this way, KSP just removes them and doesn't search to make a "fractal" explosion).

So here are my questions:

- is there a "good" way to explode a vessel completely? I think most of the issues are due to the "sum" of explosions I make by blowing each part.

- is it preferable to do a "massive" explosion and part.onPartDestroy() than just part.explode()?

- in the case it's preferable, what is a good "max" value for explosionPotential (not crashing, not lagging, still scares Jeb even if he's 2km away), and can it be set dynamically to a part via the API? (I made an "explosion.dll" already, so it's more of a "how can I set this")

It would be best for it to go from something like 0.5 for a TNT pack alone to <maxValue> if you have more than 5 or 6 explosive parts.

Anyway, if you have any ideas, please let me know.

Link to comment
Share on other sites

Okay, a bit more trial-and-error yesterday, and here's what I got:

- I can retrieve/set the explosionPotential of a part by... calling part.explosionPotential. Dunno why I was expecting something else. :) I also saw some other variables like blastForce and the like; any idea what those are? (smells like moar testing)

- destroying parts instead of exploding them is HARD. After many fails, I decided to set a part explosionPotential to 0 and explode it. However, that brings back the "old" issue if the explosion is too complex, with deadlocks and the like.

- I tried to use Vessel.destroy(vessel), but it was a lost cause, didn't work. Shame, it would have been perfect.

Also, this is more linked to my code, but if I think deadlocks are caused by the fact there is more than one TNT pack on a vessel (one is enough, but I know people will put 10 or 20 :) ) and they're trying to delete the same part at the same time.

I may have to rethink how the destruction occurs (shared static list between TNT packs? One "master" pack that destroys the vessel, while the others just explode?)

edit: well, it's done now.

What I did:

- Vessel.Die() kills the whole vessel without any fuss. It's perfect for my needs.

- before that, each pack knows the "main" pack (first one in vessel.parts). The others are destroyed with the vessel, but their explosionPotential is added to the main one; this way, only one big explosion, much less (or no) deadlocks, and the vessel is destroyed.

- the maxValue is set at 100, but since I didn't see a difference with 10, it's not very useful. Maybe I'll remove it.

Edited by Neomatt
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...