The Modding Q&A Thread

Have you compiled DLL?

Ooops...

I have read about modifying DLL just now. Now I understand, what I doing wrong - I did not compiled the new DLL.

I tried to compile this file with Dev-C++ or Microsoft Visual C++ 2008 Express Edition, but I cannot do this correctly. Maybe is too hard for me :blush:
 
Thanks, edead!

OK, I've got tools now so I can keep asking questions how to complete my evil plan. Where is number of soldiers count (the one from statistics page)? And how can I change power of unit in combat, depending on stability of owner?

Number of soldiers on the statistics page = your power * 1000 :)
Power is just the sum of iPower of your techs, buildings, wonders and most of all - units.
Each turn power is recalculated and saved with CvPlayer::changePower()
You can get it using CvPlayer::getPower()

To complete your evil plan simply modify the CvPlayer::getPower() to your liking.
Add some conditions there, like:
Code:
if (getStability() < -20) return (m_iPower * 90 / 100);
if (getStability() > 20) return (m_iPower * 110 / 100);
return m_iPower;

Or something more fluid, based on some math formula...
This will affect all internal game code that relies on getPower, i.e. the AI.
 
Guys,
I think I have found the problem. Can anybody tell me whats wrong with this python exception.
 

Attachments

  • Civ4ScreenShot0027.JPG
    Civ4ScreenShot0027.JPG
    101.3 KB · Views: 83
Well, you haven't given the right arguments to changeCulture().

The required arguments of a method are called signature, in this case it's PyCity.changeCulture(int iPlayer, int iNewValue, bool bPlots).

iPlayer specifies the player whose culture you want to change (remember, cities can have cultures of multiple players).
iNewValue is the new amount of culture you want to set it to.
bPlots requires a boolean and if I get it right this decides if the game shall be notified to update the surrounding plots (i.e. in case of a border expansion). I suggest you set it as True.

You can find these signatures by looking into the C++ code or using the modiki.
 
OK, but that was the easy one :P Thanks anyway. But now how to increase power of unit in combat?

Wait, so you want to modify combat strength, not power?
Well, it's doable as well, though a bit harsh gameplay wise and may be more complicated depending on how you want it to work and look.

My way of doing it (I used it as "Luck" factor, though it's disabled in SoI):
Look at CvUnit::resolveCombat, there are two variables there, iAttackerStrength and iDefenderStrength. Just modify them according to your formula. To get the stability, remember to use:
GET_PLAYER(getOwnerINLINE()).getStability() - for the attacker
GET_PLAYER(pDefender->getOwnerINLINE()).getStability() - for the defender

If you do it before the Python callback (marked as //Added ST), the bonus should be displayed in the combat odds tooltip. If you do it after the callback, the bonus should be hidden.

The above solution only affects combat, so units' strength will normally show base strength, at least until you check combat odds.
 
Im a bit confused; does this code make sense.
PyCity.changeCulture(int iIndependent2, int i100, bool b 65,52).

Do I insert this into riseandfall as i did before or does it go somewhere else. Im sorry im a real noob at this

You can find these signatures by looking into the C++ code or using the modiki.
Is this for future reference or do I have to find something for this particular case
 
Im a bit confused; does this code make sense.
No, it makes no sense whatsoever. You'd honestly be better off letting someone else do your coding for you.

I'm not trying to be mean, but the problem here seems to be that you only want this one task to be done - not to learn how to do programming. But you need to understand what you're doing in order to complete the task, so you might as well study programming and get the job done only afterwards.

You could easily waste a full weeks work time on this - and you might not figure it out anyway. Because you're just guessing. Know that 5 full days of study would be more than enough to learn how to do this for real, so the choice is really yours. You can do it the dumb way - or the smart way.
 
No offense taken, I am actually thankful for all ur help.
Currently, I don't have the time (maybe later I will try to learn) but if I just have to add a little snippet can u please tell me what it is. If it's Alot of work then can u breifly describe where I have to make the changes.
 
J. pride, we're all about helping here, so please post what you already have and describe exactly what you need to do. Someone knowledgeable will be able to fill in the missing code for you so that you get the job done. If you don't have the time to learn, then that is all that matters. It will be way less work than to try and explain what to do. (Even more true the longer the script, even i I suspect it will only take a single line of code in this particular case.)
 
Currently, I have to start from scratch as a few posts back Leoreth just explained to me what arguments to use. As you know I wanted to expand the culture of an indie city; i used the code that u guys provided at first but I got several Python exceptions (posted above). I think i need a new code to make it work; Leoreth posted something but i cant seem to make sense of it
 
You already spawned Warsaw, right? Well, post that code then. And we'll add what you need for the culture thing.

No need for you to understand any of it or make any sense of what someone else said or posted. Because I'm fairly certain that you could never figure it out yourself anyway. This is programming, not going at it blindly.
 
Code:
lWarsaw = [65, 52, 860, 0] #207

Code:
		self.foundCity(iIndependent2, lWarsaw, "Warszawa", iGameTurn, 3, con.iCrossbowman, 3)

These are the 2 codes I put in Barb.py to spawn Warsaw. The Warsaw spawn works perfectly
 
Try this:
Code:
		self.foundCity(iIndependent2, lWarsaw, "Warszawa", iGameTurn, 3, con.iCrossbowman, 3)
		if iGameTurn >= getTurnForYear(860):
			pCity = gc.getMap().plot(65, 52).getPlotCity()
			if pCity:
				pCity.changeCulture(iIndependent2, 100, True)
 
Thanks Baldyr, It work now. I appreciate everybody's help.

It's pretty funny that what i couldn't do in an hour was done in less then five minutes
 
Thanks Baldyr, It work now. I appreciate everybody's help.

It's pretty funny that what i couldn't do in an hour was done in less then five minutes
A quick explanation of what's going on here:

Arguments need to be of certain data types, and they are noted in the method's signature before each entry. In this case, there were two:

int means an integer. iIndependent stores an integer (iirc it's 28), and 100 is one as well, so they're valid arguments.
bool means a boolean value, i.e. either True or False.

In either case, you don't have to repeat the data types when calling a function - they're only there for you to see which kind of information you have to enter.
 
Out of pure curiosity (i can't test it myself atm)
Is it possible in python to write something like
Code:
2*(condition)
to get 2 if the condition is true, and 0 otherwise. I know that it's possible in C.
It might be useful to shorten codes.
 
Back
Top Bottom