Mod-Modders Guide to Fall Further

Ok, having two issues with my module. Attached to this post.

Firstly, with the MLF. I've set it up in a way that seems like it should work, specifying the spell folder to load after the rest of the xml which is in a seperate subfolder. I'm still getting the same incorrect info type errors though. Possibly, I haven't named the mlf properly, although I'm not sure how this should be done. BCoC has no example of that.

Secondly, a modular python issue *pokes Odalrick*
I've narrowed my modular python problems down to something of my own doing, rather than a problem with modular python itself. druids.py in this module generates a lot of errors. I have it in a subfolder, and pointed the ini at said folder as instructed, but it won't work. Perhaps the python itself is at fault.
 

Attachments

Secondly, a modular python issue *pokes Odalrick*

I love debugging python. It tells you right away where the problem is:

Error message:
Code:
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "<string>", line 52, in load_module
  File "CvEventInterface", line 10, in ?
  File "<string>", line 52, in load_module
  File "ModularEventManager", line 1791, in ?
  File "ModularEventManager", line 114, in init
  File "D:\games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall Further 051_modular_python\Assets\Modules\NormalModules\Druids/Python\druids.py", line 16
    else
       ^
SyntaxError: invalid syntax

It even points at the precise place you forgot a colon, ":".

Then a few lines later (line 22) some indentation problem. Do you have your tab size set to 2? Python uses tab size 8.

Just avoid mixing tabs and space and it can't be a problem.

Good luck with the xml.
(Glad it's not my xml.)
 
Why would exposing a dll function to python not work?

What I did was: adding the .def line in CyCityInterface1.cpp; adding the function in CyCity.cpp and .h; compile. The function seems to be exposed since it doesn't give error when using an int but does when not, which is intended. However, it doesn't seem to have any effect.

It's the CvCity::setOriginalOwner() function.
 
setOriginalOwner() would be relatively useless. You must pass in a value for such a field to work at all. But maybe you just posted it that way and it is actually taking a value in. Seeing you [code][/code] your CyCity.cpp portion would be nice.

Kirby, I'll try to look at your XML tomorrow/tonight, no time today at all.
 
CyCity.cpp
Code:
void CyCity::setOriginalOwner(int /*PlayerTypes*/ eNewValue)
{
    if (m_pCity)
        m_pCity->setOriginalOwner((PlayerTypes) eNewValue);
}
CyCity.h
Code:
    void setOriginalOwner(int /*PlayerTypes*/ eNewValue);
CyCityInterface1.cpp
Code:
        .def("setOriginalOwner", &CyCity::setOriginalOwner, "void (int PlayerTypes eIndex)")
 
Oh, wrong function, didn't check the code itself previously.

Original Owner is for buildings with OriginalOwner Commerces (no matter who owns it, the commerce goes to builder, used on some wonders in BtS)

You want to expose CvCity::setCivilizationType(int iNewValue)

Note the INT is a CivilizationType, not a playertype. Thus could even be set to a Civ not in the current game. Use pCity.setCivilizationType(pPlayer.getCivilizationType())

You may also consider a <bNonAssimilation> tag in CivInfos which replaces the check for Barbarian Orcs as prior owner in CvPlayer::acquireCity. Settling near the Infernals doesn't seem proper justification for training little Demonlings.

You might also want to make CvCity::setCivilizationType cycle over all buildings in the city and replace them with appropriate Civ specific buildings, since exposure of this field means people will be inclined to allow the Civ type to change at points other than city acquisition. Thus you could wind up having a normal Building, converting to a new Civ type, then ALSO building their Unique variant (or just being unable to gain their unique, not sure on that one. Either way, not what you want)
 
Ill take a look at that. Anyway, it seems it has already been exposed by Kael.
 
Not sure if this is related to something else I've done in my mod-mod, but the XML for summon multiple seems to be broken. When I tried using it for Meteor Swarm, it would say "Summons +3 Meteors" in the description, but after casting only one meteor would appear. I ended up having to switch to Python for that spell. I don't know if possibly it is broken specifically in relation to SPECIALUNIT_SPELL type units. I am using the same Meteor unit that is used for the Breathe Fire spell.

UPDATE: Found the issue (or possibly a related one), and it seems it could be a potentially major one. When casting a delayed spell that summons a unit with a duration, the unit will sometimes be summoned before duration is checked and sometimes after. With the following Python:
Code:
def spellMeteorSwarm(pCaster):
	pPlayer = gc.getPlayer(pCaster.getOwner())
	iUnit = gc.getInfoTypeForString('UNIT_METEOR')
	newUnit = pPlayer.initUnit(iUnit, pCaster.getX(), pCaster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
	newUnit.setDuration(2)
	newUnit2 = pPlayer.initUnit(iUnit, pCaster.getX(), pCaster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
	newUnit2.setDuration(2)
	newUnit3 = pPlayer.initUnit(iUnit, pCaster.getX(), pCaster.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
	newUnit3.setDuration(2)
on a spell with a 3 turn delay, the resulting Meteors will ~sometimes~ have 2 turns remaining, but will often show up with their duration already reduced to 1. Even more confusing is that it is not consistant with any given batch of meteors; I have had two show up with duration 2 and one show up with duration 1. Each time I cast the spell it is different.

If I remove the casting delay from the spell, it always summons meteors with a duration of 2, as you would expect it to.

I can't be positive, but seeing as the duration comes up differently different times, this seems like something that could cause OoS errors?
 
It has to do with Unit ID numbers. When a unit is summoned it is actually set to Duration of 1 more than you expect, because it immediately launched ::doTurn, to process various bonus effects for it.

Delayed Spells however, are not cast mid-turn, they are cast during ::doTurn, which is done for all units you own in order of ID numbers. Should you gain a new unit DURING another unit's ::doTurn, then the question is: How do the ID numbers compare? If the new unit should do ::doTurn BEFORE the summoner, then it will not process this turn (so only loses duration once), if it should run ::doTurn AFTER the summoner, then it will process ::doTurn twice (once for being summoned, and again for the start of the turn), and thus instantly die off

Not an OOS issue, just an unintended side-effect of having spells launch during ::doTurn, but I am curious how the affects the AI, as I was pretty sure they took their turns DURING ::doTurn. I'll have to check though, because if that was the case then the AI would never have been capable of processing any summon unit moves, but we know they have used them (I assume they have at least...), so I must be wrong. I haven't looked in detail at how all that works for the AI before since it wasn't an issue to my knowledge previously.
 
So is there any way to have a delayed summoning spell that is guaranteed to create a unit of duration 1?

Also, a question with modules, since I am switching my mod over to modular format. How do you ~remove~ a free promotion from a unit? Do you have to use bForceOverwrite and rewrite the whole unit? I tried using <bFreePromotion>0</bFreePromotion> for the relevant promotion, but that did not seem to work.
 
Kid allowed us to p through the night for once, so I didn't wind up with the one-handed freetime I had hoped for to play with code. So still no chance to check it out. You could try using a type dependancy, but you'd have to look up how to use those in the WoCipedia.
 
Two things - First, a big thank you to whoever trimmed the building XML. That was a pleasant surprise.

Secondly, I've been been running into an odd phantom problem. I have a module that reduces building prereqs for three wonders and makes the Tower of Eyes apply Sentry to units moving through the city. It consists of only the following code:
Spoiler :
Code:
	<BuildingInfos>
		<BuildingInfo>		<!-- Eyes And Ears Network -->
			<BuildingClass>BUILDINGCLASS_EYES_AND_EARS_NETWORK</BuildingClass>
			<Type>BUILDING_EYES_AND_EARS_NETWORK</Type>
			<PrereqBuildingClasses>
				<PrereqBuildingClass>
					<BuildingClassType>BUILDINGCLASS_INN</BuildingClassType>
					<iNumBuildingNeeded>1</iNumBuildingNeeded>
				</PrereqBuildingClass>
			</PrereqBuildingClasses>
		</BuildingInfo>
		<BuildingInfo>		<!-- Great Library -->
			<BuildingClass>BUILDINGCLASS_GREAT_LIBRARY</BuildingClass>
			<Type>BUILDING_GREAT_LIBRARY</Type>
			<PrereqBuildingClasses>
				<PrereqBuildingClass>
					<BuildingClassType>BUILDINGCLASS_LIBRARY</BuildingClassType>
					<iNumBuildingNeeded>1</iNumBuildingNeeded>
				</PrereqBuildingClass>
			</PrereqBuildingClasses>
		</BuildingInfo>
		<BuildingInfo>		<!-- Theatre Of Dreams -->
			<BuildingClass>BUILDINGCLASS_THEATRE_OF_DREAMS</BuildingClass>
			<Type>BUILDING_THEATRE_OF_DREAMS</Type>
			<PrereqBuildingClasses>
				<PrereqBuildingClass>
					<BuildingClassType>BUILDINGCLASS_THEATRE</BuildingClassType>
					<iNumBuildingNeeded>1</iNumBuildingNeeded>
				</PrereqBuildingClass>
			</PrereqBuildingClasses>
		</BuildingInfo>
		<BuildingInfo>		<!-- Tower Of Eyes -->
			<BuildingClass>BUILDINGCLASS_TOWER_OF_EYES</BuildingClass>
			<Type>BUILDING_TOWER_OF_EYES</Type>
			<bApplyFreePromotionOnMove>1</bApplyFreePromotionOnMove>
		</BuildingInfo>
	</BuildingInfos>
It works fine by itself, but when I tried to load my Normal Units as Commanders module as well I ended up with Tower of Eyes giving +196611 commerce from all Sages, Merchants, Engineers, Great Prophets, Great Bards, and Great Sages.
Now, this by itself would be confusing enough, since Normal Units as Commanders doesn't touch BuildingInfos. But what's really strange is that, simply by moving the module folders in and out various times trying to narrow down the problem, it's stopped. The same two folders are there unchanged, but the issue has vanished. So can anyone tell me what I did wrong to cause that, and then what I did right to make it stop? Because I'm very confused. I've also previously had something similar happen to the Theatre of Dreams but with food and production instead of commerce.
 
Did you verify that the erroneous values were reproducible before trying to fix them? And were all other conditions maintained constant? Could be coincidence that it happened this time and actually be some other factors
 
Did you verify that the erroneous values were reproducible before trying to fix them? And were all other conditions maintained constant? Could be coincidence that it happened this time and actually be some other factors
Consistent would be the word I would use, rather than reproducible. If I don't touch anything, the problem has always stayed the same. If I move some mods out and put them back in, it usually stays the same, but not always. Different combinations of mods sometimes cause the problem to move to a different building, but always one or more of the buildings in the tweak mod will cause some specialists to provide huge amounts of something. Adding an empty folder to the NormalModules folder just made the problem go away entirely.

Also, on an unrelated note, buildings are missing a sample template showing what order all the XML tags should go in.
 
Aye, I've been moving away from the sample template in favor of teaching people how to read a schema lately. It is hard to hide "dummy" options of some XML files, and I relatively frequently forget to add a new field to the template in those which exist currently. I admit they are bloody useful to have around for testing in many cases, but if I don't keep it completely accurate, then it becomes more harm than aid.


Sounds like you can very reliably say that the modules have caused the issue in some manner. But I'll have to check what/how they can screw up nearly from the point of blind since the method of "curing" the primary symptom is such a phantom issue unfortunately. Ideally it is linked to some of the other issues reported already where some tags don't modular load properly.
 
It seems that Civ4CultureLevelInfos.xml is not modular. At least, I can't seem to make it modular. I want to create a series of modular gamespeed mods (faster great people, slower research, etc) but this seems to be the sticking point. Is there something special I need to do to add <SpeedThresholds> to this file modularly? Right now i need to include all the default gamespeeds as well or it gives me an xml error if I don't include the <Description> tag and/or the <iCityDefenseModifier> tag

I had no problems adding gamespeeds to Civ4GameSpeedInfo.

It works if I include those tags, but what happens if the main mod changes those...?
 
You need to mark each entry in the Schema with minOccurs="0" so that you can omit the entries. I didn't pre-mark these as I hadn't expected anyone to do them as modules. Curiously enough, the SpeedThresholds isn't listed as being allowed to be placed there in the Schema, but it doesn't throw any errors.
 
Back
Top Bottom