Lutefisk Mafia
Inscrutable Enforcer
Want to be able to claim territory without having to build a city? Well now you can! Introducing the Lutefisk Mafia Claim Flags for FfH2!
Claim flags are a new unit that creates a zone of persistent culture around them, just like a city. This makes it possible to link far away improved resources into your civ, or to just claim territory to keep other civs out.
Here is a video clip of a claim flag being used:
Claim function = http://www.youtube.com/watch?v=0OI1BAPtwDA
The method and code examples are discussed in the Dungeon Adventure mod thread here: http://forums.civfanatics.com/showpost.php?p=6915331&postcount=502
And also reproduced in full below:
************
As I said earlier, I am going to release some of the individual items I came up with for this mod. My hope is that they will benefit the community in some way -- since it will be a while before a DA rebuild gets done.
And so, allow me to introduce "DA mod giblet 1: Claim flags."
By request, I am posting this first. Claim flags create a zone of persistent culture around them, without needing a city! This is great for claiming, and being able to get the benefits of, improved resources outside of ones normal cultural boundaries.
I created claim flags by modding the starbase code from Final Frontier. The essentials are:
1. A new unit, which I called "STARBASE_I" just to avoid more edits in the modded python code.
2. Changes and additions to the CvEventManager.py file.
3. Some method of getting the new unit into the game. In Final Frontier, starbases are built by constructor ships. In my mod, the ability to plant claim flags is restricted to a special unit called a "Dungeoneer," and required researching a special tech. The basis of this is a new spell called "stake claim." More on that later.
First, the new unit. I literally just ripped the starbase unitclass and unit XML from FF, as well as the unit arts. You could get away with any new unit actually, so long as you call it "STARBASE_I" or whatever name you use consistently in the modded python. Because I wanted the look of a planted flag, I just kept the starbase art, but scaled the NIF for the actual unit down to zero. That makes the unit itself invisible, but still shows the player flag. (Sneaky, huh?) The flag is what is important to see anyway.
Second, you must change CvEventManager.py file. Find the onEndGameTurn def and change the code block to match the stuff below. Also, add in all of the "starbase" related defs. Looks like this:
Finally, you will need a way to get the unit into the game. Keep in mind that the unit must be DOMAIN_IMMOBILE or things will get buggy on you quick. That is because the python creates an array that keeps track of where flags were planted and when. Earlier flags take precedence over later ones, and this is tied to position. Having mobile flags makes things buggy.
So given that the flags must be immobile, you need a way get them into the game that creates them at the spot they are intended to claim.
I created a spell called "stake claim" (internally called "crumbs"). Oddly enough, simply treating it like a permanent summon of a flag unit didn't seem to work. At least I couldn't make that work, which is a shame because it would have been the easiest way.
Anyway, here is the spell infos xml:
and here is the CvSpellInterface.py entry:
Finally, I have posted a snippet of the CvEventManager.py code for people to download:
http://www.atomicgamer.com/file.php?id=70011
It wouldn't be too hard to change the code to run off of an improvement rather than a unit. You can also change it so that the cultural zone will not penetrate certain terrains or features. For example, in my DA mod, I made it so the claim flag culture would not penetrate dungeon walls, but just the halls and rooms.
Anyway, enjoy! Let me know if it works, or you have additional questions.
Claim flags are a new unit that creates a zone of persistent culture around them, just like a city. This makes it possible to link far away improved resources into your civ, or to just claim territory to keep other civs out.
Here is a video clip of a claim flag being used:
Claim function = http://www.youtube.com/watch?v=0OI1BAPtwDA
The method and code examples are discussed in the Dungeon Adventure mod thread here: http://forums.civfanatics.com/showpost.php?p=6915331&postcount=502
And also reproduced in full below:
************
As I said earlier, I am going to release some of the individual items I came up with for this mod. My hope is that they will benefit the community in some way -- since it will be a while before a DA rebuild gets done.
And so, allow me to introduce "DA mod giblet 1: Claim flags."
By request, I am posting this first. Claim flags create a zone of persistent culture around them, without needing a city! This is great for claiming, and being able to get the benefits of, improved resources outside of ones normal cultural boundaries.
I created claim flags by modding the starbase code from Final Frontier. The essentials are:
1. A new unit, which I called "STARBASE_I" just to avoid more edits in the modded python code.
2. Changes and additions to the CvEventManager.py file.
3. Some method of getting the new unit into the game. In Final Frontier, starbases are built by constructor ships. In my mod, the ability to plant claim flags is restricted to a special unit called a "Dungeoneer," and required researching a special tech. The basis of this is a new spell called "stake claim." More on that later.
First, the new unit. I literally just ripped the starbase unitclass and unit XML from FF, as well as the unit arts. You could get away with any new unit actually, so long as you call it "STARBASE_I" or whatever name you use consistently in the modded python. Because I wanted the look of a planted flag, I just kept the starbase art, but scaled the NIF for the actual unit down to zero. That makes the unit itself invisible, but still shows the player flag. (Sneaky, huh?) The flag is what is important to see anyway.
Second, you must change CvEventManager.py file. Find the onEndGameTurn def and change the code block to match the stuff below. Also, add in all of the "starbase" related defs. Looks like this:
Code:
def onEndGameTurn(self, argsList):
'Called at the end of the end of each turn'
iGameTurn = argsList[0]
self.updateAllStarbases()
def doMakeStarbase(self, iPlayer, iX, iY):
pPlayer = gc.getPlayer(iPlayer)
pPlot = CyMap().plot(iX, iY)
# Create Starbase Unit
iUnitStarbaseID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_STARBASE_I')
pPlayer.initUnit(iUnitStarbaseID, iX, iY, UnitAITypes.UNITAI_ATTACK, DirectionTypes.NO_DIRECTION)
self.updateStarbaseCulture(iPlayer, iX, iY)
def updateStarbaseCulture(self, iPlayer, iX, iY):
# Create culture around unit
for iXLoop in range(iX-2, iX+3):
for iYLoop in range(iY-2, iY+3):
iActiveX = iXLoop
iActiveY = iYLoop
if (iActiveX < 0):
iActiveX = CyMap().getGridWidth() + iActiveX
if (iActiveY < 0):
iActiveY = CyMap().getGridHeight() + iActiveY
pLoopPlot = CyMap().plot(iActiveX, iActiveY)
if (pLoopPlot.getOwner() == -1):
pLoopPlot.setOwner(iPlayer)
pLoopPlot.changeCulture(iPlayer, 10, False)
def updateAllStarbases(self):
# Update Starbase culture
iUnitStarbaseID = CvUtil.findInfoTypeNum(gc.getUnitInfo,gc.getNumUnitInfos(),'UNIT_STARBASE_I')
# List made to preserve culture of units built first
aaiStarbaseList = []
for iPlayerLoop in range(gc.getMAX_CIV_PLAYERS()):
pPlayer = gc.getPlayer(iPlayerLoop)
pTeam = gc.getTeam(pPlayer.getTeam())
pyPlayer = PyPlayer(iPlayerLoop)
apUnitList = pyPlayer.getUnitList()
for pUnitLoop in apUnitList:
if (pUnitLoop.getUnitType() == iUnitStarbaseID):
aaiStarbaseList.append([pUnitLoop.getGameTurnCreated(), iPlayerLoop, pUnitLoop.getX(), pUnitLoop.getY()])
if (len(aaiStarbaseList) > 0):
# Make order such that units built first get culture preference
aaiStarbaseList.sort()
# aaiStarbaseList.reverse()
for iStarbaseLoop in range(len(aaiStarbaseList)):
self.updateStarbaseCulture(aaiStarbaseList[iStarbaseLoop][1], aaiStarbaseList[iStarbaseLoop][2], aaiStarbaseList[iStarbaseLoop][3])
Finally, you will need a way to get the unit into the game. Keep in mind that the unit must be DOMAIN_IMMOBILE or things will get buggy on you quick. That is because the python creates an array that keeps track of where flags were planted and when. Earlier flags take precedence over later ones, and this is tied to position. Having mobile flags makes things buggy.
So given that the flags must be immobile, you need a way get them into the game that creates them at the spot they are intended to claim.
I created a spell called "stake claim" (internally called "crumbs"). Oddly enough, simply treating it like a permanent summon of a flag unit didn't seem to work. At least I couldn't make that work, which is a shame because it would have been the easiest way.
Anyway, here is the spell infos xml:
Code:
<SpellInfo>
<Type>SPELL_CRUMBS</Type>
<Description>TXT_KEY_SPELL_CLAIM</Description>
<Civilopedia>TXT_KEY_SPELL_PLACEHOLDER_PEDIA</Civilopedia>
<Strategy>NONE</Strategy>
<Help>TXT_KEY_SPELL_CLAIM_HELP</Help>
<PromotionPrereq1>NONE</PromotionPrereq1>
<PromotionPrereq2>NONE</PromotionPrereq2>
<UnitPrereq>NONE</UnitPrereq>
<UnitClassPrereq>NONE</UnitClassPrereq>
<UnitCombatPrereq>NONE</UnitCombatPrereq>
<UnitInStackPrereq>NONE</UnitInStackPrereq>
<CivilizationPrereq>NONE</CivilizationPrereq>
<ReligionPrereq>NONE</ReligionPrereq>
<StateReligionPrereq>NONE</StateReligionPrereq>
<TechPrereq>TECH_CLAIM_STAKING</TechPrereq>
<bAllowAI>1</bAllowAI>
<bAdjacentToWaterOnly>0</bAdjacentToWaterOnly>
<bCausesWar>0</bCausesWar>
<bGlobal>0</bGlobal>
<bInBordersOnly>0</bInBordersOnly>
<bInCityOnly>0</bInCityOnly>
<iAIWeight>0</iAIWeight>
<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
<bHasCasted>1</bHasCasted>
<bIgnoreHasCasted>0</bIgnoreHasCasted>
<bResistable>0</bResistable>
<iRange>0</iRange>
<iResistModify>0</iResistModify>
<iDamage>0</iDamage>
<iDamageLimit>0</iDamageLimit>
<DamageType>NONE</DamageType>
<AddPromotionType1>NONE</AddPromotionType1>
<AddPromotionType2>NONE</AddPromotionType2>
<AddPromotionType3>NONE</AddPromotionType3>
<RemovePromotionType1>NONE</RemovePromotionType1>
<RemovePromotionType2>NONE</RemovePromotionType2>
<RemovePromotionType3>NONE</RemovePromotionType3>
<bBuffCasterOnly>0</bBuffCasterOnly>
<ConvertUnitType>NONE</ConvertUnitType>
<CreateBuildingType>NONE</CreateBuildingType>
<CreateFeatureType>NONE</CreateFeatureType>
<CreateImprovementType>NONE</CreateImprovementType>
<SpreadReligion>NONE</SpreadReligion>
<CreateUnitType>NONE</CreateUnitType>
<iCreateUnitNum>0</iCreateUnitNum>
<bPermanentUnitCreate>0</bPermanentUnitCreate>
<CreateUnitPromotion>NONE</CreateUnitPromotion>
<bImmuneTeam>0</bImmuneTeam>
<bImmuneNeutral>0</bImmuneNeutral>
<bImmuneEnemy>0</bImmuneEnemy>
<bImmuneFlying>0</bImmuneFlying>
<bImmuneNotAlive>0</bImmuneNotAlive>
<bDispel>0</bDispel>
<bPush>0</bPush>
<bRemoveHasCasted>0</bRemoveHasCasted>
<bSacrificeCaster>0</bSacrificeCaster>
<iChangePopulation>0</iChangePopulation>
<iCost>50</iCost>
<iImmobileTurns>0</iImmobileTurns>
<iMiscastChance>0</iMiscastChance>
<PyMiscast></PyMiscast>
<PyResult>spellCrumbs(pCaster)</PyResult>
<PyRequirement>reqCrumbs(pCaster)</PyRequirement>
<Effect>EFFECT_SPELL1</Effect>
<Sound></Sound>
<HotKey></HotKey>
<bAltDown>0</bAltDown>
<bShiftDown>0</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<bGraphicalOnly>0</bGraphicalOnly>
<iHotKeyPriority>0</iHotKeyPriority>
<Button>Art/Interface/Buttons/techtree/fanaticism.dds</Button>
</SpellInfo>
and here is the CvSpellInterface.py entry:
Code:
def reqCrumbs(caster):
pPlot = caster.plot()
if pPlot.getOwner() == caster.getOwner():
return False
if pPlot.isWater():
return false
if pPlot.isCity():
return False
return True
def spellCrumbs(caster):
pPlayer = gc.getPlayer(caster.getOwner())
newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_STARBASE_I'), caster.getX(), caster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
newUnit.finishMoves()
newUnit.setHasCasted(True)
Finally, I have posted a snippet of the CvEventManager.py code for people to download:
http://www.atomicgamer.com/file.php?id=70011
It wouldn't be too hard to change the code to run off of an improvement rather than a unit. You can also change it so that the cultural zone will not penetrate certain terrains or features. For example, in my DA mod, I made it so the claim flag culture would not penetrate dungeon walls, but just the halls and rooms.
Anyway, enjoy! Let me know if it works, or you have additional questions.