Coder Social home page Coder Social logo

starstrider42 / custom-asteroids Goto Github PK

View Code? Open in Web Editor NEW
13.0 7.0 10.0 1.59 MB

A KSP mod that lets users control where asteroids appear

Home Page: http://starstrider42.github.io/Custom-Asteroids/

License: MIT License

C# 100.00%
ksp asteroids mod plugin game kerbal-space-program custom-asteroids

custom-asteroids's People

Contributors

dmagic1 avatar starstrider42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

custom-asteroids's Issues

Insufficiently Random Numbers

When starting a new game with the default asteroid configuration, the first asteroid is always named HSJ-227, and is always placed into the following orbit:

ORBIT
{
    SMA = 30538612101.3155
    ECC = 0.136886541924265
    INC = 6.05229021995948
    LPE = 146.525451660156
    LAN = 156.887023925781
    MNA = 278.716278076172
    EPH = 0.04
    REF = 0
}

I believe this is a problem with KSP's stock random number generator, so it may not be worth the trouble of working around.

Update May 10: the issue has now spread to standardizing the first two asteroids that are spawned.

Duna.psol gives error

Background Info

  • Operating System: Windows 10 64-bit
  • KSP Version: 1.6.1
  • Custom Asteroids Version: post-1.6.0 developer build

Issue Description

The following config block:

INTERCEPT
{
	name = groupB
	title = Paired <<1>>

	spawnRate = 1.0

	targetBody = Duna

	approach
	{
		type = ImpactParameter
		max = Ratio(Duna.soi, 0.5)
	}

	warnTime
	{
		dist = Uniform
		min = Ratio(Duna.psol,  50)
		max = Ratio(Duna.psol, 220)
	}
}

will not load in Custom Asteroids, giving the following error:

Celestial body 'Duna' does not have a solar day.

The culprit is the CelestialBody.solarRotationPeriod property, which I assumed indicates that a celestial body has a well-defined solar day (i.e., is not the Sun or a tidally locked planet) but, in the stock game, is set only for Kerbin. Fix the code so that psol returns the correct solar day for both non-Kerbin planets and moons.

Asteroid discovery API

For players who want to change the rules, I might provide an API to let them decide when (and where?) new asteroids appear.

Prerequisite: issue #5 solved.

Relevant mods: CactEye, Asteroid Day

Custom Asteroids not compatible with Custom Barn Kit

Custom Asteroids never creates asteroids when Custom Barn Kit is installed. The root cause appears to be the absence of GameVariables.Instance. Presumably CBK deletes it and replaces it with something else...

Size distributions

Really an extension of #4, this would allow some asteroid groups to have bigger asteroids than others

Needs recompile

Needs to be recompiled against 1.0.5 - I really want to use this mod again!!!

Allow OrbitPhase to be specified as a radius/time

Currently, the OrbitPhase block can be given as either mean anomaly or mean longitude. However, this makes it hard to control the discovery phase of an object if it has a range of eccentricities, especially if those eccentricities are close to 1 (either eccentric or hyperbolic).

KSP's stock comets constrain the discovery phase as the radius at which the comet is first detected. It would be useful if OrbitPhase had a similar capability, with the user able to give a minimum or maximum allowed radius (this would, of course, need to be validated against the orbital apses). I'm not sure how the user should distinguish between incoming and outgoing phases.

Another useful parametrization for OrbitPhase would be as an absolute time. This would have no ambiguity, since it could follow the mean anomaly convention of negative values for phases before periapsis and positive values for after.

Redo Custom Asteroids documentation

With the addition of new config options in 1.3, the existing documentation for Custom Asteroids' config format has become too hard to navigate and read. It should be rewritten to be more user-friendly, including the following changes:

  • content split across multiple pages instead of one very long page
  • common data like distributions or expression syntax should be explicitly linked from descriptions of the fields that use them (improves both visibility of these features and makes the documentation as a whole more topic-centered)
  • more examples

Skewed coordinate systems

darkside suggested that being able to express asteroid orbital elements relative to a plane other than KSP's native coordinate system might improve compatibility with RSS.

This would require a way to transform inclination and longitude of ascending node from the skewed coordinate system to KSP's native coordinates. Argument of periapsis and mean anomaly are invariant under the coordinate change, but longitude of periapsis and mean longitude would need to be converted into standard orbital elements while in the skewed frame.

In-game Dev Feedback

Thesonicgalaxy has suggested including some in-game feedback for bad configs in addition to the current logging process.

Comets have VFX error on spawn

Description

When a comet is created using Custom Asteroids, the log emits [ProtoVessel]: Unable to create Comet VFX. immediately afterward. The comet does not show a coma and tail in the tracking station until at least one scene change since the comet appeared. Track down the error and ensure that comets are correctly displayed right away.

To Reproduce
Steps to reproduce the behavior:

  1. Load KSP with a Custom Asteroids config that supports comets.
  2. Start a new default game, and enter the tracking station.
  3. Time warp until a comet appears, and track it.
  4. Verify the error message in the Alt+F12 console.
  5. Time warp until the comet gets within Kerbin's orbit.
  6. Zoom in and verify that no visual effects are present.
  7. Leave and re-enter the tracking station.
  8. Time warp slightly, a second of 5× is enough.
  9. Zoom in on the comet and verify that it has a tail.

Background Info

  • Operating System: Windows 10 64-bit
  • KSP Version: 1.10.0
  • Custom Asteroids Version: development build of 1.9
  • Other mods: none

Unlimited Spawning in 64-bit KSP for Linux

When using the custom spawner, asteroids do not get removed from the game and just pile up. This bug does not occur with the stock spawner, though that may be because it sets the spawn rate based on the number of untracked asteroids.

Asteroids Don't Receive Custom Names Without Custom Spawner

In an effort to avoid a bug where asteroids spawn until the game chokes, I've disabled the CustomAsteroids spawner in favor of the stock one.

While this did fix the number of asteroids I have, all new asteroids are just named 'Ast. FOO' instead of the titles listed in the config files.

Asteroids removed on game load

Asteroids are sometimes removed when switching between flight mode and the KSC. The bug appears to only affect asteroids that have been visited and renamed, and strikes when setting either the asteroid or a nearby spacecraft as the active vessel then immediately exiting to KSC. The bug occurs on both KSP 1.3.0 and 1.3.1.

every asteroid is having a stroke

Background Info

  • Operating System: weenoez 1O
  • KSP Version: 1.5.1
  • 32-bit/64-bit KSP: 64-bit
  • Custom Asteroids Version: 1.5.0

Issue Description

Please describe the problem, including detailed steps to reproduce it.

Every asteroid (and some moons) are having a serious stroke, even on the map screen, the 'roids don't move, but are rotating at break-neck speeds including my kerbal in EVA. I've tried timewarp, but it didn't work. I've heard that this is a vanilla bug, but I haven't been able to reproduce it at all, so I don't know whats wrong here. Side-note: small moons (including dres) are out of orbit, wtf? (maybe i should clarify its out of the set orbit path, like this: / )
/
O
\

Composite asteroids

From daniel l. in the forums:

Is it possible to make asteroid clusters that the game views as a single entity? As in spawning a group of asteroids and creating invisible part connections between them so the game see's them as one.

Asteroid flag unset

When an asteroid is loaded in physics range, it loses its DiscoveryLevels.Name flag. Possibly related to #10.

Update: cannot reproduce this bug at present. Will keep issue open in case it reoccurs.

Alternate parametrizations

Being able to replace semimajor axis with periapsis or apoapsis, or mean anomaly with phase angle, would allow patterns that are otherwise impossible.

Group-Specific Spawn Limits

Jetski requested that it be possible for a group to create only one asteroid. After some discussion, we agreed that the limit need only apply to the number of asteroids currently spawned; there's no need to permanently disable a group once the limit is reached.

Implementation will require tracking which asteroids belong to which group, something Custom Asteroids currently ignores. This can be easily piggybacked on the extra code being written for #4.

No astroids spawning

Obligatory using 1.9.x version on 1.10.1
But no astroids have spawned in almost two ingame years of testing.

Intermittent bug when MeanLongitude specified

Most of the time, when an asteroid group is given with a orbitPhase->MeanLongitude constraint, the asteroid appears at the requested longitude. However, around 1/6 of the time, the asteroid appears in the wrong place. This is shown in the screenshot below, which shows a run of the Mean Longitude test case.

screenshot0

Asteroids circled in green are correctly placed. Asteroids in red are incorrectly placed, with an arrow pointing to where they are supposed to be.

To reproduce:

  1. Place the test.cfg file at https://gist.github.com/Starstrider42/429a770c4e64631b5acf in the CustomAsteroids/config directory, removing any other files present.
  2. Start a new game of KSP, then start a new sandbox game.
  3. Immediately go into the flight center, track all asteroids, time warp until more asteroids appear, then repeat until you have 50 or so tracked asteroids.
  4. Display the distribution of tracked asteroids.

output_log.txt and persistent.sfs for the run in the screenshot are provided at https://gist.github.com/Starstrider42/429a770c4e64631b5acf. The file testlog.csv has a data dump of all the asteroids and their orbital elements, together with the quality of the placement: "BAD" represents the two asteroids circled in red in the screenshot, while "Marginal" indicates asteroids that are almost, but not quite, where they should be.

Save file editing proves that the problem is with the sign of the mean anomaly for these cases. However, I have not been able to find a correlation between the bug and any of the orbital elements, or any combination of them, including combinations used in choosing the sign.

Incompatibility with MaximumWarp

If a player uses MaximumWarp to play the game at 1,000,000× and 10,000,000×, the asteroid counts will be unable to reach a steady state. Asteroids will only be cleaned up every 170 days or 4.7 years of game time, respectively, which means a LOT of asteroids right before cleanup.

Support KSP 1.10 comets in Custom Asteroids

KSP 1.10 adds comets to the stock game. Custom Asteroids should be able to generate such comets itself, replacing the asteroids-on-cometary-orbits approach of previous versions.

Specific requirements:

  • Custom Asteroids must still be able to work with asteroid packs written for previous versions of KSP or Custom Asteroids.
  • The comets provided by the "standard" config packs must emulate stock comets. This means changing the properties of the existing oort and innerComets groups (which roughly correspond to long- and intermediate-period comets in the new system).
    • Emulating the stock size distribution (sizes F through H, plus I) requires #6.
  • Comet-related contracts must be able to recognize new comets created by Custom Asteroids, whether or not they're from a group that emulates stock comets.
  • I'm not sure yet how much interaction the new code should have with the stock COMET_ORBIT_TYPE configs.
    • ModuleComet and CometVessel almost certainly depend on these blocks, so they must be used at least for comets' physical properties.
    • Custom Asteroids provides more flexible orbit specification than the stock configs.
    • On the other hand, Custom Asteroids does not (yet) support custom sampling experiments for asteroids of the same part type. Having each type of object be its own part is clunkier than the stock approach, but more powerful (since it naturally handles resources, textures, etc. as well).
  • Sentinel support for comets need not be handled yet (see #35).
  • It would be helpful if the Custom Asteroids code and configs could gracefully revert to the old behavior for KSP 1.9 and earlier, but this would require Custom Asteroids to create a substitute PotatoComet that would not be a drop-in replacement for the real thing (different modules). This seems like more trouble than it's worth.

CustomAsteroidPlanes does not transform consistently

Background Info

  • Operating System: Windows 10 64-bit
  • KSP Version: KSP 1.1.0 32-bit
  • Custom Asteroids Version: 1.3.0
  • Other mods: RealSolarSystem 11.0.0 (and bundled Kopernicus/ModuleManager), RSSTextures 10.4 2048.

Issue Description

I've found a weird bug that slipped through my testing of inclined asteroid groups. All behaviour in this post was tested by replacing the Custom Asteroids config that ships with RSS with this file.

If I load KSP and start a new game, asteroids will be aligned with the orbital planes of the RSS. Edge-on view:
Oblique view:

However, if I either:

  • quit to the main menu, and start a new game
  • quit KSP, then restart KSP and try to load the old game

then newly spawned asteroids will no longer have the correct orbital orientation, so long as I spawned at least one asteroid. Sometimes the effect is a few degrees, sometimes it's dozens. Oblique view of a bad case:

Within a KSP session and for a single save game, the orbital orientation does not change. I've yet to find a way of predicting the size of the offset; I used to think it increased with the number of asteroids spawned previously, but that's not the case. The rotation does not appear to be around a special axis.

Technical Details

The orbit rotations done by CustomAsteroidPlanes are implemented by finding the asteroid's untransformed state vectors (using Orbit.getRelativePositionAtUT(ut) and Orbit.getOrbitalVelocityAtUT(ut)), left-multiplying them by a Quaternion, and calling Orbit.UpdateFromStateVectors with the altered vectors. I've added some debugging logs, and the transformer swears it's always doing the same transformation, regardless of what the map view looks like:

Calibration: [0, 0, 1] -> [0.026371156796813, -0.390285193920136, 0.920316278934479]
Calibration: [1, 0, 0] -> [0.999589502811432, -1.84732489287853E-05, -0.0286505203694105]
Calibration: [0, 1, 0] -> [0.0111988745629787, 0.92069399356842, 0.390124499797821]

FixedRateSpawner initialization problems

Background Info

  • Operating System: Windows 10
  • KSP Version: 1.6.0
  • Custom Asteroids Version: Post-1.5.0 dev build

Issue Description

When a save game is first loaded and the FixedRateSpawner boots up, it thinks it is UT 0. This causes the spawner to quickly recreate all asteroids that would have spawned between UT 0 and the true in-game date. While these asteroids get cleaned up (they're mistaken for stock-spawned asteroids), this slows down game loading. Note that this bug only happens when a save game is loaded, not during scene changes.

Unfortunately, a naive fix to this problem runs into a much worse bug, where each scene change resets the Unity random number generator to a fixed value (related to #1?). The result is that identical asteroids are produced after each scene change. This doesn't seem to happen when Custom Asteroids is not installed or when FixedRateSpawner is allowed to spam asteroids, for reasons unknown.

Sentinel Telescope creates non-CA asteroids

The Sentinel Telescope appears to be implemented as an asteroid spawner independent of the ARM spawner. This means that currently Custom Asteroids neither disables nor modifies its behavior.

The Sentinel Spawner should be modified or replaced to let the telescope create Custom Asteroids-controlled asteroids. Exact behavior is TBD.

Ore drills do not work in Custom Asteroids without Community Resource Pack

Description

dprostock reported that ore drills do not work if Custom Asteroids is installed. Attempts to reproduce led to the discovery that the drilling code (and only the drilling code) crashes if the asteroid has a ModuleAsteroidResource block with unknown resources.

To Reproduce
Steps to reproduce the behavior:

  1. Start a sandbox game of KSP

  2. Run time forward until asteroids spawn

  3. Create a ship equipped with an Advanced Grabbing Unit, a stock ore drill, and an ore storage tank

  4. Launch the ship, press Alt+F12, select "Cheats/Set Orbit" from the menu, and select a rendezvous with an asteroid

  5. Dock with the asteroid, deploy the drill, and tell it to start harvesting.

  6. The drill runs, but no ore is mined, nor does the drill heat up. The log is filled with messages like:

     [ERR 14:06:12.749] [RESOURCES] - Error in - BaseConverter_GetDeltaTime - System.NullReferenceException: Object reference not set to an instance of an object
       at ModuleAsteroidDrill.PrepareRecipe (System.Double deltaTime) [0x0038d] in <55ba45dc3a43403382024deac8dcd0be>:0 
       at BaseConverter.GetBestDeltaTime (System.Double deltaTime) [0x00000] in <55ba45dc3a43403382024deac8dcd0be>:0 
       at BaseConverter.GetDeltaTime () [0x000d5] in <55ba45dc3a43403382024deac8dcd0be>:0 
    

Background Info

  • Operating System: Windows
  • KSP Version 1.9.1
  • Custom Asteroids Version: dev build built against 1.9.1
  • Community Resource Pack must not be installed -- installing it and reloading the save game described above fixes the problem.

Localization Support

Investigate whether Custom Asteroids can or should include localization features. Possibilities include:

  • Localizing asteroid titles, part tags, and science text
  • More robust planet lookup (i.e., don't depend on planet names being the same in all versions of KSP)

More flexible expression syntax

Currently, most orbital parameters in Custom Asteroid configs must be either floating-point literals, a Ratio expression, or a Offset expression. The latter two are both counterintuitive and inflexible; it would be more useful to replace them with syntax similar to everyday mathematical expressions.

The new syntax should allow numerical parameters to be an Expression, defined as one of the following:

  • a floating point literal
  • <planet>.<value>
  • Resonance(<planet>, <m>:<n>)
  • (Expression)
  • -Expression
  • Expression [+|-|*|/] Expression
    The syntax will not only be easier to work with, but will lend itself easily to future extensions.

NullReferenceExceptions in timewarp

Drew Kerman posted an intermittent bug showing NullReferenceExceptions in the log during asteroid spawns in timewarp. Another player, N3N, reported the same problem but said that reinstalling some (unspecified) third-party mods fixed it.

I cannot reproduce this bug on a clean game of KSP; given this and N3N's report, it is likely a mod conflict of some sort.

Read settings from GameDatabase

Loading mod settings with KSP's built-in mechanism rather than manually will allow ModuleManager users to tweak settings for specific mods.

Bring Custom Asteroids back in sync with CRP

Since Custom Asteroids 1.3.1 was released, CRP has added the following resources to asteroids:

  • Silicates
  • Hydrates
  • Gypsum
  • ExoticMinerals
  • RareMetals

Per-class distributions for these resources should be added to the next CA release.

Absolute spawn rate

If I could find a way to set it, I could control the rate (say, in asteroids/day) at which asteroids spawn. This would make it easier for other players to add new asteroid groups, and would be a nice customization option anyway for players who feel the stock rate is too high (or too low, but I kind of doubt that).

Bad asteroid placement errors

zilfondel reported the following log error (copied from http://forum.kerbalspaceprogram.com/index.php?/topic/72785-/&page=6#comment-1816129):

Hi, I am receiving this error message periodically while on maximum timewarp, which is ~10,000x and above due to the Time Control mod.

CustomAsteroids: Could not place Ast. TZC-416. Cause: "CustomAsteroids: Selected invalid population kboNonResonant"
Root Cause: "Culture name r is not supported.
Parameter name: name"

These errors typically come in packs of 3 at the same time, but not always. Note that I do not have the tracking station unlocked.

KSP x64 (Linux)

Mods: SETI, Outer Planets Mod, Keptunian Objects, EVE, Better Atmospheres, Time Control, etc.

Possibly related to #16.

Make asteroid class visible in Knowledge Base

Currently, there is no way to determine the object class (roughly spectral type) of an asteroid short of visiting it.

However, for comets the CometVessel module can override the knowledge base entry, displaying information about the comet's orbit instead of its size, and it seems like the purpose of VesselModule is to be accessible from unloaded contexts like the tracking station. Create a VesselModule that displays the asteroid's class, and add it to asteroids (but not comets?).

More natural Magic Boulder support

With the addition of Magic Boulders to asteroid code in 1.1.3, any asteroid can potentially be bouldered. The cleanest way for Custom Asteroids to support this is to make magic boulders a separate asteroid class, then emulate the stock occurrence rate.

Duplicate asteroids

Background Info

  • Operating System: Win10
  • KSP Version: 1.3.1
  • 32-bit/64-bit KSP: 64
  • Custom Asteroids Version: 1.5.0

Issue Description

Seeing asteroids spawning with the same name in the exact same orbit and position as they did days or weeks ago. I have 3 different save files for various purposes and I pull asteroids out of each of them into a separate save, so it's reasonable to think that maybe different saves would generate asteroids of the same name but unless the orbital properties are determined based on the name it's a bit weird to see the exact same orbit show up as well. Some asteroids that have the same name are of a different group (KBO vs. Trojan, for example) so in that case their orbits are different. The stock "Ast." group does also produce duplicate names at time but no where near the frequency of the Custom Asteroid groups.

Not sure what to tweak in the SFS or CA config to play around and see how the spawning behavior changes over time.

KSPEdia Support

Consider adding a Custom Asteroids KSPEdia page. While the basic population mechanic probably doesn't need player-oriented documentation, a summary of in-game effects of asteroid types would be useful. I'm not sure whether asteroid resource abundances should be spelled out in-game, or left as something for players to discover.

Asteroid classes

Asteroids from different populations could have different classes (stoney, carbonaceous, icy, etc.). At the most basic level, this could just be a different model. At more advanced levels, it could affect science options, or have an impact on mining mods such as Kethane, Extraplanetary Launchpads, or Interstellar.

Asteroids currupted on undock

When a vessel undocks from an asteroid, the resulting asteroid has a blank name and an incorrect seed and prefabBaseURL. In addition, the vessel that undocks has a phantom asteroid part; when the vessel is next loaded, it will appear embedded inside an asteroid.

This bug does not occur with stock 0.23.5.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.