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

Samurai replaces swordsman - Help needed

Discussion in 'Mod Creation Help' started by Sesostris, Feb 5, 2017.

  1. Sesostris

    Sesostris Chieftain

    Joined:
    Sep 8, 2013
    Messages:
    34
    Hi all.

    I'm trying to create my first-ever mod to make the samurai a straight-up replacement of the swordsman, but I simply cannot get the changes to appear in the game. I've looked at a few similar mods like Unit Rebalance but without luck and I'm getting too frustrated to keep looking, so I'd greatly appreciate help on this.

    From 'Samurai replaces swordsman.modinfo'

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <Mod id="a69ded18-c696-4916-a6ab-2669de8838ad" version="1">
      <Properties>
        <Name>Samurai replaces swordsman</Name>
        <Teaser>The samurai becomes a straight-up replacement of the swordsman, such that warriors upgrade to swordmens and the unt is available with Iron working.</Teaser>
        <Description>The samurai normally becomes available so late that you don't get much use out of him before the musketman becomes available, and you have to build swordsmen from scratch instead of upgrading your experienced warriors.
            This mod addresses that by making the samurai a straight-up replacement of the swordsman and makes the unit available with Iron Working.
            </Description>
        <Authors>Sesostris</Authors>
        <ShowInBrowser>Show</ShowInBrowser>
        <EnabledByDefault>1</EnabledByDefault>
        <EnabledAtStartup>1</EnabledAtStartup>
      </Properties>
      <Files>
        <File>Samurai replaces swordsman.xml</File>
      </Files>
      <Components>
        <UpdateDatabase id="SamuraiReplacesSwordsman">
          <Items>
            <File>Samurai replaces swordsman.xml</File>
          </Items>
        </UpdateDatabase>
      </Components>
    </Mod>
    
    From 'Samurai replaces swordsman.xml' in the same folder:

    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <GameInfo>
      <UnitReplaces>
        <Where CivUniqueUnitType="UNIT_JAPANESE_SAMURAI" />
        <Set ReplacesUnitType="UNIT_SWORDSMAN" />
      </UnitReplaces>
      <Units>
        <Update>
          <Where UnitType="UNIT_JAPANESE_SAMURAI" />
          <Set PrereqTech="TECH_IRON_WORKING" MandatoryObsoleteTech="TECH_REPLACEABLE_PARTS" />
        </Update>
      </Units>
    </GameInfo>
    
     
  2. ITcore

    ITcore Warlord

    Joined:
    Dec 25, 2016
    Messages:
    248
    Gender:
    Male
    Location:
    127.0.0.1
    Code:
    INSERT INTO UnitReplaces (CivUniqueUnitType, ReplacesUnitType) VALUES ('UNIT_JAPANESE_SAMURAI', 'UNIT_SWORDSMAN');
    Try that in an SQL filetype. I'm no entirely sure how to insert new values with XML, although there is probably a way. Updating the prereq tech and obsolete tech should still be fine in the XML.
     
  3. Sesostris

    Sesostris Chieftain

    Joined:
    Sep 8, 2013
    Messages:
    34
    It works! :D Thank you very much for the help.

    Actually, another question: If I instead wanted to make the Swordsman upgrade to the Samurai while keeping everything else the same, how would I do that? I.e., how would I make the Swordsman upgrade into a Samurai, but of course only for Japan?
     
  4. niklas153021

    niklas153021 Chieftain

    Joined:
    May 23, 2016
    Messages:
    37
    Gender:
    Male
    Location:
    Germany
    I'd make the Samurai replace the Musketman, since that's the unit Swordsmen upgrade to by default. So simply replace the UNIT_SWORDSMAN with UNIT_MUSKETMAN. Correct me if I'm missing something.
     
  5. Sesostris

    Sesostris Chieftain

    Joined:
    Sep 8, 2013
    Messages:
    34
    But wouldn't that prevent the samurai from upgrading into the musketman? That would be a disadvantage for Japan, since the samurai is weaker.
     
  6. niklas153021

    niklas153021 Chieftain

    Joined:
    May 23, 2016
    Messages:
    37
    Gender:
    Male
    Location:
    Germany
    Yes, I guess it would. So as I understand this, what you want to do is having the Samurai between the Swordsman and the Musketman in the upgrade line. Then you should delete the Samurai from the UnitReplaces table:
    Code:
    DELETE FROM UnitReplaces WHERE CivUniqueUnitType='UNIT_SAMURAI';
    Japan should still be able to build Samurais, but now also Swordsmen
     
  7. ITcore

    ITcore Warlord

    Joined:
    Dec 25, 2016
    Messages:
    248
    Gender:
    Male
    Location:
    127.0.0.1
    If you want to do a Swordsman > Samurai > Musketmen then you need:

    Code:
    DELETE FROM UnitReplaces WHERE CivUniqueUnitType='UNIT_JAPANESE_SAMURAI';
    
    UPDATE UnitUpgrades SET UpgradeUnit='UNIT_JAPANESE_SAMURAI' WHERE Unit='UNIT_SWORDSMAN';
    The issue with that, however, is it only works for the Japanese. You're best bet is to either keep the Samurai replacing the Swordsman or to have the Samurai a separate unit (but stronger) and keep the Swordsman > Musketman line. Or buff the Samurai and have it replace the Musketman and have the Japanese be similar to "The Last Samurai".
     
    Sesostris likes this.
  8. Sesostris

    Sesostris Chieftain

    Joined:
    Sep 8, 2013
    Messages:
    34
    Thanks for the advice both of you. My second goal was indeed to have the samurai between swordsman and musketman, such that your experienced swordsmen could upgrade into samurai instead having to build noob samurai when the unit become available.

    I didn't think it would be that hard to squeeze a unit in between the established upgrade paths. I think I'll go with ITcore's advice and make The Last Samurai then.
     

Share This Page