Simple Python Things

My bad.. i replaced that file, there's a difference.
should be:
<Define>
<DefineName>USE_CANNOT_TRAIN_CALLBACK</DefineName>
<iDefineIntVal>1</iDefineIntVal>
</Define>

thx, TJ :D
 
i did some merge.
btw, i've merged the "warrior of god" with "militia mod" (its prereqs a civic and an improvements instead). :D

If you need them to work with the BUG mod just let me know, i have them already;)
 
Hello, The J!

I'll get straight to the point here.

After merging the SpawnACiv modcomp into World of Legends, I got some good feedback. One of the main complaints, however, was the fact that when a barbarian civ popped up, everybody got a diplomatic bonus with each other for having a mutual military struggle (you already mentioned this earlier, I know).

Thinking over it a bit, I thought of a few ways to remedy this, and I wondered whether you'd be able to do any of them:

1. Decrease diplomatic bonuses everybody gets (through some sort of (ideally invisible) building or wonder that the barbarian civ gets when it spawns?).

or, the better solution:

2. Make the Spawnable Civ visible to ONLY civs that have actually met it. In other words, the Spawnable Civs are ALWAYS in contact with EVERYONE, so even if I'm all the way in Siberia, I'll get a message that says "The Huns have spawned!" even though the Huns are in Hawaii, and there's no way I'll meet them in 100 turns. If you can make it so that civs can come into contact with Spawnable Civs much like normal civs (except that they immediately declare war), I think this will alleviate a bit of the mutual military struggle, so everybody doesn't get it with everybody.

Thanks for reading all this, and, again, I'm in no way pressuring you to do anything (I do have a few drastic back-up plans up my sleeve). And, as always, thank you for taking the time to make these great modcomps!

cybrxkhan
 
^If I remember correctly that doesn't seem to work for some reason. Then again my memory can be off, although that doesn't change the fact that the "barbarian civ" will be in contact with every civ on the map, even if the barb civ is in Alaska and you're in South Africa.

@The J: Thanks for your help, again. :D
 
You're right, that doesn't work.
The minor civ thing is only in the SDK, it's not in XML and not in python and can only be applied in a world builder file.
Was probably an unfinished feature, i guess :dunno:.


Okay, whatever, changed it now.
There's a new part in the CvEventManager which has to be new merged in, the SpawnCivUtil just has to be replaced (the python attachement).

Not really necessary, but i want to tell it:
Funny thing: Seems when your unit gets in the range of one of your cities at the very first time, technically some diplo contact to yourself is triggered.
Let me explain that.
The new change is now done in the way, that after the first contact between 2 civs it is checked, if one of them is under the spawnable civs, and if yes and the civ is a "barbarian" civ, then it will declare war on the other civ.
In the first test, i searched for the hun cities, but could not find them, also the script threw an error, that the units could not be added to the hunish cities.
In the replay i could then see why: After the huns have spawned, they declared war on themselves, which has lead to the strange situation that the first hunish horseman, which was placed in their first city, has captured this city and due to low pop/culture the hunish horseman razed his own city :crazyeye:.
Was fixed with a short check, that contacting and contacted civ should not be the same, but that was totally unexpected :crazyeye:.


-----

Okay, second attachment is for wotan.
A looooooooooooooong time ago he requested a function that when a certain unit is killed, the war weariness for the winner will increase more than usual.
I tried that some time at a weekend that loooong time ago, but could not get it to work. Well, another great implementation: You can add in your turn as many war weariness points as you want, but they'll only get applied when you finish the turn.
-> learned again something.
In the .py files, search for "more WW after combat". Effect is currently attached to the warrior (easy for testing), and the amount of WW is atm 4000 (that's enough to make 1 :mad: more in 1 city for 1 defeated warrior; no idea how that scales :dunno:).
 

Attachments

Thank you so much for the code. I'll test it as soon as I'll find the time. :)
 
I made a thread about this, but I figured you would probably notice this first:
Is there someway to use python to give random promotions?
 
I made a thread about this, but I figured you would probably notice this first:
Is there someway to use python to give random promotions?

Definitely. Here's something I used:

Gives a 1% chance for a special "random" promotion to be given to a unit when it's built. If this is not what you want you can easily adjust it. Also it's not ONLY python but Killmeplease has a modcomp that gives units promotions based on winning battles, occasional promotions http://forums.civfanatics.com/showthread.php?t=354443

Spoiler :

Code:
	def onUnitBuilt(self, argsList):
		'Unit Completed'
		city = argsList[0]
		unit = argsList[1]
		player = PyPlayer(city.getOwner())
		iOwner = city.getOwner()
		
	# Star Signs by Smeagolheart Start

		pCity = argsList[0]
		pUnit = argsList[1]
		pPlayer = gc.getPlayer(pUnit.getOwner())
		iUnitType = pUnit.getUnitType()

		promSign1 = gc.getInfoTypeForString("PROMOTION_AQUARIUS")
		promSign2 = gc.getInfoTypeForString("PROMOTION_ARIES")
		promSign3 = gc.getInfoTypeForString("PROMOTION_CANCER")
		promSign4 = gc.getInfoTypeForString("PROMOTION_CAPRICORN")
		promSign5 = gc.getInfoTypeForString("PROMOTION_GEMINI")
		promSign6 = gc.getInfoTypeForString("PROMOTION_LEO")
		promSign7 = gc.getInfoTypeForString("PROMOTION_LIBRA")
		promSign8 = gc.getInfoTypeForString("PROMOTION_PISCES")
		promSign9 = gc.getInfoTypeForString("PROMOTION_SAGITTARIUS")
		promSign10 = gc.getInfoTypeForString("PROMOTION_SCORPIO")
		promSign11 = gc.getInfoTypeForString("PROMOTION_TAURUS")
		promSign12 = gc.getInfoTypeForString("PROMOTION_VIRGO")
		
		chance = CyGame().getSorenRandNum(100, "Random to get a Sign")
		chance2 = CyGame().getSorenRandNum(12, "Random Sign Picker")
		
		signTrue = false
		
		if chance == 7:  ### Lucky 7 Lol -> so 1% chance of getting a "sign promotion" ###
			signTrue = true
			if chance2 == 0:
				pUnit.setHasPromotion(promSign1, true)
				szIcon = "Art/Interface/Buttons/promotions/AQUARIUS.dds"
			elif chance2 == 1:
				pUnit.setHasPromotion(promSign2, true)
				szIcon = "Art/Interface/Buttons/promotions/ARIES.dds"
			elif chance2 == 2:
				pUnit.setHasPromotion(promSign3, true)
				szIcon = "Art/Interface/Buttons/promotions/CANCER.dds"
			elif chance2 == 3:
				pUnit.setHasPromotion(promSign4, true)
				szIcon = "Art/Interface/Buttons/promotions/CAPRICORN.dds"
			elif chance2 == 4:
				pUnit.setHasPromotion(promSign5, true)
				szIcon = "Art/Interface/Buttons/promotions/GEMINI.dds"
			elif chance2 == 5:
				pUnit.setHasPromotion(promSign6, true)
				szIcon = "Art/Interface/Buttons/promotions/LEO.dds"
			elif chance2 == 6:
				pUnit.setHasPromotion(promSign7, true)
				szIcon = "Art/Interface/Buttons/promotions/LIBRA.dds"
			elif chance2 == 7:
				pUnit.setHasPromotion(promSign8, true)
				szIcon = "Art/Interface/Buttons/promotions/PISCES.dds"
			elif chance2 == 8:
				pUnit.setHasPromotion(promSign9, true)
				szIcon = "Art/Interface/Buttons/promotions/SAGITTARIUS.dds"
			elif chance2 == 9:
				pUnit.setHasPromotion(promSign10, true)
				szIcon = "Art/Interface/Buttons/promotions/SCORPIO.dds"
			elif chance2 == 10:
				pUnit.setHasPromotion(promSign11, true)
				szIcon = "Art/Interface/Buttons/promotions/TAURUS.dds"
			elif chance2 == 11:
				pUnit.setHasPromotion(promSign12, true)
				szIcon = "Art/Interface/Buttons/promotions/VIRGO.dds"

			pPID = pPlayer.getID()
			iXa = pUnit.getX()
			iYa = pUnit.getY()

			if ( signTrue == true ):
				strMessage = "The stars have favored a unit produced in %s!" %(pCity.getName())			
				CyInterface().addMessage(pPID, false, 15, strMessage, "", 0, 'art/Interface/Buttons/promotions/stars.dds', ColorTypes(44), iXa, iYa, True,True)
				#Uncomment the next line to see the promotion icon instead of the generic stars icon
				#CyInterface().addMessage(pPID, false, 15, strMessage, "", 0, szIcon, ColorTypes(44), iXa, iYa, True,True)
				
	# Star Signs by Smeagolheart End
 
Is it possible you reckon J for a python mod to allow players to actually give independence to any of there cities to form new civilizations that start as vassals etc? Just wondering and oh i just want to add that your one heck of an awesome dude for doing all this.
 
mmhh...i guess that's rather a SDK task.
Depends on if under the screen itself is another check, if liberating is possible or not.
If not, then it could be done for the human, if not...
And even if, i have been in the past not be able to find any of the autogenerated civ screens (like the choose religion popup or similar), so not sure if i could do that at all.
 
Never got this error before any idea(s)?

Traceback (most recent call last):
File "BugEventManager", line 363, in _handleDefaultEvent
File "Militia", line 54, in onImprovementBuilt
AttributeError: 'NoneType' object has no attribute 'isAlive'


Spoiler :
Code:
###Militia Start ###
		BugUtil.debug("Milita mod.")
		if iImprovement == self.improvementForMilitia:
			BugUtil.debug("Milita mod - Farm built.")
			pPlot = CyMap().plot(iX, iY)
			iPlayer = pPlot.getOwner()
			pPlayer = gc.getPlayer(iPlayer)
			[B]if (pPlayer.isAlive() and pPlayer.isCivic(self.civicForMilitia)):[/B]
				iEra = pPlayer.getCurrentEra ()
				#~ BugUtil.debug("Milita mod - Farm built, Civic is Caste System, Era is %s.",  iEra)
				if iEra in self.aiEraToMilitiaUnit:
					
					pNewUnit = pPlayer.initUnit( self.aiEraToMilitiaUnit[iEra], iX, iY, UnitAITypes.UNITAI_RESERVE, DirectionTypes.NO_DIRECTION )
					CyInterface().addMessage(iPlayer,False,15,localText.getText("TXT_RECRUITED",()),'',0,'Art/Interface/Buttons/Civics/Serfdom.dds',ColorTypes(44), iX, iY, True,True)
###Militia End###
 
Is it possible in your mod to build farms outside of owned territories?
If yes, change:
PHP:
if (pPlayer.isAlive() and pPlayer.isCivic(self.civicForMilitia)):

to:
PHP:
if (iPlayer> -1 and pPlayer.isAlive() and pPlayer.isCivic(self.civicForMilitia)):
 
Does the mod only use advanced start?

In general, you could just delete this line:
PHP:
		if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):

and move every following line of the modded code one backspace back (that might sound stupid, but spaces, tabs, etc. matter in python and moving them back is important, will not work else).
 
Does the mod only use advanced start?

In general, you could just delete this line:
PHP:
		if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR") and not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_ADVANCED_START)):

and move every following line of the modded code one backspace back (that might sound stupid, but spaces, tabs, etc. matter in python and moving them back is important, will not work else).

Thanks, worked like a charm!
 
Hey there, I have a merging question about the Real OCC.

See, it's easy enough to merge it with small mods like Assimilation or a few modules. But when I try to merge it with larger mods like Neoteric World, it doesn't work, AI's spam settler's like crazy.

When I merged it with Neoteric world, there was just two changes in the XML file. And with the two Python files, there wasn't any with the same name in Neoteric World, so I just dragged em in.

Is there something conflicting with Real OCC? Or did I do something wrong?

:help:
 
Just looked into the Neoretic World thread, and NW uses RevDCM which uses BUG. And BUG has another way of loading Python files, which means in that case that the file you dropped in does not get loaded.
...er...since i always forget how to merge stuff into bug, you have 2 options now:
- You can try it yourself, there's a tutorial for it here
- You wait until the weekend, then i'll try a merge. Does probably not need long, but i'd have to read the tutorial myself again :blush:.
 
Back
Top Bottom