Public Draft: Adding a Festive Flair to Freeciv: Introducing Santa Claus

Freeciv, the open-source empire-building strategy game, offers a vast canvas for creativity, allowing players and developers to tailor their gaming experience. With the holiday season around the corner, why not add a bit of festive cheer to your game? In this tutorial, we’ll guide you through creating a new unit, Santa Claus, complete with its unique technology, “Holiday Cheer,” and a special building, the “Festival Square.”

Step 1: Conceptualizing Santa Claus

Before diving into the code, let’s conceptualize our Santa Claus unit:

  • Class: Air (Santa travels the world in his magical sleigh)
  • Abilities: Distributes gifts, brings happiness, and possibly provides bonuses to the cities he visits.
  • Requirements: Only appears after discovering the “Holiday Cheer” technology and when the “Festival Square” building is present in the city.
  • Special Flags: “Seasonal” (appears only during specific turns), “Gift Distribution” (unique action performed by Santa).

Step 2: Defining the Santa Claus Unit

  1. Open the units.ruleset File: This file contains the definitions for various units in the game. We will add our Santa Claus unit here.
  2. Add the Santa Claus Definition: Below is the code you need to insert. This code defines Santa’s attributes, such as his class, vision, movement rate, and the special requirements to create him.

    [unit_santa_claus]
    name = _("Santa Claus")
    class = "Air"
    tech_req = "Holiday Cheer"
    building_req = "Festival Square"
    vision_radius_sq = 2
    transport_cap = 1
    hp = 10
    firepower = 1
    move_rate = 3
    attack_strength = 0
    defense_strength = 1
    pop_cost = 0
    shield_cost = 30
    food_cost = 0
    gold_cost = 50
    flags = "Seasonal", "Gift Distribution", "NonMil"

Step 3: Introducing the Holiday Cheer Technology

  1. Open the techs.ruleset File: This file defines the technologies that can be discovered in the game.
  2. Define the Holiday Cheer Technology: This technology is required to bring Santa Claus into your game. Add the following lines to the file:

    [tech_holiday_cheer]
    name = _("Holiday Cheer")
    req1 = "Writing"
    req2 = "Ceremonial Burial"
    flags = ""
    graphic = "t_holiday_cheer"
    graphic_alt = "-"

Step 4: Constructing the Festival Square

  1. Open the buildings.ruleset File: Buildings in the game are defined in this file.
  2. Add the Festival Square Building: This building is a prerequisite for Santa Claus to visit your city. Here’s how you define it:

    [building_festival_square]
    name = _("Festival Square")
    genus = "Improvement"
    tech_req = "Holiday Cheer"
    reqs =
    { "type", "name", "range"
    "Tech", "Holiday Cheer", "Player"
    }
    graphic = "b_festival_square"
    graphic_alt = "-"

Step 5: Implementing Custom Behavior (Advanced)

The flags “Seasonal” and “Gift Distribution” suggest behaviors that are not part of the standard Freeciv game. Implementing these would require modifying the game’s source code, a task for those familiar with programming.

  1. Modify the Game Engine: Locate the part of the code that handles unit actions and turns. Implement custom logic for the “Seasonal” flag to make Santa Claus appear/disappear during specific turns and for the “Gift Distribution” action to define what happens when Santa visits a city.
  2. Test Thoroughly: After making these changes, compile the game and test it thoroughly to ensure that everything works as expected.

Conclusion

Adding Santa Claus to your Freeciv game is a fun way to celebrate the holiday season. It demonstrates the flexibility and extensibility of open-source games. With a bit of coding and creativity, you can bring a unique festive touch to your gaming sessions. Happy modding, and happy holidays!

Remember, these changes require a good understanding of the Freeciv game mechanics and some programming skills for full implementation. Enjoy your festive Freeciv experience!

Perfect Space Race

Some weeks ago we made the perfect Freeciv space ship to end our current game at freeciv.fi.

To do that, I had to research once more how it’s done in Freeciv 2.3.0. There isn’t much documentation about it. It doesn’t work the same as it did in the commercial Civilization 1 and 2.

It seems the fastest complete ship will take 7.7 years to travel to the Alpha Centaur — it takes 8 turns in the game based on our tests. It has three Space Modules, 16 Space Components and 20 Space Structurals.

Most important thing to know is that the order in which you build these parts is significant. It seems the best way is to build first modules and components and then enough structures. That’s because the game tries to place new parts to supplement the ship and might put some parts in the wrong order if it thinks the ship needs more structurals for modules instead of components.

To build these parts in the first place you need to have Factory built in the city and have researched Space Flight (for Space Structurals), Superconductors (for Space Modules) and Plastics (for Space Components).

My raw calculations can be read from Google Docs.

You will get something about 100-400 more points (Please note: I haven’t confirmed the exact amounts!) to your score based on the size of your space ship. Usually the space race will end the game but some games do not have space race enabled — like longturn.org — or it doesn’t end the game (just adds points). The player who wins the space race doesn’t automatically win the game if he has less points than others have. For example it’s possible to make more points by developing Future Tech or conquering land.

The space ship is lost if your capital is conquered. If that’s a possible threat you should start improving your defenses ASAP or move your capital to a better city.