Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: AI using Air units?

  1. #1
    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
    Don't ever argue with an asshole, he will bring you down to his level, and there he will win you by means of experience

  2. #2
    Currently the Warfare community has not released any information pertaining to AI building, man and flying any air vehicles.
    Armor+ 6000BWS
    EVGA x58 4-Way Classified 170-BL-E762
    i7 930 @ 2.8Ghz
    G.SKILLPI+Turbulence12GB(PC3 12800)6-8-6-20 1.6v
    Ultra X4 1050W PSU
    2x PNY 670GTX @ 4096mb in SLI

  3. #3
    Master Sergeant
    Join Date
    May 21 2007
    Location
    Sunny Spain
    Posts
    622
    Author of the Thread
    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.




  4. #4
    Gunnery Sergeant
    Join Date
    Apr 3 2002
    Location
    Brighouse, West Yorkshire. (UK)
    Posts
    576
    Quote Originally Posted by (mankyle @ Sep. 13 2008,08:25)
    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.

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

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

  7. #7
    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

  8. #8
    Master Sergeant
    Join Date
    May 21 2007
    Location
    Sunny Spain
    Posts
    622
    Author of the Thread
    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&#58; &#91;GroupName,GroupSlot&#93; Exec &#34;UpdateIndependentAI.sqs&#34;

    _team = _this Select 0

    _respawnable = true
    _role = true
    _mission = -1

    if &#40;Count _this &#62; 1&#41; then {_respawnable = _this Select 1};
    if &#40;Count _this &#62; 2&#41; then {_mission = _this Select 2};

    Goto &#34;Init&#34;

    #Update
    ~5

    &#59;Do not proceed unless team is AI controlled.
    ; if &#40;&#33;&#40;_team In eastAITeams&#41; && &#33;&#40;_team In westAITeams&#41;&#41; then {Exit};
    if &#40;Call Compile Format&#91;&#34;&#33;&#40;_team In %1AITeams&#41; && &#33;&#40;_team In %1DefenseTeams&#41;&#34;,_sideText&#93;&#41; then {Exit};

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

    _leader = Leader _team
    Call Compile Format&#91;&#34;_teamType = %1AITeamType;_mission = %1AIMission&#34;,_name&#93;

    _base = Call Compile Format&#91;&#34;%1Base&#34;,_sideText&#93;

    _lastTeamType = _teamType
    _lastMission = _mission
    _timePartialUpdate = _timePartialUpdate - 5
    _timeFullUpdate = _timeFullUpdate - 5

    _infantryTime = _infantryTime - 5
    _lightTime = _lightTime - 5
    _heavyTime = _heavyTime - 5
    _aircraftTime = _aircraftTime - 5

    if &#40;&#33;Alive _leader&#41; then {Goto &#34;WaitForRespawn&#34;};
    if &#40;_teamType &#33;= _lastTeamType &#124;&#124; _mission &#33;= _lastMission&#41; then {_lastDestination = ObjNull;Goto &#34;UpdateRole&#34;};
    if &#40;_mission == MISMOVETODESTINATION && &#40;Call Compile Format&#91;&#34;%1AIMissionX &#33;= _lastX &#124;&#124; %1AIMissionY &#33;= _lastY&#34;,_name&#93;&#41;&#41; then {_lastDestination = ObjNull;Goto &#34;UpdateRole&#34;};

    if &#40;_timePartialUpdate &#62; 0&#41; then {Goto &#34;Update&#34;} else {_timePartialUpdate = 15};

    _purchase = false

    &#59;Update leader, formation, etc. every partial update.
    Goto &#34;UpdateLeader&#34;

    #CheckForFullUpdate

    &#59;If a full update occurs, check goals, location to move to, purchases, etc.
    if &#40;_timeFullUpdate &#62; 0&#41; then {Goto &#34;Update&#34;};

    ;Determine which AI role needs to be executed.
    #UpdateRole

    _purchase = false
    _timePartialUpdate = 15
    _timeFullUpdate = 30

    _funds = _team Call GetTeamFunds
    _teamUnits = _teamTypes Select _teamType

    &#59;Calculate units in team.
    _teamMaxSize = Count _teamUnits;

    &#59;For infantry team types the leader must also be counted.
    if &#40;_teamType In _infantryTypes&#41; then {_teamMaxSize = _teamMaxSize + 1};

    &#59;Add second unit for any vehicles.
    {if &#40;&#40;_x In lightUnits&#41; &#124;&#124; &#40;_x In heavyUnits&#41; &#124;&#124; &#40;_x In aircraftUnits&#41;&#41; then {_teamMaxSize = _teamMaxSize + 1};} ForEach _teamUnits

    #UpdatePurchases

    &#59;ToDo&#58; Check if leader is stuck.

    &#59;Try not to exceed team size.
    _teamSize = Count &#40;Units _team Call GetLiveUnits&#41;
    if &#40;_teamSize &#62;= _teamMaxSize&#41; then {Goto &#34;UpdateGoal&#34;};

    &#59;Determine factories that need to be used.
    _useBarracks = false
    _useLight = false
    _useHeavy = false
    _useAircraft = false
    _minFundsNeeded = 0

    if &#40;_teamType In _infantryTypes && _infantryTime &#60;= 0&#41; then {_useBarracks = true;_minFundsNeeded = _minFundsNeeded + AIMINBARRACKSFUNDS};
    if &#40;_teamType In _lightTypes && _lightTime &#60;= 0&#41; then {_useLight = true;_minFundsNeeded = _minFundsNeeded + AIMINLIGHTFUNDS};
    if &#40;_teamType In _heavyTypes && _heavyTime &#60;= 0&#41; then {_useHeavy = true;_minFundsNeeded = _minFundsNeeded + AIMINHEAVYFUNDS};
    if &#40;_teamType In _airTypes && _aircraftTime &#60;= 0&#41; then {_useAircraft = true;_minFundsNeeded = _minFundsNeeded + AIMINAIRCRAFTFUNDS};

    ; if &#40;&#33;_useBarracks && &#33;_useLight && &#33;_useHeavy && &#33;_useAircraft&#41; then {Goto &#34;UpdateGoal&#34;};
    if &#40;_minFundsNeeded &#62; _funds&#41; then {Goto &#34;UpdateGoal&#34;};

    &#59;Do not attempt to purcahse vehicles if limit has been reached.
    &#59;if &#40;_side == west && westTotalVehicles &#62;= maxVehicles&#41; then {_useLight = false;_useHeavy = false;_useAircraft = false};
    &#59;if &#40;_side == east && eastTotalVehicles &#62;= maxVehicles&#41; then {_useLight = false;_useHeavy = false;_useAircraft = false};

    _nearestBarracks = ObjNull
    _nearestLight = ObjNull
    _nearestHeavy = ObjNull
    _nearestAircraft = ObjNull

    &#59;Attempt to get nearest barracks from leader.
    _nearestObjects = &#91;&#93;
    if &#40;_useBarracks&#41; then {_nearestObjects = nearestObjects&#91;_leader,&#91;_barracksName&#93; ,500&#93;};
    if &#40;_useBarracks && Count _nearestObjects &#62; 0&#41; then {_nearestBarracks = _nearestObjects Select 0};

    if &#40;_useLight&#41; then {_nearestObjects = nearestObjects&#91;_leader,&#91;_lightName&#93;,50 0&#93;} else {_nearestObjects = &#91;&#93;};
    if &#40;_useLight && Count _nearestObjects &#62; 0&#41; then {_nearestLight = _nearestObjects Select 0};

    if &#40;_useHeavy&#41; then {_nearestObjects = nearestObjects&#91;_leader,&#91;_heavyName&#93;,50 0&#93;} else {_nearestObjects = &#91;&#93;};
    if &#40;_useHeavy && Count _nearestObjects &#62; 0&#41; then {_nearestHeavy = _nearestObjects Select 0};

    if &#40;_useAircraft&#41; then {_nearestObjects = nearestObjects&#91;_leader,&#91;_aircraftName&#93; ,500&#93;} else {_nearestObjects = &#91;&#93;};
    if &#40;_useAircraft && Count _nearestObjects &#62; 0&#41; then {_nearestAircraft = _nearestObjects Select 0};

    _transportOnly = true
    _inRangeDistance = 0
    _currentUnit = _leader

    #CheckPurchase

    _buyLight = false
    _aircraftAvailable = false
    _heavyAvailable = false
    _lightAvailable = false
    _barracksAvailable = false
    _range = AIPURCHASERANGE

    &#59;If leader is in an immobile vehicle &#40;like a stationary gun&#41; then extend purchase range to defend range.
    if &#40;_leader &#33;= Vehicle _leader && &#40;&#33;&#40;CanMove &#40;Vehicle _leader&#41;&#41; &#124;&#124; &#40;IsNull Driver &#40;Vehicle _leader&#41;&#41;&#41;&#41; then {_range = AIDEFENDLOCATIONRANGE};

    &#59;If structure is in range, not being used, and group is small enough then flag it as usable.
    if &#40;&#33;IsNull _nearestAircraft && &#40;_leader Distance _nearestAircraft &#60; _range&#41;&#41; then {_aircraftAvailable = true};
    if &#40;&#33;IsNull _nearestHeavy && &#40;_leader Distance _nearestHeavy &#60; _range&#41;&#41; then {_heavyAvailable = true};
    if &#40;&#33;IsNull _nearestLight && &#40;_leader Distance _nearestLight &#60; _range&#41;&#41; then {_lightAvailable = true};
    if &#40;&#33;IsNull _nearestBarracks && &#40;_leader Distance _nearestBarracks &#60; _range&#41;&#41; then {_barracksAvailable = true};

    _barracksUnits = &#91;&#93;
    _lightUnits = &#91;&#93;
    _heavyUnits = &#91;&#93;
    _aircraftUnits = &#91;&#93;

    &#59;Compile lists of units based on factory types.
    if &#40;_barracksAvailable&#41; then {{if &#40;_x In soldierUnits&#41; then {_barracksUnits = _barracksUnits + &#91;_x&#93;};} ForEach _teamUnits};
    if &#40;_lightAvailable&#41; then {{if &#40;_x In lightUnits&#41; then {_lightUnits = _lightUnits + &#91;_x&#93;};} ForEach _teamUnits};
    if &#40;_heavyAvailable&#41; then {{if &#40;_x In heavyUnits&#41; then {_heavyUnits = _heavyUnits + &#91;_x&#93;};} ForEach _teamUnits};
    if &#40;_aircraftAvailable&#41; then {{if &#40;_x In aircraftUnits&#41; then {_aircraftUnits = _aircraftUnits + &#91;_x&#93;};} ForEach _teamUnits};


    &#59;Purchase all barracks units.
    if &#40;_barracksAvailable&#41; then {&#91;_barracksType,_nearestBarracks,_team,_barrac ksUnits&#93; Exec &#34;Server&#92;Server_AITeamBuyUnits.sqs&#34;;_pu rchase = true;_infantryTime = 120};

    &#59;Purchase all light units.
    if &#40;_lightAvailable&#41; then {&#91;_lightType,_nearestLight,_team,_lightUnits&# 93; Exec &#34;Server&#92;Server_AITeamBuyUnits.sqs&#34;;_pu rchase = true;_lightTime = 120};

    &#59;Purchase all heavy units.
    if &#40;_heavyAvailable&#41; then {&#91;_heavyType,_nearestHeavy,_team,_heavyUnits&# 93; Exec &#34;Server&#92;Server_AITeamBuyUnits.sqs&#34;;_pu rchase = true;_heavyTime = 120};

    &#59;Purchase all aircraft units.
    if &#40;_aircraftAvailable&#41; then {&#91;_aircraftType,_nearestAircraft,_team,_aircra ftUnits&#93; Exec &#34;Server&#92;Server_AITeamBuyUnits.sqs&#34;;_pu rchase = true;_aircraftTime = 120};
    r
    &#59;If team does not need a barracks & nothing is available then don&#39;t wait around.
    &#59;However, wait around for the first 3 minutes incase a factory is constructed.
    if &#40;&#33;_aircraftAvailable && &#33;_lightAvailable && &#33;_heavyAvailable && &#33;_useBarracks && time &#62; 180&#41; then {Goto &#34;UpdateGoal&#34;};

    if &#40;_useBarracks && &#33;_barracksAvailable && _leader Distance _base &#62; AIREINFORCERANGE&#41; then {Goto &#34;UpdateGoal&#34;};

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

    _distance = 100000
    _factories = &#91;_nearestBarracks,_nearestLight,_nearestHeavy, _nearestAircraft&#93;
    _factories = _factories - &#91;ObjNull&#93;
    _nearestFactory = ObjNull
    {if &#40;_leader Distance _x &#60; _distance&#41; then {_distance = _leader Distance _x;_nearestFactory = _x};} ForEach _factories
    if &#40;_teamSize &#60; MINAIGROUPSIZE && &#33;IsNull _nearestFactory&#41; then {Goto &#34;ReturnToFactory&#34;};
    if &#40;_teamSize &#60; &#40;_teamMaxSize * 0.75&#41; && &#33;IsNull _nearestFactory && _distance &#60; AIREINFORCERANGE&#41; then {Goto &#34;ReturnToFactory&#34;};

    #UpdateLeader
    ;goto &#34;CheckForFullUpdate&#34;
    &#59;If leader is in a mobile vehicle then skip this section.
    ? &#40;_leader &#33;= Vehicle _leader&#41; && &#40;CanMove Vehicle _leader&#41;&#58;goto &#34;UpdateMembers&#34;

    _teamVehicles = &#91;_team,true,_leader,AIEMBARKVEHICLERANGE&#9 3; Call GetTeamVehicles

    #EmbarkLeader

    &#59;If leader has been trying to enter vehicle for multiple updates then teleport into vehicle now.
    ? &#40;_embarkLeader &#62; 2&#41;&#58;_currentUnit MoveInDriver &#40;_teamVehicles Select 0&#41;;_embarkLeader = 0;goto &#34;UpdateMembers&#34;
    ? &#40;Count _teamVehicles &#62; 0&#41;&#58;_embarkLeader = _embarkLeader + 1;_embarkAsDriverInTeamVehicleReturn = &#34;UpdateMembers&#34;;goto &#34;EmbarkAsDriverInTeamVehicle&#34;

    _embarkLeader = 0

    #UpdateMembers

    _infantryCount = 0
    _units = Units _team
    _units = _units - &#91;_leader&#93;
    _unitsOutOfFormation = &#91;&#93;
    _outOfFormation = false
    _totalUnits = Count _units

    ? &#40;_totalUnits &#60; 1&#41;&#58;_updateFormationReturn = &#34;CheckForFullUpdate&#34;;goto &#34;UpdateFormation&#34;

    #UpdateMember

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

    _currentUnit = _units Select _infantryCount
    _infantryCount = _infantryCount + 1
    _vehicle = Vehicle _currentUnit

    if &#40;GetDammage _currentUnit &#62;= 1&#41; then {Goto &#34;UpdateNextMember&#34;};

    &#59;If the destination is far away embark in a transport if available.
    ? &#40;_currentUnit Distance _destinationObject &#62; AIDISEMBARKVEHICLERANGE&#41;&#58;goto &#34;EmbarkMember&#34;

    &#59;Otherwise disembark if in a transport & not one of the crew.
    ? &#40;_currentUnit &#33;= _vehicle&#41; && &#40;Driver _vehicle &#33;= _currentUnit&#41; && &#40;Gunner _vehicle &#33;= _currentUnit&#41; && &#40;Commander _vehicle &#33;= _currentUnit&#41;&#58;UnassignVehicle _currentUnit

    goto &#34;MemberOutOfRange&#34;

    #EmbarkMember

    &#59;If already in a vehicle.
    ? &#40;_vehicle &#33;= _currentUnit&#41; && &#40;CanMove _vehicle&#41;&#58;goto &#34;MemberOutOfRange&#34;

    #MemberEmbarkTransport

    _transport = ObjNull
    _transports = &#91;_team,_currentUnit,AIEMBARKVEHICLERANGE&#9 3; Call GetTeamTransport
    if &#40;Count _transports &#62; 0&#41; then {_transport = _transports Select &#40;Random &#40;Count _transports - 1&#41;&#41;};

    if &#40;IsNull _transport&#41; then {Goto &#34;MemberOutOfRange&#34;};
    if &#40;_currentUnit Distance _transport &#62; AIEMBARKVEHICLERANGE&#41; then {Goto &#34;MemberOutOfRange&#34;};

    _currentUnit AssignAsCargo _transport
    &#91;_currentUnit&#93; OrderGetIn true

    #MemberOutOfRange

    _leaderDistance = _currentUnit Distance _leader

    ? &#40;_leaderDistance &#60;= AIFORMATIONRANGE&#41;&#58;goto &#34;UpdateNextMember&#34;

    &#59;If unit is out of range of the team then proceed to the team independently.
    &#59;This prevents the team from slowing down and waiting.
    _outOfFormation = true
    _unitsOutOfFormation = _unitsOutOfFormation + &#91;_currentUnit&#93;

    &#59;If not near the leader DoMove to current position.
    ? &#40;_leaderDistance &#60; _currentUnit Distance _destinationObject&#41;&#58;_currentUnit DoMove GetPos _leader;goto &#34;UpdateNextMember&#34;

    _currentUnit DoMove GetPos _destinationObject

    #UpdateNextMember

    ? &#40;_infantryCount &#60; _totalUnits&#41;&#58;goto &#34;UpdateMember&#34;

    _updateFormationReturn = &#34;CheckForFullUpdate&#34;
    goto &#34;UpdateFormation&#34;

    #UpdateFormation

    &#59;If anyone was out of formation previously order those now in range to follow.
    ? &#40;_checkFormation&#41;&#58;_checkFormation = false;_units = _units - &#91;_unitsOutOfFormation&#93;;&#91;_units&#93; CommandFollow _leader

    &#59;If anyone is out of formation keep track of it for next update.
    ? &#40;_outOfFormation&#41;&#58;_outOfFormation = false;_checkFormation = true

    goto _updateFormationReturn

    #UpdateGoal

    &#59;If leader has purchased something and is near the base then wait around for it.
    if &#40;&#40;_aircraftTime &#62; 0 &#124;&#124; _infantryTime &#62; 0 &#124;&#124; _lightTime &#62; 0 &#124;&#124; _heavyTime &#62; 0&#41; && _teamSize &#60; _teamMaxSize && _leader Distance _base &#60; AIPURCHASERANGE&#41; then {Goto &#34;Update&#34;};

    if &#40;_mission == MISCAPTURELOCATIONS&#41; then {Goto &#34;CaptureLocations&#34;};
    if &#40;_mission == MISDEFENDBASE&#41; then {Goto &#34;DefendBase&#34;};
    if &#40;_mission == MISMOVETODESTINATION&#41; then {Goto &#34;MoveToDestination&#34;};
    if &#40;_mission == MISPATROL&#41; then {Goto &#34;Patrol&#34;};

    ; ? &#40;_mission == MISDEFENDLOCATIONS&#41;&#58;goto &#34;CheckDefendTargets&#34;

    goto &#34;Update&#34;

    ;Return to position in front of factory.
    #ReturnToFactory

    _direction = &#40;&#40;GetDir _nearestFactory + 180&#41; + &#40;Random 5&#41; - 10&#41; % 360
    _distance = 30

    _position = GetPos _nearestFactory
    _destination = &#91;&#40;_position Select 0&#41;+&#40;&#40;sin _direction&#41;*_distance&#41;,&#40;_position Select 1&#41;+&#40;&#40;cos _direction&#41;*_distance&#41;,_position Select 2&#93;
    _destination = &#91;_destination,14,20&#93; Call GetRandomPosition
    _destinationObject SetPos _destination

    _team Move _destination
    _lastDestination = ObjNull

    if &#40;&#33;&#40;CanMove &#40;Vehicle _leader&#41;&#41; &#124;&#124; &#40;IsNull Driver &#40;Vehicle _leader&#41;&#41;&#41; then {UnassignVehicle _leader};

    Goto &#34;Update&#34;

    #EmbarkAsDriverInTeamVehicle

    ; _vehicle = _teamVehicles Select &#40;Random &#40;Count _teamVehicles&#41;&#41;
    _vehicle = _teamVehicles Select 0

    UnassignVehicle Driver _vehicle
    &#59;_currentUnit DoMove GetPos _vehicle
    _currentUnit AssignAsDriver _vehicle
    &#59;&#91;_currentUnit&#93; OrderGetIn true

    goto _embarkAsDriverInTeamVehicleReturn

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

    _totalGroups = Count _defenseTeams
    ? &#33;&#40;_team In _defenseTeams&#41; &#124;&#124; &#40;_totalGroups &#60; 1&#41;&#58;goto &#34;TakeTownsAndBases&#34;

    _count = 0

    #FindDefenseTeam

    _defender = _defenseTeams Select _count
    ? &#40;_defender == _team&#41;&#58;goto &#34;SetDefenseTeam&#34;

    _count = _count + 1
    ? &#40;_count &#60; _totalGroups&#41;&#58;goto &#34;FindDefenseTeam&#34;

    goto &#34;TakeTownsAndBases&#34;

    #SetDefenseTeam

    ? &#40;&#40;Count _defendedTargets&#41; &#60;= _count&#41;&#58;goto &#34;TakeTownsAndBases&#34;
    _closestTarget = _defendedTargets Select _count

    ;AI routines for defending towns.
    #DefendTowns

    _goalLoopCount = _goalLoopCount + 1

    ? &#40;_goalLoopCount &#60; 3&#41; && &#33;&#40;_reportMission&#41;&#58;goto &#34;Update&#34;

    _goalLoopCount = 0

    if &#40;&#33;Alive _leader&#41; then {Goto &#34;WaitForRespawn&#34;};
    ; ? &#40;_reportMission&#41; && &#40;_side == west&#41;&#58;westMessage = messageOrderDefend;PublicVariable &#34;westMessage&#34;;westPlayerMessageGroupFro m = _teamValue;PublicVariable &#34;westPlayerMessageGroupFrom&#34;;_reportMissio n = false;_closestTarget = ObjNull
    ; ? &#40;_reportMission&#41; && &#40;_side == east&#41;&#58;eastMessage = messageOrderDefend;PublicVariable &#34;eastMessage&#34;;eastPlayerMessageGroupFro m = _teamValue;PublicVariable &#34;eastPlayerMessageGroupFrom&#34;;_reportMissio n = false;_closestTarget = ObjNull

    &#59;If a town was previously chosen and in range then do a patrol.
    if &#40;&#33;IsNull _defendLocation&#41; then {Goto &#34;MoveToClosestDefendTarget&#34;};

    _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 = &#40;Call Compile Format&#91;&#34;%1SideID&#34;,Str _location&#93;&#41; Call GetSideFromID
    _distance = _location Distance _leader

    if &#40;_locationSide == _side && _distance &#60; _nearestDistance&#41; then {_defendLocation = _location;_nearestDistance = _distance};

    _count =_count + 1
    if &#40;_count &#60; _total&#41; then {goto &#34;FindDefendLocation&#34;};

    #MoveToClosestDefendTarget

    ; ? &#40;IsNull _closestTarget&#41; && &#40;_side == west&#41;&#58;westMessage = messageOrderDefendDenied;PublicVariable &#34;westMessage&#34;;westPlayerMessageGroupFro m = _teamValue;PublicVariable &#34;westPlayerMessageGroupFrom&#34;
    ; ? &#40;IsNull _closestTarget&#41; && &#40;_side == east&#41;&#58;eastMessage = messageOrderDefendDenied;PublicVariable &#34;eastMessage&#34;;eastPlayerMessageGroupFro m = _teamValue;PublicVariable &#34;eastPlayerMessageGroupFrom&#34;

    if &#40;_leader Distance _defendLocation &#60; targetDefendRange&#41; then {Goto &#34;DefendTarget&#34;};

    _destinationObject SetPos GetPos _defendLocation
    _team Move GetPos _destinationObject
    goto &#34;Update&#34;


    #DefendBase

    if &#40;&#33;Alive _leader&#41; then {Goto &#34;WaitForRespawn&#34;};

    _moveCount = _moveCount + 1
    if &#40;&#33;IsNull _lastDestination && _moveCount &#60; 2&#41; then {Goto &#34;Update&#34;};

    _moveCount = 0
    _lastDestination = _base
    _destinationObject SetPos &#40;GetPos _base&#41;
    _units = Units _team Call GetLiveUnits

    Call Compile Format&#91;&#34;%1AIMissionX = GetPos _destinationObject Select 0&#34;,_name&#93;
    Call Compile Format&#91;&#34;%1AIMissionY = GetPos _destinationObject Select 1&#34;,_name&#93;
    Call Compile Format&#91;&#34;PublicVariable &#34;&#34;%1AIMissionX&#34;&#34;;PublicVariable &#34;&#34;%1AIMissionY&#34;&#34;&#34;,_name&#93 ;

    &#59;Make available units patrol base area.
    {if &#40;CanMove _x&#41; then {_x DoMove &#40;&#91;GetPos _base,12,AIDEFENDLOCATIONRANGE&#93; Call GetRandomPosition&#41;};} ForEach _units

    if &#40;_leader Distance _base &#60; AIDEFENDLOCATIONRANGE&#41; then {&#91;Units _team,AIDEFENDLOCATIONRANGE&#93; Call UseStationaryDefense};

    Goto &#34;Update&#34;

    #CaptureLocations

    if &#40;&#33;Alive _leader&#41; then {Goto &#34;WaitForRespawn&#34;};
    if &#40;IsNull _lastDestination&#41; then {Goto &#34;FindHostileLocation&#34;};

    &#59;In case team is stuck, reissue move order.
    _moveCount = _moveCount + 1
    if &#40;_moveCount &#62; 5&#41; then {_moveCount = 0;_team Move GetPos _lastDestination};

    if &#40;&#33;&#40;_lastDestination In towns&#41;&#41; then {Goto &#34;FindHostileLocation&#34;};

    &#59;Do not check for a new destination if previous is not too far away & still hostile.
    _locationSide = &#40;Call Compile Format&#91;&#34;%1SideID&#34;,Str _lastDestination&#93;&#41; Call GetSideFromID
    if &#40;_locationSide &#33;= _side && _lastDestination Distance _leader &#60; 600&#41; then {Goto &#34;Update&#34;};

    #FindHostileLocation

    _location = &#91;_leader,_side&#93; Call GetClosestHostileLocation
    if &#40;_leader Distance _base &#62; BASERANGE&#41; then {Goto &#34;FindHostileBase&#34;};

    &#59;If team is near base and there are multiple nearby locations then divide teams up amongst them.
    _locations = &#91;_base,_side,CAPTUREFROMBASERANGE&#93; Call GetClosestHostileLocations
    if &#40;Count _locations &#62; 1&#41; then {_location = _locations Select &#40;_index % &#40;Count _locations&#41;&#41;};

    #FindHostileBase

    &#59;This will prevent the enemy from attacking the base when there are no players.
    if &#40;longerPersistentServerGame && PlayersNumber East &#60; 1 && PlayersNumber West &#60; 1&#41; then {Goto &#34;MoveToLocation&#34;};

    _enemyBase = WestBase
    if &#40;_side == West&#41; then {_enemyBase = EastBase};

    if &#40;_leader Distance _enemyBase &#60; _leader Distance _location&#41; then {_location = _enemyBase};

    Goto &#34;MoveToLocation&#34;

    #MoveToLocation

    if &#40;IsNull _location&#41; then {Goto &#34;Update&#34;};
    if &#40;_lastDestination == _location&#41; then {Goto &#34;Update&#34;};

    _lastDestination = _location
    _destinationObject SetPos &#40;&#91;GetPos _location,18,24&#93; Call GetRandomPosition&#41;
    Call Compile Format&#91;&#34;%1AIMissionX = GetPos _location Select 0&#34;,_name&#93;
    Call Compile Format&#91;&#34;%1AIMissionY = GetPos _location Select 1&#34;,_name&#93;
    Call Compile Format&#91;&#34;PublicVariable &#34;&#34;%1AIMissionX&#34;&#34;;PublicVariable &#34;&#34;%1AIMissionY&#34;&#34;&#34;,_name&#93 ;

    _team Move GetPos _destinationObject

    goto &#34;Update&#34;

    #MoveToDestination

    _moveCount = _moveCount + 1
    if &#40;&#33;IsNull _lastDestination && _moveCount &#60; 2&#41; then {Goto &#34;Update&#34;};

    _moveCount = 0

    _lastX = Call Compile Format&#91;&#34;%1AIMissionX&#34;,_name&#93;
    _lastY = Call Compile Format&#91;&#34;%1AIMissionY&#34;,_name&#93;

    _destinationObject SetPos &#91;_lastX,_lastY&#93;

    _lastDestination = _destinationObject
    _team Move GetPos _destinationObject

    goto &#34;Update&#34;

    #Patrol

    _moveCount = _moveCount + 1
    if &#40;&#33;IsNull _lastDestination && _moveCount &#60; 2&#41; then {Goto &#34;Update&#34;};

    _moveCount = 0

    _x = Call Compile Format&#91;&#34;%1AIMissionX&#34;,_name&#93;
    _y = Call Compile Format&#91;&#34;%1AIMissionY&#34;,_name&#93;
    _destinationObject SetPos &#40;&#91;&#91;_x,_y,0&#93;,5,AIPATROLRANGE&#93 ; Call GetRandomPosition&#41;

    _lastDestination = _destinationObject
    _team Move GetPos _destinationObject

    goto &#34;Update&#34;

    #SearchAndDestroy

    _location = locations Select &#40;Random &#40;Count Locations - 1&#41;&#41;
    _position = GetPos _location

    ; ? &#40;_side == west&#41; && &#33;&#40;IsNull westBaseFound&#41; && &#40;GetDammage westBaseFound &#60; 1&#41;&#58;_position = GetPos westBaseFound
    ; ? &#40;_side == east&#41; && &#33;&#40;IsNull eastBaseFound&#41; && &#40;GetDammage eastBaseFound &#60; 1&#41;&#58;_position = GetPos eastBaseFound
    ; ? &#40;_baseFound&#41;&#58;_x = &#40;_position Select 0&#41; + &#40;Random 200&#41; - 100;_y = &#40;_position Select 1&#41; + &#40;Random 200&#41; - 100;goto &#34;MoveToSearchAndDestroyTarget&#34;

    _leaderPosition = GetPos _leader
    _x = &#40;_position Select 0&#41; + &#40;&#40;&#40;_leaderPosition Select 0&#41; - &#40;_position Select 0&#41;&#41; / 2&#41; * &#40;Random 1&#41;
    _y = &#40;_position Select 1&#41; + &#40;&#40;&#40;_leaderPosition Select 1&#41; - &#40;_position Select 1&#41;&#41; / 2&#41; * &#40;Random 1&#41;

    #MoveToSearchAndDestroyTarget

    _destinationObject SetPos &#91;_x,_y,0&#93;
    _team Move &#91;_x,_y&#93;
    goto &#34;Update&#34;

    #WaitForRespawn
    ~2
    _lastDestination = ObjNull

    if &#40;_respawnable&#41; then {Goto &#34;WaitForLeaderRespawn&#34;};

    _units = Units _team Call GetLiveUnits
    if &#40;Count _units &#62; 0&#41; then {_team SelectLeader &#40;_units Select 0&#41;;Goto &#34;WaitForLeaderRespawn&#34;};

    _base = Call Compile Format&#91;&#34;%1Base&#34;,_sideText&#93;

    _unitType = ESOLDIER
    if &#40;_side == West&#41; then {_unitType = WSOLDIER};

    _leader = _team CreateUnit&#91;_unitType,&#40;&#91;GetPos _base,10,25&#93; Call GetRandomPosition&#41;,&#91;&#93;,1,&#34;FORM&#34; &#93;
    &#91;_leader,_side&#93; Call InitUnit
    _team SelectLeader _leader
    ~13
    Goto &#34;UpdateRole&#34;

    #WaitForLeaderRespawn

    @ &#40;Alive Leader _team&#41;

    _leader = Leader _team
    goto &#34;UpdateRole&#34;

    #Init

    &#59;Only execute this on the server.
    if &#40;&#33;IsServer&#41; then {Exit};

    _side = Side Leader _team
    _sideText = Str _side

    _respawnMarker = &#34;EastTempRespawnMarker&#34;
    if &#40;_side == West&#41; then {_respawnMarker = &#34;WestTempRespawnMarker&#34;};

    _index = Call Compile Format&#91;&#34;%1Teams Find _team&#34;,_sideText&#93;

    &#59;If not on the standard team then see if it is an AI defense team.
    if &#40;_index &#60; 0&#41; then {_index = Call Compile Format&#91;&#34;%1DefenseTeams Find _team&#34;,_sideText&#93;;if &#40;_index &#62;= 0&#41; then {_index = _index + Call Compile Format&#91;&#34;Count %1Teams&#34;,_sideText&#93;};};

    _index = _index + 1
    _name = Format&#91;&#34;%1Team%2&#34;,_sideText,_index&#93 ;

    &#59;If the unit is a player then don&#39;t run the AI routines.
    if &#40;IsPlayer Leader _team&#41; then {Exit};
    if &#40;&#33;Local Leader _team&#41; then {Exit};

    if &#40;_respawnable&#41; then {&#91;_team,_name&#93; Spawn UpdateSquadRespawn};

    ~2

    &#59;In case this was previously a player.
    Leader _team removeAllEventHandlers &#34;killed&#34;
    &#91;Leader _team,_side&#93; Call InitUnit

    @ &#40;gameStarted&#41;

    Call Compile Format&#91;&#34;%1AIMission = MISCAPTURELOCATIONS&#34;,_name&#93;
    Call Compile Format&#91;&#34;%1AIMissionX = -1&#34;,_name&#93;
    Call Compile Format&#91;&#34;%1AIMissionY = -1&#34;,_name&#93;

    _lastX = -1
    _lastY = -1

    &#59;Default team type, player commander can change this.
    Call Compile Format&#91;&#34;%1AITeamType = %2AIDEFAULTTEAMTYPE&#34;,_name,_sideText&#93;

    &#59;If an AI commander then set this team&#39;s type according to defined template.
    if &#40;&#33;Call Compile Format&#91;&#34;IsNull %1CommanderTeam&#34;,_sideText&#93;&#41; then {Goto &#34;SkipCommanderInit&#34;};
    if &#40;_mission &#33;= -1&#41; then {Goto &#34;SkipCommanderInit&#34;};

    _AITypes = Call Compile Format&#91;&#34;%1AITeamTypes&#34;,_sideText&#93;

    &#59;Get AI slot instead of team slot since there may be less AI teams than total teams.
    _AISlot = Call Compile Format&#91;&#34;%1AITeams Find _team&#34;,_sideText&#93;

    &#59;Assign first two AI teams to base defense.
    ; if &#40;_AISlot == 0 &#124;&#124; _AISlot == 1&#41; then {Call Compile Format&#91;&#34;%1AIMission = MISDEFENDBASE&#34;,_name&#93;};
    ; if &#40;_AISlot == 0 &#124;&#124; _AISlot == 1&#41; then {Call Compile Format&#91;&#34;%1AITeamType = %2AIDEFAULTTEAMTYPE&#34;,_name,_sideText&#93;};

    &#59;If AI index is bigger than the list then increase it.
    if &#40;_AISlot &#62;= Count _AITypes&#41; then {_AITypes =_AITypes + _AITypes + _AITypes};

    Call Compile Format&#91;&#34;%1AITeamType = _AITypes Select _AISlot&#34;,_name&#93;

    #SkipCommanderInit

    &#59;_mission is usually set when team is a defense team.
    if &#40;_mission &#33;= -1&#41; then {Call Compile Format&#91;&#34;%1AIMission = _mission&#34;,_name&#93;};
    if &#40;_mission == MISPATROL&#41; then {Call Compile Format&#91;&#34;%1AITeamType = %2AIBASEPATROLTEAMTYPE&#34;,_name,_sideText&#93;};
    if &#40;_mission == MISDEFENDBASE&#41; then {Call Compile Format&#91;&#34;%1AITeamType = %2AIBASEDEFENSETEAMTYPE&#34;,_name,_sideText&#93;} ;
    if &#40;_mission == MISDEFENDLOCATIONS&#41; then {Call Compile Format&#91;&#34;%1AITeamType = %2AIATAATEAMTYPE&#34;,_name,_sideText&#93;};

    &#59;Patrol missions default at base.
    _position = Call Compile Format&#91;&#34;GetPos %1Base&#34;,_sideText&#93;
    if &#40;_mission == MISPATROL&#41; then {Call Compile Format&#91;&#34;%1AIMissionX = _position Select 0;%1AIMissionY = _position Select 1&#34;,_name&#93;};

    Call Compile Format&#91;&#34;PublicVariable &#34;&#34;%1AIMission&#34;&#34;&#34;,_name&#93;
    Call Compile Format&#91;&#34;PublicVariable &#34;&#34;%1AITeamType&#34;&#34;&#34;,_name&#93 ;
    Call Compile Format&#91;&#34;PublicVariable &#34;&#34;%1AIMissionX&#34;&#34;&#34;,_name&#93 ;
    Call Compile Format&#91;&#34;PublicVariable &#34;&#34;%1AIMissionY&#34;&#34;&#34;,_name&#93 ;

    _teamType = 0
    _lastTeamType = -1
    _mission = 0
    _lastMission = -1
    _funds = 0

    _lastDestination = ObjNull

    &#59;Stagger execution for each team a little.
    ~&#40;10 + _index * 2&#41;

    _timePartialUpdate = 15
    _timeFullUpdate = 45

    _moveCount = 0

    &#59;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&#91;&#34;%1AIRCRAFTTYPE&#34;,_sideText&#93;
    _aircraftName = Call Compile Format&#91;&#34;%1StructureNames Select _aircraftType&#34;,_sideText&#93;

    _barracksType = Call Compile Format&#91;&#34;%1BARRACKSTYPE&#34;,_sideText&#93;
    _barracksName = Call Compile Format&#91;&#34;%1StructureNames Select _barracksType&#34;,_sideText&#93;

    _lightType = Call Compile Format&#91;&#34;%1LIGHTTYPE&#34;,_sideText&#93;
    _lightName = Call Compile Format&#91;&#34;%1StructureNames Select _lightType&#34;,_sideText&#93;

    _heavyType = Call Compile Format&#91;&#34;%1HEAVYTYPE&#34;,_sideText&#93;
    _heavyName = Call Compile Format&#91;&#34;%1StructureNames Select _heavyType&#34;,_sideText&#93;

    _airTypes = Call Compile Format&#91;&#34;%1AirTeamTypes&#34;,_sideText&#93;
    _infantryTypes = Call Compile Format&#91;&#34;%1InfantryTeamTypes&#34;,_sideText &#93;
    _lightTypes = Call Compile Format&#91;&#34;%1LightTeamTypes&#34;,_sideText&#9 3;
    _heavyTypes = Call Compile Format&#91;&#34;%1HeavyTeamTypes&#34;,_sideText&#9 3;
    _teamTypes = Call Compile Format&#91;&#34;%1AITeamTemplates&#34;,_sideText&# 93;
    _destinationObject = &#34;Logic&#34; CreateVehicle &#91;0,0,0&#93;

    _team SetFormation &#34;WEDGE&#34;
    _team SetSpeedMode &#34;NORMAL&#34;

    Goto &#34;Update&#34;

    [/QUOTE]
    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&#58; Handles respawn of AI Leader.
    //************************************************** ***************************************
    Private&#91;&#34;_airTypes&#34;,&#34;_aircraft&#34 ;,&#34;_barracks&#34;,&#34;_base&#34;,&#34;_body&# 34;,&#34;_heavy&#34;,&#34;_heavyTypes&#34;,&#34;_i nfantryTypes&#34;,&#34;_leader&#34;,&#34;_light&#3 4;,&#34;_lightTypes&#34;,&#34;_list&#34;,&#34;_nam e&#34;,&#34;_position&#34;,&#34;_respawnMarker&#34 ;,&#34;_sideText&#34;,&#34;_sorted&#34;,&#34;_team &#34;,&#34;_teamType&#34;&#93;;

    _team = _this Select 0;
    _name = _this Select 1;
    _sideText = Str Side _team;

    _respawnMarker = Format&#91;&#34;%1TempRespawnMarker&#34;,_sideText &#93;;

    _airTypes = Call Compile Format&#91;&#34;%1AirTeamTypes&#34;,_sideText&#93; ;
    _infantryTypes = Call Compile Format&#91;&#34;%1InfantryTeamTypes&#34;,_sideText &#93;;
    _lightTypes = Call Compile Format&#91;&#34;%1LightTeamTypes&#34;,_sideText&#9 3;;
    _heavyTypes = Call Compile Format&#91;&#34;%1HeavyTeamTypes&#34;,_sideText&#9 3;;
    _aircraft = Call Compile Format&#91;&#34;%1StructureNames Select %1AIRCRAFTTYPE&#34;,_sideText&#93;;
    _barracks = Call Compile Format&#91;&#34;%1StructureNames Select %1BARRACKSTYPE&#34;,_sideText&#93;;
    _light = Call Compile Format&#91;&#34;%1StructureNames Select %1LIGHTTYPE&#34;,_sideText&#93;;
    _heavy = Call Compile Format&#91;&#34;%1StructureNames Select %1HEAVYTYPE&#34;,_sideText&#93;;

    while {&#33;IsPlayer Leader _team} do
    {
    WaitUntil {&#33;Alive Leader _team &#124;&#124; IsPlayer Leader _team};

    if &#40;&#33;IsPlayer Leader _team&#41; then
    {
    _body = Leader _team;

    WaitUntil {Alive Leader _team &#124;&#124; IsPlayer Leader _team};

    if &#40;&#33;IsPlayer Leader _team&#41; then
    {
    _leader = Leader _team;
    _leader SetPos GetMarkerPos _respawnMarker;

    Sleep 14;

    if &#40;Alive _leader&#41; then
    {
    _base = Call Compile Format&#91;&#34;%1Base&#34;,_sideText&#93;;
    _teamType = Call Compile Format&#91;&#34;%1AITeamType&#34;,_name&#93;;
    _structures = Call Compile Format&#91;&#34;%1BaseStructures&#34;,_sideText&#9 3;;
    _list = &#91;&#93;;

    //Find closest factory to respawn to.
    if &#40;_teamType In _airTypes&#41; then
    {
    {if &#40;&#40;TypeOf _x&#41; == _aircraft && GetDammage _x &#60; 1&#41; then {_list = _list + &#91;_x&#93;};} ForEach _structures;
    };
    if &#40;_teamType In _infantryTypes&#41; then
    {
    {if &#40;&#40;TypeOf _x&#41; == _barracks && GetDammage _x &#60; 1&#41; then {_list = _list + &#91;_x&#93;};} ForEach _structures;
    };

    if &#40;_teamType In _lightTypes&#41; then
    {
    {if &#40;&#40;TypeOf _x&#41; == _light && GetDammage _x &#60; 1&#41; then {_list = _list + &#91;_x&#93;};} ForEach _structures;
    };

    if &#40;_teamType In _heavyTypes&#41; then
    {
    {if &#40;&#40;TypeOf _x&#41; == _heavy && GetDammage _x &#60; 1&#41; then {_list = _list + &#91;_x&#93;};} ForEach _structures;
    };

    _position = &#91;GetPos _base,10,25&#93; Call GetRandomPosition;

    if &#40;Count _list &#62; 0&#41; then
    {
    _sorted = &#91;_body,_list&#93; Call SortByDistance;
    _position = &#91;GetPos &#40;_sorted Select 0&#41;,10,25&#93; Call GetRandomPosition;
    };

    _leader SetPos _position;
    _leader RemoveAllEventHandlers &#34;killed&#34;;
    &#91;_leader,Side _team&#93; Call InitUnit;
    _leader Call EquipDefaultLoadout;
    };
    };
    };
    };
    [/QUOTE]


    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&#58; defines AI teams.
    ;************************************************* ****************************************


    ;WEST
    WestAITeamTemplates = &#91;&#93;
    WestInfantryTeamTypes = &#91;&#93;
    WestDefenseTeamTypes = &#91;&#93;
    WestLargeDefenseTeamTypes = &#91;&#93;
    WestLightTeamTypes = &#91;&#93;
    WestHeavyTeamTypes = &#91;&#93;
    WestAirTeamTypes = &#91;&#93;

    _n = &#91;&#34;Infantry&#34;&#93;
    _d = &#91;&#34;Infantry&#34;&#93;
    _u = &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WMGSOLDIER&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIDEFAULTTEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAIDEFAULTTEAMTYPE&#93;

    _n = _n + &#91;&#34;AT&#34;&#93;
    _d = _d + &#91;&#34;AT&#34;&#93;
    _u = &#91;WATSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WATSOLDIER&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIATTEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAIATTEAMTYPE&#93;

    _n = _n + &#91;&#34;AA&#34;&#93;
    _d = _d + &#91;&#34;AA&#34;&#93;
    _u = &#91;WAASOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WAASOLDIER&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIAATEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAIAATEAMTYPE&#93;

    _n = _n + &#91;&#34;Sniper&#34;&#93;
    _d = _d + &#91;&#34;Sniper&#34;&#93;
    _u = &#91;WSNIPER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSNIPER&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAISNIPERTEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAISNIPERTEAMTYPE&#93;

    _n = _n + &#91;&#34;BlackOps&#34;&#93;
    _d = _d + &#91;&#34;Black Ops&#34;&#93;
    _u = &#91;WSPECOP&#93;
    _u = _u + &#91;WSPECOPSNIPER&#93;
    _u = _u + &#91;WSPECOP&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIBLACKOPSTEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAIBLACKOPSTEAMTYPE&#93;

    ;Team type with this name must always be present.
    _n = _n + &#91;&#34;ATAA&#34;&#93;
    _d = _d + &#91;&#34;AT/AA&#34;&#93;
    _u = &#91;WATSOLDIER&#93;
    _u = _u + &#91;WAASOLDIER&#93;
    _u = _u + &#91;WATSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIATAATEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAIATAATEAMTYPE&#93;
    WestDefenseTeamTypes = WestInfantryTeamTypes + &#91;WESTAIATAATEAMTYPE&#93;

    _n = _n + &#91;&#34;HummerAssault&#34;&#93;
    _d = _d + &#91;&#34;HMMWV Assault&#34;&#93;
    _u = &#91;&#34;HMMWV50&#34;&#93;
    _u = _u + &#91;&#34;HMMWVMK&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIHMMWVTEAMTYPE = Count WestAITeamTemplates - 1
    WestLightTeamTypes = WestLightTeamTypes + &#91;WESTAIHMMWVTEAMTYPE&#93;

    _n = _n + &#91;&#34;HummerAssault&#34;&#93;
    _d = _d + &#91;&#34;HMMWV AT&#34;&#93;
    _u = &#91;&#34;HMMWVTOW&#34;&#93;
    _u = _u + &#91;&#34;HMMWVMK&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIHMMWVATTEAMTYPE = Count WestAITeamTemplates - 1
    WestLightTeamTypes = WestLightTeamTypes + &#91;WESTAIHMMWVATTEAMTYPE&#93;

    _n = _n + &#91;&#34;M113&#34;&#93;
    _d = _d + &#91;&#34;M113&#34;&#93;
    _u = &#91;&#34;M113&#34;&#93;
    _u = _u + &#91;&#34;M113&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIM113TEAMTYPE = Count WestAITeamTemplates - 1
    WestLightTeamTypes = WestLightTeamTypes + &#91;WESTAIM113TEAMTYPE&#93;

    _n = _n + &#91;&#34;Vulcan&#34;&#93;
    _d = _d + &#91;&#34;Vulcan&#34;&#93;
    _u = &#91;&#34;Vulcan&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIVULCANTEAMTYPE = Count WestAITeamTemplates - 1
    WestHeavyTeamTypes = WestHeavyTeamTypes + &#91;WESTAIVULCANTEAMTYPE&#93;

    _n = _n + &#91;&#34;Stryker&#34;&#93;
    _d = _d + &#91;&#34;Stryker&#34;&#93;
    _u = &#91;&#34;Stryker_ICV_M2&#34;&#93;
    _u = _u + &#91;&#34;Stryker_TOW&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAISTRYKERTEAMTYPE = Count WestAITeamTemplates - 1
    WestHeavyTeamTypes = WestHeavyTeamTypes + &#91;WESTAISTRYKERTEAMTYPE&#93;

    _n = _n + &#91;&#34;Tank&#34;&#93;
    _d = _d + &#91;&#34;Tank&#34;&#93;
    _u = &#91;&#34;M1Abrams&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIM1TEAMTYPE = Count WestAITeamTemplates - 1
    WestHeavyTeamTypes = WestHeavyTeamTypes + &#91;WESTAIM1TEAMTYPE&#93;

    _n = _n + &#91;&#34;AH-6&#34;&#93;
    _d = _d + &#91;&#34;AH-6&#34;&#93;
    _u = &#91;&#34;AH6&#34;&#93;


    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIAH6TEAMTYPE = Count WestAITeamTemplates - 1
    WestAirTeamTypes = WestAirTeamTypes + &#91;WESTAIAH6TEAMTYPE&#93;

    _n = _n + &#91;&#34;AH-1W&#34;&#93;
    _d = _d + &#91;&#34;AH-1W&#34;&#93;
    _u = &#91;&#34;AH1W&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIAH1WTEAMTYPE = Count WestAITeamTemplates - 1
    WestAirTeamTypes = WestAirTeamTypes + &#91;WESTAIAH1WTEAMTYPE&#93;

    ;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 + &#91;&#34;BasePatrol&#34;&#93;
    ;Description was be kept blank so player commander cannot use this team.
    _d = _d + &#91;&#34;&#34;&#93;
    _u = &#91;WATSOLDIER&#93;
    _u = _u + &#91;WAASOLDIER&#93;
    _u = _u + &#91;WATSOLDIER&#93;
    _u = _u + &#91;WAASOLDIER&#93;
    _u = _u + &#91;WMGSOLDIER&#93;
    _u = _u + &#91;WMEDIC&#93;
    _u = _u + &#91;&#34;Vulcan&#34;&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIBASEPATROLTEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAIBASEPATROLTEAMTYPE&#93;
    WestHeavyTeamTypes = WestHeavyTeamTypes + &#91;WESTAIBASEPATROLTEAMTYPE&#93;
    WestLargeDefenseTeamTypes = WestLargeDefenseTeamTypes + &#91;WESTAIBASEPATROLTEAMTYPE&#93;

    ;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 + &#91;&#34;BaseDefense&#34;&#93;
    ;Description was be kept blank so player commander cannot use this team.
    _d = _d + &#91;&#34;&#34;&#93;
    _u = &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;
    _u = _u + &#91;WSOLDIER&#93;

    WestAITeamTemplates = WestAITeamTemplates + &#91;_u&#93;
    WESTAIBASEDEFENSETEAMTYPE = Count WestAITeamTemplates - 1
    WestInfantryTeamTypes = WestInfantryTeamTypes + &#91;WESTAIBASEDEFENSETEAMTYPE&#93;
    WestHeavyTeamTypes = WestHeavyTeamTypes + &#91;WESTAIBASEDEFENSETEAMTYPE&#93;

    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 = &#91;WESTAIDEFAULTTEAMTYPE&#93;
    _t = _t + &#91;WESTAIATTEAMTYPE&#93;
    _t = _t + &#91;WESTAIM113TEAMTYPE&#93;
    _t = _t + &#91;WESTAIM1TEAMTYPE&#93;
    _t = _t + &#91;WESTAIHMMWVTEAMTYPE&#93;
    _t = _t + &#91;WESTAISTRYKERTEAMTYPE&#93;
    _t = _t + &#91;WESTAISNIPERTEAMTYPE&#93;
    _t = _t + &#91;WESTAIBLACKOPSTEAMTYPE&#93;
    _t = _t + &#91;WESTAIDEFAULTTEAMTYPE&#93;
    _t = _t + &#91;WESTAIVULCANTEAMTYPE&#93;
    _t = _t + &#91;WESTAIATTEAMTYPE&#93;
    _t = _t + &#91;WESTAIAATEAMTYPE&#93;
    _t = _t + &#91;WESTAISNIPERTEAMTYPE&#93;
    _t = _t + &#91;WESTAIBLACKOPSTEAMTYPE&#93;
    _t = _t + &#91;WESTAIM113TEAMTYPE&#93;
    _t = _t + &#91;WESTAISTRYKERTEAMTYPE&#93;
    _t = _t + &#91;WESTAIAH6TEAMTYPE&#93;
    _t = _t + &#91;WESTAIAH1WTEAMTYPE&#93;
    WestAITeamTypes = _t

    ;EAST
    EastAITeamTemplates = &#91;&#93;
    EastInfantryTeamTypes = &#91;&#93;
    EastDefenseTeamTypes = &#91;&#93;
    EastLargeDefenseTeamTypes = &#91;&#93;
    EastLightTeamTypes = &#91;&#93;
    EastHeavyTeamTypes = &#91;&#93;
    EastAirTeamTypes = &#91;&#93;

    _n = &#91;&#34;Infantry&#34;&#93;
    _d = &#91;&#34;Infantry&#34;&#93;
    _u = &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;EMGSOLDIER&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIDEFAULTTEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAIDEFAULTTEAMTYPE&#93;

    _n = _n + &#91;&#34;AT&#34;&#93;
    _d = _d + &#91;&#34;AT&#34;&#93;
    _u = &#91;EATSOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;EATSOLDIER&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIATTEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAIATTEAMTYPE&#93;

    _n = _n + &#91;&#34;AA&#34;&#93;
    _d = _d + &#91;&#34;AA&#34;&#93;
    _u = &#91;EAASOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;EAASOLDIER&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIAATEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAIAATEAMTYPE&#93;

    _n = _n + &#91;&#34;Sniper&#34;&#93;
    _d = _d + &#91;&#34;Sniper&#34;&#93;
    _u = &#91;ESNIPER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESNIPER&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAISNIPERTEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAISNIPERTEAMTYPE&#93;

    _n = _n + &#91;&#34;SpetzNatz&#34;&#93;
    _d = _d + &#91;&#34;Spetz Natz&#34;&#93;
    _u = &#91;ESPECOP&#93;
    _u = _u + &#91;ESPECOPSNIPER&#93;
    _u = _u + &#91;ESPECOP&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAISPETZNATZTEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAISPETZNATZTEAMTYPE&#93;

    ;Team type with this name must always be present.
    _n = _n + &#91;&#34;ATAA&#34;&#93;
    _d = _d + &#91;&#34;AT/AA&#34;&#93;
    _u = &#91;EATSOLDIER&#93;
    _u = _u + &#91;EAASOLDIER&#93;
    _u = _u + &#91;EATSOLDIER&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIATAATEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAIATAATEAMTYPE&#93;
    EastDefenseTeamTypes = EastInfantryTeamTypes + &#91;EASTAIATAATEAMTYPE&#93;

    _n = _n + &#91;&#34;UAZAssault&#34;&#93;
    _d = _d + &#91;&#34;UAZ Assault&#34;&#93;
    _u = &#91;&#34;UAZMG&#34;&#93;
    _u = _u + &#91;&#34;UAZ_AGS30&#34;&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIUAZTEAMTYPE = Count EastAITeamTemplates - 1
    EastLightTeamTypes = EastLightTeamTypes + &#91;EASTAIUAZTEAMTYPE&#93;

    _n = _n + &#91;&#34;BRDM2&#34;&#93;
    _d = _d + &#91;&#34;BRDM2&#34;&#93;
    _u = &#91;&#34;BRDM2&#34;&#93;
    _u = _u + &#91;&#34;BRDM2_ATGM&#34;&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIBRDM2TEAMTYPE = Count EastAITeamTemplates - 1
    EastLightTeamTypes = EastLightTeamTypes + &#91;EASTAIBRDM2TEAMTYPE&#93;

    _n = _n + &#91;&#34;ZSU&#34;&#93;
    _d = _d + &#91;&#34;Shilka&#34;&#93;
    _u = &#91;&#34;ZSU&#34;&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAISHILKATEAMTYPE = Count EastAITeamTemplates - 1
    EastHeavyTeamTypes = EastHeavyTeamTypes + &#91;EASTAISHILKATEAMTYPE&#93;

    _n = _n + &#91;&#34;BMP2&#34;&#93;
    _d = _d + &#91;&#34;BMP-2&#34;&#93;
    _u = &#91;&#34;BMP2&#34;&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIBMP2TEAMTYPE = Count EastAITeamTemplates - 1
    EastHeavyTeamTypes = EastHeavyTeamTypes + &#91;EASTAIBMP2TEAMTYPE&#93;

    _n = _n + &#91;&#34;Tank&#34;&#93;
    _d = _d + &#91;&#34;Tank&#34;&#93;
    _u = &#91;&#34;T72&#34;&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIT72TEAMTYPE = Count EastAITeamTemplates - 1
    EastHeavyTeamTypes = EastHeavyTeamTypes + &#91;EASTAIT72TEAMTYPE&#93;

    _n = _n + &#91;&#34;K-50&#34;&#93;
    _d = _d + &#91;&#34;K-50&#34;&#93;
    _u = &#91;&#34;K50&#34;&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIK50TEAMTYPE = Count EastAITeamTemplates - 1
    EastAirTeamTypes = EastAirTeamTypes + &#91;EASTAIK50TEAMTYPE&#93;

    ;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 + &#91;&#34;BasePatrol&#34;&#93;
    ;Description was be kept blank so player commander cannot use this team.
    _d = _d + &#91;&#34;&#34;&#93;
    _u = &#91;EATSOLDIER&#93;
    _u = _u + &#91;EAASOLDIER&#93;
    _u = _u + &#91;EATSOLDIER&#93;
    _u = _u + &#91;EAASOLDIER&#93;
    _u = _u + &#91;EMGSOLDIER&#93;
    _u = _u + &#91;EMEDIC&#93;
    _u = _u + &#91;&#34;ZSU&#34;&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIBASEPATROLTEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAIBASEPATROLTEAMTYPE&#93;
    EastHeavyTeamTypes = EastHeavyTeamTypes + &#91;EASTAIBASEPATROLTEAMTYPE&#93;
    EastLargeDefenseTeamTypes = EastLargeDefenseTeamTypes + &#91;EASTAIBASEPATROLTEAMTYPE&#93;

    ;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 + &#91;&#34;BaseDefense&#34;&#93;
    ;Description was be kept blank so player commander cannot use this team.
    _d = _d + &#91;&#34;&#34;&#93;
    _u = &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;
    _u = _u + &#91;ESOLDIER&#93;

    EastAITeamTemplates = EastAITeamTemplates + &#91;_u&#93;
    EASTAIBASEDEFENSETEAMTYPE = Count EastAITeamTemplates - 1
    EastInfantryTeamTypes = EastInfantryTeamTypes + &#91;EASTAIBASEDEFENSETEAMTYPE&#93;
    EastHeavyTeamTypes = EastHeavyTeamTypes + &#91;EASTAIBASEDEFENSETEAMTYPE&#93;

    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 = &#91;EASTAIDEFAULTTEAMTYPE&#93;
    _t = _t + &#91;EASTAIATTEAMTYPE&#93;
    _t = _t + &#91;EASTAIBRDM2TEAMTYPE&#93;
    _t = _t + &#91;EASTAIT72TEAMTYPE&#93;
    _t = _t + &#91;EASTAIUAZTEAMTYPE&#93;
    _t = _t + &#91;EASTAIBMP2TEAMTYPE&#93;
    _t = _t + &#91;EASTAISNIPERTEAMTYPE&#93;
    _t = _t + &#91;EASTAISPETZNATZTEAMTYPE&#93;
    _t = _t + &#91;EASTAIDEFAULTTEAMTYPE&#93;
    _t = _t + &#91;EASTAISHILKATEAMTYPE&#93;
    _t = _t + &#91;EASTAIATTEAMTYPE&#93;
    _t = _t + &#91;EASTAIAATEAMTYPE&#93;
    _t = _t + &#91;EASTAISNIPERTEAMTYPE&#93;
    _t = _t + &#91;EASTAISPETZNATZTEAMTYPE&#93;
    _t = _t + &#91;EASTAIBMP2TEAMTYPE&#93;
    _t = _t + &#91;EASTAIK50TEAMTYPE&#93;

    EastAITeamTypes = _t

    commonScriptsExecuted = commonScriptsExecuted + 1

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

    ;4/18/7 MM - Created file.

    [/QUOTE]

    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&#39;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&#39;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&#39;t expect much of this anyway. For the moment I have only seen the enemy AI use choppers 3/10 times.

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




  10. #10
    Master Sergeant
    Join Date
    May 21 2007
    Location
    Sunny Spain
    Posts
    622
    Author of the Thread
    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&#58; Aircraft factory configurations.
    ;_o = One man vehicle.
    ;************************************************* ****************************************




    ;WEST
    _u = &#91;&#34;MH6&#34;&#93;
    _d = &#91;Localize &#34;STR_DN_MH6&#34;&#93;
    _c = &#91;2500&#93;
    _m = &#91;2500 + &#40;westBarracksCosts Select WPILOTTYPE&#41;&#93;
    _t = &#91;35&#93;
    _p = &#91;20&#93;
    _o = &#91;true&#93;
    _i = &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;mh6 _lb_CA.paa&#34;&#93;

    _u = _u + &#91;&#34;AH6&#34;&#93;
    _d = _d + &#91;Localize &#34;STR_DN_AH6&#34;&#93;
    _c = _c + &#91;3500&#93;
    _m = _m + &#91;3500 + &#40;westBarracksCosts Select WPILOTTYPE&#41;&#93;
    _t = _t + &#91;40&#93;
    _p = _p + &#91;30&#93;
    _o = _o + &#91;true&#93;
    _i = _i + &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;ah6 _lb_CA.paa&#34;&#93;

    _u = _u + &#91;&#34;UH60MG&#34;&#93;
    _d = _d + &#91;Localize &#34;STR_DN_UH60_MG&#34;&#93;
    _c = _c + &#91;3000&#93;
    _m = _m + &#91;3000 + &#40;westBarracksCosts Select WPILOTTYPE&#41; * 2&#93;
    _t = _t + &#91;40&#93;
    _p = _p + &#91;25&#93;
    _o = _o + &#91;false&#93;
    _i = _i + &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;uh_ 60mg_CA.paa&#34;&#93;

    _u = _u + &#91;&#34;UH60&#34;&#93;
    _d = _d + &#91;Localize &#34;STR_DN_UH60&#34;&#93;
    _c = _c + &#91;5000&#93;
    _m = _m + &#91;5000 + &#40;westBarracksCosts Select WPILOTTYPE&#41;&#93;
    _t = _t + &#91;45&#93;
    _p = _p + &#91;40&#93;
    _o = _o + &#91;true&#93;
    _i = _i + &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;uh_ 60_CA.paa&#34;&#93;

    _u = _u + &#91;&#34;AH1W&#34;&#93;
    _d = _d + &#91;Localize &#34;STR_DN_AH1Z&#34;&#93;
    _c = _c + &#91;8000&#93;
    _m = _m + &#91;8000 + &#40;westBarracksCosts Select WPILOTTYPE&#41; * 2&#93;
    _t = _t + &#91;55&#93;
    _p = _p + &#91;50&#93;
    _o = _o + &#91;false&#93;
    _i = _i + &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;ah1 z_CA.paa&#34;&#93;

    for &#91;{_count = Count _u - 1},{_count &#62;= 0},{_count = _count - 1}&#93; do {Call Compile Format&#91;&#34;%1TYPE = %2&#34;,_u Select _count,_count&#93;;}

    ;Used to calculate amount of units needed to buy vehicle.
    westOneManAircraftVehicles = &#91;&#93;
    for &#91;{_count = Count _u - 1},{_count &#62;= 0},{_count = _count - 1}&#93; do {if &#40;_o Select _count&#41; then {westOneManAircraftVehicles = westOneManAircraftVehicles + &#91;_count&#93;};}

    westAircraftUnits = _u
    westAircraftDescriptions = _d
    westAircraftCosts = _c
    westAircraftMannedCosts = _m
    westAircraftTimes = _t
    westAircraftPoints = _p
    westAircraftImages = _i

    ;EAST
    _u = &#91;&#34;MI17_MG&#34;&#93;
    _d = &#91;Localize &#34;STR_DN_MI17_MG&#34;&#93;
    _c = &#91;3000&#93;
    _m = &#91;3000 + &#40;eastBarracksCosts Select EPILOTTYPE&#41; * 2&#93;
    _t = &#91;35&#93;
    _p = &#91;20&#93;
    _o = &#91;false&#93;
    _i = &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;mi1 7_hip_mg_CA.paa&#34;&#93;

    _u = _u + &#91;&#34;MI17&#34;&#93;
    _d = _d + &#91;Localize &#34;STR_DN_MI17&#34;&#93;
    _c = _c + &#91;5500&#93;
    _m = _m + &#91;5500 + &#40;eastBarracksCosts Select EPILOTTYPE&#41;&#93;
    _t = _t + &#91;45&#93;
    _p = _p + &#91;40&#93;
    _o = _o + &#91;true&#93;
    _i = _i + &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;mi1 7_HIP_CA.paa&#34;&#93;

    _u = _u + &#91;&#34;KA50&#34;&#93;
    _d = _d + &#91;Localize &#34;STR_DN_KA50&#34;&#93;
    _c = _c + &#91;9000&#93;
    _m = _m + &#91;9000 + &#40;eastBarracksCosts Select EPILOTTYPE&#41;&#93;
    _t = _t + &#91;55&#93;
    _p = _p + &#91;50&#93;
    _o = _o + &#91;true&#93;
    _i = _i + &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;ka5 0_CA.paa&#34;&#93;

    for &#91;{_count = Count _u - 1},{_count &#62;= 0},{_count = _count - 1}&#93; do {Call Compile Format&#91;&#34;%1TYPE = %2&#34;,_u Select _count,_count&#93;;}

    ;Used to calculate amount of units needed to buy vehicle.
    eastOneManAircraftVehicles = &#91;&#93;
    for &#91;{_count = Count _u - 1},{_count &#62;= 0},{_count = _count - 1}&#93; do {if &#40;_o Select _count&#41; then {eastOneManAircraftVehicles = eastOneManAircraftVehicles + &#91;_count&#93;};}

    eastAircraftUnits = _u
    eastAircraftDescriptions = _d
    eastAircraftCosts = _c
    eastAircraftMannedCosts = _m
    eastAircraftTimes = _t
    eastAircraftPoints = _p
    eastAircraftImages = _i

    ;RESISTANCE
    _u = &#91;&#34;MH6_RACS&#34;&#93;
    _d = &#91;Localize &#34;STR_DN_MH6&#34;&#93;
    _c = &#91;2500&#93;
    _m = &#91;2500 + &#40;ResistanceBarracksCosts Select GPILOTTYPE&#41;&#93;
    _t = &#91;35&#93;
    _p = &#91;20&#93;
    _o = &#91;true&#93;
    _i = &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;mh6 _lb_CA.paa&#34;&#93;

    _u = _u + &#91;&#34;AH6_RACS&#34;&#93;
    _d = _d + &#91;Localize &#34;STR_DN_AH6&#34;&#93;
    _c = _c + &#91;3500&#93;
    _m = _m + &#91;3500 + &#40;ResistanceBarracksCosts Select GPILOTTYPE&#41;&#93;
    _t = _t + &#91;40&#93;
    _p = _p + &#91;30&#93;
    _o = _o + &#91;true&#93;
    _i = _i + &#91;&#34;&#92;ca&#92;air&#92;data&#92;ico&#92;ah6 _lb_CA.paa&#34;&#93;

    for &#91;{_count = Count _u - 1},{_count &#62;= 0},{_count = _count - 1}&#93; do {Call Compile Format&#91;&#34;%1TYPE = %2&#34;,_u Select _count,_count&#93;;}

    ;Used to calculate amount of units needed to buy vehicle.
    resistanceOneManAircraftVehicles = &#91;&#93;
    for &#91;{_count = Count _u - 1},{_count &#62;= 0},{_count = _count - 1}&#93; do {if &#40;_o Select _count&#41; then {resistanceOneManAircraftVehicles = resistanceOneManAircraftVehicles + &#91;_count&#93;};}

    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 &#91;{_count = Count _t - 1},{_count &#62;= 0},{_count = _count - 1}&#93; do {if &#40;_t Select _count &#62; longestAircraftBuildTime&#41; then {longestAircraftBuildTime = _t Select _count};}

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



    ;6/13/7 MM - Created file.
    [/QUOTE]

    Now the resistance can build AH-6s and MH-6s. But the AI is dumb won&#39;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&#58; defines everything needed for the Resistance.
    ;************************************************* ****************************************




    _n = &#91;&#34;DefaultTeam&#34;&#93;
    _u = &#91;GLEADER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GMEDIC&#93;
    _u = _u + &#91;GSNIPER&#93;
    _u = _u + &#91;GGSOLDIER&#93;
    _u = _u + &#91;GMGSOLDIER&#93;

    ;Creates an array of unit classnames for the team type. Example&#58; ResDefaultTeamUnits.
    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = &#91;&#34;DefaultSmallTeam&#34;&#93;
    _u = &#91;GLEADER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GMEDIC&#93;
    _u = _u + &#91;GGSOLDIER&#93;
    _u = _u + &#91;GMGSOLDIER&#93;


    ;Creates an array of unit classnames for the team type. Example&#58; ResDefaultTeamUnits.
    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = &#91;&#34;DefaultSmallTeam1&#34;&#93;
    _u = &#91;GLEADER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GMEDIC&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GMGSOLDIER&#93;

    ;Creates an array of unit classnames for the team type. Example&#58; ResDefaultTeamUnits.
    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = &#91;&#34;DefaultSmallTeam2&#34;&#93;
    _u = &#91;GSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GSNIPER&#93;
    _u = _u + &#91;GMEDIC&#93;

    ;Creates an array of unit classnames for the team type. Example&#58; ResDefaultTeamUnits.
    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = _n + &#91;&#34;ATTeam&#34;&#93;
    _u = &#91;GLEADER&#93;
    _u = _u + &#91;GATSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GATSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GATSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GATSOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GMEDIC&#93;

    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = _n + &#91;&#34;AATeam&#34;&#93;
    _u = &#91;GLEADER&#93;
    _u = _u + &#91;GAASOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GAASOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GAASOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GAASOLDIER&#93;
    _u = _u + &#91;GSOLDIER&#93;
    _u = _u + &#91;GMEDIC&#93;

    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = _n + &#91;&#34;ScoutTeam&#34;&#93;
    _u = &#91;&#34;LandroverMG&#34;&#93;
    _u = _u + &#91;&#34;LandroverMG&#34;&#93;

    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = _n + &#91;&#34;LightMechanizedTeam&#34;&#93;
    _u = &#91;&#34;M113_RACS&#34;&#93;

    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = _n + &#91;&#34;MechanizedTeam&#34;&#93;
    _u = &#91;&#34;M113_RACS&#34;&#93;
    _u = _u + &#91;&#34;Vulcan_RACS&#34;&#93;

    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = _n + &#91;&#34;ArmoredTeam&#34;&#93;
    _u = &#91;&#34;T72_RACS&#34;&#93;

    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

    _n = _n + &#91;&#34;AirTeam&#34;&#93;
    _u = &#91;&#34;AH6_RACS&#34;&#93;

    Call Compile Format&#91;&#34;Res%1Units = _u&#34;,_n Select &#40;Count _n - 1&#41;&#93;

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

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



    ;1/31/7 MM - Created file.
    [/QUOTE]

    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&#58; 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 &#40;Count _this &#62; 3&#41; then {_range = _this Select 3};

    ;Team types
    _t = &#91;&#34;DefaultTeam&#34;&#93;
    _t = _t + &#91;&#34;DefaultTeam&#34;&#93;
    _t = _t + &#91;&#34;ATTeam&#34;&#93;
    _t = _t + &#91;&#34;AirTeam&#34;&#93;

    _probability = 50

    &#91;_town,_townName,_nearLocations,10,50,false,_r ange,_t,_probability&#93; Exec &#34;Common&#92;Init&#92;Init_Location.sqs&#34;

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



    ;2/22/7 MM - Created file.
    [/QUOTE]

    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&#39;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)





Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •