A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #
Home » Guides » Total War: Warhammer II - Creating SCRAP Upgrades

Total War: Warhammer II - Creating SCRAP Upgrades

Written by HunterGerhart   /   Jun 8, 2020    


For assigning, creating and modifying SCRAP upgrades with existing and new faction resources.

Guide to SCRAP Upgrades



Stats for SCRAP Upgrades



unit_purchasable_effect_sets

Adds SCRAP designs to units. Faction unique SCRAP exist here too (limited elsewhere), if a unit can ever-ever-ever have a SCRAP upgrade it will be here. This is the only table required to assign an existing SCRAP upgrade to an existing unit.

  • Unit: The unit's Key that you want to have a SCRAP upgrade.
  • Purchasable Effect: Your SCRAP upgrade Key.
  • Is Exclusive: Checkmark! Unchecked the game will permit a unit with this (and only this) SCRAP upgrade to choose a new SCRAP upgrade later on. You cannot have more than one SCRAP upgrade active per unit.

unit_purchasable_effects

Assigns SCRAP upgrades with their effects, costs & ui icon.

  • Key: Your SCRAP upgrade Key.
  • Effect Bundle: (as above)
  • Cost: (as above)
  • Category: The icon art group; weapon/armour etc. (See: unit_purchasable_effects_categories)

effect_bundles_to_effects_junctions

The meat and potatoes of how your SCRAP upgrade modifies a unit. There's a lot to explain here!

  • Effect Bundle Key: Your SCRAP upgrade Key.
  • Effect Key: We've not seen this Key before, it assigns a campaign effects (such as for Lord/Hero skills trees, or research). These will already exist for your use but there's HUGE variety to pick from. Take a look through existing rows, it helps.
  • Value: Positive or Negative numbers. You'll need to know if your Effect Key is additive (-20 Speed = Value: -20) or multiplicative (-20% Speed = Value: 0.8). You cannot control which is true in this table, so you'll need the right Effect Key to match preference.
  • Effect Scope: Assigns what/who a unit's SCRAP upgrade affects. If you want this SCRAP upgrade to affect its owner only, use "character_to_character_own".
  • Advancement Stage: When your SCRAP upgrade effect applies. Use "start_turn_completed" if you want a SCRAP upgrade to work immediately after purchase.

effect_bonus_value_unit_attribute_junctions

Used for applying ablities to scrap upgrades, if you want that.

  • Effect: Your SCRAP upgrade Key.
  • Bonus Value Id: "enable"
  • Unit Ability: The Key of the ability you want the SCRAP upgrade to grant the unit.

resource_cost_pooled_resource_junctions

SCRAP upgrade costs and what resource pool they draw from.

  • Resource Cost: Your SCRAP upgrade Key.
  • Pooled Resource Factor: Make sure it's "grn_salvage_unit_upgrade"
  • Amount: Negative integers, unless you want a player to earn the resource instead.

resource_costs

For tracking SCRAP spending. Stick with SCRAP's defaults for now.

  • Id: Your SCRAP upgrade Key.
  • Treasury Cost: "0"
  • Expenditure Type: "ACTIONS"
  • Income Type: "BATTLE_KILLS"
  • Customizing SCRAP Presentation
  • unit_purchasable_effects_categories
  • Cosmetic, used for SCRAP icons.
  • Key: Organizational, armour, weapon etc.
  • Icon Path: The filename of the icon image. Unlike other db tables, this requires the file extension ".png" to be added.

effect_bundles

Name and description text for your SCRAP upgrade.

  • Key: Your SCRAP upgrade Key.
  • Localised Description: Your text here, do not add a period at the end of the line (automatically added)!
  • Localised Title: The name of your SCRAP upgrade in the UI. You can have all the periods you want here.
  • Bundle Target: Make sure its "none", I don't understand this collumn fully.
  • Priority: Make sure its "1".
  • Ui Icon: Contrary to how it sounds, leave this empty.

Navigate now to "local_en.pack -> text -> db". These are different from db tables and have unique formatting for Keys.

effect_bundles.loc

Remember those descriptions you made earlier? This table helps the game localise in English. We also have our first taste in this guide of text db formating. Your SCRAP upgrade Key will have mumbo-jumbo that comes before it that will vary for each table.

  • Key: "effect_bundles_localised_title_" then add your SCRAP upgrade key after the underscore.
  • Text: "Localised Title" from "effect_bundles"
  • Tooltip: Checkmark!
  • SCRAP Upgrade Restrictions
  • unit_purchasable_effect_lock_reasons
  • Anything here will be restricted until they are unlocked (such as with technology).
  • Key: Your SCRAP upgrade Key.

Faction exclusivity is done through "wh2_dlc15_salvage.lua".

technology_effects_junction

Whenever a technology is completed, this table is what makes it take effect, by how much, and where those effects are applied.

  • Technology: The Key your desired technology restriction has.
  • Effect: Your SCRAP upgrade Key.
  • Value: "1"
  • Effect Scope: "faction_to_faction_own_unseen"

resource_cost_pooled_resource_junctions

Used by Greenskins to determine the universal SCRAP cost of techs that unlock SCRAP upgrades. This is for reference, incase you wanted to make each tech price to vary. Do NOT change this row.

  • Resource Cost: "greenskin_technology"
  • Pooled Resource Factor: "grn_salvage_tech"
  • Amount: "-50"

Applying SCRAP costs to technologies is done through "wh2_dlc15_salvage.lua".

resource_costs

Used by Greenskins to track technology SCRAP spendatures.

  • Id: "greenskin_technology"
  • Treasury Cost: "0"
  • Expenditure Type: "TECHNOLOGY"
  • Income Type: "TECHNOLOGY"

campaign_effect_list_effect_junctions

Grom's cooking is contained within this table, which also can also unlock your SCRAP upgrades.

  • Effect list: Grom Food Key. (See: campaign_effect_lists)
  • Effect: Your SCRAP upgrade Key.
  • Value: "1"
  • Scope: "faction_to_faction_own_unseen"

SCRAP for All Races



It's possible to give Greenskins Oathgold and have them spend it on a new upgrade, or to give SCRAP upgrades to the Dawi. Both are a time consuming venture, but making it work with full functionality of design for the Dawi is far more so. I will do what I can to list the fundamentals that are needed to enable SCRAP upgrades for other races:

  • A resource.
  • A way to earn that resource.
  • A unit.
  • A SCRAP upgrade to spend that resource.

  • (Optional) New text so SCRAP isn't mentioned.
  • (Optional) Technology Requirements attached to existing tech.
  • (Optional) New Technology Branches added to existing Tech Trees.
  • (Optional) New Skills for Heros/Lords.
  • (Optional) A new scripted listener to handle unlock restrictions.
  • (Optional) A new scripted listener to handle AI SCRAP Upgrades.

Using an Existing Resource

Certain factions have existing resources beyond gold, others do not.

  • Malus: def_malus_sanity
  • Reikland, Golden Order: emp_prestige
  • Greenskins: grn_salvage
  • Tomb Kings: tmb_canopic_jars
  • Cult of Sotek: lzd_sacrificial_offerings
  • Nakai: lzd_old_ones_favour
  • Clan Skyre: skv_reactor_core
  • Clan Eshin: skv_dust
  • Skaven: skaven_food
  • Dwarfs: dwf_oathgold
  • Vampire Counts: vmp_blood_kiss
  • Vampire Coast: cst_infamy
  • Yvresse: wardens_supply

pooled_resource_factor_junctions

Every resource has a tally of how its been spent or collected when inspected on the ui. The game needs a way to track upgrade expendatures.

  • Resource: Existing Resource Key
  • Factor: "wh2_dlc15_resource_factor_unit_upgrade"
  • Unique Id: Tempting it may be to follow existing naming conventions by adding "_upgrade" to the Existing Resource Key, for compatability this should be unique to you.

resource_cost_pooled_resource_junctions

Familiar place, come here often? No longer using SCRAP, we need to make sure everything is correctly setup here, so change the following.

  • Pooled Resource Factor: Unique Id (See: pooled_resource_factor_junctions).

Creating New Resources



Adding a new resource should be compatible with other mods. Only change rows you've added, and things should remain compatible with like-minded modders.

campaign_group_crafting_infos

Get your Big Thinkin' cap on cause you need a new Key for your New Resource, hereby referred to as New Resource Key. Consider what racial group will have this New Resource Key. Here's a list, note that most have the word "feature":

  • diplomacy_Subcult_Kislev
  • wh_feature_all
  • wh_feature_bretonnia
  • wh_feature_chaos
  • wh_feature_dwarfs
  • wh_feature_empire
  • wh_feature_greenskins
  • wh_feature_norsca
  • wh_feature_vampire_counts
  • wh_dlc03_feature_beastmen
  • wh_dlc05_feature_wood_elves
  • wh2_dlc09_feature_tomb_kings
  • wh2_dlc11_feature_vampire_coast
  • wh2_main_feature_high_elves
  • wh2_main_feature_dark_elves
  • wh2_main_feature_lizardmen
  • wh2_main_feature_skaven

  • Campaign Group: Pick from the above Key list.
  • Unique Resource: Your New Resource Key.

pooled_resources

Making a resource exist is incredibly simple but thats all this table does.

  • Key: Your New Resource Key.
  • Minimum: "0", whatever's your preference.
  • Maximum: "10000", less than nine digits.
  • Persistent Factors: Unchecked!
  • Ai Ignored: Checked!
  • Default Factor: "looting", feel free to experiment with this one.
  • Optional Icon Path: File name, with a ".png" file extension in the collumn.

Earning Resources



campaign_group_pooled_resources

Starting amounts for resources are handled here.

  • Campaign Group: Pick from the above Key list.
  • Resource: Your New Resource Key.
  • Initial Amount: Make sure this number is within your assigned minimum and maximum values (See: pooled_resources).

campaign_group_post_battle_looted_pooled_resources

Post battle earnings, scaling with inflicted casualties. The enemy death count goes through some BEDMAS and you get a number, checked against thresholds.

  • Campaign Group: Pick from the above Key list.
  • Resource Factor: Your New Resource Key.
  • Exponent Multiplier: 0.4? Sure.
  • Exponent: 0.65? Sure.
  • Base Multiplier: 0.04? Sure.
  • Minimum: After small battles, this is the lowest amount earned.
  • Maximum: The max earned from big battles.
  • Base Amount: Same as the minimum.

effect_bonus_value_pooled_resource_factor_junctions

SCRAP-wise, this table handles earnings while raiding. Things like Oathgold grudge earnings, Skaven Food raiding, Skaven Food earnings through tech... if a resource is earned actively it will be here.

  • Effect: The Key for what effect will cause the change, like Skaven Pasture income.
  • Bonus Value Id: "base_amount"
  • Resource Factor: (See: "pooled_resource_factor_junctions")

effect_bonus_value_pooled_resource_junctions

Used to increase maximum storage of a resource through effects.

  • Effect: The Key for what effect will cause the change, like Skaven Pasture income.
  • Bonus Value Id: "maximum_mod"
  • Pooled Resource: Your New Resource Key.

New Resource SCRAP Upgrades



SCRAP upgrades are incredibly cross-faction compatible. You can add any unit into "unit_purchasable_effect_sets" and they'll be upgraded with that upgrade's costs (assuming you've done all the needed steps above).

wh2_dlc15_salvage.lua



This section is under warnings of ramble, vagueness and perhaps completely unneeded effort, read on if you dare, WIP!

You may notice at this point things aren't functioning fully for anything that isn't a Greenskin or an existing SCRAP upgrade. That's because there's programming to do now. A .lua file is a text file, nothing extra about it. Stay with me now, it's just like what you've been doing this whole way, taking existing structure and changing boxes. The dev's at CA have programmers that leave notes within the code explaining what each 'block' of code is designed to do. Admittedly, they skipped commenting each and every block, so I'll try to walk you through it.

This first uncommented section is variable declaration. Think of each "local" as a table, with rows and columns inside the curly braces. Maybe you'll recognise some Keys from the data pack? I won't show all the data all here, far too lengthy!

local All_Upgrades = {};
local Greenskin_subc = "wh_main_sc_grn_greenskins";
local faction_exclusive_available = {};
local faction_exclusive_upgrade_index = {};
local Upgrade_tech_keys = {};
local Upgrade_locked_properly = {};
local Advice_fired = false;
local Upgrade_techs = {};
local cooldown = 10

Personally, the lack of a ";" on the last variable bothers me. Semicolons are used to contextualize code into sections, like... stopping a run on sentence. However, in this current coding scheme it's not mandatory there. I'm more familiar with C#, so bear with my ignorance. Only one more block to go!

function add_grn_unit_upgrade_listeners())

Now before we even look at the comments from the dev team, I need to explain the last part of the name there, "listeners".

Imagine you clicked on a button. You want that button to do something right? A listener waits, then responds to something that happens.

Therefore, this block of code is dedicated to setting up all the listeners needed to add SCRAP upgrades into the Greenskin faction of Total War: Warhammer 2. So let's go over all the listeners this block creates.

"Unit_upgrade_lock_tech_grn", "FactionTurnStart"

At the start of a faction's turn, locks all SCRAP upgrades for the player by technology, then locks all faction specific SCRAP upgrades. Finally, it gives the player SCRAP resource.

"Unit_upgrade_tech_grn", "ResearchCompleted"

The listener waits for a player of the Greenskin faction to complete a technology. Then, if the tech matches one of the previously declared "local" variables, the listener unlocks the SCRAP upgrade.

"Unit_upgrade_available", "CharacterSelected"

Active when a lord is selected by a player faction, that has units. Then it goes through each unit and checks if it has purchasable SCRAP upgrades. Finally, it notifies the player the SCRAP upgrade is available.

"turn_start_upgrade_units", "FactionTurnStart"

On the start of a Greenskin AI turn, checks the 10 turn timer. If it's times for free units, lock the AI from faction restricted SCRAP upgrades. Afterwards it counts every unit that AI has (excluding garrisons) and decides a random number of those eligible to get SCRAP upgrades.

The bottom section as it reads is for saving and loading. First it determines if the player's SCRAP upgrades were locked properly, and whether or not to show available SCRAP upgrades on units cards.

Where is this all headed?

While you can assign SCRAP upgrades to units of non-Greenskins, those races lack the locking functions present here to implement restrictions of any kind beyond price. Non-Greenskin AI will also experience acute undeadness of brain, drooling on your hard work as they fail to notice SCRAP upgrades, or overindulge and give into the hunger. The answer would be to add listeners that draw from new variable declarations and check different culture groups/technology trees. Or, because I haven't done the work myself yet, I could be entirely wrong and this is delving too deep into the rabbit hole.

Written by HunterGerhart.