Mod - get elven and dwarven workers with appropriate religion

DieselBiscuit

Shoggoth tickler
Joined
Oct 23, 2005
Messages
117
Location
Land of the ice and snow (and oil)
Current version: 0.2 (download)

This mod gives access to dwarven and elven workers with the civics related to the Runes of Kilmorph and the Fellowship of the Leaves religons, Arete and Guardian of Nature.

Features:

  • Spells to upgrade workers available to civs running the Arete and Guardian of Nature civics.
  • Dwarven and Elven workers created this way revert to regular workers if their civic is abandoned.
  • Captured religious workers revert to regular workers.
  • CivilioPedia entries for both spells.
  • Easily customisable variables for cost to upgrade and available religious workers.
  • Does not break save games.

As briefly discussed in Maniacs mod thread (my apologies for that, Maniac) and based on an idea from Mr. Underhill, here's a small mod that allows adherents of the Fellowship and Runes to get workers based on their religion. The effect is implemented as spells available to regular workers. To be able to use the spell, the player must have the religious restricted civic (Guardian of Nature or Arete) and the worker must be standing in a city with a temple of the religion.

The default cost for this is 100 gold and the default maximum allowed workers of this type per player is 5. Both these variables are easily modifiable in the code.

Heres the code:
Spoiler :
Code:
Spell:		Blessing of Cernunnos
Effect:		Allows conversion of regular workers to elven workers. Economy civic must be
		Guardian of Nature and the worker to be upgraded must be in a city with a
		Temple of Leaves. Abandoning Guardian of Nature will cause elven workers made
		this way to revert to plain workers.
Files Affected: Assets\python\FFHSpells.py
		Assets\python\CvEventManager.py
		Assets\xml\units\CIV4SpellInfos.xml
		Assets\xml\units\CIV4UnitInfos.xml
		Assets\xml\text\CIV4GameText_FFH2.xml
Known Issues:	Doesn't revert civ-specific workers (Lanun, goblin, etc.) to their original form).
Breaks Saves:	No

Code Addition 1:
File: Assets\python\FFHSpells.py

<code>

#add to: canDisabledCast
	if eSpell == gc.getInfoTypeForString('SPELL_BLESSING_OF_CERNUNNOS'):
		return False
#add end


def reqBlessingOfCernunnos(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if not canCast(caster):
		return False
	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_ELVEN_WORKER'):
		return False
	if caster.getUnitClassType() != gc.getInfoTypeForString('UNITCLASS_WORKER'):
		return False
	if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
		return False
	pPlot = caster.plot()
	if pPlot.isCity() == False:
		return False
	pCity = pPlot.getPlotCity()
	if pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_OF_LEAVES')) == False:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	#if pPlayer.getStateReligion() != gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES'):
	#	return False
	if not pPlayer.isCivic(gc.getInfoTypeForString('CIVIC_GUARDIAN_OF_NATURE')):
		return False
	pTeam = gc.getTeam(pPlayer.getTeam())
	if not pTeam.isHasTech(gc.getInfoTypeForString('TECH_HIDDEN_PATHS')):
		return False
	py = PyPlayer(caster.getOwner())

	# Set the limit of units available with this variable
	iLimit = 5
	
	iNum = 0
	for pUnit in py.getUnitList():
		if (pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_ELVEN_WORKER')):
			iNum = iNum + 1
	if iNum >= iLimit:
		return False

	# Set the cost of upgrading with this variable
	iCost = 100
	
	if pPlayer.getGold() < iCost:
		return False
	if (pPlayer.getGold() < (2*iCost) and pPlayer.isHuman() == False):
		return False
	return True

def spellBlessingOfCernunnos(caster):
	doCast(caster)
	pPlayer = gc.getPlayer(caster.getOwner())
	newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_ELVEN_WORKER'), caster.getX(), caster.getY(), UnitAITypes.UNITAI_WORKER)
	bElf = caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_ELF'))
	newUnit.convert(caster)
	newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_FELLOWSHIP_OF_LEAVES'), true)
	if not bElf:
		newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ELF'), false)	

	# Set the cost of upgrading with this variable
	iCost = 100
	
	pPlayer.changeGold(-iCost)
	newUnit.finishMoves()
	
</code>

Code Addition 2
File: Assets\python\CvEventManager.py

<code>

#add to: onCombatResult
	if pLoser.getUnitType() == gc.getInfoTypeForString('UNIT_ELVEN_WORKER'):
		unitType = gc.getInfoTypeForString('UNIT_ELVEN_WORKER')
		if pLoser.isHasPromotion(gc.getInfoTypeForString('PROMOTION_FELLOWSHIP_OF_LEAVES')):
			unitType = gc.getInfoTypeForString('UNIT_WORKER')
		bUncaptured = False
		cf.FFHConvert(pWinner, pLoser, unitType, False)
#add end

</code>

Code Addition 3:
File: Assets\xml\units\CIV4Spellinfos.xml

<code>

<SpellInfo>
        <Type>SPELL_BLESSING_OF_CERNUNNOS</Type>
        <Description>TXT_KEY_SPELL_BLESSING_OF_CERNUNNOS</Description>
        <Civilopedia>TXT_KEY_SPELL_OF_CERNUNNOS_PEDIA</Civilopedia>
        <Strategy>NONE</Strategy>
        <Help>TXT_KEY_SPELL_BLESSING_OF_CERNUNNOS_HELP</Help>
        <PromotionPrereq1>NONE</PromotionPrereq1>
        <PromotionPrereq2>NONE</PromotionPrereq2>
        <iRangeSelectNum>-1</iRangeSelectNum>
        <SpellFlavors>
        </SpellFlavors>
        <Effect>EFFECT_NATURE_SUMMON</Effect>
        <Sound>AS3D_SPELL_BLOOM</Sound>
        <PyResult>FFHSpells.spellBlessingOfCernunnos(pCaster)</PyResult>
        <PyRequirement>FFHSpells.reqBlessingOfCernunnos(pCaster)</PyRequirement>
        <PyValidUnitTargets></PyValidUnitTargets>
        <PyAIWeight></PyAIWeight>
        <HotKey></HotKey>
        <bAltDown>0</bAltDown>
        <bShiftDown>0</bShiftDown>
        <bCtrlDown>0</bCtrlDown>
        <iHotKeyPriority>0</iHotKeyPriority>
        <Button>Art/Interface/Buttons/Units/Elvenworker.dds</Button>
</SpellInfo>

</code>

Code Change 1:
File: Assets\xml\units\CIV4UnitInfos.xml

<code>

#change in entry for elven worker:
<Capture>NONE</Capture>
#change end

</code>

Code Addition 4:
File: Assets\text\CIV4GameText_FFH2.xml

<code>

    <TEXT>
        <Tag>TXT_KEY_SPELL_BLESSING_OF_CERNUNNOS</Tag>
        <English>Blessing of Cernunnos</English>
        <French>Blessing of Cernunnos</French>
        <German>Blessing of Cernunnos</German>
        <Italian>Blessing of Cernunnos</Italian>
        <Spanish>Blessing of Cernunnos</Spanish>
    </TEXT>
    <TEXT>
        <Tag>TXT_KEY_SPELL_BLESSING_OF_CERNUNNOS_HELP</Tag>
        <English>Transforms an ordinary worker into an elven worker</English>
        <French>Transforms an ordinary worker into an elven worker</French>
        <German>Transforms an ordinary worker into an elven worker</German>
        <Italian>Transforms an ordinary worker into an elven worker</Italian>
        <Spanish>Transforms an ordinary worker into an elven worker</Spanish>
    </TEXT>
    <TEXT>
        <Tag>TXT_KEY_SPELL_BLESSING_OF_CERNUNNOS_PEDIA</Tag>
        <English>     Delving deep into the knowledge of the forests and ways of nature, workers studying in a Temple of the Leaves can aquire such a degree of symbiotism with the living forest that they effectively become elven workers.</English>
        <French>     Delving deep into the knowledge of the forests and ways of nature, workers studying in a Temple of the Leaves can aquire such a degree of symbiotism with the living forest that they effectively become elven workers.</French>
        <German>     Delving deep into the knowledge of the forests and ways of nature, workers studying in a Temple of the Leaves can aquire such a degree of symbiotism with the living forest that they effectively become elven workers.</German>
        <Italian>     Delving deep into the knowledge of the forests and ways of nature, workers studying in a Temple of the Leaves can aquire such a degree of symbiotism with the living forest that they effectively become elven workers.</Italian>
        <Spanish>     Delving deep into the knowledge of the forests and ways of nature, workers studying in a Temple of the Leaves can aquire such a degree of symbiotism with the living forest that they effectively become elven workers.</Spanish>
    </TEXT>
    
</code>

Spell:		Blessing of Kilmorph
Effect:		Allows conversion of regular workers to dwarven workers. Labor civic must be Arete
		and the worker to be upgraded must be in a city with a Temple of Kilmorph.
		Abandoning Arete will cause dwarven workers made this way to revert to plain workers.
Files Affected: Assets\python\FFHSpells.py
		Assets\python\CvEventManager.py
		Assets\xml\units\CIV4UnitInfos.xml
		Assets\xml\units\CIV4SpellInfos.xml
		Assets\xml\text\CIV4GameText_FFH2.xml
Known Issues:	Doesn't revert civ-spesific workers (Lanun, goblin, etc.) to their original form).
Breaks Saves:	No

Code Addition 1:
File: Assets\python\FFHSpells.py

<code>

#add to: canDisabledCast
	if eSpell == gc.getInfoTypeForString('SPELL_BLESSING_OF_KILMORPH'):
		return False
#add end

def reqBlessingOfKilmorph(caster):
	pPlayer = gc.getPlayer(caster.getOwner())
	if not canCast(caster):
		return False
	if caster.getUnitType() == gc.getInfoTypeForString('UNIT_DWARVEN_WORKER'):
		return False
	if caster.getUnitClassType() != gc.getInfoTypeForString('UNITCLASS_WORKER'):
		return False
	if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KHAZAD'):
		return False
	pPlot = caster.plot()
	if pPlot.isCity() == False:

		return False
	pCity = pPlot.getPlotCity()
	if pCity.hasBuilding(gc.getInfoTypeForString('BUILDING_TEMPLE_OF_KILMORPH')) == False:
		return False
	pPlayer = gc.getPlayer(caster.getOwner())
	#if pPlayer.getStateReligion() != gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):
	#	return False
	if not pPlayer.isCivic(gc.getInfoTypeForString('CIVIC_ARETE')):
		return False
	pTeam = gc.getTeam(pPlayer.getTeam())
	if not pTeam.isHasTech(gc.getInfoTypeForString('TECH_ARETE')):
		return False
	py = PyPlayer(caster.getOwner())

	# Set the limit of units available with this variable
	iLimit = 5
	
	iNum = 0
	for pUnit in py.getUnitList():
		if (pUnit.getUnitType() == gc.getInfoTypeForString('UNIT_DWARVEN_WORKER')):
			iNum = iNum + 1
	if iNum >= iLimit:
		return False

	# Set the cost of upgrading with this variable
	iCost = 100
	
	if pPlayer.getGold() < iCost:
		return False
	if (pPlayer.getGold() < (2*iCost) and pPlayer.isHuman() == False):
		return False
	return True

def spellBlessingOfKilmorph(caster):
	doCast(caster)
	pPlayer = gc.getPlayer(caster.getOwner())
	newUnit = pPlayer.initUnit(gc.getInfoTypeForString('UNIT_DWARVEN_WORKER'), caster.getX(), caster.getY(), UnitAITypes.UNITAI_WORKER)
	bDwarf = caster.isHasPromotion(gc.getInfoTypeForString('PROMOTION_DWARF'))
	newUnit.convert(caster)
	newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_RUNES_OF_KILMORPH'), true)
	if not bDwarf:
		newUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_DWARF'), false)
	# Set the cost of upgrading with this variable

	iCost = 100
	
	pPlayer.changeGold(-iCost)
	newUnit.finishMoves()
	
</code>

Code Addition 2
File: Assets\python\CvEventManager.py

<code>

#add to: onCombatResult
	if pLoser.getUnitType() == gc.getInfoTypeForString('UNIT_DWARVEN_WORKER'):
		unitType = gc.getInfoTypeForString('UNIT_DWARVEN_WORKER')
		if pLoser.isHasPromotion(gc.getInfoTypeForString('PROMOTION_RUNES_OF_KILMORPH')):
			unitType = gc.getInfoTypeForString('UNIT_WORKER')
		bUncaptured = False
		cf.FFHConvert(pWinner, pLoser, unitType, False)
#add end

</code>

Code Addition 3:
File: Assets\xml\units\CIV4Spellinfos.xml

<code>

<SpellInfo>
        <Type>SPELL_BLESSING_OF_KILMORPH</Type>
        <Description>TXT_KEY_SPELL_BLESSING_OF_KILMORPH</Description>
        <Civilopedia>TXT_KEY_SPELL_BLESSING_OF_KILMORPH_PEDIA</Civilopedia>
        <Strategy>NONE</Strategy>
        <Help>TXT_KEY_SPELL_BLESSING_OF_KILMORPH_HELP</Help>
        <PromotionPrereq1>NONE</PromotionPrereq1>
        <PromotionPrereq2>NONE</PromotionPrereq2>
        <iRangeSelectNum>-1</iRangeSelectNum>
        <SpellFlavors>
        </SpellFlavors>
        <Effect>EFFECT_SPELL2</Effect>
        <Sound>AS3D_SPELL_KIKIJUB_SELECT</Sound>
        <PyResult>FFHSpells.spellBlessingOfKilmorph(pCaster)</PyResult>
        <PyRequirement>FFHSpells.reqBlessingOfKilmorph(pCaster)</PyRequirement>
        <PyValidUnitTargets></PyValidUnitTargets>
        <PyAIWeight></PyAIWeight>
        <HotKey></HotKey>
        <bAltDown>0</bAltDown>
        <bShiftDown>0</bShiftDown>
        <bCtrlDown>0</bCtrlDown>
        <iHotKeyPriority>0</iHotKeyPriority>
        <Button>Art/Interface/Buttons/Units/Dwarvenworker.dds</Button>
</SpellInfo>

</code>

Code Change 1:

<code>

#change in entry for dwarven worker:
<Capture>NONE</Capture>
#change end

</code>

Code Addition 4:
File: Assets\text\CIV4GameText_FFH2.xml

<code>

    <TEXT>
        <Tag>TXT_KEY_SPELL_BLESSING_OF_KILMORPH</Tag>
        <English>Blessing of Kilmorph</English>
        <French>Blessing of Kilmorph</French>
        <German>Blessing of Kilmorph</German>
        <Italian>Blessing of Kilmorph</Italian>
        <Spanish>Blessing of Kilmorph</Spanish>
    </TEXT>
    <TEXT>
        <Tag>TXT_KEY_SPELL_BLESSING_OF_KILMORPH_HELP</Tag>
        <English>Transforms an ordinary worker into an dwarven worker</English>
        <French>Transforms an ordinary worker into an dwarven worker</French>
        <German>Transforms an ordinary worker into an dwarven worker</German>
        <Italian>Transforms an ordinary worker into an dwarven worker</Italian>
        <Spanish>Transforms an ordinary worker into an dwarven worker</Spanish>
    </TEXT>
    <TEXT>
        <Tag>TXT_KEY_SPELL_BLESSING_OF_KILMORPH_PEDIA</Tag>
        <English>     With the knowledge of Arete, a civilization adhering to the Runes of Kilmorph can bring their workers to a temple dedicated to her and ask them to be fully initiated into the Ways of the Earthmother. This gives them an increased affinity with dwarven stoneworking and effectively transforms the worker into a dwarven worker.</English>
        <French>     With the knowledge of Arete, a civilization adhering to the Runes of Kilmorph can bring their workers to a temple dedicated to her and ask them to be fully initiated into the Ways of the Earthmother. This gives them an increased affinity with dwarven stoneworking and effectively transforms the worker into a dwarven worker.</French>
        <German>     With the knowledge of Arete, a civilization adhering to the Runes of Kilmorph can bring their workers to a temple dedicated to her and ask them to be fully initiated into the Ways of the Earthmother. This gives them an increased affinity with dwarven stoneworking and effectively transforms the worker into a dwarven worker.</German>
        <Italian>     With the knowledge of Arete, a civilization adhering to the Runes of Kilmorph can bring their workers to a temple dedicated to her and ask them to be fully initiated into the Ways of the Earthmother. This gives them an increased affinity with dwarven stoneworking and effectively transforms the worker into a dwarven worker.</Italian>
        <Spanish>     With the knowledge of Arete, a civilization adhering to the Runes of Kilmorph can bring their workers to a temple dedicated to her and ask them to be fully initiated into the Ways of the Earthmother. This gives them an increased affinity with dwarven stoneworking and effectively transforms the worker into a dwarven worker.</Spanish>
    </TEXT>
    
</code>

Edit Nov 10:
I've been able to get full version zipped and available for download at this location (same as above). Have fun :)
 
Update to come for 0.3: Workers revert to workers of owning civs type instead of plain workers.
 
i can already see a major problem with this mod (at least imho). instead of requireing teh tech in order to change the unit could you please change it to require the civic? this prevents people from useing these after they chage out of the religion. or make them a religious unit that goes POOF if you switch religions.

side thought i just had. if you instead allow these to build something other then mines but that do the same thing then if the user changes religions not only will the worker POOF ... but all the improvements can POOF also ... this would prevent alot of abuse.
 
daladinn said:
i can already see a major problem with this mod (at least imho). instead of requireing teh tech in order to change the unit could you please change it to require the civic? this prevents people from useing these after they chage out of the religion. or make them a religious unit that goes POOF if you switch religions.

side thought i just had. if you instead allow these to build something other then mines but that do the same thing then if the user changes religions not only will the worker POOF ... but all the improvements can POOF also ... this would prevent alot of abuse.

Thanks for the feedback! :)

The civic requirement is duly noted and a good idea. I will make it so that the workers made this way gets a religious promotion and will revert to their old worker versions when you switch religion or civics.

I do not think that abuse of the improvements will be very serious, as with a maximum of 5 workers it would take a long time to get a big empire beefed up with elven improvements. Dwarven mines aren't overly powerful either, so I don't really see a big point in removing the improvements, though it can be done. It is meant to be more of a bonus to a Civ that sticks with a religion through the game and flavorwise I think it is be nice that a Civ can actually get specific boni of the races whom they try to emulate.
 
honestly the reason i said dwarves was because alot of people take kilmorph as a layover for the order. your right though , dwarves are not a big deal , however the elven workers are. if you can keep your cottages in forests after switching to the viel as an example. you gain a huge boost economically.

teh ability for elves to build elven farms i a nice bonus considering elves do not have any UU , yes they have heroes , but no UU's. i see no problem with having leaves grant elven worker privileges however if you change i dont think you should keep the terrain improvements. personally i think great forests should also go away with time if not in a leaves controlled area also.
 
oops, forgot another comment i had. you raised walls to 50% which i think is a great step to getting buildings being better then culture. however can you please adjust the rest of the buildings? either add 25% to each , or double them.

please include the elohim building in these thoughts....

also .... in SEVO you see that they have a fort enhancement system which i found awesome in actually play. it allowed forts to grant promotions. could you see about following that example? what you did with them so far is awesome and makes them "useable" but they should be a bit better as time goes on.
 
You're mixing up two different mods there daladinn - this is just a little one for the workers. Incidentally, the "exploits" you list as problems are very easy to do in the game anyway, since captured workers retain their abilities.
 
DieselBiscuit said:
Does anybody know how to keep the icons for upgrading workers from appearing shadowed out on other units?

Yes, Talchas added a "canDisabledCast" in FFHSpells.py. Any spell that returns false in it won't show up at all instead of showing up grey.

Code:
def canDisabledCast(caster, eSpell):
	if not canDisabledCastAny(caster):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_SACRIFICE'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_CONSUME_SOUL'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_PEACE'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_PIRATE_COVE'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_INQUISITION'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_CONVERT_CITY'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_DROWN'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_COMMANDER_JOIN'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_BURNING_BLOOD_SELF'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_CREW_BUCCANEERS'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_CREW_LONGSHOREMEN'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_CREW_NORMAL_CREW'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_CREW_SKELETON_CREW'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_SING'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_RECRUIT_MERCENARY'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_HELLFIRE'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_SPRINT'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_TAKE_AXE'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_TRAIN_MACEMAN'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_TRAIN_DANCE_OF_BLADES'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_TRAIN_ESCAPE'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_TRAIN_HASTE'):
		return False
	if eSpell == gc.getInfoTypeForString('SPELL_TRAIN_RAISE_SKELETON'):
		return False
	return True
 
your right , hehe , i was mixing up mods...

however , yes , you can capture workers np . thats great and awesome . much much harder to do then take any old elf via slavery.

we are only really trying to get around the slavery exploit. imho gaining or losing a worker has its own rewards and penalties, hehe
 
Kael said:
Yes, Talchas added a "canDisabledCast" in FFHSpells.py. Any spell that returns false in it won't show up at all instead of showing up grey.
I found it for my update, but thanks for the quick answer! You really are omnipresent in these forums :)
 
New version and new download link with all files in one zip-file (150 views and 0 downloads == :sad: ), so I kind of hope this bump will get the mod a couple of downloads *coughity*
 
MrUnderhill said:
Just downloaded it. Trying it out now.

Great! I am currently reworking the system of how religions are founded: Everyone without a state religion gets a religion when they research the related tech, but to get the holy city (ie. found the religion) you have to be the first to build a temple of that religion. I'm going to use this mod as a basis for adding a bonus of having a holy city of your state religion and I thought that this was pretty suitable for Leaves and Runes.

Any feedback and ideas would be appreciated :)
 
Back
Top Bottom