1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Is this sorta mod possible to make(Named regions)

Discussion in 'Mod Creation Help' started by MetaMagi, Jan 20, 2018.

  1. MetaMagi

    MetaMagi Chieftain

    Joined:
    Oct 11, 2016
    Messages:
    3
    Gender:
    Male
    I wrote a brief description of a mod I wish to create, and I've been on the lookout for resources to make it possible. Unfortunately, all the standard tools seem inadequate for creating such mod. Here's the description of the mod:

    ------------------------------

    # Named areas

    This mod gives names to different small'ish areas of the map, and adds interactions based on these areas. This document describes aims of the mod, the actual implementation at the time of the writing is completely missing.

    ## Description

    ### Areas


    Areas are 1-7 tile sized portions of the map, each with their individual name. Two tiles of an area can be at most 2 tile away from each other.

    All non-yield tiles are unnamed.

    Name generation gives names to any mountains and mountain ranges. Then to all islands(islands are areas composed of less than 15 tiles). Then to all bays and peninsulas(coastal tiles included). Then to all lakes(lake areas compose of only lake tiles or tiles directly adjacent to that lake. Minimum of one each). Then to all deserts. Then to all valleys(passages through hill or mountain terrain, where there is a flat tile in the middle, touching two hill or mountain tiles which are separated by flat tiles). Then to all tundras, then to all plains, then to all grasslands.

    In case of mountain ranges for example, single mountain range can be larger than just a single area. In this case, each individual named area still is going to only be 1-7 tiles large, and the whole mountain range simply consists of multiple areas.

    ### City settling

    Only one civilization may claim a tile from any one area. Settler cannot settle on tiles whose area has been claimed by another civ, and you cannot expand to or purchase tiles whose area has been claimed already. I'll use term "Weakly claimed" to describe scenario where one civilization has control of an area a tile is in, but it does not have had its city borders yet expand to control that tile.

    ### Areas swapping owners


    If an area swaps ownership, then all other civilizations lose their tiles on that area. Exception is made for districts and wonders, which remain under the ownership of the city that created them.

    ### War

    If during war one civ is the only one to have military units on an area, this civ has occupied this area. The previous owner loses ability to work any tiles in this area, and new owner can either expand their city borders to this area, or settle a new city in this area. This gives half the warmonger penalties associated with taking a city.

    ### Trading

    Areas are directly tradable in the trade screen. Trading an area gives for the buyer a weak claim of the area for 15 turns, which they can capitalize upon by settling a city, or expanding their existing borders.

    ### City growth

    Each area receives immigration from nearby, populated areas based on the sum of appeal of all the tiles, and the sum of food on the area of emigration. This appears as small bonus to food for the city that owns that area.

    ### Missions


    Each area type has score for how "culturally similar" they are. Mountain ranges, oceans etc totally separate the people, while grasslands act as connectors. Your people will want to expand onto connected areas. Not doing so will reduce amenities in connected cities for both civs, but the civ with higher culture output gets reduced amount of negative amenities. Declaring a war, or having an alliance reduces the negative amenities from this mechanic by 75%. Having a declaration of friendship reduces negative amenities by 25%

    ### Casus Belli

    With Feodalism unlocks new Casus Belli, "Declare War of Forward Settling", which reduces the cost of declaring war and taking over areas other civ controls, but has significantly higher cost for capturing cities.

    ------------------------------------

    Now, I've identified a couple of items of interests I should change to make this mod work. Worldbuildermap.sql seems to be responsible for generating an SQL database that is the map, so it was easy to modify that file to include regions into the database. However, that only gets me so far without ability to change in-game interactions based on this new field... And that's where I'm stuck. It does seem Lua scripts only talk to SQL database through specific handler functions in the game engine, and for regions, there are no pre-made handler functions. I'm thinking maybe there is some sort of "list all properties" handler function game engine has, but none of the .lua files I've seen actually use it, so...
     
  2. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    7,810
    Location:
    France
    The naming part could be coded in Lua I suppose, but everything else would require the source code to be added in the game.
     
  3. MetaMagi

    MetaMagi Chieftain

    Joined:
    Oct 11, 2016
    Messages:
    3
    Gender:
    Male
    Any tips on how? I have quite a few ideas about how to use these regions, many of them not mentioned in above document, and even if most of the ideas won't be possible to implement, I bet at least some of them are, and there could be workarounds to achieve similar effect on gameplay for others as long as I get those regions to exist at all in the first place.
     
  4. MetaMagi

    MetaMagi Chieftain

    Joined:
    Oct 11, 2016
    Messages:
    3
    Gender:
    Male
    Specifically, I'd want to know what exactly is possible, and what are the limitations of sql+lua. Could I add any bonuses to cities that control specific areas? Could I remove amenities from cities which control particular areas?

    I've looked your mod project for reference, and I'm struggling to understand how you connect your SQL tables into the game. Many of your SQL tables in the mod don't seem to be referenced at all by the Lua side, which confuses me a lot, since afaik that means they're not doing anything.
     
  5. Gedemon

    Gedemon Modder Moderator

    Joined:
    Oct 4, 2004
    Messages:
    7,810
    Location:
    France
    We use SQL to update the game DB, the game then read entries in that DB and apply them to gameplay elements.

    We don't have access (yet) to the code (C++) of the game, but we can change the parameters, and we also have access to some function exposed to Lua that allow to modify the core gameplay (spawning units, cities, changing gold, health, ...)

    When I update an existing table in SQL, it can be either to change an existing parameters for the game engine, or add a new one that will be used in my Lua code.

    When I create a new table in sql, it's for specific gameplay defined in my lua code (and applied to the game using the available core functions)

    So, in short, the limiting factor to create new gameplay today is the functions exposed in Lua.

    When (if) we get access to the DLL source code, we'll be able to create our own functions without gameplay limitations.
     

Share This Page