Is there a simple way to...

Elucidus

King
Joined
Mar 3, 2002
Messages
983
Location
USA
Can I add a bonus to AI civs where tehy gain say 10 gold per turn and maybe +10% gold to their total gold per turn so it grows with them? Preferably specific AIs, but I can work with all of them. I know this isn't related to AND or even ROM directly, but it is all I play and I know you guys probably know the answer. I am sure I can, but what is the best way? Thank you.
 
You can do this in python pretty easily. I can show you how, if you are interested.
 
Okay, it's really easy to do this in python. In the RoM Python folder, create a new file named "ExtraAIGold.py" (be sure to make sure it has the .py extension).

Inside, paste this as the contents:
Code:
from CvPythonExtensions import *
gc = CyGlobalContext()

def onBeginPlayerTurn(argsList):
	iGameTurn, ePlayer = argsList
	pPlayer = gc.getPlayer(ePlayer)
	if not ((pPlayer).isHuman()):
		iGold = pPlayer.getGold()
		pPlayer.changeGold(int(iGold * 0.10))
That's all the code it takes to make any non-human earn 10% gold from reserves. (I.e if you have 10 gold, 1 more will be added next turn.)

Save the file. Now, in the RoM/Assets/Config folder, create a new file, "ExtraAIGold.xml".

Inside if the new XML file, paste this:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
    Gives the AI an extra 10% gold based on their current reserves each turn
-->
<mod id="ExtraAIGold" module="ExtraAIGold">
    <event type="BeginPlayerTurn" function="onBeginPlayerTurn"/>
</mod>

Save that. The last thing you need to do is modify the init.xml, in the Config folder. Open it up and find this line:
"<load mod="RoMSettings"/>"
After that line, add this one:
Code:
<load mod="ExtraAIGold"/>

That causes the game to load the python module at startup. All done. ;)
 
I tested and it worked... upload the PythonErr.log, after starting a game.
(Make sure logging is enabled)
 
I tried something that didn't work so I put it back how you had it and ran it again, here is the PythonErr2.log

Contrary to it's name PythonErr2 doesn't log errors in python. I need to see PythonErr.log. ;)
 
My INI logging section looks like this:

Code:
; Enable the logging system
LoggingEnabled = 1

; Enable synchronization logging
SynchLog = 0

; Overwrite old network and message logs
OverwriteLogs = 1

; Enable rand event logging
RandLog = 1

; Enable message logging
MessageLog = 1
 
My Logging section looks teh same by the way and still no pythonerr log, though the mod is working. Sorry, it's been a while since I modded. Yeah thats it, like everyone knows you have to save the files. :D
 
OKay well, um, I, uh, forgot to save the ExtraAIGold.py file. :blush::blush::blush:

Lol. Well the file only does half of your request, but the other half would require SDK work. Anyway, it has the intended effect. Python is really easy to learn, feel free to ask for other minor things.
 
Lol. Well the file only does half of your request, but the other half would require SDK work. Anyway, it has the intended effect. Python is really easy to learn, feel free to ask for other minor things.
Can I add a bonus to AI civs where tehy gain say 10 gold per turn and maybe +10% gold to their total gold per turn so it grows with them? Preferably specific AIs, but I can work with all of them. I know this isn't related to AND or even ROM directly, but it is all I play and I know you guys probably know the answer. I am sure I can, but what is the best way? Thank you.

Would not adding the following do the other half of the request with out SDK changes or am I missing something?
Code:
	if not ((pPlayer).isHuman()):
		iGold = pPlayer.getGold()
		pPlayer.changeGold(int(iGold * 0.10[B][COLOR="Red"] + 10[/COLOR][/B]))
OR
Code:
	if not ((pPlayer).isHuman()):
		[B][COLOR="Red"]iGold = pPlayer.getGold() + 10[/COLOR][/B]
		pPlayer.changeGold(int(iGold * 0.10))
 
Well, I assume he wanted the gold text per turn to reflect what he wanted, but yes, that effectively works the same.
 
This would be a good tutorial. I am thinking of the request that deserts and other terrains cause problems with units. It may also give them an idea what goes into modding :mischief:. I have been ignoring it because I want to get AAranda's religions out of the way as well as the "building makes unit every so often" for Vincentz (am me) plus "Religious Decay".
 
Top Bottom