How to make unit only defend city?

aokces

Flanking III Submarine
Joined
Aug 17, 2005
Messages
116
Location
California
EDIT: Okay I found this thread-
http://forums.civfanatics.com/showthread.php?p=8910877

and I think I can make this work if I just set it to a Sea Domain like UNITAI_CARRIER_SEA

Thanks everyone!
==============================================================
I'm working on a scenario with pre-placed barbarian cities, some with strong defenders.

However, I want to make sure these "defenders" don't wander around the map creating havoc, and ONLY stay in that city. I've tried the different unit_ai_scripts in the editor like City_defense and even missile_unit, but they STILL wander around! :rolleyes:

Is there anyway to fix this in editor/scenario file without going into the xml? Thanks!
 
You need to set it in the XML so that they only get UNITAI_CITY_DEFENSE. Use the NotUnitAI tags to disallow everything else. That should solve your problem; the UNITAI_CITY_DEFENSE code only directs units to sit in cities and escort settlers/workers.
 
You could also make the defending unit type have its domain set to DOMAIN_IMMOBILE if you really do not want it to ever move for any reason.
 
The AI doesn't really build machine guns, so that wol't work. Basically the MG is disallowed from all UnitAI types except UNITAI_CITY_DEFENSE_SPECIAL. The problem is this unit AI isn't really used at all; if memory serves it will only consider building this unitAI type once for a city, and then will never do it again. If you actually want the AI to use the units, you must do something similar to this, as I describe in the first post, but limit it to the UNITAI_CITY_DEFENSE. Limiting the unit solely to the special version of this UnitAI wil mean the AI will, for all intents of and purposes, never build the unit.
 
You need to set it in the XML so that they only get UNITAI_CITY_DEFENSE. Use the NotUnitAI tags to disallow everything else. That should solve your problem; the UNITAI_CITY_DEFENSE code only directs units to sit in cities and escort settlers/workers.

Help me out here, is this how I add this tag?
Below is the .WBSaveFile
=========
BeginUnit
UnitType=UNIT_ARCHER, UnitOwner=18
Damage=0
Level=1, Experience=0
FacingDirection=4
UnitAIType=UNITAI_CITY_DEFENSE

NotUnitAI= UNITAI_ESCORT
NotUnitAI= UNITAI_ATTACK
NotUnitAI= UNITAI_ETC
NotUnitAI= UNITAI_ETC
NotUnitAI= UNITAI_ETC

EndUnit
===========
 
Are you sure that would work? If I had to guess, I'd say that 0 = infinite number of moves - like an ICBM.

As you wrote, I'm not sure, but it's just a simple hint to test
 
I'm working on a scenario with pre-placed barbarian cities, some with strong defenders.

However, I want to make sure these "defenders" don't wander around the map creating havoc, and ONLY stay in that city. I've tried the different unit_ai_scripts in the editor like City_defense and even missile_unit, but they STILL wander around! :rolleyes:

Is there anyway to fix this in editor/scenario file without going into the xml? Thanks!

did you try UNITAI_ANIMAL? that might work.

edit: if you set moves to 0 in the XML the unit cannot move. But in a scenario that's not an option.
 
Is there anyway to fix this in editor/scenario file without going into the xml? Thanks!

Sorry I did not see this.

No.

You can assign the units whatever UnitAI you want in the WBS file, but the AI will change these if it sees fit to do so. Also the barbarian civ works differently.

I suppose one thing you could try is to change the barbarians to some other civ in the WBS file, make their civ color black, turn them into a minor civ, and have them use the barbarian flag. That way they'd in effect, be the barbarians, they'd just show up on the scoreboard, and other SDK atributes of the barbs wouldn't apply. You could also give all these units the UnitAi for machine guns (UNITAI_CITY_DEFENSE_SPECIAL) in the WBS file. These things might work, I'm not sure. The regular AI is pretty reluctant to change UnitAI types, but it will do so; I'd just wager the Barbs would be more apt to do so.
 
Top Bottom