Jump to content

Kerbal Crew API


EnterElysium

Recommended Posts

Hey guys,

just having a quick play with making a plugin (my first time touching code other than a little bit of JavaScript as well), so please be gentle! Was trying to figure out what the calls are to read kerbal crew data such as names and their stats and badass flag whilst they are embarked or even on eva. I can't find anything on this other than a peruse of the (excellent) Crew Manifest mod's source code but that's distributed around several dll's and hard for a noob like me to follow. Any idea on where to get started and what calls I need to do to grab this info?

And since I'm a complete novice please phrase your answer as if you were talking to a very small braindead child, thanks. :)

Link to comment
Share on other sites


// Iterate through all Kerbals (including those not on a mission).
var e = HighLogic.CurrentGame.CrewRoster.GetEnumerator();
while (e.MoveNext())
{
ProtoCrewMember cm = e.Current;
// ...
}

// Access info about Kerbals on the scene.
if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null)
{
// Get the current vessel.
Vessel vessel = FlightGlobals.ActiveVessel;
// Get crew of a vessel.
List<ProtoCrewMember> cms = vessel.GetVesselCrew();
foreach (ProtoCrewMember cm in cms)
{
// Do comething for cre members.
print(cm.name);
cm.isBadass = false;
// ...
}
// ...

// Get all EVAs on the scene.
KerbalEVA[] evas = (KerbalEVA[]) KerbalEVA.FindObjectsOfType(typeof(KerbalEVA));
foreach (KerbalEVA eva in evas)
{
// Get the vessel representing the Kerbal on EVA.
Vessel evaVessel = eva.GetComponent<Vessel>();
// ...
}
}

Link to comment
Share on other sites

I'd like to be able to assign a 'sanity' value to Kerbals and initally have it tick down over time and distance from Kerbin with the rate of decrease affected by how much 'room' Kerbals on mission have. So Kerbal in confined spaces, especially alone, would suffer greater sanity loss than three kerbals with some crew compartments to live in. When sanity reaches zero for a kerbal then have some events fire such as 'goes for space walk... without his suit' or 'goes on a rampage killing another crew member' or similar.

Can around from Scott mentioning it and from playing lots of hard-modded KSP where I found manned missions to be way too superior to using probes.

Hopefully could tie this in to a kerbal's innate stats like 'courage' and 'stupidity' to have these stats affect how long it takes to go insane, which would give them some meaning at least.

The issue is I don't code but it's something I mean to get in to, and while I can be imitative and iterative with my coding I don't understand enough of the fundamental underpinnings of coding language in general. So I'm a little hesitant to call this anything other than a bit of fun/learning for now.

Link to comment
Share on other sites

I think this is definately something that would go down well in the community. I would try to talk to some of the life support modders, as this should really be a part of a life support mod rather than stand alone and they clearly know how to trigger kerbal-kill events :)

Link to comment
Share on other sites

I saw a thread asking for suggestions on sanity a while back, perhaps it was you. Anyway, I have been thinking of how it might work ever since.

My thoughts were that sanity not be a resource that depletes, but a value for each kernel that varies up or down based on their environment. Obviously living space has an impact, as does distance / communication lag from home.

I also though it would be good if the sanity of each kerbal was affected by their own attributes and those of the other kernels they are living with. So:

1) stupid kernel loose sanity faster,

2) courageous kernels have a positive effect on other kernels.

3) lack of sanity has a negative influence on the sanity of others.

The idea is to make sanity less of a problem that you solve by sending out a new part (ie send a container of fun with the cargo run to the colony), but instead it is more about the mix of crew attributes. It also has the fun of one kerbel loosing it and driving his crew mates mad, or alternatively, topping himself and so removing the negative influance on the group. You could also sepetate certain crew members for the benfirt of others, or intruduce a very courageous kernel to restore everyone else's sanity.

Anyway, just my ideas.

If you need any support or encouragement with the coding, feel free to ask me in a PM.

Edited by codepoet
Link to comment
Share on other sites

Perhaps creating a new resource and applying it to every commend pod? If it ticks down per time, you could eventually trigger something like extreme overheating of the command pod (insta-death). You would also need "supply packages," or parts that contain sanity. Checking courage/stupidity/BadS numbers would be a bit more difficult.

Link to comment
Share on other sites

A new resource would not be ideal, because you also have to account for Kerbal's on EVA and the resource would be shared equally or use at different rates meaning that Kerbal would still have a collective pool to draw from and they would all run out at once. Using personal sanity variable's this allows for much more flexibility.

Link to comment
Share on other sites

Any news on this? I've been looking into putting together a fitness/effects of zero g mod which has some similar properties ( reduced g tolerance due to time spent in near zero/high Gee environments, and use of crew modules with exercise regime parts or g simulation parts to reduce or counter these effects), and would be interested to hear how you are getting on (though I wouldn't be planning on making use of the Kerbals' stupidity stat msyelf - how hard can it be to use a gym without putting your eye out?)

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...