Mod-Modders Guide to Fall Further

I am in the process of trying to merge some of the changes made in the Orbis mod with Fall Further and it involved some modifications in the pythons. I have a feeling, based upon programming experience that I have introduced some undefined variables (i.e. no type assigned to them) that MAY be causing some errors when BTS is trying load the pythons ("Init python").

Note that I was FULLY expecting some errors on the initial attempt to run the modified XMLs and pythons, but the errors I'm getting aren't terribly explanatory.:eek:

Hopefully (and you'll probably tell me that I should NOT be messing around with the pythons!!! That's what I would tell any users of programmers that I've written... ;)) you can tell me where I might look to investigate the following errors.

The first error I get is: Traceback (most recent call last):

Followed by:

File "<string>", line 1, in ? (the question mark isn't helping!!!)

File "<string>", line 52, in load_module

File "CVEventInterface", line 14, in ? (I hadn't made ANY changes in this python...)

File "<string>, line 52, in load_module

File "CVCustomEventManager", line 23, in ?

File "<string>", line 52, in load_module

(I'm picking up a DEFINITE pattern here... The "<string>" sure seems to indicate that I have an untyped variable. I'm going to drop the "File "<string>" message since it appears between each of the following messages!!)

File "CVEventManager", line 11, in ?

File "CVScreensInterface", line 940, in ?

Then I get the error "NameError" followed by a colon (:)

name "MERCENARY_CHOOSER" is not defined

Failed to load python module CVEventInterface

Obviously the "MERCENARY_CHOOSER" is the problem. Any ideas on where this needs to be defined? I added a directory titled "Mercenaries" from Orbis that has a python file named "CvMercenaryChooser.py" that I THOUGHT would have provided the needed reference. Based upon my preliminary review, this capability seems pretty neat in Orbis given what I perceive it to permit. There are all kinds of references in the Orbis pythons to this ability.

As a side question, is there a good tool to find a specific referenced line within an XML? For example, I have an error in loading the art definitions (CIV4ArtDefines_Unit.xml) that references a specific line # (25420). Is there any editing tool that I could enter this line and actually have it go to it (Word sure doesn't work and a line editor I downloaded doesn't seem to help either).

Thanks and my apologies for being so freakin' lengthy.
 
Merc Chooser may be in part of the DLL, in which case you're hosed.

edit: Unless you want to learn how to reconstruct the DLLs and so stuff in there.
 
Merc Chooser may be in part of the DLL, in which case you're hosed.

edit: Unless you want to learn how to reconstruct the DLLs and so stuff in there.
I wanted to "give it a shot" to see if the new screen required changes to the DLL. Even it it doesn't work (i.e. doesn't provide the capability), I wouldn't think that it would cause this type of python load error. It seems to me that the path to find the Merc Chooser must be missing from some file...???
 
Most likely MERC_CHOOSER is defined as a global variable in one of the python files. Typically you need that kind of thing for defining a new screen. WidgetTypes are where new screens usually require some DLL support. Outside of that, they can be pure python fairly easily.
 
Asking here since vehem and xienwolf can't seem to figure out the problem:

Trying to tweak banishment to have a special effect on Ira, knocking off a few points of strength

Spoiler :
Code:
def spellBanishment(caster):
	iUndead = gc.getInfoTypeForString('PROMOTION_UNDEAD')
	iDemon = gc.getInfoTypeForString('PROMOTION_DEMON')
	iX = caster.getX()
	iY = caster.getY()
	iIra = gc.getInfoTypeForString('UNIT_IRA')
	pPlayer = gc.getPlayer(caster.getOwner())
	for iiX in range(iX-1, iX+2, 1):
		for iiY in range(iY-1, iY+2, 1):
			pPlot = CyMap().plot(iiX,iiY)
			for i in range(pPlot.getNumUnits()):
				pUnit = pPlot.getUnit(i)
				if pUnit.isHasPromotion(iUndead) or pUnit.isHasPromotion(iDemon):
					pUnit.doDamage(20, 50, caster, gc.getInfoTypeForString('DAMAGE_HOLY'), true)
				if pUnit.getUnitType() == iIra:
					iStrength = pUnit.getStrBoost()
					if iStrength >= 0:
						pUnit.changeStrBoost(-4)

The part I've added for ira, simply isn't working. It damages them as expected, but their strength doesn't change.

Any idea what's up ?
 
As a side question, is there a good tool to find a specific referenced line within an XML? For example, I have an error in loading the art definitions (CIV4ArtDefines_Unit.xml) that references a specific line # (25420). Is there any editing tool that I could enter this line and actually have it go to it (Word sure doesn't work and a line editor I downloaded doesn't seem to help either).

Any halfway decent text editor will show line numbers. (And Word isn't a halfway decent anything.)

I use Stani's Python Editor for editing Python and Notepad++ for any other text-files, which xml is a subset of. (Though sometimes I use python to edit xml.)


About your problem, if you aren't using from somemodule import *, which you should never use, there is no reason to expect that the name MERCENARY_CHOOSER should be available before you have defined it. Could it be that you should write somemodule.MERCENARY_CHOOSER?

Could you post the offending lines?

The part I've added for ira, simply isn't working. It damages them as expected, but their strength doesn't change.

Any idea what's up ?

Does it work if you use a different strength boost, id est -5?

I recall an issue with Repentant Angels where the function that read the strength counted elemental strength and the function that set strength didn't.

For instance, giving the angels -3 strength when they have 10+4 holy strength meant that the strength was read as 14 and then the base strength was set at 14-3, id est 11 for a net effect of +1 strength.

If Ira have +4 elemental strength, this bug would make no change when you try to deduct 4 from their strength.
 
Our StrBoost field was partially to bypass that exact issue (well, mostly it was so you can transfer the change in strength upon converting the unit, but it proved handy in avoiding that mess as well). But anyway, StrBoost only counts StrBoost, and nothing else. Typed damage doesn't touch it. The issue with Repentants was/is in FfH due to directly asking and adjusting the actual Strength value.
 
Allright, I'm breaking parts of Fall Flat that didn't get moved up into Further into modules, and I'm onto my Scion Tweaks and I have a small problem.

I'm trying to assign the Necropolis to a new Buildingclass so I can tell the Cathedral of Rebirth to look for four of those instead of four theaters (to shorten the "required to not die" part of the Scion techtree) and it's going completly wonky. It's giving me, in game, the Necropolis as "world wonder (249950116 allowed)" national wonder "also huge number" team wonder "huge number"

Even though in the xml it should do none of these. It still says it's a unique building for the Scions replacing nothing, so I know it seems to be doing its job - and the Cathedral links to it now, at least in the civopedia, so what is up with this?
 
StrBoost does allow negative numbers.


I'll have to check out how the limitations work for buildinginfos. Was Necropolis a buildingclass by itself initially? So does it still have a BuildingClass which points to it as the default building? Also does the CivilizationInfos point at it properly? Not sure if either of those matter, just trying to predict all the ways they might link together so I might have answers to questions that come up later when I do check it out.
 
It's one of the BUILDINGCLASS_CIV_BUILDING1 buildings. I wanted to give it it's own class. I managed to work around it by changing the pointer to BUILDINGCLASS_CIV_BUILDING4 - I just have two copies of it in the build bar when the module's loaded, but I can't build two necropoli in one city so it'll do for now.

On the bright side, I see PrereqTraits in the unitschema so I can avoid more python use!

EDIT: Okay, two headed dragon of a question. Know any way to change a unit's religion on the fly through XML only, or lower/reduce/eliminate anarchy from switching religions without Spiritual? Hmm. I guess I could tag the non-anarchy to the already incredibly strong trait, but it's throwing the entire balance out of whack for a simple effect I'm looking for.
 
Hi all,

I just realised I have a problem with the tech I am adding in the modular way.

Here is the tech file:

Code:
<Civ4TechInfos xmlns="x-schema:CIV4TechnologiesSchema.xml">
	<TechInfos>
		<TechInfo>		<!-- TECH_TEAR_SYMBIOSIS -->
			<Type>TECH_TEAR_SYMBIOSIS</Type>
 			<Description>TXT_KEY_TECH_TEAR_SYMBIOSIS</Description>
			<Civilopedia>TXT_KEY_TECH_TEAR_SYMBIOSIS_PEDIA</Civilopedia>
			<Help></Help>
			<Strategy></Strategy>
			<Advisor>ADVISOR_GROWTH</Advisor>
			<iAIWeight>0</iAIWeight>
			<iAITradeModifier>0</iAITradeModifier>
			<iCost>-1</iCost>
			<iAdvancedStartCost>-1</iAdvancedStartCost>
			<iAdvancedStartCostIncrease>0</iAdvancedStartCostIncrease>
			<Era>ERA_ANCIENT</Era>
			<FirstFreeUnitClass>NONE</FirstFreeUnitClass>
			<iFeatureProductionModifier>0</iFeatureProductionModifier>
			<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
			<iTradeRoutes>0</iTradeRoutes>
			<iHealth>0</iHealth>
			<iHappiness>0</iHappiness>
			<iFirstFreeTechs>0</iFirstFreeTechs>
			<iAsset>0</iAsset>
			<iPower>0</iPower>
			<bRepeat>0</bRepeat>
			<bTrade>0</bTrade>
			<bDisable>1</bDisable>
			<bGoodyTech>0</bGoodyTech>
			<bExtraWaterSeeFrom>0</bExtraWaterSeeFrom>
			<bMapCentering>0</bMapCentering>
			<bMapVisible>0</bMapVisible>
			<bMapTrading>0</bMapTrading>
			<bTechTrading>0</bTechTrading>
			<bGoldTrading>0</bGoldTrading>
			<bOpenBordersTrading>0</bOpenBordersTrading>
			<bDefensivePactTrading>0</bDefensivePactTrading>
			<bPermanentAllianceTrading>0</bPermanentAllianceTrading>
			<bVassalTrading>0</bVassalTrading>
			<bBridgeBuilding>0</bBridgeBuilding>
			<bIrrigation>0</bIrrigation>
			<bIgnoreIrrigation>0</bIgnoreIrrigation>
			<bWaterWork>0</bWaterWork>
			<iGridX>1</iGridX>
			<iGridY>14</iGridY>
			<DomainExtraMoves>
			</DomainExtraMoves>
			<CommerceFlexible>
			</CommerceFlexible>
			<TerrainTrades>
			</TerrainTrades>
			<bRiverTrade>0</bRiverTrade>
			<Flavors>
			</Flavors>
			<OrPreReqs>
			</OrPreReqs>
			<AndPreReqs>
			</AndPreReqs>
 			<Quote>TXT_KEY_TECH_TEAR_SYMBIOSIS_QUOTE</Quote>
			<Sound>AS2D_TECH_DING</Sound>
			<SoundMP>AS2D_TECH_DING</SoundMP>
			<Button>Art/Interface/Buttons/Swamp/Swamp.dds</Button>
			<PreferredAlignment>NONE</PreferredAlignment>
			<PrereqReligion>NONE</PrereqReligion>
			<iPrereqBroadAlignment>0</iPrereqBroadAlignment>
			<iFirstToTechAlignmentModifier>0</iFirstToTechAlignmentModifier>
			<iAlignmentModifier>0</iAlignmentModifier>  
		</TechInfo>
	</TechInfos>
</Civ4TechInfos>

And here is the result !
attachment.php


Somehow the tech disable all other tech ! I don't understand because I checked with the Jotnar Tradition Tech, and it seems quite similar, except for the name itself, but for the other tech not the same problem.

So I copied/pasted the tech into the main file. And then it works OK. Which would seem to mean the Techs cannot be modular (some kind of bug) ?

Any advice before I log it into the bug thread ? (I may do something wrong...)
 

Attachments

  • Civ4ScreenShot0024.JPG
    Civ4ScreenShot0024.JPG
    120.8 KB · Views: 398
OK... You may have picked up on the fact that I am TRYING to merge some features from Orbis into FF (I simply dropped the mercenary enhancement since I wasn't finding the source of the python load problem -- I still think that SOMEWHERE there is a path defined that I'm not finding!!). I have gotten past all the initialization errors (python, uncached XML, etc.). BUT...

Now I'm getting one of those extremely annoying "BTS must close" messages that tell you absolutely NOTHING about the problem (I looked at the technical details and they are pretty much Greek to me -- absolutely some type of core dump and call chain). I have the "HidePythonExceptions" set to "0", but it still does NOT tell me anything about the nature of the problem.

Does anyone know HOW to debug such a problem? A LONG time ago someone told me how to set controls so that I could trace some issues, but I'll be darned if I can find those instructions now.

If anyone can tell me how to debug errors of this nature (that tell you absolutely nothing about the cause), I would be in your debt. I'm anxious to get into the game so that I can start looking at the stuff that I've screwed up... :lol:
 
Most likely MERC_CHOOSER is defined as a global variable in one of the python files. Typically you need that kind of thing for defining a new screen. WidgetTypes are where new screens usually require some DLL support. Outside of that, they can be pure python fairly easily.
MERC_CHOOSER IS defined in the python file CVScreensInterface, but I'm missing some file that indicates what pythons should be included in the load. There is a new directory titled "Mercenaries" that contains the screen definition -- CVMercenaryChooser -- but the CVScreensInterface is, for some reason, failing to find it. As I mentioned in the previous post, I've dropped this code from the pythons so that I could move on with my debugging....
 
That really depends.
What features have you imported, I'll try to noodle this out and see what could be causing BTS to be totally explodey.
 
About your problem, if you aren't using from somemodule import *, which you should never use, there is no reason to expect that the name MERCENARY_CHOOSER should be available before you have defined it. Could it be that you should write somemodule.MERCENARY_CHOOSER?
This code (the import and "somemodule" is in the CVScreensInterface python (copied from the Orbis version). Have you, by any chance, downloaded this mod? You can look at this file and the other pythons that have been modified to support it (there are about 3 or 4 others -- I forget the exact count).
 
It's one of the BUILDINGCLASS_CIV_BUILDING1 buildings. I wanted to give it it's own class. I managed to work around it by changing the pointer to BUILDINGCLASS_CIV_BUILDING4 - I just have two copies of it in the build bar when the module's loaded, but I can't build two necropoli in one city so it'll do for now.

On the bright side, I see PrereqTraits in the unitschema so I can avoid more python use!

EDIT: Okay, two headed dragon of a question. Know any way to change a unit's religion on the fly through XML only, or lower/reduce/eliminate anarchy from switching religions without Spiritual? Hmm. I guess I could tag the non-anarchy to the already incredibly strong trait, but it's throwing the entire balance out of whack for a simple effect I'm looking for.

You can't change the unit's religion mid-game with XML, changing unit data with XML during game would require a spell, promotion or event. None of those can effect religion directly, but each could utilize python to do so. You could dodge the Anarchy with python in onReligionChange or whatever the callback is called for the event, do a check for the trait and remove the anarchy if they have it. Though that callback might happen before the Anarchy is set on the player, which would mean you cannot do it.



@sylvain5477: For now you will have to leave that tech non-modular while you finish working on the rest of the module. I had seen this happen early in my testing with the modular loading system and fixed it, but I must have reverted something later on which re-broke it. Please do make a note of it in the bug thread for me so I do not forget.
 
Bah, I'll use quasi-spiritual for the religion changes - Alternatively. Is there a way to change religion/add religion when a unit UPGRADES? Because I could ninja in something that would achieve the same desired effect, I think, and then keep it modular.
 
@sylvain5477: For now you will have to leave that tech non-modular while you finish working on the rest of the module. I had seen this happen early in my testing with the modular loading system and fixed it, but I must have reverted something later on which re-broke it. Please do make a note of it in the bug thread for me so I do not forget.

Done.
I switch to non-modular for the tech meanwhile.
 
Back
Top Bottom