<start>
<set_variable name="team0" value="0"/>
<set_variable name="team1" value="0"/>
<set_variable name="team2" value="0"/>
</start>
<!-- Damage Control Team Alpha -->
<event>
<if_damcon_members team_index="0" comparator="=" value="5"/>
<if_variable name="team0" comparator="=" value="0"/>
<warning_popup_message message="This is Lt. Cmdr. Feinberg from DamCom Alpha, sir. We had a hard radiation burst down here, and it looks like Ensign Cobb got the worst of it. Medbay has him now, but it doesn't look good." consoles="EC"/>
<set_variable name="team0" value="1"/>
</event>
<event>
<if_damcon_members team_index="0" comparator="=" value="4"/>
<if_variable name="team0" comparator="=" value="1"/>
<warning_popup_message message="Lt. Cmdr. Feinberg here, sir. I regret to inform you that Cadet Mayweather died while manually overriding the deck's pressure doors. If not for her, none of us would have made it." consoles="EC"/>
<set_variable name="team0" value="2"/>
</event>
<event>
<if_damcon_members team_index="0" comparator="=" value="3"/>
<if_variable name="team0" comparator="=" value="2"/>
<warning_popup_message message="Lt. Cmdr. Feinberg again, sir. Ensign Matthews just lost most of his skull when a panel overloaded. Tell medbay not to hurry, poor guy never had a chance." consoles="EC"/>
<set_variable name="team0" value="3"/>
</event>
<event>
<if_damcon_members team_index="0" comparator="=" value="2"/>
<if_variable name="team0" comparator="=" value="3"/>
<warning_popup_message message="This is Lt. Cmdr. Feinberg, sir. We've got a coolant leak here that just froze Ensign Rogers solid. Poor kid shattered like a cheap Denubian crystal." consoles="EC"/>
<set_variable name="team0" value="4"/>
</event>
<event>
<if_damcon_members team_index="0" comparator="=" value="1"/>
<if_variable name="team0" comparator="=" value="4"/>
<warning_popup_message message="Lt. Cmdr. Feinberg here, sir. We've encountered a hull breach. Midshipman Fielding was... well, he's no longer aboard, sir." consoles="EC"/>
<set_variable name="team0" value="5"/>
</event>
<event>
<if_damcon_members team_index="0" comparator="=" value="0"/>
<if_variable name="team0" comparator="=" value="5"/>
<warning_popup_message message="Lt. Cmdr. Feinberg again, sir. I'm fairly confident I can get this conduit working without any problem whatsoev---*SIGNAL LOST*" consoles="EC"/>
<set_variable name="team0" value="6"/>
</event>
<!-- Damage Control Team Beta -->
<event>
<if_damcon_members team_index="1" comparator="=" value="5"/>
<if_variable name="team1" comparator="=" value="0"/>
<warning_popup_message message="Lt. Jacoby from DamCom Beta reporting in, sir. That last explosion took out Crewman Caine. He was a bright kid with the whole universe in front of him. Earn him some payback, will you?" consoles="EC"/>
<set_variable name="team1" value="1"/>
</event>
<event>
<if_damcon_members team_index="1" comparator="=" value="4"/>
<if_variable name="team1" comparator="=" value="1"/>
<warning_popup_message message="This is Lt. Jacoby. I'm sorry to report that Lt. Jefferson volunteered to venture into the reactor core to re-align the primary phase sequencers. He saved us all, sir, everyone but himself." consoles="EC"/>
<set_variable name="team1" value="2"/>
</event>
<event>
<if_damcon_members team_index="1" comparator="=" value="3"/>
<if_variable name="team1" comparator="=" value="2"/>
<warning_popup_message message="Lt. Jacoby to bridge. It's my sad duty to report that Midshipman Satai was lost during a failed attempt to restore the power grid on this deck. He'll be missed." consoles="EC"/>
<set_variable name="team1" value="3"/>
</event>
<event>
<if_damcon_members team_index="1" comparator="=" value="2"/>
<if_variable name="team1" comparator="=" value="3"/>
<warning_popup_message message="Lt. Jacoby here, sir. I'm sorry to report that Crewman Lo'ren was killed by falling debris. You can rest assured that my team will carry on in her honor, sir." consoles="EC"/>
<set_variable name="team1" value="4"/>
</event>
<event>
<if_damcon_members team_index="1" comparator="=" value="1"/>
<if_variable name="team1" comparator="=" value="4"/>
<warning_popup_message message="Lt. Jacoby reporting in, sir. We just lost CPO Clark to a subspace implosion while trying to enact repairs. That poor bastard was only two days away from retirement, too." consoles="EC"/>
<set_variable name="team1" value="5"/>
</event>
<event>
<if_damcon_members team_index="1" comparator="=" value="0"/>
<if_variable name="team1" comparator="=" value="5"/>
<warning_popup_message message="This is Lt. Jacoby, sir. I'm beginning my repairs on the damaged area now. Hey, that wire's not supposed to be---*SIGNAL LOST*" consoles="EC"/>
<set_variable name="team1" value="6"/>
</event>
<!-- Damage Control Team Delta -->
<event>
<if_damcon_members team_index="2" comparator="=" value="5"/>
<if_variable name="team2" comparator="=" value="0"/>
<warning_popup_message message="This Lt. Frost from DamCom Delta, sir. That last blast caused some kinda subspace harmonic shockwave. It caught Lt. Nichols dead center. For what it's worth, I don't think she felt anything when it happened." consoles="EC"/>
<set_variable name="team2" value="1"/>
</event>
<event>
<if_damcon_members team_index="2" comparator="=" value="4"/>
<if_variable name="team2" comparator="=" value="1"/>
<warning_popup_message message="This is Lt. Frost. I'm sorry to report that Cadet Pierre was re-constituting the primary phase buffers when they overloaded. There's... not a lot of him left, sir. Thankfully." consoles="EC"/>
<set_variable name="team2" value="2"/>
</event>
<event>
<if_damcon_members team_index="2" comparator="=" value="3"/>
<if_variable name="team2" comparator="=" value="2"/>
<warning_popup_message message="Lt. Frost to bridge. Ensign Morgan was unfortunately killed in the line of duty ." consoles="EC"/>
<set_variable name="team2" value="3"/>
</event>
<event>
<if_damcon_members team_index="2" comparator="=" value="2"/>
<if_variable name="team2" comparator="=" value="3"/>
<warning_popup_message message="Lt. Frost here, sir. We lost Ensign N'Gert while trying to contain a plasma fire. It should be noted that his actions probably saved the entire deck." consoles="EC"/>
<set_variable name="team2" value="4"/>
</event>
<event>
<if_damcon_members team_index="2" comparator="=" value="1"/>
<if_variable name="team2" comparator="=" value="4"/>
<warning_popup_message message="This is Lt. Frost, sir. This section of the deck depressurized, and unfortunately, Lt. Myers was on the wrong side of the pressure doors." consoles="EC"/>
<set_variable name="team2" value="5"/>
</event>
<event>
<if_damcon_members team_index="2" comparator="=" value="0"/>
<if_variable name="team2" comparator="=" value="5"/>
<warning_popup_message message="Lt. Frost reporting in, sir. I've managed to isolate the array buffer, so now all I need to do is simply connec---*SIGNAL LOST*" consoles="EC"/>
<set_variable name="team2" value="6"/>
</event>
<start>
<set_variable name="awayteam" value="0"/>
</start>
<!-- Send over the Away team -->
<event>
<if_variable name="awayteam" comparator="<" value="1"/>
<if_distance name1="Artemis" name2="targetShip" comparator="<" value="5000"/>
<if_object_property name="targetShip" property="shieldStateFront" comparator="<" value="20"/>
<incoming_comms_text from="Commander Ryan">
This is Commander Ryan to Artemis.^
My team is aboard the target vessel now, and^
our mission is underway. We expect it will^
only take about a minute for us to override^
the ship's central computer. Stay within^
5000 km to maintain a lock on the away team^
and be ready to beam us back in 60 seconds.^
Also, if you could not blow up the ship with^
us still aboard it, I'd appreciate it.^
Ryan out.^ ^ ^
</incoming_comms_text>
<log text="Away team deployed."/>
<set_timer name="awaytimer" seconds="60"/>
<warning_popup_message message="Away team deployed. Do not destroy targetShip" consoles="W"/>
<warning_popup_message message="Away team deployed. Stay withing 5000 km of targetShip" consoles="H"/>
<set_variable name="awayteam" value="1"/>
</event>
<!-- The target ship was blown up with the Away team aboard! -->
<event>
<if_variable name="awayteam" comparator="=" value="1"/>
<if_object_property name="targetShip" property="hullDamageFront" comparator="<" value="1"/>
<incoming_comms_text from="Commander Ryan">
She's breaking up! She's brea--**SIGNAL LOST**^ ^ ^
</incoming_comms_text>
<warning_popup_message message="Contact Lost with Away team" consoles="C"/>
<log text="Away team lost."/>
<set_variable name="awayteam" value="3"/>
<end_mission>
</event>
<!-- Too far away from Away Team to maintain contact -->
<event>
<if_variable name="awayteam" comparator="=" value="1"/>
<if distance name1="Artemis" name2="targetShip" comparator=">" value="5000"/>
<incoming_comms_text from="Commander Ryan">
... say again... temi... nder Rya...^
ost... signa... eavy fire... reques...^
...diat extractio-- **SIGNAL LOST**^ ^ ^
</incoming_comms_text>
<warning_popup_message message="Contact Lost with Away team" consoles="C"/>
<log text="Away team lost."/>
<set_variable name="awayteam" value="3"/>
<end_mission>
</event>
<!-- They've been recovered! -->
<event>
<if_variable name="awayteam" comparator="=" value="1"/>
<if_timer_finished name="awaytimer"/>
<incoming_comms_text from="Commander Ryan">
This is Commander Ryan to Artemis.^
Our mission was successful, and we're ready^
to come home, Artemis.^ ^ ^
</incoming_comms_text>
<warning_popup_message message="Away team recovered" consoles="C"/>
<set_object_property name="targetShip" property="hasSurrendered" value="1"/>
<set_object_property name="targetShip" property="willAcceptCommsOrders"/>
<set_variable name="awayteam" value="2"/>
<log text="Away team recovered."/>
</event>
<!-- put this in either the start block or the enemyShip1 creation event -->
<set_timer name="torpedoCharged" seconds="60"/>
<!-- That should do it. Note that you could probably set a limited amount of torpedoes here, too -->
<!-- Torpedoes charged and in firing distance -->
<event>
<if_variable name="torpedoCharged" comparator="=" value="1"/>
<if_distance name1="enemyShip1" name2="Artemis" comparator="<" value="5000"/>
<!-- Not sure if this next one will ever be valid, but ideally it will allow the enemy to fire if torpedoes are less than 50% damaged -->
<if_object_property name="enemyShip1" property="systemDamageTorpedo" comparator="<" value=".5"/>
<if_timer_finished name="torpedoLoaded"/>
<create type="genericMesh" x="0" y="-5" z="0" name="plasmaTorpedo1" hullType="plasmaTorpedo1" meshFileName="plasmaTorp.dxs" textureFileName="plasmaTorp.png"/>
<copy_object_property name1="enemyShip1" name2="plasmaTorpedo1" property ="angle"/>
<copy_object_property name1="enemyShip1" name2="plasmaTorpedo1" property ="x"/>
<copy_object_property name1="enemyShip1" name2="plasmaTorpedo1" property ="z"/>
<set_object_property name="plasmaTorpedo1" property="turnRate" value="0.001"/>
<direct name="plasmaTorpedo1" targetName="Artemis" scriptThrottle=".85"/>
<set_timer name="torpedoCharged" seconds="60"/>
<set_timer name="torpedoLifespan" seconds="10"/>
</event>
<!-- The torpedo hits! -->
<event>
<if_distance name1="plasmaTorpedo1" name2="Artemis" comparator="LESS" value ="100"/>
<!-- Damage everything and destroy shields -->
<destroy name="plasmaTorpedo1"/>
<play_sound_now filename="plasmaTorpHits.wav">
<set_object_property name="Artemis" property="shieldStateFront" value="0"/>
<set_object_property name="Artemis" property="shieldStateBack" value="0"/>
<set_player_grid_damage systemType="systemBeam" value="0.3" index="3"/>
<set_player_grid_damage systemType="systemTorpedo" value="0.3" index="3"/>
<set_player_grid_damage systemType="systemTactical" value="0.3" index="3"/>
<set_player_grid_damage systemType="systemTurning" value="0.3" index="3"/>
<set_player_grid_damage systemType="systemImpulse" value="0.3" index="3"/>
<set_player_grid_damage systemType="systemWarp" value="0.3" index="3"/>
<set_player_grid_damage systemType="systemFrontShield" value="0.3" index="3"/>
<set_player_grid_damage systemType="systemBackShield" value="0.3" index="3"/>
</event>
<!-- Torpedo expires/dies out -->
<event>
<if_timer_finished name="torpedoLifespan"/>
<!-- If you were really ambitious, you could create a mine here, too -->
<destroy name="plasmaTorpedo1"/>
</event>
<event>
<if_variable name="yReset" comparator="!=" value="1"/>
<set_object_property name="player" property="positionY" value="0"/>
<set_timer name="yTimer" seconds="0.2"/>
<set_variable name="yReset" value="1"/>
</event>
<event>
<if_timer_finished name="yTimer"/>
<set_variable name="yReset" value="0"/>
</event>
It's nothing nearly as grandiose as your code, but it makes asteroid fields easier (and better looking) to traverse.
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
<event>
<if_variable name="tractorRdy" comparator="=" value="1"/>
<if_variable name="tractoring" comparator="!=" value="1"/>
<if_distance name1="OBJECT" name2="player" comparator="<=" value="220"/>
<warning_popup_message message="Tractor beam locked on" consoles="W"/>
<set_variable name="tractoring" value="1"/>
</event>
<event>
<if_variable name="tractoring" comparator="=" value="1"/>
<!-- This makes it so that the tractor only turns on when you are facing away from your target -->
<if_distance name1="OBJECT" name2="player" comparator=">" value="220"/>
<set_relative_position name1="player" name2="OBJECT" angle="180" distance="220"/>
</event>
<event>
<if_variable name="dummyValueDone" comparator="!=" value="1"/>
<set_variable name="dummyValue" randomIntHigh="100" randomIntLow="1"/>
<set_variable name="finalValue" value="0"/>
<set_variable name="dummyValueDone" value="1"/>
</event>
<!-- set a Location variable based on the random variable. We can now test against that variable. -->
<event>
<if_variable name="dummyValueDone" comparator="=" value="1"/>
<if_variable name="dummyValueChecked" comparator="!=" value="1"/>
<if_variable name="dummyValue" comparator=">=" value="1"/>
<if_variable name="dummyValue" comparator="<" value="26"/>
<set_variable name="finalValue" value="1"/>
<set_variable name="dummyValueChecked" value="1"/>
</event>
<event>
<if_variable name="dummyValueDone" comparator="=" value="1"/>
<if_variable name="dummyValueChecked" comparator="!=" value="1"/>
<if_variable name="dummyValue" comparator=">=" value="26"/>
<if_variable name="dummyValue" comparator="<" value="51"/>
<set_variable name="finalValue" value="2"/>
<set_variable name="dummyValueChecked" value="1"/>
</event>
<event>
<if_variable name="dummyValueDone" comparator="=" value="1"/>
<if_variable name="dummyValueChecked" comparator="!=" value="1"/>
<if_variable name="dummyValue" comparator=">=" value="51"/>
<if_variable name="dummyValue" comparator="<" value="76"/>
<set_variable name="finalValue" value="3"/>
<set_variable name="dummyValueChecked" value="1"/>
</event>
<event>
<if_variable name="dummyValueDone" comparator="=" value="1"/>
<if_variable name="dummyValueChecked" comparator="!=" value="1"/>
<if_variable name="dummyValue" comparator=">=" value="76"/>
<if_variable name="dummyValue" comparator="<" value="101"/>
<set_variable name="finalValue" value="4"/>
<set_variable name="dummyValueChecked" value="1"/>
</event>
<create type ="enemy" x="0" y="0" z="0" name="Score" hulltype="30" fleetnumber="99" angle="90" elite="1"/>
<set_object_property name="Score" property="elite" value="1"/>
<set_object_property name="Score" property="eliteAIType" value="0"/>
<set_object_property name="Score" property="eliteAbilityBits" value="7"/>
<event>
<if_exists name="Score"/>
<set_object_property name="Score" property="topSpeed" value="0.00001"/>
<set_object_property name="Score" property="turnRate" value="0.00001"/>
<set_object_property name="Score" property="shieldStateFront" value="100"/>
<set_object_property name="Score" property="shieldStateBack" value="100"/>
</event>
<if_inside_sphere name="Artemis" centerX="0" centerY="0" centerZ="0" radius="2000"/>
<set_object_property name="Artemis" property="positionX" value="2500"/>
<set_object_property name="Artemis" property="positionZ" value="2500"/>
<addto_object_property name="Score" property="positionY" value="100"/>
<event>
<if_variable name="endMission" comparator="=" value="1"/>
<if_variable name="gameOver" comparator="!=" value="1"/>
<if_object_property name="Score" property="positionY" comparator="<" value="50"/>
<big_message title="Mission Complete" subtitle1="Score 0/10" subtitle2="You didn't accomplish anything"/>
<set_timer name="endMissionTimer" seconds="20"/>
<set_variable name="gameOver" value="1"/>
<set_variable name="gameScore" value="0"/>
</event>
<if_object_property name="Score" property="positionY" comparator=">" value="50"/>
<if_object_property name="Score" property="positionY" comparator="<=" value="150"/>
since you'd max out at a value of 360
wonder if you could check this.
it may well just be a blind counter, 720 is a valid angle ...