Announcement

Collapse
No announcement yet.

[C4:AC][Programming] First try: harvester

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

  • [C4:AC][Programming] First try: harvester

    Hi


    After playing civ4 for a few turns, the first thing I missed was a usefull unit to build at any time, like our precious crawlers.

    So, I wanted to start with adding a "harvester" unit to civ4, probably with a new technology as prerequisite tech (ie: tech = harvesting, prerequisites = mining and farming).

    After a few hours looking through the files I have given up the mod for now without even "really" starting it, but I have some general remarks/questions about modding civ4 into alpha centauri:

    => There is not much documentation. Ie : there is a .ini file for each mod, but there's no list with options you can set there. There is documentation about what functions you can use in python, but no "top down" view to guide you to which files are used by the game for which purposes.

    => You can't "add" technologies, buildings or units, you have to replace the whole set with a whole new set. This might give small mods (ie: like adding 1 technology) some trouble with patches (the mod won't automaticly inherit the new "official" technologies), but this is actually beneficial for our project because patches won't interfere.

    => Graphics will be tough. For 1 unit, there are many graphics files, in different formats scattered all around the directories that are all referenced from different XML files. If I continue this small modding test, I'll probably just copy all graphics files from an existing unit and rename them to "harvester".

    => Adding windows (like designing the gui for the design workshop) is no problem at all. Firaxis used python for all screens in the game, so we should use python too and don't have to wait for the SDK.

    => All the talk about "civ4 is now fully 3D" is wrong, but we can probably make it 3D. You can not control the camera fully. You can only zoom in and out freely. When you zoom out, the camera angle changes automaticly to a more top-down view, if you zoom in, it changes to a more side-view. You can not really turn the camera, there are 3 fixed positions for rotating it (-45°, 0°, +45°). I hope we can remove all these unnecessary camera limits. Moving the camera around is quite counter-intuïtive: if you're zoomed out completely, you have to drag the map with the left mouse button to move it, if you're not zoomed out fully, this doesn't work anymore, and you have to left-click on the screen to recenter the map. Having 2 different moving-modes, depending on the zoom distance is ridiculuous IMO.
    no sig

  • #2
    By using the shift+arrow(left/right) combo you can move the viewpoint between the minus 45°-0° and 0°-45°.

    It goes back to it's current mode once the arrow key is released tho.
    He who knows others is wise.
    He who knows himself is enlightened.
    -- Lao Tsu

    SMAC(X) Marsscenario

    Comment


    • #3
      Damn I can't wait for my Civ4 copy to arrive. Should be tommorow hopefully.

      Comment


      • #4
        btw: I started a thread about this mod in the general civ-4 creation forum, and I'm documenting the small progress I make. This way I hope to:

        => Get solutions for my problems
        => Provide some kind of help-document for others that want to start modding.
        no sig

        Comment


        • #5
          Sorry for my spammy post. I'm just very excited.

          => You can't "add" technologies, buildings or units, you have to replace the whole set with a whole new set. This might give small mods (ie: like adding 1 technology) some trouble with patches (the mod won't automaticly inherit the new "official" technologies), but this is actually beneficial for our project because patches won't interfere.
          I'm hoping there will be a way to work around this with some fancy coding, to allow creating and adding new units (etc) on the fly with python code alone. I'm certain this will be possible with the C++ SDK, unless Firaxis have gone to extraordinary efforts to make it impossible...

          => All the talk about "civ4 is now fully 3D" is wrong, but we can probably make it 3D. You can not control the camera fully. You can only zoom in and out freely.
          Sounds like the typical 3D RTS camera

          => Adding windows (like designing the gui for the design workshop) is no problem at all. Firaxis used python for all screens in the game, so we should use python too and don't have to wait for the SDK.
          Cool . Am i right in saying they use wxWindows?

          Comment


          • #6
            Originally posted by Blake

            Cool . Am i right in saying they use wxWindows?
            yes, there's whole bunch of "wx..." python files, but there's also firaxis' own functions to make it easier. You basicly do something like:

            pyPopup test = new popup();
            test.setTitle ("blah");
            test.addMultilineText("blahblahblah");
            test.launch();

            (not literally correct, just to get the idea).
            no sig

            Comment


            • #7
              Originally posted by PJayTycy
              I've got all the xml working now (tech + unit), except for the few xml-tags above that I'm still unsure of. I noticed the ai didn't really want to research my new tech, but once I got it, they all came asking for it and offered a tech of theirs + gold. So I should probably tune down the iAITradeModifier a bit :-)

              Anyway, I'm now moving on to the python side of things. At the end of each player's turn, I have to search for all harvester units "supported" by each base and then add a certain amount of hammers / gold / food to that city.

              In Locutus' "initial Python reference" here, I see a lot of possibile events that could trigger my code. I don't really know which one to use:

              onBeginGameTurn
              'Called at the beginning of the end of each turn'
              arguments: iGameTurn

              onEndGameTurn
              'Called at the end of the end of each turn'
              arguments: iGameTurn

              onBeginPlayerTurn
              'Called at the beginning of a players turn'
              arguments: iGameTurn, iPlayer

              onEndPlayerTurn
              'Called at the end of a players turn'
              arguments: iGameTurn, iPlayer

              onEndTurnReady
              -
              arguments: iGameTurn

              onCityDoTurn
              'City Production'
              arguments: pCity, iPlayer


              I tried to add this code to each of these events:
              Code:
              		iGameTurn = argsList
              		popup = Popup.PyPopup()
              		popup.setHeaderString( "onBeginGameTurn" )
              		popup.setBodyString( 'iGameTurn = %d' , iGameTurn )
              		popup.launch()
              to see when each event was triggered, but I don't see any popup at all.
              SMAC/X FAQ | Chiron Archives
              The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. --G.B.Shaw

              Comment


              • #8
                well, I'm having progress at least.

                The popups show allright now (with +/- the code above, the problem was something else), but the cursor is still "locked" or something when I close them. (ie: I can click on all of the interface, but not on units/cities/the map/...)

                (I'm mostly posting questions and progress reports in the civ4 modding forum because there are more people there who can help)
                no sig

                Comment


                • #9
                  to whom it might concern (and doesn't read the thread in civ4 modding) :

                  all xml is finished
                  I've got the events and popups figured out (there just seems to be a limit of 10 popups above each other in civ4)

                  todo next:

                  -> Finding / defining a "home city" for each crawler (civ4 has global monetary support instead of city-based mineral support for units, so they don't have a "home city").
                  -> Find out how to change a city's production.
                  -> Remember some state about each unit (ie: not crawling, crawling food, crawling minerals, crawling energy)

                  This will probably work with 3 keyboard shortcuts first, as that's pretty easy to do. Adding 3 buttons to the interface (ie: crawl minerals / food / energy) will be tougher.

                  I don't have to provide the disband functionallity, as this is in the base civ4 already. Only had to set the cash-in value to the same as the production-cost in the xml file.
                  no sig

                  Comment


                  • #10
                    Instead of setting a home city upon creation, could you have a pop-up ask the player to which city the resource should be sent. I know this is not how SMAC worked, but it might be easier for you. I know very little about modding, so I may just be sounding stupid.
                    Last edited by DickieBear; November 17, 2005, 11:53.

                    Comment


                    • #11
                      That'd be such an improvement over taking the crawler back to a city, re-homing it and sending it back out. Don't know how the purists would look upon it.

                      I take it you mean when you give the harvest order?
                      #play s.-cd#g+c-ga#+dgfg#+cf----q.c
                      #endgame

                      Quantum P. is a champion: http://geocities.com/zztexpert/docs/upoprgv4.html

                      Comment


                      • #12
                        Currently I just look at all "onUnitBuilt(city, unit)" events, and if the unit is of the crawler type, I store the city-unit pair in a list (together with what resource they're crawling).

                        Then, for every player's turn, I look over the whole list to find the city/crawler pairs owned by the current player.
                        no sig

                        Comment


                        • #13
                          To #endgame: Yes, I mean when the harvest order is given. I, too, think this would be cool and not too unrealistic.

                          To PJayTycy: The idea of a crawler is very exciting. Will you be releasing a mod that just adds a crawler to Civ IV, so that I can use it in my Civ IV games while I am waiting for C4AC to come out?

                          Comment


                          • #14
                            Victory!



                            You have your supply crawler

                            Comment


                            • #15


                              Civvers, beware!
                              He who knows others is wise.
                              He who knows himself is enlightened.
                              -- Lao Tsu

                              SMAC(X) Marsscenario

                              Comment

                              Working...
                              X