Help with using update and performAttack in AI.
Posted: Sun Dec 07, 2008 12:14 pm
Having got my bars and hunters to break off from friendly fire incidents, I've told the bars to use their turrets on any pirates / criminals / thargoids they detect as well as launching hunters. The problem I'm finding is that whilst in performAttack the bar does not execute any other Commands until the target is destroyed or lost. As the bar cannot move and its turrets only have a range of 5km a problem is that the bar may lock onto a target 6 km away and go to performAttack, but it cannot hit the target as its out of range. What I'm trying to do is use update, so the bar only spends 6.5 seconds in the attack phase without requesting a new target. This works fine if a target is in range. The bar fires a 1.5 second burst of turret fire, launches a hunter and then re-engages with its turrets.However, if a target is out of range it just points its turrets at the target, doesn't launch any ships (as no other commands in the state are read until the performAttack is completed) and the update which should take it out of performAttack is only read when the ship is destroyed. I've playtested by helping it out by blasting its out of range target and as soon as I kill it, the update is read. Tried using FRUSTRATED =, but this doesn't seem to be acted upon. I'd assumed it would get frustrated if it has a target that's too far away to hit, but it doesn't seem to. Here's the AI. Any idea's anyone? The Bar is always on Red Alert when entering the ATTACK1 state, so three decreeseAlterLevels take it out of attack. This works, but the update is not read until performAttack is complete, which it never is if the target is out of range of the bars turrets!
[/code]
Code: Select all
"ATTACK" = {
"ENTER" = ("commsMessage: Attack1", "launchShipWithRole: random_hits_patrol", "pauseAI: 1.0");
UPDATE = ("setStateTo: ATTACK2");
"EXIT" = (); };
"ATTACK2" = {
"ENTER" = ("commsMessage: attack2", "launchShipWithRole: random_hits_patrol", checkTargetLegalStatus, increaseAlertLevel, performAttack, "pauseAI: 0.5");
"TARGET_CLEAN" = ("sendTargetCommsMessage: [random_hits_bar_sorry_for_friendly_fire]", setTargetToSystemStation, "setStateTo: SCAN_FOR_CRIMINAL_PLAYER");
"ENEMY_ATTACK" = (setTargetToFoundTarget, "sendTargetCommsMessage: [spacebar-warning]", "markTargetForOffence: 51", increaseAlertLevel, performAttack);
"INCOMING_MISSILE" = (fireECM, setTargetToFoundTarget, "sendTargetCommsMessage: [spacebar-warning]", "markTargetForOffence: 51", increaseAlertLevel);
"LAWFULL_ATTACK" = (setTargetToFoundTarget, "safeScriptActionOnTarget: setAITo: randomhitsbreakoffAI.plist", setTargetToSystemStation, "setStateTo: SCAN_FOR_CRIMINAL_PLAYER");
"NO_TARGET" = (setTargetToSystemStation, "setStateTo: SCAN_FOR_CRIMINAL_PLAYER");
"RED_ALERT" = ("launchShipWithRole: random_hits_patrol");
"CONDITION_GREEN" = (setTargetToSystemStation, "setStateTo: SCRAMBLE_PAUSE");
"TARGET_DESTROYED" = (setTargetToSystemStation, "setStateTo: SCAN_FOR_CRIMINAL_PLAYER");
"TARGET_LOST" = (setTargetToSystemStation, "setStateTo: SCAN_FOR_CRIMINAL_PLAYER");
"FRUSTRATED" = ("commsMessage: frustrated in attack", setTargetToSystemStation, "setStateTo: SCRAMBLE_PAUSE");
"UPDATE" = (decreaseAlertLevel);
"EXIT" =(); };
"SCRAMBLE_PAUSE" = {
"ENTER" = ("commsMessage: scramble pause", "launchShipWithRole: random_hits_patrol", "pauseAI: 5.0");
"ENEMY_ATTACK" = (setTargetToFoundTarget, "sendTargetCommsMessage: [spacebar-warning]", "markTargetForOffence: 51", increaseAlertLevel, "setStateTo: ATTACK");
"INCOMING_MISSILE" = (fireECM, setTargetToFoundTarget, "sendTargetCommsMessage: [spacebar-warning]", "markTargetForOffence: 51", increaseAlertLevel, "setStateTo: ATTACK");
"UPDATE" = (setTargetToSystemStation, "setStateTo: SCAN_FOR_CRIMINAL_PLAYER");
"EXIT" =(); };