Austrin Remote Found modding questions

Pickly

Prince
Joined
Jun 5, 2009
Messages
535
Not about modding the spell itself, but about using it in another mod. (It's been copied from wildmana, so I'm asking the question here.)

I'm attempting to use this spell in another mod, but am running into a problems where both pythons don't actually work.

Python (strikethrough shows parts of the austrin spell that are deleted for my version..):

Code:
def reqAustrinRemoteFound(caster):
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())
	
	[s]if not pPlayer.isFeatAccomplished(FeatTypes.FEAT_EXPEDITION_READY):
		return false[/s]
		
	if pPlot.isOwned() and pPlot.getOwner() != caster.getOwner():
		return false
		
	if pPlot.isCityRadius():
		return false
		
	if pPlot.isWater():
		return false

	if not pPlayer.isHuman():
		if pPlot.getFoundValue() < (pPlot.area().getBestFoundValue() * 2) / 3:
			return false

	return true

def spellAustrinRemoteFound(caster):
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())

	pCity = pPlayer.initCity(pPlot.getX(),pPlot.getY())
	[s]CvEventManager.CvEventManager().onCityBuilt([pCity])
	pPlayer.setFeatAccomplished(FeatTypes.FEAT_EXPEDITION_READY, false)[/s]

I've also tried playing around with the XML changes, (The full spell is supposed to change the unit into a worker, though deleting this part doesn't have any effect either way.). It seems both parts of the python for the spell aren't working, as i cannot cast the spell when the requirement is included, while no city is founded when the the requirement is deleted or commented out.

(Awaits extremely simple, obvious answer that will make me feel really dumb when it is suggested.)
 
The feat's been deleted from the spell I'm attempting to use. (It's in bold above because it was changed. Perhaps I'll change the notification. for this.)
 
The feat's been deleted from the spell I'm attempting to use. (It's in bold above because it was changed. Perhaps I'll change the notification. for this.)

Post all of your code? Are you using a ritual, for example?

I'm not sure that you're actually doing anything in the spell part of the code. It's just some variable assignment.

From the code shown there, it should be creating a city on the caster's plot. Would be what initCity does. :p
 
Here's the XML for the spell at the moment. This is the only other part of the spell that I have been adjusting. The "change to worker" part of it has been moved around a bit.

(If there is an XML problem, I'll be a bit surprised, since all the parts appear to be in the same order as other spells. Though since nothing about the Python code seems have stuck out as wrong, only sensible place is here.

Code:
		<SpellInfo>	
			<Type>SPELL_SETTLE</Type>
			<Description>TXT_KEY_SPELL_SETTLE</Description>
			<Civilopedia>TXT_KEY_SPELL_SETTLE</Civilopedia>
			<Help>TXT_KEY_SPELL_SETTLE_HELP</Help>
			<UnitPrereq>UNIT_IMMIGRANT</UnitPrereq>
			<bAllowAI>1</bAllowAI>
			<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
			<ConvertUnitType>UNIT_WORKER</ConvertUnitType>
			<bHasCasted>1</bHasCasted>
			<iRange>1</iRange>
			<PyResult>spellSettle(pCaster)</PyResult>
			<PyRequirement>reqSettle(pCaster)</PyRequirement>		
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_MUTATION</Sound>
			<Button>Art/Interface/Buttons/Spells/Sanctify.dds</Button>
		</SpellInfo>

This current version is just copying the AustrinFound code, replacing all the numbers and links that need to be replaced, and adding the "change to worker element. As mentioned, the XML effects (change to worker) works and displays fine, its the python parts that aren't doing anything.
 
1. remove the convertunittype from XML
2. add back in the eventmanager line in the python
3. add this to the spellresult python (at the bottom)

Code:
pUnit=gc.getPlayer(caster.getOwner()).initUnit(gc.getInfoTypeForString("UNIT_WORKER"), caster.plot().getX(),caster.plot().getY(),UnitAITypes.UNITAI_WORKER, DirectionTypes.DIRECTION_NORTH)
pUnit.convert(caster)
pUnit.changeImmobileTimer(1)
 
Followed your advice, (I think) ended up with the code below, and the spell still does not do anything (With the requirement in, the spell can't be cast, without it in, the spell has no effect at all.)

Spoiler :

Code:
		<SpellInfo>	
			<Type>SPELL_SETTLE</Type>
			<Description>TXT_KEY_SPELL_SETTLE</Description>
			<Civilopedia>TXT_KEY_SPELL_SETTLE</Civilopedia>
			<Help>TXT_KEY_SPELL_SETTLE_HELP</Help>
			<UnitPrereq>UNIT_IMMIGRANT</UnitPrereq>
			<bAllowAI>1</bAllowAI>
			<bDisplayWhenDisabled>1</bDisplayWhenDisabled>
			<bHasCasted>1</bHasCasted>
			<iRange>1</iRange>
			<PyResult>spellSettle(pCaster)</PyResult>
			<PyRequirement>reqSettle(pCaster)</PyRequirement>	
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_MUTATION</Sound>
			<Button>Art/Interface/Buttons/Spells/Sanctify.dds</Button>
		</SpellInfo>

Code:
def reqSettle(caster):
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())
		
	if pPlot.isOwned() and pPlot.getOwner() != caster.getOwner():
		return false
		
	if pPlot.isCityRadius():
		return false
		
	if pPlot.isWater():
		return false

	if not pPlayer.isHuman():
		if pPlot.getFoundValue() < (pPlot.area().getBestFoundValue() * 2) / 3:
			return false

	return true

def spellSettle(caster):
	pPlot = caster.plot()
	pPlayer = gc.getPlayer(caster.getOwner())

	pCity = pPlayer.initCity(pPlot.getX(),pPlot.getY())
	CvEventManager.CvEventManager().onCityBuilt([pCity])
	pUnit=gc.getPlayer(caster.getOwner()).initUnit(gc.getInfoTypeForString("UNIT_WORKER"), caster.plot().getX(),caster.plot().getY(),UnitAITypes.UNITAI_WORKER, DirectionTypes.DIRECTION_NORTH)
	pUnit.convert(caster)
	pUnit.changeImmobileTimer(1)


(Which is really strange, since you've done plenty of this sort of stuff in the mods, so it seems like it should have worked, but still isnt'. Time to fiddle around with some more random XML stuff, I guess. Or find whichever comma is missing.)
 
check the civilization.ini if you have show python exceptions enabled.
you can use addmessage to see if the python code is run at all

CyInterface().addMessage(caster.getOwner(),True,25,"Hello Erebus!",'AS2D_UNIT_BUILD_UNIT',1,'Art/Interface/Buttons/Religions/Ashen.dds',ColorTypes(5),caster.getX(),caster.getY(),True,True)
 
It's working now. (turns out another non-working spell was interfering with it, which I hadn't thought was an issue.) Thanks for the python exceptions point.
 
Back
Top Bottom