![](https://forum.kerbalspaceprogram.com/uploads/set_resources_17/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
![](https://forum.kerbalspaceprogram.com/uploads/set_resources_17/84c1e40ea0e759e3f1505eb1788ddf3c_default_photo.png)
DMagic
Members-
Posts
4,180 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by DMagic
-
[WIP] [0.24] Crowd-sourced Story Logs: Contracts Need you!
DMagic replied to Joshwoo70's topic in KSP1 Mod Development
If at all possible you should come up with a module manager config for this rather than directly editing and replacing stock Squad files. Replacing stock files is always a bad idea and seems to have led to many of the problems that people had with crowd sourced science logs. The contract storydefs file seems to use the same basic kind of config node structure that the sciencedefs file uses, so it shouldn't be difficult to do this with module manager. -
This thread collects most of what you should need to know: http://forum.kerbalspaceprogram.com/threads/25013-Compilation-of-modding-information-links-for-0-19-20-21-22-23-Last-update-24th-Jan. It covers pretty much all of the basics on modelling, texturing, importing into KSP and setting up config files. The modelling and texturing subforum has more information and more specific questions: http://forum.kerbalspaceprogram.com/forums/14-Modelling-and-Texturing-Discussion
-
Contract Modding Information for Mod Authors
DMagic replied to MrHappyFace's topic in KSP1 Mod Development
I've had some success getting a more generalized and customizable system setup for adding science experiment contracts. First of all, I'm not sure if it's been mentioned, but in the Alt+F12 debug console there is a "Contracts" tab that allows you to manually create any type of contract. There are three buttons there, and I'm not sure what the difference is, but this is great for forcing contract generation while testing. So anyway, my first thought was that instead of just scanning through all of the existing science experiments (and potentially stepping on science modders' toes) I would setup a config file system. It's a fairly simple system where you just include a few items about the experiments you want to add and put them in a config file. CONTRACT_EXPERIMENT { name = Magnetometer Scan experimentID = magScan sitMask = 51 bioMask = 1 part = dmmagBoom techNode = scienceTech agent = DMagic } This is my format. My experiments have a few added complications because I store the situation and biome masks internally rather than in the ScienceDefs.cfg file (the better to keep unwanted mods from interfering with my parts:wink:), but the basic requirements are simple. You add a name, I'm using the experiment name from the ScienceDefs file, but anything will do, the experimentID, the name of the part that the experiment is associated with, the tech node where that part can be researched, and an agent. These can be generalized or made to work with different types of experiments. For example the EVA report would look like CONTRACT_EXPERIMENT { name = EVA Report experimentID = evaReport part = None techNode = notANode agent = Any } As long as the part is named "None" then the system will assume that no part is associated with the experiment and skip all of the part and tech node steps (putting something in the tech node field is probably still required though). And setting the agent equal to "Any" means that none will be specified. The code is getting too complicated to post here, but everything is on GitHub in the Contracts! branch and I update that frequently. The system loads all of the experiments from the config file at the mainmenu and prints out which were added. It stores all of the information in a simple object that I created. The contract generator just takes a random value from the list of all these objects then scans through to check if it is eligible. It checks to see if the tech node is valid and has been researched, then it checks to see if the specific part has been purchased from the R&D center. Once it gets past there it assigns a target Celestial Body (which I haven't really implemented yet, but it looks like there are some standard methods for this). Then it checks which experimental situations can be done by the selected experiment, selects one at random, and generates the appropriate Science Subject. This would be the experiment ID, the target body, the target situation, and a biome if applicable (I haven't implemented the biome part yet). If the experiment doesn't have enough remaining science to be collected (maybe one or two samples from that area have already been collected) then it returns false. If it gets past that point then it assigns the agent if applicable, and generates the Contract Paramater. I have an idea to set the rewards values based on the celestial body science parameters. These are the multipliers for your science experiments, I think they serve as a decent analogue for the difficulty level involved with any given experiment. It all seems to working so far. It's generating contracts based on my list of experiments, and none of them are invalid, I'm not getting requests to perform a laser surface scan from orbit. I think I just need to figure out the celestial body generating code, come with a way to generate descriptions, and maybe tweak the reward settings. But it should be very simple to add in the stock experiments and any standard mod experiments using a slightly altered form of this code. Then the contracts for my own experiments could live alongside these without any conflicts. I'll post more when I get something more finalized. -
[KSP1.8] DMagic Module Science Animate V0.22 (11/2/19)
DMagic replied to DMagic's topic in KSP1 Mod Development
Updated to version 6; get it on MediaFire. The major addition here is ability to setup multiple-use experiments. These function similar to the solar particle collector and the core drill in my pack. They allow for multiple samples to be collected by a single part. A second animation can be used in conjunction with this feature. It is meant to be either a sample storage type of animation, or some kind of indicator animation (something that tells you how many samples have been collected). To set this up properly you want to create a second Unity animation and enter its name in the "sampleAnim" field. This will play in segments based on how many experiments have been collected by the part. So if you create a 10 second long animation, and your part can collect 4 experiments, it will play 2.5 seconds of the animation every time you store or transmit a new experiment. Create your animation with this pattern in mind. Also note that the full animation will play backward after lab reset, and individual segments will play after discarding data from the results page. Experiments can now be deployed by an EVA Kerbal, just set "externalDeploy = true". You can change how much science lab processing will boost the transmission rate for your experiments. The "labDataBoost" field is set to 0 by default, which triggers the stock, 50% transmission rate boost. Set it to something other than 0 to change this. Check the reference config included on the first post here and in the download packaged for the complete set of customizable fields. Let me know if you have any questions on settings or any requests. -
[24.2] Karbonite Ongoing Dev and Discussion
DMagic replied to RoverDude's topic in KSP1 Mod Development
I have to release a quick update to fix some RPM problems, so I'll add Karbonite to the list of ORS resources and give you the required SCANtype to use. -
You have SpacePlane Plus installed, correct? It looks like the SCANsat module is not getting applied to the SpacePlane Plus cockpits, it does appear to be getting added to the stock and MKS pods though. I see that you're crashing, but does it happen right away, or are you able to right click on the cockpit to check if it has an "Open Map" button? What's supposed to happen here is that RPM will add the necessary modules to any parts with an IVA. Then SCANsat will come along and check to see if any parts have the RPM modules attached, and if so attach it's own module. From what I can tell SCANsat isn't seeing the SpacePlane parts and so doesn't add its module. I've tested this with stock parts and it doesn't trigger a crash when I deliberately remove the SCANsat module from a command pod, so I'm not sure why it's causing such severe problems with SpacePlane Plus. Either way a fix for this will have to be released so that even if the module doesn't get added it won't break or cause crashing. It's a simple thing to fix, I was just dumb in not being careful about assuming that the SCANsat module would always be present. In the meantime you can try adding a module manager config with this inside to just force the SCANsat module onto the part; just fill in whatever the actual part name is. @PART[*SpacePlane Cockpit*] { MODULE { name = SCANsat sensorType = 0 fov = 0 min_alt = 0 max_alt = 0 best_alt = 0 scanName = Eyeball Scan power = 0.05 } }
-
[24.2] Karbonite Ongoing Dev and Discussion
DMagic replied to RoverDude's topic in KSP1 Mod Development
Let me know when you have finalized anything related to the specific resources you'll be using. -
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
I foresee much more writing in my future , though I am partial to the "Do Something" contract, it really gets to the point. Yeah, it should provide for some much more interesting ways to interact with science. -
Contract Modding Information for Mod Authors
DMagic replied to MrHappyFace's topic in KSP1 Mod Development
I'm all for combining resources, but most of my contracts will probably be specific to my own parts. I'm thinking, though, that maybe I'll make a generic generator with a ScienceExperiment array populated with the available science parts to serve as a source of contracts. There is no reason why this wouldn't work with stock science parts too, or any other science experiments. This could exist separately from my mod, or maybe I could also include it with my mod, but just disable it if the separate version is also installed. I'll have to see what's possible. -
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
I've had some success making basic contracts. My thinking is to create a generic procedural contract type along with a number of more specific contracts, but maybe with some degree of proceduralness (a word?) associated with them. I'm thinking that I can create a pool of available science experiments to create contracts for based on tech node progression, maybe with some emphasis on newly unlocked (or maybe just higher up the tech tree) science parts. These could just as easily work for stock parts too, since the stock science contracts don't ask for any specific experiments as far as I can tell. I could randomly pull an experiment from that pool, then assign a planet based on your progress (which stock contracts seem to have the methods for) and maybe add a minimum science return. For more specific contracts I could maybe require that a number of experiments be carried out at some specific location. I'll have to think of something interesting to do for these. I've also added myself as an agent, I can make contracts specify which agent they use, or let them use anything (I think). -
Just to be clear on this, and I know Arsonide is releasing the source code, it is absolutely required to make the source available if you release a plugin on the KSP forums, license requirements aside. It is the first rule on plugin posting: http://forum.kerbalspaceprogram.com/threads/7529
-
Contract Modding Information for Mod Authors
DMagic replied to MrHappyFace's topic in KSP1 Mod Development
It looks like they added some new GameEvents, which should be extremely helpful for detecting completion of new contracts. OnScienceReceived fires after transmitting or recovering science and returns the science subject and the amount of science gained. This should be perfect for setting up very specific science contracts. Instead of just collect science from the Mun, I think I can give it a specific experiment (and even biome) with a required amount of science to be gained. I will post the ContractParameter code if I get it working. Edit: Success! I've got created a new Contract Parameter that calls for specific experiments around a specific body, and can require a set amount of science to be gathered. This code is all sorts of rough, but everything seems to be working so far. namespace DMagic { public class DMContract: Contract { private CelestialBody body = null; private BodyLocation scienceLocation; private ScienceExperiment exp = null; #region overrides protected override bool Generate() { if (body == null) body = FlightGlobals.Bodies[1]; scienceLocation = BodyLocation.Space; if (exp == null) exp = ResearchAndDevelopment.GetExperiment("rpwsScan"); this.agent = Contracts.Agents.AgentList.Instance.GetAgent("DMagic"); this.AddParameter(new DMCollectScience(body, scienceLocation, exp), null); base.SetExpiry(); base.SetScience(5f, body); base.SetDeadlineYears(100f, body); base.SetReputation(5f, 10f, body); base.SetFunds(100f, 10f, 50f, body); return true; } public override bool CanBeCancelled() { return true; } public override bool CanBeDeclined() { return true; } protected override string GetHashString() { return body.name + scienceLocation.ToString() + exp.id; } protected override string GetTitle() { return "Contract to do something"; } protected override string GetDescription() { return "Do something!"; } protected override string GetSynopsys() { return "You did something!"; } protected override string MessageCompleted() { return "Success"; } protected override void OnLoad(ConfigNode node) { Debug.Log("[DM] Loading Contract"); int targetBodyID = int.Parse(node.GetValue("ScienceTarget")); foreach (CelestialBody cBody in FlightGlobals.Bodies) { if (cBody.flightGlobalsIndex == targetBodyID) body = cBody; } Debug.Log("[DM] Body Set"); ScienceExperiment sciExp = ResearchAndDevelopment.GetExperiment(node.GetValue("ScienceExperiment")); if (sciExp != null) exp = sciExp; Debug.Log("[DM] Experiment Set"); string location = node.GetValue("TargetLocation"); if (location != null) if (location == "Space") scienceLocation = BodyLocation.Space; else scienceLocation = BodyLocation.Surface; Debug.Log("[DM] Location Set"); } protected override void OnSave(ConfigNode node) { Debug.Log("[DM] Saving Contract"); node.AddValue("ScienceTarget", body.flightGlobalsIndex); node.AddValue("ScienceExperiment", exp.id); node.AddValue("TargetLocation", scienceLocation); } public override bool MeetRequirements() { return true; } #endregion } #region Contract Parameter public class DMCollectScience: CollectScience { public CelestialBody scienceTargetBody; public BodyLocation scienceLocation; public ScienceExperiment targetScience; public DMCollectScience() { } public DMCollectScience(CelestialBody target, BodyLocation location, ScienceExperiment experiment) { scienceTargetBody = target; scienceLocation = location; targetScience = experiment; } protected override string GetHashString() { return scienceTargetBody.name + scienceLocation.ToString() + targetScience.id; } protected override string GetTitle() { if (scienceLocation == BodyLocation.Space) return string.Format("Collect {0} data from in orbit around {1}.", targetScience.experimentTitle, scienceTargetBody.theName); else return string.Format("Collect {0} data from the surface of {1}.", targetScience.experimentTitle, scienceTargetBody.theName); } protected override void OnRegister() { GameEvents.OnScienceRecieved.Add(scienceRecieve); } protected override void OnUnregister() { GameEvents.OnScienceRecieved.Remove(scienceRecieve); } protected override void OnSave(ConfigNode node) { Debug.Log("[DM] Saving Contract Parameter"); node.AddValue("ScienceTarget", scienceTargetBody.flightGlobalsIndex); node.AddValue("ScienceExperiment", targetScience.id); node.AddValue("TargetLocation", scienceLocation); } protected override void OnLoad(ConfigNode node) { Debug.Log("[DM] Loading Contract Parameter"); int targetBodyID = int.Parse(node.GetValue("ScienceTarget")); foreach (CelestialBody body in FlightGlobals.Bodies) { if (body.flightGlobalsIndex == targetBodyID) scienceTargetBody = body; } Debug.Log("[DM] Param Body Set"); ScienceExperiment exp = ResearchAndDevelopment.GetExperiment(node.GetValue("ScienceExperiment")); if (exp != null) targetScience = exp; Debug.Log("[DM] Param Experiment Set"); string location = node.GetValue("TargetLocation"); if (location != null) if (location == "Space") scienceLocation = BodyLocation.Space; else scienceLocation = BodyLocation.Surface; Debug.Log("[DM] Param Location Set"); } private void scienceRecieve(float sci, ScienceSubject sub) { if (sub.id == targetScience.id + "@" + scienceTargetBody.name + ExperimentSituations.InSpaceLow.ToString()) { Debug.Log("[DM] Contract Complete"); base.SetComplete(); } } } #endregion The OnSave and OnLoad methods were giving me headaches, hence all of the debug spam, but in principle they are simple (also, MrHappyFace, I think you have the OnSave and OnLoad switched in your ContractParameter code), you can check the persistent file to see how things look once they've been saved. The other problem that I kept running into, was that my DMCollectScience Contract Parameter needed to have an empty constructor, the public DMCollectScience() line, in addition to the one called by the Contract generator. The only method really specific to this type of contract is the last one, scienceRecieve(), that's the one tied to the game event that checks to see if the correct experiment has been performed. It also returns the amount of science gained, so I could check that, too. -
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
An excellent chance The plan here is to have some method for assigning not just asteroid family types, but composition types based on the standard asteroid spectral compositions. I sort-of have a method for this, but something similar to the name thing that Custom Asteroids is using would be best because it's easily accessible to other mods. That way I could more specifically tailor my results based on spectral type instead of just kind-of fudging it based on the existing size classes. I can't say anything about BTSM specifically, but anything that adds new experiment definitions has the potential to cause this. I should actually submit a bug to Squad for this, even if it is mod related. If it hits a duplicate experiment definition while loading it seems to stop loading any further experiments, breaking all of the remaining experiments. -
Universal Storage 1.4.0.0 (For KSP 1.4.x) 13th March 2018
DMagic replied to Paul Kingtiger's topic in KSP1 Mod Releases
It's also worth keeping in mind that creating one type of wedge means not creating or delaying another type. And considering the overall desire not to create part bloat more than necessary there are good reasons why not to make new parts when existing versions function very well. -
Contract Modding - what's available and what's possible?
DMagic replied to jfjohnny5's topic in KSP1 Mods Discussions
Contract modding information is being collected here: http://forum.kerbalspaceprogram.com/threads/86588 It requires plugin coding, so until or unless someone creates some kind of config loader you won't be able to create simple contracts the way you can with science experiments, at least not by any method that I'm aware of. -
Universal Storage 1.4.0.0 (For KSP 1.4.x) 13th March 2018
DMagic replied to Paul Kingtiger's topic in KSP1 Mod Releases
This seems kind-of superfluous. We already have three very good in-line batteries, the largest of which is very thin, looks fine, and has a very high capacity. And for other situations you can always stuff the radially attached batteries into an empty bay. -
If you don't want ModStatistics to send data you can follow the opt-out instructions provided in the ModStatistics thread. Alternatively you can download and install a disabling mod such as this one (regardless of the thread status, this version appears to have no issues with possible license infringement, and so the download should remain available). If you think there is something actively harmful about the plugin itself, regardless of what it sends you can delete any copies of it in your GameData folder. If any of the above options are too onerous or otherwise unsatisfactory you can delete or not install SCANsat. If you follow the instructions and completely delete the existing SCANsat and SCANsatRPM folders before installing the new version then you should have no problems with existing vessels; nothing about the parts was changed. If you are worried about it though, just create a backup of your save file somewhere safe before updating. The tech tree, part cost and science gains are all subject to change. Though really, given the amount of science available, it doesn't really take any time at all to progress far enough up the tech tree to unlock the multispectral scanner. ------- I would like to know if anyone is having issues with SpacePlane Plus 1.3 when used with SCANsat and RasterPropMonitor. In particular I would like to know if you are seeing this line in your output.log or crash files. InvalidOperationException: Operation is not valid due to the current state of the object at System.Linq.Enumerable.First[SCANsat] (IEnumerable`1 source) [0x00000] in <filename unknown>:0 at SCANsat.JSISCANsatRPM.Start () [0x00000] in <filename unknown>:0 (Filename: Line: -1)
-
Contract Modding Information for Mod Authors
DMagic replied to MrHappyFace's topic in KSP1 Mod Development
Yes, that would probably make more sense. -
Contract Modding Information for Mod Authors
DMagic replied to MrHappyFace's topic in KSP1 Mod Development
If you want to force it to a specific agent you need: base.agent = new Contracts.Agents.Agent("DMagic", "logo URL", "logo Scaled URL"); in your Generate code, with the URLs being the location of the logos specified in the Agent config file. Edit: Use the code in the next post to fetch an existing agent rather than creating a new one. -
Contract Modding Information for Mod Authors
DMagic replied to MrHappyFace's topic in KSP1 Mod Development
Huzzah! A contract to "Do something" asks you to collect some science from Kerbin orbit. I'll have to do something about that terrible scaled logo..., Edit: or maybe just not use the scaled logo for both types... So am I thinking about this right that we'll need a new instance of the Contract class for every contract we make? Then I guess the idea would be to make the contract parameters as flexible as we need them to be. Alternatively, would it be possible to create a config file with parameters for several contracts, then write some code to load those parameters, create a new instance of our Contract-derived class, and pass those parameters into it? I probably need to spend more time thinking about the Contract.Parameters. -
Contract Modding Information for Mod Authors
DMagic replied to MrHappyFace's topic in KSP1 Mod Development
I assume we can add new agencies by simply including a config file with the AGENT{} with the name, logo (and I'm guessing the scaled logo is just smaller?), and whatever modifiers you want to add. It seems to add it according to the log file during loading, though I haven't actually added any actual contracts, so I can't tell for sure if it's working. Edit: Yep, this works for adding new agents. -
[1.8.x] DMagic Orbital Science: New Science Parts [v1.4.3] [11/2/2019]
DMagic replied to DMagic's topic in KSP1 Mod Releases
Out of date versions of Lionhead probes and landers can cause this. Any other mod that adds science experiments that are duplicates of others will too. Thu crown sourced science logs can cause problems if you don't install it properly. Wow, that's really weird. I tried out a number of your examples and couldn't get anything to break it. Really nailing this down will probably be very difficult with so many other mods installed. I'm on a relatively clean installation so maybe I'm missing something that's breaking it in very strange ways.