Announcement

Collapse
No announcement yet.

Initial Python reference

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

  • #76
    Ganraeln : I think your question is too complex to be answered in this topped thread where all subjects flow through each other. You might get better results with a new thread with the only focus on your problem.
    no sig

    Comment


    • #77
      PJay,

      Thanks for the response. After posting the first time, and seeing a bunch of posts responding to something else entirely, I was probably coming off a bit snippish. That, I'm sure, will get me nowhere, especially since we should all be grateful for any information given out by these fine folks.

      I'll just wait for the SDK, I think. I'm hoping the documentation is much better then. Otherwise, it's looking very much like hunt and peck - something I've never found very much fun.

      Comment


      • #78
        Hi guys,

        Just let me quickly explain what I am trying to attempt.

        I have created a specialist-Slave-which is only ever going to appear under the Slavery Civic, because I think the Slavery Civic is currently a little lacklustre.

        Anyway, After modding the SpecialistInfo.xml file, I did a VERY simple python script, called CvCivics.py, to access this specialist under the Slavery Civic. Problem is, it is NOT currently working. Here it is:

        def onBeginPlayerTurn(self, argsList):
        'Civic Chosen'

        iGameTurn, iPlayer, iCity = argsList

        if iCivic==gc.getInfoTypeForString('CIVIC_SLAVERY')):
        pSpecialist.gc.getFreeSpecialist(7)-int(2)

        print("You have enslaved the local natives")

        Can anyone help me with some advice as to what I need to add? Thanks in advance.

        Yours,
        Aussie_Lurker.
        Last edited by The_Aussie_Lurker; December 10, 2005, 05:36.

        Comment


        • #79
          This part looks very wrong:

          pSpecialist.gc.getFreeSpecialist(7)-int(2)


          if you defined gc like everybody does, it can't be used with anything in front of it. I don't quite get what you want this line to do exactly.
          What do you think pSpecialist is (it's not defined in your code here)?
          Why the - int(2) ?


          Anyway, the freespecialist functions you find in the API are for things like mercantilism giving 1 free specialist, and can be set in XML without python. Perhaps you'll have to give the specialists' bonusses directly to the cities instead of giving them indirectly through a specialist.
          no sig

          Comment


          • #80
            Hi there. Thanks for the advice regarding specialists. Actually, things have evolved quite a bit since that post, and I feel quite positive that I have got the right code now. I will post the results of my efforts within the next 7 days.

            Yours,
            Aussie_Lurker.

            Comment


            • #81
              Is there anyway to define new "types"?

              Specifically, I'd like to add a couple of new CivilopediaPageTypes, but I can't find a place to do this.

              Comment


              • #82
                Does anyone know if it is possible to link tech rates to in-game factors via python? For instance I would like to do something like this:

                essentially if player has resource=copper, then tech rate for bronze working is 0.75 of normal.

                Anyone able to help me with this?

                Yours,
                Aussie_Lurker.

                Comment


                • #83
                  Anyone knows how rivers are generated in map scripts? I can see land/peak/hills/water on one side, ice/tundra/grass/plains/desert on another, and resources and forest/jungle in the third part, but can't find rivers.
                  Clash of Civilization team member
                  (a civ-like game whose goal is low micromanagement and good AI)
                  web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                  Comment


                  • #84
                    On river generation in map scripts: It is done by a set of global functions, mainly, if I'm not mistaken, getRiverAltitude, which seems to provide the altitude of a plot in order to compute where the river should flow.
                    The problem is the rivers are computed to flow from a source to the sea rather than the opposite. This means the rivers will sometimes cross mountain ranges because they seem unable to decide to go sideways when they meet a mountain, and even that wouldn't ensure they will someday meet the sea. If anyone knows how to replace the whole river system generation, I'd like to hear from them.
                    Clash of Civilization team member
                    (a civ-like game whose goal is low micromanagement and good AI)
                    web site http://clash.apolyton.net/frame/index.shtml and forum here on apolyton)

                    Comment


                    • #85
                      Hi I've got a question for someone:

                      I want to extract the combat log; I've found the relevant functions that write to the combat log, but since CyInterface().addCombatMessage is not in the SDK, I can't think of a way to get these logs extracted to a text file!

                      Any help on this would be appreciated -- I'm probably looking in the wrong places since I went to the Python first (I'm a programmer) :P

                      Comment


                      • #86
                        If you have a unit and move it, how to know on what tile it was on? So you can change things on a tile when a unit moves away from it.

                        Comment


                        • #87
                          There's no way to do that. If you read earlier in the thread, you'll note I asked already, and was told I'd have to wait for the SDK - so I guess you will too.

                          Bh

                          Comment


                          • #88
                            Okey :-). Well my solution was to check every tile around the unit that moved. One could also check the direction and reverse it to get the old tile but I didn't want to do that.



                            Originally posted by Bhruic
                            Another question - it's possible to add new Promotion types, yes? I haven't been able to successfully do so at this point, just want to make sure I'm not banging my head against the wall pointlessly.

                            edit: nm, got it working. Apparently if you add a new promotion type and try and load an old savegame, it'll die, but if you start a new one, it works fine.

                            Bh
                            How do you add it?



                            Originally posted by Locutus
                            General
                            onUnitCreated
                            'Unit Completed'
                            arguments: unit

                            onUnitLost
                            'Unit Lost'
                            arguments: unit
                            Can't get those to work. When are they called? When I tried to check unit x y it gave me an error.


                            Also is there any onImprovementRemoved or something?
                            Last edited by Zuul; January 20, 2006, 07:26.

                            Comment


                            • #89
                              Is there an ETA on documentation for the Map generation scripts? If not, has someone figured out the name for floodplains terrain features in the FeatureGenerator class? I haven't found it in any of the map scripts.

                              Comment


                              • #90
                                Originally posted by Zuul

                                How do you add it?
                                Just edit the xml file.

                                Can't get those to work. When are they called? When I tried to check unit x y it gave me an error.

                                Also is there any onImprovementRemoved or something?
                                They both work fine for me. What exactly are you trying to do with them?

                                As for removing Improvements, no, no function exists for that (that I'm aware of).

                                Bh

                                Comment

                                Working...
                                X