Mod-Modders Guide to Fall Further

ok, having more problems

the spells to take the sword aren't working. My spellinfos.xml


Spoiler :
Code:
<?xml version="1.0"?>
<!-- Created with the FfH editor by Kael -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Spell Infos -->
<Civ4SpellInfos xmlns="x-schema:sabathiel_CIV4UnitSpellSchema.xml">
	<SpellInfos>
		<SpellInfo>			<!-- Take Justice (Promotion) -->
			<Type>SPELL_TAKE_JUSTICE_PROMOTION</Type>
			<Description>TXT_KEY_SPELL_TAKE_JUSTICE</Description>
			<Civilopedia>TXT_KEY_SPELL_PLACEHOLDER_PEDIA</Civilopedia>
			<Help>TXT_KEY_SPELL_TAKE_EQUIPMENT_HELP</Help>
			<PromotionInStackPrereq>PROMOTION_JUSTICE</PromotionInStackPrereq>
			<bAllowAI>1</bAllowAI>
			<iAIWeight>50</iAIWeight>
			<bHasCasted>1</bHasCasted>
			<bAbility>1</bAbility>
			<PyResult>spellTakeEquipmentPromotion(pCaster,'EQUIPMENT_JUSTICE')</PyResult>
			<PyRequirement>reqTakeEquipmentPromotion(pCaster,'EQUIPMENT_JUSTICE')</PyRequirement>
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_TRAIN</Sound>
			<bGraphicalOnly>1</bGraphicalOnly>
			<Button>Modules/Sabathiel/Justice.dds</Button>
		</SpellInfo>
		<SpellInfo>			<!-- Take Justice (Unit) -->
			<Type>SPELL_TAKE_JUSTICE_UNIT</Type>
			<Description>TXT_KEY_SPELL_TAKE_JUSTICE</Description>
			<Civilopedia>TXT_KEY_SPELL_PLACEHOLDER_PEDIA</Civilopedia>
			<Help>TXT_KEY_SPELL_TAKE_EQUIPMENT_HELP</Help>
			<UnitInStackPrereq>EQUIPMENT_JUSTICE</UnitInStackPrereq>
			<bAllowAI>1</bAllowAI>
			<iAIWeight>50</iAIWeight>
			<bHasCasted>1</bHasCasted>
			<AddPromotionType1>PROMOTION_JUSTICE</AddPromotionType1>
			<bBuffCasterOnly>1</bBuffCasterOnly>
			<bAbility>1</bAbility>
			<PyResult>spellTakeEquipmentUnit(pCaster,'EQUIPMENT_JUSTICE')</PyResult>
			<PyRequirement>reqTakeEquipmentUnit(pCaster,'EQUIPMENT_JUSTICE')</PyRequirement>
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_TRAIN</Sound>
			<bGraphicalOnly>1</bGraphicalOnly>
			<Button>Modules/Sabathiel/Justice.dds</Button>
		</SpellInfo>
	</SpellInfos>
</Civ4SpellInfos>


All the references in there are correct, no xml errors on startup. The spells just don't appear for other units in his tile, to take Justice.
I just copied the spells from War and changed some references.
What am I doing wrong?
 
Trying to block Duin from being built if a new Doviello leader (Baron Duin ;)) is in game, and currently alive. Does this block of code accomplish that, or am I doing it horribly wrong? Don't have time to test it just now. :lol: Put the relevant text in bold.

Code:
if eUnit == gc.getInfoTypeForString('UNIT_DUIN'):
	if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_DUIN):
		return True
[B]	iDuin = gc.getInfoTypeForString('LEADER_DUIN')
	for iPlayer in range(gc.getMAX_PLAYERS()):
		pLoopPlayer = gc.getPlayer(iPlayer)
		if pLoopPlayer.getLeaderType() == iDuin and pLoopPlayer.isAlive():
			return True[/B]

Edit: Never mind, just tested it. Works exactly as intended... Duin cannot be built if he is in game as a leader, but if he does not start as a leader or if he is killed, he becomes available as a hero. :goodjob:
 
Last edited:
Hm. A quick question. How would one go about adding a trait to a leader... preferably through an event.
 
I can't speak from personal experience, but from looking at how the Elohim do it, create an event in the xml, and in the python portion have something along the lines of
Code:
def doRemnantsOfPatria(argsList):
	iEvent = argsList[0]
	kTriggeredData = argsList[1]
	iPlayer = kTriggeredData.ePlayer
	pPlayer = gc.getPlayer(iPlayer)
	CyMessageControl().sendApplyEvent(5013, EventContextTypes.EVENTCONTEXT_ALL, (iPlayer,gc.getInfoTypeForString('TRAIT_INDUSTRIOUS'),True))

Although, I can't tell why pPlayer is necessary... it's not used at all.
 
Trying to block Duin from being built if a new Doviello leader (Baron Duin ;)) is in game, and currently alive. Does this block of code accomplish that, or am I doing it horribly wrong? Don't have time to test it just now. :lol: Put the relevant text in bold.

Code:
if eUnit == gc.getInfoTypeForString('UNIT_DUIN'):
	if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_DUIN):
		return True
[B]	iDuin = gc.getInfoTypeForString('LEADER_DUIN')
	for iPlayer in range(gc.getMAX_PLAYERS()):
		pLoopPlayer = gc.getPlayer(iPlayer)
		if pLoopPlayer.getLeaderType() == iDuin and pLoopPlayer.isAlive():
			return True[/B]

Edit: Never mind, just tested it. Works exactly as intended... Duin cannot be built if he is in game as a leader, but if he does not start as a leader or if he is killed, he becomes available as a hero. :goodjob:

You could actually do this a lot quicker by checking for the Civ Duin can lead first:

Code:
if eUnit == gc.getInfoTypeForString('UNIT_DUIN'):
	if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_DUIN):
		return True
	iDuin = gc.getInfoTypeForString('LEADER_DUIN')
	iDoviello = gc.getInfoTypeForString('CIVILIZATION_DOVIELLO')
	iNumDoviello = CyGame().getNumCivActive(iDoviello)
	for iLoop in range(iNumDoviello):
		pLoopPlayer = CyGame().getCivActivePlayer(iDoviello, iLoop)
		if pLoopPlayer.getLeaderType() == iDuin:
			return True


This way if there aren't any Doviello in the game (and alive), nothing is checked at all. If there ARE any Doviello, then we ONLY check the leaders of the Doviello Civs to see if any are Duin. Now instead of looping over 50 players, many of whom aren't alive and never had been, you only loop over the number of actual Doviello civs, most likely just one, if any.
 
It would probably be a good idea to make Angel/Manes gifting work like that too, and probably to make them only go to one random player of that civ instead of to all of them.
 
Aparently you haven't looked at our code in a while, it DOES work this way already. I've left it to grant units to all civilizations of that type for now though as I don't know of it being used for anything where such an issue comes up, so don't particularly need it fixed.
 
It seems you're right, xien Looking though the python, it seems to be expecting a promotion, and I've referenced a unit.
The promotion is called PROMOTION_JUSTICE, the unit is EQUIPMENT_JUSTICE

However, in my defence,it's kael's mistake, not mine. I just copied the template from War and altered a few things. In fact, all of the equipment taking spells are like this, as far as I can see. Referencing a unit where it should be a promotion. Why do any of them work at all, and why doesn't mine if this is the case ?


On another note, it's decided it no longer wants to load, anyways. And is now throwing generic xml errors. What could cause an "xml load call failed for civ4spellinfos.xml" The file is exactly as I posted above, unchanged, but it just refuses to load now. I'm not running any other modules with it atm, which seemed to be the problem before.
 
Last edited:
Oh, I misread what you said. The FIRST one.

Well, I don't think that is wrong either. War Does that too, look:

Spoiler :
Code:
<SpellInfo>			<!-- Take War (Promotion) -->
			<Type>SPELL_TAKE_WAR_PROMOTION</Type>
			<Description>TXT_KEY_SPELL_TAKE_WAR</Description>
			<Civilopedia>TXT_KEY_SPELL_PLACEHOLDER_PEDIA</Civilopedia>
			<Help>TXT_KEY_SPELL_TAKE_EQUIPMENT_HELP</Help>
			<PromotionInStackPrereq>[B][U]PROMOTION_WAR[/U][/B]</PromotionInStackPrereq>
			<bAllowAI>1</bAllowAI>
			<iAIWeight>50</iAIWeight>
			<bHasCasted>1</bHasCasted>
			<bAbility>1</bAbility>
			<PyResult>spellTakeEquipmentPromotion(pCaster,[B][U]'EQUIPMENT_WAR'[/U][/B])</PyResult>
			<PyRequirement>reqTakeEquipmentPromotion(pCaster,'[B][U]EQUIPMENT_WAR[/U][/B]')</PyRequirement>
			<Effect>EFFECT_SPELL1</Effect>
			<Sound>AS3D_SPELL_TRAIN</Sound>
			<bGraphicalOnly>1</bGraphicalOnly>
			<Button>Art/Interface/Buttons/Equipment/War.dds</Button>
		</SpellInfo>

Important part bolded.

Having a closer look at the spells, it seems that reqTakeEquipmentPromotion takes the name of the equipment unit, and gets the promotion from that. Seems like an odd way to do it. Wouldn't the logical method just be to directly pass the promotion name into the promotion version?
 
Last edited:
We have the units alphabetical, with equipment first, and promotions alphabetical with equipment first. Lucky coincidence that they happen to match up on index because of that.

EDIT: Or if you just looked at the python with your second post maybe it does account for things decently. Anyway.... Equipment has a huge overhaul planned as well, one day it'll be REAL easy to add new equipment, just a single boolean in the promotion(and possibly building too) instead of a promotion/unit/spell/spell(and possibly building/spell too)
 
Last edited:
Hi,

I'm back with another question:

I intended to use the following part of the promotion infos to gain beakers when killing a unit:

<CommercesFromWin>
<iCommerce>0</iCommerce> <!-- Gold -->
<iCommerce>10</iCommerce> <!-- Science -->
<iCommerce>0</iCommerce> <!-- Culture -->
</CommercesFromWin>

However, while my unit does have the promotion and it indeed specifies in the promotion text ingame that it will give 10 beakers per kill, no beaker are added when winning from defense combat or offense ones.

Any idea whether it is broken at the moment ? (seemed used for gold only in FF in the Bounty Hunter promo).
 
Code:
if eUnit == gc.getInfoTypeForString('UNIT_DUIN'):
	if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_DUIN):
		return True
	iDuin = gc.getInfoTypeForString('LEADER_DUIN')
	iDoviello = gc.getInfoTypeForString('CIVILIZATION_DOVIELLO')
	iNumDoviello = CyGame().getNumCivActive(iDoviello)
	for iLoop in range(iNumDoviello):
		pLoopPlayer = CyGame().getCivActivePlayer(iDoviello, iLoop)
		if pLoopPlayer.getLeaderType() == iDuin:
			return True

Doesn't appear to be working...Duin is in game, and I'm still able to construct him. :confused:
 
Ok, I'm stumped. And probably going to go bald from tearing my hair out.

I just keep getting generic xml errors for the spellinfos file. No linenumber or source of the problem. just "xml load call failed". It refuses to tell me why.


My current progress is attached to this post. Could anyone have a look and possibly try to figure out what's wrong?

One thing I can think of, do pyreqs and effects work in modules? I'm only referencing stuff that's already in FF, so I don't see why not. but perhaps that's yet another shortcoming of this frustrating module system.
 

Attachments

The sabathiel_CIV4UnitSpellSchema file is missing. I added it and it worked.
 
Hi,

I'm back with another question:

I intended to use the following part of the promotion infos to gain beakers when killing a unit:

<CommercesFromWin>
<iCommerce>0</iCommerce> <!-- Gold -->
<iCommerce>10</iCommerce> <!-- Science -->
<iCommerce>0</iCommerce> <!-- Culture -->
</CommercesFromWin>

However, while my unit does have the promotion and it indeed specifies in the promotion text ingame that it will give 10 beakers per kill, no beaker are added when winning from defense combat or offense ones.

Any idea whether it is broken at the moment ? (seemed used for gold only in FF in the Bounty Hunter promo).

The research you gain will be toward the TechPrereq of the unit you killed or any promotions on the unit. It is meant as a "reverse engineering" concept, so you won't wind up learning Omniscience after killing a warrior.

Doesn't appear to be working...Duin is in game, and I'm still able to construct him. :confused:

I would say at this point to add some text output so that you can debug the values and where the code is stopping at. Or possibly a spelling error in one of the getInfoType settings.
 
Back
Top Bottom