Programming Question please help with docking functions

Mr Martian

Orbinaut/Addon dev/Donator
Addon Developer
Donator
Joined
Jun 6, 2012
Messages
317
Reaction score
126
Points
43
Location
Sydney, Australia, Earth, Sol
Website
www.orbithangar.com
hey guys, i am working on the ISV Pegasus V2.0, and i am having a bit of trouble with the lander separation. i want Pegasus to spawn a lander, which i have managed to do, but i want the spawned vessel to be docked to Pegasus as soon as it is spawned. so far i have this:

Code:
void Pegasus::OrpheusSep (void)
{
	if (OrpheusState == ATTACHED1) // Sanity check, is there a Lander to jettison?
	{
		VESSELSTATUS vs;
		char name[256];
		VECTOR3 sofs = ORPHEUS_POS;	// Seperation offset			
		VECTOR3	sdir = { 0, 0, 1};		// Seperation direction
		double	svel = 0.03;				// Separation velocity

				// Get vessel status structure
		VECTOR3 rofs;
		GetStatus (vs);
		Local2Rel (sofs, vs.rpos);	
		HorizonRot (sdir, rofs);
		vs.rvel += rofs*svel;
		
				// Create descent stage as seperate vessel
		strcpy (name, GetName()); 
		strcat (name, "-Orpheus");
		oapiCreateVessel (name, "ISV_PEGASUS/LANDERS/Orpheus", vs);	// create descent stage vessel
		DelMesh (Mesh_Orpheus);

		PlayVesselWave(PEGD,SEPERATION,NOLOOP,900,11025);

		Dock (dock_1, 0, 1, 0);

			//Dock (OBJHANDLE target, UINT n, UINT tgtn, UINT mode)
		OrpheusState = DETACHED1;							// Set vessel status to ascent
	}
}

as you can see i have used:
Code:
Dock (OBJHANDLE target, UINT n, UINT tgtn, UINT mode)

but i am not quite sure what i am doing wrong, because orbiter crashes whenever i spawn the lander. any help would be much appreciated :cheers:
 

Hlynkacg

Aspiring rocket scientist
Addon Developer
Tutorial Publisher
Donator
Joined
Dec 27, 2010
Messages
1,870
Reaction score
3
Points
0
Location
San Diego
Is this the code for the lander or the mother ship?
 

Zatnikitelman

Addon Developer
Addon Developer
Joined
Jan 13, 2008
Messages
2,302
Reaction score
6
Points
38
Location
Atlanta, GA, USA, North America
If you can step through it with the debugger, that's the best way of finding on which line it crashes. If you're not sure how to do this, you could also stick oapiWriteLog("") at a few places to narrow down where it crashes. Basically if you have a unique string (between the quotes), just look for the last string in Orbiter.log and you know it's between the location of that oapiWriteLog() and the next one.

Something like this:
Code:
if (OrpheusState == ATTACHED1) // Sanity check, is there a Lander to jettison?
	{
		VESSELSTATUS vs;
		char name[256];
		VECTOR3 sofs = ORPHEUS_POS;	// Seperation offset			
		VECTOR3	sdir = { 0, 0, 1};		// Seperation direction
		double	svel = 0.03;				// Separation velocity

                [COLOR="Red"]oapiWriteLog("After sep");[/COLOR]
				// Get vessel status structure
		VECTOR3 rofs;
		GetStatus (vs);
		Local2Rel (sofs, vs.rpos);	
		HorizonRot (sdir, rofs);
		vs.rvel += rofs*svel;
		
				// Create descent stage as seperate vessel
		strcpy (name, GetName()); 
		strcat (name, "-Orpheus");
		oapiCreateVessel (name, "ISV_PEGASUS/LANDERS/Orpheus", vs);	// create descent stage vessel
		DelMesh (Mesh_Orpheus);
                [COLOR="Red"]oapiWriteLog("After create");[/COLOR]

		PlayVesselWave(PEGD,SEPERATION,NOLOOP,900,11025);

		Dock (dock_1, 0, 1, 0);

			//Dock (OBJHANDLE target, UINT n, UINT tgtn, UINT mode)
		OrpheusState = DETACHED1;							// Set vessel status to ascent
                [COLOR="Red"]oapiWriteLog("After dock");[/COLOR]
	}
 
Top