AI Scripting for mine/turret

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
McSpider
Average
Average
Posts: 14
Joined: Tue Sep 22, 2009 10:45 pm
Location: Milky Way Galaxy

AI Scripting for mine/turret

Post by McSpider »

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

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
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.

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 = ();
	};
}
If some one could tell me what I did wrong I'd be very grateful.
McSpider
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

AI commands between brackets (multiple commands for a single event like ENTER or UPDATE) are an array. So you need to remove the trailing comma at the end of the lists in each one. For example

Code: Select all

ENTER = (
         switchLightsOff,
         performStop,
         "setStateTo: LOOK_FOR_TARGETS",
      ); 
should read

Code: Select all

ENTER = (
         switchLightsOff,
         "setSpeedfactorTo: 1.0",
         performStop,
         "setStateTo: LOOK_FOR_TARGETS"
      ); 
Note the lack of comma after "setStateTo: LOOK_FOR_TARGETS".

AIs are notoriously finicky about spelling and punctuation, and can be "interesting" to debug as a result. In that case above you may also be better to move the setStateTo into UPDATE (and remove the comma after performStop as it would then be the last command in the array), but that's just a personal code style.

You've also got a few other commands that look to me to be in the wrong events (the setTargetToFoundTarget in LOOK_FOR_TARGETS for example), and your detonate code needs to be across several states. So overall I'd re-write it to:

Code: Select all

{
   GLOBAL = {
      ENTER = (
         switchLightsOff,
         "setSpeedFactorTo: 1.0",
         performStop
      );
      EXIT = ();
      UPDATE = ( "setStateTo: LOOK_FOR_TARGETS");
   };
   "LOOK_FOR_TARGETS" = {
      ENTER = (
         "consoleMessage3s: Mine Ready - searching for targets.",
         "setDesiredRangeTo: 50000",
         switchLightsOn,
         "scanForNearestShipHavingAnyRole: thargoid thargorn hardpirate pirate"
      );
      "TARGET_FOUND" = (
         "setTargetToFoundTarget",
         "consoleMessage3s: Krypton Mine - target found.",
         "setStateTo: DEFEND_SHIP"
      );
      "NOTHING_FOUND" = (
         "consoleMessage3s: Krypton Mine - no target found.",
         "pauseAI: 4",
         "setStateTo: DETONATE"
      );
      EXIT = ();
      UPDATE = (
         "scanForNearestShipHavingAnyRole: thargoid thargorn hardpirate pirate"
         "pauseAI: 5.0"
      );
   };

   "DEFEND_SHIP" = {
      ENTER = (
         switchLightsOn,
         "setTargetToFoundTarget",
         performAttack,
         "consoleMessage3s: Krypton Mine - attacking target."
      );
      "ENERGY_LOW" = (
         "consoleMessage3s: Krypton Mine - energy low self detonating.",
         "setStateTo: DETONATE_NOW"
      );
      "INCOMING_MISSILE" = (
         switchLightsOff,
         "consoleMessage3s: Krypton Mine - being attacked.",
         fireECM,
         "setTargetToPrimaryAggressor",
         "setStateTo: DEFEND_SHIP"
      );
      ATTACKED = (
         switchLightsOff,
         "setTargetToPrimaryAggressor",
         "setStateTo: DEFEND_SHIP"
      );
      ECM = (
         "setStateTo: LOOK_FOR_TARGETS"
      );
      "TARGET_DESTROYED" = (
         switchLightsOn,
         "consoleMessage3s: Krypton Mine - target destroyed.",
         "setStateTo: LOOK_FOR_TARGETS"
      );
      "TARGET_LOST" = (
         switchLightsOn,
         "consoleMessage3s:: Krypton Mine - target lost.",
         "setStateTo: LOOK_FOR_TARGETS"
      );
      UPDATE = (
         checkEnergy,
         "pauseAI: 2.0"
      );
   };

   DETONATE = {
      ENTER = (
         "commsMessage: Krypton Mine - Detonating press ecm to cancel.",
         "pauseAI: 1"
      );
      UPDATE = ("setStateTo: DETONATE3");
      ECM = (
         "setStateTo: LOOK_FOR_TARGETS"
      );
      EXIT = ();
   };

 DETONATE3 = {
      ENTER = (
         "commsMessage: Krypton Mine - Detonating in 3.",
         "pauseAI: 1"
      );
      UPDATE = ("setStateTo: DETONATE2");
      ECM = (
         "setStateTo: LOOK_FOR_TARGETS"
      );
      EXIT = ();
   };

 DETONATE2 = {
      ENTER = (
         "commsMessage: Krypton Mine - Detonating in 2.",
         "pauseAI: 1"
      );
      UPDATE = ("setStateTo: DETONATE1");
      ECM = (
         "setStateTo: LOOK_FOR_TARGETS"
      );
      EXIT = ();
   };

 DETONATE1 = {
      ENTER = (
         "commsMessage: Krypton Mine - Detonating in 1.",
         "pauseAI: 1"
      );
      UPDATE = ("setStateTo: DETONATE0");
      ECM = (
         "setStateTo: LOOK_FOR_TARGETS"
      );
      EXIT = ();
   };

 DETONATE0 = {
      ENTER = (
         "commsMessage: Krypton Mine - Detonating in 0.",
         "pauseAI: 1"
      );
      UPDATE = ("setStateTo: DETONATE_NOW");
      ECM = (
         "setStateTo: LOOK_FOR_TARGETS"
      );
      EXIT = ();
   };

   "DETONATE_NOW" = {
      ENTER = (
         "commsMessage: Krypton Mine - Detonating.",
         "setDesiredRangeTo: 200",
         "dealEnergyDamageWithinDesiredRange",
         becomeExplosion
      );
      UPDATE = ();
      EXIT = ();
   };
}
That's just a rough AI, which I stress is entirely untested and may well not work exactly as planned (they rarely do first time!). But as I don't have the full package, I can't test it of course. But it may give you more guidance as to how to put it together anyway.

I've taken a few things out (like the awardKills and the fines) as they probably shouldn't be in there for such an item. And you need to spread things out across the states, and have different states for things like the detonation. Also it's not good to put messages and such in so often. You'll end up spamming the screen, especially if they go into UPDATE as that line can run anything up to 4x per second (depending on pauseAI commands.

Also the ATTACKED_BY_CLOAKED is normally used to make a ship flee, as you cannot lock onto a cloaked ship to attack it. But of course in this case that doesn't make any sense, so I've removed it for the moment.

But anyway that should hopefully put you at least one step in the right direction.
Last edited by Thargoid on Sat Nov 07, 2009 11:16 am, edited 2 times in total.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: AI Scripting for mine/turret

Post by Commander McLane »

Hi, McSpider!

The first step would be to check whether your mine actually gets the correct AI. Perhaps you made a typo in its ai_type key?

If you've got Debug.oxp installed, it is very easy to monitor the mine with the Target Inspector. Simply target your released mine, and choose "Inspect Target" from the Debug menu.

This opens a small window next to the Oolite window, which shows you a lot of information about the mine, including its current AI. Clicking on the small "i" next to the "AI" in this window opens another window with more information about the current AI state, pending AI messages, and the current behaviour.

Here's your syntax problem: There must be no comma after the last item of an array (read: after the last method inside any of the message parts). Therefore
ENTER = (
"consoleMessage3s: Mine Ready - searching for targets.",
"setDesiredRangeTo: 50000",
switchLightsOn,
"scanForNearestShipHavingAnyRole: thargoid thargorn hardpirate pirate",
"setTargetToFoundTarget",
);

automatically leads to a syntax error, and Oolite not being able to even use the plist. Which explains why you don't see anything happening. Your AI is not a working plist.

Together with the Target Inspector you should use your log file. I'm sure this error is mentioned and explained there. General advice: If you are writing any kind of script, the first step of debugging is to read your log file. Chances are that it explains you what you are doing wrong.

Second, there are a couple of typos or wrong methods in your AI. For instance it is "setSpeedFactorTo:", not "setSpeedfactorTo:". I suggest you check your AI against the OXP howto AI-page on the Wiki, which is the official documentation of everything concerning AI. Another problem is that "commsMessage:" doesn't work with your mine, because there is no pilot sitting in it who can send messages. If you want an unpiloted entity to communicate, you have to use the method "commsMessageByUnpiloted:" instead. This is also documented on the Wiki page I linked to.

Third, you haven't scripted your AI along your intentions. Take for instance the first four lines of your "flow diagram":

Code: Select all

Gets launched from players ship. 
Pause ai 2 sec. 
Turns on lights. 
perform stop
Where is the "Pause ai 2 sec." in your AI? It's not there. If you want the AI to pause, before it does anything, your GLOBAL state should look like this:

Code: Select all

    GLOBAL = {
        ENTER = ("pauseAI: 2.0"); 
        UPDATE = ("setStateTo: LOOK_FOR_TARGETS"); 
    };
Note that any "pauseAI:" method is not executed as an immediate pause (that's what I mistakenly assumed when I started with AI scripting), but merely sets the interval until the next "UPDATE" message is sent to the AI. Therefore, if you want your entity to effectively pause, you have to put, whatever it is supposed to do after pausing, in the "UPDATE" part of your AI state. And usually you should then leave this state (like in my example), because if you don't, whatever you put in "UPDATE", will be executed again after another two seconds. And again. And again.

Another issue is that

Code: Select all

         "setSpeedFactorTo: 1.0", 
         performStop, 
actually doesn't make sense. If you want it to fly, you need to employ a method that makes it fly, not stop. And if you want it stop, you need a speed factor of 0, not 1. According to what you indicate in your diagram, I think can safely remove the "setSpeedFactorTo: 1.0", because the backwards velocity of the mine, which purely comes from being ejected, will be enough to let it get some distance from your ship. The "performStop" could perhaps do in the "ENTER" message of your "LOOK_FOR_TARGETS" state.

And you should rewrite the "LOOK_FOR_TARGETS" in a way, that you move all scanning from the "ENTER" message to the "UPDATE" message, which does not need another "setStateTo:", because it is repeated over and over again anyway. You should, however, set an appropriate interval for the repetition through a "pauseAI:" in its "ENTER" part. Something between 2 and 5 seconds should be sufficient.

I see that you only want a one-time search. Are you sure about this?

Another thing: "setTargetToFoundTarget" confirms a target after it was found. So it is only useful in the "FOUND_TARGET" message.

So "LOOK_FOR_TARGETS" should look something like this:
"LOOK_FOR_TARGETS" = {
ENTER = (
"consoleMessage3s: Mine Ready - searching for targets.",
switchLightsOn,
"setDesiredRangeTo: 50000",
"pauseAI: 5.0",
);
"TARGET_FOUND" = (
setTargetToFoundTarget,
"consoleMessage3s: Krypton Mine - target found.",
"setStateTo: DEFEND_SHIP"
);
"NOTHING_FOUND" = (
"consoleMessage3s: Krypton Mine - no target found.",
"setStateTo: DETONATE"
);
EXIT = ();
UPDATE = (
"commsMessageByUnpiloted: Krypton Mine - searching for targets.",
"scanForNearestShipHavingAnyRole: thargoid thargorn hardpirate pirate"
);
};
All in all I think the mine is way too chatty. It will flood the player's screen with messages, which is generally not good in combat, when you want to actually see your opponents. You should think about that.

Okay, try to improve the AI along the lines outlined here, and please report back.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Hi McSpider,

I have not read all the previous advise but commsMessages are only send by ships that contain a pilot. And when using missiles they probably have not. So explicitly add a pilot to your missile in shipdata (sounds wrong) or use the "commsMessageByUnpiloted" (Look in the wiki for correct syntax.)

I don't know the status of consoleMessage3s. It could be that that one also looks if the ship/missile has a pilot.

On the ending comma I just can say: Some computers accept it and others don't. When you run for example Mac OSX.5 it is allowed but with OSX.4 the plist won't even load. Without the comma is runs on all platforms without troubles.

And you can just remove all the empty EXIT = (); and UPDATE = (); lines. They do nothing but make reading the plist more difficult.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Looking at your code I notice the DETONATE state can not work. pauseAI works different than you think. It adds not a pause to code execution at that point but sets the time for the next UPDATE to be executed. This is probably the most difficult part in understanding how AI works. I rewrote that state to something that should work. (not tested)

Code: Select all

   DETONATE = { 
      ENTER = ("messageSelf: STAGE_1"); 
	"STAGE_1" = (
			"commsMessage: Krypton Mine - Detonating press ecm to cancel.",
			"pauseAI: 1",
			"messageSelf: STAGE_2"
	);
	"STAGE_2" = (
			"commsMessage: Krypton Mine - Detonating in 3.",
			"pauseAI: 1",
			"messageSelf: STAGE_3"
	);
	"STAGE_3" = (
			"commsMessage: Krypton Mine - Detonating in 2.",
			"pauseAI: 1",
			"messageSelf: STAGE_4"
	);
	"STAGE_4" = (
			"commsMessage: Krypton Mine - Detonating in 1.",
			"pauseAI: 1",
			"messageSelf: STAGE_5"
	);
	"STAGE_5" = (
			"commsMessage: Krypton Mine - Detonating in 0.",
			"pauseAI: 1",
			"messageSelf: STAGE_6"
	);
	"STAGE_6" = (becomeExplosion);
      ECM = ( 
         "setStateTo: LOOK_FOR_TARGETS", 
      ); 
   }; 
Every message sends itself a new message to be called on the next UPDATE that is activated after a 1 second delay. There does not even need to be a UPDATE = (); entry present in that state to update the state.
Last edited by Eric Walch on Sat Nov 07, 2009 10:49 am, edited 2 times in total.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

BTW, would you AI boffins like a tool to produce AI transition diagrams like this? (Like various similar graphs produced by Oolite, it would be produced as a text file to be processed with Graphviz – specifically, the “dot” tool.) I thought I’d ask before implementing it, as a change of pace. :-)
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Talking as a non-AI boffin: yay! :P
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2483
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

the 'becomeExplosion' written at the end of that complex looking chart makes me laugh for some reason :D I might start charting my daily life in the format, eg ' I went to the shop to buy bread but they were all sold out -> becomeExplosion'
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

I was thinking something quite similar, except mine involves being stuck in all weekend with the kids, plus 6 others tomorrow for the eldest's birthday party ;)

Although I get the feeling becomeEnergyBlast would be more appropriate, except being ill energy is the last thing I have at the moment.
User avatar
Disembodied
Jedi Spam Assassin
Jedi Spam Assassin
Posts: 6885
Joined: Thu Jul 12, 2007 10:54 pm
Location: Carter's Snort

Post by Disembodied »

Code: Select all

(becomeBetter);
:D
User avatar
McSpider
Average
Average
Posts: 14
Joined: Tue Sep 22, 2009 10:45 pm
Location: Milky Way Galaxy

Post by McSpider »

Thanks for the replies.
I'll download Debug.oxp and fix the errors mentioned.
Thargoid wrote:
Also it's not good to put messages and such in so often. You'll end up spamming the screen
I put in the messages to let me see in which state the mine currently is in.
Thargoid wrote:
So you need to remove the trailing comma at the end of the lists in each one.
I didn't add the commas the Mac "Property List Editor" adds them like that.
And if I remove them In "Text Edit" it adds them again if I open and save it in the "Property List Editor".
McSpider
User avatar
Kaks
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 3009
Joined: Mon Jan 21, 2008 11:41 pm
Location: The Big Smoke

Post by Kaks »

Hmm, the plist editor is just slightly evil then! There's a variety of free text editors for the mac you could try. I believe the most promising are listed on the wiki somewhere, but sadly can't remember where...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
User avatar
DaddyHoggy
Intergalactic Spam Assassin
Intergalactic Spam Assassin
Posts: 8515
Joined: Tue Dec 05, 2006 9:43 pm
Location: Newbury, UK
Contact:

Post by DaddyHoggy »

Kaks wrote:
Hmm, the plist editor is just slightly evil then! There's a variety of free text editors for the mac you could try. I believe the most promising are listed on the wiki somewhere, but sadly can't remember where...
To beat Commander McLane to the punch (for once) - the very end one of this list apparently (non-Mac user):

http://wiki.alioth.net/index.php/List_of_software
Selezen wrote:
Apparently I was having a DaddyHoggy moment.
Oolite Life is now revealed here
User avatar
McSpider
Average
Average
Posts: 14
Joined: Tue Sep 22, 2009 10:45 pm
Location: Milky Way Galaxy

Post by McSpider »

I have the autopilot working now but it won't accredit the kills it makes to me. I added is_submunition to "shipdata.plist" but that doesn't work.
I also have a sub entity (a shield ring) how do I make that send a attacked message to its parent when attacked?
Also it appears that checkEnergy is depreciated.

Code: Select all

[ai.unpermittedMethod]: Handler "UPDATE" for state "DEFEND_SHIP" in AI "KryptonDefenseMine.plist" uses "checkEnergy", which is not a permitted AI method. In a future version of Oolite, this method will be removed from the handler. If you believe the handler should be a permitted method, please report it to [email protected].
[ai.unpermittedMethod]: Handler "ENTER" for state "LOOK_FOR_TARGETS" in AI "KryptonDefenseMine.plist" uses "checkEnergy", which is not a permitted AI method. In a future version of Oolite, this method will be removed from the handler. If you believe the handler should be a permitted method, please report it to [email protected].
Anyway here's a link to a beta.
Krypton Mine 0.2b
Last edited by McSpider on Sun Nov 08, 2009 11:45 pm, edited 1 time in total.
McSpider
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Post by Thargoid »

McSpider wrote:
I have the autopilot working now but it won't accredit the kills it makes to me. I added is_submunition to "shipdata.plist" but that doesn't work.
It's a separate entity, so generally it won't add kills. This can however be done (see my hired guns or drones OXPs for examples), most simply via js. You can probably do it in AI via safeScriptActionOnTarget having targetted the player ship first.

The is_submunition key is for weapons that are spawned from other weapons (e.g. bomblets from a cluster bomb), which isn't the case here.

McSpider wrote:
I also have a sub entity (a shield ring) how do I make that send a attacked message to its parent when attacked?
If it's a sub-ent, then technically it's part of the ship. So there is no "parent", attacking the sub-ent is attacking the ship.
McSpider wrote:
Also it appears that checkEnergy is depreciated.

Code: Select all

[ai.unpermittedMethod]: Handler "UPDATE" for state "DEFEND_SHIP" in AI "KryptonDefenseMine.plist" uses "checkEnergy", which is not a permitted AI method. In a future version of Oolite, this method will be removed from the handler. If you believe the handler should be a permitted method, please report it to [email protected].
[ai.unpermittedMethod]: Handler "ENTER" for state "LOOK_FOR_TARGETS" in AI "KryptonDefenseMine.plist" uses "checkEnergy", which is not a permitted AI method. In a future version of Oolite, this method will be removed from the handler. If you believe the handler should be a permitted method, please report it to [email protected].
That's not quite true, if you look at the message it says it's not a permitted method, rather than a depreciated one. And if you look in the wiki closely you will see:
The Wiki wrote:
Checks the energy level and returns: ENERGY_LOW (energy< 25%), ENERGY_MEDIUM (25%<energy<75%), ENERGY_HIGH (75%<energy<100%) or ENERGY_FULL (energy = 100%). Added with Oolite 1.74
So unless you're running a self-build 1.74 trunk rather than a test release 1.73.4, it's not that checkEnergy is depreciated, more that it doesn't actually exist yet ;). And if you are running 1.74, then it sounds like the implementation isn't quite right yet, but that's one for the dev's.
Post Reply