How would I, say, set the altitude of a vessel that isn't the one in focus? The only thing I can think of is to use SetVessel, and the DefSetState, but that seems to be for initial initialisation.
[SIZE=2][SIZE=2]VESSELSTATUS status;[/SIZE]
[SIZE=2][SIZE=2]pOtherVessel->GetStatus(status);[/SIZE]
[SIZE=2]// ... change status ...[/SIZE]
[SIZE=2]pOtherVessel->[SIZE=2]DefSetState(&status); [COLOR=red]// unsafe!![/COLOR][/SIZE][/SIZE][/SIZE][/SIZE]
[SIZE=2][SIZE=2]VESSELSTATUS status;[/SIZE][/SIZE]
[SIZE=2][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// core bug workaround: initialize entire structure to zero before invoking the read from the core.[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]memset(&status, 0, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]sizeof[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](status));[/SIZE]
[SIZE=2][SIZE=2]pOtherVessel->GetStatus(status); [/SIZE][/SIZE]
[SIZE=2][SIZE=2]// ... change status ...[/SIZE]
[SIZE=2]pOtherVessel->[SIZE=2]DefSetState(&status); [COLOR=green]// this is safe now[/COLOR][/SIZE][/SIZE][/SIZE][/SIZE]
for (unsigned int i=0; i < oapiGetVesselCount(); i++)
{
const OBJHANDLE hVessel = oapiGetVesselByIndex(i); // handle will always be valid here since we retrieved the handle from the core in this timestep
const VESSEL *pVessel = oapiGetVesselInterface(hVessel);
// If vessel is *us*, skip it!
if (hVessel == GetHandle())
continue;
// ... use pVessel as desired here ...
}
EDIT: Of course, the vessel class constructor.
No, if you do that you'll make another vessel.
To get the VESSEL pointer from an OBJHANDLE use:
oapiGetVesselInterface(OBJHANDLE);
Then why is there an OBJHANDLE in the constructor?
Bug:
I'm having a problem with the message not apearing when my ship explodes. I checked the config file and by what I saw in the file, the message should apear. Well, I tried firing the nuke and once it explodes, the thing crashes to the desktop to spite the fact that I was far from the explosion.
Well, to spite the little bug, the thing works quite well. And I can't seem to get that Martian shuttle in one of the challanges.
Bug:
I'm having a problem with the message not apearing when my ship explodes. I checked the config file and by what I saw in the file, the message should apear. Well, I tried firing the nuke and once it explodes, the thing crashes to the desktop to spite the fact that I was far from the explosion.
Well, to spite the little bug, the thing works quite well. And I can't seem to get that Martian shuttle in one of the challanges.