editing the XML for the Haste spell to make it not such a micro nightmare.. how?

Cuteunit

Danse Macabre
Joined
Sep 5, 2007
Messages
618
Heyho. I'd like to make the Body 1 spell Haste last as long on the stack it is in as the Adept stays with the stack, rather than being a cast per turn micro nightmare.

Over fiddling with the xmls and whatnot and learning the hard way, I thought I would ask here so as to benefit from the experience of others like a smart person would do.

Anybody have proper datas on what to do to accomplish what I ask?
 
I'm not sure if there is a particularly elegant way of doing what you ask. I don't think there is a way to make the promotions disappear as soon as the caster leaves the tile, but it is possible to check once per turn if a valid caster (it wouldn't distinguish between the unit that actually casted the spell and one that is merely capable of doing so) is in the same tile, and to remove the promotion otherwise.

The one way I know of doing this is to set a python function in the <PyPerTurn> tag in the CIV4PromoitonInfos.xml file. Judging by the Crown of Brilliance promotion (which I think is the only promotion to use this tag at the moment, at least in the main mod. I just added a function to Vampire, but since its only has a small random chance of doing anything, I haven't actually seen it it it working yet), this define should be located in the same file as spell requirements/effects, i.e., C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2 030\Assets\python\entrypoints\CvSpellInterface.py. I would recommend a function like this :
Code:
def effectValidHaste(caster):
	pPlot = caster.plot()
	iPlayer = caster.getOwner()
	pPlayer = gc.getPlayer(iPlayer)
	hasteValid = False
	for i in range(pPlot.getNumUnits()):
		pUnit = pPlot.getUnit(i)
			if pUnit.getOwner() == caster.getOwner():
				if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_BODY1')) and pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_CHANNELING11')):
					hasteValid = true
					break  ###this break statement really isn't necessary, but I think it will save computing time by not requiring the computer to check every unit in the stack once it has found one that can caste haste
	if not hasteValid:
		caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HASTED1'), False)

You would also need to change the <iExpireChance> from 100 to 0, and of course to write effectValidHaste(pCaster) in the <PyPerTurn> tag of the CIV4PromotionInfos.xml file.


Since I took the time to come up with this code, I think I'll go ahead and include it in my little modmod. Since it is a little annoying that it doesn't work on siege and undead units, I think I'll remove the <bImmuneNotAlive>1 to a 0 in the CIV4SpellInfos.xml file as well.
 
Quick comment while you are online and talking about your modmod MC:

When you do get around to posting it, Could you include a tip for people on how to create a duplicate version of FfH to be newly modded? Pretty simple, but then again, that might only be for people who know computers.

If they just make a folder parallel to FfH2 030 called MC Mod, copy everything from FfH2 030 into that folder, then you design your modmod to install there instead of into the basic FfH folder we can probably dodge a couple dozen questions about how to revert back to default FfH, or to upgrade to the newest version FfH when it comes out.

That is, unless you figured out how to make it work properly with modular loading, which I guess you might have easily done :p
 
modular loading wont work with python, just xml.. I thought

I'll wait for the MC Modmod then.. MC seems to have his finger on the beating pulse of cuteunit's desires.
 
Unfortunately, there are problems with having multiple version of the mod under different names; you get the ""GFC error: failed to initialaize the primary control theme" error loading the mod. You will recieve this error if FfH isn't installed in the correct location (under Program Files\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods). If you don't have Civ4 installed to that location just make sure the FfH is installed in the same directory as Final Frontier, Age of Ice and the other mods that came with BtS." if you are trying to load the mod under a different name or in a different location. Therefore, you cannot have multiple versions/modmods of the same version of FfH on the computer at the same time and be able to play both of them. You can create a backup under a different name, but you will have to change the name back to the default one (and change the mommod's name to something else) in order to actually play it. I find this very annoying, but I know no way around it. you must also change the names before installing any patches, because they would overwrite everything. The modmod would have to updated to each new patch separately (I'd have to go through every file with a compare tool, probably copying the stuff from the existing mod into the patched main mod since I'd have a better idea of what I've changed than what Kael changed.)

It has been this way since FfH went to BtS (and possibly since .23, I don't know since I didn't have internet fast enough to download anything over the summer., an so went from .22 to .24. I have a suspicion that the media pack has something to do with the problem.)


Since I don't know much about installers, I'll probably just post a zip (I don't really know how to zip files yet either, but I figure I can learn) of the needed xml/python files in their folders so that you can move my mod's assets folder into the main mod folder and have it overwrite the appropriate files (the way the art team released their fantasy terrains for testing before they were included in the main mod). I'd recommend that users first make a backup copy of the original mod in a different location so they can switch back and forth between them. Actually, so save time and space, it would probably be better to backup only the Python/xml files/folders rather than the whole mod.

Also, I know absolutely nothing about modular loading, except that the way it is implemented in BtS is only for xml (my most important changes are in python). Actually, Firaxis was planning to have modular python instead of Modular xml (having both is supposedly way to complicated), but Kael convinced them that modular xml would be more useful to more modders (they thought it would be to complicated to implement, then some modder practically did it for them). Everything I know about either xml or Python I've taught myself since about this time last year. (Well, I did have a class last semester that used visual python, but I don't think I learned anything I hadn't already figured out in that class. Last year I also had a class in MatLab, which isn't too different from python, and in high school I did take a course in Java)
 
There are lots of easy install creators. I use one myself for making modmods of Next War and stuff for my friends.

It's Advanced Installer 5.2.2 and it's really about as easy as making a zip file, but lets you make self installing .msi ( windows installer)
 
I was just about to upload my mod mod, then I noticed a big problem with the code I'd proposed here earlier. Actually, I have no idea where the problem is, but it seems to be linked to the caster.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HASTED1'), False) line. Whenever the promotion should be removed, it instead causes the unit to gain large negative strength of every type.

I also noticed a similar problem in a portion of code I added to the CvEventManager.py file which isn't working. I don't remember whether it was 1. where I was trying to cause living units that die on a certain terrain improvement ("Accursed Ground", a new improvement created by my new Death III Sorcery spell) to rise again as barbarian Skeletons with the strength and most of the promotions of dead unit. (I used the same .setHasPromotion... line to make sure the Skeletons didn't get courage, valor, channeling 1-3, sorcery, summoning, divine, blessed, etc., from their earlier promotions.) Or 2. Where I tried to make goblins once again turn to wolf riders when they kill a wolfs.

I got this error from the PyPerTurn effect I added to the vampire promotion (I set it up so that, when not in their own territory, vampires randomly get a very negative promotion, Famished, which reduces their strength, make them less effective casters, makes them more vulnerable to magic, gives them negative healing, and a small chance of turning barbarian. If the vampire is on on the same tile as a bloodpet, the bloodpet gets injured instead of letting its vampire master become famished. Famished is removed by feed or feast, which can also grant a temporary "Satiated" promotion, whose effect is the opposite of Famished). I was thinking it could be caused by using the "Break" command (effectValidHaste and effectVampirism are the only 2 places I've ever used "break"), but now I'm thinking it is because I called a variable that I'd only defined within an if statement; if there wasn't a bloodpet on the same tile as the vampire, then the code called a variable that didn't exist.

I also remember that whenever I've run into negative strength before, the game works fine until the unit engages in combat. When a negative strength unit tries to fight, the game freezes and not even Ctrl-Alt-Del can stop it; it requires restarting the computer. (Negative movement makes game freezes up like that if you accidentally try to move the unit. Edit: the Skeleton's movement went negative the next turn)

I'll try to see if I can remedy the situation, but I thought I'd try to explain the delay first, and to see if anyone knows an easy solution to the problem.
 
Hrm... I'm not sure about the problems with renaming the directory. That is what I have been doing in order to set up Sevopedia to work with FfH. I made a new folder (FfH Sevo) and copied everything in FfH2 030 into that folder (except the editor since I don't use that). Changed the shortcut to launch my new folder name, and changed the name of the .ini to match the new folder name as well. I can run from that just fine (media pack is installed, but settings are turned way down, so I don't think I see any of it anyway). It says on the loading screen my folder name instead of the other, and when the game is up on the first menu, new folder name is in the upper corner instead of FfH...

Maybe it is tied to renaming the .ini? Or possibly to another change you made in the course of your mod... but just changing the name of the folder FfH is in (and the ini to match) still does allow you to run the game.
 
hmmm....It seems that you are right.

I know I had problems with renaming the directory in .24 and .25, so I guess I just assumed that this problem carried over to Shadow. The good News is, it seems like it did not!

I was pretty sure that I at least vaguely remembered having this problem at least once in .30, but that would have been before I lost everything on my hard drive and reinstalled everything. This time I did install the media pack (and like you have the settings turned down far that it really doesn't matter), whereas I never had before. Perhaps the error only happens when the Media pack is not installed?

Edit: any advice on those errors that cause massive negative strength/movement? I really don't want to release a modmod with such major errors, although I think that it is otherwise ready. Hmm, I just remembered that the "roar" spell used to cause this kind of problem, whereas every other time I've seen such an error it was after I'd made significant changes. I wonder If I can find how Kael fixed it that time.
 
I came up with a way to get an Auto-Haste spell working with just the XML. Basically it consists of an Auto-Haste promotion and two spells which add and remove it. The promotion simply runs "pCaster.cast([Haste])" each turn and is removed when the unit enters combat or when "Cancel Auto-Haste" is used.

It works fairly well (even has the little "Haste" text appear in the log each turn), but my biggest problem is that the caster can still use other spells while the auto-haste function is still going, leading to an exploit. I tried adding another line of Python code to my Auto-Haste promotion but the engine didn't like it (gave me "Invalid Syntax" for using a ';' to separate them), and since I can't find any other way to force the unit to stop casting (without tweaking the scripts, which I'd rather avoid for the sake of modularity), I'll have to leave it buggy for now.

Ideally, I'd like there to be a bHasCasted value for promotions that stop the unit from casting most spells (like good ol' "silence", for you RPG fans). Then you could just set it to 1 on the Auto-Haste promotion and you've got it. This could be expanded on to give more functionality to the AI or to automated units, as well (much easier than adding more mission types to the SDK).
 
Wish I could help you do exactly what you want, but the most reliable and least time-intensive way I've found to manage haste is to simply keep a unit on the tile who can skip turn each turn. It can get quite tiresome, but at least it's only a click or two per stack of workers (for they are the most irritating part of using haste in my experience...). Otherwise, use the nifty active path that shows up after casting haste on a stack, and move them all precisely one turn away. It takes more effort, but that extra micromanagement can actually save your butt if you're automoving someplace that suddenly becomes detrimental to your survival. Anyhow, best of luck with your endeavors, and I'm waiting for Ice to see how many of these little things can be straightened out. Have fun.
 
Wouldn't this be similar to the spells like city-wall, inspiration etc? Any caster that can cast the spell, if it ends the turn in a city, will keep the affect. Of course this is a building rather than a promotion...
 
Aye, similar, but since outside of a city now, more complicated. Plus you want an elegant solution since you could on a huge map potentially have 100's of units with Haste checks to perform, each one means a slightly longer delay inbetween turns.
 
I just thought I'd mention that after working on it for far too long last night (almost until sunrise), I fixed the bug in effectValidHaste(caster) and effectVampirism(caster), and posted my modmod. It turns out the problem was just a couple of typoes in the names of the promotions.

I also decided that lasting forever on units that ca cast it it too much, so I added a 5% chance of expiring.
 
Back
Top Bottom