Announcement

Collapse
No announcement yet.

Freeciv Event Examples

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

  • Freeciv Event Examples

    ***Warning: Freeciv Enthusiast Plug***

    Well I've been putzing around Freeciv 2.1 Beta for a bit now and the developers have released their first work using an event structure.

    In Freeciv, almost all of the files used to create a game can be edited using a simple text editor. Save files, graphic dimensions, game rules, terrain rules, etc... can all be edited without having to get involved in major programming or hex editing.

    Freeciv 2.1 Beta uses a unique way of grouping events. Instead of existing in a seperate text file that has to be "loaded" into a game save the event structure exists within the save. It sits right there next to the game map (which can be edited in the text editor), the games basic world rules (which can be edited in the text editor), and civilization players included (which can edited in the text editor along with their starting positions). In short, it can all be edited using Wordpad.

    Of course, there's a small hitch. The save games are compressed into gz format, but thankfully they can be unzipped using a number of handy utilities similar to Winzip and Winrar. I used 7-zip, which is a free compressor program with a handy file manager screen like WinRar. After the file is unzipped it is ready to be edited using a text editor.

    The event structure is still a bit basic, but powerful as you can see from some lines of script I have cut from the tutorial.sav. I probably have left out a little bit of the scripting from my rudimentary cutting and pasting, but the bulk of the event is listed.

    This is an example of an If Turn trigger used to cause the Notify event. It displays a popup text box using regular windows language, just like anyother window on your desktop. The text has to be sparsed using some basic code "\\n\" to get the text to wrap, just like we have to do with our scenario popups in Civ2.

    function turn_callback(turn, year)
    if turn == 0 then
    notify.event(nil, nil, E.TUTORIAL,
    _('Welcome to Freeciv. You lead a civilization. Your\\n\
    task is to conquer the world! You should start by\\n\
    exploring the land around you with your explorer,\\n\
    and using your settlers to find a good place to build\\n\
    a city. Use the number pad to move units around.'))
    end
    end
    signal.connect('turn_started', 'turn_callback')
    This is an example of an City Growth trigger used to cause the Notify event.

    function city_growth_callback(city, size)
    if city.owner:is_human() then
    if size == 2 and not growth2msg then
    notify.event(city.owner, city.tile, E.TUTORIAL,
    _('Your city has grown! As a city grows, more citizens become\\n\
    available that can be put to work in the fields or dedicated as\\n\
    citizen specialists. A city of size two or more may also build\\n\
    settlers, which costs one unit of population.\\n\
    \\n\
    If your city is building settlers, you should consider buying them\\n\
    now. Open the city dialog and click on the Buy button. This trades\\n\
    in gold (if you have enough of it) to instantly complete the\\n\
    production.'))
    growth2msg = true
    This is an example of an If Unit Built trigger used to cause the Notify event.

    function unit_built_callback(unit)
    if not unit.owner:is_human() then
    return
    end
    if unit:type().name == 'Settlers' then
    if settlersbuilt == 0 then
    notify.event(unit.owner, unit.tile, E.TUTORIAL,
    _('You have built a settler unit. Settlers are best used to build \\n\
    new cities, so as to expand your civilization. Move your settler\\n\
    away from your existing cities to find a spot for a new city. When\\n\
    you have picked a spot press B to build the city.\\n\
    \\n\
    Again, cities are best built on open ground near water. Grassland\\n\
    and plains provide food for the city. Forests and hills provide\\n\
    the resources (shields) needed for building things. Rivers and ocean\\n\
    give trade bonuses that provide civilization-wide benefits. Desert,\\n\
    tundra, and mountains generally provide little output and are not\\n\
    of much use to small cities. See the help on terrain and specials\\n\
    for more information about terrain specs.'))
    This is an example of an If Unit Can't Be Built trigger used to cause the Notify event.

    function unit_cant_be_built_callback(unittype, city, reason)
    if not city.owner:is_human() then
    return
    end
    if unittype.name == 'Settlers' and not nosettlermsg then
    notify.event(city.owner, city.tile, E.TUTORIAL,
    _('Your city cannot build a settler. Settlers take one unit of\\n\
    population to build, so a city of size one cannot build one without\\n\
    disbanding the city.\\n\
    \\n\
    To remedy this, you need to adjust the citizens in the city to\\n\
    provide more food so as to grow the city faster. Cities that\\n\
    do not have much food should not try to build settlers. When\\n\
    founding a new city, make sure it is built on terrain that provides\\n\
    enough food - grassland is best; plains or hills are almost as good.'))
    nosettlermsg = true
    Other Triggers:

    If Military Unit Built
    If Tech Researched
    If Hut Entered


    As you can see, the event language is growing and is quickly becoming fully fleshed out.

    I'm having a ball screwing around with Freeciv. The language is easy to use and read. Try it out!

    ***End Freeciv Enthusiast Transmission***

  • #2
    Keep posting. You'll hook us eventually.

    Is there a limit to the number of events?
    El Aurens v2 Beta!

    Comment


    • #3
      Originally posted by Boco
      Keep posting. You'll hook us eventually.

      Is there a limit to the number of events?

      Not that I know of

      Here's an uncompressed save from one of my recent games. It's fully editable in Wordpad. Take a look at its guts.

      I'll have to break it up to post. Here's only about a 6th of the file.
      Attached Files

      Comment


      • #4
        That save is on a 6000 tile map with about 20 civs and around 380 cities.

        Comment


        • #5


          What do you think of the AI?
          El Aurens v2 Beta!

          Comment


          • #6
            Originally posted by Boco


            What do you think of the AI?

            Well I've been playing on normal level for the time being, just to get used to it. I should try the hardest level next.

            My first real game I had a serious problem develop where a neighboring AI decided to declare war on me when I least expected it. They managed to take three cities before I got my head in the game and drove them back with a concerted effort.

            The normal Freeciv AI, as I view it, is about the same as the normal Civ 2 AI, but without the constraints imposed upon it by the Civ 2 engine. The AI empires are expansive and contain more cities than any normal Civ 2 AI would, making them dangerous to piss off if you are behind in tech and productivity.

            To get a full view of the AI I need to play on the hardest level and see if I can survive. Deity on Civ2 is not a huge challenge for me, expecially when I employ some sort of war planning. This same holds true for the normal AI level in Freeciv.

            One thing I have found. If the AI can't break my lines at a choke point or I'm more powerful militarily they will back off slightly and either try a different route or employ skirmishes within my border.

            Also, the AI seems to have some inkling of combined arms. They deploy infantry with artillery and even with mounted units. The infantry fill out a defensive role while the AI can pound on me with their high attack items.

            Overall I think the AI is adequate, but I want to see what I'm up against with the hard level or even experimental.

            Comment


            • #7
              One more note about the AI. I played another game where a group of six AI were set on one of four islands on the map (15 civs were playing). I noticed that after the island was filled up where there was little land to settle on the Franch civ started to expand expoentially toward an unoccupied island on the other side of the map. The Franch had only about 6 cities on the main island but after about 50 turns I was neck and neck with them settling the unoccupied island.

              The good news is that the AI is not timid about expanding over the sea.

              Another note, the French were on the Western side of a world map that did not wrap. They were boxed in a corner from the start but managed to settle land that was past the eastern expanse of the main island on the other side of map. They also managed to contact the civs on the other islands before I did. That says something.

              Comment


              • #8
                And as always, the code is written in C and can be edited directly from the source and then compiled, or it can be edited after compilation. Right now I'm looking at the AI guts...

                Comment


                • #9
                  Huh, I was looking on the internet for Freeciv variations and found a patch for an Alpha Centauri version of one of the older versions of the game. The big difference from it being just a mod is that the patch created a design workshop that actually created unique units in-game...

                  Comment


                  • #10
                    Thinking of designing a FreeCiv scenario?

                    Btw, how fluent are you in C?
                    El Aurens v2 Beta!

                    Comment


                    • #11
                      I could probably manage to design a simple one easily enough. The non-programming language files are easy to manipulate.

                      I know very little about C programming, but then again that's only a problem if I want to manipulate the inner workings of the game and not just the regular rules, text, files etc...

                      I dunno, maybe I'll give it a try and create a quick scenario in a bit. RomaFreeciv anyone?

                      Comment


                      • #12
                        Oh, did I mention that Wonder effects can be changed? Think the SETI wonder is useless? Well why not change it to a shield producing wonder like King Richard's Crusade? All you have to do is swap out the effect script.

                        Also, an update on the Hard AI. I am playing a small 2000 tile map with 5 players (now 4, I killed one). The game turn is 94 and I'm lagging behind in research by a considerable margin. I am neck and neck with the Indians in colonizing the empty islands on the map. I'm doing OK as it stands, but the AI is giving me trouble expanding.

                        Oh one more thing. In Freeciv you can share "vision" with another civ, allowing the civ to see your map each turn. Or it can go one way with you seeing just the other civs "vision", or both ways. Currently I have an alliance with the Indians and I have struck a deal so that I can only see their map without them seeing mine. Odd thing is, the Indians keep loading one of their explorers onto my triremes, allowing them to see where my ship is going, effectively showing them additional parts of my map when I move my trireme. This is a sneaky, sneaky trick! Damn AI is smart!
                        Last edited by Harry Tuttle; April 29, 2006, 00:43.

                        Comment


                        • #13
                          Hehe. The explorer-in-trireme thing is not intentional. Also if you play around with the events stuff enough, you will soon find a bug (at least in the create unit function) that will crash the game. Should be fixed for the next beta.

                          Notice the file data/default/scripting.lua - this is another way of using the event system. Instead of adding it inside a savegame, you can couple it with a ruleset. Once we fix the bug I mentioned, I will move event behaviour like huts out from the C code and into this event file.

                          Comment


                          • #14
                            What I dislike about freeciv is that ICS is embraced by the Ai to such an extent that it isn't optional for the human player
                            No Fighting here, this is the war room!

                            Comment


                            • #15
                              I for one think "Infinite City Sprawl" is really something that you cannot avoid when dealing with a strategy game like Civ or Freeciv. Sure, you can win a game with a few gigantic cities, but is it really advantageous to do so? Cities produce units, gold, and research. The more cities you have the more of each you can expect to have.

                              I could see a better AI that focuses on warfare and individual unit use, but when it comes down to it the civ with more resources can win the game.

                              How can we change this strategy? Maybe the terrain tiles could be set to allow more improvements built, each consecutively more productive than the next. This would allow a civ to produce more with fewer, older cities. The bonus to working older tiles within curent city range might outweigh the benefit of producing more cities. But therein lies a problem. Each city, at most, can produce one unit per turn, creating a natural cap on how many units can be produced with current cities. Eventually the civ will have to expand to produce more units. I guess you can counter this by offering more units with even greater attack and defense at more of a cost. The next problem is creating an AI program that weighs these cost benefits.

                              Another problem with thwarting ICS is the basics behind city starvation. What if I surround a major city, one of 10 a civ has created? I can occupy so many tiles within that city's radius that I can starve it to death, rendering close to 10% of a civ's resource capacity moot. Expansion just makes more sense. It's much easier to destroy or take one city than ten others.

                              I think ICS is a valid strategy, unless an AI can be taught to effectively stragize on a small scale. If I was playing multiplayer I would employ ICS because it is probably the most effective long term strategy there is.

                              Comment

                              Working...
                              X