The Modding Q&A Thread

Code:
	getDefenderCombatValues(*pDefender, pPlot, iAttackerStrength, iAttackerFirepower, iDefenderOdds, iDefenderStrength, iAttackerDamage, iDefenderDamage, &cdDefenderDetails);

[COLOR="Red"]	iAttackerStrength = iAttackerStrength * std::max(10, (GET_PLAYER(getOwnerINLINE()).getStability() + 100)) / 100; //LuKo
	iDefenderStrength = iDefenderStrength * std::max(10, (GET_PLAYER(pDefender->getOwnerINLINE()).getStability() + 100)) / 100; //LuKo[/COLOR]
	
	int iAttackerKillOdds = iDefenderOdds * (100 - withdrawalProbability()) / 100;

I've created above changes but nothing has changed (except maybe sometimes unit dying in combat respawns and is ready to attack again).

[EDIT]:
Woohoo! I've made it! I've changed damage instead of strength and everything is OK :) Confusing that AttackerDamage means damage dealt TO attacker but... :)
 
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.
I doubt it. C doesn't know booleans as a primitive data type, all conditions result in 0 or 1 respectively, that's why you can go on manipulating them with integer operations.

Python on the other hand knows booleans. Maybe someone was smart enough to define multiplication on booleans, but if not, it'll result in an error.
 
civ-addicted, yeah thats correct. The value True can be used instead of the integer value 1 in mathematical calculations. Likewise the value False is equals zero.

But you can lose the parenthesis. Most of the time you can.

Also, you can use the value None instead of -1. Python is very handy that way.
 
J. pride, my script is kinda clumsy and if you wanna be able to add culture to more spawning cities I could upgrade the Barbs module for you, so that this would be easily achieved. Extremely easily, even.

edit: This is how to augment the foundCity() method:
Spoiler :
Code:
        def foundCity(self, iCiv, lCity, name, iTurn, iPopulation, iUnitType, iNumUnits[COLOR="Red"], iCulture=-1[/COLOR]):
                if ((iTurn == getTurnForYear(lCity[2]) + lCity[3]) and (lCity[3]<10)): # conversion from years - edead
                        #print self.checkRegion(tUr)
                        bResult, lCity[3] = self.checkRegion(lCity)
                        if (bResult == True):
                                pCiv = gc.getPlayer(iCiv)
                                pCiv.found(lCity[0], lCity[1])
                                self.getCity((lCity[0], lCity[1])).setName(name, False)
                                if (iPopulation != 1):
                                        self.getCity((lCity[0], lCity[1])).setPopulation(iPopulation)
                                if (iNumUnits > 0):
                                        self.makeUnit(iUnitType, iCiv, (lCity[0], lCity[1]), iNumUnits, 0)
[COLOR="Red"]                                if iCulture:
                                        self.getCity((lCity[0], lCity[1])).changeCulture(iCiv, iCulture, True)[/COLOR]
                                return True
                        if (bResult == False) and (lCity[3] == -1):
                                return False
With these edits in place, you can (optionally) add a culture value to any city spawn line:
Code:
		self.foundCity(iIndependent2, lWarsaw, "Warszawa", iGameTurn, 3, con.iCrossbowman, 3[COLOR="Red"], 100[/COLOR])
Note that the previously posted code is not needed with this setup.
 
Thanks again Baldyr :salute:, I have successfully added the module; this makes it even easier to edit the culture
 
You only added the code marked with red, right? You didn't add the whole thing I posted, I hope. (Also, there are two edits, don't miss the first line!)
 
Good, now you get to test my work. :D No warranty included.
 
civ-addicted, yeah thats correct. The value True can be used instead of the integer value 1 in mathematical calculations. Likewise the value False is equals zero.

But you can lose the parenthesis. Most of the time you can.

Also, you can use the value None instead of -1. Python is very handy that way.

Spoiler :
Python is handy in every way:lol:
 
Not to be overly critical or anything, but the current foundCity() method is fairly cluttered. You should be able to get away with something along these lines:
Code:
        def foundCity(self, iCiv, lCity, name, iTurn, iPopulation, iUnitType, iNumUnits, iCulture=-1):
		iX, iY, iYear, dummy = lCity
                if iTurn == getTurnForYear(iYear):
                        if self.checkRegion(lCity)[0]:
                                pCity = gc.getPlayer(iCiv).found(iX, iY)
                                pCity.setName(name, False)
                                if iPopulation:
                                        pCity.setPopulation(iPopulation)
                                if iNumUnits:
                                        self.makeUnit(iUnitType, iCiv, (iX, iY), iNumUnits, 0)
                                if iCulture:
                                        pCity.changeCulture(iCiv, iCulture, True)
This should be easier on the eyes and could also be good for learning how to mod with Python scripting.
 
civ-addicted, yeah thats correct. The value True can be used instead of the integer value 1 in mathematical calculations. Likewise the value False is equals zero.

But you can lose the parenthesis. Most of the time you can.

Also, you can use the value None instead of -1. Python is very handy that way.
Say about Python what you will, it really is programmer-friendly.
 
That would be a way to do it, yes.
 
Thanks :) Do anyone have any idea what could cause some tribal villages to not disappear when visited (but not working anymore so it's rather graphic glitch)? I assume it can be connected with merging my mod with Next War scenario because I think once there was a village in Portugal but now my warriors see there just a city ruins looking like an arcology shielding.
 
No idea. Goody huts count as a tile improvement graphic-wise iirc, so maybe you messed with their order in the XML files?
 
I've changed the order to match Next War's. I assume the order could be stored somewhere in RFC files?
The order of the XML entries need to match the mod.

How to make the last unit in city (nearly) immune to plague? And make damage (more) unhealthiness-dependant? And make cities with +8 health immune to plague? And that's it... for now :p
How? You learn some practical Python, you evaluate the Plague module and edit it accordingly. What's the problem? :D
 
How? You learn some practical Python, you evaluate the Plague module and edit it accordingly. What's the problem?

Hmmm... I can see a few. Probably one day I will fix the problem by "hard way"- trying, failing and trying again. That's why every hint is welcome.

[EDIT]: Where is stored data allowing creating bigger cities by later civs?
 
Hi Everyone!

Boy oh boy do I have an issue with coding events! ;)

Basically in my mod I've added in a unit called the "True Cross", which is a unit which only spawns ONE TIME, when then Crusaders capture Jerusalem, and instead of giving a relic like in the past, this time it should give the iTrue_Cross unit. But every time I start up a game, I get my new event pop-up, but I don't receive the True Cross unit, I just receive a relic, like in the past! This has led me to believe that I have not altered all the files I need to, to have a new event. So I've attached all the files I've altered in my pursuit to get this new event.

Oh and the event is called, "TRUE_CROSS_RECOVERED"

Thank You for anybodies help! :)
 

Attachments

  • True Cross Event.rar
    199.3 KB · Views: 44
Okay, n00b question: How do I make it so I can mouse over a tile and get the coords?
 
Top Bottom