Jump to content
Sign in to follow this  
computica

A.I.'s Capture Priority Script

Recommended Posts

I can't find where the Capture List is. I think I should add in some text somewhere in other scripts. Right now I am going to look in every file.

EDIT 1:

Ok I think I found something in the "\Server\AI\Starter" folder there is a starter_GetMission.sqs that mainly points the A.I. towards Camps:

;Find the nearest camp to use

_nearestCamp = [side _team,_nearestMission,GetPos _currentLocation] call GetClosestAttackerCampSite

;if (!IsNull _nearestCamp) then {Call Compile Format["_nearestDisembark = %1Disembark",str _nearestCamp]};

;Roundup external variables

_mission = MISCAPTURETOWN

Call Compile Format["%1Mission = _mission",_name]

Call Compile Format["%1MissionDisembark = _nearestCamp",_name]

Call Compile Format["%1MissionLocation = _nearestMission",_name]

Call Compile Format["%1MissionX = GetPos _nearestMission Select 0",_name]

Call Compile Format["%1MissionY = GetPos _nearestMission Select 1",_name]

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

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

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

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

if (_mission == MISCAPTURETOWN) then {[_name] Exec "Server\AI\Starter\Starter_MissionCaptureTown.sqs"};

;if (_mission == MISCAPTUREBASE) then {[_name] Exec "Server\AI\Starter\Starter_MissionCaptureBase.sqs"};

I think I could insert a script for making Airports based on the "Starter_MissionCaptureTown.sqs"

EDIT 2: Ok I've figured out there are a list of Missons...

Share this post


Link to post
Share on other sites

I found another method I can use for A.I. to use Airports by changing the A.I. range for the Hangar as a seperate script by making a new range like how the opted this one:

;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};

I want to make it so Airports are able to used if it's on an A.I's side...

Ok check this out, Airports were never given a SIDE, so that's why they never been a priority to use, they left it for the players to fight for, well I think things could get a little unfair... but I wanna see what'll happen.

It seems from what I'm reading the A.I. would capture airports according to the Advanced_UpdateSquad.sqs I'll run a test to check though...

Nah, the A.I. didn't even recognize it when I changed the side to GUER. I guess i'ts because it looks for camps first.

Alright I have to make a special script for range when it comes to airports but I have to make it work for airports only... it's wiki time! sad_o.gif

Share this post


Link to post
Share on other sites

The list of towns that the AI will try to capture is called 'locations'. It is initialized to [] in Common\Init\Init_Common.sqf and the init script of the towns (in Server\Config) in turn call Common\Init\Init_Location.sqf where a town is actually added to the locations list. If you want to make the AI capture the airport, it should probably be added to the locations list as well (right at the start of Server\Update_Airport.sqs for example). You would still need to figure out how the AI will know that the airport has been captured and that it can move on to the next target.

Doomguy

Share this post


Link to post
Share on other sites

I seen that MM added an embark script but I think the script in the towncapture leads it back to the embark script I'll focus to see if they can even buy from the Airport at a far distance.

Share this post


Link to post
Share on other sites

I just added AI airport capture in WACO. It's very simple: it works like a normal town now, and the AI will try to capture it just as it does for the other towns. If a side captures the town, ownership of the airport (hanger) is also granted and that side can construct airplanes. Now I'll update the AI to actually buy airplanes and use them.

Doomguy

Share this post


Link to post
Share on other sites

The AI is capable of buying planes now too. When the airport is on the AI's side, it has enough funds, and it knows of enemy targets like vehicles or structures, it will purchase a plane (A-10 for west, SU-34B for east) and send it to an enemy target.

To be released soon... when it has been tested a little bit more (it seems to work fine already), and when some other additions have been made.

Share this post


Link to post
Share on other sites

I have finally enable the AI capture of airports

For that what you have to do is treat the airports as towns, and for that you have to use the standard server/config_town.sqs script. (the line that comes in the init line of all warfare depot buildings)

If you do like that and you add a couple of camps near you will have a fully capturable airport location with its defending teams and everything.

Now. For the airport to be able to build planes you have to change the variable the warfare system uses for enabling/disabling the GUI. for that you have to change a line in the client/Client_UpdateAvailableActions.sqf

this is the revised file

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

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

Private["_capturingCamp","_icons","_images","_objects","_repair","_textControl","_usable"];

_repair = WREPAIRTRUCK;

if (sideJoined == East) then {_repair = EREPAIRTRUCK};

_HQ = Call Compile Format["%1StructureNames Select %1HEADQUARTERSTYPE",sideJoinedText];

_names = Call Compile Format["%1StructureNames",sideJoinedText];

_structures = Call Compile Format["[_names Select %1BARRACKSTYPE,_names Select %1LIGHTTYPE,_names Select %1HEAVYTYPE,_names Select %1AIRCRAFTTYPE]",sideJoinedText];

_icons = ["\Warfare\Images\icon_barracks.paa","\Warfare\Images\icon_light.paa","\Warfare\Images\icon_heavy.paa","\Warfare\Images\icon_aircraft.paa","\Warfare\Images\icon_airport.paa"];

_loop = 0;

while {!gameOver} do

{

Sleep 1.5;

_MHQ = Call Compile Format["%1MHQ",sideJoinedText];

_loop = _loop + 1;

//Check for nearby repair trucks.

_objects = (Vehicle player NearObjects[_repair,15]) Call GetUndestroyedUnits;

if (Count _objects > 0) then

{

repairTruckInRange = _objects Select 0;

}

else

{

repairTruckInRange = ObjNull;

};

//Check for nearby camps.

_capturingCamp = false;

campInRange = ObjNull;

_objects = Vehicle player NearObjects["WarfareBCamp",10];

if (Count _objects > 0) then

{

if (Call Compile Format["%1SideID == sideID",Str (_objects Select 0)]) then

{

campInRange = _objects Select 0;

}

else

{

_capturingCamp = true;

};

};

//Check for nearby depot.

depotInRange = false;

_objects = Vehicle player NearObjects["WarfareBDepot",30];

if (Count _objects > 0) then

{

if (Call Compile Format["%1SideId == sideID",Str (_objects Select 0)]) then

{

depotInRange = true;

_icons Set [Count _icons - 1,"\Warfare\Images\icon_service_station.paa"];

}

};

//Check for nearby airport.

airportInRange = false;

_objects = Vehicle player NearObjects["WarfareBAirport",30];

if (Count _objects > 0) then

{

if (Call Compile Format["%1SideId == sideID",Str (_objects Select 0)]) then

{

airportInRange = true;

_icons Set [Count _icons - 1,"\Warfare\Images\icon_airport.paa"];

}

};

//Check every 3 seconds.

if (_loop > 1) then

{

_loop = 0;

HQInRange = ObjNull;

//If player is commander then check for a functioning nearby HQ.

if (!IsNull commanderTeam) then

{

if (Group player == commanderTeam) then

{

_objects = Vehicle player NearObjects[_HQ,CONSTRUCTIONRANGE];

//Check for MHQ (if it has not been deployed).

if (!IsNull _MHQ) then

{

_objects = _objects + (player NearObjects[TypeOf _MHQ,CONSTRUCTIONRANGE]);

};

if (Count _objects > 0) then

{

if (GetDammage (_objects Select 0) < 1) then

{

HQInRange = _objects Select 0;

};

};

};

};

_objects = NearestObjects[Vehicle player,_structures,BASERANGE] Call GetUndestroyedUnits;

// _objects = NearestObjects[Vehicle player,_structures,15] Call GetUndestroyedUnits;

_types = [];

{_types = _types + [TypeOf _x]} ForEach _objects;

barracksInRange = false;

lightFactoryInRange = false;

heavyFactoryInRange = false;

aircraftFactoryInRange = false;

if ((_structures Select 0) In _types) then {barracksInRange = true};

if ((_structures Select 1) In _types) then {lightFactoryInRange = true};

if ((_structures Select 2) In _types) then {heavyFactoryInRange = true};

if ((_structures Select 3) In _types) then {aircraftFactoryInRange = true};

};

if (barracksInRange || lightFactoryInRange || heavyFactoryInRange || aircraftFactoryInRange || airportInRange || depotInRange || (!IsNull campInRange && !townCaptureProgressBarActive)) then

{

if (IsNull currentCutDisplay) then

{

CutRsc["UseObject","PLAIN",0];

WaitUntil {!IsNull currentCutDisplay};

};

_usable = [barracksInRange || !(IsNull campInRange),lightFactoryInRange,heavyFactoryInRange,aircraftFactoryInRange,airportInRange || depotInRange];

//Create list of icons for usable structures & display them.

_count = 0;

_count1 = 0;

_images = ["","","","",""];

{if (_x) then {_images Set[_count,_icons Select _count1];_count = _count + 1} else {_images = _images + [""]};_count1 = _count1 + 1} ForEach _usable;

_count = 0;

{(currentCutDisplay DisplayCtrl (IDCGENERICIMAGE + _count)) CtrlSetText _x;_count = _count + 1} ForEach _images;

_textControl = currentCutDisplay DisplayCtrl IDCMenuInfo;

_textControl CtrlSetText Format[Localize "STRWFTOUSE",ActionKeysNames["TeamSwitch",1]]

}

else

{

if (!_capturingCamp && !townCaptureProgressBarActive && !IsNull currentCutDisplay) then

{

CutText["","PLAIN"];

};

};

};

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

//1/26/8 MM - Created file.

And voila, you have a fully AI capturable airport that when captured allow building fixed wing planes.

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  

×