Jump to content

Removing Kerbal fron unloaded Vessel - Not working as expected


Recommended Posts

I'm using the following code to remove a kerbal from a unloaded vessel. Everything seems to work and when queried again the kerbal appears to be gone. But when I switch scenes he shows back up in the vessel.

private void CrewTestProto(int REASON, ProtoPartSnapshot p, double l)
{
int CUR_CWLS = IFICWLS;
CUR_CWLS += (Convert.ToInt16(l) * 10);
float rand;
ProtoCrewMember iCrew;
for (int i = 0; i < p.protoModuleCrew.Count; i++)
{
rand = UnityEngine.Random.Range(0.0f, 100.0f);
if (CUR_CWLS > rand)
{
iCrew = p.protoModuleCrew[i];
p.protoModuleCrew.Remove(iCrew);// Remove crew from part
iCrew.Die();
IFIDebug.IFIMess(p.pVesselRef.vesselName + " POD Kerbal Killed due to no LS - " + iCrew.name);
string message = ""; message += p.pVesselRef.vesselName + "\n\n"; message += iCrew.name + "\n Was killed due to ::";
if (REASON == 1) { message += "No Electric Charge Remaining"; } else { message += "No Life Support Remaining"; }
message += "::";

MessageSystem.Message m = new MessageSystem.Message("Kerbal Death from LifeSupport Failure", message, MessageSystemButton.MessageButtonColor.RED, MessageSystemButton.ButtonIcons.ALERT);
MessageSystem.Instance.AddMessage(m);

p.storePartRefs();
}
}
}

Link to comment
Share on other sites

I did it this way..

either that

FlightEVA.fetch.spawnEVA(kerbal, p, p.airlock);

or that

            foreach (Part part in sourceShip.Parts)
{
kerbal = null;
foreach (ProtoCrewMember availableKerbal in part.protoModuleCrew)
{
if (kerbalToMove.name == availableKerbal.name)
{
//UnityEngine.Debug.Log("ImpulseDrive Transporter ShipToShip_RemoveCrew 1 ");
kerbal = availableKerbal;

part.RemoveCrewmember(kerbalToMove);

kerbalToMove.seat = null;
return;
}
}
}


depending on it's usage

my kerbals surwived the process, so I can't say how to kill them effectively.. - sorry..

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