Civ FFH2 spells

dood100125

Chieftain
Joined
Sep 13, 2010
Messages
34
Location
Manitoba
I have made a spell for my mod but I dont know how to change the effect it will have in the game? I want it to change a tile to ice terrain like the spell snowfall but only for only one tile could anybody help me with this please.
 
How do you mean you have made a spell, but you really don't know how to make one? :confused:

If you post your code I would probably be able to figure out what to do with it.
 
there is a tag for every spell:
<Effect>X</Effect>
just put the desired effect in there. the different effects are listed in the CIV4EffectInfos.xml
if you create a new effect you have to link it there first and then in the spell
i hope i could answer your question.
 
who gave you that idea? the tag already exists in ffh you just have to use it in your xml code.
 
Sorry if I did not explain corectly I have made a spell thru my xml. But I want the spell to change the terrain tile the caster is on and the only way I could co that, I think is thru python script but I cant seem to get that to work either. below is my xml.


Code:
</SpellInfo>    
		<SpellInfo>			<!-- Frost -->
			<Type>SPELL_Frost</Type>
			<Description>Frost</Description>
			<Civilopedia>Turns the surrounding tiles to ice temp</Civilopedia>
			<Help> </Help>
			<PromotionPrereq1>PROMOTION_Werdandi</PromotionPrereq1>
			<UnitPrereq>UNIT_Werdandi</UnitPrereq>
			<bAllowAI>1</bAllowAI>
			<bCausesWar>1</bCausesWar>
			<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
			<bHasCasted>1</bHasCasted>
			<iRange>1</iRange>
			<PyResult>spellSnowfall(pCaster)</PyResult>
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_SPRING</Sound>
			<bGraphicalOnly>1</bGraphicalOnly>
			<Button>Art/Interface/Buttons/Spells/Snowfall.dds</Button>

and is this the line that directs it to python?
Code:
<PyResult>spellSnowfall(pCaster)</PyResult>

could anybody help please?
 
The interesting thing here would be the name/variable/reference "pCaster". I'm assuming this is a unit, then? And not a player or something else?

I don't have FFH2 myself but you should probably locate the .py file which would include the function/method spellSnowfall() - in other words the file where the other spell effects are scripted. If you could post some code from that module I would be able to write the code for you.

Copy-paste from the top of the file and some way down - something like one spell definition would be sufficient to see how the module is setup. And don't forget to use the
Code:
 tags!
 
I tracked down where the xml led to and all I could find was the CvSpellInterface PY file and I did try the copy and paste method and just rename the Snowfall to Frost and it doesn't seem to reconize it? examples:

The spell snow fall
Code:
</SpellInfo>
		<SpellInfo>			<!-- Snowfall -->
			<Type>SPELL_SNOWFALL</Type>
			<Description>TXT_KEY_SPELL_SNOWFALL</Description>
			<Civilopedia>TXT_KEY_SPELL_PLACEHOLDER_PEDIA</Civilopedia>
			<Help>TXT_KEY_SPELL_SNOWFALL_HELP</Help>
			<PromotionPrereq1>PROMOTION_ICE3</PromotionPrereq1>
			<PromotionPrereq2>PROMOTION_DIVINE</PromotionPrereq2>
			<bAllowAI>1</bAllowAI>
			<bCausesWar>1</bCausesWar>
			<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
			<bHasCasted>1</bHasCasted>
			<iRange>1</iRange>
			<iDamage>40</iDamage>
			<iDamageLimit>80</iDamageLimit>
			<DamageType>DAMAGE_COLD</DamageType>
			<PyResult>spellSnowfall(pCaster)</PyResult>
			<Effect>EFFECT_SNOWFALL</Effect>
			<Sound>AS3D_SPELL_SPRING</Sound>
			<Button>Art/Interface/Buttons/Spells/Snowfall.dds</Button>

what I found in the CvSpellInterface PY file
Code:
def spellSnowfall(caster):
	iX = caster.getX()
	iY = caster.getY()
	iFlames = gc.getInfoTypeForString('FEATURE_FLAMES')
	iSmoke = gc.getInfoTypeForString('IMPROVEMENT_SMOKE')
	iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			if not pPlot.isNone():
				if not pPlot.isWater():
					if pPlot.getTerrainType() != iSnow:
						iRnd = CyGame().getSorenRandNum(6, "Snowfall") + 3
						pPlot.setTempTerrainType(iSnow, iRnd)
						if pPlot.getFeatureType() == iFlames:
							pPlot.setFeatureType(-1, -1)
						if pPlot.getImprovementType() == iSmoke:
							pPlot.setImprovementType(-1)

As long as use the string
Code:
<PyResult>spellSnowfall(pCaster)</PyResult>
in my spell's xml it works?

and here is my spell xml and its location in the PY file
Code:
</SpellInfo>   
		<SpellInfo>			<!-- Frost -->
			<Type>SPELL_Frost</Type>
			<Description>Frost</Description>
			<Civilopedia>Turns the surrounding tiles to ice temp</Civilopedia>
			<Help> </Help>
			<PromotionPrereq1>PROMOTION_Werdandi</PromotionPrereq1>
			<UnitPrereq>UNIT_Werdandi</UnitPrereq>
			<bAllowAI>1</bAllowAI>
			<bCausesWar>1</bCausesWar>
			<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
			<bHasCasted>1</bHasCasted>
			<iRange>1</iRange>
			<PyResult>spellFrost(pCaster)</PyResult>
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_SPRING</Sound>
			<bGraphicalOnly>1</bGraphicalOnly>
			<Button>Art/Interface/Buttons/Spells/Snowfall.dds</Button>

Code:
def spellFrost(caster):
	iX = caster.getX()
	iY = caster.getY()
	iFlames = gc.getInfoTypeForString('FEATURE_FLAMES')
	iSmoke = gc.getInfoTypeForString('IMPROVEMENT_SMOKE')
	iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			if not pPlot.isNone():
				if not pPlot.isWater():
					if pPlot.getTerrainType() != iSnow:
						iRnd = CyGame().getSorenRandNum(6, "Snowfall") + 3
						pPlot.setTempTerrainType(iSnow, iRnd)
						if pPlot.getFeatureType() == iFlames:
							pPlot.setFeatureType(-1, -1)
						if pPlot.getImprovementType() == iSmoke:
							pPlot.setImprovementType(-1)

Any suggestions?
 
Any suggestions?
Yeah, add this to CySpellInterface:
Code:
def spellSnow(caster):
	iX = caster.getX()
	iY = caster.getY()
	iFlames = gc.getInfoTypeForString('FEATURE_FLAMES')
	iSmoke = gc.getInfoTypeForString('IMPROVEMENT_SMOKE')
	iSnow = gc.getInfoTypeForString('TERRAIN_SNOW')
	pPlot = CyMap().plot(iX,iY)
	if not pPlot.isNone() and not pPlot.isWater() and pPlot.getTerrainType() != iSnow:
		iRnd = CyGame().getSorenRandNum(6, "Snowfall") + 3
		pPlot.[B]setTempTerrainType[/B](iSnow, iRnd)
		if pPlot.getFeatureType() == iFlames:
			pPlot.setFeatureType(-1, -1)
		if pPlot.getImprovementType() == iSmoke:
			pPlot.setImprovementType(-1)
The thing I'm not sure about is the method highlighted above. It must be something specific to the mod, because I sure can't find it in the CivIV Python Library...
 
It would help if you had posted this in the FFH 2 forum- or in the "modder's guide" thread there.

For future reference- any XML tag added in FFH that begins with "Py" takes the name (and arguments) of a function that redirects to CvSpellInterface.py. The main other one is <PyRequirement>, which lets you define a requirement function (that returns true if a spell can happen, false if not) in the same file.
 
Top Bottom