Modmodding Q&A Thread

Code:
# attitude stability
    
    iRelationStability += calculateSumScore(lAttitudes) / 2
    iRelationStability += calculateSumScore(lAttitudes, 2) / 2
    iRelationStability += calculateSumScore(lAttitudes, 3)

Can somebody please explain me this code?
 
Code:
# attitude stability
  
    iRelationStability += calculateSumScore(lAttitudes) / 2
    iRelationStability += calculateSumScore(lAttitudes, 2) / 2
    iRelationStability += calculateSumScore(lAttitudes, 3)

Can somebody please explain me this code?

IIRC calculateSumScore adds up all of the values in lAttitudes that meet the given absolute value threshold, default being 1.
 
Sorry, not sure I understood. First line -- adding all the +/- 1 attitude? Second line adding +/- 2 attitudes, and then for +/- 3? Meaning if someone is -5 against me -- he will not be counted in attitude score determination? My main problem is the second argument of Sumscore function... If it represents a threshold -- in which way mathematically does it work?
 
Sorry, not sure I understood. First line -- adding all the +/- 1 attitude? Second line adding +/- 2 attitudes, and then for +/- 3? Meaning if someone is -5 against me -- he will not be counted in attitude score determination? My main problem is the second argument of Sumscore function... If it represents a threshold -- in which way mathematically does it work?

The first line sums all values >= 1, the second line >= 2, and the third 3

So if you have a -5 it's absolute value is 5, which is >= 1, 2 and 3, meaning it's added on all 3 lines. I'm not sure how Python handles uneven integer division so let's assume for the sake of this example 5 / 2 = 2, we'd get -2 + -2 + -5 = -9.
 
I don't have the code in front of me but iirc it counts the attitude modifiers that exceed the given threshold in the negatives or positives, instead of adding them.
 
Where is the wonder limit stored? I want to try some fun one-city challenges and I'd like to disable the wonder limit for OCCs.
 
It is in CvCity.cpp, at CvCity::isWorldWondersMaxed().

However, if you enable the OCC option it should already remove the limit for human players. You can enable that option in the WB. The option only effects the human player, so it doesn't matter that it is enabled during autoplay. It is not worth making changes so it is enabled from loading the scenario, as that has no effect.

EDIT:
Ignore the wonder limit indicator (next to the city name in the cityscreen) if you do this. It still displays the original limit, but you can still build new wonders.
 
Is there any way to trigger a civ rebirth through the python console? For example, the Egyptian one in the middle ages. Thanks in advance
 
What where the changes that that made Orthodox spread correctly before the Reformation and that made Catholicism found more often and where they simple enough for me to slap into 1.14? I looked at Religions.py but I don't understand at all
 
Religion spread was significantly reimplemented in the DLL, I think that was after 1.14.
 
As someone who learned coding with C++ I have always had a deep suspicion for Python, so I'd like to ask for confirmation, is this code:

Code:
if iPlayer == iPolynesia or iVikings or iIndonesia or iNetherlands:

really 100% certainly just a shorter more elegant but otherwise functionally identical version of this:

Code:
if iPlayer == iPolynesia or if iPlayer == iVikings or if iPlayer == iIndonesia or if iPlayer == iNetherlands:

?
 
As someone who learned coding with C++ I have always had a deep suspicion for Python, so I'd like to ask for confirmation, is this code:

Code:
if iPlayer == iPolynesia or iVikings or iIndonesia or iNetherlands:

really 100% certainly just a shorter more elegant but otherwise functionally identical version of this:

Code:
if iPlayer == iPolynesia or if iPlayer == iVikings or if iPlayer == iIndonesia or if iPlayer == iNetherlands:

?
I think what you're looking for is
Code:
if iPlayer in [iNetherlands, iIndonesia, iVikings, iPolynesia]:
 
The second is not valid Python at all, but I suppose you mean:
Code:
if iPlayer == iPolynesia or iPlayer == iVikings ...
If so the shorthand equivalent is:
Code:
if iPlayer in [iPolynesia, iVikings, ...]:

Your first example will always evaluate to true. Consider that iVikings etc. are integer values. In Python, an integer always evaluates to true unless it is zero. So the "or iVikings" parts already make the statement true.
 
Code:
data.iSeed % 4

What does that mean exactly? What does that sinister 4 plan to do with the percentage sign to that pure unsuspecting random seed?
 
In Python (and many other languages), % is the modulo operator. In other words, x % y computes the remainder of dividing x / y as integers.

This is useful when you want to quickly have a random set of y different cases. For example, when you compute x % 4, the results are in the range [0, 1, 2, 3]. So if you want something to happen in 25% of all games, seed % 4 == 0 is one way to do it. Likewise, seed % 4 == 1 gives you another case with 25% probability that never occurs at the same time as the previous thing.

Why is all of this derived from the same seed instead of rolling a random number each time? Multiple reasons: sometimes you want multiple mutually exclusive outcomes, sometimes you need consistency for those cases at multiple points in time (so you don't have to store another randomly generated number), and random number generation is more computationally expensive.
 
How would I go about making the corporations screen be able to scroll?
 
You could take a look at the religion advisor. The religion list is horizontally scrollable. I assume you want to make that part of the advisor scrollable.
 
Related question, I've been trying to get the scoreboard on the main screen interface scrollable but have been having trouble. Do you know of a good example I could base my code off of?
 
Related question, I've been trying to get the scoreboard on the main screen interface scrollable but have been having trouble. Do you know of a good example I could base my code off of?

Earth 2010 has one IIRC.
 
Back
Top Bottom