AI script error: AI not playing competitively

:arrow_forward: GAME INFORMATION

:point_down: These details are CRITICAL; DO NOT skip them or your issue may not be reviewed.

  • GAME BUILD #: 101.102.42346.0 (#107882) 13720908
  • GAME PLATFORM: Steam
  • OPERATING SYSTEM: Windows 10

:arrow_forward: ISSUE EXPERIENCED

:point_down: DESCRIBE THE ISSUE IN DETAIL (below). LIMIT TO ONE BUG PER THREAD.
When starting a multiplayer game error code of:
AI script error
Player 2
File: ai (HD version).per 2
Line 4466: ERR2005: invalid identifier

The computer players then don’t play as they should. This happened since the recent update. I uninstalled and reinstalled. I don’t use any mods

:arrow_forward: FREQUENCY OF ISSUE

:point_down: How often does the issue occur? CHOSE ONE; DELETE THE REST!

  • 100% of the time / matches I play (ALWAYS)

:arrow_forward: REPRODUCTION STEPS

:point_down: List CLEAR and DETAILED STEPS we can take to reproduce the issue ourselves… Be descriptive!

Here’s the steps to reproduce the issue:

  1. Set up a multiplayer map, hard mode, various maps and races
  2. Start game, error code displays on launch
  3. Ai characters just wander around not doing much

:arrow_forward: EXPECTED RESULT

:point_down: What was SUPPOSED to happen if the bug you encountered were not present?
I could play the game

:arrow_forward: IMAGE

:point_down: ALWAYS attach a PICTURE (.jpg, .png, .gif) or VIDEO (.mp4, YouTube link) that highlights the problem.

:arrow_forward: GAME FILES (SAVE / RECORDING)

:point_down: Attach a SAVE GAME (.aoe2spgame) or GAME RECORDING (.aoe2record) of the match where you encountered the issue. Link it below if using an external file service.

the game file is saved as .aoe2mpgame so I can’t include it

1 Like

I have the same problem since yesterday’s update, I uninstalled and reinstalled the game, it doesn’t change anything! :frowning:

The team is investigating this issue.

I’m having the same problem since yesterday

Salut!

Des nouvelles de développeurs? car du coup le jeu est totalement inutilisable…

If you use the ‘standard’ map size then it still seems to work!

Thanks for that, I was playing with the huge map when I had the error, if I play with any other map it works ok?

The issue is with the huge maps. In the last update, they renamed them from giant maps, but neglected to update the reference in the AI. With a text editor, I edited the AI script found at C:\XboxGames\Age of Empires II- Definitive Edition\Content\Game\resources_common\ai\AI (HD version).per. There are three instances of the word GIANT-MAP that I changed to HUGE-MAP. Problem solved.

Use the search feature, or look on lines 3433, 3479, and 3575.

Not just that, it’s all the ‘new’ sizes that causes it. (since they are not defined in those AI’s yet.)

I went ahead and did your job for you…

edit: something along the lines of this… (for HD ai.) you will have to edit some of the values though. (I just inserted ‘1’ for most of them for now.)

; bug fix
#load-if-defined MINIATURE-MAP-SIZE
(defconst tsa-increment 1)
(defconst shorefishreq 1)
(defconst shorefishreq2 1)
(defconst deepfishreq 1)
(defconst deepfishreq2 1)
(defconst heavy-wood 1)
(defconst max-trade-cart 1)
(defconst trade-distance 1)
(defconst timer-lcs 1)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined TINY-MAP-SIZE
(defconst tsa-increment 6)
(defconst shorefishreq 50)
(defconst shorefishreq2 25)
(defconst deepfishreq 6)
(defconst deepfishreq2 3)
(defconst heavy-wood 7000)
(defconst max-trade-cart 22)
(defconst trade-distance 80)
(defconst timer-lcs 30)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined SMALL-MAP-SIZE
(defconst tsa-increment 7)
(defconst shorefishreq 100)
(defconst shorefishreq2 50)
(defconst deepfishreq 8)
(defconst deepfishreq2 4)
(defconst heavy-wood 8000)
(defconst max-trade-cart 28)
(defconst trade-distance 105)
(defconst timer-lcs 36)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined MEDIUM-MAP-SIZE
(defconst tsa-increment 8)
(defconst shorefishreq 150)
(defconst shorefishreq2 75)
(defconst deepfishreq 10)
(defconst deepfishreq2 5)
(defconst heavy-wood 10000)
(defconst max-trade-cart 35)
(defconst trade-distance 130)
(defconst timer-lcs 42)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined NORMAL-MAP-SIZE
(defconst tsa-increment 10)
(defconst shorefishreq 200)
(defconst shorefishreq2 100)
(defconst deepfishreq 12)
(defconst deepfishreq2 6)
(defconst heavy-wood 14000)
(defconst max-trade-cart 40)
(defconst trade-distance 155)
(defconst timer-lcs 54)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined LARGE-MAP-SIZE
(defconst tsa-increment 12)
(defconst shorefishreq 250)
(defconst shorefishreq2 150)
(defconst deepfishreq 14)
(defconst deepfishreq2 7)
(defconst heavy-wood 18000)
(defconst max-trade-cart 45)
(defconst trade-distance 180)
(defconst timer-lcs 66)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
; bug fix
#load-if-defined HUGE-MAP-SIZE
(defconst tsa-increment 1)
(defconst shorefishreq 1)
(defconst shorefishreq2 1)
(defconst deepfishreq 1)
(defconst deepfishreq2 1)
(defconst heavy-wood 1)
(defconst max-trade-cart 1)
(defconst trade-distance 1)
(defconst timer-lcs 1)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined GIANT-MAP-SIZE
(defconst tsa-increment 14)
(defconst shorefishreq 300)
(defconst shorefishreq2 150)
(defconst deepfishreq 16)
(defconst deepfishreq2 8)
(defconst heavy-wood 22000)
(defconst max-trade-cart 55)
(defconst trade-distance 205)
(defconst timer-lcs 78)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
; bug fix
#load-if-defined MASSIVE-MAP-SIZE
(defconst tsa-increment 1)
(defconst shorefishreq 1)
(defconst shorefishreq2 1)
(defconst deepfishreq 1)
(defconst deepfishreq2 1)
(defconst heavy-wood 1)
(defconst max-trade-cart 1)
(defconst trade-distance 1)
(defconst timer-lcs 1)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
; bug fix
#load-if-defined ENORMOUS-MAP-SIZE
(defconst tsa-increment 1)
(defconst shorefishreq 1)
(defconst shorefishreq2 1)
(defconst deepfishreq 1)
(defconst deepfishreq2 1)
(defconst heavy-wood 1)
(defconst max-trade-cart 1)
(defconst trade-distance 1)
(defconst timer-lcs 1)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
; bug fix
#load-if-defined COLOSSAL-MAP-SIZE
(defconst tsa-increment 1)
(defconst shorefishreq 1)
(defconst shorefishreq2 1)
(defconst deepfishreq 1)
(defconst deepfishreq2 1)
(defconst heavy-wood 1)
(defconst max-trade-cart 1)
(defconst trade-distance 1)
(defconst timer-lcs 1)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
; bug fix
#load-if-defined INCREDIBLE-MAP-SIZE
(defconst tsa-increment 1)
(defconst shorefishreq 1)
(defconst shorefishreq2 1)
(defconst deepfishreq 1)
(defconst deepfishreq2 1)
(defconst heavy-wood 1)
(defconst max-trade-cart 1)
(defconst trade-distance 1)
(defconst timer-lcs 1)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
; bug fix
#load-if-defined MONSTROUS-MAP-SIZE
(defconst tsa-increment 1)
(defconst shorefishreq 1)
(defconst shorefishreq2 1)
(defconst deepfishreq 1)
(defconst deepfishreq2 1)
(defconst heavy-wood 1)
(defconst max-trade-cart 1)
(defconst trade-distance 1)
(defconst timer-lcs 1)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined LUDICROUS-MAP-SIZE
(defconst tsa-increment 20)
(defconst shorefishreq 350)
(defconst shorefishreq2 175)
(defconst deepfishreq 18)
(defconst deepfishreq2 9)
(defconst heavy-wood 26000)
(defconst max-trade-cart 75)
(defconst trade-distance 360)
(defconst timer-lcs 102)
(defconst water-mixed 1)
(defconst water-islands 1)
#end-if
#load-if-defined TINY-MAP-SIZE
(defconst tsa-increment 6)
(defconst shorefishreq 50)
(defconst shorefishreq2 25)
(defconst deepfishreq 6)
(defconst deepfishreq2 3)
(defconst heavy-wood 7000)
(defconst max-trade-cart 22)
(defconst trade-distance 80)
(defconst timer-lcs 30)
#end-if

edit: as for CD ai, I will look into that now…

edit: elite petersen constants.per2 (same thing here. edit the ‘1’'s as needed.)

;*************************************************************
#load-if-defined MINIATURE-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 1)
#end-if
;**************************
#load-if-defined TINY-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 8)
#end-if
;**************************
#load-if-defined SMALL-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 8)
#end-if
;**************************
#load-if-defined MEDIUM-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 10)
#end-if
;**************************
#load-if-defined NORMAL-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 2)
(defconst mining-count 11)
#end-if
;**************************
#load-if-defined LARGE-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 2)
(defconst imperial-mill-count 3)
(defconst mining-count 12)
#end-if
;**************************
#load-if-defined HUGE-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 1)
#end-if
;**************************
#load-if-defined GIANT-MAP-SIZE
(defconst feudal-mill-count 2)
(defconst castle-mill-count 3)
(defconst imperial-mill-count 4)
(defconst mining-count 15)
#end-if
;**************************
#load-if-defined MASSIVE-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 1)
#end-if
;**************************
#load-if-defined ENORMOUS-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 1)
#end-if
;**************************
#load-if-defined COLOSSAL-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 1)
#end-if
;**************************
#load-if-defined INCREDIBLE-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 1)
#end-if
;**************************
#load-if-defined MONSTROUS-MAP-SIZE
(defconst feudal-mill-count 1)
(defconst castle-mill-count 1)
(defconst imperial-mill-count 1)
(defconst mining-count 1)
#end-if
;**************************
#load-if-defined LUDIKRIS-MAP
(defconst feudal-mill-count 2)
(defconst castle-mill-count 3)
(defconst imperial-mill-count 4)
(defconst mining-count 18)
#end-if
;**************************

edit: tested/no startup runtime errors.

edit: your welcome.

I think this problem has been fixed with a beta update. Just updated a march beta and launched the game ok using the huge map no error this time.

The Issue

The extra parenthesis remains a syntax error even within the larger code block. The game’s script interpreter will still stumble upon it and likely throw an error.

Corrected Code

Here’s the corrected block:

(defrule
(or	(military-population >= 2)
	(population >= max-civ-pop))
(or	(and	(strategic-number sn-maximum-town-size >= 40)
		(building-type-count town-center >= 1))
	(or	(strategic-number sn-number-attack-groups >= 1)
		(strategic-number sn-number-boat-attack-groups >= 1)))
	(up-compare-goal team-coordination-goal != 1)
=>
	(set-strategic-number sn-gather-defense-units 0)
	(set-goal team-coordination-goal 1))
(defrule
(or	(goal under-attack-goal 1)
(or	(goal team-coordination-goal 1)
	(or	(and	(strategic-number sn-maximum-town-size >= 40)
			(strategic-number sn-minimum-water-body-size-for-dock < water-islands)) ; TSA is not used on islands
		(strategic-number sn-number-attack-groups >= 1))))
	(building-type-count-total town-center >= 1)
=>
	(set-goal hostilities-goal 1))

This code seems to define two rules for AI behavior in a strategy game:

  • Rule 1: This rule triggers when the AI has a certain military or overall population, and either has a large enough town or enough attack groups. The rule sets the AI to coordinate with its team and stop gathering defensive units.
  • Rule 2: This rule triggers if the AI is under attack, coordinating with its team, has a large town and certain water conditions, or has enough attack groups. The rule sets the AI to be hostile.

The water-islands Check

The line we corrected seems to be a condition that checks if the AI is using Transport Ship AI (TSA) on a non-island map. This check might be here to prevent the AI from behaving strangely when trying to use transport ships on maps without large bodies of water.

Key Points

  • The extra parenthesis was the immediate issue causing the script error.
  • The code attempts to adjust AI behavior based on several factors, including map type and military strength.
  • While the fix addresses the error, you’ll likely need additional code to actually disable the TSA on islands if that’s your ultimate goal.