全面战争:战锤2

全面战争:战锤2

评价数不足
How To Edit Simple Things for WH2 Chaos Invasion Script
由 MrSoul 制作
Time To Make Mod: 30mins
Time To Read Guide: 30-45mins
Difficulty: Easy/New To Modding, basic script editing
Tools Needed: Rusted Pack File Manager.
For this guide we will be looking at:
1. How to change the horde spawn time
2. How to simply increase the number of hordes which will spawn
3. How to enable the debug setting, and configure its turn numbers

While I work on QoL update to have the MCT do this for all of us with my mod;
https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2251075085
I figured writing up a quick guide would not be too hard to explain how you can edit few simple, but crucial elements of my mod's invasion script OR the vanilla script (in theory any similar invasion script too) for your ideal invasion event, so here it is.
   
奖励
收藏
已收藏
取消收藏
Getting Started with your tools
Okay first off, breathe in, breathe out.
Probably here because you want to start editing the invasion, increase hordes, or tweak similar aspects of my mod. This guide IS easy, it just takes time to fully understand what you're looking at, patience with testing sometimes, and importantly due diligence with the script, take your time, don't rush. Before you know it you'll be configuring your own crazy chaos invasion mod ;)

*For modders, or advanced users just looking to quickly figure out basic aspects of new invasion script, probably safe to just skip ahead to relevant sections.

Anyways, here's where you can find Frodo's excellent modding tool known as the Rusted Pack File Manager:
https://github.com/Frodo45127/rpfm

Documentation to set it up is all within that link, so once you're installed and successfully booted it up, point the RPFM to Warhammer 2 and open up either:
  • For Vanilla: "data.pack" (D:\Steam\steamapps\common\Total War WARHAMMER II\data, on my computer for example this is the path where the ".pack" files rest, be on same hard drive you've installed the game.)
    or
  • For my mod...well open my mod...(Same file path as above will contain a .pack file of my mod, you can safely use, edit and save this one as your version. my mod is called "!end_time_comes_daemons" in case you're squinting through the KMM trying to find it...and if you don't know what KMM is...go find it in the workshop, read the description and ditch that still janky built in mod manager lol)

Within there you'll need to navigate through the folders like so:
Script - campaign - main_warhammer - wh2_chaos_invasion.lua
(third from the top in vanilla data.pack file, right below "scripting.lua", be only script in that folder with my mod.)

Click on the .lua script named above to open it in the RFPM, you should see a bunch of 'gibberish' script now populating your right had side of the pack manager.

Once you have the "wh2_chaos_invasion.lua" script view able in the RFPM you're both ready to edit the script and nearly done with this guide! (Seriously, mainly just reading and comprehension ahead, depending on what you're looking to do your mod may only consist of a couple numerical edits in places) Next section wooo!


To Note:
Once properly installed on your computer you can easily open the RFPM on any mod you have highlighted with KMM, just takes some monkeying around with pack manager's directory settings.

This is the best place to seek direct help with the RFPM (or modding in general), should you experience issues getting it installed: https://discord.gg/z65GyvwJ
Just nicely ask for help, someone will likely direct to you the right place and/or know the answer there.

Recommend creating a backup version of your vanilla script and/or alterations to my mod. Script work can be frustrating as a single "typo" can cause it to break, having a backed up script you know works will do wonders for your sanity when you start getting into modding scripts, simple or not. As well quickly enabling the debug (details in last section) and saving that as a sort of backup will allow you a separate, easy to use mod for testing any changes you make.
Three Key Areas In the Script To Edit
For this guide we will be looking at:
  • 1. How to change the horde spawn time
  • 2. How to simply increase the number of hordes which will spawn.
  • 3. How to enable the debug setting, and configure its turn numbers
1. Changing Invasion Times


First off for our "1" above you don't need to go far, in fact both timing and horde numbers can be influenced from here.

To start, you want to start reading the script from the very top, and if you scroll down a tiny bit you will see the following section in the script's code:

"CI_EVENTS = {
{key = "INTRO", required_stage = 0, first_turn = 15, last_turn = 25, army_spawns = 0, agent_spawns = 0, chaos_effect = ""},
{key = "MID_GAME", required_stage = 1, first_turn = 90, last_turn = 110, army_spawns = 4, agent_spawns = 2, chaos_effect = "rises"}, -- rises
{key = "END_GAME", required_stage = 2, first_turn = 140, last_turn = 160, army_spawns = 8, agent_spawns = 4, chaos_effect = ""}, -- invasion
{key = "VICTORY", required_stage = -1, first_turn = -1, last_turn = -1, army_spawns = 0, agent_spawns = 0, chaos_effect = ""}
};"

You've found it! I'll just quickly explain the functions and what they all do here, but basically all you need to do is edit the numerical values in that field:
  • Intro = Pre-invasion state, only thing that really happens for the player is the "chaos stirs" text message will pop up.
  • Mid_Game = The first primary invasion of the script, but not Archeon's wave.
  • End_Game = Probably starting to piece this together yourself by now eh? final, "late game" invasion wave.
  • Victory = When the player defeats chaos and/or the state the script will default to if the invasion is disabled in the settings. This is the last stage of the script as well, despite the ominously titled "end_game" stage(think someone was a MCU fan much?).
  • First_turn/last_turn = There are no imperium values that effect the new invasion, simply a range of turns for when the script will trigger.
  • Army/agent_spawns = Base number for army and agents to spawn per stage.
  • chaos_effect: Relates to things like corruption values during the invasion, there are other parts of the script which influence this so leave it alone, it is not a simple value like the others.

Anyways, so If you wanted the chaos invasion to pop up on turn 20 you would set the CI_EVENTS table to something like this with the script:
"CI_EVENTS = {
{key = "INTRO", required_stage = 0, first_turn = 1, last_turn = 2, army_spawns = 0, agent_spawns = 0, chaos_effect = ""},
{key = "MID_GAME", required_stage = 1, first_turn = 19, last_turn = 20, army_spawns = 4, agent_spawns = 2, chaos_effect = "rises"}, -- rises
{key = "END_GAME", required_stage = 2, first_turn = 140, last_turn = 160, army_spawns = 8, agent_spawns = 4, chaos_effect = ""}, -- invasion
{key = "VICTORY", required_stage = -1, first_turn = -1, last_turn = -1, army_spawns = 0, agent_spawns = 0, chaos_effect = ""}
};"

We've edited two "stages" (intro and mid game) and tweaked a total of four numbers, this will now force the invasion "chaos stirs" text to prompt on turns 1/2 and the first wave to trigger on turns 19/20.

!Important Note! Stages require the previous stage to be set, so don't try leap frogging the last stage before intro and mid_game. If you want to bring it up early, or only have a single wave invasion, set the turn numbers for the first two stages to be lower than what you desire the final wave to be. Like so:

{key = "INTRO", required_stage = 0, first_turn = 5, last_turn = 6, army_spawns = 0, agent_spawns = 0, chaos_effect = ""},
{key = "MID_GAME", required_stage = 1, first_turn = 8, last_turn = 9, army_spawns = 4, agent_spawns = 2, chaos_effect = "rises"}, -- rises
{key = "END_GAME", required_stage = 2, first_turn = 11, last_turn = 12, army_spawns = 8, agent_spawns = 4, chaos_effect = ""}, -- invasion

And if you want to skip the mid wave as I mentioned above, then as we'll discover below how to do, just set your "army_spawns" to 0 for the mid_game event.
2. Changing Number of Hordes


In our sample script we tweaked above we've got a REALLY early mid game invasion coming up here, now let's increase the army amounts, or "army_spawns" of our mid_game stage for the invasion.

There are two ways to do this.

One is directly increasing the number of hordes which spawn in our script, like so:
" {key = "MID_GAME", required_stage = 1, first_turn = 19, last_turn = 20, army_spawns = 9001*, agent_spawns = 2, chaos_effect = "rises"}, -- rises"

(*I WOULD not actually try this many, just a joke lol)

The second way, perhaps more nuanced way is to increase the multiplier, oh but wait where's that in the script?

Scroll down slowly past a few sections, and right below the "_ARMY_SPAWNS" blocks you will see the header for a function called: "CI_ARMY_SETTINGS" with the following table:
{key = "Off", multiplier = 0},
{key = "On", multiplier = 1},
{key = "Hard", multiplier = 1.5},
{key = "Very Hard", multiplier = 2},
{key = "Legendary", multiplier = 3}
};

By editing these values we can influence the default number of hordes with higher or lower multipliers then vanilla has present. This will allow you far greater control per campaign, as well as the ability to select multiple preset multiplies you've configured without having to always manually edit the horde counts in the first script section we looked at, called "CI EVENTS".

Now there is only one more section to be mindful of and that is the section just above where you currently are in the script called "_ARMY_SPAWNS".

The main factions will not have a value, but "lesser" factions like norsca and beastmen do, for example let's bump those beastmen up over 9000 too(again just a joke, do not try this edit lol):

CI_BEASTMEN_ARMY_SPAWNS = {
faction_key = "wh_dlc03_bst_beastmen_chaos",
effect_bundle = "wh_main_bundle_military_upkeep_free_force",
buildings = {"wh_dlc03_horde_beastmen_herd_5", "wh_dlc03_horde_beastmen_gors_3", "wh_dlc03_horde_beastmen_minotaurs_1"},
army_count = 9001,
positions = {
{788, 605}
}
};

Now that's a lot of milk!
For what it's worth too this section controls some of the functions of how, and what armies spawn during the invasion, but that's not the only part of the script which influences those factors, and ultimately, that's a story for another time.
3. Setting the Debug


Okay last thing, and this time our two sections we need to work with are at the very top, and near the very bottom and are very self explanatory.

So at the top you will see the following line of script:
"CI_DEBUG = false;"
You can set this to true for testing, etc purposes and the script will go off the following table located near the bottom:

"function CI_debug_setup()
if CI_DEBUG == true then
out.chaos("!!!! DEBUG IS ACTIVE !!!!");
CI_EVENTS[1].first_turn = 1;
CI_EVENTS[1].last_turn = 2;
CI_EVENTS[2].first_turn = 2;
CI_EVENTS[2].last_turn = 3;
CI_EVENTS[3].first_turn = 4;
CI_EVENTS[3].last_turn = 5;

local player = cm:get_local_faction_name(true);..."

Only thing to point out here is "CI_EVENTS[1]",CI_EVENTS[2]" and so on are just the respective stages of the invasion as we've discussed earlier in this guide. 1=intro, 2=mid game, 3=late game.

You can use this as a test, or as an alternative way to force the turn to change, for my mod for example I just edit the CI_EVENTS table at the top and it works fine, but that's where it is, and that's where you change the turns the debug uses.

If you're making changes to the turn numbers within the main script, obviously enabling the debug will over ride those changes, just a heads up more for when you end up testing your mod, a debug version is great overall for creating an invasion mod, but if you're just changing turn numbers at the top, you don't need it.
Saving Your Mod and Final Notes
Congrats you now know how to edit these simple things in the invasion script for your own nefarious desires.

The last thing you need to do is of course, save your new pack file as a mod with its own name.

If you're editing vanilla you can just toss out everything but your script (or export it, then add it to a brand new mod with the RFPM being the easiest method there)

If you're editing my mod, just save it as a prefix with your own name instead of soul, ie if you're name is Susan, save it as "!end_time_comes_daemons_susan.pack" or w/'e you want to, but point being if you over write my mod, when I update it again, Steam may just overwrite your script changes!

Oh, obviously make sure you're saving it/copying it to your data folder once you're done editing.

If you've noticed I have updated my main mod, your best bet would to be just going in to my mod again, making the simple numerical edits etc again and saving it as your mod. That way if I've changed anything else in the script your not missing out any new features, fixes, etc. Same logic could be applied to any other mod, or vanilla patches for that matter if CA changes something in the script which is unlikely for WH2 at least going forwards now.

As well you may want to create two versions of your invasion script mod, one with the debug enabled and one without so you can 1. Test your new changes/with other mods you use quickly and 2. Have an easy to use companion mod for testing any future changes you may want to make. Can call that one "!end_time_comes_daemons_susantest.pack" for another example.

Here's a song for you too:
9 条留言
MrSoul  [作者] 2022 年 9 月 14 日 上午 8:07 
Link to Da Modding Den discord too:

https://discord.com/invite/moddingden

Great place, just read the rules and you’ll see how laid it out, have entire wiki working on so if ever doing anything beyond just editing this, wonderful place to seek help and resources.
MrSoul  [作者] 2022 年 9 月 14 日 上午 8:05 
Ahhhh clever clever ya the 19 may not do anything cos base engine only goes that far, thx for sharing
Macallan 2022 年 9 月 14 日 上午 4:32 
Ty a lot. After some tries I managed to make it work haha. Changing the 19 to 39 didn't worked idk why but "forcing" the spawn as mandatory units worked and all armies spawned with 19 randon + these mandatory units I added. :D
MrSoul  [作者] 2022 年 9 月 12 日 下午 3:55 
Np and good luck o7 sounds like a cool idea you’re working on, one thing should note might be best to use that method to just check the script quickly, and always keep a backup in RFPM you know works where I’d personally make final edit once done testing versus copying and pasting back and forth, or better yet there are actual lua editing programs, the note pad search just how I quickly find stuff right
Macallan 2022 年 9 月 12 日 上午 9:57 
ahh nice. This trick with copy and paste to notepad will make it easier no doubt. Tyvm for the help!!!
MrSoul  [作者] 2022 年 9 月 12 日 上午 9:05 
One way can do it too, copy and paste to note pad or somewhere can “find in” and search for 19 in script, might be present few places but it’s one next to army Gen lists
MrSoul  [作者] 2022 年 9 月 12 日 上午 9:03 
Hey, top if my head(been a while since looked this over), should be a line by the “army Gen lists”(ie where put what kinds of units), beside general for the army iirc, it’ll say 19(ie general + 19 troops), setting that to 39 should do the trick
Macallan 2022 年 9 月 12 日 上午 7:53 
Please How to mod the number of units per spawned army? I mod my game to 40 units per amy so I want the invasion adjusted to that. I can't find where or how to do that.
FentanylWallaby 2021 年 12 月 12 日 下午 10:31 
BY SIGMAR YES!!!