[mod] TOTAL REALISM 2.0

Guys, can you send me a piece of code where experience distributed after battle?
May be my fresh look find there some bugs? ;)
 
Serga said:
Guys, can you send me a piece of code where experience distributed after battle?
May be my fresh look find there some bugs? ;)


Sure. :)

And Bug tracking link is here: http://sourceforge.net/tracker/?group_id=163217&atid=842522

Code:
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## sdUnitXP by Stone-D (Laga Mahesa)
## Copyright Laga Mahesa 2005
##
## Version 1.00


from CvPythonExtensions import *
import PyHelpers
import sys
import time

gc = CyGlobalContext()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo

################# SD-UTILITY-PACK ###################
import SdToolKitAdvanced as sdToolKit

sdEcho         = sdToolKit.sdEcho
sdModLoad      = sdToolKit.sdModLoad
sdEntityInit   = sdToolKit.sdEntityInit
sdEntityWipe   = sdToolKit.sdEntityWipe
sdGetVal       = sdToolKit.sdGetVal
sdSetVal       = sdToolKit.sdSetVal
sdGetGlobal    = sdToolKit.sdGetGlobal
sdSetGlobal    = sdToolKit.sdSetGlobal
sdDelGlobal    = sdToolKit.sdDelGlobal

############### SD-CULTURE-CONQUEST #################

szModID        = 'sdUnitXP'
szVersion      = '1.00'

bUpgradeXP     = True
bShareXP       = True

class sdUnitXP:

	def sdUnitXPGetUnitID(self, unit):
		szUnitID = 'Unit_%s' %(str(unit.getID()).rjust(10, '0'))
		return szUnitID

	# Version Check and Fix
	def sdUnitXPDoVersionCheck(self):
		if ( sdGetGlobal(szModID, 'Version') == szVersion ):
			return 0
		self.sdUnitXPFixUnits()
		self.sdUnitXPUpgradeProtect()
		sdSetGlobal(szModID, 'Version', szVersion)
		sdEcho('StackXP : Upgraded to version %s' %(szVersion))
		return 1

	def sdUnitXPFixUnits(self):
		for i in range(gc.getMAX_PLAYERS()):
			iPlayer = PyPlayer(i)
			if ((iPlayer.isAlive()) or (iPlayer.isBarbarian())):
				unitList = iPlayer.getUnitList()
				mTable = sdModLoad(szModID)
				for c in range(len(unitList)):
					unit  = unitList[c]
					uType = unit.getUnitCombatType()
					if ( (uType > 0) and (uType != 4) and (not mTable.has_key(self.sdUnitXPGetUnitID(unit))) ):
						self.sdUnitXPInitUnit(unit)

	def sdUnitXPInitUnit(self, unit):
		szUnitID = self.sdUnitXPGetUnitID(unit)
		oldXP  = unit.getExperience()
		vTable = {
			'Experience' : oldXP,
			'createTurn' : gc.getGame().getGameTurn()
		}
		sdEntityInit(szModID, szUnitID, vTable)
		sdEcho('Initialized %s (%s)' %(unit.getName(), szUnitID))
		sdSetGlobal(szModID, 'LastInitUnitID', unit.getID())
		sdSetGlobal(szModID, 'LastInitUnitTM', unit.getTeam())
		sdSetGlobal(szModID, 'LastInitUnitMV', unit.getMoves())
		sdSetGlobal(szModID, 'LastInitUnitCT', gc.getGame().getGameTurn())
		sdEcho('Meh lCT=%s  GT=%s' %(sdGetGlobal(szModID, 'LastInitUnitCT'), gc.getGame().getGameTurn()))
		sdEcho('Mex X=%s Y=%s' %(unit.getX(),unit.getY()))
		return oldXP

	def sdUnitXPUpgradeCheck(self, oldunit):
		u       = oldunit
		uID     = u.getID()
		uTM     = u.getTeam()
		uXP     = u.getExperience()
		try:
			lID = sdGetGlobal(szModID, 'LastInitUnitID')
			lTM = sdGetGlobal(szModID, 'LastInitUnitTM')
			lMV = sdGetGlobal(szModID, 'LastInitUnitMV')
			lCT = sdGetGlobal(szModID, 'LastInitUnitCT')
		except:
			return 0
		if ( (bUpgradeXP) and (lTM == uTM) and (lMV == 0) and (lCT == gc.getGame().getGameTurn()) ):
			gc.getActivePlayer().getUnit(lID).setExperience(uXP, -1)
		self.sdUnitXPUpgradeProtect()

	def sdUnitXPUpgradeProtect(self):
		sdDelGlobal(szModID, 'LastInitUnitID')
		sdDelGlobal(szModID, 'LastInitUnitTM')
		sdDelGlobal(szModID, 'LastInitUnitMV')
		sdDelGlobal(szModID, 'LastInitUnitCT')

	def sdUnitXPWipeUnit(self, unit):
		self.sdUnitXPUpgradeCheck(unit)
		szUnitID = self.sdUnitXPGetUnitID(unit)
		sdEntityWipe(szModID, szUnitID)
		sdEcho('Purging %s (%s)' %(szUnitID, unit.getName()))
		return 0

	def sdUnitXPCombatResult(self, argsList):
		u       = argsList[0]
		uPlot   = u.plot()
		uType   = u.getUnitCombatType()

		self.sdUnitXPUpgradeProtect()

		typesTable = {
			'-1' : 'Unknown',
			'0'  : 'None',
			'1'  : 'Archer',
			'2'  : 'Mounted',
			'3'  : 'Melee',
			'4'  : 'Siege',
			'5'  : 'Gun',
			'6'  : 'Armor',
			'7'  : 'Helicopter',
			'8'  : 'Naval'
		}

		if (uPlot.getNumUnits() < 2): # He's on his lonesome!
			return 0

		if ( (uType < 1) or (uType == 4) ): # People don't learn from siege weapons.
			sdEcho('StackXP : %s unit is invalid for stack distribution.' %(typesTable[str(uType)]))
			return 0

		try:
			oXP = sdGetVal(szModID, self.sdUnitXPGetUnitID(u), 'Experience')
		except:
			oXP = self.sdUnitXPInitUnit(u)-1
	
		dXP     = u.getExperience()-oXP
		if ( (not bShareXP) or (dXP < 1) ):
			sdSetVal(szModID, self.sdUnitXPGetUnitID(u), 'Experience', u.getExperience())
			return 0
		sdEcho('StackXP : %s %s (%s) : Distributing %s (%s-%s) Experience Points.' %(typesTable[str(uType)], u.getName(), self.sdUnitXPGetUnitID(u), dXP, u.getExperience(), oXP))
		u.setExperience(oXP, -1)

		# Look for the crappiest unit in the stack with the same combat type as the winner.
		w       = u
		while (dXP > 0):
			for i in range(uPlot.getNumUnits()):
				pUnit = CyInterface().getInterfacePlotUnit(uPlot, i)
				if (pUnit):
					if ( (pUnit.getID() != w.getID()) and (pUnit.getTeam() == u.getTeam()) and (pUnit.getUnitCombatType() == u.getUnitCombatType()) and (pUnit.getExperience() < w.getExperience()) ):
						w       = pUnit
			# sdEcho('StackXP : Plus 1 XP to %s %s (%s)' %(w.getName(), self.sdUnitXPGetUnitID(w), w.getExperience()))
			w.setExperience((w.getExperience()+1), -1)
			sdSetVal(szModID, self.sdUnitXPGetUnitID(u), 'Experience', w.getExperience())
			sdEcho('StackXP : Gave 1 XP to %s %s (%s)' %(w.getName(), self.sdUnitXPGetUnitID(w), w.getExperience()))
			dXP -= 1
		sdSetVal(szModID, self.sdUnitXPGetUnitID(u), 'Experience', u.getExperience())
		return 0
 
May you please elaborate what exactly is not working for these units and buildings?

Thanks
Houman

Toys®Us said:
Now, the Civilopedia ---> the only thing I'm able to do to help! Enjoy! :lol:
I found some text problems... it will be nice to fix it in the next version.
***
:scan: (Scanning)

Technologies
------------
Scientific Method

Units
-----
Bomber
Nuclear Carrier
Persian Horse Archer
Stealth Bomber
Strike Fighter
Zeppelin

Buildings
--------
*Free Specialist Listed ??
Zoroastrian Fire Temple
Zoroastrian Monastery
Zoroastrian Temple

Wonders
--------
Adur Burzen-Mihr
The Three Gorges Dam

***

You did a splendid work!
A piece of art!
THANK YOU!
[party]
 
Code:
if (pUnit):
if ( (pUnit.getID() != w.getID()) and (pUnit.getTeam() == u.getTeam()) and (pUnit.getUnitCombatType() == u.getUnitCombatType()) and (pUnit.getExperience() < w.getExperience()) ):
w       = pUnit

is this correct?
may be it must be so?

Code:
if (pUnit):
if ( (pUnit.getID() != u.getID()) and (pUnit.getTeam() == u.getTeam()) and (pUnit.getUnitCombatType() == u.getUnitCombatType()) and (pUnit.getExperience() < u.getExperience()) ):
w       = pUnit
 
Serga said:
Code:
if (pUnit):
if ( (pUnit.getID() != w.getID()) and (pUnit.getTeam() == u.getTeam()) and (pUnit.getUnitCombatType() == u.getUnitCombatType()) and (pUnit.getExperience() < w.getExperience()) ):
w       = pUnit

is this correct?
may be it must be so?

Code:
if (pUnit):
if ( (pUnit.getID() != u.getID()) and (pUnit.getTeam() == u.getTeam()) and (pUnit.getUnitCombatType() == u.getUnitCombatType()) and (pUnit.getExperience() < u.getExperience()) ):
w       = pUnit

no..this code is searching for crappiest unit (u - is winner, w - last finded unit which is less exp. as winner)
 
Code:
		u.setExperience(oXP, -1)

		# Look for the crappiest unit in the stack with the same combat type as the winner.
		w       = u
		while (dXP > 0):
			for i in range(uPlot.getNumUnits()):
				pUnit = CyInterface().getInterfacePlotUnit(uPlot, i)
				if (pUnit):
					if ( (pUnit.getID() != w.getID()) and (pUnit.getTeam() == u.getTeam()) and (pUnit.getUnitCombatType() == u.getUnitCombatType()) and (pUnit.getExperience() < w.getExperience()) ):
						w       = pUnit
			# sdEcho('StackXP : Plus 1 XP to %s %s (%s)' %(w.getName(), self.sdUnitXPGetUnitID(w), w.getExperience()))
			w.setExperience((w.getExperience()+1), -1)
			sdSetVal(szModID, self.sdUnitXPGetUnitID(u), 'Experience', w.getExperience())
			sdEcho('StackXP : Gave 1 XP to %s %s (%s)' %(w.getName(), self.sdUnitXPGetUnitID(w), w.getExperience()))
			dXP -= 1
		sdSetVal(szModID, self.sdUnitXPGetUnitID(u), 'Experience', u.getExperience())
		return 0

Winner does not receive any exp if there are any same less experienced units in a stack ?
Am i right?
I think its not very realistic.
 
Vishaing said:
I THINK I might have figured out the Judaism "bug".

Unfortunately I don't have the save, but here is the thing I noticed:

I founded Judaism, as Germany, and the Holy city was Hamburg (My Second City, in keeping with the core founding paramaters) There was a brief problem with Judaism spreading to Rome (Antium) before I converted and became "Defender of the Faith". So I went into the WB and removed Judaism from Rome before they could convert, and then continued playing.

So its about... Dangit, I forgot there aren't years in this... and suddenly I notice that BOTH Russia and Greece are now Jewish. And I think wtf mate?

Then I notice something else, Hamburg is no longer the Jewish Holy City.

The Holy City is gone. Vamis Vamadoes, Vanished. (Sorry for all the spelling errors)

I think that might be the problem, the script focuses on a civ having Judaism's Holy City to be the "Defender of the Faith" and only let it spread in their borders. For some reason, my city is losing its holy city status, and the Jewish people are now feeling homeless, thinking I'm not their defender, so they try to wander to find someone who is a bit more considerate to them.

This is actually a logical concept, the spreading over the borders when it's not your state religion. Also It could be that you made Judaism your state religion in the exact 15th turn the game will move the holy city to somewhere else.

I've already talked to 12M about it, and in my situation I converted immediately in the turn the little movie starts. Though the game might set the spread over the borders before that turn where I make it to my state religion (probably in the loading process for the turn).
Or the game spreads the religion over the borders before it recognizes I own the Holy city and Judaism is my state religion (in the loading process from the one turn I've been shown the religion movie to the next turn).

It sounds complicated, but read slowly and you'll understand.
At least these are my 2 theories. After all, it couldn't be even an issue within the religion mod python code.

/e: There are definitely NO additional files in my custom assets folder.
 
Serga said:
Winner does not receive any exp if there are any same less experienced units in a stack ?
Am i right?
I think its not very realistic.
hmm.
i think i must look deeper into code..this very good note...(we are implement this without changing , so if this is a bug, it is from original - must look into forum)

EDIT: in my tested game winner get exp. too - so i really must carefully study this code..
 
Hey Guys,

I have Writing (and Alphabet) but still can't trade techs with anyone else?

Do they need to have Writing also?

Do I need to connect via trade route first?

Something else I am missing here?

Thanks much,

Seato.
 
JohnnyBuck9 said:
Hey Guys,

I have Writing (and Alphabet) but still can't trade techs with anyone else?

Do they need to have Writing also?

Do I need to connect via trade route first?

Something else I am missing here?

Thanks much,

Seato.

in this mod is not allowed technology trading, but is implemented Open Technology mod - so if you have open border agreement with other civ, and this civ has already researched technology which you are researching, you get bonus 150% for research in every city more you can find in Documentation\Inclusions\OpenTech.txt under mod directory
 
Can something be done to slow down the holy city "movement" ? In my current game, Zoroaterism..(can't remember the full spelling) religion holy city keeps poping around and I CONSTANTLY get its music (sometimes twice in one turn). It was a cool song the first 100 times, but now its MASSIVLY annoying to hear almost every turn. After a 100 turns, its clear that NO CIV WANTS IT !!! :mad:

Some kind of Hysterisis (sp??) needs to be added so the holy city doesn't rapdily pop around if no one wants to have it as their religion.

Don't get me wrong, its a good concept :goodjob: , but when your down to a few civs then you always have multiple religons that will never have a "home" and they just constantly keep poping around, playing their songs and poping up messages. WAYYYY to much "noise" :twitch:
 
Couple possible bugs.

1.) MINOR: after the install, I did not see nor was I shown the Readme as was stated earlier in the thread.

2.) MEDIUM: I have multiple cases where I send a missionary to a foreign city and when they get in the city, NONE of their command buttons are visible again. I can use my numpad to move them out and magically their buttons all apear again. It only happens on a few of the foreign cities and not all of them. I looked and the city is not a holy city or anything that I can tell about it.

3.) MINOR: this could be an exploit on being able to use slavery to provide free experience to your garrisoned troops. Does the exp. code check to see if it was just a slave uprising and not give any exp? If not, this would be too easy to "run up" some cheap exp. points.


Request (beside my "hoping" holy city issue posted aboved):

1.) please add a hover over label (like the other command ones) for the "make a mercenary" button. Its not clear, not document(yes I searched the readme).
 
ravenone said:
Couple possible bugs.

1.) MINOR: after the install, I did not see nor was I shown the Readme as was stated earlier in the thread.

2.) MEDIUM: I have multiple cases where I send a missionary to a foreign city and when they get in the city, NONE of their command buttons are visible again. I can use my numpad to move them out and magically their buttons all apear again. It only happens on a few of the foreign cities and not all of them. I looked and the city is not a holy city or anything that I can tell about it.

3.) MINOR: this could be an exploit on being able to use slavery to provide free experience to your garrisoned troops. Does the exp. code check to see if it was just a slave uprising and not give any exp? If not, this would be too easy to "run up" some cheap exp. points.


Request (beside my "hoping" holy city issue posted aboved):

1.) please add a hover over label (like the other command ones) for the "make a mercenary" button. Its not clear, not document(yes I searched the readme).

bugs:
1) yes, know issue : http://forums.civfanatics.com/showpost.php?p=4138800&postcount=138

2) same : http://forums.civfanatics.com/showpost.php?p=4141486&postcount=194

3) we will be thinking about it

Request:
1.) this is problem - in-game engine limitation, cannot be implemented yet

AND PLEASE, READ (OR SEARCH) FORUM OR BUG TRACKER .... same questions on every page :( , same bugs reporting - but no one can (or no one want??) upload saves to bug tracker - if i can't test (when i can't reproduce) bug, i can't solve this
 
Mexico,

Bug tracker = good.

Suggest you put in BIG BOLD TEXT right near (Above or below) the download link on the first page, first message a notice about using the bug tracker for all issue searching and entry.

No where on the first few messages talking about the mod does it mention that bug tracker. Hence noobs like me not knowing to enter/search all bugs there.

I tried to read through the entire thread, but at 12 pages things can get missed. (sorry for the duplicate bugs. :sad: )
 
Serga said:
Chariot with 3/10 exp has two permanent promotions.
IMHO its a same bug with experience distribution.
Annoying..

Also present here is an almighty Judaism world religion. In my game it was founded by Romans, they adopted it right away, the Holy City never moved (they even built ToSolomon there), and it spreads to all their neighbors. If I understand properly, then it doesn't matter if Judaism is your state religion - it should spread only in the cities of a civ that controls its Holy City. And that is definitely not happening.
 
ravenone said:
Mexico,

Bug tracker = good.

Suggest you put in BIG BOLD TEXT right near (Above or below) the download link on the first page, first message a notice about using the bug tracker for all issue searching and entry.

No where on the first few messages talking about the mod does it mention that bug tracker. Hence noobs like me not knowing to enter/search all bugs there.

I tried to read through the entire thread, but at 12 pages things can get missed. (sorry for the duplicate bugs. :sad: )

ok...np ;) ... problem is, that bug tracker is mentioned in readme (which i forgot to include in installer) - this readme and bug tracker has link in start menu, but no one read this :( (or no one found this)
 
ravenone said:
Can something be done to slow down the holy city "movement" ? In my current game, Zoroaterism..(can't remember the full spelling) religion holy city keeps poping around and I CONSTANTLY get its music (sometimes twice in one turn). It was a cool song the first 100 times, but now its MASSIVLY annoying to hear almost every turn. After a 100 turns, its clear that NO CIV WANTS IT !!! :mad:

Some kind of Hysterisis (sp??) needs to be added so the holy city doesn't rapdily pop around if no one wants to have it as their religion.

Don't get me wrong, its a good concept :goodjob: , but when your down to a few civs then you always have multiple religons that will never have a "home" and they just constantly keep poping around, playing their songs and poping up messages. WAYYYY to much "noise" :twitch:

As I said that was a mistake from my soundtrack implementation. The next Patch will solve it. No worries. Have few more days patience. ;)

Houman
 
Mexico said:
hmm.
i think i must look deeper into code..this very good note...(we are implement this without changing , so if this is a bug, it is from original - must look into forum)

EDIT: in my tested game winner get exp. too - so i really must carefully study this code..

Try make a battle just after loading some save or just in the first game turn. In that case stack experience distributed completle wrong.
Try that combination of winner stack: warrior (exp 5/10) + warrior (2/5) + warrior (6/10). Attak by warrior (5/10). If you win, winners exp may become even less, like (4/10).

It works only if battle happend at the fist turn after loading.
 
Top Bottom