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

[Lua] Trouble with a Lua file assigning UnitPerks by default.

Discussion in 'CivBE - Modding Help & Mod Creation' started by Galgus, Sep 6, 2020.

  1. Galgus

    Galgus Emperor

    Aug 22, 2012

    I've found a workaround that works for my mod: players select a single upgrade option for Unique Units upon unlocking them that gives them the intended abilities.

    I'm trying to make a mod that lets Unique Units start with some effects that they normally only get as Unit Perks when upgrading, but I'm not sure how to do that.

    This is a mod that did assigned Unit Perks to Aliens that I've been trying to copy.

    Since some of the effects aren't in promotions I need to somehow assign them perk without replacing an upgrade.

    I'm looking in the Alien Strains mod since it assigns perks to Aliens, but that mod is marked not compatible with Rising Tide. I'm pretty sure the incompatibility is due to Alien textures changing with Biome, though.

    I'm also still not sure how it works other than that it assigns a dummy upgrade to them with an Upgrade Tier of 0: everything in the game file CivBEUnitUpgrades.xml starts at Upgrade Tier 1.

    That 0 upgrade tier also has no affinity level requirement in the mod.

    Then they have a Lua file with many entries that I'll shorten to one here:

    local iUnitKRL = GameInfo.Units["UNIT_ALIEN_KRAKEN_LEVIATHAN"].ID local iUpgradeKRL = GameInfo.UnitUpgrades["UNITUPGRADE_ALIEN_KRAKEN_LEVIATHAN"].ID local iPerkKRL = GameInfo.UnitPerks["UNITPERK_ALIEN_KRAKEN_LEVIATHAN"].ID

    for i = 0, GameDefines.MAX_PLAYERS-1, 1 do local pPlayer = Players; pPlayer:AssignUnitUpgrade(iUnitKRL, iUpgradeKRL, iPerkKRL); print("All alien strains perked up for player ".. i .."!") end

    Is the idea there that it looks for unit UNIT_ALIEN_KRAKEN_LEVIATHAN, chooses the dummy upgrade assigned to it UNITUPGRADE_ALIEN_KRAKEN_LEVIATHAN, and then chooses the perk with the effects he wanted them to start with UNITPERK_ALIEN_KRAKEN_LEVIATHAN?

    Also, would having such a dummy Unit Upgrade at tier 0 interfere with the regular upgrade progression for units?

    I'm not sure I understand the for loop, is it just doing this assigning process for every player including the Aliens, in case the player spawns an Alien via expedition?

    I've tried to get one unit with a single XML and a single Lua file, with the Lua file set in Content as InGameUIAddin but not imported into VHS, matching the AlienStrainsInit.lua file it is based on.

    I linked those in the post as txt files.

    I also turned ReloadUnitSystem On, matching the Alien Strains mod, but I'm still getting a Runtime Error in the Lua logs saying it's attempting to index a nil value where it attempts to read the new perk:

    local iUpgradeLTS = GameInfo.UnitUpgrades["UNITUPGRADE_LEV_TANK_START"].ID

    Attached Files:

    Last edited: Sep 7, 2020

Share This Page