Jump to content
Sign in to follow this  
mankyle

AI using Air units?

Recommended Posts

Exactly what the question say.

I have edited a Warfare mission and I have added two new AITeamtypes that use the AH6 and AH1Z helicopters.

Unfortunately there must be something else to do to enable the AI use choppers or planes because anytime I click on respawn on a team that has the AH6 or AH1Z tags and I have enough resources and a working Aircraft factory the team respawns as a rifleman and that's all.

Could anyone point me to any other files that I may have skipped to enable those vehicles?

Thanks in advance

Share this post


Link to post
Share on other sites

Currently the Warfare community has not released any information pertaining to AI building, man and flying any air vehicles.

Share this post


Link to post
Share on other sites

Hi again, guys.

In the end I have finally achieve a modification of the AI so it uses helicopters.

I must say that due to the prices the quantity of spawned choppers is very short but I ended up with a huge surprise when an enemy KA-50 blasted me with missiles.

Now I have exactly discovered how to enable Air Teams so I will try to add planes to the AI options.

I will post my results here.

Share this post


Link to post
Share on other sites
Hi again, guys.

In the end I have finally achieve a modification of the AI so it uses helicopters.

I must say that due to the prices the quantity of spawned choppers is very short but I ended up with a huge surprise when an enemy KA-50 blasted me with missiles.

Now I have exactly discovered how to enable Air Teams so I will try to add planes to the AI options.

I will post my results here.

sounds intresting will be waiting for more info.

Share this post


Link to post
Share on other sites

Excellent...I don't need to see loads of AI choppers, but even an occasional one would add a lot to the game.

Share this post


Link to post
Share on other sites

I am more surprised that the AI Chopper actually shot at something.

Share this post


Link to post
Share on other sites

O i cant wait how did you do it?

I had them in warfare but they where part of the support pack not built into the warfare price system

Share this post


Link to post
Share on other sites

Well, actually it is a matter of editing three files

server/AI/advanced/advanced_updatesquad.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;Last modified 4/6/8

;Use on a group to give it AI control.

;Script usage: [GroupName,GroupSlot] Exec "UpdateIndependentAI.sqs"

_team = _this Select 0

_respawnable = true

_role = true

_mission = -1

if (Count _this > 1) then {_respawnable = _this Select 1};

if (Count _this > 2) then {_mission = _this Select 2};

Goto "Init"

#Update

~5

;Do not proceed unless team is AI controlled.

; if (!(_team In eastAITeams) && !(_team In westAITeams)) then {Exit};

if (Call Compile Format["!(_team In %1AITeams) && !(_team In %1DefenseTeams)",_sideText]) then {Exit};

;Check for AI state change and if enough time has passed to update current state.

#UpdateState

_leader = Leader _team

Call Compile Format["_teamType = %1AITeamType;_mission = %1AIMission",_name]

_base = Call Compile Format["%1Base",_sideText]

_lastTeamType = _teamType

_lastMission = _mission

_timePartialUpdate = _timePartialUpdate - 5

_timeFullUpdate = _timeFullUpdate - 5

_infantryTime = _infantryTime - 5

_lightTime = _lightTime - 5

_heavyTime = _heavyTime - 5

_aircraftTime = _aircraftTime - 5

if (!Alive _leader) then {Goto "WaitForRespawn"};

if (_teamType != _lastTeamType || _mission != _lastMission) then {_lastDestination = ObjNull;Goto "UpdateRole"};

if (_mission == MISMOVETODESTINATION && (Call Compile Format["%1AIMissionX != _lastX || %1AIMissionY != _lastY",_name])) then {_lastDestination = ObjNull;Goto "UpdateRole"};

if (_timePartialUpdate > 0) then {Goto "Update"} else {_timePartialUpdate = 15};

_purchase = false

;Update leader, formation, etc. every partial update.

Goto "UpdateLeader"

#CheckForFullUpdate

;If a full update occurs, check goals, location to move to, purchases, etc.

if (_timeFullUpdate > 0) then {Goto "Update"};

;Determine which AI role needs to be executed.

#UpdateRole

_purchase = false

_timePartialUpdate = 15

_timeFullUpdate = 30

_funds = _team Call GetTeamFunds

_teamUnits = _teamTypes Select _teamType

;Calculate units in team.

_teamMaxSize = Count _teamUnits;

;For infantry team types the leader must also be counted.

if (_teamType In _infantryTypes) then {_teamMaxSize = _teamMaxSize + 1};

;Add second unit for any vehicles.

{if ((_x In lightUnits) || (_x In heavyUnits) || (_x In aircraftUnits)) then {_teamMaxSize = _teamMaxSize + 1};} ForEach _teamUnits

#UpdatePurchases

;ToDo: Check if leader is stuck.

;Try not to exceed team size.

_teamSize = Count (Units _team Call GetLiveUnits)

if (_teamSize >= _teamMaxSize) then {Goto "UpdateGoal"};

;Determine factories that need to be used.

_useBarracks = false

_useLight = false

_useHeavy = false

_useAircraft = false

_minFundsNeeded = 0

if (_teamType In _infantryTypes && _infantryTime <= 0) then {_useBarracks = true;_minFundsNeeded = _minFundsNeeded + AIMINBARRACKSFUNDS};

if (_teamType In _lightTypes && _lightTime <= 0) then {_useLight = true;_minFundsNeeded = _minFundsNeeded + AIMINLIGHTFUNDS};

if (_teamType In _heavyTypes && _heavyTime <= 0) then {_useHeavy = true;_minFundsNeeded = _minFundsNeeded + AIMINHEAVYFUNDS};

if (_teamType In _airTypes && _aircraftTime <= 0) then {_useAircraft = true;_minFundsNeeded = _minFundsNeeded + AIMINAIRCRAFTFUNDS};

; if (!_useBarracks && !_useLight && !_useHeavy && !_useAircraft) then {Goto "UpdateGoal"};

if (_minFundsNeeded > _funds) then {Goto "UpdateGoal"};

;Do not attempt to purcahse vehicles if limit has been reached.

;if (_side == west && westTotalVehicles >= maxVehicles) then {_useLight = false;_useHeavy = false;_useAircraft = false};

;if (_side == east && eastTotalVehicles >= maxVehicles) then {_useLight = false;_useHeavy = false;_useAircraft = false};

_nearestBarracks = ObjNull

_nearestLight = ObjNull

_nearestHeavy = ObjNull

_nearestAircraft = ObjNull

;Attempt to get nearest barracks from leader.

_nearestObjects = []

if (_useBarracks) then {_nearestObjects = nearestObjects[_leader,[_barracksName],500]};

if (_useBarracks && Count _nearestObjects > 0) then {_nearestBarracks = _nearestObjects Select 0};

if (_useLight) then {_nearestObjects = nearestObjects[_leader,[_lightName],500]} else {_nearestObjects = []};

if (_useLight && Count _nearestObjects > 0) then {_nearestLight = _nearestObjects Select 0};

if (_useHeavy) then {_nearestObjects = nearestObjects[_leader,[_heavyName],500]} else {_nearestObjects = []};

if (_useHeavy && Count _nearestObjects > 0) then {_nearestHeavy = _nearestObjects Select 0};

if (_useAircraft) then {_nearestObjects = nearestObjects[_leader,[_aircraftName],500]} else {_nearestObjects = []};

if (_useAircraft && Count _nearestObjects > 0) then {_nearestAircraft = _nearestObjects Select 0};

_transportOnly = true

_inRangeDistance = 0

_currentUnit = _leader

#CheckPurchase

_buyLight = false

_aircraftAvailable = false

_heavyAvailable = false

_lightAvailable = false

_barracksAvailable = false

_range = AIPURCHASERANGE

;If leader is in an immobile vehicle (like a stationary gun) then extend purchase range to defend range.

if (_leader != Vehicle _leader && (!(CanMove (Vehicle _leader)) || (IsNull Driver (Vehicle _leader)))) then {_range = AIDEFENDLOCATIONRANGE};

;If structure is in range, not being used, and group is small enough then flag it as usable.

if (!IsNull _nearestAircraft && (_leader Distance _nearestAircraft < _range)) then {_aircraftAvailable = true};

if (!IsNull _nearestHeavy && (_leader Distance _nearestHeavy < _range)) then {_heavyAvailable = true};

if (!IsNull _nearestLight && (_leader Distance _nearestLight < _range)) then {_lightAvailable = true};

if (!IsNull _nearestBarracks && (_leader Distance _nearestBarracks < _range)) then {_barracksAvailable = true};

_barracksUnits = []

_lightUnits = []

_heavyUnits = []

_aircraftUnits = []

;Compile lists of units based on factory types.

if (_barracksAvailable) then {{if (_x In soldierUnits) then {_barracksUnits = _barracksUnits + [_x]};} ForEach _teamUnits};

if (_lightAvailable) then {{if (_x In lightUnits) then {_lightUnits = _lightUnits + [_x]};} ForEach _teamUnits};

if (_heavyAvailable) then {{if (_x In heavyUnits) then {_heavyUnits = _heavyUnits + [_x]};} ForEach _teamUnits};

if (_aircraftAvailable) then {{if (_x In aircraftUnits) then {_aircraftUnits = _aircraftUnits + [_x]};} ForEach _teamUnits};

;Purchase all barracks units.

if (_barracksAvailable) then {[_barracksType,_nearestBarracks,_team,_barracksUnits] Exec "Server\Server_AITeamBuyUnits.sqs";_purchase = true;_infantryTime = 120};

;Purchase all light units.

if (_lightAvailable) then {[_lightType,_nearestLight,_team,_lightUnits] Exec "Server\Server_AITeamBuyUnits.sqs";_purchase = true;_lightTime = 120};

;Purchase all heavy units.

if (_heavyAvailable) then {[_heavyType,_nearestHeavy,_team,_heavyUnits] Exec "Server\Server_AITeamBuyUnits.sqs";_purchase = true;_heavyTime = 120};

;Purchase all aircraft units.

if (_aircraftAvailable) then {[_aircraftType,_nearestAircraft,_team,_aircraftUnits] Exec "Server\Server_AITeamBuyUnits.sqs";_purchase = true;_aircraftTime = 120};

r

;If team does not need a barracks & nothing is available then don't wait around.

;However, wait around for the first 3 minutes incase a factory is constructed.

if (!_aircraftAvailable && !_lightAvailable && !_heavyAvailable && !_useBarracks && time > 180) then {Goto "UpdateGoal"};

if (_useBarracks && !_barracksAvailable && _leader Distance _base > AIREINFORCERANGE) then {Goto "UpdateGoal"};

;Return to base for reinforcements if team is very small or it is just convenient.

#CheckReturnToBase

_distance = 100000

_factories = [_nearestBarracks,_nearestLight,_nearestHeavy,_nearestAircraft]

_factories = _factories - [ObjNull]

_nearestFactory = ObjNull

{if (_leader Distance _x < _distance) then {_distance = _leader Distance _x;_nearestFactory = _x};} ForEach _factories

if (_teamSize < MINAIGROUPSIZE && !IsNull _nearestFactory) then {Goto "ReturnToFactory"};

if (_teamSize < (_teamMaxSize * 0.75) && !IsNull _nearestFactory && _distance < AIREINFORCERANGE) then {Goto "ReturnToFactory"};

#UpdateLeader

;goto "CheckForFullUpdate"

;If leader is in a mobile vehicle then skip this section.

? (_leader != Vehicle _leader) && (CanMove Vehicle _leader):goto "UpdateMembers"

_teamVehicles = [_team,true,_leader,AIEMBARKVEHICLERANGE] Call GetTeamVehicles

#EmbarkLeader

;If leader has been trying to enter vehicle for multiple updates then teleport into vehicle now.

? (_embarkLeader > 2):_currentUnit MoveInDriver (_teamVehicles Select 0);_embarkLeader = 0;goto "UpdateMembers"

? (Count _teamVehicles > 0):_embarkLeader = _embarkLeader + 1;_embarkAsDriverInTeamVehicleReturn = "UpdateMembers";goto "EmbarkAsDriverInTeamVehicle"

_embarkLeader = 0

#UpdateMembers

_infantryCount = 0

_units = Units _team

_units = _units - [_leader]

_unitsOutOfFormation = []

_outOfFormation = false

_totalUnits = Count _units

? (_totalUnits < 1):_updateFormationReturn = "CheckForFullUpdate";goto "UpdateFormation"

#UpdateMember

;ToDo: Check if free gunner or driver positions are available & move unit into one.

_currentUnit = _units Select _infantryCount

_infantryCount = _infantryCount + 1

_vehicle = Vehicle _currentUnit

if (GetDammage _currentUnit >= 1) then {Goto "UpdateNextMember"};

;If the destination is far away embark in a transport if available.

? (_currentUnit Distance _destinationObject > AIDISEMBARKVEHICLERANGE):goto "EmbarkMember"

;Otherwise disembark if in a transport & not one of the crew.

? (_currentUnit != _vehicle) && (Driver _vehicle != _currentUnit) && (Gunner _vehicle != _currentUnit) && (Commander _vehicle != _currentUnit):UnassignVehicle _currentUnit

goto "MemberOutOfRange"

#EmbarkMember

;If already in a vehicle.

? (_vehicle != _currentUnit) && (CanMove _vehicle):goto "MemberOutOfRange"

#MemberEmbarkTransport

_transport = ObjNull

_transports = [_team,_currentUnit,AIEMBARKVEHICLERANGE] Call GetTeamTransport

if (Count _transports > 0) then {_transport = _transports Select (Random (Count _transports - 1))};

if (IsNull _transport) then {Goto "MemberOutOfRange"};

if (_currentUnit Distance _transport > AIEMBARKVEHICLERANGE) then {Goto "MemberOutOfRange"};

_currentUnit AssignAsCargo _transport

[_currentUnit] OrderGetIn true

#MemberOutOfRange

_leaderDistance = _currentUnit Distance _leader

? (_leaderDistance <= AIFORMATIONRANGE):goto "UpdateNextMember"

;If unit is out of range of the team then proceed to the team independently.

;This prevents the team from slowing down and waiting.

_outOfFormation = true

_unitsOutOfFormation = _unitsOutOfFormation + [_currentUnit]

;If not near the leader DoMove to current position.

? (_leaderDistance < _currentUnit Distance _destinationObject):_currentUnit DoMove GetPos _leader;goto "UpdateNextMember"

_currentUnit DoMove GetPos _destinationObject

#UpdateNextMember

? (_infantryCount < _totalUnits):goto "UpdateMember"

_updateFormationReturn = "CheckForFullUpdate"

goto "UpdateFormation"

#UpdateFormation

;If anyone was out of formation previously order those now in range to follow.

? (_checkFormation):_checkFormation = false;_units = _units - [_unitsOutOfFormation];[_units] CommandFollow _leader

;If anyone is out of formation keep track of it for next update.

? (_outOfFormation):_outOfFormation = false;_checkFormation = true

goto _updateFormationReturn

#UpdateGoal

;If leader has purchased something and is near the base then wait around for it.

if ((_aircraftTime > 0 || _infantryTime > 0 || _lightTime > 0 || _heavyTime > 0) && _teamSize < _teamMaxSize && _leader Distance _base < AIPURCHASERANGE) then {Goto "Update"};

if (_mission == MISCAPTURELOCATIONS) then {Goto "CaptureLocations"};

if (_mission == MISDEFENDBASE) then {Goto "DefendBase"};

if (_mission == MISMOVETODESTINATION) then {Goto "MoveToDestination"};

if (_mission == MISPATROL) then {Goto "Patrol"};

; ? (_mission == MISDEFENDLOCATIONS):goto "CheckDefendTargets"

goto "Update"

;Return to position in front of factory.

#ReturnToFactory

_direction = ((GetDir _nearestFactory + 180) + (Random 5) - 10) % 360

_distance = 30

_position = GetPos _nearestFactory

_destination = [(_position Select 0)+((sin _direction)*_distance),(_position Select 1)+((cos _direction)*_distance),_position Select 2]

_destination = [_destination,14,20] Call GetRandomPosition

_destinationObject SetPos _destination

_team Move _destination

_lastDestination = ObjNull

if (!(CanMove (Vehicle _leader)) || (IsNull Driver (Vehicle _leader))) then {UnassignVehicle _leader};

Goto "Update"

#EmbarkAsDriverInTeamVehicle

; _vehicle = _teamVehicles Select (Random (Count _teamVehicles))

_vehicle = _teamVehicles Select 0

UnassignVehicle Driver _vehicle

;_currentUnit DoMove GetPos _vehicle

_currentUnit AssignAsDriver _vehicle

;[_currentUnit] OrderGetIn true

goto _embarkAsDriverInTeamVehicleReturn

;Check if AI teams need to defend a target or just take towns.

#CheckDefendTargets

_totalGroups = Count _defenseTeams

? !(_team In _defenseTeams) || (_totalGroups < 1):goto "TakeTownsAndBases"

_count = 0

#FindDefenseTeam

_defender = _defenseTeams Select _count

? (_defender == _team):goto "SetDefenseTeam"

_count = _count + 1

? (_count < _totalGroups):goto "FindDefenseTeam"

goto "TakeTownsAndBases"

#SetDefenseTeam

? ((Count _defendedTargets) <= _count):goto "TakeTownsAndBases"

_closestTarget = _defendedTargets Select _count

;AI routines for defending towns.

#DefendTowns

_goalLoopCount = _goalLoopCount + 1

? (_goalLoopCount < 3) && !(_reportMission):goto "Update"

_goalLoopCount = 0

if (!Alive _leader) then {Goto "WaitForRespawn"};

; ? (_reportMission) && (_side == west):westMessage = messageOrderDefend;PublicVariable "westMessage";westPlayerMessageGroupFrom = _teamValue;PublicVariable "westPlayerMessageGroupFrom";_reportMission = false;_closestTarget = ObjNull

; ? (_reportMission) && (_side == east):eastMessage = messageOrderDefend;PublicVariable "eastMessage";eastPlayerMessageGroupFrom = _teamValue;PublicVariable "eastPlayerMessageGroupFrom";_reportMission = false;_closestTarget = ObjNull

;If a town was previously chosen and in range then do a patrol.

if (!IsNull _defendLocation) then {Goto "MoveToClosestDefendTarget"};

_nearestDistance = 100000

_count = 0

_total = Count locations

;If no friendly locations exist then attempt to find a nearby hostile location.

#FindDefendLocation

_location = locations Select _count

_locationSide = (Call Compile Format["%1SideID",Str _location]) Call GetSideFromID

_distance = _location Distance _leader

if (_locationSide == _side && _distance < _nearestDistance) then {_defendLocation = _location;_nearestDistance = _distance};

_count =_count + 1

if (_count < _total) then {goto "FindDefendLocation"};

#MoveToClosestDefendTarget

; ? (IsNull _closestTarget) && (_side == west):westMessage = messageOrderDefendDenied;PublicVariable "westMessage";westPlayerMessageGroupFrom = _teamValue;PublicVariable "westPlayerMessageGroupFrom"

; ? (IsNull _closestTarget) && (_side == east):eastMessage = messageOrderDefendDenied;PublicVariable "eastMessage";eastPlayerMessageGroupFrom = _teamValue;PublicVariable "eastPlayerMessageGroupFrom"

if (_leader Distance _defendLocation < targetDefendRange) then {Goto "DefendTarget"};

_destinationObject SetPos GetPos _defendLocation

_team Move GetPos _destinationObject

goto "Update"

#DefendBase

if (!Alive _leader) then {Goto "WaitForRespawn"};

_moveCount = _moveCount + 1

if (!IsNull _lastDestination && _moveCount < 2) then {Goto "Update"};

_moveCount = 0

_lastDestination = _base

_destinationObject SetPos (GetPos _base)

_units = Units _team Call GetLiveUnits

Call Compile Format["%1AIMissionX = GetPos _destinationObject Select 0",_name]

Call Compile Format["%1AIMissionY = GetPos _destinationObject Select 1",_name]

Call Compile Format["PublicVariable ""%1AIMissionX"";PublicVariable ""%1AIMissionY""",_name]

;Make available units patrol base area.

{if (CanMove _x) then {_x DoMove ([GetPos _base,12,AIDEFENDLOCATIONRANGE] Call GetRandomPosition)};} ForEach _units

if (_leader Distance _base < AIDEFENDLOCATIONRANGE) then {[Units _team,AIDEFENDLOCATIONRANGE] Call UseStationaryDefense};

Goto "Update"

#CaptureLocations

if (!Alive _leader) then {Goto "WaitForRespawn"};

if (IsNull _lastDestination) then {Goto "FindHostileLocation"};

;In case team is stuck, reissue move order.

_moveCount = _moveCount + 1

if (_moveCount > 5) then {_moveCount = 0;_team Move GetPos _lastDestination};

if (!(_lastDestination In towns)) then {Goto "FindHostileLocation"};

;Do not check for a new destination if previous is not too far away & still hostile.

_locationSide = (Call Compile Format["%1SideID",Str _lastDestination]) Call GetSideFromID

if (_locationSide != _side && _lastDestination Distance _leader < 600) then {Goto "Update"};

#FindHostileLocation

_location = [_leader,_side] Call GetClosestHostileLocation

if (_leader Distance _base > BASERANGE) then {Goto "FindHostileBase"};

;If team is near base and there are multiple nearby locations then divide teams up amongst them.

_locations = [_base,_side,CAPTUREFROMBASERANGE] Call GetClosestHostileLocations

if (Count _locations > 1) then {_location = _locations Select (_index % (Count _locations))};

#FindHostileBase

;This will prevent the enemy from attacking the base when there are no players.

if (longerPersistentServerGame && PlayersNumber East < 1 && PlayersNumber West < 1) then {Goto "MoveToLocation"};

_enemyBase = WestBase

if (_side == West) then {_enemyBase = EastBase};

if (_leader Distance _enemyBase < _leader Distance _location) then {_location = _enemyBase};

Goto "MoveToLocation"

#MoveToLocation

if (IsNull _location) then {Goto "Update"};

if (_lastDestination == _location) then {Goto "Update"};

_lastDestination = _location

_destinationObject SetPos ([GetPos _location,18,24] Call GetRandomPosition)

Call Compile Format["%1AIMissionX = GetPos _location Select 0",_name]

Call Compile Format["%1AIMissionY = GetPos _location Select 1",_name]

Call Compile Format["PublicVariable ""%1AIMissionX"";PublicVariable ""%1AIMissionY""",_name]

_team Move GetPos _destinationObject

goto "Update"

#MoveToDestination

_moveCount = _moveCount + 1

if (!IsNull _lastDestination && _moveCount < 2) then {Goto "Update"};

_moveCount = 0

_lastX = Call Compile Format["%1AIMissionX",_name]

_lastY = Call Compile Format["%1AIMissionY",_name]

_destinationObject SetPos [_lastX,_lastY]

_lastDestination = _destinationObject

_team Move GetPos _destinationObject

goto "Update"

#Patrol

_moveCount = _moveCount + 1

if (!IsNull _lastDestination && _moveCount < 2) then {Goto "Update"};

_moveCount = 0

_x = Call Compile Format["%1AIMissionX",_name]

_y = Call Compile Format["%1AIMissionY",_name]

_destinationObject SetPos ([[_x,_y,0],5,AIPATROLRANGE] Call GetRandomPosition)

_lastDestination = _destinationObject

_team Move GetPos _destinationObject

goto "Update"

#SearchAndDestroy

_location = locations Select (Random (Count Locations - 1))

_position = GetPos _location

; ? (_side == west) && !(IsNull westBaseFound) && (GetDammage westBaseFound < 1):_position = GetPos westBaseFound

; ? (_side == east) && !(IsNull eastBaseFound) && (GetDammage eastBaseFound < 1):_position = GetPos eastBaseFound

; ? (_baseFound):_x = (_position Select 0) + (Random 200) - 100;_y = (_position Select 1) + (Random 200) - 100;goto "MoveToSearchAndDestroyTarget"

_leaderPosition = GetPos _leader

_x = (_position Select 0) + (((_leaderPosition Select 0) - (_position Select 0)) / 2) * (Random 1)

_y = (_position Select 1) + (((_leaderPosition Select 1) - (_position Select 1)) / 2) * (Random 1)

#MoveToSearchAndDestroyTarget

_destinationObject SetPos [_x,_y,0]

_team Move [_x,_y]

goto "Update"

#WaitForRespawn

~2

_lastDestination = ObjNull

if (_respawnable) then {Goto "WaitForLeaderRespawn"};

_units = Units _team Call GetLiveUnits

if (Count _units > 0) then {_team SelectLeader (_units Select 0);Goto "WaitForLeaderRespawn"};

_base = Call Compile Format["%1Base",_sideText]

_unitType = ESOLDIER

if (_side == West) then {_unitType = WSOLDIER};

_leader = _team CreateUnit[_unitType,([GetPos _base,10,25] Call GetRandomPosition),[],1,"FORM"]

[_leader,_side] Call InitUnit

_team SelectLeader _leader

~13

Goto "UpdateRole"

#WaitForLeaderRespawn

@ (Alive Leader _team)

_leader = Leader _team

goto "UpdateRole"

#Init

;Only execute this on the server.

if (!IsServer) then {Exit};

_side = Side Leader _team

_sideText = Str _side

_respawnMarker = "EastTempRespawnMarker"

if (_side == West) then {_respawnMarker = "WestTempRespawnMarker"};

_index = Call Compile Format["%1Teams Find _team",_sideText]

;If not on the standard team then see if it is an AI defense team.

if (_index < 0) then {_index = Call Compile Format["%1DefenseTeams Find _team",_sideText];if (_index >= 0) then {_index = _index + Call Compile Format["Count %1Teams",_sideText]};};

_index = _index + 1

_name = Format["%1Team%2",_sideText,_index]

;If the unit is a player then don't run the AI routines.

if (IsPlayer Leader _team) then {Exit};

if (!Local Leader _team) then {Exit};

if (_respawnable) then {[_team,_name] Spawn UpdateSquadRespawn};

~2

;In case this was previously a player.

Leader _team removeAllEventHandlers "killed"

[Leader _team,_side] Call InitUnit

@ (gameStarted)

Call Compile Format["%1AIMission = MISCAPTURELOCATIONS",_name]

Call Compile Format["%1AIMissionX = -1",_name]

Call Compile Format["%1AIMissionY = -1",_name]

_lastX = -1

_lastY = -1

;Default team type, player commander can change this.

Call Compile Format["%1AITeamType = %2AIDEFAULTTEAMTYPE",_name,_sideText]

;If an AI commander then set this team's type according to defined template.

if (!Call Compile Format["IsNull %1CommanderTeam",_sideText]) then {Goto "SkipCommanderInit"};

if (_mission != -1) then {Goto "SkipCommanderInit"};

_AITypes = Call Compile Format["%1AITeamTypes",_sideText]

;Get AI slot instead of team slot since there may be less AI teams than total teams.

_AISlot = Call Compile Format["%1AITeams Find _team",_sideText]

;Assign first two AI teams to base defense.

; if (_AISlot == 0 || _AISlot == 1) then {Call Compile Format["%1AIMission = MISDEFENDBASE",_name]};

; if (_AISlot == 0 || _AISlot == 1) then {Call Compile Format["%1AITeamType = %2AIDEFAULTTEAMTYPE",_name,_sideText]};

;If AI index is bigger than the list then increase it.

if (_AISlot >= Count _AITypes) then {_AITypes =_AITypes + _AITypes + _AITypes};

Call Compile Format["%1AITeamType = _AITypes Select _AISlot",_name]

#SkipCommanderInit

;_mission is usually set when team is a defense team.

if (_mission != -1) then {Call Compile Format["%1AIMission = _mission",_name]};

if (_mission == MISPATROL) then {Call Compile Format["%1AITeamType = %2AIBASEPATROLTEAMTYPE",_name,_sideText]};

if (_mission == MISDEFENDBASE) then {Call Compile Format["%1AITeamType = %2AIBASEDEFENSETEAMTYPE",_name,_sideText]};

if (_mission == MISDEFENDLOCATIONS) then {Call Compile Format["%1AITeamType = %2AIATAATEAMTYPE",_name,_sideText]};

;Patrol missions default at base.

_position = Call Compile Format["GetPos %1Base",_sideText]

if (_mission == MISPATROL) then {Call Compile Format["%1AIMissionX = _position Select 0;%1AIMissionY = _position Select 1",_name]};

Call Compile Format["PublicVariable ""%1AIMission""",_name]

Call Compile Format["PublicVariable ""%1AITeamType""",_name]

Call Compile Format["PublicVariable ""%1AIMissionX""",_name]

Call Compile Format["PublicVariable ""%1AIMissionY""",_name]

_teamType = 0

_lastTeamType = -1

_mission = 0

_lastMission = -1

_funds = 0

_lastDestination = ObjNull

;Stagger execution for each team a little.

~(10 + _index * 2)

_timePartialUpdate = 15

_timeFullUpdate = 45

_moveCount = 0

;Timers to prevent purchasing same units too soon.

_aircraftTime = 0

_infantryTime = 0

_lightTime = 0

_heavyTime = 0

_killed = false

_embarkLeader = 0

_checkFormation = true

_reportMission = false

_defendingTarget = true

_goalLoopCount = 0

_unitsBought = 0

_returnToBase = false

_aircraftType = Call Compile Format["%1AIRCRAFTTYPE",_sideText]

_aircraftName = Call Compile Format["%1StructureNames Select _aircraftType",_sideText]

_barracksType = Call Compile Format["%1BARRACKSTYPE",_sideText]

_barracksName = Call Compile Format["%1StructureNames Select _barracksType",_sideText]

_lightType = Call Compile Format["%1LIGHTTYPE",_sideText]

_lightName = Call Compile Format["%1StructureNames Select _lightType",_sideText]

_heavyType = Call Compile Format["%1HEAVYTYPE",_sideText]

_heavyName = Call Compile Format["%1StructureNames Select _heavyType",_sideText]

_airTypes = Call Compile Format["%1AirTeamTypes",_sideText]

_infantryTypes = Call Compile Format["%1InfantryTeamTypes",_sideText]

_lightTypes = Call Compile Format["%1LightTeamTypes",_sideText]

_heavyTypes = Call Compile Format["%1HeavyTeamTypes",_sideText]

_teamTypes = Call Compile Format["%1AITeamTemplates",_sideText]

_destinationObject = "Logic" CreateVehicle [0,0,0]

_team SetFormation "WEDGE"

_team SetSpeedMode "NORMAL"

Goto "Update"

server/AI/Advanced/advanced_updatesquadrespawn.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">//Last modified 4/6/8

//*****************************************************************************************

//Description: Handles respawn of AI Leader.

//*****************************************************************************************

Private["_airTypes","_aircraft","_barracks","_base","_body","_heavy","_heavyTypes","_infantryTypes","_leader","_light","_lightTypes","_list","_name","_position","_respawnMarker","_sideText","_sorted","_team","_teamType"];

_team = _this Select 0;

_name = _this Select 1;

_sideText = Str Side _team;

_respawnMarker = Format["%1TempRespawnMarker",_sideText];

_airTypes = Call Compile Format["%1AirTeamTypes",_sideText];

_infantryTypes = Call Compile Format["%1InfantryTeamTypes",_sideText];

_lightTypes = Call Compile Format["%1LightTeamTypes",_sideText];

_heavyTypes = Call Compile Format["%1HeavyTeamTypes",_sideText];

_aircraft = Call Compile Format["%1StructureNames Select %1AIRCRAFTTYPE",_sideText];

_barracks = Call Compile Format["%1StructureNames Select %1BARRACKSTYPE",_sideText];

_light = Call Compile Format["%1StructureNames Select %1LIGHTTYPE",_sideText];

_heavy = Call Compile Format["%1StructureNames Select %1HEAVYTYPE",_sideText];

while {!IsPlayer Leader _team} do

{

WaitUntil {!Alive Leader _team || IsPlayer Leader _team};

if (!IsPlayer Leader _team) then

{

_body = Leader _team;

WaitUntil {Alive Leader _team || IsPlayer Leader _team};

if (!IsPlayer Leader _team) then

{

_leader = Leader _team;

_leader SetPos GetMarkerPos _respawnMarker;

Sleep 14;

if (Alive _leader) then

{

_base = Call Compile Format["%1Base",_sideText];

_teamType = Call Compile Format["%1AITeamType",_name];

_structures = Call Compile Format["%1BaseStructures",_sideText];

_list = [];

//Find closest factory to respawn to.

if (_teamType In _airTypes) then

{

{if ((TypeOf _x) == _aircraft && GetDammage _x < 1) then {_list = _list + [_x]};} ForEach _structures;

};

if (_teamType In _infantryTypes) then

{

{if ((TypeOf _x) == _barracks && GetDammage _x < 1) then {_list = _list + [_x]};} ForEach _structures;

};

if (_teamType In _lightTypes) then

{

{if ((TypeOf _x) == _light && GetDammage _x < 1) then {_list = _list + [_x]};} ForEach _structures;

};

if (_teamType In _heavyTypes) then

{

{if ((TypeOf _x) == _heavy && GetDammage _x < 1) then {_list = _list + [_x]};} ForEach _structures;

};

_position = [GetPos _base,10,25] Call GetRandomPosition;

if (Count _list > 0) then

{

_sorted = [_body,_list] Call SortByDistance;

_position = [GetPos (_sorted Select 0),10,25] Call GetRandomPosition;

};

_leader SetPos _position;

_leader RemoveAllEventHandlers "killed";

[_leader,Side _team] Call InitUnit;

_leader Call EquipDefaultLoadout;

};

};

};

};

and finally,

common/config/config_AITeams.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;Last modified 4/23/8

;*****************************************************************************************

;Description: defines AI teams.

;*****************************************************************************************

;WEST

WestAITeamTemplates = []

WestInfantryTeamTypes = []

WestDefenseTeamTypes = []

WestLargeDefenseTeamTypes = []

WestLightTeamTypes = []

WestHeavyTeamTypes = []

WestAirTeamTypes = []

_n = ["Infantry"]

_d = ["Infantry"]

_u = [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WMGSOLDIER]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIDEFAULTTEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAIDEFAULTTEAMTYPE]

_n = _n + ["AT"]

_d = _d + ["AT"]

_u = [WATSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WATSOLDIER]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIATTEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAIATTEAMTYPE]

_n = _n + ["AA"]

_d = _d + ["AA"]

_u = [WAASOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WAASOLDIER]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIAATEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAIAATEAMTYPE]

_n = _n + ["Sniper"]

_d = _d + ["Sniper"]

_u = [WSNIPER]

_u = _u + [WSOLDIER]

_u = _u + [WSNIPER]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAISNIPERTEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAISNIPERTEAMTYPE]

_n = _n + ["BlackOps"]

_d = _d + ["Black Ops"]

_u = [WSPECOP]

_u = _u + [WSPECOPSNIPER]

_u = _u + [WSPECOP]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIBLACKOPSTEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAIBLACKOPSTEAMTYPE]

;Team type with this name must always be present.

_n = _n + ["ATAA"]

_d = _d + ["AT/AA"]

_u = [WATSOLDIER]

_u = _u + [WAASOLDIER]

_u = _u + [WATSOLDIER]

_u = _u + [WSOLDIER]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIATAATEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAIATAATEAMTYPE]

WestDefenseTeamTypes = WestInfantryTeamTypes + [WESTAIATAATEAMTYPE]

_n = _n + ["HummerAssault"]

_d = _d + ["HMMWV Assault"]

_u = ["HMMWV50"]

_u = _u + ["HMMWVMK"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIHMMWVTEAMTYPE = Count WestAITeamTemplates - 1

WestLightTeamTypes = WestLightTeamTypes + [WESTAIHMMWVTEAMTYPE]

_n = _n + ["HummerAssault"]

_d = _d + ["HMMWV AT"]

_u = ["HMMWVTOW"]

_u = _u + ["HMMWVMK"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIHMMWVATTEAMTYPE = Count WestAITeamTemplates - 1

WestLightTeamTypes = WestLightTeamTypes + [WESTAIHMMWVATTEAMTYPE]

_n = _n + ["M113"]

_d = _d + ["M113"]

_u = ["M113"]

_u = _u + ["M113"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIM113TEAMTYPE = Count WestAITeamTemplates - 1

WestLightTeamTypes = WestLightTeamTypes + [WESTAIM113TEAMTYPE]

_n = _n + ["Vulcan"]

_d = _d + ["Vulcan"]

_u = ["Vulcan"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIVULCANTEAMTYPE = Count WestAITeamTemplates - 1

WestHeavyTeamTypes = WestHeavyTeamTypes + [WESTAIVULCANTEAMTYPE]

_n = _n + ["Stryker"]

_d = _d + ["Stryker"]

_u = ["Stryker_ICV_M2"]

_u = _u + ["Stryker_TOW"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAISTRYKERTEAMTYPE = Count WestAITeamTemplates - 1

WestHeavyTeamTypes = WestHeavyTeamTypes + [WESTAISTRYKERTEAMTYPE]

_n = _n + ["Tank"]

_d = _d + ["Tank"]

_u = ["M1Abrams"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIM1TEAMTYPE = Count WestAITeamTemplates - 1

WestHeavyTeamTypes = WestHeavyTeamTypes + [WESTAIM1TEAMTYPE]

_n = _n + ["AH-6"]

_d = _d + ["AH-6"]

_u = ["AH6"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIAH6TEAMTYPE = Count WestAITeamTemplates - 1

WestAirTeamTypes = WestAirTeamTypes + [WESTAIAH6TEAMTYPE]

_n = _n + ["AH-1W"]

_d = _d + ["AH-1W"]

_u = ["AH1W"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIAH1WTEAMTYPE = Count WestAITeamTemplates - 1

WestAirTeamTypes = WestAirTeamTypes + [WESTAIAH1WTEAMTYPE]

;Team type with this name must always be present.

;Special defense team for the base, normal AI team cannot be set to this.

_n = _n + ["BasePatrol"]

;Description was be kept blank so player commander cannot use this team.

_d = _d + [""]

_u = [WATSOLDIER]

_u = _u + [WAASOLDIER]

_u = _u + [WATSOLDIER]

_u = _u + [WAASOLDIER]

_u = _u + [WMGSOLDIER]

_u = _u + [WMEDIC]

_u = _u + ["Vulcan"]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIBASEPATROLTEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAIBASEPATROLTEAMTYPE]

WestHeavyTeamTypes = WestHeavyTeamTypes + [WESTAIBASEPATROLTEAMTYPE]

WestLargeDefenseTeamTypes = WestLargeDefenseTeamTypes + [WESTAIBASEPATROLTEAMTYPE]

;Team type with this name must always be present.

;Special defense team for the base, normal AI team cannot be set to this.

_n = _n + ["BaseDefense"]

;Description was be kept blank so player commander cannot use this team.

_d = _d + [""]

_u = [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

_u = _u + [WSOLDIER]

WestAITeamTemplates = WestAITeamTemplates + [_u]

WESTAIBASEDEFENSETEAMTYPE = Count WestAITeamTemplates - 1

WestInfantryTeamTypes = WestInfantryTeamTypes + [WESTAIBASEDEFENSETEAMTYPE]

WestHeavyTeamTypes = WestHeavyTeamTypes + [WESTAIBASEDEFENSETEAMTYPE]

WestAITeamTemplateDescriptions = _d

WestTeamTypes = WestInfantryTeamTypes + WestLightTeamTypes + WestHeavyTeamTypes + WestAirTeamTypes

;AI commander preferences for AI teams. Note this should be at least the size of the total amount of playable teams in game.

_t = [WESTAIDEFAULTTEAMTYPE]

_t = _t + [WESTAIATTEAMTYPE]

_t = _t + [WESTAIM113TEAMTYPE]

_t = _t + [WESTAIM1TEAMTYPE]

_t = _t + [WESTAIHMMWVTEAMTYPE]

_t = _t + [WESTAISTRYKERTEAMTYPE]

_t = _t + [WESTAISNIPERTEAMTYPE]

_t = _t + [WESTAIBLACKOPSTEAMTYPE]

_t = _t + [WESTAIDEFAULTTEAMTYPE]

_t = _t + [WESTAIVULCANTEAMTYPE]

_t = _t + [WESTAIATTEAMTYPE]

_t = _t + [WESTAIAATEAMTYPE]

_t = _t + [WESTAISNIPERTEAMTYPE]

_t = _t + [WESTAIBLACKOPSTEAMTYPE]

_t = _t + [WESTAIM113TEAMTYPE]

_t = _t + [WESTAISTRYKERTEAMTYPE]

_t = _t + [WESTAIAH6TEAMTYPE]

_t = _t + [WESTAIAH1WTEAMTYPE]

WestAITeamTypes = _t

;EAST

EastAITeamTemplates = []

EastInfantryTeamTypes = []

EastDefenseTeamTypes = []

EastLargeDefenseTeamTypes = []

EastLightTeamTypes = []

EastHeavyTeamTypes = []

EastAirTeamTypes = []

_n = ["Infantry"]

_d = ["Infantry"]

_u = [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [EMGSOLDIER]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIDEFAULTTEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAIDEFAULTTEAMTYPE]

_n = _n + ["AT"]

_d = _d + ["AT"]

_u = [EATSOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [EATSOLDIER]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIATTEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAIATTEAMTYPE]

_n = _n + ["AA"]

_d = _d + ["AA"]

_u = [EAASOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [EAASOLDIER]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIAATEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAIAATEAMTYPE]

_n = _n + ["Sniper"]

_d = _d + ["Sniper"]

_u = [ESNIPER]

_u = _u + [ESOLDIER]

_u = _u + [ESNIPER]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAISNIPERTEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAISNIPERTEAMTYPE]

_n = _n + ["SpetzNatz"]

_d = _d + ["Spetz Natz"]

_u = [ESPECOP]

_u = _u + [ESPECOPSNIPER]

_u = _u + [ESPECOP]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAISPETZNATZTEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAISPETZNATZTEAMTYPE]

;Team type with this name must always be present.

_n = _n + ["ATAA"]

_d = _d + ["AT/AA"]

_u = [EATSOLDIER]

_u = _u + [EAASOLDIER]

_u = _u + [EATSOLDIER]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIATAATEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAIATAATEAMTYPE]

EastDefenseTeamTypes = EastInfantryTeamTypes + [EASTAIATAATEAMTYPE]

_n = _n + ["UAZAssault"]

_d = _d + ["UAZ Assault"]

_u = ["UAZMG"]

_u = _u + ["UAZ_AGS30"]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIUAZTEAMTYPE = Count EastAITeamTemplates - 1

EastLightTeamTypes = EastLightTeamTypes + [EASTAIUAZTEAMTYPE]

_n = _n + ["BRDM2"]

_d = _d + ["BRDM2"]

_u = ["BRDM2"]

_u = _u + ["BRDM2_ATGM"]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIBRDM2TEAMTYPE = Count EastAITeamTemplates - 1

EastLightTeamTypes = EastLightTeamTypes + [EASTAIBRDM2TEAMTYPE]

_n = _n + ["ZSU"]

_d = _d + ["Shilka"]

_u = ["ZSU"]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAISHILKATEAMTYPE = Count EastAITeamTemplates - 1

EastHeavyTeamTypes = EastHeavyTeamTypes + [EASTAISHILKATEAMTYPE]

_n = _n + ["BMP2"]

_d = _d + ["BMP-2"]

_u = ["BMP2"]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIBMP2TEAMTYPE = Count EastAITeamTemplates - 1

EastHeavyTeamTypes = EastHeavyTeamTypes + [EASTAIBMP2TEAMTYPE]

_n = _n + ["Tank"]

_d = _d + ["Tank"]

_u = ["T72"]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIT72TEAMTYPE = Count EastAITeamTemplates - 1

EastHeavyTeamTypes = EastHeavyTeamTypes + [EASTAIT72TEAMTYPE]

_n = _n + ["K-50"]

_d = _d + ["K-50"]

_u = ["K50"]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIK50TEAMTYPE = Count EastAITeamTemplates - 1

EastAirTeamTypes = EastAirTeamTypes + [EASTAIK50TEAMTYPE]

;Team type with this name must always be present.

;Special defense team for the base, normal AI team cannot be set to this.

_n = _n + ["BasePatrol"]

;Description was be kept blank so player commander cannot use this team.

_d = _d + [""]

_u = [EATSOLDIER]

_u = _u + [EAASOLDIER]

_u = _u + [EATSOLDIER]

_u = _u + [EAASOLDIER]

_u = _u + [EMGSOLDIER]

_u = _u + [EMEDIC]

_u = _u + ["ZSU"]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIBASEPATROLTEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAIBASEPATROLTEAMTYPE]

EastHeavyTeamTypes = EastHeavyTeamTypes + [EASTAIBASEPATROLTEAMTYPE]

EastLargeDefenseTeamTypes = EastLargeDefenseTeamTypes + [EASTAIBASEPATROLTEAMTYPE]

;Team type with this name must always be present.

;Special defense team for the base, normal AI team cannot be set to this.

_n = _n + ["BaseDefense"]

;Description was be kept blank so player commander cannot use this team.

_d = _d + [""]

_u = [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

_u = _u + [ESOLDIER]

EastAITeamTemplates = EastAITeamTemplates + [_u]

EASTAIBASEDEFENSETEAMTYPE = Count EastAITeamTemplates - 1

EastInfantryTeamTypes = EastInfantryTeamTypes + [EASTAIBASEDEFENSETEAMTYPE]

EastHeavyTeamTypes = EastHeavyTeamTypes + [EASTAIBASEDEFENSETEAMTYPE]

EastAITeamTemplateDescriptions = _d

EastTeamTypes = EastInfantryTeamTypes + EastLightTeamTypes + EastHeavyTeamTypes + EastAirTeamTypes

;AI commander preferences for AI teams. Note this should be at least the size of the total amount of playable teams in game.

_t = [EASTAIDEFAULTTEAMTYPE]

_t = _t + [EASTAIATTEAMTYPE]

_t = _t + [EASTAIBRDM2TEAMTYPE]

_t = _t + [EASTAIT72TEAMTYPE]

_t = _t + [EASTAIUAZTEAMTYPE]

_t = _t + [EASTAIBMP2TEAMTYPE]

_t = _t + [EASTAISNIPERTEAMTYPE]

_t = _t + [EASTAISPETZNATZTEAMTYPE]

_t = _t + [EASTAIDEFAULTTEAMTYPE]

_t = _t + [EASTAISHILKATEAMTYPE]

_t = _t + [EASTAIATTEAMTYPE]

_t = _t + [EASTAIAATEAMTYPE]

_t = _t + [EASTAISNIPERTEAMTYPE]

_t = _t + [EASTAISPETZNATZTEAMTYPE]

_t = _t + [EASTAIBMP2TEAMTYPE]

_t = _t + [EASTAIK50TEAMTYPE]

EastAITeamTypes = _t

commonScriptsExecuted = commonScriptsExecuted + 1

;*****************************************************************************************

;4/18/7 MM - Created file.

If you compare this last file with the one that comes with the original Warfare mission you will see that I have added two AI teams in the WEST side and one in the EAST side.

both are airteams and are both in the team list and in the AI team list.

In the other two files we tell the AI that can produce and spawn air units, something that, in the original warfare mission, wasn't enabled.

If you want to add air teams to the AI you must add lines in the config_AITeams.sqs

For the moment I haven't had time for adding the fixedwingunits but I will try to do so in a couple of days.

Theoretically I think that we could do the same with waterteams but for that we would have to create a new cathegory and link it with the other files and produce PBXs, RHIBs or other boats.

Don't expect much of this anyway. For the moment I have only seen the enemy AI use choppers 3/10 times.

Share this post


Link to post
Share on other sites

o great thanks - Just testing this and it works:-) I have lowered the prices and they are pumping out ah-1's. Its great tho swarms of them flying about its like apocalypse now. Thanks for this.

Share this post


Link to post
Share on other sites

BTW, it works also with the resistance units.

If you go to server/config/config_resistance.sqs and you add a new type of team and you have that unit in the master config list of the factory config file you can add a new resistance group that will be spawned when you get near an enemy town.

1st step:

editing the config file aircraftfactory, located in the common/config folder

There you would have to add resistance choppers to the list (They are not there)

I have them in this modified version

config_AircraftFactory.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Last modified 3/18/8

;*****************************************************************************************

;Description: Aircraft factory configurations.

;_o = One man vehicle.

;*****************************************************************************************

;WEST

_u = ["MH6"]

_d = [Localize "STR_DN_MH6"]

_c = [2500]

_m = [2500 + (westBarracksCosts Select WPILOTTYPE)]

_t = [35]

_p = [20]

_o = [true]

_i = ["\ca\air\data\ico\mh6_lb_CA.paa"]

_u = _u + ["AH6"]

_d = _d + [Localize "STR_DN_AH6"]

_c = _c + [3500]

_m = _m + [3500 + (westBarracksCosts Select WPILOTTYPE)]

_t = _t + [40]

_p = _p + [30]

_o = _o + [true]

_i = _i + ["\ca\air\data\ico\ah6_lb_CA.paa"]

_u = _u + ["UH60MG"]

_d = _d + [Localize "STR_DN_UH60_MG"]

_c = _c + [3000]

_m = _m + [3000 + (westBarracksCosts Select WPILOTTYPE) * 2]

_t = _t + [40]

_p = _p + [25]

_o = _o + [false]

_i = _i + ["\ca\air\data\ico\uh_60mg_CA.paa"]

_u = _u + ["UH60"]

_d = _d + [Localize "STR_DN_UH60"]

_c = _c + [5000]

_m = _m + [5000 + (westBarracksCosts Select WPILOTTYPE)]

_t = _t + [45]

_p = _p + [40]

_o = _o + [true]

_i = _i + ["\ca\air\data\ico\uh_60_CA.paa"]

_u = _u + ["AH1W"]

_d = _d + [Localize "STR_DN_AH1Z"]

_c = _c + [8000]

_m = _m + [8000 + (westBarracksCosts Select WPILOTTYPE) * 2]

_t = _t + [55]

_p = _p + [50]

_o = _o + [false]

_i = _i + ["\ca\air\data\ico\ah1z_CA.paa"]

for [{_count = Count _u - 1},{_count >= 0},{_count = _count - 1}] do {Call Compile Format["%1TYPE = %2",_u Select _count,_count];}

;Used to calculate amount of units needed to buy vehicle.

westOneManAircraftVehicles = []

for [{_count = Count _u - 1},{_count >= 0},{_count = _count - 1}] do {if (_o Select _count) then {westOneManAircraftVehicles = westOneManAircraftVehicles + [_count]};}

westAircraftUnits = _u

westAircraftDescriptions = _d

westAircraftCosts = _c

westAircraftMannedCosts = _m

westAircraftTimes = _t

westAircraftPoints = _p

westAircraftImages = _i

;EAST

_u = ["MI17_MG"]

_d = [Localize "STR_DN_MI17_MG"]

_c = [3000]

_m = [3000 + (eastBarracksCosts Select EPILOTTYPE) * 2]

_t = [35]

_p = [20]

_o = [false]

_i = ["\ca\air\data\ico\mi17_hip_mg_CA.paa"]

_u = _u + ["MI17"]

_d = _d + [Localize "STR_DN_MI17"]

_c = _c + [5500]

_m = _m + [5500 + (eastBarracksCosts Select EPILOTTYPE)]

_t = _t + [45]

_p = _p + [40]

_o = _o + [true]

_i = _i + ["\ca\air\data\ico\mi17_HIP_CA.paa"]

_u = _u + ["KA50"]

_d = _d + [Localize "STR_DN_KA50"]

_c = _c + [9000]

_m = _m + [9000 + (eastBarracksCosts Select EPILOTTYPE)]

_t = _t + [55]

_p = _p + [50]

_o = _o + [true]

_i = _i + ["\ca\air\data\ico\ka50_CA.paa"]

for [{_count = Count _u - 1},{_count >= 0},{_count = _count - 1}] do {Call Compile Format["%1TYPE = %2",_u Select _count,_count];}

;Used to calculate amount of units needed to buy vehicle.

eastOneManAircraftVehicles = []

for [{_count = Count _u - 1},{_count >= 0},{_count = _count - 1}] do {if (_o Select _count) then {eastOneManAircraftVehicles = eastOneManAircraftVehicles + [_count]};}

eastAircraftUnits = _u

eastAircraftDescriptions = _d

eastAircraftCosts = _c

eastAircraftMannedCosts = _m

eastAircraftTimes = _t

eastAircraftPoints = _p

eastAircraftImages = _i

;RESISTANCE

_u = ["MH6_RACS"]

_d = [Localize "STR_DN_MH6"]

_c = [2500]

_m = [2500 + (ResistanceBarracksCosts Select GPILOTTYPE)]

_t = [35]

_p = [20]

_o = [true]

_i = ["\ca\air\data\ico\mh6_lb_CA.paa"]

_u = _u + ["AH6_RACS"]

_d = _d + [Localize "STR_DN_AH6"]

_c = _c + [3500]

_m = _m + [3500 + (ResistanceBarracksCosts Select GPILOTTYPE)]

_t = _t + [40]

_p = _p + [30]

_o = _o + [true]

_i = _i + ["\ca\air\data\ico\ah6_lb_CA.paa"]

for [{_count = Count _u - 1},{_count >= 0},{_count = _count - 1}] do {Call Compile Format["%1TYPE = %2",_u Select _count,_count];}

;Used to calculate amount of units needed to buy vehicle.

resistanceOneManAircraftVehicles = []

for [{_count = Count _u - 1},{_count >= 0},{_count = _count - 1}] do {if (_o Select _count) then {resistanceOneManAircraftVehicles = resistanceOneManAircraftVehicles + [_count]};}

resistanceAircraftUnits = _u

resistanceAircraftDescriptions = _d

resistanceAircraftCosts = _c

resistanceAircraftMannedCosts = _m

resistanceAircraftTimes = _t

resistanceAircraftPoints = _p

resistanceAircraftImages = _i

aircraftUnits = westAircraftUnits + eastAircraftUnits + resistanceAircraftUnits

aircraftUnitCosts = westAircraftCosts + eastAircraftCosts + resistanceAircraftCosts

aircraftUnitDescriptions = westAircraftDescriptions + eastAircraftDescriptions + resistanceAircraftDescriptions

;Determine longest build time.

longestAircraftBuildTime = 0

_t = eastAircraftTimes + westAircraftTimes + resistanceAircraftTimes

for [{_count = Count _t - 1},{_count >= 0},{_count = _count - 1}] do {if (_t Select _count > longestAircraftBuildTime) then {longestAircraftBuildTime = _t Select _count};}

;*****************************************************************************************

;6/13/7 MM - Created file.

Now the resistance can build AH-6s and MH-6s. But the AI is dumb won't do a thing unless we tell her to do it.

2nd step

Now we have to add a new group type in the master config file od the resistance, which is equivalent to the EAST and WEST config_AITeams.sqs file.

This file is called config_resistance.sqs and it is located in the server/config  folder.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Last modified 3/25/8

;*****************************************************************************************

;Description: defines everything needed for the Resistance.

;*****************************************************************************************

_n = ["DefaultTeam"]

_u = [GLEADER]

_u = _u + [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GMEDIC]

_u = _u + [GSNIPER]

_u = _u + [GGSOLDIER]

_u = _u + [GMGSOLDIER]

;Creates an array of unit classnames for the team type. Example: ResDefaultTeamUnits.

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = ["DefaultSmallTeam"]

_u = [GLEADER]

_u = _u + [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GMEDIC]

_u = _u + [GGSOLDIER]

_u = _u + [GMGSOLDIER]

;Creates an array of unit classnames for the team type. Example: ResDefaultTeamUnits.

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = ["DefaultSmallTeam1"]

_u = [GLEADER]

_u = _u + [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GMEDIC]

_u = _u + [GSOLDIER]

_u = _u + [GMGSOLDIER]

;Creates an array of unit classnames for the team type. Example: ResDefaultTeamUnits.

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = ["DefaultSmallTeam2"]

_u = [GSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GSNIPER]

_u = _u + [GMEDIC]

;Creates an array of unit classnames for the team type. Example: ResDefaultTeamUnits.

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = _n + ["ATTeam"]

_u = [GLEADER]

_u = _u + [GATSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GATSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GATSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GATSOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GMEDIC]

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = _n + ["AATeam"]

_u = [GLEADER]

_u = _u + [GAASOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GAASOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GAASOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GAASOLDIER]

_u = _u + [GSOLDIER]

_u = _u + [GMEDIC]

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = _n + ["ScoutTeam"]

_u = ["LandroverMG"]

_u = _u + ["LandroverMG"]

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = _n + ["LightMechanizedTeam"]

_u = ["M113_RACS"]

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = _n + ["MechanizedTeam"]

_u = ["M113_RACS"]

_u = _u + ["Vulcan_RACS"]

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = _n + ["ArmoredTeam"]

_u = ["T72_RACS"]

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

_n = _n + ["AirTeam"]

_u = ["AH6_RACS"]

Call Compile Format["Res%1Units = _u",_n Select (Count _n - 1)]

;Master list of team types that can be created in a Resistance town.

resistanceTeamTypes = _n

;*****************************************************************************************

;1/31/7 MM - Created file.

Now the resistance has choppers in the array list of buildable teams.

But for that one more step is needed.

Step 3: town config files.

The town config files are files that control which resistance teams are spawned in each town. This scripts are referenced in the oninit field of the depots in each town.

For the resistance to spawn choppers you would have to add a new town config file to the array in the oninit field of the depot of the town you want.

example a new town config file called Config_SmallTownChopper.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;Last modified 4/23/8

;*****************************************************************************************

;Description: Helper script that can be used to create predefined town stats.

;*****************************************************************************************

_town = _this Select 0

_townName = _this Select 1

_nearLocations = _this Select 2

_range = 450

if (Count _this > 3) then {_range = _this Select 3};

;Team types

_t = ["DefaultTeam"]

_t = _t + ["DefaultTeam"]

_t = _t + ["ATTeam"]

_t = _t + ["AirTeam"]

_probability = 50

[_town,_townName,_nearLocations,10,50,false,_range,_t,_probability] Exec "Common\Init\Init_Location.sqs"

;*****************************************************************************************

;2/22/7 MM - Created file.

Notice the line that says _probability = 50. This means that 50% of the time we get nearer than 450 meters of the town center this script will be executed and two "defaultTeam", one "ATTeam" and 1 "AirTeam" will be spawned.

Well, I hope everything in my explanation is clear and also that this serves for you to enjoy more the WARFARE mission.

For the moment I'm trying to enable the fixed wing aircraft so OPFOR AI uses them too. For the Resistance, I doubt the AI will use fixed wing units unless we put an incredibly high value in the range field, because the script only kicks when an OPFOR/BLUFOR units gets nearer than this value.

I will post some new code soon (I hope)

smile_o.gif

Share this post


Link to post
Share on other sites

Much thanks about it  smile_o.gif

I guess why BIS didn't made the code for air units

about planes: maybe make AI capture airfields first  smile_o.gif

Share this post


Link to post
Share on other sites

Hello Everyone! I am Computica! I am here today on these forums because I've became an armaholic just 3 days ago! Since I play Warfare buy myself and not online all the time ManKyle opened my eyes to scripting the Warfare code so I would like to post my 2 Versions of Warfare Based on Mankyle's Air Unit Script. I added only original units from the game... hold on I need to figure how to attach it.. give me a sec... If it doesn't work I'll send it to you all to pass around I'll also upload it on alcholic I think. Anyways I made a 64 player version of Warfare (I play buy myself ;>) then I said I'll double it so I did. I got a fast comp and the only time it will lag is in the city. And my settings were on high, not very high! View Distance was about 3000-5000 I guess!? My comp runs 10000 no prob on 64 players. 128 players is the limit I'll comeback and list more details...

Scratch that here ya go play on LAN for a while set how many bots you want I cut AirCraft prices down at resonable rates and I even refined somethings ManKyle didn't Mention, oh this means AI spawns all vehicle except airplanes on there. oh and I'm looking into that as we speak!!

http://hosted.filefront.com/computica/

I'm still updating the files so I'll be throwing up new ones as T7, T8, T9, T10, etc. OH AND THANKS MANKYLE!!! smile_o.gif

EDIT 3:

I still need help though I would really like for the A.I. to Capture and use Airports on there own without having to be there! Same with players, unless you know how to fly and shoot a ground target planes are just too useless for me. Oh yeah I really beefed up the Resistance too, Yo I'm about to get some zzz's my fingers hurt from all that scripting... Oh I uploaded the N&S Version too without all the fancy scripts! took me a while to disable all of that...

Edit 4:

Ok I fell in love with the Sakakah_Al_Jawf Warfare map so I'm gonna add up to 32 player support A.I. Choppers Grenade Launcher for the East side and... Motorcycles I guess...

I found out that I forgot to change these numbers in the Description files...

-----------------------

class Header

{

gameType = CTI;

minPlayers = 1;

maxPlayers = 16;

};

-----------------------

I might have an idea to have the A.I. spawn Airplanes at the Airport but I don't know how to make it into an capture priority yet...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×