Again me - SDK help!

Duke176

Warlord
Joined
Oct 19, 2006
Messages
241
Location
Turin - Italy
Hi it's me again, sorry if I stress you guys guys but if I tell you that I've tested 25 different "versions" of codifications for my uses I'm not trying to joke you.

I'll try to ask a question in a different way, maybe I haven't been so clear as I would.

CvPlayer.cpp

In order to modify GOLD, you have 3 different functions: int GETGold / void SETGold(int iNewValue) / void CHANGEGold(int iChange).

In order to create and OIL counter I did the same int GETOil / void SETOil(int iNewValue) / void CHANGEOil(int iChange) - and this works.

In order to know how much was the production each turn, I've created different functions that returns numbers, one that make a calculation of ammount and again something really similar to GOLD and OIL: int GETOilProdPerTurn / void SETOilProdPerTurn(int iNewValue) / void CHANGEOilProdPerTurn(int iChange)

All right my problem is to pass a certain int Value to CHANGEOilProdPerTurn(int iChange), so that the iChange assume a value and modify everything else that works. All the functions works just passing this value doesn't work.

So questions:
1- is there some rules to pass values from and INT function to a VOID one? (int CalculateOilProdPerTurn() - void ChangeOilProdPerTurn(int iChange)).

2- where should I check to see which functions are called on every turn for each player?


I ask the second one becuase I start thinking this could be a prb of code missing in order to update each turn this value (OILRESERVE). I thoght in CvPlayer.cpp there were all the functions the game have to calculate each turn, but I'm starting thinking is something else (like python recall on update maininterface each turn).

Thx, pls help me if you can. It's 3 month I'm on this little mod.
 
I know absolutely nothing about the SDK and Python, but wanted to give you a little encouragement. When you get this to work (and I think you will, given by what you've done so far) it will change the way civ runs completely. It's a much needed improvement that will help make the game more realistic and fun. As one who's had his own issues with modding the game, please don't give up!

-Smitty
 
one more question (related).

3) Does anyone knows the existance of a function like "onNewTurn" or "NewTurnUpdate" I know already most of them but noone seems to be the one i'm looking for.
I searching for the function that makes the game update a lot of infos (like Gold) on start of each new turn.

I guess my prb is there, I should put my calculateOilProdPerTurn() to be updated each turn...
 
Edit: I changed my mind. For your third question, I think you should be looking at PyHelpers.py:

# Players Gold
def getGold(self):
return self.player.getGold()

def changeGold(self, iGold):
self.player.changeGold(iGold)

def setGold(self, iGold):
' none - Sets Gold to iGold '
self.player.setGold( iGold )

def hasGold(self, iNumGold):
' bool - Has at least iNumGold? '
if ( self.player.getGold() >= iNumGold ):
return True

def getTotalMaintenance(self):
return self.player.getTotalMaintenance()

def calculateUnitCost(self):
return self.player.calculateUnitCost()

def calculateUnitSupply(self):
return self.player.calculateUnitSupply()
 
Passing arguments to function is the same regardless of the functions return type. The big turn functions are call doTurn() theirs one at the player level and one at the City level, it mostly calls other functions. The best way to track what functions are being called is to print to a log. Use this code by jdog5000 to add some handy loging to your project.

Add this to CvGlobals.cpp
Code:
void CvGlobals::logMsg(char* format, ... )  // sdkDbg.log by Jdog5000
{
	static char buf[1024];
	_vsnprintf( buf, 1020, format, (char*)(&format+1) );
	gDLL->logMsg("sdkDbg.log", buf);
}
Add this to CvGlobals.h
Code:
    DllExport void logMsg(char* format, ... );   // sdkDbg.log by Jdog5000

Call like this

Code:
int importantValue;
CvString importantname;
GC.logMsg("A hand logging message reports %i units of %s", importantValue, importantname);

A log called sdkDbg.log will apear in Civ4/Logs on each run of the game (overwrites each time you load), Simplest thing is to just regurgitate the arguments of the function at the top of the function along with someting like "Function such and such called with args or X, Y and Z". Then just before the return log what is about to be returned "Function X returning R". It should be trivial to read the log and determine what the issues are.
 
thx for help from both.
But Impaler as always you are the best!!!!

Now it works perfecly!!!

I forgot only to resert iOilProdPerTurn in order to have production resert each turn.

Now I have one further question.

1) Do you think I should change also AI a bit after this mod?
I mean Oil become extrimely important to move units so I should tell the AI to produce more not mechanized armies in order to have the AI thinking about new strategy in case it doesn't own an Oil goody?


2) I know there's a function that makes a count of all available goodys you civ owns, do you if there's a function to count all the improvements do you own?

ATM only working on graphic interface in order to show you how much OIL do you own.
 
I know absolutely nothing about the SDK and Python, but wanted to give you a little encouragement. When you get this to work (and I think you will, given by what you've done so far) it will change the way civ runs completely. It's a much needed improvement that will help make the game more realistic and fun. As one who's had his own issues with modding the game, please don't give up!

-Smitty


I haven't thx 1st part of mod is out for testing if oyu wish to try it.
 
all right yes the beta version is out, I would suggest you to wait 2-3 days more becuase I'll make 2 more changes inside sdk and python to correct 2 little prb I missed but than it will be ready.

About buildings: I haven't implemented it yet, which buildings do you think should have a new tag like "iOilMantainanceCosts"?
I was considering there are not a lot of buildings that may need oil.

for ex. I think at Airport, Port, but what else?

Another idea I had was: there could be a value of OilConsumption assigned to each number population or check for pop of a city and make a count like "if pop is between x < city < y assign a value of 15 each turn for consumption... or somethink like this.
 
Factories should definitely need oil to work (whether from whales or oil). During the US War of Succession (Civil War) the South's industrial capacity grew rapidly until 1863 where it started to shut down. It broke apart because the Northern blockade cut off the factories supply of oil, so much so to the point that they were litterally grinding themselves apart.

Pretty much anything (unit, building, anything) that has moving parts should need oil. How much is just a matter of ballancing things out. I agree with what you have so far that units need so much oil depending on how much they move. Buildings I think should need a set amount per turn.

I hope it's set up so that the effects from buildings go away if they get no oil. You should also work in so that you decide what gets oil and what doesn't. This isn't to mean that you go through everything that needs oil and pick; only so that you say that all buildings get oil, and whatever's left goes to units; or vise versa. It would suck going through an army and every oil-needing building deciding how much they get every turn. Of course this is only if you have a shortage, such as during a war.

Thanks again for your work on this. When you get the bugs worked out I would love to test this for you to help balance it out. Are you going to get the AI to use it correctly too? I'd think that would be necessary for this to be truly successful.

-Smitty
 
well I guess I should mod also AI for this but It won't be so easy I guess. For sure I could start increasing heavyness (so the importance that it has for AI) of OIL between bonuns. And than I should study a funtion like:

getOILReserve... if TotalOilConsumption is > of the 60% of OIL Reserve (for ex.) AI should start considering to ask tributes or to invade.

In reality before this I should implement OIL commerce, like Unit of OIL for Gold... or the AI will have WAR as only chance of getting OIL.

Well it's a long work but step by step...
let's say the 1st one is done. the basic structure is complited now we can start with rest....
 
Back
Top Bottom