Jump to content

[Plugin][WIP][0.23.5] Custom Asteroids 0.2.1


Starstrider42

Recommended Posts

Hello all,

I am pleased to present a pre-release version of Custom Asteroids. Custom Asteroids adds an asteroid belt and comets to the solar system, as well as letting you set up additional asteroid groups as you see fit. If you're not trying to add new groups, you don't need to configure anything: just install the mod, load a save game, and any newly spawned asteroids will follow the new rules.

Download -- includes config file with asteroid belt, near-Kerbin asteroids, Trojans, and comets

WARNING: Custom Asteroids 0.2 is a complete rework of 0.1. If you installed 0.1 previously, please delete that folder before installing the new version

Optional Trans-Jool Pack -- adds the Kuper Belt [sic], scattered disk, short-period comets, and centaurs. Not compatible with mods that add more giant planets beyond Jool, or with reported dev plans for adding more giants to stock KSP.

Custom Asteroids is available under the MIT license. Source code hosted by Github. Please report bugs on the issue tracker.

Customization instructions are included in the download. All orbital elements may be customized, as can the relative occurrence of asteroids in different groups. Objects may be placed in orbit around planets or moons, although this is not done in the stock configs.

13BiHCD.png

Credits

xEvilReeperx developed the method Custom Asteroids uses to place asteroids in specific orbits. I am eternally grateful for their help, as otherwise this mod would not exist.

Custom Asteroids was heavily inspired by Trueborn's Custom Biomes, and follows the same format of giving players a set of "stock" config files along with the tools to make more.

Known Issues

  • Currently, the inclination and eccentricity of an asteroid are drawn from a Rayleigh distribution by default. While this works well (with the added bonus of realism) for low-inclination, low-eccentricity populations like the asteroid belt, it creates too many extreme values when you ask for highly inclined or highly eccentric populations. Any suggestions for a better distribution would be much appreciated.

Planned features

  • Asteroids labeled by the group they belong to.
  • Different asteroid compositions, possibly offering different amounts of science. May be integrated with Kethane and other mining mods.
  • Control of the game's asteroid spawn rate, if possible.
  • Control of the size distribution in each asteroid population, if possible.
  • Possibly an asteroid discovery API that other mods can plug into?

I'm happy to take suggestions for more things to support.

Edited by Starstrider42
Posted 0.2.1 hotfix
Link to comment
Share on other sites

YES. YES! YES!!!!!

Now I just need to set up an asteroid storm near a spaceship, And I will be in business.

You realize that asteroid belts dont work like this in real life, dont you? :)

http://img2.wikia.nocookie.net/__cb20120921014106/starwars/images/d/de/GolmAsteroidBelt-DoaD.png

OP do you plan on some custom models or textures?

Link to comment
Share on other sites

Ah, I was wondering what an "asteroid storm" was.

Yes, the orbits can be placed around any planet or moon. A couple of people had asked for that feature in advance.

I'm not an artist, so I won't be making any textures myself. But I agree that they would enhance the mod quite a bit.

Link to comment
Share on other sites

Ah, I was wondering what an "asteroid storm" was.

Yes, the orbits can be placed around any planet or moon. A couple of people had asked for that feature in advance.

I'm not an artist, so I won't be making any textures myself. But I agree that they would enhance the mod quite a bit.

ok, but is that possible, are models and textures for asteroids hardcoded in game or one can manipulate it?

Link to comment
Share on other sites

AFAIK it's hardcoded, but it's probably still possible. The asteroid orbits in stock ARM are definitely hardcoded, but you can change them just by swapping them out on asteroid spawn. I'd bet the same trick would work for the model file, since an asteroid is basically a 1-part spacecraft.

Link to comment
Share on other sites

You realize that asteroid belts dont work like this in real life, dont you? :)

http://img2.wikia.nocookie.net/__cb20120921014106/starwars/images/d/de/GolmAsteroidBelt-DoaD.png

OP do you plan on some custom models or textures?

That looks closer to flying thru a planetary ring... and even then everything is way too close together.

Link to comment
Share on other sites

Good work, my save was full of asteroids (tracking a lot for search a capturable one) and I'm too lazy to untrack all sooo:


using UnityEngine;


namespace nomoreasteroids
{
[KSPAddon(KSPAddon.Startup.EveryScene, false)]
public class NoMoreAsteroids : MonoBehaviour
{
public void Start()
{
if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneHasPlanetarium)
{
GameEvents.onVesselCreate.Add(DestroyAsteroid);
}
}

public void DestroyAsteroid(Vessel vessel)
{
if (vessel.vesselType == VesselType.SpaceObject || vessel.vesselType == VesselType.Unknown)
{
//Debug.Log("NoMoreAsteroids is destroying: " + vessel.GetName());
vessel.orbitDriver.orbit = new Orbit(0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, FlightGlobals.Bodies[0]);
}
}
}
}

Then copy paste the 2 ones I have captured from the backup save and remove the plugin, :D

Salud.

Link to comment
Share on other sites

Good work, my save was full of asteroids (tracking a lot for search a capturable one) and I'm too lazy to untrack all sooo:

Then copy paste the 2 ones I have captured from the backup save and remove the plugin, :D

Salud.

Sorry, not completely clear on what you're trying to say, but onVesselCreate happens only when a new ship is created, not when it's loaded from the save file (I checked that VERY carefully, since CA would have had a major bug if it weren't the case). So the code you posted won't clean up your asteroids, it will just keep you from getting any more.

Link to comment
Share on other sites

Sorry, not completely clear on what you're trying to say, but onVesselCreate happens only when a new ship is created, not when it's loaded from the save file (I checked that VERY carefully, since CA would have had a major bug if it weren't the case). So the code you posted won't clean up your asteroids, it will just keep you from getting any more.

I can confirm the code I paste does the job, just double tested with a save with plenty of asteroids (tracked and untracked) as soon I put the plugin all asteroids disappears and no new ones created.

That's just after go to flight or tracking center:



(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. XCZ-841

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. BKT-092

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. AZF-293

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. TZW-626

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. GVH-039

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. CTA-090

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. QYJ-760

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. NWO-874

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

NoMoreAsteroids is destroying: Ast. NRU-101
.....
.....
Vessel Ast. HSJ-227 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. XCZ-841 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. BKT-092 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. AZF-293 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. TZW-626 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. GVH-039 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. CTA-090 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. QYJ-760 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. NWO-874 crashed through terrain on the Sun

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

Vessel Ast. NRU-101 crashed through terrain on the Sun
NoMoreAsteroids is destroying: Ast. HSJ-227

Salud.

Edited by agises
Link to comment
Share on other sites

I can confirm the code I paste does the job, just double tested with a save with plenty of asteroids (tracked and untracked) as soon I put the plugin all asteroids disappears and no new ones created.

Salud.

Aha, after some testing I've figured it out. The key difference is the call I have to onVesselCreate.Remove(). I assume that means that in my code the function isn't registered at the moment the save file is loaded, while in yours it is first registered some time before that.

I REALLY wish this stuff were documented... I got the right answer (for my needs) by sheer luck. :huh:

Link to comment
Share on other sites

If it were possible to create different categories of asteroid, a trans-NeptunianEeloonian object belt (worth more science) would be great, and perhaps even a few highly elliptical comets?

Link to comment
Share on other sites

This is great! I've been working on pretty much the same thing but you beat me to it (well, I barely started). It would be great if there were more customizable characteristics in the cfg, ideally every orbital characteristic with min and max values.

I quickly made a config for use with Real Solar System:


AsteroidSets
{
POPULATION
{
name = Main Belt
centralBody = Sun
spawnRate = 1
smaMin = 314155528470
smaMax = 493672973310
eccAvg = 0.18
incAvg = 7.5
}
POPULATION
{
name = Near-Earth
centralBody = Sun
spawnRate = 0.3
smaMin = 29919574140
smaMax = 747989353500
eccAvg = 0.5
incAvg = 7.5
}
POPULATION
{
name = Centaurs
centralBody = Sun
spawnRate = 0.1
smaMin = 29919574140
smaMax = 2991957414000
eccAvg = 0.5
incAvg = 7.5
}
POPULATION
{
name = Kuiper belt
centralBody = Sun
spawnRate = 0.05
smaMin = 4487936120000
smaMax = 7479893540000
eccAvg = 0.5
incAvg = 7.5
}
POPULATION
{
name = Kuiper belt core
centralBody = Sun
spawnRate = 0.1
smaMin = 5983914830000
smaMax = 6731904180000
eccAvg = 0.5
incAvg = 7.5
}
}

It is not very accurate because I assume a lot will change, so I didn't put too much effort into it, but it works for now. The main issue is that RSS uses inclined orbits for all planets to emulate Earth axial tilt. Seems like we'd need at least longitude of ascending node option in asteroids.cfg to accommodate for that. Also, tracking 70+ asteroids reduces my FPS from 60 to 7 but this is not relevant to the topic.

Javascript is disabled. View full album

When I was thinking how I would do this thing, I thought about having an asteroid detector, like a PartModule, essentially a telescope of some kind, that would be required to detect nearby asteroids, there could be telescopes of different power so one would have to send it to orbit to detect asteroids farther away from Kerbin and not just have them appear automatically. What do you think?

Link to comment
Share on other sites

When I was thinking how I would do this thing, I thought about having an asteroid detector, like a PartModule, essentially a telescope of some kind, that would be required to detect nearby asteroids, there could be telescopes of different power so one would have to send it to orbit to detect asteroids farther away from Kerbin and not just have them appear automatically. What do you think?

Link to comment
Share on other sites

If you can make it an experiment for the CactEye telescope, and I think it shouldn't be a problem, that would probably be best.

Well, if anyone will make it happen, probably won't be me, I see no point in re-doing what is already done so it is in Starstrider42's hands now.

Also I don't see it as a part of the current science system (which I really dislike, not that it is of any relevance).

Link to comment
Share on other sites

Hi, thanks for all your feedback!

If it were possible to create different categories of asteroid, a trans-NeptunianEeloonian object belt (worth more science) would be great, and perhaps even a few highly elliptical comets?

I'd like this too, but it's a little beyond what I know how to do at the moment. I've been discussing with some other people who've been working on asteroid mods, and they seem like they might be interested in supporting different asteroid types.

Cometary orbits will have to wait until I can handle high-eccentricity populations better (right now, you'd end up with half the spawned comets on unbound orbits, or else too far from the sun to make for interesting gameplay), but they're on my list.

However, I'm probably not going to have a trans-Joolian belt included in the main Custom Asteroids download, though if enough people want it I could make it an optional download. Rumor has it that the devs are planning to add two more planets beyond Jool, which will change that part of the solar system quite a bit. So I'd rather not mess with it now.

It is not very accurate because I assume a lot will change, so I didn't put too much effort into it, but it works for now. The main issue is that RSS uses inclined orbits for all planets to emulate Earth axial tilt. Seems like we'd need at least longitude of ascending node option in asteroids.cfg to accommodate for that.

Ouch. I didn't know RSS handled it like that. You might want to talk to NathanKell. I know he's expressed some interest in adding asteroids to RSS, so he might be happy that you've already been experimenting with settings.

I'm planning to add support for all six orbital elements soon, probably in the next version.

When I was thinking how I would do this thing, I thought about having an asteroid detector, like a PartModule, essentially a telescope of some kind, that would be required to detect nearby asteroids, there could be telescopes of different power so one would have to send it to orbit to detect asteroids farther away from Kerbin and not just have them appear automatically. What do you think?

Something like that seems out of the scope of the mod, at least at the moment -- I kind of like having a parts-free plugin, and I don't even know if it's possible to change the spawning system enough to do what you describe. But I'll keep the possibility in mind.

Edited by Starstrider42
Link to comment
Share on other sites

A question for the solar system modders out there: I've been thinking about what kind of config format I'd need to actually support all my planned features, and I wanted to run it by you first.

Do you think you'd be able to work with something that looks like this? Or is it too clunky? Too confusing?

POPULATION
{
name = Near-Kerbin
centralBody = Sun
spawnRate = 0.3
sizeType = Apoapsis
size
{
dist = LogUniform
min = 10000000000
max = 43324628162
}
ecc
{
dist = Beta
min = 0
max = 1
avg = 0.7
}
inc
{
dist = Rayleigh
avg = 7.5
}
...
}

(Also, if anybody knows how to get rid of those annoying empty lines at the end of every code block, I'd love to know.)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...