Announcement

Collapse
No announcement yet.

Initial Python reference

Collapse
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #91
    Just a quickie...

    What does the file '<CivDir>\Assets\Python\Screens\CvDanQuayle.py' actually do? And why is it called Dan Quayle (I do know who he is)?

    Also, in reference to removing improvements, what about 'onPillage' or something? Is there a function like that?
    Ceeforee v0.1 - The Unofficial Civ 4 Editor -= Something no Civ Modder should ever be without =- Last Updated: 27/03/2009
    "Just because I'm paranoid doesn't mean there's no conspiracy"

    Comment


    • #92
      Wow, forgot about this thread

      Not gonna bother answering questions that are more than 4 months old, I assume everyone either already found an anwer or gave up. If anyone still has any outstanding questions they want answered, just repeat them...

      Originally posted by MMC
      Just a quickie...

      What does the file '<CivDir>\Assets\Python\Screens\CvDanQuayle.py' actually do? And why is it called Dan Quayle (I do know who he is)?
      Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

      Comment


      • #93
        Event Logging

        Hi,

        Working on my first mod and one of the added features is a disease promotion that spreads to nearby units and eventually kills infected units - a bioterrorist element. This works fine but my playtesters are concerned that this is a very quiet event - no indications except for changing promotions which can be difficult to catch.

        I added the following:

        popup=PyPopup.PyPopup()
        popup.setBodyString('Your Unit has been infected')
        popup.launch()

        which works fine except that the message appears on everyone's screen.

        How would someone add messages to the events log that already are posted on individual's screens.

        Thanks for your help in advance,
        Cheers

        Comment


        • #94
          Two ways to do that. If you want a popup like above, simply precede it by a check if the affected player is the active player, that is the player running the script on his pc:

          Code:
          if gc.getGame().getActivePlayer() == gc.getPlayer(iAffectedPlayer):
          Or, perhaps more elegantly and less intrusive, you could display a message in the top-left corner of the screen, like what happens when e.g. a religion spreads:

          Code:
          button = "[path to some icon you want to use for the arrow pointing to the unit in question]"
          CyInterface().addMessage(iAffectedPlayer, False, 0, "Your Unit has been infected", "", 0, button,     \
                      CyGame().getReplayMessageColor(0), affectedUnit.getX(), affectedUnit.getY(), True, True)
          If you don't want to bother with arrows and icons and all that:

          Code:
          CyInterface().addMessage(iAffectedPlayer, False, 0, "Your Unit has been infected", "", 0, "",     \
                      CyGame().getReplayMessageColor(0), 0, 0, False, False)
          Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

          Comment


          • #95
            Nice!

            Answered my question and the next step that I hadn't considered yet (the event button).

            Looking forward to implementing next hacking session.

            Many Thanks,
            Elustrian

            Comment


            • #96
              Is it possible to use onUnitMove() to charge x gold from any player every time any of his units moves one square?
              "Learn to overcome the crass demands of flesh and bone, for they warp the matrix through which we perceive the world. Extend your awareness outwards, beyond the self of body, to embrace the self of group and the self of humanity. The goals of the group and the greater race are transcendent, and to embrace them is to achieve enlightenment."

              -- Sheng-ji Yang, "Essays on Mind and Matter"

              Comment


              • #97
                Yeah sure.

                Code:
                	def onUnitMove(self, argsList):
                		'unit move'
                		pPlot,pUnit = argsList
                		player = gc.getPlayer(pUnit.getOwner())
                		player.changeGold(-x)
                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                Comment


                • #98
                  The API link on the first post is bad. The current one I'm using is http://civilization4.net/files/modding/PythonAPI_v160/ - is this the same as the 1.61 API?

                  Also, the type-list link off the Updates tab doesn't work - you have to go through the legend or get to it by clicking on a type in the API.
                  Civ 4 Wiki - Please help out!
                  Civ4 Mods @ Loadedinc
                  SDK Community Civ 4 Enhancement Project
                  - Any takers?

                  Comment


                  • #99
                    Locutus, the link in the first post is still wrong.
                    no sig

                    Comment


                    • I have a WBS file that has sleeping units..... in other words when the WBS scenario starts, all the units on the map are fortified, so I don't have to visit each one and give it orders. This is a good thing if you have dozens of units.

                      But I have started another scenario, a WBS file, and put in the "Sleep" line with the unit, just like in the other WBS file, but when I start the scenario, I have to visit each unit.

                      What is the difference? What python file needs to be imported for them to be asleep?

                      Thanks for any help you can provide.
                      Question Authority.......with mime...

                      Comment


                      • I just learned that the Sleep command in the WBS file didn't come around until the 1.61 update, so maybe my mod's globaldefines.xml file is out of date....?
                        Question Authority.......with mime...

                        Comment


                        • I think you're asking in the wrong section. The WBS files are nothing to do with python. You could try creating a new thread for your problem.
                          Ceeforee v0.1 - The Unofficial Civ 4 Editor -= Something no Civ Modder should ever be without =- Last Updated: 27/03/2009
                          "Just because I'm paranoid doesn't mean there's no conspiracy"

                          Comment


                          • You are mostly correct, though I found some WBS code in some python files which is what originally inspired me to ask here. But later investigating turned up the aforementioned xml file as the solution, so you are right. Sorry about the confusion, and thanks for the very helpful advice.
                            Question Authority.......with mime...

                            Comment


                            • Well, as it turns out, the globaldefines.xml files were all up to date. The problem is that the scenario I am trying to mod has numerous changes to other files that prevent the 1.61 changes from working.

                              So... in a python related question..... what code could I add to my events file, so that at the beginning of the scenario, each unit is visited and set to "fortify"?

                              Thanks.
                              Question Authority.......with mime...

                              Comment


                              • Hoi U Pythons:

                                I try to make sth like a KingUnit:

                                In the StartYear i want to create a GreatGeneral with the name of the leader of the specific nation.
                                This is what i got so long:

                                //--- CvEventInterface.py -----------------------------------

                                def onGameStart(self, argsList):
                                if (gc.getGame().getGameTurnYear() == gc.getDefineINT("START_YEAR")):
                                for iPlayer in range(gc.getMAX_PLAYERS()):
                                pPlayer = gc.getPlayer(iPlayer)
                                pPlayer.addFreeUnit((UnitTypes)91)

                                //------------------------------------------------------------------

                                i know that there was somewhere a function where you can tell a unit its name but hadn't found it again.
                                The >addFreeUnit((UnitTypes)91)< -function works in C++ good don't know if it does with python...

                                Any help in here would be pretty nice

                                Thx Tom
                                Last edited by Thror78; September 14, 2006, 09:54.

                                Comment

                                Working...
                                X