Tweak Mod for Xtended + Master of Mana Updates

First, and I would like to share it for other to comment, on my PC I got a CTD and tracing back was due to a null pointer in updateGroupCycle after pLoopSelectionGroup = getSelectionGroup(pSelectionGroupNode->m_data); as pLoopSelectionGroup resulted in null. Adding thousand of logs I traced back in CvPlayerAI inside AI_doEnemyUnitData. I report here below the relevant correction but according to my poor c knowledge m_aiUnitCombatWeights[iI] will result in random memory area beeing modified...
ah, the good old logging. It's great that you found the error. I hope that I did not make another one.

I played around 400 turns with 0.2 last year and got zero OOS which is pretty awesome. Can't remember the last time I had that with modified civ4. Encountered no bugs, only the resource spawn chance was too high. Haven't tried out 0.3 yet.
I wonder if resource popping might not be scaled to game speed. Maybe the game engine never scaled it because the resource popping rate in the unmodded game is so low that you don't notice it much. I think the difference between Quick and Epic is a factor of 3 (although different parts of the game are scaled differently) and so it could be that I've effectively been seeing 3 times as many resource pops as you have been seeing.
The difference between quick and epic is about 2.2 (67 to 150 for most things). The base civ4 game does not scale resource chance but it was patched in the unoffical patch mod which is included in MoM.
I looked at the code and I found one bug from base MoM.


which should be





this ichance stuff is really errorprone because a higher iChance value means a lower chance to find a resource. The effective chance to find a resource is 1 in iChance which means iChance of 100 equals 1% and iChance of 200 equals 0.5%. So right now after you build 5 merchant districts you will only find half as many resources as before.

But the reason why so many resources are found are the values of iAdjacentFindResourceModify in ImprovementInfos. Currently is it scaled in a way that each point of iAdjacentFindResourceModify gives you 10% more chance to find a resource. Some higher tier tradepost improvement for example has an iAdjacentFindResourceModify value of 30, which means +300%. If you have three of them adjacent you get +900% which explains the resource spam.
Can anyone say exactly when the Sidar can Wane? I think you need 100 mana, and you need one or more units with high XP that are not garrisoned and that that have spent all their XP, but some other condition is required in addition to that, and I can't tell what. It seems random.
View attachment 681665
Mmm if I remember well last time I played them, the unit should have unspent XP left... And there should be a counter in main interface in the left side of the screen that shows to you if you have enough to use waning ability.
Can also confirm that the Improvements (mines, lumbermills, etc) spawn resources WAY too often. Cutting the rate by around 3/4 would be way more in line.

Also, the gold economy seems weird. I am on my first playthrough, bumbling my way around not knowing what half of the stuff does and I am over 10k gold saved with per-turn gain of 36.

Other than that, it is really fun. Didn't encountered any serious bugs or any problems. Thanks a lot for keeping such a fantastic mod alive and kicking!
Mmm if I remember well last time I played them, the unit should have unspent XP left... And there should be a counter in main interface in the left side of the screen that shows to you if you have enough to use waning ability.

Thank you, I see the counter "Exp for Shades X/Y" now. I'll need to experiment to understand exactly how it works.
Can someone explain how these resource counting buildings work? I've got access to crab, claim & fish. I have 7 copies of them. Why does my Harbor only give me 4.88 gold? I do have a -20% penalty from civics, but I should still have more than that. I added another claim resource and it didn't change that total. Does it just count resources in the city limits? Just those being worked by the city?

You can get Adventurers even if you are not Grigori, primarily by exploring dungeon, barbarian forts and unique features, so the event is correct.
For the spell research from unimproved forests maybe you have to work on the unimproved forest with a citizen of the city, don't know, i don't play often with the svartalfar.
And lastly the resource count of the buildings it's strange, you should have way more golds from them, maybe SpyFanatic or another developer should see in the code if something is wrong.
Try send a save game with this error so they can look in to it!
Did some statistics on resource spawn. I cannot reproduce the situation reported in the different screenshots as using AI Autoplay it seems that AI is not quite capable to optimize the improvement in the same way.
Anyhow, I would like to have some feedback from the active users of this forum before adapting the code for a future 0.4 and for this purpose I have uploaded a dll with the following changes:
  1. Resulting spawning chance has been divided by 2 so reducing spawn rate to 50% (after all modifications are applied)
  2. iAdjacentFindResourceModify has been reduced as well according to the table reported below (numbers are slightly different now compared to base MoM Extended). If it is fine I will then apply the modification in the XML files (it is much easier to make this evaluation by proposing a dll).
  3. ResourceSpawnLand.log and ResourceSpawnWater.log (in case logging is enabled) are reporting some statistics about spawning resources.
Comparing the resulting spawning resource using a MoM_Lakes_Climate, Human size, Epic speed, 400 turns AI autoplay I can see a reduction from 100 land resources + 21 water resources to 42 + 11. Which is somehow the expected 50% less, but as noted I am not sure AI is optimizing Cottages and Trade post.

DLL is available here: CvGameCoreDLL.dll

Sample base chance
Current Modifier
% at Epic (on 100000)
Proposed Modifier% at Epic (on 100000)Increase
I'm playing the Jotnar for the first time. The pedia says that their cities are only able to work the first ring around them and population is capped at 8. That isn't the case in my game, all my cities are getting the Jotnar Staedding building which lets them work 3 full rings (plus gives other benefits).
I'm playing the Jotnar for the first time. The pedia says that their cities are only able to work the first ring around them and population is capped at 8. That isn't the case in my game, all my cities are getting the Jotnar Staedding building which lets them work 3 full rings (plus gives other benefits).
Yes civilopedia entries are a little bit outdated to the first implementation.
Jotnar cities cost less maintenance, no population cap and ring of 3, but requires more food for each citizien (i think 5 instead of 3)
Ok. Maybe update the 'pedia (or at least remove the old info) on the next update?

Another Jotnar question. I see their epic destiny victory requires 10 Legendary Giants. What is a legendary giant and how do I get one?

Edit: never mind, I figured it out
Last edited:
One question for Sephi, maybe you know. I am now looking into the different Assert spawning with the debug dll, trying to understand if there are errors anywhere.
Stumble across an assert related to health not be correctly managed, and I have noticed some strange code around Bonuses marked with isModifierPerBonus (done by Kael, are related to Mana with the correspondent text 'Benefits of this resource are cumulative').
My understanding is that the intention is to apply several times the bonus for each instance of the Mana, but mainly are intended for the spell research and mutated chance for Chaos Mana.
To apply a cumulative bonus for health,happiness etc.. seems a little bit OP (sacred woods granting +3H for each Nature mana seems really too much...) and in fact the code does not really do that... it simply screw up some internal computation and is visible like this:


So Sweet Air gives +1H for having 1+ Air Mana, but on the right you can see that the computation is done to give +2H (one for each Air Mana) even if this is not correctly managed, resulting in assert.
My idea is to tune isModifierPerBonus to be valid only for spell research and mutated choice, to remove this discrepancy, but I am really wondering what the original intention were....
Yes, that is correct. Sweet air should only give +1H for access to Air Mana, not multiple health. I guess the help text logic in city screen was not updated to deal with mana granting a bonus to enchantments / buildings, it should be (2) +1 instead of (2) + 2.
Thanks! This has been corrected in CvMainInterface (see isModifierPerBonus)
Another issue is that in order to accomplish that, processBonus is called once per resource, which is not correct as it will do other stuff other than increase spell research. Corrected as well.
Hey hey, dear all!

I would like to inform that under 0.3 version that I love, I have stumbled upon the following weird stuff:

1) I played as a small one city empire, and in the diplomacy everyone accepted to give me their resources for free, even didn't ask for some money, all the copies, until over. Fish, copper, whatever. Weird, has it gone broken? Or they loved me too much? That even happened with the Calabim nation who are not so caring and loving ones...

2) As well, I have been able to conduct trade before unlocking trade...

3) Have seen somewhere a promo "Mithril guard" with no access to Mithril. By the way, the first time ever that I have seen a Mithril resource, was a MoM map generator.

4) By the way, do other than MoM generators place those interesting features, like mushroom forests, lands of perdition, Mithril and what not? By the way, haven't seen so many explorable dungeons as before. Are these real rare now?

5) Could you please think of some mechanics that might make the process of resource copies hoarding, more interesting?

6) The Raging Wilderness is such a hardcore option... Always being visited by a constant peregrination of monsters of all kind. Could we please consider to split apart the Raging Barbarians and Raging Fauna please? I would like to have an option to have more animal meetings and less barbs... I can't imagine that some Necromancer "lair" with no empire might keep constantly printing out more units than my not-so-small city. I stopped using the Raging Wilderness option... And it is still hardcore on Prince. Actually I love that, but in the times of MoM you could travel the map with your stack, now I can only afford sitting in my first and hopefully, second city, and to repel constant visits of barbs of all kind. As well, I notice that I see less spiders in the woods than before.
I've played two games to turn ~100 with the new DLL and so far resource spawning looks good. Thank you for the work.

Since dungeons were mentioned, here is some map feedback:

* There don't seem to be nearly enough dungeons for the Grigori to explore 20 for their destiny victory. I tried once with an early invisible recon unit (IIRC on mom_lakes_climate, Dwarf, Normal speed, Deity) and only found two. Maybe change it to... 10? You would still have to pick map settings to make it possible, but I think that's OK. For comparison, on many map the Lanun can't find enough enemy ships for their victory condition, either. I think that's OK as long as you can find some map settings that work. For some civs you can use map settings to adjust the difficulty of their destiny condition; I think that's good.

* The _climate scripts start the Balseraphs on plains, which is a bit unfortunate because their favorite improvement is cottages.

* The Illians have a unique economic challenge on _climate scripts because it's hard to get wood (little or no forest on ice biomes) and very hard to get herbs (none from the palace; no calendar resources in ice biomes; grassland tiles get changed to ice quickly even without a Temple of the Hand; and they can't unlock Herbalism because they're evil.) I have come to appreciate the challenge as an interesting peculiarity, but it is an imbalance. Maybe you could allow trading posts on ice - that would fix it at least for human players, and maybe AIs too if they understand that they should build trading posts in response to their need for resources.

* The Amurites seemed to get choked pretty badly by the jungle starts that they usually get.

* In posts about resource spawning there was a bit of discussion about water tiles. My two cents is that I think water tiles are fine, without needing additional resource spawning. A seafood resource or two is plenty of motivation for me to settle a city on the coast, and naval or trade access can be a motivator too. That's playing on mom_lakes_climate with high sea level. And water tiles are much weaker than land, of course, but they're great with investment in water spell research.

* in an older version it was possible to use Regenerate Map with the _climate scripts, but not the current version. I miss that, myself, because I like to reroll starts. And the leader selection dropdown has always felt a bit hard to use in FFH (I'm not sure how to make it better), so I notice it when I use it over and over again rerolling starts.
Last edited:
Hi Jet
Thanks for the feedback, i will wait a little for other active user of the forum in order to have it in 0.4. In the meantime I think that the standalone dll can be used.
On water bonus resources, I think is mostly dependents on map used. We normally play MoM_Erebus and it is really annoying to found on coast as normally it is never fresh water, there is no river, and food is scarce (except exceptional cases of course). I hope that the current dll offers a good tradeoff between your play experience and ours (nb: spawn chance has been halved also for water resources).

On your consideration about _climate maps: yes I agree and this is the reason why we do not play climate... some civs are really placed in horrible spots, where everyone struggles... Can you try t change to the 'nonclimate' version? I never deal with map script, so I am not sure how I can really modify those, but for us solution was to use the nonclimate...

On Regenerate Map, I do not know... But checking the code it seems it is not visible if:
  1. If it is not turn 0
  2. You have met some other civ
  3. the Game or any plot on the map as some 'ScriptData' which I still do not know what they are but seems used by a mod (e.g. the blizzard features on a plot)
PS: do you mean before 0.3 or with this 'debug' dll for Resource spawning?
Thanks for the feedback, i will wait a little for other active user of the forum in order to have it in 0.4. In the meantime I think that the standalone dll can be used.
How long until you reckon 0.4 comes along mate? I've been keeping an eye out for it so I can share it across the CivFanatics news and socials. :)
Already gave you guys in this section a mini plug the other day but want to do something more specific to the great work you guys are doing in the future.
Top Bottom