Announcement

Collapse
No announcement yet.

prohibit building construction

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • prohibit building construction

    I'm wondering is it possible to specify which building could be built or not in certain city using python, since I want some kind of buildings can only be built when there's particular resource near the city. \

    So probabally, I need to check whether there's a tile containing that resource around the city first, and if not i should prohibit the construction of the building.

    Is there anybody know where and how i could add the code?

  • #2
    Thats going to be hard to do as Buildability is handled by an API call "isBuildible" or something like that.

    So your going to need to cheat by using the Python code to create an instance of a whole new building which you will design. This new building will be impossible to get by any means other then the Python code placing it in a City. Then the Building you want to restrict will require this new building as a prerequiste like Aquaduct for Hanging Gardens.
    Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest. - Thus spoke Zarathustra, Fredrick Nietzsche

    Comment


    • #3
      Thanks!
      I just found a func in cvGameUtils.py:

      def canConstruct(self,argsList):
      pCity = argsList[0]
      eBuilding = argsList[1]
      bContinue = argsList[2]
      bTestVisible = argsList[3]
      bIgnoreCost = argsList[4]
      return False

      def cannotConstruct(self,argsList):
      pCity = argsList[0]
      eBuilding = argsList[1]
      bContinue = argsList[2]
      bTestVisible = argsList[3]
      bIgnoreCost = argsList[4]
      return False
      Hope they are useful, but they all return false, suppose there's other codes controling can or cannot construct

      Comment


      • #4
        I belive thouse are just helpers, the logic is controled by the API call under the CvCity

        Get info about the API here

        Gabung bersama DEPE4D situs Judi Online terpercaya di indonesia menyediakan sarana deposit pulsa dan e-money cukup 1 user id untuk semua permainan judi online.


        you need to call

        BOOL canConstruct(INT iBuilding, BOOL bContinue, BOOL bTestVisible, BOOL bIgnoreCost)
        bool (int eBuilding, bool bContinue, bool bTestVisible, bool bIgnoreCost)

        basicaly querrying the city if it can or can not build a building.
        Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest. - Thus spoke Zarathustra, Fredrick Nietzsche

        Comment


        • #5
          Just curious -


          Couldn't you use this "" under each building in Civ4buildinginfos.xml to specify which bonus need to be nearby?

          I'm not sure, since this line doesn't get used at all by any building in the game.

          Comment


          • #6
            hi, do you mean these 2 lines:
            NONE

            Yes, just because the game haven't used them, I fogot to check the XML. Thanks for reminding!

            though, I think it's not enough, since the required resource specified here could be anywhere within country's border. But what I want is limit it to city's working area. Like the Ironwork in CIV3, which needs iron and coal near the city to build. Thank you anyway.

            Comment


            • #7
              eh, I tried to use cannotConstruct(...) func in cvGameUtils.py. But it doesn't work. Looks like it wasn't called by game engine before showing the building production list. I think firax has provided a way to control whether a building could be buildt or not using python, though i can't figure out how to do now.

              Is there anybody having experience on restricting building construction?

              Comment


              • #8
                Can and Canot construct dont set anything, functions that set values start with the word set, thouse functions just return booleans that answer the question can or cannot construct. They dont DO anything.

                If you haven't made any changes that will prevent the building from being built then ofcorse theirs going to be no effect. I ment you call thouse functions to TEST if your changes have been effective. A prerequisite building is your best bet for making a building unbuildable.
                Companions the creator seeks, not corpses, not herds and believers. Fellow creators, the creator seeks - those who write new values on new tablets. Companions the creator seeks, and fellow harvesters; for everything about him is ripe for the harvest. - Thus spoke Zarathustra, Fredrick Nietzsche

                Comment


                • #9
                  I think, since there are 2 functions: canConstruct and cannot Construct, and normally, they all return False, they may take effects when returning True. If cannot Construct return True means cannot, of cause I don't know what happens if they all return True. However, I didn't see they were called by game codes at all. I put some lines like pyprint("blab...") in those functions, and didn't see it appeared.

                  Thanks, it may be the best idea now that creating a code-putting prerequisite building. And could you tell me a best way to make a building impossible to be built by players at any time please? To set its prereq tech a non-researchable one?

                  Comment

                  Working...
                  X