IFF system


IDENTIFICATION FRIEND OR FOE SYSTEM

by TreChipman

 

This is a code snippet which must be part of a mission script.

 

"Here's a way to emulate the IFF system Capt. Gwen was advocating over in the Development forum"

 

<start> 

<create type ="neutral" raceKeys="friendly" hullKeys="cargo" x="10000" y="0" z="50000" name="innocentShip"/> 

<create type ="player" x="90000" y="0" z="50000" name="Artemis" angle="90"/> 

<set_variable name="messageSent" value="0"/> 

<set_variable name="warningSent" value="0"/> 

<set_variable name="trapSprung" value="0"/> 

</start> 

 

<event> 

<if_distance name1="innocentShip" name2="Artemis" comparator="LESS" value ="4000"/>

<if_variable name="messageSent" comparator="=" value="0"/> 

<incoming_comms_text from="innocentShip"> 

Hello, Artemis!^ 

We are a completely innocent ship.^ 

Why don't you close to less than 1000m so we can give you some cookies?^ 

</incoming_comms_text> 

<set_variable name="messageSent" value="1"/> 

</event> 

 

<event> 

<if_distance name1="innocentShip" name2="Artemis" comparator="LESS" value ="2000"/> 

<if_variable name="warningSent" comparator="=" value="0"/> 

<incoming_comms_text from="IFF_System"> 

IFF Signature for Innocent Ship is out of date!^ 

Sugget Targeting Ship Immediately!^ 

</incoming_comms_text> 

<set_variable name="warningSent" value="1"/> 

</event> 

 

<event> 

<if_distance name1="innocentShip" name2="Artemis" comparator="LESS" value ="1000"/> 

<if_variable name="trapSprung" comparator="=" value="0"/> 

<create type ="enemy" raceKeys="Kralien enemy" hullKeys="small" x="0" y="-200" z="0" angle="0" name="enemyShip"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="x"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="y"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="z"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="angle"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="throttle"/> 

<destroy name="innocentShip"> 

<incoming_comms_text from="enemyShip"> 

Bwhahahaha!^ 

I'll give you a cookie, alright...^ 

A COOKIE OF DEATH!!!^ 

</incoming_comms_text> 

<set_variable name="trapSprung" value="1"/> 

<log text="It was a trap!"/> 

</event> 

 

<event> 

<if_player_is_targeting name="innocentShip"/> 

<if_variable name="warningSent" comparator="=" value="1"/> 

<create type ="enemy" raceKeys="Kralien enemy" hullKeys="small" x="0" y="-200" z="0" angle="0" name="enemyShip"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="x"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="y"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="z"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="angle"/> 

<copy_object_property name1="innocentShip" name2="enemyShip" property ="throttle"/> 

<destroy name="innocentShip"> 

<incoming_comms_text from="enemyShip"> 

Curse you, Artemis!^ 

Somehow, you saw through our clever ruse!!^ 

</incoming_comms_text> 

<set_variable name="trapSprung" value="1"/>

<set_variable name="warningSent" value="2"/> 

</event>