Advertisement
Civilization Fanatics' Center

Go Back   Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization

Notices

Reply
 
Thread Tools
Old May 15, 2009, 05:58 PM   #1
peter450
Prince
 
Join Date: Sep 2006
Posts: 392
Getting the ai to not build a unit

Does anyone know what, i need to put in the unitinfos.xml to have the ai not build a unit type, i'm sure this is the file i need to edit as it has all the unit attributes and unit AI types but i don't know what to put in place of the default unit AI

On a side note, does anyone know if the pirate AI also works for a land unit, with the hidden nationality, always hostile atrributes?
peter450 is offline   Reply With Quote
Old May 15, 2009, 06:16 PM   #2
The_J
Say No 2 Net Validations
 
The_J's Avatar
 
Join Date: Oct 2008
Location: Germany / Netherlands
Posts: 29,034
Images: 51
Do you want, that nobody can build the unit?
If yes: Set iCost to -1, this disables a unit.
__________________
Civ4-BtS-Mod "Mars, Now!"


Steam eats the souls of little gamers!!!
The_J is offline   Reply With Quote
Old May 15, 2009, 06:38 PM   #3
Tholish
Emperor
 
Tholish's Avatar
 
Join Date: Jul 2002
Location: Japan
Posts: 1,344
Quote:
Originally Posted by peter450 View Post
On a side note, does anyone know if the pirate AI also works for a land unit, with the hidden nationality, always hostile atrributes?
Definitely. It works real good.

The method to use to make the AI not build a unit depends on what kind of unit and why you want to discourage it. If you want to play as a human with a unit that the AI cannot use, why not just make a Human civilization in CivilizationInfos and give it this as a UU? If you simply want to discourage the building of a unit, you could make another unit similiar to it that is better. For example, if you have Swordsman and Legion, and you don't want the AI to build Swordsman, give Legion an icombat of 8 and Swordsman an icombat of 6, but make them otherwise identical.

Last edited by Tholish; May 15, 2009 at 06:44 PM.
Tholish is offline   Reply With Quote
Old May 15, 2009, 08:54 PM   #4
mechaerik
Tricking and/or Treating
 
mechaerik's Avatar
 
Join Date: Oct 2008
Location: Los Angeles
Posts: 6,999
But then nobody would build swordsmen at all (8 vs 6 at an identical cost), you want to set the iPower or iAsset (preferabley the latter) higher, because then the AI will think its better, but they'll be the same/
__________________
Then I have won.
mechaerik is online now   Reply With Quote
Old May 15, 2009, 09:52 PM   #5
phungus420
Deity
 
phungus420's Avatar
 
Join Date: Mar 2003
Posts: 6,296
Give it no UnitAIs, and fill up the NotUnitAI field with all UnitAI types for that domain, AI will never see it as a valid unit to build, as it is invalid for all roles it is looking to fill if that's the case.
iPower and iAsset will have an effect, but the AI will ignore it if it wants to fill a role and sees the unit is available and has the best stats for the job.
__________________
Do not PM me with questions about modding. I will not answer. If you want help with something, start a thread on it, or post in a related existing thread.
phungus420 is offline   Reply With Quote
Old May 16, 2009, 07:57 PM   #6
peter450
Prince
 
Join Date: Sep 2006
Posts: 392
Thanks for all the replies, basically i made a assasin unit, that becomes available with guilds (at least thats my current thinking)

The unit is going to be a national unit limited to 3, with a very good withdrawl change and attack bonus into difficult terain

It's also going to be hidden nationality and always hostile

I was told in the better AI forum that pirate AI does not work for land units, i don't want the AI to build this unit, as defensively it's not all that great, same str as a maceman and does not get terrain def bonus's, it relies on speed and making hit and run strikes using it high withdrawl and terrain attack bonus to ambush units before pulling back

The AI is just going to build it like a normal unit, as it's a hostile unit (anyone can attack it with declaring war, like a privateer)it will likely get killed the second they leave there teritory with it, so i don't want the AI wasting money on a quite expensive unit, that it won't use effectively, thats why i was wondering if there is somthing you can put in the unit AI field that basically says don't build this
peter450 is offline   Reply With Quote
Old May 16, 2009, 10:30 PM   #7
mechaerik
Tricking and/or Treating
 
mechaerik's Avatar
 
Join Date: Oct 2008
Location: Los Angeles
Posts: 6,999
Give it a very low iAsset and iPower, then the AI will think it's worthless.
__________________
Then I have won.
mechaerik is online now   Reply With Quote
Old May 17, 2009, 02:12 AM   #8
JEELEN
Deity
 
Join Date: Oct 2006
Location: Leiden, the Netherlands
Posts: 12,318
Images: 22
Good to know.

Any suggestions for a unit not to be built by barbs?
JEELEN is offline   Reply With Quote
Old May 17, 2009, 02:30 AM   #9
phungus420
Deity
 
phungus420's Avatar
 
Join Date: Mar 2003
Posts: 6,296
civilizationsinfos file. At the bottom of it is a list of all the units barbs and minor civs can't build/spawn as. Just add the unit there, and barbs/minors can't build or spawn as them.
__________________
Do not PM me with questions about modding. I will not answer. If you want help with something, start a thread on it, or post in a related existing thread.
phungus420 is offline   Reply With Quote
Old May 17, 2009, 02:41 AM   #10
JEELEN
Deity
 
Join Date: Oct 2006
Location: Leiden, the Netherlands
Posts: 12,318
Images: 22
Cool! I'll add it to my TO DO list for MOO2Civ's next patch. (Don't want Space Pirates to spawn Planetary Defense ships.)
JEELEN is offline   Reply With Quote
Old May 17, 2009, 12:33 PM   #11
deanej
Deity
 
deanej's Avatar
 
Join Date: Apr 2006
Location: New York State
Posts: 4,859
If you want to guarantee that an AI won't build a unit you can disallow it in python. In CvGameUtils.py in the cannotTrain method just add something like this:
Code:
		iKlingonUU = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_KLINGON_CHANG')
		iKlingonUUClass = gc.getUnitInfo(iKlingonUU).getUnitClassType()

                if (eUnit == iKlingonUU):
                    if (not gc.getPlayer(ePlayer).isHuman()):
                        return True
deanej is offline   Reply With Quote
Old May 17, 2009, 07:09 PM   #12
Flintlock1415
Emperor
 
Flintlock1415's Avatar
 
Join Date: Feb 2008
Location: MN
Posts: 1,057
Actually the XML tags using <Unit>NONE</Unit> works 100% of the time, without the need for Python.
__________________
Flintlock1415 is offline   Reply With Quote
Old May 17, 2009, 07:33 PM   #13
deanej
Deity
 
deanej's Avatar
 
Join Date: Apr 2006
Location: New York State
Posts: 4,859
I think that disallows everyone from building it (I say "I think" because many files have a <Unit> tag and I'm not sure where you're referring to). My stuff was mentioned for preventing the AI from building it while allowing humans to build it.
deanej is offline   Reply With Quote
Old May 17, 2009, 09:38 PM   #14
Flintlock1415
Emperor
 
Flintlock1415's Avatar
 
Join Date: Feb 2008
Location: MN
Posts: 1,057
I think I now understand your method. My way, when used in CivilizationInfos.xml disallows any chosen Civ to not build a unit, human or not. Your way appears to only allow the human to build a unit, which was the whole point of this thread.

Thanks for the clarification.
__________________
Flintlock1415 is offline   Reply With Quote
Old May 17, 2009, 10:34 PM   #15
JEELEN
Deity
 
Join Date: Oct 2006
Location: Leiden, the Netherlands
Posts: 12,318
Images: 22
Quote:
Originally Posted by deanej View Post
If you want to guarantee that an AI won't build a unit you can disallow it in python. In CvGameUtils.py in the cannotTrain method just add something like this:
Code:
        iKlingonUU = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_KLINGON_CHANG')
        iKlingonUUClass = gc.getUnitInfo(iKlingonUU).getUnitClassType()

                if (eUnit == iKlingonUU):
                    if (not gc.getPlayer(ePlayer).isHuman()):
                        return True
Ah, thanks! (I checked the barb list phungus mentioned, but it seems to list units the barbs actually do build.)
JEELEN is offline   Reply With Quote
Old May 18, 2009, 04:49 PM   #16
mechaerik
Tricking and/or Treating
 
mechaerik's Avatar
 
Join Date: Oct 2008
Location: Los Angeles
Posts: 6,999
Quote:
Originally Posted by JEELEN View Post
(I checked the barb list phungus mentioned, but it seems to list units the barbs actually do build.)
Actually, it uses the UU system to place NONE as a unit for that particular UnitClass. That's why you will never see barb missionaries, even if they captured a city with a religion. Below that is also the buildings they cannot build (all the wonders).
__________________
Then I have won.
mechaerik is online now   Reply With Quote
Old May 18, 2009, 05:39 PM   #17
JEELEN
Deity
 
Join Date: Oct 2006
Location: Leiden, the Netherlands
Posts: 12,318
Images: 22
OK, thanks.
JEELEN is offline   Reply With Quote
Old May 20, 2009, 02:21 AM   #18
JEELEN
Deity
 
Join Date: Oct 2006
Location: Leiden, the Netherlands
Posts: 12,318
Images: 22
Quote:
Originally Posted by deanej View Post
If you want to guarantee that an AI won't build a unit you can disallow it in python. In CvGameUtils.py in the cannotTrain method just add something like this:
Code:
        iKlingonUU = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_KLINGON_CHANG')
        iKlingonUUClass = gc.getUnitInfo(iKlingonUU).getUnitClassType()

                if (eUnit == iKlingonUU):
                    if (not gc.getPlayer(ePlayer).isHuman()):
                        return True
Hm. I changed the CvGameUtils.py like this:


def cannotTrain(self,argsList):
pCity = argsList[0]
eUnit = argsList[1]
bContinue = argsList[2]
bTestVisible = argsList[3]

# Block out the rest
return False

iStarbaseI = CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), "UNIT_STARBASE_I")
iStarbaseII = CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), "UNIT_STARBASE_II")
iStarbaseIII = CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), "UNIT_STARBASE_III")

if (eUnit == iStarbaseI or eUnit == iStarbaseII or eUnit == iStarbaseIII):
return True

iRobo-Warriors = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUni tInfos(),'UNIT_ROBO_WARRIORS')
iRobo-Armor = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUni tInfos(),'UNIT_ARMOR')
iRobo-Battleloid = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUni tInfos(),'UNIT_BATTLELOID')

if (eUnit == iRobo-Warriors or eUnit == iArmor or eUnit == iBattleloid):
return True

return False


copying the Starbase example, but after reloading I have no interface. What's wrong?
JEELEN is offline   Reply With Quote
Old May 20, 2009, 03:12 AM   #19
phungus420
Deity
 
phungus420's Avatar
 
Join Date: Mar 2003
Posts: 6,296
Put that in code tags. It's python so whitespace matters.
__________________
Do not PM me with questions about modding. I will not answer. If you want help with something, start a thread on it, or post in a related existing thread.
phungus420 is offline   Reply With Quote
Old May 20, 2009, 03:54 AM   #20
JEELEN
Deity
 
Join Date: Oct 2006
Location: Leiden, the Netherlands
Posts: 12,318
Images: 22
Do you mean like this: [CODE] ... [\CODE]? (Because that still gives me no interface.)
JEELEN is offline   Reply With Quote
Reply

Bookmarks

Go Back Civilization Fanatics' Forums > CIVILIZATION IV > Civ4 - Creation & Customization > Getting the ai to not build a unit

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Advertisement

All times are GMT -6. The time now is 10:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
This site is copyright Civilization Fanatics' Center.
Support CFC: Amazon.com | Amazon UK | Amazon DE | Amazon CA | Amazon FR