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

How to edit an existing units values

Discussion in 'Mod Creation Help' started by LPG17, Feb 26, 2018.

  1. LPG17

    LPG17 Chieftain

    Joined:
    Feb 26, 2018
    Messages:
    5
    Gender:
    Male
    Can somebody please link me to a detailed guide or tell me how to edit an existing units values.
    I want to edit the production cost of pikemen from 200 to 180.
    Here is what I have, it does not work for me.
    If somebody knows what is wrong please let me know I am new to modding and SQL but not new to coding.
    C# and C++

    My modinfo file: (PikemenCost.modinfo)
    <?xml version="1.0" encoding="utf-8"?>
    <Mod id="77773a5c-a91a-7cc8-ae88-991777a777bd" version="1">
    <Properties>
    <Name>PikeMenCost</Name>
    <Description>PikemenCost180</Description>
    <Teaser>PikemenCost180 Teaser</Teaser>
    <Authors>LPG</Authors>
    <SupportsSinglePlayer>1</SupportsSinglePlayer>
    <SupportsHotSeat>1</SupportsHotSeat>
    </Properties>
    <FrontEndActions />
    <InGameActions>
    <UpdateDatabase id="UNIT_PIKEMEN">
    <File>PikemenCost.sql</File>
    </UpdateDatabase>
    </InGameActions>
    <Files>
    <File>PikemenCost.sql</File>
    </Files>
    </Mod>

    My SQL file: (PikemenCost.sql)
    UPDATE Units SET Cost=180 WHERE UnitType='UNIT_PIKEMEN';
     
  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,733
    Location:
    Illinois, USA
  3. LPG17

    LPG17 Chieftain

    Joined:
    Feb 26, 2018
    Messages:
    5
    Gender:
    Male
    I changed my files and it still does not work, I'm thinking maybe it's my mod info file but I'm not sure.
    My SQL file: (PikemenCost.sql)
    UPDATE Units SET Cost=180 WHERE UnitType='UNIT_PIKEMAN';

    I changed my modinfo to update database ID NewAction instead of UNIT_PIKEMAN is that correct?

    (PikemenCost.modinfo)
    <?xml version="1.0" encoding="utf-8"?>
    <Mod id="77773a5c-a91a-7cc8-ae88-991777a777bd" version="1">
    <Properties>
    <Name>PikeMenCost</Name>
    <Description>PikemenCost180</Description>
    <Teaser>PikemenCost180 Teaser</Teaser>
    <Authors>LPG</Authors>
    </Properties>
    <InGameActions>
    <UpdateDatabase id="NewAction">
    <File>PikemenCost.sql</File>
    </UpdateDatabase>
    </InGameActions>
    <Files>
    <File>PikemenCost.sql</File>
    </Files>
    </Mod>
     
  4. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,733
    Location:
    Illinois, USA
    I don't see anything else obviously wrong with your mod's code so the only thing I can suggest is to zip the mod from the game's "MODS" folder and attach to a post so your mod can be run by me or someone else here on the forum. zip the entire folder of the mod rather than the individual files from the mod.
     
  5. LPG17

    LPG17 Chieftain

    Joined:
    Feb 26, 2018
    Messages:
    5
    Gender:
    Male

    Attached Files:

  6. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,733
    Location:
    Illinois, USA
    Something seems to have gone awry in the creation of the mod itself. The sql code is fine, and executed fine when I dropped it into and executed it in a SQL database viewer program. But the game would not execute the code and was reporting a syntax error related to the file. Civ6 will report in database.log certain types of errors within the structure of the modinfo file as syntax errors in an XML or SQL file

    I built my own version of the mod on my end using Modbuddy and simply dropped your code into my SQL file and everything worked properly in-game. I've attached the working version of the mod. For the life of me though I cannot see where the problem is in your mod in either the modinfo file or the SQL file, so if you saved any of this from any other program (like a text editor other than Notepad or Notepad++) at any time there may be hidden characters appended to one or other of the files that the game simply does not like.
     

    Attached Files:

  7. LPG17

    LPG17 Chieftain

    Joined:
    Feb 26, 2018
    Messages:
    5
    Gender:
    Male
    Your mod works like a charm. I have no idea what I can't get mine to work.

    I can't for the life of me get my own project to work, I made it again from scratch.
    What I did:
    Open Modbuddy
    create empty mod
    add SQL file
    typed out manually:
    UPDATE Units SET Cost = 180 WHERE UnitType='UNIT_PIKEMAN';
    saved the project
    Build the project
    Launch the game with the newly created mod enabled and all other mods disabled.
    PikeMan still cost 200 instead of 180.

    Is there a video guide somewhere of editing a unit value from scratch showing the entire process on Modbuddy? have I got it right?
     
  8. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,733
    Location:
    Illinois, USA
    Did you remember to create an InGameAction in modbuddy specifying UpdateDatabase as the type of action and then selecting the SQL file from the menus for adding a file to an action ?
     
  9. LPG17

    LPG17 Chieftain

    Joined:
    Feb 26, 2018
    Messages:
    5
    Gender:
    Male
    Thank you very much for all your help, my first mod now works.
    I don't understand what creating an InGameAction in mod buddy does differently compared to typing it out manually EG
    <InGameActions>
    <UpdateDatabase id="NewAction">
    <File>GameData1.sql</File>
    </UpdateDatabase>
    </InGameActions>

    It looks the same to me, if you know the technical difference i'd love to know.
     
  10. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,733
    Location:
    Illinois, USA
    There really shouldn't be a difference. The first few mods I made for civ6 were before Modbuddy was released and they worked fine. I know some people still make their mods without using modbuddy at all.

    But sometimes wierd stuff happens.
     

Share This Page