Dockports

More
19 years 4 months ago #18288 by drake
Dockports was created by drake
I'm experimenting with some POG code that needs to dock a shuttle vessel to a specific dockport on a mothership. This is pretty straightforward (iAI.GiveDockOrderWithDockport does the job nicely) once I can identify the correct dockport handle on the mothership. Therein lies the problem...

I can retrieve a list of dockport handles that meet given type and and status values, but I don't know how to relate this back to the dockport entry in the ship's INI file (I specifically want to dock to the first dockport listed in the INI file.) How can I retrieve just the handle of the dockport I want?

While on the subject, how does the type_flags values given in the dockport subsim INI files relate to the eDockportType enumerators in the scripting language? It's probably glaringly obvious but I can't see it.

Any information would be much appreciated.

Drake

P.S.: As someone who is only just getting into serious POG scripting, a word of thanks is definitely owing to a few people:
- ericman64 for an excellent mission tutorial;
- Mehrunes for iFleet, which I has proved an excellent source of example code;
- Steve Robertson for making all this possible, and continuing to provide support where needed.
- Everyone else who has contributed to this game.

Please Log in or Create an account to join the conversation.

More
19 years 4 months ago #11904 by MajorTom
Replied by MajorTom on topic Dockports
It is difficult to identify the first dockport in the ini to a dockport that is distinguisable in pog.

Here is a workaround example I used in the disruptor gun turret mod. It docks a disruptor gun unit to a specific dockport on the Tug. It works by identifying the dockport type. Since the standard tug only has one of that dockport type it is pretty easy:
Code:
//Dock the turret and lock it to the player ship Object.SetFloatProperty( turret_ship, "docking_priority", 84 ); if (iSim.Type(iSim.Cast(player))== T_Tug) { port_list = List.FromSet ( iDockport.DockportsOfType ( iSim.Cast ( turret_ship ), DT_Cargo, DS_Free ) ); the_port = List.GetNth( port_list, 0 ); dockport_1 = iDockport.Cast( the_port ); debug { Debug.PrintString( "SWMOD, found Dockport_1: " ); Debug.PrintHandle( dockport_1 ); Debug.PrintString( " \n" ); } port_list = List.FromSet ( iDockport.DockportsOfType ( iSim.Cast ( player ), DT_CargoFreightOnly, DS_Free ) ); the_port = List.GetNth( port_list, 0 ); dockport_2 = iDockport.Cast( the_port ); iDockport.Dock( dockport_1, dockport_2 ); debug { Debug.PrintString( "SWMOD, found Dockport_2: " ); Debug.PrintHandle( dockport_2 ); Debug.PrintString( " \n" ); } } else iSim.Dock( iSim.Cast(turret_ship), iSim.Cast(player) ); iSim.SetDockingLock( iSim.Cast(turret_ship), iSim.Cast(player), true);

The only other alternative I could thing of would be to find out the null position in the ships .lws and just do your docking by means of:
Sim.AddChildRelativeTo( hsim parent, hsim child, float x, float y, float z );

If the attached child is a class icship the docking lock will flash just as if you docked it normally

Iwar2 Multiplayer Fan Site

Please Log in or Create an account to join the conversation.

More
11 years 8 months ago #17237 by SRC
Replied by SRC on topic Dockports
I'm dealing with this same question now in attempts to generalize Bineshi's Unleashed mod to make "docked-ship" turrets moddable in .ini data rather than hard-coded as they currently are in the Unleashed mod.

Here is a potential way to get a reliable "one-to-one" correspondence between .ini file template[] dockport items (or other subsystems) and in-game information that is accessible to the modder.

1) need to access the playership .ini file (if you are modding the player ship)

a possible solution to this (which does work though it might become complex if you have many many different player-ship options) is at this thread:

www.i-war2.com/forum/topic.asp?TOPIC_ID=3091

2) Modify the ship .ini file to include .lws location information about the position and orientation of the dockport subsystems that you are interested in. Templates of how to do this can be found in the Unstable Space player-ship .ini files. Basically, you add additional number keys or numbered vector keys to the appropriate .ini file.

3) At some early point in game play, after the ship is created but before you need to access the dockports, do the following

3.a) delete the dockports that you are interested in. This can be done with the Subsim package:

Subsim.Destroy( hsubsim subsim );

3.b) re-create each of the dockports that you just destroyed. You will need to access the player-ship .ini file and determine which of the template[] items correspond to the ones you destroyed. This should not be hard since you know which template[]= "ini:/ ..." items
are the dockports you are interested in. You need the .ini file template names to re-create the dockports.

the recreation can be done with the Subsim and Sim package commands:

i) create the dockport:

hsubsim Subsim.Create( string template, string name );

ii) attach it to the parent ship:

Sim.AddSubsim( hsim sim, hsubsim subsim );

iii) place it on the parent ship:

Subsim.Place( hsubsim subsim, float x, float y, float z );

The x,y,z data will come from the new numbered vector keys you created in the .ini file, where you added them after consulting the associated .lws file to determine the proper values.

iv) orient it at the placement location:

Subsim.OrientateEuler( hsubsim subsim, float yaw, float pitch, float roll );

the yaw, pitch, roll data comes from the .lws file via the .ini file, through the additional numbered vector keys you created

3c) Using functions in the Object package, create a hdockport handle property on the handle of the player-ship (or whatever ship you did this to) that identifies the newly-created dockport. If you re-create multiple dockports, give them distinct names that are meaningful for your purposes.

Now, to dock a ship to a specific dockport (when there are multiple dockports of the same type available), retrieve the particular dockport handle(s)(Object package functions, again) that you want from the various handle properties you created on the ship handle, and then proceed as desired to dock to that dockport.

This is a bit involved, and I am trying to create a package that will make it straightforward for modders to do this to any ship. You will specify by name which subsystems you want to "destroy and recreate" and will specify the handle property names you want to give to the re-created subsystems, and the functions will do the work for you.

This resembles things that are done in the Unstable Space loadout system, and I hope to bring at least some of these features back into a toolkit for vanilla EoC modding.

Please Log in or Create an account to join the conversation.