AI Scripting for mine/turret
Posted: Sat Nov 07, 2009 12:48 am
Hi,
I'm trying to script an auto pilot for a mine/turret I made.
The mine is equipped with a front plasma accelerator and ten nano missiles.
It is 15m in diameter and after being launched is supposed to be stationary.
This is basically what I what it to do after being launched from the players ship
This is what I have already scripted, it doesn't work though.
After I deploy the mine It doesn't even send the ready message.
If some one could tell me what I did wrong I'd be very grateful.
I'm trying to script an auto pilot for a mine/turret I made.
The mine is equipped with a front plasma accelerator and ten nano missiles.
It is 15m in diameter and after being launched is supposed to be stationary.
This is basically what I what it to do after being launched from the players ship
Code: Select all
Gets launched from players ship.
Pause ai 2 sec.
Turns on lights.
perform stop
Console message: Mine Ready - searching for targets.
Look for enemy ships.
If mine finds enemy targets.
Console message: Krypton Mine - target found.
perform attack.
Else if mine finds no targets.
start self detonation sequence.
target destroyed.
Console message: Krypton Mine - target destroyed.
turn lights on
look for closest enemy ships
target lost
Console message: Krypton Mine - target lost.
turn lights on
look for closest enemy ships
If mine detects attack on itself.
turn lights off
attack primary aggressor.
If mine detects missile targeted on itself.
activate ecm.
If mine detects ecm blast.
look for closest enemy ships
If mine energy is low.
Console message: Krypton Mine - self detonating energy low.
self detonate immediately.
Self detonation sequence
Console message: Krypton Mine - self detonating cancel with ecm blast.
Pause ai 1 sec.
Message to player: Krypton Mine - self detonating in 3.
Pause ai 1 sec.
Message to player: Krypton Mine - self detonating in 2.
Pause ai 1 sec.
Message to player: Krypton Mine - self detonating in 1.
Pause ai 1 sec.
Message to player: Krypton Mine - self detonating in 0.
Pause ai 1 sec.
become explosion
Immediate detonation sequence
set range to: 400
dealEnergyDamageWithinDesiredRange
become explosion
After I deploy the mine It doesn't even send the ready message.
Code: Select all
{
GLOBAL = {
ENTER = (
switchLightsOff,
"setSpeedfactorTo: 1.0",
performStop,
"setStateTo: LOOK_FOR_TARGETS",
);
EXIT = ();
UPDATE = ();
};
"LOOK_FOR_TARGETS" = {
ENTER = (
"consoleMessage3s: Mine Ready - searching for targets.",
"setDesiredRangeTo: 50000",
switchLightsOn,
"scanForNearestShipHavingAnyRole: thargoid thargorn hardpirate pirate",
"setTargetToFoundTarget",
);
"TARGET_FOUND" = (
"consoleMessage3s: Krypton Mine - target found.",
"setStateTo: DEFEND_SHIP",
);
"NOTHING_FOUND" = (
"consoleMessage3s: Krypton Mine - no target found.",
"pauseAI: 4",
"setStateTo: DETONATE",
);
EXIT = ();
UPDATE = (
"pauseAI: 0.5",
"setStateTo: LOOK_FOR_TARGETS",
"commsMessage: Krypton Mine - searching for targets.",
);
};
"DEFEND_SHIP" = {
ENTER = (
switchLightsOn,
"setTargetToFoundTarget",
performAttack,
"consoleMessage3s: Krypton Mine - attacking target.",
checkEnergy,
);
"ENERGY_LOW" = (
"consoleMessage3s: Krypton Mine - energy low self detonating.",
"setStateTo: DETONATE_NOW",
);
"INCOMING_MISSILE" = (
switchLightsOff,
"consoleMessage3s: Krypton Mine - being attacked.",
fireECM,
"setTargetToPrimaryAggressor",
performAttack,
);
ATTACKED = (
switchLightsOff,
"markTargetForFines: 200",
"consoleMessage3s: Krypton Mine - being attacked.",
"setTargetToPrimaryAggressor",
performAttack,
"setStateTo: LOOK_FOR_TARGETS",
);
"ATTACKED_BY_CLOAKED" = (
switchLightsOff,
"markTargetForFines: 50",
"consoleMessage3s: Krypton Mine - being attacked.",
"setTargetToPrimaryAggressor",
performAttack,
"setStateTo: LOOK_FOR_TARGETS",
);
ECM = (
"setStateTo: LOOK_FOR_TARGETS",
);
"TARGET_DESTROYED" = (
switchLightsOn,
"consoleMessage3s: Krypton Mine - target destroyed.",
"awardShipKills: 1",
"setStateTo: LOOK_FOR_TARGETS",
);
"TARGET_LOST" = (
switchLightsOn,
"consoleMessage3s:: Krypton Mine - target lost.",
"setStateTo: LOOK_FOR_TARGETS",
);
UPDATE = (
checkEnergy,
"pauseAI: 0.8",
);
};
DETONATE = {
ENTER = (
"commsMessage: Krypton Mine - Detonating press ecm to cancel.",
"pauseAI: 1",
"commsMessage: Krypton Mine - Detonating in 3.",
"pauseAI: 1",
"commsMessage: Krypton Mine - Detonating in 2.",
"pauseAI: 1",
"commsMessage: Krypton Mine - Detonating in 1.",
"pauseAI: 1",
"commsMessage: Krypton Mine - Detonating in 0.",
becomeExplosion,
);
UPDATE = ();
ECM = (
"setStateTo: LOOK_FOR_TARGETS",
);
EXIT = ();
};
"DETONATE_NOW" = {
ENTER = (
"commsMessage: Krypton Mine - Detonating.",
"setDesiredRangeTo: 200",
"dealEnergyDamageWithinDesiredRange",
becomeExplosion,
);
UPDATE = ();
EXIT = ();
};
}