Announcement

Collapse
No announcement yet.

[MOD] Building Demolition mod

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

  • #16
    Need some help!

    One other thing I want to add is a sound effect when the building is demolished. I have no idea yet how to trigger sounds but I'm sure it can be done- I'll start looking into the Python part of it tomorrow... But in the meantime if anyone has a good building being demolished sound effect that is copyright free and would like to contribute, please post it so I can try and incorporate it into this mod, thanks!

    Comment


    • #17
      OK I updated this mod today, new rar will be on the Apolyton directory.

      For what changed, see the original post in this thread

      Comment


      • #18
        Can you add 'None' or 'Nevermind' to the list? That would seem safer to the end user than pushing the hotkey again
        ~I like eggs.~

        Comment


        • #19
          Originally posted by ghen
          Can you add 'None' or 'Nevermind' to the list? That would seem safer to the end user than pushing the hotkey again
          Isn't there a Cancel button if you opened it not intending to demolish a building?

          Comment


          • #20
            I was looking at your screenie before downloading. If it has a cancel button now, thats fine.
            ~I like eggs.~

            Comment


            • #21
              TheDarkside, I made some changes to your CvEventManager.py file. I can now use it to abandon cities. Also whenever someone razes or abandons a city, they get population/5 workers.

              Here are the updated sections:

              Code:
              	def onCityRazed(self, argsList):
              		'City Razed'
              		city, iPlayer = argsList	
              		owner = PyPlayer(city.getOwner())
              		razor = PyPlayer(iPlayer)
              		ipopulation = city.getPopulation()
              		if (ipopulation > 4):
              			iworkers = ipopulation/5
              			for i in range(0,iworkers):
              				razor.initUnit(5, city.plot().getX(), city.plot().getY(), UnitAITypes.NO_UNITAI)
              Code:
                      def __eventDestroyBuildingBegin(self, argsList):
                              pHeadSelectedCity = CyInterface().getHeadSelectedCity()
              		popup = PyPopup.PyPopup(DEMOLISH_BUILDING_EVENT, EventContextTypes.EVENTCONTEXT_ALL)
                              popup.setHeaderString("Choose building to demolish")
                              popup.createPullDown()
                              i = 0
                              for i in range( gc.getNumBuildingInfos() ):
                                  if (i > 0 and pHeadSelectedCity.hasBuilding(i) and not isWorldWonderClass(gc.getBuildingInfo(i).getBuildingClassType())):
                                      popup.addPullDownString(gc.getBuildingInfo(i).getDescription() , i)
              		popup.addPullDownString('Abandon City', i+1)
                              popup.addButton("Ok")
                              popup.addButton("Cancel")
                              popup.launch(False, PopupStates.POPUPSTATE_IMMEDIATE)
              		return	    
              
              	def __eventDestroyBuildingApply(self, playerID, userData, popupReturn):             
              		if (popupReturn.getButtonClicked() == 0):
              			if (popupReturn.getSelectedPullDownValue(0) == gc.getNumBuildingInfos() ):
              				pHeadSelectedCity = CyInterface().getHeadSelectedCity()
              				ix = pHeadSelectedCity.getX()
              				iy = pHeadSelectedCity.getY()
              				ipopulation = CyInterface().getHeadSelectedCity().getPopulation()
              				Player = gc.getPlayer(playerID)
              				pHeadSelectedCity.kill()
              				CyAudioGame().Play2DSound("AS2D_DISCOVERBONUS")
              				if (ipopulation > 4):
              					iworkers = ipopulation/5
              					for i in range(0,iworkers):
              						Player.initUnit(5, ix, iy, UnitAITypes.NO_UNITAI)
              			else:
                              		iBuildingType = popupReturn.getSelectedPullDownValue(0)
              				CyInterface().getHeadSelectedCity().setHasRealBuilding(iBuildingType, False)                 
              				CyAudioGame().Play2DSound("AS2D_DISCOVERBONUS")
              				CyInterface().setDirty(InterfaceDirtyBits.CityScreen_DIRTY_BIT, True)
              				CyInterface().setDirty(InterfaceDirtyBits.SelectionButtons_DIRTY_BIT, True) 
              		return

              Comment


              • #22
                The .rar file in the directory seems to only be a readme file?

                Am I downloading the right thing?

                Comment


                • #23
                  I know this is a very old thread, but I could not find anything like this. I am wondering if this mod or something like it has been updated to work with BTS.

                  I tried to do it on my own, but never having worked with Python before is really causing me problems. I am not quite sure what is wrong but after adding the parts that were tagged in this to the new BTS CvEventManager.py file I get a pop up sound when pressing ctrl+d when I am in a city I own, but it does not show the pop up.

                  Thank you for your help.

                  Comment

                  Working...
                  X