[SDK] Advanced Unit Automations

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
Advanced Unit Automations

Version 1.60
Last Update: 9/19/10

New Unit Automations:

City Defense:
The unit will defend your cities. If a nearby, weaker enemy approaches, the unit will engage and destroy the enemy, and return to defending the city of origin.

Border Patrol
The unit will wander around the edges of your border, searching for potential enemies, and engage them.

Hunt
The unit will search and destroy any enemy units it can find.

Auto-Pillage
The unit will search and pillage any enemy improvements it can find.

Auto-Hurry
Not useful for normal BTS, but for any mods that add units that can hurry or speed up production of buildings in a city via the <iBaseHurry> XML tag will be able to be automated.

Auto-Pirate
Privateers and any other sea-faring, hidden, always hostile units will be able to cause terror on the open seas, sinking weak transports and blockading wealthy harbors.

Auto-Air Strike:
Airplanes and jets will automatically deal damage to nearby enemies, and protect your cities from harm.

Auto-Air Bomb
Bombers will attack and weaken enemy improvements and cities, if possible.

Auto Air Recon
Aircraft will attempt to conduct recon missions near enemy encampments.

Auto Upgrade
Units will automatically upgrade if the player has the gold, and the unit is not in immediate danger

Auto Promote
Units will automatically be promoted whenever possible.

Auto Protect
Allows the Player to select a unit to escort and protect. If you select a tile with multiple units, a popup will appear directing you to specify which unit.

New Player Options:

Automated Pillaging Ignores Danger:
Units will pillage in territory even when there are enemies present

Automated Pillaging Avoids Barbarians:
Units will not enter barbarian territory

Automated Air Units Can Rebase:
Air units can rebase to more offensive or defensive cities and position on their own, without player interaction

Automated Air Units Can Defend:
Air units can act as defenders, intercepting enemy air craft, when it deems it necessary to.

Automated Explorers Cannot Heal:
Explorers will be unable to heal.

Border Patrol Units Stay in Borders:
Units Automated to Border Patrol will be unable to leave your nations borders for any reason.

New Unit Missions:

Gather Intel:
Spies will sleep in a city until their maximum espionage bonus accrues (5 turns in BTS), then wake up and ask the player for orders.

Wait for Desired Discovery Tech:
Allows selection of a desired discovery tech for that great person, and the GP will wait until that tech becomes available, at which time it will research it.

Any Land and Sea units that can attack (and pillage, if applicable) will be able to use the new automations. The Automated units are fairly sophisticated, and won't go suiciding against stacks of enemy units, or when the odds are poor.

Mods that use AUA:
Modders, please let me know if your mod has AUA in it, and I will add it to the list!

Download Mod & Sources

Modders: There are some Better AI functions included in the source code. They are all marked with specific and hard to miss comments, and are only needed if you are not using at least Better AI .84b. If you are using Better AI .84b or above, please don't merge those functions.

I've included the file changes and sources in a zip archive. Tell me if I forgot anything.

Credits:
  • Artwork
    • SmeagolHeart
  • Code Contributions
    • Jdog5000
    • CAR Mod Team
    • Thomas SG
 
I tried merging the code. I'm getting an error with the "getOppositeDirection" function as if it doesn't exist.

1>CvUnitAI.cpp(24283) : error C3861: 'getOppositeDirection': identifier not found, even with argument-dependent lookup

So it's not working for me yet anyway. I made some buttons for the actions. I think they are okay, maybe not perfect. What do you think?

Edit: Added Screenshot
edit edit: updated screenshot with additional action buttons

actions-1.jpg
 

Attachments

Oh sorry, I forgot one function, one sec, let me update the OP.
 
I like the buttons alot. I updated the OP, the missing function was in CvGameCoreUtils.
 
Everything for CvUnitAI was up there, I just labeled it as CvUnit instead of CvUnitAI. The OP has been corrected, and everything should work now.
 
Very good buttons! But I don't like the hunting button. Can you make another, please? That would be fantastic. :goodjob:
 
hi,

can someone plz upload the modified files?

im having trouble adding some of the code, since i dont know were to insert some of the codes - like in the CvGameCoreUtils, and cvunitai,

i cant recognize a reference - like for example shown in the cvenums.h part - "AUTOMATE_RELIGION,"

can anyone help?
 
The code can go anywhere in CvGameCoreUtils, it doesn't modify anything, it's a new function. Search for AUTOMATE_RELIGION in CvEnums and you should find the spot.
 
Keldath,
There is a Modified Part and a New Part, each are separated and labeled. If you get errors when compiling, post them, and I'll try to help.

smeagolheart,

Did You ever get it to compile correctly? I'm working on an Automate Pirate Ship, do you think you could make a button for that too? I'd be eternally grateful.

To All,

Any other significant automations that I should add?
 
great thanks a lot!

cant think of anything more to automate,


but i can think of some nice think for you to make:
airport improvements - an improvement that will allow airlift to city or another airport improvement (also air units will be able to park on it).

i dunnoits just popped in my head right now..:)
 
Any other significant automations that I should add?

Ya... automate air strike (units/improvements/cities), automate air bomb (cities)


What about automated spy actions?
 
Automated Air strikes are possible, but what would be the point of automated spies?
 
@ThomasSG and Afforess

alt hunt button. Better I think. For the first one my concept was "intercept barbarians" this one is based of the tech tree hunting icon.

I tried merging yesterday, but ran into a problem somewhere. I'll get it a go again today. If someone has a download that would be great.. Other than that I'm using the code above and the beta sdk files from "A New Dawn" to work on this. I've done the icons but haven't seen em in game lol.
 

Attachments

Keldath,
There is a Modified Part and a New Part, each are separated and labeled. If you get errors when compiling, post them, and I'll try to help.

smeagolheart,

Did You ever get it to compile correctly? I'm working on an Automate Pirate Ship, do you think you could make a button for that too? I'd be eternally grateful.

To All,

Any other significant automations that I should add?

Let me see if I understand the concept of "Automate Pirate Ship"... Is this an auto-pillaging option for ships or a border patrol thing (ocean and coastal bound)? Will the targets will be pillage enemies or hunting pirate ships?
 
@Afforess: hm dunno. ;) I've just tested your automations. Very nice! :) But hunters should prefer hunting near enemy culture when at war.

@smeagolheart: your attachment does not work. //edit: now.
 
Back
Top Bottom