Modder's Guide to A New Dawn

Maybe I should ask this here too, so...

I tried to change how Palace works: You don't start with one but has a tech requirement and you have to build it.
But once I (or the AI) settle the first city there is an error appearing on screen. Its not fatal but annoying.


I think I have found the source of the error. In RevEvents.py I've found this code:

Code:
def onCityBuilt( argsList ):
        'City Built'
        city = argsList[0]

        RevData.initCity( city )

        pPlayer = gc.getPlayer( city.getOwner() )

        if( pPlayer.isBarbarian() ) :
            city.setRevolutionIndex( int(.4*RevOpt.getAlwaysViolentThreshold()) )
            city.setRevIndexAverage(city.getRevolutionIndex())
            return

        if( not city.area().getID() == pPlayer.getCapitalCity().area().getID() ) :
            city.setRevolutionIndex( int(.35*RevOpt.getInstigateRevolutionThreshold()) )
        else :
            city.setRevolutionIndex( int(.25*RevOpt.getInstigateRevolutionThreshold()) )
        city.setRevIndexAverage(city.getRevolutionIndex())
      
        revTurn = RevData.revObjectGetVal( pPlayer, 'RevolutionTurn' )
        if( not revTurn == None ) :
            if( pPlayer.getNumCities() < 4 and game.getGameTurn() - revTurn < 25 ) :
                relID = pPlayer.getStateReligion()
                if( relID >= 0 ) :
                    if( LOG_DEBUG ) : CvUtil.pyPrint("Rev - New rebel city %s given rebel religion"%(city.getName()))
                    city.setHasReligion( relID, True, False, False )

When I tagged out this part of the code no error occurred when settling the first city.
I am a noob for python but I understand that this code is checking for the civ's capital which does not exist.
So how could it be changed without breaking the original purpose of the code but give no error message for settling first city? :confused:
 
The test to see if a civilization does not have a capital is if pPlayer.getCapitalCity().isNone(). It's used in CvRandomEventInterface.py.

But I don't think you can do this test on the same line as the pPlayer.getCapitalCity().area().getID() test or you will still get an error if the civilization doesn't have a capital. So you need a nested series of if-else statements. That way, if the civilization doesn't have a capital, then the game never even asks for the nonexistent capital's area and there should be no error messages.

I think this would work:
Code:
      if pPlayer.getCapitalCity().isNone():
        city.setRevolutionIndex( int(.35*RevOpt.getInstigateRevolutionThreshold()) )
      else :
        if ( not city.area().getID() == pPlayer.getCapitalCity().area().getID() ) :
            city.setRevolutionIndex( int(.35*RevOpt.getInstigateRevolutionThreshold()) )
        else :
            city.setRevolutionIndex( int(.25*RevOpt.getInstigateRevolutionThreshold()) )
      city.setRevIndexAverage(city.getRevolutionIndex())

That first .35 can be adjusted up or down depending on how high you want the revolution index to start. The current InstigateRevolutionThreshold is 1000, so in games with a Palace, the RevIndex starts at 250 on the Palace's continent and 350 off of it.
 
I remember that it was possible to read the pre-compiled dll code somewhere but I don't find it. What's the link for it?

http://svn.code.sf.net/p/anewdawn/code/Trunk/Sources/ has all the source files that make up the DLL. If you download the SVN version you should get a Sources folder that has all those files in it. I'm not sure if you can download that version without a SourceForge account.
 
CvTechChooser.py looks like it should work. placeTechs (starting at line 317) does the blocks and places the tech icons. Try changing TEXTURE_SIZE in line 9 and see if that gets you the bigger icon.

I also need to fix that black question mark on Code of Laws. (It's supposed to be the Can Adjust Science slider.)
 
@45
Is it intended and necessary that OverrideResourceBuilding tag relates to building <Type> instead of <BuildingClass> ?
If ever anyone wants to use this tag on a building that has a UB replacement than it won't work.
 
Can a tech belong to none of the eras?
I want to create one or more techs that can be acquired by some special means (events, buildings, etc.) but that sholud be the ONLY way.
And I'm not just talking about iCost -1. My problem is that if I set the era to Ancient you get the tech if starting in a later era or a civ spawned from barbarians or through revolutions. OTOH if I set the era to Future than acquiring the tech sends the civ to the Future era.
 
Can a tech belong to none of the eras?
I want to create one or more techs that can be acquired by some special means (events, buildings, etc.) but that sholud be the ONLY way.
And I'm not just talking about iCost -1. My problem is that if I set the era to Ancient you get the tech if starting in a later era or a civ spawned from barbarians or through revolutions. OTOH if I set the era to Future than acquiring the tech sends the civ to the Future era.

Mmm. I remember thinking about the same problem years ago on another project of mine but I don't remember if or how I solved it. I'll have a look at my old archive and maybe I can come up with something.
 
Another question:
There is a building tag: iLineOfSight
I was expecting that a building with <iLineOfSight>1</iLineOfSight> would increase the line of sight of the city but no such thing happened. I tried it several times, also with the numbers 2, 10, 100 and 1000 but still nothing. However it the tag DOES appear in the game with a proper text saying "Will increase ine of sight" or something similar.
Is this tag broken or disabled?
 
Another question:
There is a building tag: iLineOfSight
I was expecting that a building with <iLineOfSight>1</iLineOfSight> would increase the line of sight of the city but no such thing happened. I tried it several times, also with the numbers 2, 10, 100 and 1000 but still nothing. However it the tag DOES appear in the game with a proper text saying "Will increase ine of sight" or something similar.
Is this tag broken or disabled?

It looks like it's never been used. I can see the tag is only present in some units (set to 0) and in no building at all. Code looks correct to me, but I haven't tested it.
 
Can a tech belong to none of the eras?
I want to create one or more techs that can be acquired by some special means (events, buildings, etc.) but that sholud be the ONLY way.
And I'm not just talking about iCost -1. My problem is that if I set the era to Ancient you get the tech if starting in a later era or a civ spawned from barbarians or through revolutions. OTOH if I set the era to Future than acquiring the tech sends the civ to the Future era.

I didn't find any hint in my archive but looking at some old post you might get some advice. It looks like you can disable researching a tech with <bDisable>1</bDisable> tag. Never actually tried, IIRC, so I'm not sure how it works. Maybe worth checking it.
 
I didn't find any hint in my archive but looking at some old post you might get some advice. It looks like you can disable researching a tech with <bDisable>1</bDisable> tag. Never actually tried, IIRC, so I'm not sure how it works. Maybe worth checking it.
Oh, thx! I'll try that.
 
Any idea why I get this error?
upload_2018-10-31_19-57-30.png

I'm working on my own custom modmod and changed the name of the folder.
Also, AIAutoplay doesn't work.
I'm updating the files manually comparing AND2 files with my modified folder.
What am I missing? :(
 
I didn't find any hint in my archive but looking at some old post you might get some advice. It looks like you can disable researching a tech with <bDisable>1</bDisable> tag. Never actually tried, IIRC, so I'm not sure how it works. Maybe worth checking it.
I tried it but that didn't do it.
I think that's only good to disable clicking on the tech.
 
Any idea why I get this error?
View attachment 507098
I'm working on my own custom modmod and changed the name of the folder.
Also, AIAutoplay doesn't work.
I'm updating the files manually comparing AND2 files with my modified folder.
What am I missing? :(
I think I have found the cause of the above error.

The code Vokarya gave me seems to interefere with something in the new update.
Code:
      if pPlayer.getCapitalCity().isNone():
        city.setRevolutionIndex( int(.35*RevOpt.getInstigateRevolutionThreshold()) )
      else :
        if ( not city.area().getID() == pPlayer.getCapitalCity().area().getID() ) :
            city.setRevolutionIndex( int(.35*RevOpt.getInstigateRevolutionThreshold()) )
        else :
            city.setRevolutionIndex( int(.25*RevOpt.getInstigateRevolutionThreshold()) )
      city.setRevIndexAverage(city.getRevolutionIndex())

When I reversed this code to the origianal one of AND2 I no longer get the above message... but get the previous one when founding the first city and not having a capital :undecide:
 
Top Bottom