unable to create ship
- TheCoredump
- Topic Author
- Offline
- Beginner
19 years 5 months ago #18480
by TheCoredump
TheCoredump
unable to create ship was created by TheCoredump
Please help
I don't try to do something special. I am just trying to make a mission via the scenario function. But I am unable to create any ship except the player ship.
Here is my code of the main task handler. As you see it is very, very, very, very simple.
But why the Hell the instructor_ship won't show up ?!?
Thanks in advance for your help
TheCoredump
I don't try to do something special. I am just trying to make a mission via the scenario function. But I am unable to create any ship except the player ship.
Here is my code of the main task handler. As you see it is very, very, very, very simple.
But why the Hell the instructor_ship won't show up ?!?
Code:
task MissionHandler ()
{
hstate state;
hsim start_waypoint;
hsim weapons_waypoint;
hemail ehandle;
htask mission_task = Task.Current();
hship player_ship;
hship instructor_ship;
debug Debug.PrintString("MissionHandler\n");
atomic
{
// get the mission state
state = State.Find( mission_task );
if ( !state )
{
// if it doesnt exist create a state and set up the global for this mission
state = State.Create( mission_task, MS_Start );
start_waypoint = iUtilities.CreateWaypointRelativeTo ( iMapEntity.FindByName ( "Lucrecia's Base" ), 24 km, 0, 0 );
player_ship = iShip.Create( "ini:/sims/ships/player/DreadnaughtCorvette", "Dreadnaught" );
Sim.PlaceRelativeTo ( player_ship, start_waypoint, 0, 0, 0 );
iShip.InstallPlayerPilot( player_ship );
instructor_ship = iShip.Create( "ini:/sims/ships/navy/old_corvette", "Instructeur" );
iPilotSetup.GenericMilitary( instructor_ship );
iSim.SetFaction( instructor_ship, iFaction.Find( "Navy" ) );
Sim.PlaceRelativeTo ( instructor_ship, start_waypoint, 5000, 0, 0 );
}
}
iGame.EnableBlackout( false );
}
Thanks in advance for your help
TheCoredump
TheCoredump
Please Log in or Create an account to join the conversation.
- GrandpaTrout
- Offline
- King of Space
19 years 5 months ago #13309
by GrandpaTrout
Replied by GrandpaTrout on topic unable to create ship
There are a few things that worry me about this code. It does not handle culling. I would set the waypoint as not cullable (Sim.SetCullable). And I would set the player and instructor ship as not cullable before putting them into game. My first guess as to why this would fail, is that the you place the waypoint, the game marks it for deletion. Then you place the player. The player gets into the game before the waypoint is deleted. The waypoint is gone, and the instructor cannot be placed.
One thing you should consider doing is a Debug.PrintHandle on each object to prove that it was created correctly before attempted placement. a statement like if (none==instructor_ship) {Debug.PrintString("no instructor ship to place\n"); would also be effective.
One thing you should consider doing is a Debug.PrintHandle on each object to prove that it was created correctly before attempted placement. a statement like if (none==instructor_ship) {Debug.PrintString("no instructor ship to place\n"); would also be effective.
Please Log in or Create an account to join the conversation.
- TheCoredump
- Topic Author
- Offline
- Beginner
19 years 5 months ago #13311
by TheCoredump
TheCoredump
Replied by TheCoredump on topic unable to create ship
Thanks. You're right, setting the three objects as not cullable solved it.
But could you explain me SetCullable ? What is its purpose ? And why did you say "the game marks it for deletion" about the waypoint ?
TheCoredump
But could you explain me SetCullable ? What is its purpose ? And why did you say "the game marks it for deletion" about the waypoint ?
TheCoredump
TheCoredump
Please Log in or Create an account to join the conversation.
- GrandpaTrout
- Offline
- King of Space
19 years 5 months ago #13312
by GrandpaTrout
Replied by GrandpaTrout on topic unable to create ship
The game deletes all objects that are more than 400km away from the player. The idea is to delete all objects that the player cannot see. Like deleting memory that no longer has a valid reference (garbage collection).
When you set the object as not cullable, then it will not ever be deleted. Unless you delete it (or set it to be cullable).
The issue (as you have discovered) is that you must be careful when placing objects. If you do not set them as not cullable, they can get deleted as you as you place them into the game. Specifically, you placed the waypoint before you placed the player. This means the waypoint was far more than 400km away from the player when it was placed. The game would have marked it to be deleted (but it takes time to delete). By chance the player object was placed before the waypoint was deleted.
Choosing when and how to delete objects is one of the real headaches of programming POG. It would be worth a discussion at some point.
When you set the object as not cullable, then it will not ever be deleted. Unless you delete it (or set it to be cullable).
The issue (as you have discovered) is that you must be careful when placing objects. If you do not set them as not cullable, they can get deleted as you as you place them into the game. Specifically, you placed the waypoint before you placed the player. This means the waypoint was far more than 400km away from the player when it was placed. The game would have marked it to be deleted (but it takes time to delete). By chance the player object was placed before the waypoint was deleted.
Choosing when and how to delete objects is one of the real headaches of programming POG. It would be worth a discussion at some point.
Please Log in or Create an account to join the conversation.
- TheCoredump
- Topic Author
- Offline
- Beginner
19 years 5 months ago #13314
by TheCoredump
TheCoredump
Replied by TheCoredump on topic unable to create ship
As you are very helpfull I have an other request. Here is an extract of my DreadnaughtCorvette.ini :
Obviously in game, there is no fwd and aft feature but I don't understand why the react as they are differents weapons : I have to manually select the left PBC, or the right PBC. The same with missiles. They aren't linked.
TheCoredump
Code:
; Weapons - PBC
template[15]=ini:/subsims/systems/player/pbc_wide_angle
null[15]=fwd_pbc_hardpoint
template[16]=ini:/subsims/systems/player/pbc_wide_angle
null[16]=aft_pbc_hardpoint
; Weapons - Missiles
template[17]=ini:/subsims/systems/player/deadshot_missile_magazine
null[17]=fwd_missile_hardpoint
template[18]=ini:/subsims/systems/player/deadshot_missile_magazine
null[18]=aft_missile_hardpoint
Obviously in game, there is no fwd and aft feature but I don't understand why the react as they are differents weapons : I have to manually select the left PBC, or the right PBC. The same with missiles. They aren't linked.
TheCoredump
TheCoredump
Please Log in or Create an account to join the conversation.
- GrandpaTrout
- Offline
- King of Space
19 years 5 months ago #13318
by GrandpaTrout
Replied by GrandpaTrout on topic unable to create ship
You start with all the hard problems!
Ok, linking is done by the player loadout using a special subsim. We don't really know how it works. And trying to link ships with beam weapons causes the game to crash. So the sad truth is, you cannot really link weapons from player mods.
Ok, linking is done by the player loadout using a special subsim. We don't really know how it works. And trying to link ships with beam weapons causes the game to crash. So the sad truth is, you cannot really link weapons from player mods.
Please Log in or Create an account to join the conversation.