-
Posts
485 -
Joined
-
Last visited
Content Type
Profiles
Forums
Developer Articles
KSP2 Release Notes
Everything posted by MrHappyFace
-
Contract Modding Information for Mod Authors
MrHappyFace replied to MrHappyFace's topic in KSP1 Mod Development
I'm good with the combined mod idea. Also, the code in the op has long since been updated, the contract's target will never be the same twice, and it picks the next logical target based on where you've been, but the OnLoad OnSave thing did cause me some grief... I just hate how much of my time has been wasted on REALLY stupid typos like that. -
In the list of possible targets, just remove Planetarium.fetch.Sun from the list before selecting the target. Edit: I noticed you don't have any source code included in the download, its required (look at 5.2 in http://forum.kerbalspaceprogram.com/threads/30064-Community-Rules-October-27th-2013)
-
Contract Modding Information for Mod Authors
MrHappyFace replied to MrHappyFace's topic in KSP1 Mod Development
Right now, it selects a random orbit from 3 types: low orbit, geostationary, and ececentric. Also please note that ( as far as I know) the "asteroid system" doesn't spawn anything itself, it simply asks the vessel spawning system to spawn asteroids, and the vessel spawning system is moddable, so yes, it is possible. -
Contract Modding Information for Mod Authors
MrHappyFace replied to MrHappyFace's topic in KSP1 Mod Development
I'm making* a new type of contract: *attempting and failing miserably EDIT: DMagic, shouldnt you use base.agent = Contracts.Agents.AgentList.Instance.GetAgent("DMagic"); -
Contract Modding Information for Mod Authors
MrHappyFace replied to MrHappyFace's topic in KSP1 Mod Development
Update: I added ContractParameter and ProgressTracking information and uploaded some example code. -
Contract Modding Information for Mod Authors
MrHappyFace replied to MrHappyFace's topic in KSP1 Mod Development
It does say so in the title -
I posted a thread about modding contracts here.
-
Modding Contracts As you can see, there are now some contracts asking you to dock around Kerbin, of course, it needs some work (the insane rewards are insane), but it is basically the framework for a modded contract. It was also generated based on how far i had advanced (none at all, because it was a testing world, hence why it said Kerbin instead of Jool or something crazy like that) Notes: MOST Contract related stuff is found in the Contracts namespace any class extending Contract (in the namespace Contracts) is automatically found and added Creating a contract: Make a class that extends Contract, the game automatically finds all classes extending Contract and adds them in. override the following methods: Generate() CanBeCancelled() CanBeDeclined() GetHashString() GetTitle() GetDescription() GetSynopsis() MessageCompleted() OnLoad() OnSave() MeetRequirements() [*]In Generate(), you MUST call the following things: base.SetExpiry() base.SetScience(float reward, CelestialBody) base.SetDeadlineYears(float numberOfYears, CelestialBody targetBody) OR base.SetDeadlineDays(float numberOfDays, CelestialBody targetBody) base.SetReputation(float reward, float failiure, CelestialBody targetBody) base.SetFunds(float advance, float reward, float failiure, targetBody) [*]In Generate(), add some parameters using this.AddParameter(ContractParameter parameter, string id). I have no clue what id does, I just use null, which seems to work, Ill talk about ContractParameters later in this thread, but for now, just use new KerbalDeaths(), which will make you fail the contract if you kill any victims kerbals while the contract is active. The stock ContractParameters are in the namespace Contracts.Parameters, so try messing around with those. [*]In MeetRequirements(), you can check if this contract should show up in mission control, and return false is it shouldn't and true if it should. [*]the rest is customizable, but if you fill out the GetTitle(), GetDescription(), GetSynopsis(), and MessageCompleted(), it should show up in game. Mess around with the TextGen class (which, of course, is in the namespace Contracts) ContractParameters: Make a class extending ContractParameter Override the following methods: OnRegister() OnUnregister() OnLoad() OnSave() GetTitle() GetHashString() [*]In OnRegister(), put initialization code such as adding to a GameEvent, or instantiating a new MonoBehaviour [*]In OnUnregister(), put code similar to what you would expect in OnDestroy(), such as removing a GameEvent added in OnRegister() or destroying a MonoBehaviour created in OnRegister() [*]OnSave() and OnLoad() are where you handle persistence, keep in mind that in OnSave(), NEVER use node.SetValue(), ALWAYS usennode.AddValue() [*]In GetTitle(), simply return the name of your parameter, like "Orbit " + targetBody.the name [*]use base.SetComplete() to complete the contract. Using ProgressTracking to select targets based on progress: such an imaginative title! ​just mess around with the ProgressTracking class and the protected static methods in the Contract class, such as Contract.GetBodies_NextUnvisited(). Use these in Generate () in your contract class to select the targetBody parameter used in SetScience() and SetFunds() in your contract class. You should also pipe the targetBody parameter into the the ContractParameter you made. Example Code: Note: I dont care what you do with this code, its in the public domain DockingContract.cs: using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using Contracts; using Contracts.Parameters; using KSP; using KSPAchievements; using ContractsPlus.Contracts.Parameters; namespace ContractsPlus.Contracts { public class DockingContract : Contract { CelestialBody targetBody = null; protected override bool Generate () { targetBody = GetNextUnreachedTarget (1, true, false); if (targetBody == null) { targetBody = Planetarium.fetch.Home; Debug.LogWarning ("targetBody could not be computed, using Kerbin"); } CelestialBodySubtree progress = null; foreach (var node in ProgressTracking.Instance.celestialBodyNodes) { if (node.Body == targetBody) progress = node; } if (progress == null) { Debug.LogError ("ProgressNode for targetBody " + targetBody.bodyName + " not found, terminating contract"); return false; } if (progress.docking.IsComplete) { Debug.Log ("Docking has already been completed for targetBody " + targetBody.bodyName + ", terminating contract"); return false; } bool manned = UnityEngine.Random.Range (0, 1) == 0; this.AddParameter (new DockingParameter (targetBody, manned), null); if (manned) this.AddParameter (new KerbalDeaths(), null); base.SetExpiry (); base.SetScience (2.25f, targetBody); base.SetDeadlineYears (1f, targetBody); base.SetReputation (150f, 60f, targetBody); base.SetFunds(15000f, 50000f, 35000f, targetBody); return true; } public override bool CanBeCancelled () { return true; } public override bool CanBeDeclined () { return true; } protected override string GetHashString () { return targetBody.bodyName; } protected override string GetTitle () { return "Dock in orbit around " + targetBody.theName; } protected override string GetDescription () { //those 3 strings appear to do nothing return TextGen.GenerateBackStories (Agent.Name, Agent.GetMindsetString (), "docking", "dock", "kill all humans", new System.Random ().Next()); } protected override string GetSynopsys () { return "Dock two vessels in orbit around " + targetBody.theName; } protected override string MessageCompleted () { return "You have succesfully docked around " + targetBody.theName; } protected override void OnLoad (ConfigNode node) { int bodyID = int.Parse(node.GetValue ("targetBody")); foreach(var body in FlightGlobals.Bodies) { if (body.flightGlobalsIndex == bodyID) targetBody = body; } } protected override void OnSave (ConfigNode node) { int bodyID = targetBody.flightGlobalsIndex; node.AddValue ("targetBody", bodyID); } //for testing purposes public override bool MeetRequirements () { return true; } protected static CelestialBody GetNextUnreachedTarget(int depth, bool removeSun, bool removeKerbin) { var bodies = Contract.GetBodies_NextUnreached (depth, null); if (bodies != null) { if (removeSun) bodies.Remove (Planetarium.fetch.Sun); if (removeKerbin) bodies.Remove (Planetarium.fetch.Home); if (bodies.Count > 0) return bodies [UnityEngine.Random.Range (0, bodies.Count - 1)]; } return null; } } } DockingParameter.cs: using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using Contracts; using KSP; using KSPAchievements; namespace ContractsPlus.Contracts.Parameters { public class DockingParameter : ContractParameter { public CelestialBody targetBody; public bool manned = false; public DockingParameter(CelestialBody target, bool manned) { this.targetBody = target; this.manned = manned; } protected override string GetHashString () { return targetBody.bodyName; } protected override string GetTitle () { return "Dock two vessels in orbit around " + targetBody.theName; } protected override void OnRegister () { GameEvents.onPartCouple.Add (OnDock); } protected override void OnUnregister () { GameEvents.onPartCouple.Remove (OnDock); } protected override void OnSave (ConfigNode node) { int bodyID = int.Parse(node.GetValue ("targetBody")); foreach(var body in FlightGlobals.Bodies) { if (body.flightGlobalsIndex == bodyID) targetBody = body; } } protected override void OnLoad (ConfigNode node) { int bodyID = targetBody.flightGlobalsIndex; node.AddValue ("targetBody", bodyID); } private void OnDock(GameEvents.FromToAction<Part, Part> action) { if (manned) { if (action.from.vessel.GetVesselCrew ().Count > 0 && action.to.vessel.GetVesselCrew ().Count > 0) { if (action.from.vessel.mainBody == targetBody && action.to.vessel.mainBody) { base.SetComplete (); } } } else { if (action.from.vessel.mainBody == targetBody && action.to.vessel.mainBody) { base.SetComplete (); } } } } } Feel free to contribute and/or correct me if im wrong.
-
Look in the namespace Contracts
-
Nice RTG... I've also noticed a distinct lack of stars Edit: I meant as in the skybox has no stars
-
[GAME!] Describe the person above you in one sentence
MrHappyFace replied to Misterspork's topic in Forum Games!
Someone who is not to be trusted with explosives -
Basically what the title says, what do you think will happen to the space launch industry and, generally, the world, IF Skylon succeeds? Wikipedia page: https://en.wikipedia.org/wiki/Skylon_%28spacecraft%29
-
Version 2.2 [LIST] [*]Updated to 1.0.5 [*]Fixed spelling errors [*]Fixed configuration error [/LIST] Version 2.1 [LIST] [*]Added persistent time warp selections. [*]Added the GUI to the space center and tracking station [*]Minor bugfixes [*]1.0.4 support [/LIST] Version 2.0 [LIST] [*]Completely overhauled UI [*]Added Lossless Physics, which allows you to keep accurate physics simulation even at high warp [*]Scrolling on the UI no longer affects the camera [*]The camera no longer is slow and laggy in lower time warp [*]Fixed the issue where the button did not scale with the rest of the UI properly [*]Fixed many more issues as well [*]fixed some kraken related bugs. [/LIST] Version 1.2 [LIST] [*]Polished up UI [*]1.0.2 support [/LIST] Version 1.1 [LIST] [*]Made UI disappear when pressing F2 [/LIST] Version 1.0 [LIST] [*]Initial release [/LIST]
-
Better Time Warp For KSP 1.0.5 Gifs: Without Lossless Physics Warp: http://gfycat.com/ObedientFlawedArctichare With Lossless Physics Warp: http://gfycat.com/DeepSkeletalKoala 1,000,000x time warp in low orbit: http://gfycat.com/GrandNervousGoldfinch Better Time Warp is HappyFaceIndustries' first mod, which adds the ability to customize your time warp. It has many of the same features as Time Control, and WarpUnlocker, but with a stylish UI and customization features. Features: Customizable physics and regular (On-Rails) warp Lower-than-1 physics warp can be used to help with laggy, high part ships. It is also pretty good for cinematics 0x time warp can be used to freeze time Great for ion engines! 1 hour burn completed in 3 minutes at 20x physical warp. Higher warp settings can be used in lower orbits Lossless Physics, meaning that you can keep accurate physics simulation even at high physical time warp Non-Intrusive UI, which can be disabled using F2 Can be enabled/disabled in the settings file, without uninstalling or deleting Self regenerating settings file Persistent time warp selections Works in space center and tracking station All planets get the same altitude limits for time warp: 0m for 1-1000, 100,000m for 10,000x, and 2,000,000m for 100,000x Bugs: Physics warp below x0.1 or above x100 is kind of buggy Rarely, if using low (less than 0.1) physics warp on EVA, your kerbal will go flying off at about 7x light speed More will be added to this list as they are found. Download from SpaceDock Or get it from CKAN! Download (Github) Source License (GNU GPL 3.0)
- 183 replies
-
- 20
-
-
[WIP][1.0.5]* RSS Visual Enhancements (RVE)
MrHappyFace replied to pingopete's topic in KSP1 Mod Development
there isn't a download link. i would really like to use this mod. -
I made a small cheap build http://pcpartpicker.com/user/kerbalguy123/saved/Y7848d
-
[24.2] Deployable Airbags [v0.4.0 - 2014.08.17]
MrHappyFace replied to RoverDude's topic in KSP1 Mod Releases
Will you ever write a custom plugin and remove the world cup mod dependency? -
No, all the spawning is done by private functions in ScenarioDiscoverableObjects.
-
DarkMultiPlayer 0.3.8.0 [KSP 1.12.0]
MrHappyFace replied to godarklight's topic in KSP1 Mod Releases
How should i go about hosting a private server, i'm mainly confused about port forwarding -
Make a wish... and have it horribly corrupted!
MrHappyFace replied to vexx32's topic in Forum Games!
granted, but because superman is a fictious entity, your new powers are confused and explode. I wish for a wish that can wish for other wishes that can wish for wishes.