• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

Paul Hanson

Second Lieutenant
5 Badges
Sep 3, 2005
134
0
  • Arsenal of Democracy
  • Darkest Hour
  • Europa Universalis III
  • 500k Club
  • Hearts of Iron IV: Death or Dishonor
Making fairly good progress on converting MDS to Darkest Hour, but I'm running into a bit of a snag after reintroducing Kuwait into the scenario; AI-controlled America and Britain simply won't invade Iraq. Seeing as the scenario begins with the invasion of Iraq in March 2003, and that many of the key events of the scenario rely upon the US conquering and occupying Iraq, this is a bit irritating.

My previous experience with AI modding fits on the back of a postage stamp, and my attempts to modify the AI by referring to examples and guides seems to be having little/no effect. From what I can tell, the AI is far too preoccupied with garrisoning it's home beaches than it is in spreading democracy and freedom abroad, which is what I'd prefer it did.

The AI file I'm using (and it IS loading, as best I can tell) is as follows:

Code:
#USA AI - Iraq War

switch = no # [yes/no]
max_front_ratio = 0.75 
max_garrison_prop = 0.25
min_garrison_prop = 0.10
neutrality = 95
war = 100
upgrading = 0.35
reinforcement = 0.2
strat_redeploy_threshold = 25
exp_force_ratio = 0.750
exp_force_ratios = { }
no_exp_forces_to = { }

###################################
# Invasions and Naval
###################################
invasion = { 
 	base				 = 0.1	#Relative modifier. (lower = specific targets much more important.)
	random				 = 1.0	#How big a random range.  (1.0 = 1%)
	coastal				 = 0.1	#increase to avoid coastal forts more.
	beach				 = 1.0	#higher, avoid worst beaches.
	max_distance  		 = 2500.0  #About the distance from ? to ?
	max_staging_distance = 100	# How far should the staging area be from the target invasion point?
	distance			 = 0.01	#higher = avoid long distance.
	pocket				 = 20.0	#prioritise pockets, ie provinces with no adjacent controlled by same.
	island				 = 2.0	#prioritise taking pure islands.
	enemy				 = 1.0	#higher = much more vary of troops in province.
	adjacentenemy 		 = 0.5	#higher = much more vary of troops nearby
	air_base			 = 1.5 
    naval_base 			 = 1.5 
   	ignore				 = no
	help_allies 		 = yes
      
	target = {
				   1034 = 90 # Baghdad
				   1032 = 75 # Basrah
			 } 
		    } 
			
front = { 
     strength = 1.0000 
     organisation = 1.0000 
     dig_in = 1.0000 
     soft_attack = 1.0000 
     hard_attack = 1.0000 
     ground_defense = 1.0000 
     support_defense_prop = 0.3300 
     river = 1.0000 
     frozen_attack = 1.0000 
     snow_attack = 1.0000 
     blizzard_attack = 1.0000 
     storm_attack = 1.0000 
     muddy_attack = 1.0000 
     largefort = 1.0000 
     smallfort = 1.0000 
     occupied = 0.8000 
     owned = 0.5000 
     jungle_attack = 1.0000 
     mountain_attack = 1.0000 
     swamp_attack = 1.0000 
     forest_attack = 1.0000 
     hill_attack = 1.0000 
     urban_attack = 1.0000 
     recklessness = 1 
     enemy_reinf_days = 6 
     reserve_prop = 0.2000 
     panic_ratio_vs_ai = 3.0000 
     panic_ratio_vs_human = 2.0000 
     base_attack_odds = 2.5000 
     min_attack_odds = 1.0000 
     max_attack_odds = 3.0000 
     reinforce_odds = 1.0000 
     withdraw_odds = 0.5000 
     distrib_vs_ai = op_offensive 
     distrib_vs_human = op_offensive 
     enemy_handicap = { } 
     passivity = { } 
     province_priorities = { 
				   1034 = 90 # Baghdad
				   1032 = 75 # Basrah
	 } 
}

###################################
# Military
################################### 

military = {
relative_build_scheme = no


max_batch_peace = 400
max_batch_war = 400
max_batch_home_front = 200


# Countries build-up:
infantry = 10
cavalry = 0
motorized = 15
mechanized = 0
light_armor = 10
armor = 0
paratrooper = 0
marine = 0
bergsjaeger = 5
garrison = 0
hq = 0
militia = 0
# 40 %

interceptor = 20
multi_role = 10
cas = 0
strategic_bomber = 0
tactical_bomber = 0
naval_bomber = 0
transport_plane = 0
flying_bomb = 0
flying_rocket = 0
# 30 %


battleship = 0
carrier = 0
escort_carrier = 0
destroyer = 10
light_cruiser = 5
heavy_cruiser = 0
battlecruiser = 0
submarine = 10
nuclear_submarine = 0
transport = 5
# 30 %


# NOTE: The sum _must_ be exactly 100%!
# Brigade preferences:
# Land types:
artillery = 0
sp_artillery = 0
rocket_artillery = 0
sp_rct_artillery = 20
anti_tank = 0
tank_destroyer = 0
light_armor_brigade = 0
heavy_armor = 50
super_heavy_armor = 0
armored_car = 0
anti_air = 10
police = 0
engineer = 20
# Sum of these should be <= 100

# Naval types:
cag = 100
# Sum of these should be <= 100
}

technology = {
	endgoal 	= { }
	preference 	= { }
	ignore 	= { }

	armor 			= 3
	infantry 			= 4
	industry 		= 5
	aircraft 		= 3
	naval 			= 3
	land_doctrines 	= 2
	secret_weapons 	= 0
	air_doctrines 	= 3
	naval_doctrines = 2
}
###################################
# Diplomacy
################################### 

# Special resistance against "influence" by the listed nations. Value range = [0 - 10]
# Used in mod as how much increase diplomacy difficulty for Big 10.
resistance = { 
} 
befriend = { 
U16 = 100 # Kuwait
}
protect = { 
U16 = 300 # Kuwait
}
combat = {
IRQ = 100 # Iraq
}
 
I believe I've already specified targets in that section - specifically, I've set Basrah and Baghdad to be the main targets (although this will need to have Mosul and Kirkuk added at some point, but that's another story).

A bit more information, if it helps; the troops are all based in Kuwait (province) which is owned by Kuwait (country), which I have set both as a member of the US-led alliance and as a puppet of the USA. I've placed a large supply and oil stockpile in Kuwait, although I think that the AI has a tendency to ship it all back to the US as soon as the game starts.
 
Script an event giving it free units there. Oh wait...it'll just send it back to the capital (observed ai behavior in 1.01 anyway).

The ai tends to not use allied territory very well. I think it prefers expeditionary forces in allied territory. :/

There is a naval invasion preferred bases ai parameter somewhere. Try that?
 
Sounds like it'd be worth a try. I'll give it a shot a bit later.

Of course, it may turn out that there was a good reason why the original developers of MDS had Kuwait as American territory at the start of the scenario, and only had it released once the invasion of Iraq was over.
 
Some hints from Modding Documentation folder

Invasion AI (Armageddon / Darkest Hour 1.00)

1. Controlled AIs do not invade
2. invasion = yes #Allow/Disallow invasions
3. ignore = yes #Should launch invasions if there is home front (land border with enemy at the area where the capital is)?
4. Check for available transports. Used to determine max invasions:
TP > 40 -> 4
TP > 20 -> 3
TP > 10 -> 2
TP > 1 -> 1
5. Check for currently started invasions (this includes invasions still in preparation). Should be less the the number calculated in (4)
6. Creates a list of all curent enemies
7. help_allies = yes/no. Check if there is ally (country in the same alliance!!!) in need:
- AI country should be at war
- The ally should not be in no_exp_forces_to = { } list!!!
- The ally should be AI controlled too
- Allies are checked one by one, starting with the first country in the alliance
- All land areas controlled by that ally are checked one by one. First arrea that has a port, is war zone and the ally needs more divisions is returned.
8. List of all available for invasion land units is created. That excludes all units currently in combat, borbardment, retreat, loaded on ships/transport planes, garrisons, locked for movement, paratroops, located in front provinces or already assigned to a front or for transportation.
9. Then the best unit (highest score) for invasion is selected among the list created in (8). This is based on factors like (- for negative, + for positive):
- Cuurent Location lacking units * 10
- Distance to the target province (usually it is 0 as target is not set yet)
- Average STR damage for the unit (0 to 100)
+ Count of Marines * 100
+ Count of MTN * 50
- Count of MIL * 50
- Count of CAV * 10
- -100 points if the unit is originally from another country
-/+ -100 points if the unit is in the Home area and home is treaten (bordering enemy) ELSE +150 points
10. Check for a port in Home Area. If not -> halts all invasions.
11. Takes the enemies list created in (6) and search for best invasion target. For each enemy country, for every land area:
- skip areas already targeted by another invasion
- skip areas without provinces that can be invaded by sea
- skip areas which sea provinces cannot be reached (pass Suez, Gibraltar etc.)
For each province in area check:
- skip no coast or no beach provinces
- skip provinces with no, less or equal to 0.0 priority set in target = { ... } list if province_priorities parameter is set to "yes"
- skip islands with value less then 50 points or no positive value in target = { ... } list (NEW for Darkest Hour). Value = VP * 100 + Naval Base * 10 + Air base * 10 + Max IC * 20 + Oil prod. * 10 + Rares prod. * 10 + Metal prod. * 2 + Energy prod.
- skip provinces already targeted for invasion
- skip Rebel controlled provinces if prov. owner is another country
Calculates needed for invasion divisions. This is quite complex logic, taking into account enemy units on the beach and provinces around, distance to the targeted province, defending units type and strength, friendly units in the area that could help and so on.
- skip province if there is an Ally in need (7) and needed invasion force is more then 3 divisions
- skip province if needed invasion force is more then then the size of the best unit (9).
- skip province if there are not enough TPs available: (All TPs / (1 + current invasions)) < (Needed Div / 2)
- skip province if its value in target = { ... } list is less then 0. Doesn't skip provinces not in the list!!!
Calculates invasion score of the province:
score = target = { ... } value / (<base> value + 0.01) # Province not found in the list gets 0 score
score = score + (10 * [Max of 1 or rounded <random> value from AI prefs]) # In total this random component adds 10 or more points (80 for random = 8.0)
- skip province if naval distance to it is greater then <max_distance>
- Reduce score based on distance and <distance> AI parameter:
score = score - (10 * distance * <distance>)
- Reduce score if there are defending enemy units in the province and coastal forts:
score = score - ( 100 * Coastal level in the province * <coastal> )
- Modifies score of island provinces(areas with just one province) using <island> AI parameter:
score = score + ( (<island> - 1)*1000)
- Modifies score of areas with just one province by <pocket>. Note: this applies to islands too!
score = score + ( <pocket> - 1)*1000)
- Reduce score if there are land units in the province, based on <enemy> AI parameter:
score = score - ( <enemy> * total land unit size in the province * 200 )
- Modifies score if there is air base in the province by <air_base> AI parameter:
score = score + ( <air_base> * Air base size * 100 )
- Modifies score if there is naval base in the province by <naval_base> AI parameter:
score = score + ( <naval_base> * Naval base size * 100 )
Check enemy neighboring provinces that are not impassable. For each province modify score by:
score = score - ( <adjacentenemy> * total land unit size in the province * 20 )
score = score + ( <air_base> * Air base size * 20 )
score = score + ( <naval_base> * Naval base size * 20 )
NOTE: Skip province if any of the adjacent provinces is allied controlled!!!
Check if this province scores are higher then all currently checked and only if it is so:
Check for closest staging province (from which we can launch the invasion). Allied provinces that can be reached are checked too.
- skip province if distance to it from the closest staging province (calculated above) is highre then <max_staging_distance> AI parameter
- else select this province as best target for invasion
12. Return if no good invasion province was found, else continue
13. Calculates again needed invasion army size, this time to for the selected target. It could be a at least 1 unit and is set to 3 if there are anough units, transports and enemy area has more then 3 provinces
14. Calculatest best province to launch invasion from. Allied provinces included too:
- province should be coastal
- province should have naval base
- province should not be already selected for another invasion
- distance from that province to invasion target should be less then <max_staging_distance> AI parameter
- province should have a sea zone
- that sea zone should be reachable from the country (Suez, Gibraltar Panama etc. could prevent access to it)
- Modify score by distance from staging to invasion target province:
score = -(Naval Distance between the two)
- Modify score if selected for the invasion army:
is already in the province (score = score + Army size*2)
or in the same area (score = score + Army size)
- Modify score if this province is in the home area (where the capital is)
score = score + 3
- Check if the province is in staging_province = { ... } list and adds bonus if so:
score = score + 7
- Check if this is the only province in the area (could be an island or province surrounded by another countries). If so reduce score by 4:
score = score -4
Check if current province scores are higher then the previous best and if so selects this one as best staging province. Then check the rest.
15. Return if no good staging province was found in (14)
16. Move selected invasion army (9) to the staging province (14) if not already there. Marks the army as invasion force prints to invasions.txt:
"%s(COUNTRY) initializing invasion of %s(TARGET PROV) with %i(INVASION FORCE SIZE) (%i)(CALCULATED NEEDED SIZE) divisions from %s (STAGING PROVINCE)"



DEFAULT VALUES:

_bInvade = true;

_vBase = 1.0f;
_vRandom = 1.0f;
_vCoastal = 1.0f;
_vBeach = 1.0f;
_vDistance = 1.0f;
_vMaxDistance = 99999.0f;
_vMaxStagingDistance = 10.0f;
_vPocket = 1.0f;
_vIsland = 1.0f;
_vEnemy = 1.0f;
_vAdjacentEnemy = 1.0f;

_vAirBase = 0.1f;
_vNavalBase = 0.1f;
_vAirSupport = 0.1f;

_nRedirMode = _HOIIR_NEAREST_;

_Ignore = false;
_bHelpAllies = true;


EXAMPLE:

invasion = yes #Allow/Disallow invasions
base = 0.1 #Relative modifier. (lower = specific targets much more important.) target value / (THIS + 0.01)
random = 8.0 #How big a random range. (1.0 = 1%)
coastal = 0.1 #increase to avoid coastal forts more. (CF level * this * 100)
beach = 0.1 #higher, avoid worst beaches.
max_distance = 250.0 #About the distance from Japan to Batavia NOTE: In-game distnace = This * 100 (km)
max_staging_distance = 250 # How far should the staging area be from the target invasion point; NOTE: In-game distnace = This * 100 (km)
distance = 0.1 #higher = avoid long distance.
pocket = 20.0 #prioritise pockets, ie provinces with no adjacent controlled by same. Applies to islands too. (this - 1) * 1000
island = 0.1 #prioritise taking pure islands (one province). (this - 1) * 1000
enemy = 2.0 #higher = much more vary of troops in province. ( this * total land unit size in the province * 200 )
adjacentenemy = 2.0 #higher = much more vary of troops nearby
air_base = 1.5 #Bonus to air bases( this * Air base size * 100 ), ( this* Air base size * 20 ) for adjacent enemy provinces
naval_base = 0.1 #Bonus to naval bases( this * Naval base size * 100 ), ( this* Air Naval size * 20 ) for adjacent enemy provinces
air_support = 3.0 # NOT USED!
redirect = priority # NOT USED!
ignore = no #Should launch invasions if there is home front?
help_allies = no #[yes/no] Should send troops to help allied invasions too?

staging_province = { ... } # Adds bonus (+7) for provinces in that list when searching for best province to launch invasion from
target = { ... } # skip provinces with value less then 0