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

Quick Modding Questions Thread

Discussion in 'Mod Creation Help' started by Leyrann, Oct 28, 2018.

  1. AntSou

    AntSou Emperor

    Joined:
    Jun 8, 2019
    Messages:
    1,176
    I need to open an exception to the Alpine Promotion to exclude Desert Hills. Is there a direct way to add one?



    Since Name is a Primary Key, I can't just have four TerrainTypes with a different Value for each Hill terrain. This is what I did instead:

    Code:
    -- Changing Alpine Promotion to exclude Desert Hills
    DELETE FROM UnitPromotions WHERE UnitPromotionType ='PROMOTION_ALPINE';
    DELETE FROM ModifierArguments WHERE ModifierId ='ALPINE_IGNORE_HILLS_MOVEMENT_PENALTY';
    
    INSERT OR REPLACE INTO Modifiers
        (ModifierId, ModifierType)
    VALUES ('ALPINE_IGNORE_GRASS_HILLS_MOVEMENT_PENALTY', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST'),
           ('ALPINE_IGNORE_PLAINS_HILLS_MOVEMENT_PENALTY', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST'),
           ('ALPINE_IGNORE_TUNDRA_HILLS_MOVEMENT_PENALTY', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST'),
           ('ALPINE_IGNORE_SNOW_HILLS_MOVEMENT_PENALTY', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST');
         
    INSERT OR REPLACE INTO ModifierArguments
        (ModifierId, Name, Value)
    VALUES ('ALPINE_IGNORE_GRASS_HILLS_MOVEMENT_PENALTY', 'TerrainType', 'TERRAIN_GRASS_HILLS'),
           ('ALPINE_IGNORE_PLAINS_HILLS_MOVEMENT_PENALTY', 'TerrainType', 'TERRAIN_PLAINS_HILLS'),
           ('ALPINE_IGNORE_TUNDRA_HILLS_MOVEMENT_PENALTY', 'TerrainType', 'TERRAIN_TUNDRA_HILLS'),
           ('ALPINE_IGNORE_SNOW_HILLS_MOVEMENT_PENALTY', 'TerrainType', 'TERRAIN_SNOW_HILLS');
    
    INSERT OR REPLACE INTO UnitPromotions 
        (UnitPromotionType, Name, Description, Level, Column, PromotionClass)
    VALUES ('PROMOTION_ALPINE', 'LOC_PROMOTION_ALPINE_NAME', 'LOC_PROMOTION_ALPINE_DESCRIPTION', 1, 3, 'PROMOTION_CLASS_RECON');
         
    INSERT OR REPLACE INTO UnitPromotionModifiers
        (UnitPromotionType, ModifierId)
    VALUES ('PROMOTION_ALPINE', 'ALPINE_IGNORE_GRASS_HILLS_MOVEMENT_PENALTY'),
           ('PROMOTION_ALPINE', 'ALPINE_IGNORE_PLAINS_HILLS_MOVEMENT_PENALTY'),
           ('PROMOTION_ALPINE', 'ALPINE_IGNORE_TUNDRA_HILLS_MOVEMENT_PENALTY'),
           ('PROMOTION_ALPINE', 'ALPINE_IGNORE_SNOW_HILLS_MOVEMENT_PENALTY');
    
    Well, that didn't work. For whatever reason I had to delete PROMOTION_ALPINE and re-insert it because just deleting the original modifier was causing the modifier to reappear as soon as I launched a new game and the remaining code not to load. So in that first attempt, the Scout would move through desert mountains as usual.

    The second attempt was the code above, and it just caused Alpine Promotion to have no effect. The code loaded properly, so I'm guessing the 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST' ModifierType just doesn't take a TerrainType value?

    Is there a workaround?
    -------

    One odd thing I found is that UnitPromotionType is an integer column that accepts text in UnitPromotionModifiers table:



    UnitPromotionType in UnitPromotions table accepts text though. What's going on here?
     
  2. Pikachaoomega

    Pikachaoomega Chieftain

    Joined:
    Jul 3, 2020
    Messages:
    9
    Does the Modifier "MODIFIER_PLAYER_UNITS_ADJUST_INITIATION_YIELD_POPULATION" work as like "The first time you convert a city to your religion, gain a population" like I think it does? and if so does it need amounts or types defined in it to make it work?
     
  3. AntSou

    AntSou Emperor

    Joined:
    Jun 8, 2019
    Messages:
    1,176
    The only Modifier which I see using that Type is Fez, which reads "Each time you convert a city for the first time earn 20 Science per Population of that city."

    With the following arguments:


     
  4. maconnolly

    maconnolly Chieftain

    Joined:
    Jun 3, 2019
    Messages:
    85
    Gender:
    Male
    So, I'm not familiar with that specific ModifierType - but I've just looked it up quickly. I don't think it does anything to population, as such - in the game, the use of this ModifierType is linked to the ModifierId MINOR_CIV_FEZ_INITIATION_SCIENCE_POPULATION. It doesn't have any Subject or Owner requirements, so it's hard to understand the context for me.

    That particular ModifierId has two ModifierArguments - one defining YIELD_SCIENCE and the other defining an amount of 20.

    My guess is that it is used to grant an amount of a specified yield when something happens. I can't find a text entry that gives an indication of what this something is, though.
     
  5. Pikachaoomega

    Pikachaoomega Chieftain

    Joined:
    Jul 3, 2020
    Messages:
    9
    Ahhhhh I see I see. Would it be possible to use yield_food? or just global yields like science gold etc.?
     
  6. maconnolly

    maconnolly Chieftain

    Joined:
    Jun 3, 2019
    Messages:
    85
    Gender:
    Male
    YIELD_FOOD is valid for a YieldType value, generally. But for this kind of provision (to the civilization as a whole), it'd need testing I suspect. Not sure how it would distribute said food.
     
  7. Pikachaoomega

    Pikachaoomega Chieftain

    Joined:
    Jul 3, 2020
    Messages:
    9
    Ok I was able to get this code to work with gold science and culture but not food. Is there some modifier I can use that gives population or food on converting a city?

    EDIT: I found 'EFFECT_ADJUST_CITY_POPULATION' or MODIFIER_PLAYER_NEAREST_CITY_ADD_POPULATION is there a way to connect that to like when you convert a city and to the capital.
     
    Last edited: Jul 4, 2020
  8. AntSou

    AntSou Emperor

    Joined:
    Jun 8, 2019
    Messages:
    1,176
    This also didn't work:

    Code:
    INSERT OR REPLACE INTO Requirements
      (RequirementId, RequirementType, Inverse)
    VALUES ('REQUIRES_PLOT_HAS_NOT_DESERT_HILLS', 'REQUIREMENT_PLOT_TERRAIN_TYPE_MATCHES', 1);
    
    INSERT OR REPLACE INTO RequirementArguments
      (RequirementId, Name, Value)
    VALUES ('REQUIRES_PLOT_HAS_NOT_DESERT_HILLS', 'TerrainType', 'TERRAIN_DESERT_HILLS');
    
    INSERT OR REPLACE INTO RequirementSetRequirements
      (RequirementSetId, RequirementId)
    VALUES ('RECON_ALPINE_EXCLUDE_DESERT_HILLS', 'REQUIRES_PLOT_HAS_NOT_DESERT_HILLS');
    
    INSERT OR REPLACE INTO RequirementSets
      (RequirementSetId, RequirementSetType)
    VALUES ('RECON_ALPINE_EXCLUDE_DESERT_HILLS', 'REQUIREMENTSET_TEST_ALL');
    
    UPDATE Modifiers SET SubjectRequirementSetId = 'RECON_ALPINE_EXCLUDE_DESERT_HILLS' WHERE ModifierId = 'ALPINE_IGNORE_HILLS_MOVEMENT_PENALTY';
    I'm going to read more on the "EFFECT_ATTACH_MODIFIER" EffectTypes, might be able to uncover something.

    Might also be able to use the Maryannu Chariot Archer modifier to circumvent it.

    Edit: Found "EFFECT_ATTACH_MODIFIER_IF_PROMOTION_CLASS_MATCHES". Will see tomorrow if I can do anything with it.
    ______

    I'm an idiot. This works:

    Code:
    UPDATE ModifierArguments SET Value ='TERRAIN_GRASS_HILLS' WHERE ModifierId ='ALPINE_IGNORE_HILLS_MOVEMENT_PENALTY' AND Value = 'HILLS';
    
    INSERT OR REPLACE INTO Modifiers
        (ModifierId, ModifierType)
    VALUES ('ALPINE_IGNORE_PLAINS_HILLS_MOVEMENT_PENALTY', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST'),
           ('ALPINE_IGNORE_TUNDRA_HILLS_MOVEMENT_PENALTY', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST'),
           ('ALPINE_IGNORE_SNOW_HILLS_MOVEMENT_PENALTY', 'MODIFIER_PLAYER_UNIT_ADJUST_IGNORE_TERRAIN_COST');
        
    INSERT OR REPLACE INTO ModifierArguments
        (ModifierId, Name, Value)
    VALUES ('ALPINE_IGNORE_PLAINS_HILLS_MOVEMENT_PENALTY', 'Type', 'TERRAIN_PLAINS_HILLS'),
           ('ALPINE_IGNORE_PLAINS_HILLS_MOVEMENT_PENALTY', 'Ignore', '1'),
           ('ALPINE_IGNORE_TUNDRA_HILLS_MOVEMENT_PENALTY', 'Type', 'TERRAIN_TUNDRA_HILLS'),
           ('ALPINE_IGNORE_TUNDRA_HILLS_MOVEMENT_PENALTY', 'Ignore', '1'),
           ('ALPINE_IGNORE_SNOW_HILLS_MOVEMENT_PENALTY', 'Type', 'TERRAIN_SNOW_HILLS'),
           ('ALPINE_IGNORE_SNOW_HILLS_MOVEMENT_PENALTY', 'Ignore', '1');
          
    INSERT OR REPLACE INTO UnitPromotionModifiers
        (UnitPromotionType, ModifierId)
    VALUES ('PROMOTION_ALPINE', 'ALPINE_IGNORE_PLAINS_HILLS_MOVEMENT_PENALTY'),
           ('PROMOTION_ALPINE', 'ALPINE_IGNORE_TUNDRA_HILLS_MOVEMENT_PENALTY'),
           ('PROMOTION_ALPINE', 'ALPINE_IGNORE_SNOW_HILLS_MOVEMENT_PENALTY');
    Spent the whole day on this, looking for increasingly convoluted options, when the answer was
    right in my face :mischief:
     
    Last edited: Jul 4, 2020
  9. Pikachaoomega

    Pikachaoomega Chieftain

    Joined:
    Jul 3, 2020
    Messages:
    9
    Is there a way to do If/then statement type stuff with sql like if convert then MODIFIER_PLAYER_NEAREST_CITY_ADD_POPULATION?
     
  10. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,640
    Gender:
    Male
    Location:
    Warsaw
    @Pikachaoomega

    Example 1
    UPDATE Improvements SET PrereqTech = 'TECH_ENGINEERING'
    WHERE ImprovementType = 'IMPROVEMENT_LUMBER_MILL' AND EXISTS (SELECT * FROM GlobalParameters WHERE Name = 'RES_MAX_ERA' AND Value = '2');
    This is
    if RES_MAX_ERA in GlobalParameters is 2 then move IMPROVEMENT_LUMBER_MILL to TECH_ENGINEERING

    Example 2
    UPDATE Boosts SET ResourceType = (SELECT CASE WHEN RType IS NULL THEN NULL ELSE 'RESOURCE_'||RType END FROM REurBoostsView WHERE Boosts.BoostID = REurBoostsView.BoostID);
    This is a conditional update on one field, it puts either NULLs or a value from another table with 'RESOURCE_' prefix

    Example 3
    INSERT INTO Building_YieldChanges (BuildingType, YieldType, YieldChange)
    SELECT 'BUILDING_SUKIENNICE_UPGRADE', 'YIELD_GOLD', 2
    FROM Buildings
    WHERE BuildingType = 'BUILDING_SUKIENNICE';
    This is
    if 'BUILDING_SUKIENNICE' exists then make 'BUILDING_SUKIENNICE_UPGRADE' yield 2 gold
     
  11. LeeS

    LeeS Imperator Supporter

    Joined:
    Jul 23, 2013
    Messages:
    6,857
    Location:
    Illinois, USA
    It might work assuming the game pays any attention to the RequirementSet.

    There's also a MODIFIER_SINGLE_CITY_GRANT_BUILDING_IN_CITY_IGNORE which I think just plops the building regardless of any requisites being satisfied so far as other buildings that are normally prerequisites, etc.

    Not sure how the plain old MODIFIER_SINGLE_CITY_GRANT_BUILDING_IN_CITY differs in its implementation since the EffectTypes between the two "grant building" ModifierTypes are different.
     
    maconnolly likes this.
  12. Pikachaoomega

    Pikachaoomega Chieftain

    Joined:
    Jul 3, 2020
    Messages:
    9

    Ok! I think I get this! So Is there a way I guess to check when a city converts or if like the religion crosses threshholds in numbers of cities or something that can be used like this?
     
  13. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,640
    Gender:
    Male
    Location:
    Warsaw
    No, for such cases look at @LeeS post.
    You asked if you could do sort of if-then in the sql, so I showed you how. But these are all things that happen before the game starts. Once the game is running, you can’t change anything in the database. All is read only.
    And whatever effects you wanna achieve during the gameplay, you need to either code them in advance by using e.g. modifiers or item parameters or Lua scripts, etc.
    And from your second post it seems that you are looking for some gameplay effect and this what @LeeS was addressing.
     
  14. Pikachaoomega

    Pikachaoomega Chieftain

    Joined:
    Jul 3, 2020
    Messages:
    9
    Oh! Ok! thank you! sorry about that!
     
  15. AntSou

    AntSou Emperor

    Joined:
    Jun 8, 2019
    Messages:
    1,176
    Tried adding damage to a specific terrain type:

    Code:
    INSERT OR REPLACE INTO Modifiers
      (ModifierId, ModifierType, SubjectRequirementSetId)
    VALUES ('UNIT_IN_DESERT_TAKE_DAMAGE', 'MODIFIER_ALL_UNITS_ATTACH_MODIFIER', null),
           ('UNIT_IN_DESERT_TAKE_DAMAGE_MODIFIER', 'MODIFIER_PLAYER_UNITS_ADJUST_HEAL_PER_TURN', 'FOOD_PLOT_HAS_DESERT_REQUIREMENTS');
        
    INSERT OR REPLACE INTO ModifierArguments
      (ModifierId, Name, Value)
    VALUES ('UNIT_IN_DESERT_TAKE_DAMAGE', 'ModifierId', 'UNIT_IN_DESERT_TAKE_DAMAGE_MODIFIER'),
           ('UNIT_IN_DESERT_TAKE_DAMAGE_MODIFIER', 'Amount', '-30'),
           ('UNIT_IN_DESERT_TAKE_DAMAGE_MODIFIER', 'Type', 'ALL');
    That loaded but had no effect at all. Also tried _ALL_PLAYERS_. Giving medics negative healing does work.

    Is there a way I might be able to accomplish this?

    EDIT: I can add damage to units through gradient desert storms by increasing frequency and disabling damage to infrastructure,pop,etc, and leaving only damage to units. I'll try that if I can't find a direct solution.
     
    Last edited: Jul 6, 2020
  16. maconnolly

    maconnolly Chieftain

    Joined:
    Jun 3, 2019
    Messages:
    85
    Gender:
    Male
    One more from me - which I think is a quick question, based on hypothesising rather than any practical test (shame on me).

    The Traits table allows you to define a TraitType. I believe this is the only place to define a TraitType, irrespective of that TraitType. As such, is it safe to assume that any TraitType defined therein can be applied into any other table that accepts a TraitType entry?

    The most basic usage of the TraitType are things like civilization- or leader-specific abilities, buildings, improvements - that kind of thing.

    Along the lines of that context, is the only practical use of TraitType on something like a building to restrict which civilizations/leaders can access it? Or can you use a set of criteria to apply a TraitType? Or is the limitation imposed by the fields in the individual Buildings, Districts and Improvements tables.

    Perhaps I'm asking the same question as I was before and the only answer is to use a Modifier to grant a dummy building that is a prerequisite of the building you wish to build. It's a shame RequirementSet cannot be used to drive this kind of logic, though - or maybe it can, and I just cannot get my head around which order things sit in right now. I've put in bold what I think the one-sentence version of this post is.
     
  17. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,640
    Gender:
    Male
    Location:
    Warsaw
    @maconnolly
    If you quickly go through database schema then you will notice that there is no such thing as "conditional trait". A trait is either obligatory (text not null) or not (text). You cannot apply any criteria to a trait, there is simply no such mechanics.
    Modifiers can be conditional. They have requirements, both for an owner and subjects.

    Technically yes. But it doesn't mean that it would make sense because what matters are modifiers that define a trait. They have to be valid and make sense for the object that you want to assign them to (via a trait).
     
    maconnolly likes this.
  18. maconnolly

    maconnolly Chieftain

    Joined:
    Jun 3, 2019
    Messages:
    85
    Gender:
    Male
    Yep, that all makes sense. Appreciate the speedy response. To be honest, I think what I did was ask a question that I worded so poorly, it probably hid what I was trying to ask!

    But in simple terms, I think I get it - and I am fairly clear on the 'fastest/easiest' way to achieve what I'm thinking about at this time; which is allowing buildings to be built, based on criteria that can't be defined through the Buildings table, but can be recognised through Modifier logic.
     
  19. AntSou

    AntSou Emperor

    Joined:
    Jun 8, 2019
    Messages:
    1,176
    How do I load an AST file from the CivRoyale folder via Asset Editor? They are not showing up despite CivRoyale being in the Assets folder.
    --

    What is column Spacing in RandomEvents doing? Is it the distance between tiles where events of that type may trigger? Is it the distance events of this type must maintain from one another? Minimum amount of turns between events of that type? Or something else?

    Column Animation and Sound in RandomEvent_Presentation cannot be Null, but is there a way to turn off random event movies?
     
    Last edited: Jul 6, 2020
  20. AntSou

    AntSou Emperor

    Joined:
    Jun 8, 2019
    Messages:
    1,176
    I spent days trying to figure out a way to have units take damage on desert after moving, only to encounter a bug:



    Instead of dying, it disappears and takes no extra damage :lol:.

    I might have to settle for it. At -5 it shouldn't be very frequent. But if there's a workaround, I would appreciate it.

    EDIT: What I really need is ADJUST_DAMAGE_PER_TURN. Adjust_Damage changes the base health on Desert, but it goes up +30 as soon as I leave. Adjust_Heal_Per_Turn has the above effect.

    Where can I find the weight/chance of a resource appearing in a given terrain? Selecting Terrain Types is easy, but I can't figure out how to change the relative chance of each valid terrain.
     
    Last edited: Jul 9, 2020

Share This Page