Cephei

The official unoffical "help a fellow plugin developer" thread

Recommended Posts

So right now, after using spawnEVA to send a kerbal out on EVA, I use an ejection force to get him away from the ship.  This has problems, mainly if the direction of the force happens to be into the ship, bad things happen (explosions, receding form Kerben at >40,000m/sec, etc).

I'd rather just have the kerbal let go, but haven't yet found how to do this.  Any ideas?

Thanks in advance

Share this post


Link to post
Share on other sites

I'll give it some thought... there should be a way to invoke the release mechanism.. I don't recall off the top of my head.

Share this post


Link to post
Share on other sites
4 hours ago, linuxgurugamer said:

So right now, after using spawnEVA to send a kerbal out on EVA, I use an ejection force to get him away from the ship.  This has problems, mainly if the direction of the force happens to be into the ship, bad things happen (explosions, receding form Kerben at >40,000m/sec, etc).

I'd rather just have the kerbal let go, but haven't yet found how to do this.  Any ideas?

Thanks in advance

I believe spawnEVA does switch to the EVA kerbal as active vessel even if called when not active vessel. But could be wrong there.
As for how to get him/her to let go. KerbalEVA.OnALadder will be true if they are well, yep.
You can then KerbalEVA.fsm.RunEvent(kerbalEVA.On_ladderLetGo )

Share this post


Link to post
Share on other sites

Yup, that is what happens.  you could also capture the event handler onCrewOnEva and set the to part to null.  that may keep them from grabbing the ladder at all...

 

Share this post


Link to post
Share on other sites
4 hours ago, JPLRepo said:

I believe spawnEVA does switch to the EVA kerbal as active vessel even if called when not active vessel. But could be wrong there.
As for how to get him/her to let go. KerbalEVA.OnALadder will be true if they are well, yep.
You can then KerbalEVA.fsm.RunEvent(kerbalEVA.On_ladderLetGo )

Well, the OnALadder is not true right after the spawnEVA, but probably the next frame.

and, the ON_ladderLetGo is private, which means I'll have to do some Reflection to use it.  So next up is trying to capture the event onCrewOnEva 

Share this post


Link to post
Share on other sites

So I'm trying to turn on edge highlighting on a part when it's hovered over in a list (as shown in the screenshots) and I sort of have it working but not completely. When you hover over a part normally and it highlights green, it has very bright edge highlighting and can be seen through objects but if you look at what it looks like when I turn on the highlight with my plugin, it is like the old highlight method which is not as bright and not really visible through objects.

Here is the relevant code and some screenshots

if (hovercheck.Contains(Event.current.mousePosition))
{
	part.SetHighlightColor(Color.cyan);
	part.SetHighlight(true, false);
	part.highlightType = Part.HighlightType.AlwaysOn;
	part.gameObject.GetComponent<ExplosionDetector>().highlightPart = true;      
}
else if (part.gameObject.GetComponent<ExplosionDetector>().highlightPart == true)
{
	part.SetHighlightColor(Part.defaultHighlightPart);
	part.SetHighlight(false, false);
	part.highlightType = Part.HighlightType.OnMouseOver;
	part.gameObject.GetComponent<ExplosionDetector>().highlightPart = false;
}

Here is what it looks like when you hover over the part

DxHYjPW.png

Here is what my plugin looks like

N0uJwDC.png

Thanks :)

Share this post


Link to post
Share on other sites
1 minute ago, linuxgurugamer said:

Check the opacity setting

its at 100% - and that shouldn't make a difference in terms of visibility through objects and such

Edited by JoePatrick1

Share this post


Link to post
Share on other sites

Sorry, on mobile right now.  But that looks nice, what I'm working on will fit with it nicely, Eva parachutes and ejecting all kerbals.  Last problem is the ejection, and having them let go of the ladder

Share this post


Link to post
Share on other sites

I had a simple test window which was tagged with KSPAddon.Startup.EveryScene and used a random window id.
After updating to the current version the window still worked as expected except when going into either of the editors. In the editors the window gets created 3 times, but in all other scenes it just gets created once. 
Changing the attribute tag so use KSPAddon.Startup.AllGameScenes sorted the problem out. But I'm just curious as to why; KSPAddon still supports Startup.EveryScene but is it being phased out in favour of AllGameScenes ?

Also, I had a little helper class to jump me to a scene and load a craft as soon as KSP had loaded.  It also opened the debug console by setting;

HighLogic.fetch.showConsole = true;

But that doesn't do anything anymore (I guess due to the change to the console).  How do I open the new console in code?

Share this post


Link to post
Share on other sites

@katateochi - DebugToolbar.toolbarShown = true;

EDIT: As to the EveryScene issue, loading is a scene too - so you're probably spawning it during that scene, then again in the editor.  Just a guess though.

Edited by nightingale

Share this post


Link to post
Share on other sites

A question for all you smart people who understand  vector3

Here is the situation:

A ship, and a Kerbal has just exited and is holding on to the ladder (or, possibly, has let go and is floating there).  I want to use Vessel.AddForce(Vector3 awayFromCOM * ejectionForce)

where

awayFromCOM is calculated by pointing away from the Center of Mass of either the entire ship, or, preferably, from a specific part.  Right now I'm using : part.transform.up, (part is the kerbal), but, if the kerbal is underneath the ship, bad things happen.

How would I do this?

Thanks in advance.

Share this post


Link to post
Share on other sites
28 minutes ago, linuxgurugamer said:

A question for all you smart people who understand  vector3

Here is the situation:

A ship, and a Kerbal has just exited and is holding on to the ladder (or, possibly, has let go and is floating there).  I want to use Vessel.AddForce(Vector3 awayFromCOM * ejectionForce)

where

awayFromCOM is calculated by pointing away from the Center of Mass of either the entire ship, or, preferably, from a specific part.  Right now I'm using : part.transform.up, (part is the kerbal), but, if the kerbal is underneath the ship, bad things happen.

How would I do this?

Thanks in advance.

Gah, I feel stupid.

5 minutes after writing this, I found the answer:

Where:
origVessel is the ship
FlightGlobals.Vessels[i] is the Kerbal

Vector3 direction = FlightGlobals.Vessels[i].rootPart.transform.position - origVessel.rootPart.transform.position;
direction.Normalize();
FlightGlobals.Vessels[i].rootPart.AddForce(direction * ejectionForce);

I'm not sure yet of the order of the calculation, but it's mostly a matter of testing. 

Comments would be appreciated.

Edited by linuxgurugamer

Share this post


Link to post
Share on other sites
On 9/17/2016 at 10:38 AM, linuxgurugamer said:

Sorry, on mobile right now.  But that looks nice, what I'm working on will fit with it nicely, Eva parachutes and ejecting all kerbals.  Last problem is the ejection, and having them let go of the ladder

I may have a candidate event for you:          GameEvents.onPartLadderEnter.  Take a look at that and see if it can help... I've not expored it yet (working other bugs in other mods), but at least it gets you access into the proper point in time.

Share this post


Link to post
Share on other sites
44 minutes ago, Papa_Joe said:

I may have a candidate event for you:          GameEvents.onPartLadderEnter.  Take a look at that and see if it can help... I've not expored it yet (working other bugs in other mods), but at least it gets you access into the proper point in time.

What I need is something which is currently not available:  

KerbalEVA.On_ladderLetGo

But I've been told that something is going to be done soon in the game, so now I'm just waiting.

I will look at that, and the OnPartLadderExit, but I need to be able to let go of the ladder, which is a bit different.

Thanks

Share this post


Link to post
Share on other sites
1 minute ago, linuxgurugamer said:

What I need is something which is currently not available:  

KerbalEVA.On_ladderLetGo

But I've been told that something is going to be done soon in the game, so now I'm just waiting.

I will look at that, and the OnPartLadderExit, but I need to be able to let go of the ladder, which is a bit different.

Thanks

Sounds like a plan :wink: 

Share this post


Link to post
Share on other sites

I feel like banging my head against a wall.

I'm trying to trigger the event that tells a kerbal on a ladder to let go.

The only events related to the ladder are:

    public static EventData<KerbalEVA, Part> onPartLadderEnter;
    public static EventData<KerbalEVA, Part> onPartLadderExit;

Using the following:

if (kEVA.OnALadder && kEVA.Ready)
{
   KerbalEVA kEVA = FlightGlobals.ActiveVessel.GetComponentInChildren<KerbalEVA>();

I've tried:

EventData<KerbalEVA, Part> onLadderExit = new EventData<KerbalEVA, Part>("onLadderExit");
onLadderExit.Fire(kEVA, kEVA.LadderPart);

and

EventData<KerbalEVA, Part> onLadderExit = new EventData<KerbalEVA, Part>("onPartLadderExit");
onLadderExit.Fire(kEVA, kEVA.LadderPart);

and

GameEvents.onPartLadderExit.Fire(kEVA, kEVA.LadderPart);

After firing the event, I then tried waiting 5 ticks (in FixedUpdate).

Nothing happens.  the kerbal is on the ladder and stays there

So, what am I doing wrong here?

Share this post


Link to post
Share on other sites

 @linuxgurugamer - you've got it backwards, the event is fired on response to the Kerbal letting go out falling.

The actually check is in the KerbalFSM somewhere - I'm not sure if there's a simple way to trigger it yourself offhand.

Share this post


Link to post
Share on other sites
1 hour ago, nightingale said:

 @linuxgurugamer - you've got it backwards, the event is fired on response to the Kerbal letting go out falling.

The actually check is in the KerbalFSM somewhere - I'm not sure if there's a simple way to trigger it yourself offhand.

Yes, I was sent on a wild goose chase by what someone (at Squad) said :-)

A solution has been implemented in the next version, so this particular discussion can be let go.

Share this post


Link to post
Share on other sites
17 minutes ago, linuxgurugamer said:

Yes, I was sent on a wild goose chase by what someone (at Squad) said :-)

A solution has been implemented in the next version, so this particular discussion can be let go.

Assuming the kerbal is on the ladder (to be sure you'll find the let go event), you can run the right event directly:

var fsm = FlightGlobals.ActiveVessel.gameObject.GetComponent<KerbalEVA>().fsm;
var letGoEvent = fsm.CurrentState.StateEvents.SingleOrDefault(e => e.name == "Ladder Let Go");

if (letGoEvent == null) 
    Debug.LogError("Did not find let go event");
else fsm.RunEvent(letGoEvent);

 

Share this post


Link to post
Share on other sites
44 minutes ago, xEvilReeperx said:

Assuming the kerbal is on the ladder (to be sure you'll find the let go event), you can run the right event directly:


var fsm = FlightGlobals.ActiveVessel.gameObject.GetComponent<KerbalEVA>().fsm;
var letGoEvent = fsm.CurrentState.StateEvents.SingleOrDefault(e => e.name == "Ladder Let Go");

if (letGoEvent == null) 
    Debug.LogError("Did not find let go event");
else fsm.RunEvent(letGoEvent);

 

Thank you. 

Share this post


Link to post
Share on other sites

How to deploy a chute?

I've added a KIS EVA item, a wearable parachute.

0bYqcld.png

And it works fine... on the ground.

The problem is the bounding box for registering right-click seems to lag behind the kerbal. While walking, that's not a problem, as it's at worst several centimeters off, upper half of the chute not registering clicks or so. But when falling 200m/s, the actual click may register if I'm clicking several meters above the falling kerbal. This is a kind of an issue.

How can I fix this? I guess the rightclick issue may be hard to solve, too ingrained into the engine,  but if the chute was to be activated by key (e.g. bound to a Brakes action group), or staged, or triggered through KIS Inventory action - that would work. But how do I do it? It can't be done in VAB, as the chute is usually stowed in some container, and only appears physically in the world once the kerbal equips it.

Actually that would be one more solution: that the parachute initially starts in the ACTIVE state, instead of STOWED - the kerbal wears an already armed parachute, and it deploys as soon as pressure and altitude are right, without taking any action.  (it's just an entry in KIS inventory before equipping, so it won't deploy before being equipped.)

But how do I do any of these things? Preferably just by .cfg file option, but if that's not possible, a plugin?

Edited by Sharpy

Share this post


Link to post
Share on other sites
40 minutes ago, Sharpy said:

How to deploy a chute?

I've added a KIS EVA item, a wearable parachute.

0bYqcld.png

And it works fine... on the ground.

The problem is the bounding box for registering right-click seems to lag behind the kerbal. While walking, that's not a problem, as it's at worst several centimeters off, upper half of the chute not registering clicks or so. But when falling 200m/s, the actual click may register if I'm clicking several meters above the falling kerbal. This is a kind of an issue.

How can I fix this? I guess the rightclick issue may be hard to solve, too ingrained into the engine,  but if the chute was to be activated by key (e.g. bound to a Brakes action group), or staged, or triggered through KIS Inventory action - that would work. But how do I do it? It can't be done in VAB, as the chute is usually stowed in some container, and only appears physically in the world once the kerbal equips it.

Actually that would be one more solution: that the parachute initially starts in the ACTIVE state, instead of STOWED - the kerbal wears an already armed parachute, and it deploys as soon as pressure and altitude are right, without taking any action.  (it's just an entry in KIS inventory before equipping, so it won't deploy before being equipped.)

But how do I do any of these things? Preferably just by .cfg file option, but if that's not possible, a plugin?

Hi , I'm not sure about the latest Pre versions but in 1.1.3 there was no way to get the chute toggle, and in fact connecting the chute via KIS turned out to be something that the game didn't like.  By now you've likely discovered that the chute will be operational if you can keep the gui open,  which is an issue if you just need an emergency bailout.  I seriously beat this thing till I was sick of it, spoke to everyone including Ferram and the Kis guys and in the end Squad. I got nowhere. As the chute was attached by a mod (KIS) that mod has an effect on the chute toggle, in previous versions you could see that the collider around the chute appears to be flickering on and off, and I reckon that is the root of the trouble. If you can't click the collider you cant activate the chute. Take a look in my  chute thread and it may stop you just repeating what i went through. and hopefully you ca get further with it than I.  Good luck

Spoiler

 

 

Share this post


Link to post
Share on other sites

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.