Blaze's FfH MaxMod

sure does, after it's explained ;)
 
Cool.

Okay, hopefully someone out there with a knack for this can give me some ideas here. I am trying to get my Combat Upgrades for Priests running.
I found an interesting bit here. It seems like I won't be able to get it working the way it is. Seems like the getNumBonuses isn't coded to be seen in onUnitCreated,
For those unfamiliar, the idea is to give a +1 special damage type to Priests(and Priests are now upgrade only from Disciple units), when the civ has a specific Mana type.
Funny, because it seems to translate fine for the Adepts getting free upgrades in onUnitBuilt, but since my new Priests aren't being "Built", it won't work there.
Anyway, I see 2 ways around this. First, adding the getNumBonuses to the SDK to make it available to CyUnit functions. this may be ultimately the best way to do it, but honestly, I'm not sure my skills are up to it, but I'm willing to give it a shot if the consensus is this is really the most prudent way to do it.
The other way I can see is add it to onBeginPlayerTurn. I would have it see if the player had the mana type and make that promotion true for UnitClass_Preists_x. This would add a some work to processes every turn, but I'm not sure how much. I know Kael and team unloaded a lot of similar functions off to the SDK in this version to keep the CPU cycle at the begining of a turn down, but I am pretty sure I can code this up without too many problems.

Opinions? Ideas?

Cheers!
 
Your problem isn't that getnumbonus() isn't seen. But that onUnitCreated runs before the upgrade process does. So it follows the following order:

1. Create your new priest.
2. Process him through onUnitCreated (adding whatever you have set).
3. Upgrade- ie: copy all the attributes from the disciple over to the priest (and therefor wipe out anything you did in onUnitCreated).
4. Delete the Disciple.

Its a real pain. I've been meanign to reverse the order for a long time (so onUnitCreated runs after the upgrade). I need to check that out.

In the meantime you may want to grant the perk to disciples when they hit the level they need to upgrade to priests (just in onUnitPromoted). Or you could have a function that checks every turn for priests without their +1 upgrades and applies them (cpu intensive). Or when a disciple dies (sacked by the upgrade) you could search that disciples stack for a priest of the same religion that doesnt have the perk and apply it).
 
Excellent! Thanks for the response Kael. I can see, once you put it in the current order, why its giving me that error call. It is funny and counter-intuitive the way it seems to process now.

Hmm.. I'll test a couple of your recommended solutions and see what I like.

Thanks!
 
Hey man, I'm just thinking, if a unit defeats a hero like Orthus, it gets the hero promotion. However, looking at the way you posted it in your 2nd post, when someone defeats a huge ass nasty dragon, it doesn't get the hero promo because the dragon didn't have it. Perhaps change it to World Units _and_ heroes? Just a thought, sorry if you do get hero promo for dragons (haven't tested it out, acheron's constantly spawning far away).
Oh and btw, I absolutely LOVE getting hero promo for defeating a hero. Great idea. (7 str dwarven soldier at turn 120 FTW! :P)
And I really like what you've done so far. Great addition to FfH, though somewhat confusing at times (like descriptions saying "Grants three fire mana", while it's actually a completely different wonder, and Public Bathrooms saying "+3 happyfaces and +1 dirtyface", while you changed it to +2 happyfaces and +1dirtyface. But this is all minor and only annoying when you're really unfocussed).
Edit: Oh, I actually have a(nother ;p) question for ya, when I research fishing, I can create a national unit fishing boat (limit: 1) and a normal fishing boat. Any difference between the two?
 
That confused me at first too. The boats are the same except that the national unit does not need to be on a tile containing fish, clams, crabs, etc. in order to build fishing boats; when it builds them, there is a chance that fish, etc, will be discovered. Since this action consumes the boat, you can them build another one. I think that the normal boat upgrades to the national unit one, since I have never seen both available at once. The national unit might also cost more, but I'm not sure.

I believe that whales were also on the list of discoverable resources, which seems wrong since they would need whaling boats instead of fishing boats to access. It could also be that the fishing boats created by the national unit are in fact a completely separate improvement, and that it can harvest all the water resources. The fishing boats never actually uncovered anything for me (I didn't really play that long), but they did boost food and gold from my water tiles.
 
I'm pretty sure I built fishing boats on a normal (empty) tile without the national unit one. I'm also able to build em both, and they cost the same.
 
I believe that if the national unit one is available, it will be the boat built. It can sometimes be hard to tell them apart. I'm pretty sure that when I had one of each type on the same empty tile at the same time only one of them had the option to build fishing boats.
 
I thought about adding a Dragons defeat to bring on the Hero Promotion... and it is a good idea, but I kind of started out just doing it against units that were already Heroes. As much as I am kicking things around in this mod, I wanted to kind of keep as much of the status quo as I could, but I"ll add a note to potentially do this in the future.

As far as the boat... I don't know for sure. It was one of the units I drew from SureShot. I don't see anything special about it, other than its a national unit. Any boat should be able to put out fishing nets on any coast tile now, with a chance to discover bonuses. Should be... I wonder if it was originally added to provide the Lanun sea cottages... maybe I am just missing something and SS will call me on it.
This thing has been sort of a mess :) ... more work than I thought it would be, but its been a blast.

Back to testing.

Cheers!
 
Okay, so heres the whats up with the Priests Combat Bonuses.

I poked around all afternoon getting it to work via Kael's suggestions... but it just wouldn't bite. Either it would tell me that CyUnit didn't have a certain Attribute, or that an 'int' or 'tuple' didn't have an Attribute. Either I am missing some key bit of knowledge about python process here(which is likely), or something... my brain is too tired to consider what else I could be missing... because using the same instances (e.g. unit = argsList[1], as per in the def onUnitBuilt) in different definitions produce vastly different errors... I don't know.. going to hunt food...

I did get it to work though, but I will have to set Priests back to being buildable units, since thats the only place I could get it to work at the moment. With that thought, I was considering allowing Disciples to keep Channeling 1. It would be sort of a trade off situation... Priests that "came up" through the ranks could then access spells like Sanctify, but couldn't have the extra Str that newly trained Priests would have.

Maybe some genius will jump in and tell me what I'm missing, and I'll be able to implement one of Kael's suggestions, and then that will all be moot.

I think the promotion route would be the best way to go.. so this is what I did.. I tried using the code more or less as is(from Adept automatic spell upgrade), but got an 'CyUnit' doesn't have getNumBonuses(I tried using .hasBonus , but it gave me essentially the same error, and tried using "if pPlayer.getNumBonuses"(and .hasBonus), but that gave me a CyPlayer error...so I kept it as close to existing code as possible to eliminate an error of ignorance on my part). I then noticed that the inst. unit was defined differently where I ..err.. borrowed my code from so I created a new instance with the same definition as was used in onUnitBuilt. and got 'int' has no Attribute getUnit... Anyway, this is what I was working with in unitPromoted(the indentation doesn't transfer well here, but its right in the py)
Code:
#		city = argsList[0]
#               iUnit = argsList[1]
#		if iUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_DISCIPLE'):
#	          	if iUnit.getLevel() >= 4:
#				iNum = city.getNumBonuses(gc.getInfoTypeForString('BONUS_MANA_FIRE'))
#				if iNum >= 1:
#					iUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_KILMORPH'), True)
 
Try the following:

Code:
	def onUnitPromoted(self, argsList):
		'Unit Promoted'
		pUnit, iPromotion = argsList
		player = pUnit.getOwner()
		pPlayer = gc.getPlayer(player)

		if pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_DISCIPLE'):
	          	if pUnit.getLevel() >= 4:
				if pPlayer.hasBonus(gc.getInfoTypeForString('BONUS_MANA_FIRE')):
					pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_KILMORPH'), True)

		if (not self.__LOG_UNITPROMOTED):
			return
		CvUtil.pyPrint('Unit Promotion Event: %s - %s' %(player.getCivilizationName(), pUnit.getName(),))

Note that I pointed to the hasBonus on the player not the city (thats a special FfH function) because you cant always assume a unit will be in a city when it promotes.
 
Hey Blaze, forgive the ignorance but does this install over the top of the existing Fall From Heaven install? And if so, will that mean making a fresh re-install whenever FFH or your mod are patched? Is there some way of running the two side-by-side for comparison? Civ4 mods confuse me enough as it is, and mods on top of mods are just too much for my poor head :D

Anyway, really like the sound of the changes and can't wait to give them a try!
 
Wow, Thanks Kael, I guess I was pretty close.. I must have missed that particular combination. good point about being in a city.

Polycrates: Right now I do have it set up to install over the Fall From Heaven mod directly.

I would say the best way to do it is to go ahead and install the FfH stuff. Then go ahead and install my stuff.

Then you'll have to get a little involved with explorer. Open up My Computer and go to C:\Program Files\Firaxis Games\Sid Meier's Civilization 4\Mods
You'll see a folder there Fall From Heaven 2 021. I would rename that, maybe something like Fall From Heaven 2 021Blaze(or something, just so you know what it is).

Then go back and Install the Main Fall From Heaven install again.

Then, when you go into Civ 4 and go to set your mod, you should see both Fall and Fall...Blaze. Set to play as you wish.

I hope I didn't make that too simple, but it sounds like you are a basic user, so that is probably the easiest way to do it.

Cheers!
 
Sorry folks, even with Kael's help, it seems this Priest promotion just doesn't want to play.

This is what I ended up with finally, to cover everybody(reiterating for each StateReligion)::

Code:
		if pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_DISCIPLE'):
			if pUnit.getLevel() >= 4:
				if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):			
					if pPlayer.hasBonus(gc.getInfoTypeForString('BONUS_MANA_FIRE')):
						pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_KILMORPH'), True)

And I thought I had gotten pretty close to this somewhere in the middle of my trying different combos... I guess I got close enough. This failed to with..
Attribute Error: 'CyPlayer' does not have Attribute 'hasBonus'.

BUT! With great persistence, and my little bit of know how.. I dug through the SDK CyPlayers to see if there was a function that Would work here... and found it!
Code:
#Jmod Grants Priests Bonuses with Mana

		if pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_DISCIPLE'):
			if pUnit.getLevel() >= 4:
				if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_RUNES_OF_KILMORPH'):			
					if (pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_FIRE')) >= 1):
						pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_KILMORPH'), True)
				if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_FELLOWSHIP_OF_LEAVES'):			
					if (pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_MIND')) >= 1):
						pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_LEAVES'), True)
				if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ORDER'):			
					if (pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_LIFE')) >= 1):
						pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HEAVEN'), True)
				if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_OCTOPUS_OVERLORDS'):			
					if (pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_CHAOS')) >= 1):
						pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_OVERLORDS'), True)
				if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):			
					if (pPlayer.countOwnedBonuses(gc.getInfoTypeForString('BONUS_MANA_DEATH')) >= 1):
						pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_ASHEN'), True)	
		
#Jmod End
So, there is the callout if you are looking to effect a Player. with a Bonus.
countOwnedBonuses(int /BonusString).

EDIT:: Tested it good right away, almost forgot to make sure it didn't work when it wasn't supposed to! But the good news is, it tests properly 100%


Cheers!
 
Hey again, during my current game I'm currently being harassed by nomadic chariots, which started to appear around age 150. Now, perhaps you wanted to add some more challenge to the barbs, but they're really annoying, especially for the civs who didn't get as lucky as I did (got bronze working through goodie hut). With 4 strength and 3 (?) movement they destroy your workers and warriors.
 
hmm.. as far as I know, I didn't change anything in the way Barbs are able to generate units. I think that x number of Civs have to have the same prereq techs for the barbs to be able to build specific units. That said, the Nomadic chariot may come a bit early, and they may be a little strong overall. I'll double check that, but I think that having wild Nomads coming in to raid you certainly fits thematically.

Also, A note. I mentioned earlier that I noticed a problem With the Shadow wolf getting generated multiple times when you first start the game in a Sto map. I just did a little poking there, and the only thing I can find that is different between Sto's maps and the otehrs I have checked against it is, Sto has a whole set of instructions to place Barbarian units in his scripts, and everyone else seems to be okay using the engines default schema. Not sure If there is anything I can do about this, since I am still not sure why the script picks on the Shadow wolf and leaves Typhoid Mary alone. Orthus and Sailor's Dirge have scripts in FfH to make sure they come out at a specific time, so I can see how they get "immune" to this wierd effect...

Thanks for the feedback Gravage!

Cheers!
 
Hm, I put goodie huts to crazy (12% of the map's land covered in em ;p), so people prolly just got Animal Husbandry a lot of times.
Thanks for replying so fast all the time btw, and np for the feedback :)
 
I just checked, and for some reason, a lot of the code you jsut put up isn't in your python file for ver11 of your mod.

Yes it is. :p

edit2: Maniac, from your code I undestand that the AI will "reveal" the unit if it's defending a city or a fort right ?

Yes. Invisible units simply teleport away if you walk in their tile, so without this you could just walk into Sidar and Svartalfar cities unopposed.
 
Doh! I see what I did. All that code was burried in areas that got moved from py to sdk in 21. I should have been more careful. And I should never have doubted the Mighty Maniac!

On the better news front. I have the bug with the Shadow Wolf in Sto maps figured out, and I put in a little trick to give Units that take on Hero status a unique random name(credit to Exavier for that function!). I want the World announcement to indicate the New name, but still trying to find the right function to make that statement Dynamic. I'll include it in the next patch, along with the Priest Combat Upgrades and some other minor fixes...
It seems that the Priest Combat Upgrades breaks saved games though, so I am trying to pile as much as I can into the next update to really make it count for you all!

Cheers!
 
Back
Top Bottom