Active City Defense

As a followup to this, while searching for something else I actually came across the CanRangeStrike, CanRangeStrikeNow, and CanRangeStrikeAt functions for cities. Could be used to semi-automate city defense, if you want to pursue this. If you're too busy though I could probably work something out eventually, just wanted to point it out.

once you establish a city can attack and get the x,y coords of the lowest health unit, you can have cities that a player forgot to bombard attack with this:

Code:
local player = Players[ num ];
for city in player:Cities() do
	--if city meets criteria:
	--city:DoTask(TaskType, x_coord, y_coord, TaskType??, bool??, bool??, bool??, bool??);
	city:DoTask(17, 29, 14, 17, true, true, true, true); --enemy unit at 29x,14y

tasktypes are from live tuner -> table browser -> action panel state
 
Is it posible to make cities earn exp the same way as units?

if yes, then you can make promotion to them and that way make cities that in constant battle harder to take.

A cities that has been in defending itself for the last 1000 years is then becomes harder to take compared to the city that has no confict at all eventhou the have the same buildings.
 
Is it posible to make cities earn exp the same way as units?

if yes, then you can make promotion to them and that way make cities that in constant battle harder to take.

A cities that has been in defending itself for the last 1000 years is then becomes harder to take compared to the city that has no confict at all eventhou the have the same buildings.

At the moment, No i'm afraid.

I asked this way back on page 1 I think it was. At the moment the gods that are creating these wonderful mods dont have the required access to the correct bits of the code etc.
 
Great Mod!
I have one concern, however. The 1 damage to adjacent enemies pr turn for castle and military base is a really good idea. It will, however, result in ranged units being even more owerpowered/important that they already are! With this setting I would just try to sit back and let my ranged units weaken the city and then charge in with melee! And I am pretty sure the AI would not be able to do that in the state it is currently in giving you yet another exploit/advantage (and you already have enough).
Why not give the city 1 additional attack pr turn or something with castle and the 1 hp damage to adjacent units when military base is built or something?

Apart from that it is a great and needed mod, I will for sure install it right away.

What stops the AI from rushing your fragile ranged units if you don't have a proper front line?
 
Found a MOD-Incompatibility:
- Thal´s-Balance v5
- Active City Defense (v 2)

Error: Well this one is a bit tricky :p - i used Patch 1.0.1.217
When you choose Meritocracy in the "Liberty"-Policytree you get a "Great Person" to choose from (with Thal´s Balance).
But when you click on the Icon which normally let you choose one - nothing happens!
Actions: Cleared cache, narrowed responsible Mods down to one "Active City Defense (v 2)",
confirmed by only installing these two mods - which resulted in this error
I used a new game-setup and Firetuner to test...
Tested with "Thal´s-Balance v5" and "Thal´s-Balance v5.2" - both result in errors
Info: Since i never had the Option to choose "Great Person" since i use MODs, i cant say if it would have worked with "Thal´s-Balance v4"
 
Well nonetheless...
MOD-Incompatibility fixed

i had a short look at the files used by afforess.
He uses the ingame.xml with only one line of added code

But the ingame.xml obviously was quite old - and the vanilla ingame.xml was modified since then!

I used the vanilla ingame.xml and added Afforess Code.
This fixed the "bug" but i havent tested if "Active City Defense" still works as intended :crazyeye:

Since i have only basic knowledge of how to work with code, it would be greatly appreciated if someone checks if this copy&paste was really enough :)

Anyway here all Infos:
Complete code of the new ingame.xml
Spoiler :

<?xml version="1.0" encoding="utf-8"?>
<Context Name="InGame" >

<LuaContext FileName="Assets/UI/Civilopedia/CivilopediaScreen" ID="CivilopediaScreen" Hidden="True" />

<Container Size="F,F" ID="BulkUI" >

<LuaContext FileName="Assets/UI/InGame/YieldIconManager" ID="YieldIconManager" Hidden="0" />
<LuaContext FileName="Assets/UI/InGame/PlotHelpManager" ID="PlotHelpManager" />
<LuaContext FileName="Assets/UI/InGame/ResourceIconManager" ID="ResourceIconManager" Hidden="0" />

<LuaContext FileName="Assets/UI/InGame/GenericWorldAnchor" />
<LuaContext FileName="Assets/UI/InGame/UnitFlagManager" ID="UnitFlagManager" />
<LuaContext FileName="Assets/UI/InGame/CityBannerManager" ID="CityBannerManager"/>
<Container ID="SelectedUnitContainer" />
<Container ID="PopupTextContainer" />


<LuaContext FileName="Assets/UI/InGame/WorldView/WorldView" ID="WorldView" />
<LuaContext FileName="Assets/UI/InGame/CityView/CityView" ID="CityView" Hidden="True" />

<LuaContext FileName="Assets/UI/InGame/TechTree/TechTree" ID="TechTree" Hidden="True" />

<!--<LuaContext FileName="Assets/UI/InGame/Popups/CityPurchasePopup" ID="CityPurchasePopup" Hidden="True" />-->
<LuaContext FileName="Assets/UI/InGame/Popups/GenericPopup" ID="GenericPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/TextPopup" ID="TextPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/SocialPolicyPopup" ID="SocialPolicyPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/NotificationLogPopup" ID="NotificationLogPopup" Hidden="True" />
<!--<LuaContext FileName="Assets/UI/InGame/Popups/MinorCivsListPopup" ID="MinorCivsListPopup" Hidden="True" />-->
<LuaContext FileName="Assets/UI/InGame/Popups/WhosWinningPopup" ID="WhosWinningPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/NewEraPopup" ID="NewEraPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/NaturalWonderPopup" ID="NaturalWonderPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/GoodyHutPopup" ID="GoodyHutPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/BarbarianCampPopup" ID="BarbarianCampPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/GoldenAgePopup" ID="GoldenAgePopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/GreatPersonRewardPopup" ID="GreatPersonRewardPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/CityStateGreetingPopup" ID="CityStateGreetingPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/CityStateDiploPopup" ID="CityStateDiploPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/DiploVotePopup" ID="DiploVotePopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/VoteResultsPopup" ID="VoteResultsPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/TechAwardPopup" ID="TechAwardPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/WonderPopup" ID="WonderPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/AdvisorInfoPopup" ID="AdvisorInfoPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/AdvisorCounselPopup" ID="AdvisorCounselPopup" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/AdvisorModal" ID="AdvisorModal" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/EconomicOverview" ID="EconomicOverview" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/DiploOverview" ID="DiploOverview" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/MilitaryOverview" ID="MilitaryOverview" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/EndGameMenu" ID="EndGameMenu" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/Demographics" ID="Demographics" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/VictoryProgress" ID="VictoryProgress" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/ChooseFreeItem" ID="ChooseFreeItem" Hidden="True" />

<LuaContext FileName="Assets/UI/InGame/Popups/SetUnitName" ID="SetUnitName" Hidden="True" />
<LuaContext FileName="Assets/UI/InGame/Popups/SetCityName" ID="SetCityName" Hidden="True" />
<!-- Added by Afforess -->
<LuaContext FileName="BuildingEffects" ID="BuildingEffects" Hidden="True" />
<!-- End add -->
<LuaContext FileName="Assets/UI/InGame/Popups/ProductionPopup" ID="ProductionPopup" Hidden="True" />

<LuaContext FileName="Assets/UI/InGame/TopPanel" ID="TopPanel" />

<Stack Anchor="C,T" Size="Full,Full" StackGrowth="B" Padding="16" ID="AlertStack" Offset="0,129"/>

<LuaContext FileName="Assets/UI/InGame/Menus/GameMenu" ID="GameMenu" Hidden="True" />

<Container ID="ScreenEdgeScrolling" Size="F,F" >

<Button Anchor="C,T" Size="F,2" ID="ScrollTop" />
<Button Anchor="C,B" Size="F,2" ID="ScrollBottom" />
<Button Anchor="L,C" Size="2,F" ID="ScrollLeft" />
<Button Anchor="R,C" Size="2,F" ID="ScrollRight" />

<!--
<Box Anchor="C,T" Size="F,2" Color="White" />
<Box Anchor="C,B" Size="F,2" Color="White" />
<Box Anchor="L,C" Size="2,F" Color="White" />
<Box Anchor="R,C" Size="2,F" Color="White" />
-->

</Container>

<LuaContext FileName="Assets/UI/FrontEnd/ExitConfirm" Hidden="1" />

</Container>

<LuaContext FileName="Assets/UI/InGame/DebugMenu" ID="DebugMenu" Hidden="True" />

<Label ID="FPSText" String="FPS" Anchor="C,B" Offset="0,60" Hidden="True" />
<Label ID="VisInfo" String="TextureInfo" Anchor="C,B" Offset="0,40" Hidden="True" />
<Label ID="DrawCalls" String="Draw Calls" Anchor="C,B" Offset="0,20" Hidden="True" />

<Label ID="SerialEventStream" String="SerialEventStream" Anchor="C,B" Offset="0,80" Hidden="True" />
<Label ID="NonSerialEventStream" String="NonSerialEventStream" Anchor="C,B" Offset="0,100" Hidden="True" />
<Label ID="LocalMachineEventStream" String="LocalMachineEventStream" Anchor="C,B" Offset="0,120" Hidden="True" />

<Label ID="TimerRate" String="Timer" Anchor="C,B" Offset="0,140" Hidden="True" />

<Instance Name="AlertMessageInstance" >
<Label ID="AlertMessageLabel" String="" Color0="255,255,200,255" Color1="0,0,0,200" Font="TwCenMT20" FontStyle="Stroke" Anchor="C,T"/>
</Instance>


<Instance Name="PopupText" >
<WorldAnchor ID="Anchor" Anchor="c,c" >
<SlideAnim Anchor="c,c" End="0,-100" Cycle="once" Speed=".5" ID="SlideAnim" >
<AlphaAnim Anchor="c,c" AlphaStart="0" Cycle="once" AlphaEnd="1" ID="AlphaAnimIn" Pause="0" Speed="100" >
<AlphaAnim Anchor="c,c" AlphaStart="1" Cycle="once" AlphaEnd="0" ID="AlphaAnimOut" Pause="0.75" Function="Square" >
<Label ID="Text" Anchor="c,c" ColorSet="White_Black" Font="TwCenMT22" FontStyle="Stroke" ForceNonIME="1" />
</AlphaAnim>
</AlphaAnim>
</SlideAnim>
</WorldAnchor>
</Instance>

</Context>


and below the whole file as attchment :)
.. which should replace the existing file in: "..\My Games\Sid Meier's Civilization 5\MODS\Active City Defense (v 2)\Lua\.."

EDIT:
hmm upload fails... no attachment
 
@ Bananijoe
Since the December patches, mods are no longer suppose to touch the ingame.xml. Instead, the Lua files used are to be put in to the 'Content' tab of the project file in ModBuddy. Under the 'Type' column you'd put in 'InGameUIAddin', under 'Name' and 'Description', you would put the ID names that were in the ingame.xml without extensions and under the FileName, you'd put the path of the files also specified in the ingame.xml.
 
I would highly recommend you lower the base strength of unfortified cities. Cities are way too difficult to take in the base game even if they have no walls, but I didn't see any changes suggesting the default values have changed.

Also, you can use saveutils mod component to track variables between saves.
 
I also would like to see the file posted here, as a Wine user i cant use the ingame modbrowser because no support in wine for the download tool this game uses.

I third this!
I'm on a mac, and while we mac users can mod the game to give us the option to use mods, we can't get to the mod browser.
I'd love to try this mod out. Help a non-PC owner out! :)
 
Interesting mod. I`ve been modifying city defence since way back by rising walls to 3000 defence points, castles to 4000, 50 hit points for both. Works wery fine; citys are still captured but (off course) a city with walls shouldn`t be an easy catch. Stabilizes the game.

City-walls like the Babylonian was seen as undefeatable back then, not like in this game where soldiers seems to just "walk through" them. The walls around old Constantinople stod against 17 attempts through 1000 years until they finally was broken by the worlds biggest cannon in 1453.

(updated)
 
Top Bottom