Here is How the Rock Hermit Locator works...
The Code presently look like this, but will alter a bit as i will add a penalty, in the form of destroying a players Rock Hermit Locator.
This first Part is the Rock Hermits New AI
It is like the first but basicly adds Four extra states
The new Stages are
"LOOK_FOR_ASTEROID" : Find nearest asteroid and make it global target,
"DETONATE_TARGET" : spawn a mockbouy / Dummy near the asteroid, and kill the asteroid
"LOOK_FOR_BOUYMOM" : Find mockbouy and make it global target.
"DETONATE_MOM" : simply destroy mockboy because the shipdata.plist will create 1 of 2 new boys, one with or without a beacon depending on wheter or not the player has bought the Rock Hermit Locator..
Code for Rock Hermit AI..
Code: Select all
{
"DEFENSE_MODE" = {
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel);
ENTER = ();
EXIT = ();
"RED_ALERT" = (launchDefenseShip);
"YELLOW_ALERT" = ("setStateTo: IDLE");
"CONDITION_YELLOW" = ("setStateTo: IDLE");
"CONDITION_GREEN" = ("setStateTo: CHECK_FOR_DEBRIS");
"INCOMING_MISSILE" = (increaseAlertLevel);
"ENERGY_FULL" = ("pauseAI: 20.0", "setStateTo: IDLE");
"TARGET_DESTROYED" = ("pauseAI: 20.0", "setStateTo: IDLE");
"TARGET_LOST" = ("pauseAI: 20.0", "setStateTo: IDLE");
"NO_TARGET" = ("pauseAI: 20.0", "setStateTo: IDLE");
UPDATE = ();
};
"LOOK_FOR_ASTEROID" = {
ENTER = ();
UPDATE = ("scanForNearestShipWithRole: asteroid");
"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: DETONATE_TARGET");
"NOTHING_FOUND" = ("pauseAI: 20.0","setStateTo: LOOK_FOR_ASTEROID");
EXIT = ();
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
};
"DETONATE_TARGET" = {
ENTER = ();
UPDATE = ("scriptActionOnTarget: spawn: mockbuoy 1","scriptActionOnTarget: becomeExplosion","setStateTo: LOOK_FOR_BOUYMOM");
EXIT = ();
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
};
"LOOK_FOR_BOUYMOM" = {
ENTER = ();
UPDATE = ("scanForNearestShipWithRole: mockbuoy");
"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: DETONATE_MOM");
"NOTHING_FOUND" = ("setStateTo: LOOK_FOR_BOUYMOM");
EXIT = ();
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
};
"DETONATE_MOM" = {
ENTER = ();
UPDATE = ("scriptActionOnTarget: becomeExplosion","setStateTo: IDLE");
EXIT = ();
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
};
"CHECK_FOR_DEBRIS" = {
ENTER = ();
UPDATE = (scanForLoot,"pauseAI: 20.0");
"TARGET_FOUND" = (launchScavenger, "setStateTo: IDLE");
"NOTHING_FOUND" = ("setStateTo: CHECK_FOR_ROCKS", "pauseAI: 20.0");
EXIT = ();
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
};
"CHECK_FOR_ROCKS" = {
ENTER = ();
UPDATE = (scanForRocks, "pauseAI: 20.0");
"TARGET_FOUND" = (launchMiner, "setStateTo: IDLE");
"NOTHING_FOUND" = ("setStateTo: IDLE", "pauseAI: 20.0");
EXIT = ();
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
};
GLOBAL = {
ENTER = ("setStateTo: LOOK_FOR_ASTEROID");
EXIT = ();
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
"INCOMING_MISSILE" = (fireECM, increaseAlertLevel);
UPDATE = ();
};
IDLE = {
ATTACKED = (setTargetToPrimaryAggressor, increaseAlertLevel, "setStateTo: DEFENSE_MODE");
ENTER = ();
EXIT = ();
"INCOMING_MISSILE" = (increaseAlertLevel);
UPDATE = (decreaseAlertLevel, "setStateTo: CHECK_FOR_DEBRIS");
};
}
Here the Code for the Mock Bouy in shipdata.plist ,
The Two objects spawned when it dies are objects copy pasted from the Navigation Bouy however the bouy that has role
rockbeacon 1 has a beacon and will only be spawned if the player has The Rock Hermit Locator so i will not post that code..
Code: Select all
<key>mockmack</key>
<dict>
<key>ai_type</key>
<string>buoyAI.plist</string>
<key>bounty</key>
<integer>0</integer>
<key>cargo_type</key>
<string>CARGO_NOT_CARGO</string>
<key>death_actions</key>
<array>
<string>debugOn</string>
<string>testForEquipment: EQ_ROCKHERMIT_SCANNER</string>
<dict>
<key>conditions</key>
<array>
<string>foundEquipment_bool equal NO</string>
</array>
<key>do</key>
<array>
<string>spawn: rockbeacof 1</string>
</array>
</dict>
<dict>
<key>conditions</key>
<array>
<string>foundEquipment_bool equal YES</string>
</array>
<key>do</key>
<array>
<string>spawn: rockbeacon 1</string>
</array>
</dict>
<string>debugOff</string>
</array>
<key>energy_recharge_rate</key>
<real>2</real>
<key>forward_weapon_type</key>
<string>WEAPON_NONE</string>
<key>likely_cargo</key>
<integer>0</integer>
<key>max_cargo</key>
<integer>0</integer>
<key>max_energy</key>
<real>250</real>
<key>max_flight_pitch</key>
<real>2</real>
<key>max_flight_roll</key>
<real>2</real>
<key>max_flight_speed</key>
<real>0.0</real>
<key>missiles</key>
<integer>0</integer>
<key>model</key>
<string>buoy.dat</string>
<key>name</key>
<string>Rock Hermit Buoy</string>
<key>roles</key>
<string>mockbuoy</string>
<key>scanClass</key>
<string>CLASS_BOUY</string>
<key>thrust</key>
<real>100</real>
<key>unpiloted</key>
<true/>
<key>weapon_energy</key>
<real>0.0</real>
<key>weapon_offset_x</key>
<real>0.0</real>
</dict>
The last bit of entry is in the equipment.plist where the correct entries are made so that the player can buy the Rock Hermit Locator
Code: Select all
<array>
<integer>1</integer>
<integer>150000</integer>
<string>Rock Hermit Locator</string>
<string>EQ_ROCKHERMIT_SCANNER</string>
<string>Connects to Bouy System Link to find current locations of Rock Hermits</string>
<dict>
<key>available_to_all</key>
<true/>
</dict>
The AI is not entirely foolproof if say the rockhermit comes under attack in the first second, Which is VERY unlikely, then the AI may not work... But so far it has worked on every run...
I beleive this system could be used also so you spawn a particular ship with a beacon if the player has the right Equipment to trace it its just a matter of making a duplicate of the ship with the beacon..
Usefull for say assasin missions
, so that you dont get lost in locating your Victims
.
Cheers Frame...