Everything Python and SDK related

Actualy, I decided to change the spell system. Having different kinds of spells made things needlessly complicated. I thought that it would be easier to have just 1 event for all the spells and then use python to select a square, which I believe has already been done.
 
an improvement from the system I posted earlier. If the function returns true, then you will get to select a square. If you return False, you can cast a spell as normal.
 
Ploeperpengel requested the python for the Homeland trait in case you guys would like to do something similar. In FfH the trait gives all your units a slight strength bonus is they are in a plot they control.

The way this works is there is a Homeland promotion that gives the iCombat adjustment (you could of course have it do whatever you would prefer). Then all you need is a small python routine in onUNitMove int he CvEventManager.py as follows:

Code:
		pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HOMELAND'), False)
		if pPlot.isOwned():
			if (pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_DEFENDER')) and pPlot.getOwner() == pUnit.getOwner()):
				if (pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_MELEE') or pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_RECON') or pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ARCHER') or pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_MOUNTED')):
					pUnit.setHasPromotion(gc.getInfoTypeForString('PROMOTION_HOMELAND'), True)

Let me know if you have any quesitons about the code, it basically if the player has the homeland trait it checks the plot the units moves into to see if it is owned by the same player that owns the unit. If it does the homeland promotion is added.

Similar code could be added to grant promotions if a unit is in forest, in a city, within 3 spaces of a general, whatever you want.
 
Ploeperpengel requested the python for the Hidden, Barbarian, Scorched Earth and Raiders traits.

Hidden isn't implemented yet, it doesn't currently do anything.

Barbarian is implemented by including the following in the onGameStart function in CvEventManager.py:

Code:
		if player.hasTrait(gc.getInfoTypeForString('TRAIT_BARBARIAN')):
			eTeam = gc.getTeam(player.getTeam())
			iTeam = gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam()
			eTeam.makePeace(iTeam)

Scorched Earth is an SDK only change (change in the city capture code that forces the raze).

Raiders is a mix of an SDK change (do modify the amount of gold gained by pillaging) and a python change to grant an extra experience point after each successful combat. The following goes in onCombatResult in CvEventManager.py to accompolish it:

Code:
		if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_RAIDERS')):
			pWinner.changeExperience(1, -1)
 
@Olleus and theLopez
The traits Barbarian and Raiders I'd like to have combined(renamed the trait to Trait_Barbarian_Raiders) for the greenskins. The additional features for them: minus warwearyness and +1extrahealth if multiple meadresources are available should be added to it.

Here's the current traitinfo:
Please also check in the additional +1food on foresttile for trait_friendsofthewood(the current healthbonus is irrelevant).
and Homeland to the trait_defender
 
I have finished making the magic mod but I currently have no AI for it, and don't really know how to do this. TGA, theLopez if you read this please help me. Right now the plan is this:

1) Have a new UNIT_AI called WIZARD

2) All the spells have a 'strengh' tag, and the spell the wizard casts is random, but weight towards spells with higher strenghts.

3) The AI checks every plot in which the spell can be cast and chooses the best one (depending on whether the spell is an attack spell, a collateral spell, a heal spell, ect...)

4) If there are no 'decent' places to cast a spell the wizard moves to a better place.


This will, obviously, produce a rather bad AI. 2 and 3 could be merged so that it checks every plot for every spell, and then chooses the best spell to cast. I have no idea on how to make step 4. Should I just copy the UNITAI_ATTACK and UNITAI_DEFENCE?
 
No, the player which choose which spell he casts and where. This is onlyconcerning the AI.
 
Top Bottom