1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

The Modding Q&A Thread

Discussion in 'Rhye's and Fall Modmods' started by Leoreth, Apr 2, 2011.

  1. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,043
    Gender:
    Male
    Location:
    Leblanc
    Hey everyone,

    I noticed there were quite a lot questions regarding modding RFC or its modmods the last days. To avoid cluttering the respective modmod's thread or this subforum, I took the initiative to create this thread so
    • we save space in the forum and the modmod threads
    • questions don't get lost in some discussions
    • repeating questions don't have to be anwered twice

    This is not "my" thread, so of course everyone can answer here if he likes.
     
  2. Cosmos1985

    Cosmos1985 Chieftain

    Joined:
    Sep 20, 2008
    Messages:
    631
    Location:
    Aarhus, Denmark
    Excellent idea. I by the way also was thinking about whether it would be an idea to have one thread dedicated to proposals/suggestions - a lot of stuff written in the respective modmod-threads are really just general idea, and while that's of course a great thing, to have new idea and brainstorming en masse, maybe it would be better to have all that focused in one thread, instead of randomly spread out. This would also serve the same purpose, of keeping the modmod-threads focused.
    But this is just me rambling off-topic really :D

    On-topic: Can anybody show me how to toggle the thing off where already existing cities are destroyed if build at or around the spawn tile for the new civ? Also, in which file(s) is tech speeds regulated - the bonusses (or penalties) that certain civs get?
     
  3. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,043
    Gender:
    Male
    Location:
    Leblanc
    That's right, but I'd like to keep this thread free from ideas because the subsequent enthusiasm and brainstorming would clutter this thread as well.

    On to your questions - I'm no expert on the spawn mechanics and tend to avoid touching them, but it seems the point you should attack here is the bDeleteEverything bool in RiseAndFall.initBirth():
    Code:
    [COLOR="Red"]                                bDeleteEverything[/COLOR] = False
                                    pCapital = gc.getMap().plot(tCapital[0], tCapital[1])
                                    if (pCapital.isOwned()):
                                            if (iCiv == iHuman or not gc.getPlayer(iHuman).isAlive()):
                                                    if not (pCapital.isCity() and pCapital.getPlotCity().isHolyCity()):
                                                            [COLOR="Red"]bDeleteEverything[/COLOR] = True
                                                            print ("bDeleteEverything 1")
                                            else:
                                                    [COLOR="Red"]bDeleteEverything[/COLOR] = True
                                                    for x in range(tCapital[0] - 1, tCapital[0] + 2):        # from x-1 to x+1
                                                            for y in range(tCapital[1] - 1, tCapital[1] + 2):	# from y-1 to y+1
                                                                    pCurrent=gc.getMap().plot(x, y)
                                                                    if (pCurrent.isCity() and (pCurrent.getPlotCity().getOwner() == iHuman or pCurrent.getPlotCity().isHolyCity())):
                                                                            [COLOR="Red"]bDeleteEverything[/COLOR] = False
                                                                            print ("bDeleteEverything 2")
                                                                            break
                                                                            break
                                    print ("bDeleteEverything", bDeleteEverything)
                                    if (not gc.getMap().plot(tCapital[0], tCapital[1]).isOwned()):
                                            if (iCiv == iNetherlands or iCiv == iPortugal or (iCiv == iRome and utils.getReborn(iCiv) == 1) or iCiv == iByzantium): #dangerous starts
                                                    self.setDeleteMode(0, iCiv)
                                            self.birthInFreeRegion(iCiv, tCapital, tTopLeft, tBottomRight)
                                    elif ([COLOR="Red"]bDeleteEverything[/COLOR]):
                                            for x in range(tCapital[0] - 1, tCapital[0] + 2):        # from x-1 to x+1
                                                    for y in range(tCapital[1] - 1, tCapital[1] + 2):	# from y-1 to y+1
                                                            self.setDeleteMode(0, iCiv)
                                                            #print ("deleting", x, y)
                                                            pCurrent=gc.getMap().plot(x, y)
                                                            #self.moveOutUnits(x, y, tCapital[0], tCapital[1])
                                                            for iLoopCiv in range(iNumTotalPlayers+1): #Barbarians as well
                                                                    if (iCiv != iLoopCiv):
                                                                            utils.flipUnitsInArea(tTopLeft, tBottomRight, iCiv, iLoopCiv, True, False)
                                                            if (pCurrent.isCity()):
                                                                    pCurrent.eraseAIDevelopment() #new function, similar to erase but won't delete rivers, resources and features()
                                                            for iLoopCiv in range(iNumTotalPlayers+1): #Barbarians as well
                                                                    if (iCiv != iLoopCiv):
                                                                            pCurrent.setCulture(iLoopCiv, 0, True)
                                                            pCurrent.setOwner(-1)
                                            self.birthInFreeRegion(iCiv, tCapital, tTopLeft, tBottomRight)
                                    else:                                
                                            self.birthInForeignBorders(iCiv, tTopLeft, tBottomRight, tBroaderTopLeft, tBroaderBottomRight)
    Making sure it's never set to True should avoid the gams starting "deleteMode", which erases the units and cities.

    However, it would be wise to put another system into place instead, because I really don't know what happens if you try to spawn units on a foreign city plot (Python exception or crash, likely). So I suggest to flip all cities around the spawn plot instead, which can best be done using utils.flipCity(...).

    For the research modifiers, they're in C++. You can find them in CivInfos::getResearchPercentByID().
     
  4. Cosmos1985

    Cosmos1985 Chieftain

    Joined:
    Sep 20, 2008
    Messages:
    631
    Location:
    Aarhus, Denmark
    Sure, I just meant that that also could be an idea, to create SUCH a thread, for the same purpose. And thanks a lot for your answer, gonna try it out and see if I can get it to work.
     
  5. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,043
    Gender:
    Male
    Location:
    Leblanc
    I'm interested to see how it turns out :)
     
  6. J. pride

    J. pride Chieftain

    Joined:
    Feb 23, 2011
    Messages:
    788
    What do you need to modify in order to add an independent city spaw. (similar to Kiev or Lhasa)
     
  7. Cosmos1985

    Cosmos1985 Chieftain

    Joined:
    Sep 20, 2008
    Messages:
    631
    Location:
    Aarhus, Denmark
    You were absolutely right in that it needs some more... finesse :) It succesfully keeps the city from being destroyed on spawn, but the changes also meant that when a city is not prebuilt, the new civ dont flip the tiles in their starting zones as they should, and so end up being exiled. Also, as the turks, when I started as them - autoplaying untill then - all their cities had city ruins as graphic. No gameplay problem, just.. yeah - it wasn't pretty. But of course it's a low priority thing, it's only really important for the Byzantines, and that seems to be wad. People who want to cheat can do it anyway, with WB, so... yeah. But thx for the help anyway - I have a game with a prebuilt Amsterdam now, so I'm a happy camper.
     
  8. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    You could use PyScenario, provided that you use the RFC Epic/Marathon mod-mod.

    Other than that, you can mimic what Rhye does in the Barbs.py file in order to add unit/city spawns.
     
  9. J. pride

    J. pride Chieftain

    Joined:
    Feb 23, 2011
    Messages:
    788
    I was talking about DOC; could u elaborate on to which files i would need to make the changes?

    Thnx
     
  10. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    I'm guessing that Dawn of Civilization uses the same module for its city spawns, as would most mod-mods.
     
  11. J. pride

    J. pride Chieftain

    Joined:
    Feb 23, 2011
    Messages:
    788
    I tried modifying the Barbarian.py but to no avail. Is there any other file that I need to change inorder to add an indie spawn
     
  12. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    You need to edit it correctly, or it won't work. If you enable Python exceptions you should be getting error messages. These exceptions would be the reason it isn't working for you - whether or not you're aware of them.
     
  13. Jarkov

    Jarkov Chieftain

    Joined:
    Oct 23, 2010
    Messages:
    158
    There is one list in Barbarian.py that needs to be modified (the one that says (among other things) where the city will be), and a function that actually spawns the cities. Apart from that, no further modding should be necessary.
     
  14. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Well, the module should be named Barbs.py and the coordinates and name are defined as tuple values assigned to constant variables. And the actual spawning action is achieved with a method invocation, using the constant as one of its parameters. This is in turn is found within the body of a Barbs class instance method. Just so that we're clear about this.

    Perhaps J. pride could post his edits for the rest of us to see? Any obvious mistakes would be easy enough to spot.
     
  15. The Turk

    The Turk Chieftain

    Joined:
    Jun 25, 2008
    Messages:
    2,189
    Gender:
    Male
    Location:
    Canada
    Hi Everyone,

    First off, I just want to say what a great thread this is! :)


    Anyway, can someone please tell me what wrong with the text in the red box! I cannot understand why that castle will not spawn in Damascus!

    Thank You!
     

    Attached Files:

  16. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,043
    Gender:
    Male
    Location:
    Leblanc
    This looks like an odd place for this part of the code. Which method is it?
     
  17. civ-addicted

    civ-addicted Chieftain

    Joined:
    Aug 8, 2009
    Messages:
    852
    Location:
    The City of the Lion
    I think it should be self.getTurnForYear(1096)
    python is pretty picky about that
     
  18. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    The Turk, your indentation is whacked up. You have one level too much, to be exact, so deduct 8 blank spaces from every line.

    Also, on the third line, it should probably be iNumMajorPlayers. :confused:
     
  19. Leoreth

    Leoreth 心の怪盗団 Moderator

    Joined:
    Aug 23, 2009
    Messages:
    33,043
    Gender:
    Male
    Location:
    Leblanc
    You're right, the comment line is really confusing here.

    There's no iNumMajorPlayers in SoI, and the ID of the first independent civ equals iNumPlayers.
     
  20. Baldyr

    Baldyr "Hit It"

    Joined:
    Dec 5, 2009
    Messages:
    5,530
    Location:
    Sweden
    Yeah, makes sense. I never actually looked at SoI... :p
     

Share This Page