Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
PPQ_Purple said:
invalid opcode -2147483648

EmielRegis said:
We had user that typed:
Code:
(neq|eq, ":something"),
which produced simmilar error you described. Cant think of anything else im afraid.

that is what the message is telling you. You have a invalid negative operation (like the example above) in your code. Read the entire log to see which script, code line, etc is the cause.
 
How could i make troop uses specific weapon i give to it ever if its worse than the ones he has in inventory?
basicly i would in dialog use (misspelled operation but i hope you understand which operation im thinkink about.The one putting item in ek_slot_1 or 2 etc)
troop_set_item_inventory_slot but that still does not asure that troop will use this item.
Also i dont wanna change price or any stats of that item nor i want to copy paste item's entry and use id of that copied entry and change stats or price (because i know how engine chooses weapons just its price isnt it?but i need price for second part of code)

I though about freeing all 4 inventory slots and that would fit but i cant do it with combination of
Troop_get_slot
and
troop_remove_item.
Hope you understand me... :grin:
 
DarkNord said:
How could i make troop uses specific weapon i give to it ever if its worse than the ones he has in inventory?

1) Why should the troop keep better weapons on the inventory? Simple solution here is to remove all his weapons and give the new one (worst type), so the agent has no choice  :mrgreen:
^ remove all weapons from slots 1 to (max=64 or whatever you have). Gear is part of inventory. Not two different things.

2) If for some weird reason (1) is not possible: override the gear using a mission template trigger (after spawn)
 
just a small question : can we have more bandit type ?
i mean is there a limit on how many we can have ?
can i just do this
from this:
Code:
.........
  ("kingdom_72",  "Wakasa Takeda Clan",              0, 0.9, [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.02),("woku_pirates", -0.05),("kyoshu_rebel", -0.05),("Kanto_rebel", -0.05),("Clanless_Basterds", -0.05)], [], 0xEE7744), ##########----------Major Clan----------##########
  ("kingdom_73",  "Yamana Clan",                     0, 0.9, [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.02),("woku_pirates", -0.05),("kyoshu_rebel", -0.05),("Kanto_rebel", -0.05),("Clanless_Basterds", -0.05)], [], 0xCCBB99), ##########----------Major Clan----------##########
  ("kingdom_74",  "Yuki Clan",                       0, 0.9, [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.02),("woku_pirates", -0.05),("kyoshu_rebel", -0.05),("Kanto_rebel", -0.05),("Clanless_Basterds", -0.05)], [], 0xCC99FF), ##########----------Major Clan----------##########
to this:
Code:
.........
  ("kingdom_72",  "Wakasa Takeda Clan",              0, 0.9, [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.02),("woku_pirates", -0.05),("kyoshu_rebel", -0.05),("Kanto_rebel", -0.05),("Clanless_Basterds", -0.05)], [], 0xEE7744), ##########----------Major Clan----------##########
  ("kingdom_73",  "Yamana Clan",                     0, 0.9, [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.02),("woku_pirates", -0.05),("kyoshu_rebel", -0.05),("Kanto_rebel", -0.05),("Clanless_Bastards", -0.05)], [], 0xCCBB99), ##########----------Major Clan----------##########
  ("kingdom_74",  "Yuki Clan",                       0, 0.9, [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.02),("woku_pirates", -0.05),("kyoshu_rebel", -0.05),("Kanto_rebel", -0.05),("Clanless_Bastards", -0.05)], [], 0xCC99FF), ##########----------Major Clan----------##########

while of course adding to this line: (in the beginning of module_faction.py)
Code:
default_kingdom_relations = [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.05),("woku_pirates", -0.02),("kyoshu_rebel", -0.02)]
so it will look like this :
Code:
default_kingdom_relations = [("outlaws",-0.05),("shinano_rebels", -0.1),("deserters", -0.05),("woku_pirates", -0.02),("kyoshu_rebel", -0.02),("Kanto_rebel", -0.02),("Clanless_Bastards", -0.02)]

will this work out ? and if not is there anyway to either make more bandit types or spawn the same bandit type in to many places (japan map is huge damn)
thanks in advance
and i hope my code looks nicer this way "kalarhan"
 
imado552 said:
just a small question : can we have more bandit type ?

yes

but lets take a step back and try to understand what are you trying to do.

1) Why do you need multiple factions for the bandit types? And how many are you planning to use?

For example: you can have a faction with several different "types" of bandits. Each "type" has a composition (name, behaviour, troops, etc). But they can still belong to the same faction. So understand this point before going crazy creating 1000 factions

2) The "kingdom_XXX" is a string reference (a name). You can put anything there, as long it is unique (no other faction has the same name). So use strings that make sense, like :

"bandit_rebels_1", "bandits_rebels_2", "bandits_north_1", "bandits_center_1", ... something that when you see it (read the name) will help you understand and remember what that faction is for.

3) The basic system for bandits:
3.a) party template (recipe to spawn the troops).
3.b) create rules to how many parties should exist for a particular template (like 10 deserters, but not 11). Yes, you can create a rule like: 5 parties North, 5 parties South, 2 parties center of the country.
3.c) VC has a interesting "database" like configuration for the bandits spawn (rate and quantity), based around spawn points (home bases). Easy to setup and change. You could look at it for inspiration.

4) You can add ruleset to control the bandit population. VC, as a example, uses the player army strength (how many troops you have and their quality). Weaker player (starting a new game) will result in more weak bandits. A very strong player (king with 300 soldiers) will reduce bandits to a small number, but parties will be bigger/stronger.
^ it also takes the bandit type into consideration. So a strong bandit party will be more frequent at end game, etc
 
1) Why do you need multiple factions for the bandit types? And how many are you planning to use?

For example: you can have a faction with several different "types" of bandits. Each "type" has a composition (name, behavior, troops, etc). But they can still belong to the same faction. So understand this point before going crazy creating 1000 factions
Why is because i want half of those factions(bandit) to be at war with each other so for example
bandit_1 don't get along with bandit_2 but do get along with bandit_3 and bandit_3 don't get along with bandit-2 so they can gang up on it

My idea here is you can't find war only between factions(clans in what i'm doing) even the outlaws are fighting between them so player have many choices helping bandit_1 against others will result in them loving him and helping him as well in need (if possible) so players can have more variety on how they play they don't necessary need to fight a clan later they can just keep on fighting in the lower guys wars while getting stronger

2) The "kingdom_XXX" is a string reference (a name). You can put anything there, as long it is unique (no other faction has the same name). So use strings that make sense, like :

"bandit_rebels_1", "bandits_rebels_2", "bandits_north_1", "bandits_center_1", ... something that when you see it (read the name) will help you understand and remember what that faction is for.
i used those names cuz they will be in game like that and will help me memorize and remember where each one is supposed to be like for example kyoshu_rebels are supposed to be in kyoshu island and so will make things more easier for me and i write everything in a notepad page so that i can get back to it when i'm confused but thanks for the advice!!

3) The basic system for bandits:
3.a) party template (recipe to spawn the troops).
i recently just found out i was scrolling and trying to understand each file in module system so that i have a better knowledge on it while doing some tests on a copy native module but thanks

3.b) create rules to how many parties should exist for a particular template (like 10 deserters, but not 11). Yes, you can create a rule like: 5 parties North, 5 parties South, 2 parties center of the country.
didn't know that thanks for the info exactly what i was looking for this should make thing more easier for me but i will have to do some messing around lol to know how it works

3.c) VC has a interesting "database" like configuration for the bandits spawn (rate and quantity), based around spawn points (home bases). Easy to setup and change. You could look at it for inspiration.
i followed your advice and downloaded the VC ModSys after reading their rules of crediting and what we should use and stuff and i'm happy i did i found great things that would help me even though i will need some time to learn how to use them lol

4) You can add ruleset to control the bandit population. VC, as a example, uses the player army strength (how many troops you have and their quality). Weaker player (starting a new game) will result in more weak bandits. A very strong player (king with 300 soldiers) will reduce bandits to a small number, but parties will be bigger/stronger.
^ it also takes the bandit type into consideration. So a strong bandit party will be more frequent at end game, etc
that would be cool i might think about it so challenges for players!!

and i'm not trying to create a lot of bandits factions i'm just trying to create bandit faction for each cregions and so they will fight each other and will have allies just like factions do but their allies are fixed unless there is an option to do that

PS: you see when we use cheate mod there is that option in dialogues when speaking to a lord "i would like to join your faction "(so there is  no need for relations building) can i some how create a dialogues a line or two i don't know a small simple one that gives that option so when speaking with one of those bandits faction i'll have an option to join them (even taking fiefs for them since they are at war with big guys why not helping bad guys against bad guys lol)and then you will have an option to leave their brotherhood or something is it possible ? i'm 45% positive but i wanted to make sure to not waste my time !

and again thank you kalarhan you are really helping us out well!!
 
I know that if I make changes to troops or items I have to start a new game for it to register. What about parties though? Like, I changed the faction of one of the bandit parties to a custom faction. Does this necessitate a reload?
 
PPQ_Purple said:
I know that if I make changes to troops or items I have to start a new game for it to register. What about parties though? Like, I changed the faction of one of the bandit parties to a custom faction. Does this necessitate a reload?

depends. Adding new stuff will break savegame compatibility. You can't increase/decrease the count of items, troops, triggers... but you can modify them. Others you can like scripts.

some changes can be made by code to preserve the old savegames.

VC has a good example. They had to keep the game compatible from version 1.0 and on. They couldn't break savegames. Yet they wanted to modify/add items, parties, change balance, modify troops, and so on. So they used a combination of empty assets (like a "blank_quest_10") and a trigger that checks your current save and applies all changes, thus upgrading it to the latest version.

VC RE (2.0) included new features that were unavailable to old players (versions 1.0 to 1.04). However, the game still worked for them. They simple couldn't use the new troops, or see the new places. For that they had to start a new game.

It is a lot of work to keep and test old savegames. Easier to break them from time to time. Your code will be better for it. And you won't go crazy trying to keep compatibility.

Usually in software you see this:  VERSION.MAJOR.MINOR
Major: indicates new features, but still compatible
Minor: updates/fixes for the current major
Version: change this to indicate you broke savegame compatibility

1.0.0 -> 1.0.1 -> 1.0.2 (fixes for 1.0)
1.0.0 -> 1.1.0 (new features, balance, etc, but compatible)
1.1.0 -> 2.0.0 (not compatible, or for MB: requires a new savegame)

you can use other ways to indicate changes. Just keep it simple.
 
imado552 said:
lots of stuff

lets start from the end: yes you can add a dialog like that. It is all done via modsys, nothing hardcoded here.

about factions: I never tested the limit (how many you can have). But keep in mind a few things:

a) more is not the same as better
b) more will impact your performance and can even cause lag on your worldmap. There are many process that loop for factions, nobles, parties, etc, and the more of them exist, the longer that process will take, to the point it could stop your game from time to time (world freeze) causing loss of FPS and even lag.

You are working with a base game (Native) that has code/features for a small map, few factions, few parties around. It is not optimized for a huge universe. To create one you will need to adapt/replace the basic features of the game, like how economy works, the campaign AI, and so on. Big mods (in faction numbers) like 1257AD and Brytenwalda had to just that. Are you willing to invest the time and energy on the technical side of the code?

Besides that comment all your wishes are possible. I didn't catch any hardcoded rule stopping you.



Factions: you can have internal conflict within a faction as well. Like different clans/groups in war or alliance inside the same faction. All you need to do is change the personal relation between them. But again, you would need to check the impact on the general game mechanics.
 
kalarhan said:
depends. Adding new stuff will break savegame compatibility. You can't increase/decrease the count of items, troops, triggers... but you can modify them. Others you can like scripts.
That's all I needed to know.

It is a lot of work to keep and test old savegames. Easier to break them from time to time. Your code will be better for it. And you won't go crazy trying to keep compatibility.
I am asking primarily for testing purposes. As in, when testing my own mod when do I need to start from scratch and when I can just add iterative changes, load a save game, test, change again etc. like I can with dialogue.


I don't rightly care about keeping end user saves compatible because I don't care for the whole iterative release / death of a thousand patches concept. I much prefer to have public releases happen only rarely but be worth the wait. And that approach breaks saves anyway.
 
PPQ_Purple said:
I am asking primarily for testing purposes.

when in doubt: if your savegame crashs the game, it broke one of the rules of adding/removing stuff  :mrgreen:

for triggers there is a "trick". Create empty triggers in the end of your files (module_triggers.py and module_simple_triggers.py)

example:

Code:
(24, 0, 0,[],[]),
(24, 0, 0,[],[]),
(24, 0, 0,[],[]),
(24, 0, 0,[],[]),
(24, 0, 0,[],[]),
(24, 0, 0,[],[]),

then if you want to add a new trigger: replace one of those. It will keep the same count of triggers (won't crash the game). Just remember the timer (clock) is stored with the savegame, so you need to pass a cycle to change it (from 24hours to something else)



PPQ_Purple said:
user saves compatible

at least copy your latest variables.txt to the .py folder.
 
Modding(adding) items or troops etc. is corrupting save games. But adding menus, mission templates etc. is not corrupting save games. Anybody knows which file modding affects save games? Is there a list like hardcoded stuff?
 
lets start from the end: yes you can add a dialog like that. It is all done via modsys, nothing hardcoded here.
thanks glad to hear that!

a) more is not the same as better
Yes i know and i'm always thinking of ways to make it better

b) more will impact your performance and can even cause lag on your worldmap. There are many process that loop for factions, nobles, parties, etc, and the more of them exist, the longer that process will take, to the point it could stop your game from time to time (world freeze) causing loss of FPS and even lag.
yes , i'm aware of that but since my mod is simply pure historical accuarate i need to have it like that (even though i removed many things for gameplay sake but still the damn history is too big)


You are working with a base game (Native)
No, i'm just using it for testing stuff and to improve my skills as best as i can
i have a copy of my mod module for the real thing with huge map and such..(and there is no lag with the map in game but i need to do more testing with the newly added factions (and i'm using a low end pc for the purpose of testing if it will run in low end machines good so low end pc can enjoy the same as us good machines guys)



It is not optimized for a huge universe. To create one you will need to adapt/replace the basic features of the game, like how economy works, the campaign AI, and so on. Big mods (in faction numbers) like 1257AD and Brytenwalda had to just that
yes i'm aware and i'm trying my best to do better!



Are you willing to invest the time and energy on the technical side of the code?
Yes if it make my work great and better and PLAYABLE yes

Besides that comment all your wishes are possible. I didn't catch any hardcoded rule stopping you.
thank god this was the only thing i was afraid of !

you can have internal conflict within a faction as well. Like different clans/groups in war or alliance inside the same faction. All you need to do is change the personal relation between them. But again, you would need to check the impact on the general game mechanics.
i will try that if it would prove to be helpful i'll do it i don't care about how much time it will take as long as i do a good job !
but thanks again!
 
First as you surmised you need to set up faction relationships, changing other ones as well to reciprocate.
Code:
default_bandit_relations = [("outlaws",0.01),("commoners",-0.2),("merchants",-0.5),("manhunters",-0.7),("player_faction",-0.1)]
...
  #bandit factions sorted by kingdom association
  ("forest_bandits","{!}Forest Bandits", 0, 0.7, default_bandit_relations + [("kingdom_1",-0.3),("steppe_bandits",-0.01)], [], 0xAB7057),
  ("taiga_bandits","{!}Taiga Bandits", 0, 0.4, default_bandit_relations + [("kingdom_2",-0.25),("kingdom_4",-0.16),("forest_bandits",-0.01),("steppe_bandits",-0.01)], [], 0x9BC1A5),
  ("steppe_bandits","{!}Steppe Bandits", 0, 0.3,default_bandit_relations + [("kingdom_3",-0.25),("kingdom_6",-0.1),("mountain_bandits",-0.01)], [], 0x6C6995),
  ("sea_raiders","{!}Sea Raiders", 0, 0.5, default_bandit_relations + [("kingdom_4",-0.4),("kingdom_1",-0.3),("kingdom_2",-0.2),("forest_bandits",-0.02),("mountain_bandits",-0.02)], [], 0x459C9C),
  ("mountain_bandits","{!}Mountain Bandits", 0, 0.33, default_bandit_relations + [("kingdom_5",-0.2),("kingdom_6",-0.1),("taiga_bandits",-0.01)], [], 0x559555),
  ("desert_bandits","{!}Desert Bandits", 0, 0.6, default_bandit_relations + [("kingdom_6",-0.1),("kingdom_3",-0.15),("kingdom_5",-0.15),("mountain_bandits",-0.01),("steppe_bandits",-0.02)], [], 0xC3C364),
Although I haven't tested setting internal relationships to promote infighting, if you set coherence to a negative number in addition to that you might see them fighting eachother.

Then you need to make sure the bandits are spawning as the correct faction by setting the party templates. This can be done from just changing the party templates or dynamically at spawn if they share the same troops.
Code:
  ("forest_bandits","Forest Bandits",icon_stickman|carries_goods(2),0,fac_forest_bandits, aggressiveness_3 | courage_6 | banditness,[(trp_forest_bandit,4,52)]),
  ("taiga_bandits","Tundra Bandits",icon_bandit_horseman_b|carries_goods(2),0,fac_taiga_bandits, aggressiveness_4 | courage_9 | banditness,[(trp_taiga_bandit,4,58)]),
  ("steppe_bandits","Steppe Bandits",icon_khergit|carries_goods(2),0,fac_steppe_bandits, aggressiveness_6 | courage_6 | banditness, [(trp_steppe_bandit,4,58)]),
  ("mountain_bandits","Mountain Bandits",icon_bandit_horseman|carries_goods(2),0,fac_mountain_bandits, aggressiveness_4 | courage_7 | banditness, [(trp_mountain_bandit,4,60)]),
  ("sea_raiders","Sea Raiders",icon_axeman|carries_goods(2),0,fac_sea_raiders, aggressiveness_8 | courage_7, [(trp_sea_raider,5,50)]),
  ("desert_bandits","Desert Bandits",icon_khergit_horseman_b|carries_goods(2),0,fac_desert_bandits, aggressiveness_5 | courage_8 | banditness, [(trp_desert_bandit,4,58)]),

With that setup the bandits will prey on eachother on the world map. However, you still can't join fights because normally they are both hostile (and so you can only leave) in Native. You can modify this threshold as follows, changing the relation threshold needed (remembering that the ones we set in module_factions scale as a percent).
Code:
    [
      ("pre_join_help_attackers",[
          (store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
          (store_relation, ":attacker_relation", ":attacker_faction", "fac_player_supporters_faction"),
          (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
          (store_relation, ":defender_relation", ":defender_faction", "fac_player_supporters_faction"),
          (ge, ":attacker_relation", -20),
          (lt, ":defender_relation", 0),
          ],
          "Move in to help the {s2}.",[
              (select_enemy,0),
              (assign,"$g_enemy_party","$g_encountered_party"),
              (assign,"$g_ally_party","$g_encountered_party_2"),
              (jump_to_menu,"mnu_join_battle")]),
      ("pre_join_help_defenders",[
          (store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
          (store_relation, ":attacker_relation", ":attacker_faction", "fac_player_supporters_faction"),
          (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
          (store_relation, ":defender_relation", ":defender_faction", "fac_player_supporters_faction"),
          (ge, ":defender_relation", -20),
          (lt, ":attacker_relation", 0),
          ],
          "Rush to the aid of the {s1}.",[
              (select_enemy,1),
              (assign,"$g_enemy_party","$g_encountered_party_2"),
              (assign,"$g_ally_party","$g_encountered_party"),
              (jump_to_menu,"mnu_join_battle")]),
      ("pre_join_leave",[],"Don't get involved.",[(leave_encounter),(change_screen_return)]),
    ]

Then you need to handle the post-battle conversation. Because dialogs are parsed top-to-bottom you need to make sure the correct state triggers (so you don't have to fight the bandits you helped after). The native dialog state is supposed to be "party_relieved", but that's been replaced by using talk_context and the "start" state, checking for (eq,"$talk_context",tc_ally_thanks), a bit further down from bandit ones.

The join faction stuff is a bit more complicated, as $players_kingdom is assumed to be between player_faction and kingdoms_end. There are many calculations which uses that as an offset, so if you allow it to take on other values it can produce errors.

After that to add immersion you should consider simulating regionality for villages and towns infested by bandits. Normally this is on a faction basis (1 bandit faction paired with specific kingdom's centers) but you can mix it up by using proximity to bandit lairs, original factions, or whatever you please.
bandits.png
 
I know that there used to be a mod out there (or was that in native???) where you could just walk up to a party of deserters and pay them to join your army. Anyone have any idea what this was? I am basically looking for the source as a starting point for a similar feature.

Also, a question about this:
kalarhan said:
PPQ_Purple said:
It's random question time.

If I wanted to take a named NPC from a settlement (like say a guild master or some other guy with a fixed name and face (thus hero flag) ) and make him a lord mid game. Like, player clicks dialog option = guy becomes lord in players faction. But without actually giving him a fief in the process. How would I go about this?

And what would be the consequences? Would I end up duplicating the character?

not a good idea  :mrgreen:. There are tons of code that uses ranges for lords, so you will probably break something. Unless you have a better module system, or you are willing to recode it, the easier way to do this is another route:

1) Create empty lord troops (together with the others on module_troops.py) and put them in a not active faction (so they won't spawn in the map, it is similar to killing a lord)
2) When you execute teh process (like on a dialog), clone the village npc (face, skills, name, whatever) to one of the unused lords. Transfer that lord to your faction. Active it (set all flags). Then use a random process to regenerate the village npc (new face, age, name, ...)
How would I go about making a faction inactive? Like, what flags need to be set to make it inactive vs active?

Like, a faction looks like this in the code:
("ID","Name",flags supposedly but they are not defined anywhere, coherence, [relationships with other factions], [something called ranks that I don't know what is], color),
 
PPQ_Purple said:
questions...

VC has the dialog to recruit bandits, so you could check their code (its a easy feature to write too)

To activate/deactivate the player faction check the script used for the player faction (a example), and you will see all the flags listed there

Code:
script_activate_player_faction; script_deactivate_player_faction

For npc kingdoms check this trigger
Code:
# Check if a faction is defeated every day
  (24,
   [
 
I could swear I saw the feature in a mod for regular M&B warband though. And a relatively old one too. I really don't want to have anything to do with VC.

EDIT: There is no such trigger in the module system.
 
PPQ_Purple said:
I really don't want to have anything to do with VC.

that is a weird comment, but whatever rocks your boat. If you don't want to look at the most recent game code and learn from it (the good and the bad), its your call  :grin:

the feature itself, as I said above, is quite simple to code. You just need to decide on your rules for balance (when should you be able to recruit, restrictions, cooldown period, cost, etc). Then simple loop for the party stacks, add those same troops to your army, and kill off the bandit party (all done via operations)

some examples of rules: what happens with the bandits prisoners; does a stat influence teh decision (persuasion, honor, etc); do you lose honor if you recruit bandits; does it affect RTR; cost per head to recruit them (just like in a village); and so on
 
the feature itself, as I said above, is quite simple to code. You just need to decide on your rules for balance (when should you be able to recruit, restrictions, cooldown period, cost, etc). Then simple loop for the party stacks, add those same troops to your army, and kill off the bandit party (all done via operations)
No restrictions in my case. By the time you get the power you will have earned it through quests.

So the rest is just loop through the other party, clone troops and than paste them into the player party. Hm. I can get half of that from the recruitment scripts and the rest I can fiddle with.

My main concern though is that the comment you listed (and indeed a function related to it) is not in the module system I have on hand (the one from the mod I am editing) and I whilst I have found "deactivate_player_faction" I can't actually find where it is being called (I mean the initial call when the game begins, I can figure out where it's called when I surrender my faction but that's not the point).

Could I just get away with pasting the relevant flags into the faction file directly? Am asking mostly because that would be a cool hack more than anything.
 
Status
Not open for further replies.
Back
Top Bottom