RDNWiki: DOWScar/AI/AIFiles ...

RDN Wiki Home | Page Index | Recent Changes | Recently Commented | Users | Registration | Login:  Password:  

AI Files


Contents

Introduction


This section is dedicated to documenting the different AI files included in the working Dawn of War AI. Of course, if you created another, different AI, this provides a good reference of how the original AI works.


Check this to see how to add new units, abilities and races so that the AI works with your modidifications to the game!

cpu_manager.ai


cpu_manager.ai – General Clerical work that tells the AI where to look for all these files throughout the AI structure..


These are the important sections to fill out:


import( 'Strategies/<modname>BuildBaseStrategy.ai' )

import( 'Tactics/<modname>/<unitname>Tactic.ai' )


function CpuManager:Initialize()
self.player_stats:GetPlayerRaceName() == "<mod_race>" or

self.player_stats:GetPlayerRaceName() == "<mod_race>" or


function CpuManager:AddStrategy( strategy_name, priority )
elseif self.player_stats:GetPlayerRaceName() == "<mod_race>" then
strategy = <modname>BuildBaseStrategy( BuildBaseStrategyInfo )


function CpuManager:ForceAttack( player_id )
AttackStrategyInfo.<mod_race>.stop_attack_rating = -INT_MAX
	AttackStrategyInfo.<mod_race>.prefer_player = player_id


function CpuManager:CreateTactic( squad_ai )

if squad_ai:IsEngineer() then
elseif stats:GetSquadName() == "<mod's builder unit>" then
return <unitname>Tactic( squad_ai )

if 	class == UnitStatsAI.UC_LightInfantryLow or  
	class == UnitStatsAI.UC_LightInfantryMed or
	class == UnitStatsAI.UC_LightInfantryHigh then
elseif squad_name == "<mod's light infantry squad>" then
tactic = <unitname>Tactic( squad_ai )

elseif 	class == UnitStatsAI.UC_HeavyInfantryMed or
        class == UnitStatsAI.UC_HeavyInfantryHigh then
elseif squad_name == "<mod's heavy infantry squad>" then
tactic = <unitname>Tactic( squad_ai )

elseif 	class == UnitStatsAI.UC_Commander then
elseif squad_name == "<mod's commander unit>" then
tactic = <unitname>Tactic( squad_ai )


elseif 	class == UnitStatsAI.UC_VehicleLow or
class == UnitStatsAI.UC_VehicleMed or
class == UnitStatsAI.UC_VehicleHigh then
elseif squad_name == "<mod's vehicle unit>" then
tactic = <unitname>Tactic( squad_ai )

elseif 	class == UnitStatsAI.UC_MonsterMed or  
        class == UnitStatsAI.UC_MonsterHigh then
elseif squad_name == "<mod's monster unit>" then
tactic = <unitname>Tactic( squad_ai )

unitstats.ai


unitstats.ai – Organizes the faction's units into categories and tables for the AI to understand their usefulness and threats..


1) Arrange your faction's squads both in unitstats.ai and buildbasestrategyinfo.ai in the sequence they are build
during a game.. (Space marines used as example):
Engineer/Builder
Scout
Marine/Assault Marine
Heavy Marine/Terminators
Commander/Heroes
Vehicles-Light/Medium
Vehicles-Heavy
Uber Units


2) «attack_role =" is either R for RANGE, M for Melee or RM for both roles.

3) «class =" based on 1) should look like:

Engineer/Builder ( UnitStatsAI.UC_LightInfantryLow )
Scout ( UnitStatsAI.UC_LightInfantryMed or UnitStatsAI.UC_LightInfantryHigh )
Marine/Assault Marine ( UnitStatsAI.UC_HeavyInfantryMed or UnitStatsAI.UC_MonsterMed )
Heavy Marine/Terminators ( UnitStatsAI.UC_HeavyInfantryHigh )
Commander/Heroes ( UnitStatsAI.UC_Commander )
Vehicles-Light/Medium ( UnitStatsAI.UC_VehicleLow or UnitStatsAI.UC_VehicleMed )
Vehicles-Heavy ( UnitStatsAI.UC_VehicleHigh )
Uber Units ( UnitStatsAI.UC_VehicleHigh or UnitStatsAI.UC_MonsterHigh )

4) The unit's «rating =" line dictates how important that unit is to the AI. Its 8 digits long right of the decimal (ie. 0.31694573).

The higher this # reaches 1.00000000, the more likely the AI will build it, so a good rule of thumb is:

Class Recommended Rating Span
UnitStatsAI.UC_LightInfantryLow0.10000000 – 0.20000000
UnitStatsAI.UC_LightInfantryMed / UnitStatsAI.UC_LightInfantryHigh0.20000000 – 0.30000000
UnitStatsAI.UC_HeavyInfantryMed / UnitStatsAI.UC_MonsterMed0.30000000 – 0.40000000
UnitStatsAI.UC_HeavyInfantryHigh0.40000000 – 0.45000000
UnitStatsAI.UC_Commander 0.45000000 – 0.55000000
UnitStatsAI.UC_VehicleLow / UnitStatsAI.UC_VehicleMed0.30000000 – 0.50000000
UnitStatsAI.UC_VehicleHigh / UnitStatsAI.UC_MonsterHigh0.50000000 – 1.00000000

NB: You should jumble the #s up similar to the 0.31694573 example and not have a rating at a perfect 0.30000000.

5) The «range =" line for each weapon should kinda fit like this..

range = UnitStatsAI.RT_None (For Engineers with no weapons at all or Dummy weapons)
range = UnitStatsAI.RT_Melee (For swords, power fists, etc... Some Pistols are also considered Melee - up to you..)
range = UnitStatsAI.RT_ShortRanged (flamers, melta)
range = UnitStatsAI.RT_Ranged (everything else)

6) You don't need to include a Squad captain or sargeant in unitstats.ai as the AI knows how to build one + you have no control over its weapons/behaviour since its part of the squad anyway. Note that all other factions don't have one mentioned (except for Orks' Nobz Leader which is kinda odd).

7) REMEMBER: NO CAPS ! !! No name or filename except under sections «name =", «attack_role =", «class =", «effectiveness =", and «range =" should have caps. No other sections should have any capitalized letters other than those five mentioned!!

8) If a unit has an upgrade that starts with no visible weapon showing, use:

name = "<race _name>_dummy_weapon",
effectiveness = GenerateUnitEffectiveness(0,0,0,0,0,0,0,0,0,0,0),
range = UnitStatsAI.RT_None,

..as the first part of the effectiveness list of weapons for that unit. This will trick the AI into thinking it 

already has a weapon sponsor present and reliably continue and upgrade to other weapons you have mentioned after
the dummy weapon.


9) General Unit Effectiveness is based on the 11 Classes you've already seen above:

UnitStatsAI.UC_LightInfantryLow
UnitStatsAI.UC_LightInfantryMed
UnitStatsAI.UC_LightInfantryHigh
UnitStatsAI.UC_HeavyInfantryMed
UnitStatsAI.UC_HeavyInfantryHigh
UnitStatsAI.UC_VehicleLow
UnitStatsAI.UC_VehicleMed
UnitStatsAI.UC_VehicleHigh
UnitStatsAI.UC_MonsterMed
UnitStatsAI.UC_MonsterHigh
UnitStatsAI.UC_Commander


The #s you see in the line:

effectiveness = GenerateUnitEffectiveness(5.6,4,3.2,2.4,0,1,0.5,0,0.89,0,1.32),

..correspond to the above list. A higher # means that weapon is more effective to that type of class.

For the sake of standardization, the list below standardizes AI effectiveness values:


Just copy one «effectiveness = ..» line for each applicable weapon!


Lasers
	        name = "laspistol",
                effectiveness = GenerateUnitEffectiveness(2,3,2,2,1,1,1,1,1,1,1),
		range = UnitStatsAI.RT_Melee,

		name = "laser_rifle",
		effectiveness = GenerateUnitEffectiveness(3,4,3,3,1,1,1,1,1,1,1),
                range = UnitStatsAI.RT_Melee,

		name = "multilaser_vehicle",
		effectiveness = GenerateUnitEffectiveness(6,8,5,5,3,2,1,1,1,1,1),
		range = UnitStatsAI.RT_Ranged,

Bolt and Bolters
		name = "bolt_pistol",
		effectiveness = GenerateUnitEffectiveness(7,9,8,8,8,3,3,3,8,3,4),
		range = UnitStatsAI.RT_Melee,

		name = "twin_bolt_pistol",
		effectiveness = GenerateUnitEffectiveness(8,10,9,8,8,3,3,3,8,3,4),
		range = UnitStatsAI.RT_Ranged,

		name = "bolter_tactical",
		effectiveness = GenerateUnitEffectiveness(7,9,8,8,8,3,3,3,8,3,4),
		range = UnitStatsAI.RT_Ranged,

		name = "heavy_bolter",
		effectiveness = GenerateUnitEffectiveness(14,16,15,10,14,5,3,3,18,3,9),
		range = UnitStatsAI.RT_Ranged,

		name = "heavy_bolter_vehicle",
		effectiveness = GenerateUnitEffectiveness(21,24,21,21,10,14,5,3,10,3,5),
		range = UnitStatsAI.RT_None,

		name = "heavy_bolter_twin_vehicle",
		effectiveness = GenerateUnitEffectiveness(23,24,26,10,9,5,5,10,11,6,7),
		range = UnitStatsAI.RT_Ranged,

		name = "storm_bolter",
		effectiveness = GenerateUnitEffectiveness(12,19,17,20,17,8,6,4,20,4,7),
		range = UnitStatsAI.RT_Ranged,

		name = "storm_bolter_tactical",
		effectiveness = GenerateUnitEffectiveness(12,19,17,20,17,8,6,4,20,4,7),
		range = UnitStatsAI.RT_Ranged,

		name = "storm_bolter_vehicle",
		effectiveness = GenerateUnitEffectiveness(13,17,17,25,25,23,17,7,43,9,9),
		range = UnitStatsAI.RT_None,

Flamers
		name = "flamer",
		effectiveness = GenerateUnitEffectiveness(4,6,4,5,4,1,1,1,2,1,2),
		range = UnitStatsAI.RT_ShortRanged,

		name = "twin_flamer_pistol",
		effectiveness = GenerateUnitEffectiveness(6,7,5,5,4,1,1,1,2,1,2),
		range = UnitStatsAI.RT_ShortRanged,

		name = "flamer_tactical",
		effectiveness = GenerateUnitEffectiveness(4,6,4,5,4,1,1,1,2,1,2),
		range = UnitStatsAI.RT_ShortRanged,

		name = "rifle_flamer",
		effectiveness = GenerateUnitEffectiveness(4,6,4,5,4,1,1,1,2,1,2),
		range = UnitStatsAI.RT_ShortRanged,

		name = "flamer_vehicle",
		effectiveness = GenerateUnitEffectiveness(15,16,21,20,16,12,8,1,10,1,10),
		range = UnitStatsAI.RT_ShortRanged,

		name = "heavy_flamer",
		effectiveness = GenerateUnitEffectiveness(7,14,9,12,10,5,4,2,16,2,4),
		range = UnitStatsAI.RT_ShortRanged,

		name = "heavy_flamer_vehicle",
		effectiveness = GenerateUnitEffectiveness(18,16,14,12,10,4,1,1,12,1,4),
		range = UnitStatsAI.RT_ShortRanged,

		name = "twin_heavy_flamer_vehicle",
		effectiveness = GenerateUnitEffectiveness(20,17,15,13,10,4,1,1,12,1,4),
		range = UnitStatsAI.RT_ShortRanged,

Grenade
		name = "grenade_launcher",
		effectiveness = GenerateUnitEffectiveness(9,12,9,6,3,3,3,3,4,3,3),
		range = UnitStatsAI.RT_Ranged,

Plasma
		name = "plasma_pistol",
		effectiveness = GenerateUnitEffectiveness(2,3,8,11,13,5,7,9,13,7,6),
		range = UnitStatsAI.RT_Melee,

		name = "plasma_gun",
		effectiveness = GenerateUnitEffectiveness(6,8,9,10,13,8,7,8,12,6,7),
		range = UnitStatsAI.RT_Ranged,

		name = "plasma_rifle",
		effectiveness = GenerateUnitEffectiveness(11,19,16,24,21,5,3,3,24,3,14),
		range = UnitStatsAI.RT_Ranged,

		name = "plasmagun_vehicle",
		effectiveness = GenerateUnitEffectiveness(12,20,17,24,21,5,3,3,24,3,14),
		range = UnitStatsAI.RT_Ranged,

Missiles and Rockets
              	name = "missile_launcher_tactical",
		effectiveness = GenerateUnitEffectiveness(4,4,4,4,4,29,28,10,4,9,4),
		range = UnitStatsAI.RT_Ranged,

		name = "missile_launcher_vehicle",
		effectiveness = GenerateUnitEffectiveness(7,7,7,7,7,34,25,7,7,7,7),
		range = UnitStatsAI.RT_Ranged,

		name = "missile_battery",
		effectiveness = GenerateUnitEffectiveness(5,5,5,5,5,36,36,38,5,14,4),
		range = UnitStatsAI.RT_Ranged,

		name = "rocket_launcher_twin_vehicle",
		effectiveness = GenerateUnitEffectiveness(4,4,4,4,4,39,38,20,4,9,4),
		range = UnitStatsAI.RT_Ranged,

Assault Cannon
		name = "assault_cannon",
		effectiveness = GenerateUnitEffectiveness(21,26,22,22,21,10,11,7,25,7,10),
		range = UnitStatsAI.RT_Ranged,

		name = "assault_cannon_vehicle",
		effectiveness = GenerateUnitEffectiveness(22,29,25,11,9,6,7,3,11,3,8),
		range = UnitStatsAI.RT_Ranged,

Autocannon
		name = "autocannon_vehicle",
		effectiveness = GenerateUnitEffectiveness(7,31,25,20,19,16,16,20,19,6,6),
		range = UnitStatsAI.RT_Ranged,

		name = "autocannon_twin_vehicle",
		effectiveness = GenerateUnitEffectiveness(11,39,34,31,29,26,27,17,23,19,19),
		range = UnitStatsAI.RT_Ranged,

Battlecannon
		name = "battlecannon_vehicle",
		effectiveness = GenerateUnitEffectiveness(5,5,5,5,5,13,13,13,5,13,3),
		range = UnitStatsAI.RT_Ranged,

Lascannon
	 	name = "lascannon_tactical",
		effectiveness = GenerateUnitEffectiveness(16,20,17,7,4,27,29,8,8,3,3),
		range = UnitStatsAI.RT_Ranged,

	 	name = "lascannon_vehicle",
		effectiveness = GenerateUnitEffectiveness(20,26,20,10,4,53,32,9,10,4,4),
		range = UnitStatsAI.RT_None,

                name = "lascannon_twin_vehicle",
		effectiveness = GenerateUnitEffectiveness(23,25,22,12,10,27,16,7,19,8,5),
            	range = UnitStatsAI.RT_Ranged,

Melta
		name = "melta_gun",
		effectiveness = GenerateUnitEffectiveness(2,3,6,11,13,16,14,9,8,15,15),
		range = UnitStatsAI.RT_Ranged,

		name = "melta_rifle",
		effectiveness = GenerateUnitEffectiveness(2,3,6,11,13,16,14,9,8,15,15),
		range = UnitStatsAI.RT_Ranged,

		name = "multi_melta",
		effectiveness = GenerateUnitEffectiveness(2,3,6,11,13,16,14,9,8,15,15),
		range = UnitStatsAI.RT_Ranged,

		name = "multimelta_vehicle",
		effectiveness = GenerateUnitEffectiveness(2,3,6,13,15,16,16,9,8,15,15),
		range = UnitStatsAI.RT_Ranged,

		name = "twin_multi_melta_vehicle",
		effectiveness = GenerateUnitEffectiveness(2,3,6,15,18,22,20,18,10,17,15),
		range = UnitStatsAI.RT_Ranged,

Specials
		name = "sniper_rifle",
		effectiveness = GenerateUnitEffectiveness(8,22,22,11,11,1,1,1,11,1,1),
		range = UnitStatsAI.RT_Ranged,

		name = "rifle_hellgun",
		effectiveness = GenerateUnitEffectiveness(16,14,15,11,9,9,8,7,7,9,3),
		range = UnitStatsAI.RT_Ranged,

		name = "daemon_fire",
		effectiveness = GenerateUnitEffectiveness(10,19,17,17,14,5,3,3,14,4,7),
		range = UnitStatsAI.RT_ShortRanged,

		name = "neuro_(bio)_pistol",
		effectiveness = GenerateUnitEffectiveness(6,7,6,10,11,4,7,9,8,8,9),
		range = UnitStatsAI.RT_ShortRanged,

		name = "shotgun",
		effectiveness = GenerateUnitEffectiveness(16,14,15,11,9,9,8,7,7,9,3),
		range = UnitStatsAI.RT_Ranged,

		name = "fusion_pistol",
		effectiveness = GenerateUnitEffectiveness(2,3,6,11,13,16,14,9,8,15,15),
		range = UnitStatsAI.RT_ShortRanged,

		name = "blasta",
		effectiveness = GenerateUnitEffectiveness(10,8,5,2,1,1,1,1,1,1,1),
		range = UnitStatsAI.RT_Melee,

		name = "bomb_launcher_vehicle",
		effectiveness = GenerateUnitEffectiveness(6,5,4,5,6,8,3,3,5,3,4),
		range = UnitStatsAI.RT_Ranged,

Melee
	  	name = "power_fist",
		effectiveness = GenerateUnitEffectiveness(17,26,20,21,9,8,8,5,20,5,11),
 		range = UnitStatsAI.RT_Melee,

		name = "power_claw",
		effectiveness = GenerateUnitEffectiveness(22,34,29,31,30,19,21,8,20,8,26),
 		range = UnitStatsAI.RT_Melee,

		name = "powersword",
		effectiveness = GenerateUnitEffectiveness(22,29,24,25,16,4,3,3,24,3,12),
 		range = UnitStatsAI.RT_Melee,

		name = "chainsword",
		effectiveness = GenerateUnitEffectiveness(18,23,19,20,20,3,3,3,19,3,10),
 		range = UnitStatsAI.RT_Melee,

		name = "powerlance",
		effectiveness = GenerateUnitEffectiveness(13,11,9,8,10,6,4,3,7,7,4),
 		range = UnitStatsAI.RT_Melee,

		name = "blade",
		effectiveness = GenerateUnitEffectiveness(10,9,8,7,6,12,5,9,4,10,5),
		range = UnitStatsAI.RT_Melee,

Eldar-specific
		name = "shuriken_catapult",
		effectiveness = GenerateUnitEffectiveness(6.86,5.87,4.9,3.92,1.5,1,0.5,0,2.17,0,6.49),
		range = UnitStatsAI.RT_ShortRanged,

		name = "shuriken_catapult_vehicle",
		effectiveness = GenerateUnitEffectiveness(3.61,3.02,3.01,2.27,2.532465,1.98,0.76,1.3779045,1.33,1.44943623,2.01),
		range = UnitStatsAI.RT_Ranged,

		name = "shuriken_pistol",
		effectiveness = GenerateUnitEffectiveness(10.97,8.53,7.31,7.31,3.96,2.43,0.92,0,4.07,7.1739773,6.08),
		effectiveness = GenerateUnitEffectiveness(5.19,4.62,4.04,3.46,3.08,6.31,2.82,6.11308425,4.5,8.06706427,3.38),
		effectiveness = GenerateUnitEffectiveness(1.179839,1.178659,0.588677,0.589919,1.218265016,2.646875,0.967675,0,0.984677,1.38003898,1.949218),
		range = UnitStatsAI.RT_Melee,

		name = "shuriken_cannon_vehicle",
		effectiveness = GenerateUnitEffectiveness(9.8875,7.75,6.6375,5.525,3.7986975,1.475,0.625,0,3.95,2.159513575,2.8375),
		effectiveness = GenerateUnitEffectiveness(3.75,3.78,2.78,3.75,3.155841,1.24,0.95,0,3.34,1.84473702,2.37),
		effectiveness = GenerateUnitEffectiveness(3.6,2.89,2.16,2.19,1.16883,3.85,2.19,2.65738725,1.44,7.11541422,0.91),
		range = UnitStatsAI.RT_Ranged,

		name = "reaper_launcher",
		effectiveness = GenerateUnitEffectiveness(3.77,1.39,1.09,6.41,8.467524,2.15,1.2,0,6.9,0,5.19),
		range = UnitStatsAI.RT_Ranged,

		name = "deathspinner",
		effectiveness = GenerateUnitEffectiveness(13.4,10.34,9.76,1.91,1.675323,1.91,0.72,0,2.19,1.37623238,3.29),
		range = UnitStatsAI.RT_Ranged,

		name = "brightlance_vehicle",
		effectiveness = GenerateUnitEffectiveness(2.5,1.69,0.75,1.63,0.701298,21.96,6.75,13.254129,2.11,6.16376417,1.51),
		effectiveness = GenerateUnitEffectiveness(0.72,0.73,0.72,0.72,0.623376,5.97,2.26,2.7339375,3.34,2.928154,1),
		effectiveness = GenerateUnitEffectiveness(0.33,8.91,4.455,4.95,5.94,3.3,19.695,11.91,18.02758388,6.6,23.16901853),
		range = UnitStatsAI.RT_Ranged,

		name = "scatter_laser_vehicle",
		effectiveness = GenerateUnitEffectiveness(3.8,2.65,2.22,2.25,3.220776,5.95,1.5,1.36696875,4,1.464077,1.89),
		range = UnitStatsAI.RT_None,

		name = "starcannon_vehicle",
		effectiveness = GenerateUnitEffectiveness(3.8,2.65,2.22,2.26,2.259738,9.63,3.92,4.418043,4.89,7.99386042,2.66),
		effectiveness = GenerateUnitEffectiveness(1.4,8.91,4.455,4.95,5.94,3.3,19.695,11.91,18.02758388,6.6,23.16901853),
		range = UnitStatsAI.RT_Ranged,

<race_name>buildbasestrategy.ai


<race_name>buildbasestrategy.ai – The master build file for your faction that controls how it builds important things for itself to stay competitive..


You can use the "marinebuildbasestrategy.ai" file as a basic template how to get your mod working. Of important note:


1) Ensure Squad and Support caps are included here IF your mod requires the AI to research them to gain higher unit populations. Use the Space Marine scripts as a guide for you.
2) If, however, squad/support caps are decided by the # of a certain building that is built then use either the Ork or Eldar scripts from their particular “buildbasestragy.ai” file.

attackstrategyinfo.ai


attackstrategyinfo.ai – File that controls the tolerance by which the AI will retreat when overwhelmed.


Deal with \Advanced first then trickle down to \Easy..


This is generally a good script to use:


<mod name>_race =
{
--my prorate against yours before I stop attacking you and retreat
stop_attack_rating = -100,
min_units = 2,

buildbasestrategyinfo.ai


buildbasestrategyinfo.ai – Controls general build toggles, research queue, and squad demand limits.


Deal with \Advanced first then trickle down to \Easy..


Follow these values as default below:


<mod name>_race =
{
--how much requisition I have before I try to build an uber unit
uber_unit_cost = <requisition cost of your uber unit>,
		
--minimum amount of power before I build another generator
min_power = 100,
		
resourcers = 2,
		
--reserve this amount for building units/buildings (not for use in upgrading/ reinforcing)
req_reserve = 200,

ETA =
{
cost = 250,
},

--attack rating needs to be greater than this prorated to attack
attack_rating = 150,
		
--need at least this at all times
squad_cap_threshold = 2,

--need at least 3 at all times
support_cap_threshold = 3,

--tolerance attacking turrets
turret_tolerance = 200,
		
--used to calculate wants for engineers
Engineers =
{
--number of engineers we're aiming for
want = 2,
},

ResearchOrder =
{
<ensure your AI researches everything it needs to "IN ORDER" the AI should and be careful of missing prerequistes that
can stop the AI from researching. Also, comment out any research that the AI won't be able to use or is redundant - 
a fast teching AI is always a good policy. However, include all research items your faction can research and then 
later on comment out those not needed!>
},

SquadLimits = 
{
standard = 
{
<create your squad list based on the order you put your units in unitstats.ai (ie. Engineers first and uber last)>
},
		
standard2 = 
{
                        
},

Notes on SquadLimits:
1) The # after the squad is the total # of that unit the AI can have playable in the game at one time so ensure you put a # in for the infantry and vehicle squads that equals to the max of the squad/support cap respectively.

As example:

space_marine_squad_scout = 3,
space_marine_squad_tactical = 4,
space_marine_squad_assault = 1,
space_marine_squad_terminator = 2,
space_marine_squad_terminator_assault = 2,

Notice that the # approaches a total value of 10. 10 Squad_tactical (marine squads) = full squad cap! Too add variety we limit other infantry units to a degree so they can be built. The grand total should be close to 10 so each squad gets between 1–4 as long as it adds up to 10 or the squad cap. Same will go for vehicles for their support cap! Don't worry about if your infantry totals go over 10 as in the above example – its all about what the AI fields on the map at that time that is important.

2) Engineers should always be set to “0” as the AI scripts create them based on necessity and should not be part of an attack force (unless this is what you want).

3) Have 2 SquadLimit sections as shown above with “standard” and “standard2” to add a limited variety to the limit the AI can build certain units.

buildorderstrategyinfo.ai


buildorderstrategyinfo.ai – Controls how the AI will initially build its base in the first minute of game time.


A good gamestart build order looks like this:


<mod name>_race =
{
{ "flag_capture" }, { "post_builder" },
{ "flag_capture" }, { "post_builder" },
{ "flag_capture" },
{ "squad", "<your scout unit>" },
{ "squad", "<your scout unit>" },
{ "squad", "<your builder unit>" }, 
{ "squad", "<your scout unit>" },
{ "building", "<your barracks building>", true },
{ "squad", "<your commander unit>", true },
{ "squad", "<your first-tier infantry unit>", true },
{ "building", "<your power generator building(if applicable)>" },

infantrytactic.ai


infantrytactic.ai – Dictates how general infantry use special abilities


-target ability table
InfantryTactic.TargetAbilities = 
{
{ nil, "<infantry anti-infantry weapon ability>",            Ability.Filters.CloseInfantryEnemy },
{ nil, "<infantry anti-vehicle weapon ability>",             Ability.Filters.CloseVehicleEnemy },


function InfantryTactic:DoAbilities()

		--check if I can use <this ability name>
		local <ability shortname>_id = cpu_manager.stats:GetAbilityID( "<actual ability name>" )
		Ability.DoAbilityArea( self.squad_ai, ability shortname>_id, Ability.Filters.<check filter section below> )

	if self.squad_ai:IsAttached() then

		<Commander Unit>Tactic.DoAbilities( self )

function InfantryTactic:Update()

		--check if I can use <this ability name>
		local <ability shortname>_id = cpu_manager.stats:GetAbilityID( "<actual ability name>" )

		if self.squad_ai:CanDoAbility( <ability shortname>_id ) then
			self.squad_ai:DoSpecialAbility( <ability shortname>_id )

	if cpu_manager.assassinate and 
		( self.squad_ai:HasSquadAttached( "<your commander unit>") or

vehicletactic.ai


vehicletactic.ai – Dictates how general vehicles use special abilities


function VehicleTactic:DoAbilities()

	--check if I can use <this ability name>
	   
		local <ability shortname>_id = cpu_manager.stats:GetAbilityID( "<actual ability name>" )
		if self.squad_ai:CanDoAbility( <ability shortname>_id ) then
		self.squad_ai:DoSpecialAbility( <ability shortname>_id )

<specific unit>tactic.ai


<specific unit>tactic.ai – Dictates how specialized units use their own special abilities not normally used by regular units.


General script format that works well is:


function <specific unit>Tactic:UpdateAbilities()

	if <ability shortname>_id == nil then
		<ability shortname>_id = cpu_manager.stats:GetAbilityID( "<actual ability name>" )
	end

function <specific unit>:DoAbilities()

	<specific unit>.UpdateAbilities( self )

	dbAssert( <ability shortname>_id ~= nil )

	Ability.DoAbility<SelectBehaviour>( self.squad_ai, <ability shortname>_id, Ability.Filters.<SelectFilter>, <# of enemy units nearby> )

Examples of ability scripts can be found using existing factions (a variety lumped together shown below):


function <specific unit>Tactic:UpdateAbilities()

	if FarSeer.storm_id == nil then
		FarSeer.storm_id = cpu_manager.stats:GetAbilityID( "eldar_psychic_storm" )
	end

	if FarSeer.eldritchstorm_id == nil then
		FarSeer.eldritchstorm_id = cpu_manager.stats:GetAbilityID( "eldar_eldritchstorm" )
	end
	
	if FarSeer.mind_war_id == nil then
		FarSeer.mind_war_id = cpu_manager.stats:GetAbilityID( "eldar_mind_war" )
	end
	
	if FarSeer.guide_id == nil then
		FarSeer.guide_id = cpu_manager.stats:GetAbilityID( "eldar_guide" )
	end
 
        if FarSeer.fleetoffoot_id == nil then
                FarSeer.fleetoffoot_id = cpu_manager.stats:GetAbilityID( "eldar_fleetoffoot" )
        end
	
        if MekBoy.zap_id == nil then
		MekBoy.zap_id = cpu_manager.stats:GetAbilityID( "ork_tank_zappa" )
	end

	if ChaosLord.strength_id == nil then
	        ChaosLord.strength_id = cpu_manager.stats:GetAbilityID( "chaos_daemon_strength" )	
	end

	if Sorcerer.torment == nil then
		Sorcerer.torment = cpu_manager.stats:GetAbilityID( "chaos_chains_of_torment" )
	end

	if Sorcerer.corruption == nil then
		Sorcerer.corruption = cpu_manager.stats:GetAbilityID( "chaos_corruption" )
	end
	
	if Sorcerer.doombolt_id == nil then
		Sorcerer.doombolt_id = cpu_manager.stats:GetAbilityID( "chaos_doombolt" )
	end

function <specific unit>Tactic:DoAbilities()
	
	<specific unit>Tactic.UpdateAbilities( self )
	
	dbAssert( FarSeer.storm_id ~= nil )
	dbAssert( FarSeer.mind_war_id ~= nil )
        dbAssert( ChaosLord.strength_id ~= nil )
	dbAssert( Sorcerer.torment ~= nil )
	dbAssert( Sorcerer.doombolt_id ~= nil )
	dbAssert( Sorcerer.corruption ~= nil )
	
	Ability.DoAbilityPos( self.squad_ai, FarSeer.storm_id, Ability.Filters.CloseInfantryEnemy, 6 ) 
	Ability.DoAbilityPos( self.squad_ai, FarSeer.eldritchstorm_id, Ability.Filters.CloseEnemy, 6 ) 
	Ability.DoAbilityTarget( self.squad_ai, FarSeer.mind_war_id, Ability.Filters.CloseCommanderEnemy ) 
	Ability.DoAbilityTarget( self.squad_ai, FarSeer.guide_id, Ability.Filters.CloseInCombat ) 
	Ability.DoAbilityFastMove( self.squad_ai, FarSeer.fleetoffoot_id, false )
	Ability.DoAbilityTarget( self.squad_ai, MekBoy.zap_id, Ability.Filters.CloseVehicleEnemy )
	Ability.DoAbility( self.squad_ai, ChaosLord.strength_id, Ability.Filters.IsInCombat ) 
	Ability.DoAbilityPos( self.squad_ai, Sorcerer.torment, Ability.Filters.CloseEnemy, 6 ) 
	Ability.DoAbilityPos( self.squad_ai, Sorcerer.corruption, Ability.Filters.CloseEnemy, 12 ) 
	Ability.DoAbilityPos( self.squad_ai, Sorcerer.doombolt_id, Ability.Filters.CloseInfantryEnemy, 6 )
Note: The # value at the end of each Filter denotes the # of enemy units that need to be present to activate the ability.

Links


AI Home
SCAR Home
Wiki Home

End of Page


Referring pages: DOWScar/AI

There are no files on this page. [Display files/form]
There is no comment on this page. [Display comments/form]