AI Help Please

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

Moderators: winston, another_commander

User avatar
matt634
Deadly
Deadly
Posts: 206
Joined: Tue Mar 21, 2006 6:32 pm
Location: Colorado, USA

AI Help Please

Post by matt634 »

Hi All,

I've been working on a convoy oxp that adds groups of merchant ships outfitted with turrets (including some very nasty galcop transports) to the oonivese. I've got everything up and running except for one annoying feature in my ai that I can't seem to fix.

Is there a way to script the ai so that when one ship in the convoy is attacked the other ships will then attack the hostile? Currently, this only happens with the galcop transports, because the attacker then becomes an offender and is targeted by the other transports using "scanForOffenders".

I've tried using the distress call but with no results. Any ideas?

Thanks
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 »

I've been working on a convoy oxp that adds groups of merchant ships outfitted with turrets (including some very nasty galcop transports) to the oonivese. I've got everything up and running except for one annoying feature in my ai that I can't seem to fix.

Is there a way to script the ai so that when one ship in the convoy is attacked the other ships will then attack the hostile? Currently, this only happens with the galcop transports, because the attacker then becomes an offender and is targeted by the other transports using "scanForOffenders".
I have been working on the same problem the last few days. I didn't find a real solution. If the scanClass of your ship is police, things are easy. Than the ship will react on distresscalls and offenders.

I have been working with "groupAttack". That didn't work as I placed each item separately. To be precisely in a square on the planet surface.

But if you ad your ships in one command as a group, things should work, I think.

LOOP = {ENTER=();
ATTACKED = (setTargetToPrimaryAgressor, groupAttackTarget);
"GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP";
}

If all the ships are in this AI loop, than the attacked ship will call for a groupattack and set the value "GROUP_ATTACK_TARGET" to true. Then it will respond on its own call and also the others of the group.

I did only test it with separate added ships, but the are not seen as a group. But the pirate AI script uses something like this and they work as group.
User avatar
matt634
Deadly
Deadly
Posts: 206
Joined: Tue Mar 21, 2006 6:32 pm
Location: Colorado, USA

Post by matt634 »

Eric Walch wrote:
But if you ad your ships in one command as a group, things should work, I think.
I've tried several different addship commands(addSystemShips, addShipsWithinRadius, addShipsAt) with no luck on the groupattack working. The ships are there, but I can still single them out without the other ships responding... kinda defeats the protective purpose of a convoy.

Here's the ai I've been tinkering with:
{
"HEAD_FOR_PLANET" = {
ENTER = (setCourseToPlanet, "setDesiredRangeTo: 30000.0", "setSpeedFactorTo: 0.35", checkCourseToDestination);
"COURSE_OK" = ("setSpeedFactorTo: 0.65", performFlyToRangeFromDestination);
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
"AEGIS_CLOSE_TO_PLANET" = ("setStateTo: GO_TO_STATION");
"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, "setStateTo: GO_TO_STATION");
"DESIRED_RANGE_ACHIEVED" = ("setStateTo: GO_TO_STATION");
"TARGET_FOUND" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget);
"INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, broadcastDistressMessage, deployEscorts, groupAttackTarget);
ATTACKED = (setTargetToPrimaryAggressor, broadcastDistressMessage, groupAttackTarget);
"GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP");
UPDATE = (setCourseToPlanet, "setDesiredRangeTo: 50000.0", checkCourseToDestination, scanForHostiles, "pauseAI: 10.0");
EXIT = ();
};

"GO_TO_STATION" = {
ENTER = (setTargetToSystemStation, "setDesiredRangeTo: 5000.0", setDestinationToTarget, checkCourseToDestination);
"COURSE_OK" = ("setSpeedFactorTo: 0.5", performFlyToRangeFromDestination);
"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
"DESIRED_RANGE_ACHIEVED" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
"AEGIS_IN_DOCKING_RANGE" = (dockEscorts, setTargetToSystemStation, "setAITo: dockingAI.plist");
"TARGET_FOUND" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget);
"INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, deployEscorts, groupAttackTarget);
ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget);
"GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP");
UPDATE = (
setTargetToSystemStation,
"setDesiredRangeTo: 5000.0",
setDestinationToTarget,
checkCourseToDestination, scanForHostiles, "pauseAI: 10.0"
);
EXIT = ();
};

"ATTACK_SHIP" = {
"ENERGY_LOW" = (setTargetToPrimaryAggressor, broadcastDistressMessage);
ENTER = (broadcastDistressMessage, performAttack);
EXIT = ();
"INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, deployEscorts, performAttack);
"TARGET_DESTROYED" = ("setStateTo: HEAD_FOR_PLANET");
"TARGET_LOST" = ("setStateTo: HEAD_FOR_PLANET");
UPDATE = ();
};
GLOBAL = {ENTER = (setUpEscorts, "setStateTo: HEAD_FOR_PLANET"); EXIT = (); UPDATE = (); };
}
Any ideas?
User avatar
matt634
Deadly
Deadly
Posts: 206
Joined: Tue Mar 21, 2006 6:32 pm
Location: Colorado, USA

Post by matt634 »

WOW!

I've got a whole new frustration now. I went into the shipdata and removed the escorts from my transport and removed its police scan class to simplify things. I load my play test save and NOTHING CHANGED! The transports still had their escorts and were still purple! What's going on. Is there some kind of spite action hard coded in the game.

Please, help before I move to something more irrational than just cursing a computer program.
User avatar
Captain Hesperus
Grand High Clock-Tower Poobah
Grand High Clock-Tower Poobah
Posts: 2310
Joined: Tue Sep 19, 2006 1:10 pm
Location: Anywhere I can sell Trumbles.....

Post by Captain Hesperus »

I believe that purging the cache file will result in the changes taking place. If you press shift when starting up Oolite, this should cause Oolite to dump it's cache file and build a new one. One that has your changes in it.

I think.

Captain Hesperus
The truth, revealed!!
Image
User avatar
matt634
Deadly
Deadly
Posts: 206
Joined: Tue Mar 21, 2006 6:32 pm
Location: Colorado, USA

Post by matt634 »

The solution was actually easier, and not due to any malicious intent on oolite's part (as I had believed), but was my own fault :roll:
I had copied the shipdata entry out of an older oxp I was using and never deleted the entry out of the old oxp.
So that's fixed, now if I could just solve my original problem!
User avatar
Helvellyn
Dangerous
Dangerous
Posts: 118
Joined: Wed Jul 11, 2007 11:59 pm
Location: Qudira
Contact:

Post by Helvellyn »

Captain Hesperus wrote:
I believe that purging the cache file will result in the changes taking place. If you press shift when starting up Oolite, this should cause Oolite to dump it's cache file and build a new one. One that has your changes in it.

I think.
If you're right it'll save me a lot of bother. I've been shifting a spare OXP back and forth every time I've wanted to test my ArcElite one.
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 »

I've tried several different addship commands(addSystemShips, addShipsWithinRadius, addShipsAt) with no luck on the groupattack working. The ships are there, but I can still single them out without the other ships responding... kinda defeats the protective purpose of a convoy.
You are right. I tried it also with a simplified AI and just adding a group of ships in one command does not make them a group. It seems not possible to create a group with a script. The pirateAI uses groupsattack commands, but those ships are probably only a group as the populating machine of oolite adds them.

As you also noted is the variable "OFFENCE_COMMITTED" only set to true if the command "scanForOffenders" is used by a ship with scanClass: POLICE.

In the route1PatrolAI there is also a variable "ACCEPT_DISTRESS_CALL". I never figured out how it worked. I don't even think it works in the route1PatrolAI script, as the AI will also react on the "OFFENCE_COMMITTED" that is placed in the same state.
User avatar
matt634
Deadly
Deadly
Posts: 206
Joined: Tue Mar 21, 2006 6:32 pm
Location: Colorado, USA

Post by matt634 »

I've tried the ACCEPT_DISTRESS_CALL from route1patrol and "acceptDistressMessageFrom: ShipEntity" listed in the wiki with no results. When I first hit upon the idea I thought it was a genius stroke; unfortunately, it looks like something only the game engine can use.

The group attack would be great if we knew how to create a group. Anybody have any knowledge on the subject?
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:

Post by Commander McLane »

I have a very similar headache with an OXP of mine, which is also still not resolved yet, stalling the release of this OXP for a couple of months now.

In my case it's a group of defensive asteroids placed around a large asteroid that don't defend their mother as intended. I've tried it all: letting them scan for offenders (which seems to work sometimes, but not in a predictable way), ACCEPT_DISTRESS_CALL (which had no result at all) and a couple of things more.

A critical point seems to be that entities need to be escorts of another entity, in order to be able to act as a group. It seems to work with the escorts set up by the engine, and it seems to work as well with escorts of OXP-generated ships. I'm not sure, however, if these escorts will need 'escort' as one of their roles.

If you set them up as escorts, you run into the next problem. By default the engine will give every entity that is called as an escort escortAI, overriding any custom AI specified in its shipdata. This problem is not yet resolved with a new shipdata-key, but there is a work-around. You can use setAITo:, placed in an array called launch_actions in the shipdata. The whole thing should look like this

Code: Select all

		<key>launch_actions</key>
		<array>
			<string>setAITo: myCustomAI.plist</string>
		</array>
, myCustomAI.plist being the same you would usually use for the ai_type-key. When I used this I ran into the next problem that my asteroids were set up as escorts of their mother, and also could act as a group, but their subentities weren't there, namely the ballturrets they are using as a weapon. :( So they still couldn't fight. This problem is now in the queue of problems-that-need-to-be-fixed, but so far hasn't been resolved yet. Of course it won't affect you if your ships don't have subentities.

Hope this is of some help. And: good luck (and patience!) while OXPing! :)
User avatar
LittleBear
---- E L I T E ----
---- E L I T E ----
Posts: 2882
Joined: Tue Apr 04, 2006 7:02 pm
Location: On a survey mission for GalCop. Ship: Cobra Corvette: Hidden Dragon Rated: Deadly.

Post by LittleBear »

If you gave the asteroid-base station scan class and a zero bounty and also gave the asteroid guard-turrets a:-

Code: Select all

"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP");
That should get them fireing on anyone who fires on the base. Haven't tested it though, but as police ships will fire on someone they spot fireing on a clean ship, it ought to work.
OXPS : The Assassins Guild, Asteroid Storm, The Bank of the Black Monks, Random Hits, The Galactic Almanac, Renegade Pirates can be downloaded from the Elite Wiki here.
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 »

LittleBear wrote:
If you gave the asteroid-base station scan class and a zero bounty and also gave the asteroid guard-turrets a:-

Code: Select all

"OFFENCE_COMMITTED" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP");
That should get them fireing on anyone who fires on the base. Haven't tested it though, but as police ships will fire on someone they spot fireing on a clean ship, it ought to work.
I don't think so. I have tried "OFFENCE_COMMITTED" on several testships but the ship only reacted if ScanClass was Police. And probably Station as well. Without scanClass or even with scanClass Military the "OFFENCE_COMMITTED" is not set. So it only works if the asteroids also have scanclas police or station. Both are probably unwanted. You are then immedeately Fugitive is you fire on a asteroid.
User avatar
matt634
Deadly
Deadly
Posts: 206
Joined: Tue Mar 21, 2006 6:32 pm
Location: Colorado, USA

Post by matt634 »

When I used this I ran into the next problem that my asteroids were set up as escorts of their mother, and also could act as a group, but their subentities weren't there, namely the ballturrets they are using as a weapon.
I noticed that funny glitch as well when I was trying to create a carrier group by assigning escort frigates to behemoths. The frigates show up, but for some reason that I was unable to fix, ships placed as escorts will not have turrets.
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 »

      <key>launch_actions</key>
      <array>
         <string>setAITo: myCustomAI.plist</string>
      </array>
That is new to me and many others. I looked in some other OXP's with escorts. I recently downloaded Transports v2.1 from Murgh.

He gives his escorts a special AI but if I look at the actual AI with a object dump I see they are flying with a standard escortAI. Adding your lines to the shipdata I see with a objectdump, that the escorts get the AI that was intended.
In this case it does not matter as his linerescortAI is an exact copy of the escortAI.

The same I noticed with the Behemoth. It has also his own AI. The included script only places the ship near the witchpoint. Than it runs under its intended script. But I have also seen him running under a route1patrolAI In that case it was added by oolite with one of its roles. Probably this launch_actions will also let him maintain its intended AI.

Looking further in escort ships I noticed that "Executive Spaceways v2.1.oxp" has also a flaw. He puts the description.plist in the AI folder instead of the config folder. So I tried firing a missile on the liner. Instead of shouting its plea, it shouts the name of the variable. Please put this description.plist file in the right place in the next version, or it will not work. At least not on my mac system.
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:

Post by Commander McLane »

Eric Walch wrote:
      <key>launch_actions</key>
      <array>
         <string>setAITo: myCustomAI.plist</string>
      </array>
That is new to me and many others. I looked in some other OXP's with escorts. I recently downloaded Transports v2.1 from Murgh.

He gives his escorts a special AI but if I look at the actual AI with a object dump I see they are flying with a standard escortAI. Adding your lines to the shipdata I see with a objectdump, that the escorts get the AI that was intended.
In this case it does not matter as his linerescortAI is an exact copy of the escortAI.

The same I noticed with the Behemoth. It has also his own AI. The included script only places the ship near the witchpoint. Than it runs under its intended script. But I have also seen him running under a route1patrolAI In that case it was added by oolite with one of its roles. Probably this launch_actions will also let him maintain its intended AI.
Indeed, those are the problems. The matter of OXP-ships added by the engine in one of their roles during the usual process of populating the Ooniverse is addressed with the new auto-ai-key. Look here and here for the discussion.

The second matter of escorts always having escortAI and the workaround is addressed here (same thread as the first link, in both cases you should read the preceding and following posts as well; and this 'Progress'-thread is where you will find everything Ahruman has done with the code).
Post Reply