Help wanted 3.0: AI.plist vs. role revisited

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

Moderators: winston, another_commander

Post Reply
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

Help wanted 3.0: AI.plist vs. role revisited

Post by Lestradae »

So, again, (three) questions for those who know these things.

Potential problem 1: Death Actions.

I understand that they are somehow massively deprecated and don`t work properly. For my OXP to rewrite them all is not thinkable due to size.

Two possible solutions spring to (my) mind:

One, let them stand as they stand. If parts of them work, good. If they don`t, at least they don`t damage anything. But that clutters.

Two, I could simply remove all the death actions. A bit radical, but doesn`t clutter and if they won`t work properly with 1.70+ anymore, well ...

Three? Suggestions?

Potential problem 2: Bounties.

I believe I read somewhere that criminals get bounties assigned anyways.

Would it make sense to just remove the bounties entries and let the game determine them due to role automatically, if that is what happens?

What do you people think?

Potential problem 3: Weird AI.plists.

After the SWATCondorAI.plist, I had a look and tried to understand how they work. And there are quite a few that do rather ... creative ... things.

Hm. I thought there was talk about some kind of default AI that could be entered into the AI line in shipdata that would lead to the game choosing a fitting AI according to role, is that right?

I see two solutions again.

One, put the default AI (if it exists) into the shipdata instead of too-funky AIs I inherited from some of the merged ship-OXPs` authors.

Two, I could put in the default AI for given roles according to role. For example, give the SWATCondor, that is intended to be police, the patrol1routeAI.plist and so on.

Good ideas, bad ideas?

Looking forward to feedback on how to solve those questions 8)

L
Last edited by Lestradae on Fri Jun 20, 2008 10:50 am, edited 1 time in total.
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 »

On 1:-

DeathActions in shipdata don't work at all if the ship has a JavaScript attached. But I don't think any of Charlie's ships included in RS have a JS script attached. As I remember, he just used this to send comms messages along the lines of "Oh no, there goes my turret!" etc when sub-entries get blown off. Not sure that sub-entries are allowed death-actions anymore. Death Actions in shipdata for a main ship (rather than a subentry) still work, as I've tested Assassin's on 1.71.2 and its running OK. The worst that'll happen is the sub-entries won't send there comms messages, so you probabley could just ignore this. :wink: DeathActions are only needed if you want a ship to do somthing more than just die when it err dies! So unless you want to set a mission variable, send a comms message etc, you don't need to use death actions.

On 2:-

Yep. If you remove the bounty key completeley, that (should) work fine and the game will automaticaly give a ship a bounty if its called as a pirate. However the automatic bounty is quite low. I think its random between about 5 and 30 credits, so if you want to give a higher bounty for a particulary tough ship (eg a SuperCobra Pirate), you'd need to have a sepearte entry like-shiped with just the bounty key and only having the role pirate.

On 3:-

If autoAI is set to true (which it is by default), the ship will automatoically get the AI approprate (a pirateAI if called as a pirate, policeAI if called as a cop). However route1partrol is probabley a bad choice for carriers as the ship will try to dock on reaching the station. Bear in mind that all the ships in the native game are small enough to dock easily. Only Vipers and bounty hunters such as the Cobra would be given this in the un-expanded game. With a really big ship it'll need a modified AI. For the Condor, giving it the role police will cause it to be launched by station as well. Better would be to give it a custom role and place it by script. If you don't want to faff around with adding a script, then giving it the role police should work as long as you set autoAI to false and specify the custom AI in shipdata. If you want to avoid condors crashing into stations a customAI would be needed. I quick hack of route1patrol should do it. This is a very quick hack, but it would make the ship jump out rather than try to dock :-

Code: Select all

{
    "HEAD_FOR_PLANET" = {
		ENTER = (setCourseToPlanet, "setDesiredRangeTo: 50000.0", checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.8", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
        "DOCKING_REQUESTED" = (performHyperSpaceExit); 
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: HEAD_FOR_WITCHPOINT");
        "ACCEPT_DISTRESS_CALL" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget); 
        "OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", deployEscorts, groupAttackTarget); 
        "TARGET_FOUND" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget); 
        "INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, deployEscorts, groupAttackTarget, "setAITo: interceptAI.plist", "setStateTo: INBOUND_LOOT"); 
        ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget); 
        "GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setAITo: interceptAI.plist"); 
		UPDATE = (setCourseToPlanet, "setDesiredRangeTo: 50000.0", checkCourseToDestination, scanForOffenders, "pauseAI: 10.0");
		EXIT = ();
	}; 
    "HEAD_FOR_WITCHPOINT" = {
		ENTER = (setCourseToWitchpoint, checkCourseToDestination);
		"COURSE_OK" = ("setSpeedFactorTo: 0.8", performFlyToRangeFromDestination);
		"WAYPOINT_SET" = ("setAITo: gotoWaypointAI.plist");
        "DOCKING_REQUESTED" = (performHyperSpaceExit); 
		"DESIRED_RANGE_ACHIEVED" = ("setStateTo: HEAD_FOR_PLANET");
        "ACCEPT_DISTRESS_CALL" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget);
        "OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", deployEscorts, groupAttackTarget); 
        "TARGET_FOUND" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget); 
        "INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, deployEscorts, groupAttackTarget, "setAITo: interceptAI.plist", "setStateTo: OUTBOUND_LOOT"); 
        ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget); 
        "GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setAITo: interceptAI.plist"); 
		UPDATE = (setCourseToWitchpoint, checkCourseToDestination, scanForOffenders, "pauseAI: 10.0");
		EXIT = ();
	}; 
    "OUTBOUND_LOOT" = {
        "GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setAITo: interceptAI.plist"); 
        "DOCKING_REQUESTED" = (performHyperSpaceExit); 
        ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget); 
        ENTER = ("setSpeedTo: 0.0", performIdle); 
        EXIT = (); 
        "INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, deployEscorts, groupAttackTarget, "setAITo: interceptAI.plist", "setStateTo: OUTBOUND_LOOT"); 
        "TARGET_FOUND" = (setTargetToFoundTarget, "setAITo: collectLootAI.plist"); 
        "NOTHING_FOUND" = ("setStateTo: OUTBOUND_CHECK"); 
        UPDATE = (scanForLoot, "pauseAI: 10.0"); 
    }; 
    "INBOUND_LOOT" = {
        "GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setAITo: interceptAI.plist"); 
        "DOCKING_REQUESTED" = (performHyperSpaceExit); 
        ATTACKED = (setTargetToPrimaryAggressor, groupAttackTarget); 
        ENTER = ("setSpeedTo: 0.0", performIdle); 
        EXIT = (); 
        "INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, deployEscorts, groupAttackTarget, "setAITo: interceptAI.plist", "setStateTo: INBOUND_LOOT"); 
        "TARGET_FOUND" = (setTargetToFoundTarget, "setAITo: collectLootAI.plist"); 
        "NOTHING_FOUND" = ("setStateTo: INBOUND_CHECK"); 
        UPDATE = (scanForLoot, "pauseAI: 10.0"); 
    }; 
    "INBOUND_CHECK" = {
        ENTER = (scanForOffenders, checkForNormalSpace); 
        EXIT = (); 
        "OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", deployEscorts, groupAttackTarget); 
        "TARGET_FOUND" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget); 
        "GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setAITo: interceptAI.plist"); 
        RESTARTED = ("setStateTo: INBOUND_LOOT");
        "NORMAL_SPACE" = ("setStateTo: HEAD_FOR_PLANET"); 
        "INTERSTELLAR_SPACE" = ("setSpeedFactorTo: 1.0", "pauseAI: 15.0", "setStateTo: HYPER_OUT"); 
        UPDATE = (); 
    }; 
    "OUTBOUND_CHECK" = {
        ENTER = (scanForOffenders, checkForNormalSpace); 
        EXIT = (); 
        "OFFENCE_COMMITTED" = (setTargetToFoundTarget, "markTargetForOffence: 7", deployEscorts, groupAttackTarget); 
        "TARGET_FOUND" = (setTargetToFoundTarget, deployEscorts, groupAttackTarget); 
        "GROUP_ATTACK_TARGET" = (setTargetToFoundTarget, "setAITo: interceptAI.plist"); 
        RESTARTED = ("setStateTo: OUTBOUND_LOOT");
        "NORMAL_SPACE" = ("setStateTo: HEAD_FOR_WITCHPOINT"); 
        "INTERSTELLAR_SPACE" = ("setSpeedFactorTo: 1.0", "pauseAI: 15.0", "setStateTo: HYPER_OUT"); 
        UPDATE = (); 
    }; 
    "HYPER_OUT" = {ENTER = (); EXIT = (); UPDATE = (performHyperSpaceExit); }; 
    GLOBAL = {ENTER = ("setStateTo: HEAD_FOR_WITCHPOINT"); EXIT = (); UPDATE = (); }; 
}

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
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

...

Post by Lestradae »

Hi LittleBear, thanks for the tips! :D

Concerning Death Actions: I guess I will just let them stay as they are then. As they should not create any trouble and at least the main ship ones still work that is perhaps the best option.

Concerning bounties: I assume I will remove them generally, just for especially tough and/or powerful pirate ships (especially carriers) I shall create a like-ship with only the pirate role and a special (high) bounty. That will also be a good moment to get rid of some inherited strange oxp-bounties like the I think 2000 Cr for an Ixian carrier that is more a trader than anything, a sitting duck ...

Concerning AI`s: I might just put in autoAI as true for those ships which`s AI seems to be too funky. Other ships I will just leave with their original AI. For the carriers perhaps the docking attempts could be replaced with hyperspacing out (not a bad trick,that :) )

Thanks for your quick hack! What exactly did you change? Because, if it was understandable for me how-to change docking and undocking attempts to "hyperspacing out" and "hyperspacing in" actions - that could be a solution for really big ships.

The AI`s would then be altered as such:

* No funky problems - stays as is.
* Funky somehow, not too big ship - replace with standard AI from core game.
* Problematic AI, very big to carrier ship - replace with standard AI rewritten so that, instead of undocking or docking, comes from or goes to hyperspace.

You think that`s a solution or am I overlooking something?

Cheers

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

To stop docking you'd just need to go through the AI and replace anything that sets to dockingAI or requestdockingAI to something else. A search of the AI searching for the word dock should find them all. (I've just Searched and replaced in the example the normal AI and replaced with performWitchSpaceExit). I haven't tested this but it should be fine. A replacement will jump in at the W/S beacon (you could use performWitchSpaceExitWithoutReplacing to avoid this - but this command will only work on 1.70 onwards, so for backward compatability the standard command would be easier). If you liked you could change it to a setting its state to "setStateTo: HEAD_FOR_WITCHPOINT" which would cause the ship to turn round when it reaches the station and head off on partol again.

If you DONT say anything about autoAI it is automatically set for true. (ie you won't need to go through the whole shipdata adding true for each one! :wink: ). However this is only the case on 1.70 onwards. If you want the OXP to work on lower versions, then you will need to set it to true for each entry. :( You plan for the AIs sounds good. Where you want the ship not to use the default AI for its role then setting autoAI to false and specifing the AI you want it to use instead (either native or custom) should do it.
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
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post by Svengali »

Lestradae wrote:
Concerning Death Actions: I guess I will just let them stay as they are then. As they should not create any trouble and at least the main ship ones still work that is perhaps the best option.
I don't know if some of them are using special things in their death_actions, but if so you could/should think about ship-scripts too (some day all script_actions won't work at all). It is a lot of work, but maybe the right time to start these things. .-)
User avatar
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

...

Post by Lestradae »

@LittleBear:
If you liked you could change it to a setting its state to "setStateTo: HEAD_FOR_WITCHPOINT" which would cause the ship to turn round when it reaches the station and head off on partol again.
Sounds an even better idea than making big ships jump in and out instead of docking ...
If you DONT say anything about autoAI it is automatically set for true.
So, in case of me just wanting to change the AI to custom I could simply erase the entry and it`s automatically attributed according to role, yes?
If you want the OXP to work on lower versions
No, really, I think people should just download the newest version of Oolite. So I won`t invest work into that ...

Hm, and how do I stop the big ships from launching from stations? (Though, they seem to manage that one ... at least I never saw a crash from the inside out with the big ships).

@Svengali:
I don't know if some of them are using special things in their death_actions, but if so you could/should think about ship-scripts too (some day all script_actions won't work at all). It is a lot of work, but maybe the right time to start these things.
You have PM :)

Cheers guys

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

Only way to stop the big ships being launched from stations would be not to give them the role police or trader. As you say, they don't blow up when launched even if they are actually too big to get out of the port! Although it can look kinda strange for a ship to be coming out of a docking port thats smaller than they are! :) . Alternatively you could just place by script. Give the big cop carriers a custom role eg "RS_COP_CARRIER" and then a simple legacy script eg:-

Code: Select all

<key>rs_big_cop_placement</key> 
   <array> 
      <dict> 
         <key>conditions</key> 
         <array> 
            <string>status_string equal STATUS_EXITING_WITCHSPACE</string>
	    <string>systemGovernment_number greaterthan 0</string>
	    <string>d100_number greaterthan 80</string> 
         </array> 
         <key>do</key> 
         <array> 
	   <string>addSystemShips: RS_COP_CARRIER  1 0.[d100]</string>
         </array> 
      </dict> 
   </array>
That'd create a 20% chance of a COP_CARRIER appearing in a non-anarchy system somewhere in the spacelanes. You could if you liked have different entries (and numbers) for different system govenment types. If you have a look at the Renaged Pirates script that'll give you the idea. I wrote this ages ago and you could do it a lot better by just having one entry and then varibles for the numbers of ships and chances, so you get more in safe systems and less (or none) in dangerous ones.

On the AIs yep thats right. If you don't include any AI or any key for autoAI Oolite will automaticly give it the default one for its role. But if you want it to have a none-default one (or you call it by a custom role) then you would need the AI specified and autoAI set to false. This'll work fine on 1.70 onwards, but woudn't work on lower versions, so if you go this way, add a requires.plist (with 1.70 set as the minum) and put a note on the Wiki page that the OXP requires 1.70 or higher.
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
Lestradae
---- E L I T E ----
---- E L I T E ----
Posts: 3095
Joined: Tue Apr 17, 2007 10:30 pm
Location: Vienna, Austria

...

Post by Lestradae »

Just another question about AI.plists.

If I have a ship with an AI.plist specified in shipdata.plist which has roles specified that contradict this AI.plist, which AI is then chosen:

The autoAI (resulting in the ship automatically gettting the appropriate AI) or the specified AI.plist (i.e. the ship gets spawned as "trader" but does something funky its specific AI says instead)?

:?:

L
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 called by a standard role (trader, pirate, police etc) the ship ALWAYS gets the default AI for its role UNLESS autoAI is set to false. EG:-

Code: Select all

<key>my_trader_ship</key>
<dict>
<key>roles</key>
<string>trader</string>
<key>ai_type</key>
<string>randomhitspatrolAI.plist</string>
In the above example I have NOT set autoAI to false. So although I have specified a custom AI type, the ship will use route1traderAI because it is being called by the role trader. However:-

Code: Select all

<key>my_trader_ship2</key>
<dict>
<key>roles</key>
<string>trader</string>
<key>auto_ai</key>
<false/>
<key>ai_type</key>
<string>randomhitspatrolAI.plist</string>
In this example I have set autoAI to false. The ship will be on the call list for traders, but will NOT use trader AI. Instead it will use the custom AI. This would mean of course though it would not behave as a trader, so might not be a good thing to do!
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 »

Little Bear wrote:
However route1partrol is probabley a bad choice for carriers as the ship will try to dock on reaching the station. Bear in mind that all the ships in the native game are small enough to dock easily. ..... This is a very quick hack, but it would make the ship jump out rather than try to dock :-
You probably read it to fast: route1partrol works excellent for carriers. What you read as docking is accept docking. route1partrol will never dock, it just patrol;s the spacelane. It has even special code in is for use as a carrier. I think Giles added the carrier code it for the behemoth when it was spawn as hunter. So no changing of it needed for use with carriers.
Little Bear wrote:
If called by a standard role (trader, pirate, police etc) the ship ALWAYS gets the default AI for its role UNLESS autoAI is set to false.
Not correct. auto_ai has only effect when a ship is added by script in a default role. The polulator always uses the default AI's for that role.

But I would like that the populator also looks at the auto_ai. Looking at the code it shouldn't be that big a problem to look every time for the auto_ai. e.g.: when I look for the adding of a trader by the populator i read:

Code: Select all

[self addEntity:trader_ship];
[[trader_ship getAI] setStateMachine:@"route1traderAI.plist"];
[trader_ship release];
With a simple IF addition it does the same when there is no auto_ai or auoto_ai = YES. With an auto_ai of NO it will leave the Ai as it was -> the one defined in shipdata.

Code: Select all

[self addEntity:trader_ship];
if ([trader_ship->shipDict fuzzyBooleanForKey:@"auto_ai" defaultValue:YES])
 [[trader_ship getAI] setStateMachine:@"route1traderAI.plist"];
[trader_ship release];
I better place suggestion this in requests. Or has this auto_ai handling a big drawback?
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 »

LittleBear wrote:
If you DONT say anything about autoAI it is automatically set for true. (ie you won't need to go through the whole shipdata adding true for each one! :wink: ). However this is only the case on 1.70 onwards. If you want the OXP to work on lower versions, then you will need to set it to true for each entry. :(
auto_ai did not exist in the last stable version. I strongly recommend against doing extra work to support obsolete test versions.
Svengali wrote:
I don't know if some of them are using special things in their death_actions, but if so you could/should think about ship-scripts too (some day all script_actions won't work at all). It is a lot of work, but maybe the right time to start these things. .-)
The intention is that death_actions should continue to work as before. There is no plan to remove the old scripting system, ever.

I am not aware of any bugs pertaining to death_actions, but the bug tracker is currently not working. If you know of a bug and you haven’t reported it, it is likely that it won’t get fixed.
Post Reply