Members | Sign In
All Forums > Mission Scripting
avatar

Carrier Bay

posted Jan 10, 2013 23:05:23 by SteveWohlwend
The following will enable the comms officer to launch and dock three small drone ships. Launch with "L", dock with "K". This requires adding scripts to whatever missions you wish to use it in.

The following ship goes in vesseldata.xml

<vessel uniqueID="1502" side="1" classname="Drone" broadType="fast">
<!-- TSN Drone -->
<art meshfile="dat/ENE_Matt3A.dxs" diffuseFile="dat/ship4A_diffuse.png"
glowFile="dat/ship4A_glow.png" specularFile="dat/ship4A_specular.png" scale="0.05" pushRadius="50"/>
<shields front="80" back="80" />
<performance turnrate="0.01" topspeed="5" />
<fleet_ai commonality="100" />
<beam_port x=" 111" y="-1" z="217" damage="1" arcwidth="0.3" cycletime="3.0" range="800"/>
<beam_port x="-111" y="-1" z="217" damage="1" arcwidth="0.3" cycletime="3.0" range="800"/>
<engine_port x="0" y="0" z="-230" />
<engine_port x="92" y="-7" z="-240" />
<engine_port x="-92" y="-7" z="-240" />
<impulse_point x="-124" y="-6" z="-248" />
<impulse_point x=" 124" y="-6" z="-248" />
<maneuver_point x="-177" y="-6" z="-132" />
<maneuver_point x=" 177" y="-6" z="-132" />
</vessel>

The rest needs to be merged with the relevant missions.

<!-- mission_data is the big wrapper for all the parts of a mission -->
<mission_data version="1.70">

<!-- all the things that exist at the start of the mission -->
<start>
<create type ="player" x="5000" y="0" z="95000" name="Artemis" angle="325"/>

<set_variable name="carrier_cooldown" value="0"/>
<set_variable name="clotho_launched" value="0"/>
<set_variable name="clotho_launched" value="0"/>
<set_variable name="lachesis_launched" value="0"/>
<set_variable name="atropos_launched" value="0"/>

<start_getting_keypresses_from consoles="C" />
</start>



<!-- ************************************ CARRIER BAY ******************************* -->

<!-- Launch ships -->
<event>
<if_object_property name="Artemis" property="positionX" comparator=">" value="1000"/>
<if_object_property name="Artemis" property="positionZ" comparator=">" value="1000"/>
<if_object_property name="Artemis" property="positionX" comparator="<" value="99000"/>
<if_object_property name="Artemis" property="positionZ" comparator="<" value="99000"/>
<!--<if_inside_box name="Artemis" leastx="1000" leastz="1000" mostx="99000" mostz="99000"/>-->

<if_client_key keyText="L" />
<if_variable name="carrier_cooldown" comparator="=" value="0"/>
<if_variable name="clotho_launched" comparator="=" value="0"/>

<set_variable name="clotho_launched" value="1"/>
<log text="Creating launch ship Clotho."/>
<incoming_comms_text from="Clotho">
Clotho launched.
</incoming_comms_text>
<play_sound_now filename="shiplaunch.wav"/>

<create type="neutral" hullID="1502" x="0" y="-5" z="0" angle="0" name="Clotho"/>
<set_relative_position name1="Artemis" name2="Clotho" angle="0" distance="300"/>
<copy_object_property name1="Artemis" name2="Clotho" property="angle"/>

<clear_ai name="Clotho"/>
<add_ai name="Clotho" type="FOLLOW_COMMS_ORDERS"/>
<add_ai type="TARGET_THROTTLE" targetName="Artemis" value1="1" name="Clotho" />

<set_timer name="carrier_timer" seconds="1"/>
<set_variable name="carrier_cooldown" value="3"/>
</event>

<event>
<if_object_property name="Artemis" property="positionX" comparator=">" value="1000"/>
<if_object_property name="Artemis" property="positionZ" comparator=">" value="1000"/>
<if_object_property name="Artemis" property="positionX" comparator="<" value="99000"/>
<if_object_property name="Artemis" property="positionZ" comparator="<" value="99000"/>
<!--<if_inside_box name="Artemis" leastx="1000" leastz="1000" mostx="99000" mostz="99000"/>-->

<if_client_key keyText="L" />
<if_variable name="carrier_cooldown" comparator="=" value="0"/>
<if_variable name="clotho_launched" comparator="=" value="1"/>
<if_variable name="lachesis_launched" comparator="=" value="0"/>

<set_variable name="lachesis_launched" value="1"/>
<log text="Creating launch ship Lachesis."/>
<incoming_comms_text from="Lachesis">
Lachesis launched.
</incoming_comms_text>
<play_sound_now filename="shiplaunch.wav"/>

<create type="neutral" hullID="1502" x="0" y="-5" z="0" angle="0" name="Lachesis"/>
<set_relative_position name1="Artemis" name2="Lachesis" angle="90" distance="300"/>
<copy_object_property name1="Artemis" name2="Lachesis" property="angle"/>

<clear_ai name="Lachesis"/>
<add_ai name="Lachesis" type="FOLLOW_COMMS_ORDERS"/>
<add_ai type="TARGET_THROTTLE" targetName="Artemis" value1="1" name="Lachesis" />

<set_timer name="carrier_timer" seconds="1"/>
<set_variable name="carrier_cooldown" value="3"/>
</event>

<event>
<if_object_property name="Artemis" property="positionX" comparator=">" value="1000"/>
<if_object_property name="Artemis" property="positionZ" comparator=">" value="1000"/>
<if_object_property name="Artemis" property="positionX" comparator="<" value="99000"/>
<if_object_property name="Artemis" property="positionZ" comparator="<" value="99000"/>
<!--<if_inside_box name="Artemis" leastx="1000" leastz="1000" mostx="99000" mostz="99000"/>-->

<if_client_key keyText="L" />
<if_variable name="carrier_cooldown" comparator="=" value="0"/>
<if_variable name="lachesis_launched" comparator="=" value="1"/>
<if_variable name="atropos_launched" comparator="=" value="0"/>

<set_variable name="atropos_launched" value="1"/>
<create type="neutral" hullID="1502" x="0" y="-5" z="0" angle="0" name="Atropos"/>
<log text="Creating launch ship Atropos."/>
<incoming_comms_text from="Atropos">
Atropos launched.
</incoming_comms_text>
<set_relative_position name1="Artemis" name2="Atropos" angle="270" distance="300"/>
<copy_object_property name1="Artemis" name2="Atropos" property="angle"/>

<clear_ai name="Atropos"/>
<add_ai name="Atropos" type="FOLLOW_COMMS_ORDERS"/>
<add_ai type="TARGET_THROTTLE" targetName="Artemis" value1="1" name="Atropos" />

<set_timer name="carrier_timer" seconds="1"/>
<set_variable name="carrier_cooldown" value="3"/>
</event>

<event>
<if_timer_finished name="carrier_timer"/>
<if_variable name="carrier_cooldown" comparator="!=" value="0"/>
<set_variable name="carrier_cooldown" value="0"/>
</event>

<event>
<if_client_key keyText="K" />
<if_variable name="clotho_launched" comparator="=" value="1"/>
<if_exists name="Clotho"/>
<if_distance name1="Artemis" name2="Clotho" comparator="LESS_EQUAL" value="500"/>

<set_variable name="clotho_launched" value="0"/>
<log text="Docking launch ship Clotho."/>
<incoming_comms_text from="Clotho">
Clotho docked.
</incoming_comms_text>
<play_sound_now filename="shipdock.wav"/>

<destroy name="Clotho"/>
</event>

<event>
<if_client_key keyText="K" />
<if_variable name="lachesis_launched" comparator="=" value="1"/>
<if_exists name="Lachesis"/>
<if_distance name1="Artemis" name2="Lachesis" comparator="<" value="500"/>

<set_variable name="lachesis_launched" value="0"/>
<log text="Docking launch ship Lachesis."/>
<incoming_comms_text from="Lachesis">
Lachesis docked.
</incoming_comms_text>
<play_sound_now filename="shipdock.wav"/>

<destroy name="Lachesis"/>
</event>

<event>
<if_client_key keyText="K" />
<if_variable name="atropos_launched" comparator="=" value="1"/>
<if_exists name="Atropos"/>
<if_distance name1="Artemis" name2="Atropos" comparator="<" value="500"/>

<set_variable name="atropos_launched" value="0"/>
<log text="Docking launch ship Atropos."/>
<incoming_comms_text from="Atropos">
Atropos docked.
</incoming_comms_text>
<play_sound_now filename="shipdock.wav"/>

<destroy name="Atropos"/>
</event>

<!-- ************************************ /CARRIER BAY ****************************** -->

</mission_data>

Thanks so much to Mike_Substelny and TreChipman for their help!
[Last edited Jan 12, 2013 05:22:37]
page   1
7 replies
avatar
TreChipman said Jan 11, 2013 08:16:52
Have you checked out DwayneShaffer's work over here?
I'm not a mad scientist. I'm an angry one. You'd be wise to fear the latter.

Visit Artemis Command!
avatar
Mike_Substelny said Jan 11, 2013 14:53:01
This could be a simple syntax error. Where is the / at the end of that line of code?

Try this:

<set_relative_position name1="Artemis" name2="Fighter A" angle="180" distance="300"/>
<copy_object_property name1="Artemis" name2="Fighter A" property="angle"/>

Also, this code block should check to see if Artemis is close to the edge of the map. You don't want to spawn your fighters into limbo.
"Damn the torpedoes! Four bells, Captain Drayton!"

(Likely actual words of Admiral David Farragut, USN, at the battle of Mobile Bay. Four bells was the signal for the engine room to make full steam ahead).
avatar
SteveWohlwend said Jan 12, 2013 02:53:56
Thank you so much! The end tag is my whole problem. I forgot about those entirely. I knew it had to be something stupid.

No worries, my final code will be robust, I just tried to keep this post simple. All right, back to work!
avatar
SteveWohlwend said Jan 12, 2013 04:17:43
*snip*

Alright, works so far. Comms presses "L" to launch, "K" to dock. Haven't tested very carefully yet but seems to behave about like I wanted.

Two issues currently. Firstly, I'd really like to be able to start the ships in a "defend Artemis" position; they currently start stationary. More specifically, I'd love to see a doc detailing how ship AI works, as I have been learning mostly from a couple old threads and trial and error.

Secondly, I can't seem to get if_inside_box to work. I can just look at x and z as a workaround but I'd like a better solution if possible.

TreChipman, I can't get your link to work.
[Last edited Jan 12, 2013 05:23:48]
avatar
TreChipman said Jan 12, 2013 05:04:18
Sorry, SteveWohlwned, one of the charming things about the current forum software is the complete inability to link to its own internal references. Here, try this:

http://px2owffng8.embed.tal.ki/20111224/code-snippets-1128430/
[Last edited Jan 12, 2013 05:06:26]
I'm not a mad scientist. I'm an angry one. You'd be wise to fear the latter.

Visit Artemis Command!
avatar
SteveWohlwend said Jan 12, 2013 05:19:08
Oh, beautiful, I remember that thread from last year!

TARGET_THROTTLE does exactly what I wanted. Perfect. Well, this all pretty much meets my goals then. I've edited my original post. Thanks for your help, everyone!
avatar
TaigiaReilly said Feb 18, 2013 15:14:49
So does this work now?
Login below to reply: