Invasion Party and Module_Script Errors

Users who are viewing this thread

Ishapar

Regular
Remember the Dark Knight's Invasion in the Native Expansion mod? I was always interested in adding some type of invading party(s) to the game to act as a separate threat from bandits and lords. I didn't find much information on how to do this other than this topic: https://forums.taleworlds.com/index.php?threads/an-invasion-osp-script.231383/

Lumos provided a simple code to have an invading party of Swadian Knights spawn and chase any other party. I'll provide his codes here:

module_party_templates:
Python:
  Code:

 

         ("invaders","Invaders",icon_khergit|carries_goods(2)|pf_show_faction,0,fac_outlaws,bandit_personality,[(trp_swadian_knight,100,320),]),

       # I hate the evil swadians...

module_triggers:
Python:
Code:
 
       (8765,0,ti_once,[],[
     (set_spawn_radius, 4),
     (try_for_range, ":i", 0, 251), # 251 = number of invaders to spawn + 1
           (spawn_around_party, "p_town_1", "pt_invaders"),
           (val_add, ":i", 1), # i++, so no "unused local var" message
     (try_end),

So I tried to paste both codes in my module. I pasted the module_party template first and was able to build a batch file with no problems. Anytime I try to paste the module_triggers code and build the batch, however, I get "WARNING: Global variable never used" for every single variable in the batch. I tried running the mod and...let's just say it is very buggy. I am not sure what to think.

When you add a code to module_triggers, does the placement of the code matter? What else could be causing those warnings? Is there a different way people have done an invading party that can give input on these errors?

Thanks.
 
Last edited:
Literally a few posts under the main one (https://forums.taleworlds.com/index.php?threads/an-invasion-osp-script.231383/) there are instructions on how to avoid build module errors/ warnings. Look up posts of MadVader and Maxim Suvorov and implement the solution into your module. Report back if you succeed (or not).
It did no difference. I pasted the same code at the end of module_triggers and changed the ":i" to "unused" as both of them suggested. I still get the same Warning: Global variable never used when I try to build the batch file. I encountered the same bugs and issues in my mod when trying to launch it. There was no other followup to that post to search for anymore solutions, so I am back to asking you for help.

What does this warning mean?

This is where I put the code in my module_triggers template:

Python:
Code:

(8765,0,ti_once,[],[
     (set_spawn_radius, 4),
     (try_for_range, ":unused", 0, 251), # 251 = number of invaders to spawn + 1
           (spawn_around_party, "p_town_1", "pt_invaders"),
           (val_add, ":unused", 1), # i++, so no "unused local var" message
     (try_end),

]

This was at the end of the file just before the last bracket. I am using mrclopes Diplomacy 4.3-MRCmod and bugfixes as the mod I am trying to modify: https://www.nexusmods.com/mbwarband/mods/6044. I have already succeeded in modifying the module_parties template and built the batch file with no errors. I have tried to copy and paste Native's variable.txt file into my mod as I saw some suggest in regard to the variable errors, but there is no difference. I know there were other times I tried to paste codes for other open scripts on this forum to either the mission or trigger template and would receive the same errors. What are these warnings about? It doesn't help when I have no idea what the error is about as there is no traceback comapred to a syntax error: instead every variable that is built upon gets this warning and ends up bugging the game.
 
Upvote 0
You seem to be more literate in WB scripting that I previously thought; that is nice you already know much. Frankly, I have no idea what to do past this point as I do not have access to your ModSys. The issue seems odd, so maybe you will find a way out by modifying the script's contents (the trigger) or the snippet's properties (pt_invaders).
 
Upvote 0
Thanks for the compliments. I've only tried coding the past month and it still looks like a bunch of nonsense to me:wink:
The module I am modding is from the link I posted. Mrclopes did release a source file download for his Diplomacy 4.3 mod, and it is what I have been tampering with (I like how the mod divides the 6 factions into 12 kingdoms and 8 cultures while adding the lord execution option). The mod is missing a lot of potential with not having scripts like spear bracing or battle formations, but I feel like his mod gave the best rehaul of Native without changing too much of the vanilla gameplay. I wanted to add some more troops and bandit figures as well as weapons/armory (which I can easily do with Morgh's Editor), but I was curious whether I could implant some good code scripts you all have posted here on the forum.

But yeah, I really don't know much about coding. I have to read a person's response probably a dozen times to understand what they are referring to, and I really know nothing about the jargon talk in coding. Even your solution is your post is confusing to me until I interact with the code enough times to understand what you are referring to. I can try to give it a shot, but I am still curious as to what the warning refers to. I tried looking it up on this forum, but I have failed to find a good explanation to the global variables. Some posts I read said those warnings weren't a big deal or to just copy Native's variable.txt into your mod, but each time I started up my mod after those build errors, the game went bonkers. I have already added some scripts to the module (I added firearms to the merchants, enabled shooting town civilians, and being able to bribe bandits), so the issue can't be on the module end but mine.

Mods like POP do have various parties spawn on the map that are not always bandits; I would like to try something similar in this mod so the player/factions have to deal with more than just bandits. I've already created the Dark Knights in the past and tried them out with pleasing results, but I always just put them in with a certain bandit party through Morgh's Editor. I would love to make them (and maybe some other hostile units) spawn as parties that will attack both the player and lords as an upgrade from the typical bandit party. Lumos' code looked promising as it described a similar idea (only his involved Swadian knights) and was the only information I could find of the invasion system. I can try to look again, but it is hard finding useful information for beginning modders (it took me probably 2 weeks to even properly install Python and properly linked the source files to the mod directory). I will try at what you said about modifying the script's content...wish me luck.
 
Upvote 0
I am afraid you need to better understand modding before kickstarting your scripting adventure. If it is not for you, just try out a ready-made mod since modding is tough and time-consuming for lay people. Take a look at the thread linked in Earendil's signature - "New at modding Warband? Read here!" - and maybe try to learn something on your own.
 
Upvote 0
Yeah, I think I found that out. I can do some scripts, but this is beyond my knowledge. I'll probably just pass on this idea for my mod. Thanks for the help though.
 
Upvote 0
I'm not sure. I already gave up doing this since it seemed beyond my skill level. I wouldn't doubt if I did a mistake like that since 90% of coding issues seems to be a misspelling or forgetting to add the ) or ] at the right place. I could maybe give this a go again, but I have a feeling it will do the same response.
 
Upvote 0
I'm not sure. I already gave up doing this since it seemed beyond my skill level. I wouldn't doubt if I did a mistake like that since 90% of coding issues seems to be a misspelling or forgetting to add the ) or ] at the right place. I could maybe give this a go again, but I have a feeling it will do the same response.
Learn some modding knowledge from this: https://forums.taleworlds.com/index...post-new-at-modding-warband-read-here.448322/. Use Notepad++ or Visual Studio Code to highlight syntax. Take a look around a ModSys to know how to create scripts and appropriately close them with proper characters, such as normal or square brackets and commas. That script should work though, so make sure to grasp the basics.
 
Upvote 0
Back
Top Bottom