Mod-Modders Guide to Fall Further

Does getSorenRandNum(100, "whatever") generate an integer between 0-99, between 1-100 or between 0-100?

Contextually, I've set an effect to trigger only when the integer is superior to 99, but if 99 is actually the maximum... :p
 
I KNEW it! This promotion would have been very rare :lol:

Thanks for the quick answer :goodjob:
 
Are there other hidden factors at work with magic resistance?

Vehem said the base is 20%, but so far, it seems to be much higher. In a few seperate tests, I'm seeing 2/7 successes, or 3/13, on a spell with no resistance modifier. Which surely means it should be working 80% of the time?

The targets in question are just warriors standing around. Some on hills, some on flatlands. Does terrain affect magic damage and resistance rates?

From what I'm seeing, magic resist rates seem to be significantly higher than 20%.
 
Are there other hidden factors at work with magic resistance?

Vehem said the base is 20%, but so far, it seems to be much higher. In a few seperate tests, I'm seeing 2/7 successes, or 3/13, on a spell with no resistance modifier. Which surely means it should be working 80% of the time?

The targets in question are just warriors standing around. Some on hills, some on flatlands. Does terrain affect magic damage and resistance rates?

From what I'm seeing, magic resist rates seem to be significantly higher than 20%.

Is a "success" a successful cast or a successful resist? Of it's resist, the numbers look right. Otherwise it should just be down to the target unit level and any promotions they had - terrain shouldn't be a factor...

If you've given those warriors to Cernunnos for testing purposes - they're probably Magic resistant (he has that trait).
 
Is a "success" a successful cast or a successful resist? Of it's resist, the numbers look right. Otherwise it should just be down to the target unit level and any promotions they had - terrain shouldn't be a factor...

If you've given those warriors to Cernunnos for testing purposes - they're probably Magic resistant (he has that trait).

By success, I mean the spell is not resisted. So a sucessful cast.

Why does Cernunnos have magic resistance?
 
I want to add the possibility of building a pasture only on flat grassland for one civilization. Here's the code I did in canBuild (callback activated):
Code:
# ngomele start
		iBuildFarm = gc.getInfoTypeForString('BUILD_FARM')
		iBuildQuarry = gc.getInfoTypeForString('BUILD_QUARRY')
		iBuildForester = gc.getInfoTypeForString('BUILD_FOREST_PRESERVE')
		iBuildPasture = gc.getInfoTypeForString('BUILD_PASTURE')
		
		iWheat = gc.getInfoTypeForString('BONUS_WHEAT')
		iCorn = gc.getInfoTypeForString('BONUS_CORN')
		iRice = gc.getInfoTypeForString('BONUS_RICE')
		iFlax = gc.getInfoTypeForString('BONUS_FLAX')
		
		iMarble = gc.getInfoTypeForString('BONUS_MARBLE')
		iSheutStone = gc.getInfoTypeForString('BONUS_SHEUT_STONE')
		
		iDuskwood = gc.getInfoTypeForString('BONUS_DUSKWOOD')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_NGOMELE'):
			pPlot = CyMap().plot(iX, iY)
			if pPlot.getOwner() == iPlayer:
				if pPlot.isCity() == False:
					if (iBuild == iBuildFarm):
						if pPlot.getBonusType(-1) == iWheat:
							return 1
						if pPlot.getBonusType(-1) == iCorn:
							return 1
						if pPlot.getBonusType(-1) == iRice:
							return 1
						if pPlot.getBonusType(-1) == iFlax:
							return 1
						else:
							return 0
					if (iBuild == iBuildQuarry):
						if pPlot.getBonusType(-1) == iMarble:
							return 1
						if pPlot.getBonusType(-1) == iSheutStone:
							return 1
						else:
							return 0
					if (iBuild == iBuildForester):
						if pPlot.getBonusType(-1) == iDuskwood:
							return 1
						else:
							return 0
					if (iBuild == iBuildPasture):
						if not pPlot.isHills():
							if pPlot.getTerrainType() == gc.getInfoTypeForString('TERRAIN_GRASS'):
								if pPlot.getImprovementType() != iBuildPasture:
									return 1
						return 0
However, it is still buildable on top of pasture and can be build on top of Unique Features, removing them.

By the way, would there be any way to adjust the yields when an improvement is built? The Ngomele have +1:food: for pasture (defined in the XML) but I would like this bonus to drop to +0 when there is no resource in the pasture's plot. How should I do?
 
Looks like you want them to only be able to build anything on appropriate resources. You could return a negative value if there is a resource at all, which should leave the DLL to decide if it is allowed or not. Simplifies some of your checks if that works.

Adjusting yields can be done the same way that Muris Goblins work, main question is how to undo them when pillaged or owner changes I suppose.


For your pasture issue: Add some print statements so you can be certain it is ever checking your function at all. The check of improvement type against Pasute BUILD ORDER is not a good idea though, Improvement != Build Order. Very different XML files, so very different enumerations.
 
Looks like you want them to only be able to build anything on appropriate resources. You could return a negative value if there is a resource at all, which should leave the DLL to decide if it is allowed or not. Simplifies some of your checks if that works.
Thanks for the tip :)

For your pasture issue: Add some print statements so you can be certain it is ever checking your function at all. The check of improvement type against Pasute BUILD ORDER is not a good idea though, Improvement != Build Order. Very different XML files, so very different enumerations.
Well, I'm stupid :lol: Thanks!

Another question: is it possible to make two different units count to the limit of a unit class? Like, say, Lich counting for the Archmage cap (this isn't this at all though).
 
You would need DLL work, or some invisible Fort Commander style units which don't do anything except count as part of the same unitclass who spawn automatically to "Double book" each of the units under the other's class. If you don't want them both to be buildable, then you could just assign them to the same unitclass and ensure that only one (or none) are actually buildable, and the others are gained via spell or python.

If using the DLL, I would just create a new tag which allows you to link a unit to multiple unitclasses, or create a new UnitCategory system which all units can belong to and limit by that instead of Class.
 
Be careful with CanBuild - it get's a *lot* of calls during the game (millions) - need to keep the Python as tight as you can...
Could it slow the game? I've some issues right now but nothing I can really understand. Once, I tried some feature and everytime I selected a Scout or a Hunter, it lagged. Then, when I holded right click on a tile a moved the mouse around, it lagged. After, I tried another feature and that was the arcane units that were causing problems, the exact same one. It's confusing. Especially considering that neither the recon nor the arcane units have anything to do with the CanBuild code I added.
 
Problem is that it tests every build order for every unit every time you try to look at moving to a new tile. On account of that the python is allowed to authorize players to build something when normally they aren't capable of such a thing. Mild pity is that it can only effectively STOP a unit from building something, since it links to player and not to unit. Unit needs to have been able to build there anyway, but they do the check against the player BEFORE seeing if the unit is capable of the build or not. Seems silly, but there must be a decent reason, that or a MASSIVE oversight which if reversed would reduce the number of total python checks by a significant fraction.
 
Hmmm.

I'll look at that. Maybe commenting some things and testing, etc. I hope it's causing the problem, thus resolving it. I'll keep you updated :)
 
Back
Top Bottom