Modders Guide to FfH2

Yes, mana string and faith string are defined, and they've been exposed as well.
 
Made some other changes a bit ago. The map interface seems mostly fine, but won't display the gold, mana, or faith income, but the city interface is quite borked, and doesn't show at all.


Are the text strings part of the main interface file the only things that need to be changed, or are other adjustments needed as well?
 
Okay, I have another question about spells to change units. I have created a spell for a unit to change into another unit. That new unit has a spell to change back to the previous unit. It's the mechanism I am using for a Transformers-based mod so the units may transform.

Anyway the problem as follows: I notice the AI uses it, but in tests I give them one unit in the World Builder, but when it's their turn, there are multiple instances of the spell's audio effect (almost stuttering-like and louder because it is happening several times at once) and then the AI has multiple versions of that unit.

I have only only filled in the ConvertUnitType, Unit Prereq and the Booleans: HaveCasted and IgnoreHaveCasted (plus AllowAI) are 1.

I cannot replicate it as a player. It's just the AI. Any ideas on what could be causing this effect?
 
Are the text strings part of the main interface file the only things that need to be changed, or are other adjustments needed as well?

yes

maybe try it step by step. First try to just display a "hello Erebus" text. Once that works you can replace it with the string generated by the dll.
 
Okay, I have another question about spells to change units. I have created a spell for a unit to change into another unit. That new unit has a spell to change back to the previous unit. It's the mechanism I am using for a Transformers-based mod so the units may transform.

Anyway the problem as follows: I notice the AI uses it, but in tests I give them one unit in the World Builder, but when it's their turn, there are multiple instances of the spell's audio effect (almost stuttering-like and louder because it is happening several times at once) and then the AI has multiple versions of that unit.

I have only only filled in the ConvertUnitType, Unit Prereq and the Booleans: HaveCasted and IgnoreHaveCasted (plus AllowAI) are 1.

I cannot replicate it as a player. It's just the AI. Any ideas on what could be causing this effect?

Is the effect that the same spell goes off multiple times, that extra units are being summoned, or that the AI constantly switches between units?

If the third, you may want to turn off "ignorehascasted", since that allows a spell to be used even after another one had been.
 
I'm having some trouble with what should be a simple cut-and-paste job.

Basically, I'm taking the existing, working code that creates New Forests when Treants die, and copying it to another section so that New Forests are also created when a Treant summons expires.

Here's the original code found in postCombatTreant. This works exactly as it should.

Code:
def postCombatTreant(pCaster, pOpponent):
	pPlot = pCaster.plot()
	if pPlot.getFeatureType() == -1:
		if pPlot.canHaveFeature(gc.getInfoTypeForString('FEATURE_FOREST_NEW')):
			pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST_NEW'), 0)

And here's my code in onUnitLost. This isn't creating any New Forests, no matter what terrain the Treant is standing on.

Code:
def onUnitLost(self, argsList):
	'Unit Lost'
	unit = argsList[0]
	player = PyPlayer(unit.getOwner())
#	pPlot = unit.plot()
	iX = unit.getX()
	iY = unit.getY()
	pPlot = CyMap().plot(iX,iY)
	
	if unit.getUnitType() == gc.getInfoTypeForString('UNIT_TREANT'):
		CvUtil.pyPrint('Treant check')
		if pPlot.getFeatureType() == -1:
			CvUtil.pyPrint('feature check')
			if pPlot.canHaveFeature(gc.getInfoTypeForString('FEATURE_FOREST_NEW')):
				CvUtil.pyPrint('creating forest')
                                pPlot.setFeatureType(gc.getInfoTypeForString('FEATURE_FOREST_NEW'), 0)
		
		if (not self.__LOG_UNITLOST):
			return
		CvUtil.pyPrint('%s was lost by Player %d Civilization %s' 
			%(PyInfo.UnitInfo(unit.getUnitType()).getDescription(), player.getID(), player.getCivilizationName()))

I can tell from my debug text output that it's failing when it gets to the canHaveFeature check. But since this code is exactly the same as the other code, I'm guessing that pPlot isn't being set correctly?!? You can see that I've tried setting pPlot in two different ways, with the same results each time.

Here's what the debug output looks like.
Code:
PY:Treant check
PY:feature check
PY:Treant was lost by Player 0 Civilization Ljosalfar
PY:Treant check
PY:feature check
PY:Treant was lost by Player 0 Civilization Ljosalfar
PY:Treant check
PY:feature check

Any thoughts or suggestions?
 
you can put a breakpoint into CvPlot::canHaveFeature and see why it returns false in this case with a debug DLL
 
I'm guessing that pPlot isn't being set correctly?!?

After taking a break and then digging around in the code some more, I discovered that the UnitLost python function isn't being called until near the end of the kill() function in the DLL, after their XY coordinates were invalidated! So I moved the call to UnitLost farther up and that took care of the problem.
 
I would like to have crimerate in my mod and would like to know all the xml python and sdk related to it so i can put it in my mod.
 
Spell question: How do different modders put in spells that can be targetted on a particular square? (I'll probably look in some of the SDK's for possible methods, but an explanation here would be helpful.)

Also, is there any way to change the size of the main interface panel for units? (The bottom left area with movement, strength, level, and experience). I've added another stat here, but the resulting scroll bar when all four stats are on screen covers some of the numbers.
 
Although I posted the same issue in the "Mulcarn reborn"-thread (from the ffh2 scenarios), I thought it would be more appropriate to post it here in the modding-section.

I really liked the mechanic of switching to the weakest (or second weakest if you are last) teammember every 40 turns. Can anyone tell me how to implement this in other scenarios (or regular custom games)? Has it something to do with python or XML?
Is this a modified version of the game-option "high to low"?
Thanks in advance for your answers! :)

Edit: I found a solution, not a very elegant one but at the moment it seems to work. :-)
I startet a custom game (4 vs 4), saved it under the Worldbuilder and renamed it in "Mulcarn reborn". Then I copied it in the Scenario folder were the original "Mulcarn Reborn"-Scenario was replaced with my new one.
Then I edited the "ScenarioFunctions"-python file (I simply deleted the part were Decius would spawn at turn 5 and also removed the part from "def gameStart(self)" were Amelanchier and Volanna are in them). The the other parts of this file I left untouched. For editing I used Notepad++ (someone here in the forum gave me the tip which program to use)

After that I edited also my new "Mulcarn Reborn" Scenario and added the lines:

Option=GAMEOPTION_WB_MULCARN_REBORN
Description=TXT_KEY_WB_MULCARN_REBORN_DESC
ModPath=Mods\Fall from Heaven 2

Also I changed the line were the 4 civs of the enemy team are unplayable:
from "PlayableCiv=1" to "PlayableCiv=0"

I don't even know if my changes make sense (sometimes programming seems like voodoo to me :crazyeye: ), but I tried it out and the first Civ-switch worked fine so far. :banana:
 
Hi. I would like to incorporate the <ihealrate> .xml tag of improments into my mods. FFH2 seems like a very big mod so I am not sure if it is in the .sdk/python, etc. Do you know what code I would need to incorporate it? I do know the .xml schema of my mod would have to change.
 
Hi. I would like to incorporate the <ihealrate> .xml tag of improments into my mods. FFH2 seems like a very big mod so I am not sure if it is in the .sdk/python, etc. Do you know what code I would need to incorporate it? I do know the .xml schema of my mod would have to change.

All XML tags need to be accounted for the the SDK. In addition to all the code for that, you'll need to adjust the healRate() function in unit.cpp to make the effect actually work.
 
Thanks for the tip.

Code:
pCity = pPlot->getPlotCity();

	iTotalHeal = 0;

	if (pPlot->isCity(true, getTeam()))
	{
		iTotalHeal += GC.getDefineINT("CITY_HEAL_RATE") + (GET_TEAM(getTeam()).isFriendlyTerritory(pPlot->getTeam()) ? getExtraFriendlyHeal() : getExtraNeutralHeal());
		if (pCity && !pCity->isOccupation())
		{
			iTotalHeal += pCity->getHealRate();
		}
	}

I'm pretty sure that's the sdk code you are talking about. I gues I'd have to change isCity to eImprovmenttype(somehow add it to define the imrpvoment I want, which is a field hospital) and remove city heal rate?
 
I'm pretty sure that's the sdk code you are talking about. I gues I'd have to change isCity to eImprovmenttype(somehow add it to define the imrpvoment I want, which is a field hospital) and remove city heal rate?

That is the function, but the wrong section of it. If you look at the FFH code, the part you want is at the end of the ::healRate() function.

Code:
//FfH: Added by Kael 10/29/2007
    if (pPlot->getImprovementType() != NO_IMPROVEMENT)
    {
        iTotalHeal += GC.getImprovementInfo((ImprovementTypes)pPlot->getImprovementType()).getHealRateChange();
    }
    if (iTotalHeal < 0)
    {
        iTotalHeal = 0;
    }
//FfH: End Add

Since we're talking about improvements healing units, you dont want to change the section dealing with healing inside of cities.
 
Sounds about right.

To get it to compile I also had to add int getIHealRateChange() const; underneath CvImprovementInfo in CvInfos.h. I believe that is the answer, but then I get this error.

1>CvUnit.obj : error LNK2019: unresolved external symbol "public: int __thiscall CvImprovementInfo::getHealRateChange(void)const " (?getHealRateChange@CvImprovementInfo@@QBEHXZ) referenced in function "public: int __thiscall CvUnit::healRate(class CvPlot const *)const " (?healRate@CvUnit@@QBEHPBVCvPlot@@@Z)
 
Back
Top Bottom