AI Preferences In Building and Using Units

thinkingnut

Warlord
Joined
Sep 18, 2013
Messages
146
Hi Everyone,

I'm trying to tweak it so that a particular AI I've created will do two things.

1. Build and use more siege units when attacking.

2. Use a particular unit as a super medic.

Anyone know how I can do this in the CIV4LeaderHeadInfos.xml?

Many thanks,
W.
 
In the LeaderHeadInfos, the tag <iBuildUnitProb> is quite general. You also have the <UnitAIWeightModifiers> which could be a more specific, like UNITCOMBAT_SIEGE for your desired siege units.

Otherwise, in the UnitInfos, you could use the tag iAIWeight for a certain unit if you see that the AI, in general then, does not seem to build enough of them to your taste.

Edit: near the top of the forum's page, there's a link to the Modiki. You will find there explanations for most of the tags in the XML. Happy modding!
 
In the LeaderHeadInfos, the tag <iBuildUnitProb> is quite general. You also have the <UnitAIWeightModifiers> which could be a more specific, like UNITCOMBAT_SIEGE for your desired siege units.

Otherwise, in the UnitInfos, you could use the tag iAIWeight for a certain unit if you see that the AI, in general then, does not seem to build enough of them to your taste.

Edit: near the top of the forum's page, there's a link to the Modiki. You will find there explanations for most of the tags in the XML. Happy modding!

Ah, an old friend, Isenchine! Great, thank you again for your help. :crazyeye:
 
Well, I guess I should clarify my second point.

Created a UU that's a replacement for a scout. It has a free medic 1, guerrilla 1 and woodsman 1 promotion. The idea is that once it has served its scouting purposes in the early game, one can attach a GG to it to make it become a super medic (I unlocked woodsman 3 for recon units) so that he can heal for +40% per turn.

Thing is, I notice the AI only using him as a scout. Is there any way to make it understand that this unit can also be used throughout the entire game as a super medic? I know the AI aren't the brightest of players, but there must be a way, right?
 
In the LeaderHeadInfos, the tag <iBuildUnitProb> is quite general. You also have the <UnitAIWeightModifiers> which could be a more specific, like UNITCOMBAT_SIEGE for your desired siege units.

To clarify, UnitAIWeightModifiers is for UnitAITypes not CombatTypes.

Well, I guess I should clarify my second point.

Created a UU that's a replacement for a scout. It has a free medic 1, guerrilla 1 and woodsman 1 promotion. The idea is that once it has served its scouting purposes in the early game, one can attach a GG to it to make it become a super medic (I unlocked woodsman 3 for recon units) so that he can heal for +40% per turn.

Thing is, I notice the AI only using him as a scout. Is there any way to make it understand that this unit can also be used throughout the entire game as a super medic? I know the AI aren't the brightest of players, but there must be a way, right?

Not with XML only. That's too specific.
Actually, what we call the AI is nothing but a bunch of dice rolls with some tendencies.
 
To clarify, UnitAIWeightModifiers is for UnitAITypes not CombatTypes.

Not with XML only. That's too specific.
Actually, what we call the AI is nothing but a bunch of dice rolls with some tendencies.

Right, of course! I went to the Units file looking for a specific UnitAIType and stumbled upon UNITCOMBAT_SIEGE which suddenly appealed to me! It would rather be UNITAI_COLLATERAL or the generic UNITAI_ATTACK_CITY for a siege engine.

To elaborate a bit on what Horatius said, the AI is told what to do with units mainly through those UNITAI types. So your scout-to-become-a-medic still has UNITAI_EXPLORE and will remain an explorer. For the AI, Medic is just a promotion. There is no such UNITAI as UNITAI_MEDIC as long as you don't write the codes for that in C++ in the files that are then compiled as a dll.

Then only the bunch of dice rolls will have a Medic tendency... :)
 
To clarify, UnitAIWeightModifiers is for UnitAITypes not CombatTypes.



Not with XML only. That's too specific.
Actually, what we call the AI is nothing but a bunch of dice rolls with some tendencies.

Darn. Ok. Thanks for clarifying.:yup:

Right, of course! I went to the Units file looking for a specific UnitAIType and stumbled upon UNITCOMBAT_SIEGE which suddenly appealed to me! It would rather be UNITAI_COLLATERAL or the generic UNITAI_ATTACK_CITY for a siege engine.

To elaborate a bit on what Horatius said, the AI is told what to do with units mainly through those UNITAI types. So your scout-to-become-a-medic still has UNITAI_EXPLORE and will remain an explorer. For the AI, Medic is just a promotion. There is no such UNITAI as UNITAI_MEDIC as long as you don't write the codes for that in C++ in the files that are then compiled as a dll.

Then only the bunch of dice rolls will have a Medic tendency... :)

Yes, I see. Well, UNITAI_ATTACK_CITY it is. I've tried slapping on UNITAI_COLLATERAL, but the AI still seems woefully bad at using siege. Did a Duel sized map where I fortified a bunch of rifles on a hill. Had the AI (at Deity, mind you) attack me, and it spent the next 200 years (all the way past 2050!) sending wave upon wave of Cuirassiers at my stack. It could have ended so much sooner if it thought of bringing some more siege. :hammer2:

Thank you to both of you for replying.

Edit: Oh, and for your interest, I got so frustrated at seeing it suicide so many troops at me that I eventually used World Builder and gifted it 16 Stealth Bombers. Needless to say, my remaining city fell soon after that lol.
 
Is there a specific AI for medic? if there is, then you can simply change the scout ai to that one, since scout is useless for AI, they will be fine without some simple exploring.
 
Is there a specific AI for medic? if there is, then you can simply change the scout ai to that one, since scout is useless for AI, they will be fine without some simple exploring.

Unfortunately there's no such UNITAI type. At least not in the XML files. I suppose one may be able to do something in the Python or, better yet, write entirely new code in the C++ files, but that's far beyond my capabilities.
 
How about the c2c mod? I saw medic specific units in that mod, maybe you can borrow some from there?
Sorry, I'm a newbie here, just share some stupid thoughts.
 
How about the c2c mod? I saw medic specific units in that mod, maybe you can borrow some from there?
Sorry, I'm a newbie here, just share some stupid thoughts.

C2c? What's that?

No, please. All questions and thoughts are welcome.
 
C2C = Caveman to Cosmos, a HUGE mod! :D

A medic specific unit is not enough if there is no appropriate coding for it in the dll. Maybe C2C has done that, but to extract the code and then compile your own dll is not an easy task.

I even had a look at this modcomp, but it is clearly said that the Doctor unit is a recon unit.
 
C2C = Caveman to Cosmos, a HUGE mod! :D

A medic specific unit is not enough if there is no appropriate coding for it in the dll. Maybe C2C has done that, but to extract the code and then compile your own dll is not an easy task.

I even had a look at this modcomp, but it is clearly said that the Doctor unit is a recon unit.

Aw darn. Thanks for looking into it isenchine.

No other way then. It's time to give the civ ANOTHER UU and UB! :goodjob:
 
Back
Top Bottom