Three questions about the script

Users who are viewing this thread

jcsm130988

Recruit
Hello, I'm trying to make a (single player) mod and have three questions regarding the garrison, spawn frequency and the wives and family relations. First, garrison: where is the max garrison determined? Say I want a town to have a max 200 troops garrison and a castle to have a max 10 troop garrison, where in the script.py do I make the changes? Second, spawn frequency (especifically bandits): How is it determined the frequency of the spawns? In particular I want to make it so the bandits dissapear from the map after destroying the bandit lair for, say 3 months and then they start to spawn agan, would that be possible? Third, wives: I've read somewhere in the forums that the ladies relations are random (although the wives must not be entirely random since the wives have older face codes). Would it be possible to make so that it's not random but I can determine in the code who's married to who and who's father is who, etc. And for that matter make it so, not just for ladies, but also for lords, but I'm mostly interested in ladies. Thanks in advance and everyone have a nice day.

P.S.: Wash your hands and stay at home.
 
couple of things:
1) are you using modsys (.py files) or .txt tweaks?
2) what is your base module? Native? Floris? Something else? Which version? Like Native 1.174

answers depends on that
 
Upvote 0
couple of things:
1) are you using modsys (.py files) or .txt tweaks?
2) what is your base module? Native? Floris? Something else? Which version? Like Native 1.174

answers depends on that

1) modsys. I suppose I have to edit the module_script.py to achieve what I'm loking for
2) It's -ahem- Dickplomacy. It's basically diplomacy plus other submods
 
Upvote 0
as you are not using Native I can only give some hints. You can wait for someone that has this modsys or ask on the mod forum for help as well.

1) recruits for centers on Native use templates. So you can look where the operation party_add_template is used (Native is script_cf_reinforce_party). If your mod doesnt use that, then look for party_add_members operations. And walk the code to see where the limit.

2) spawns of bandits means a trigger (event). Native uses script_spawn_bandits, called by the event handler (timer). You can look for something similar.

3) Family relations on Native uses script_initialize_aristocracy. You can replace the random code for straight hardcoded relations (this X is father of Y). If you cant find that look for slots like "slot_troop_father"
 
Upvote 0
as you are not using Native I can only give some hints. You can wait for someone that has this modsys or ask on the mod forum for help as well.

1) recruits for centers on Native use templates. So you can look where the operation party_add_template is used (Native is script_cf_reinforce_party). If your mod doesnt use that, then look for party_add_members operations. And walk the code to see where the limit.

2) spawns of bandits means a trigger (event). Native uses script_spawn_bandits, called by the event handler (timer). You can look for something similar.

3) Family relations on Native uses script_initialize_aristocracy. You can replace the random code for straight hardcoded relations (this X is father of Y). If you cant find that look for slots like "slot_troop_father"

Thank you. I'll check those out
 
Upvote 0
Ok, so I kind of made the garrison thing work out, I'll have to further test.
The triggers for the spawn_bandits... I couldn't find it.
The family relations seem to be working.

If anyone could help with the bandits thing I would be very grateful
 
Upvote 0
get a editor like Notepad++ (with explorer plugin) or SublimeText (both are free).

use full folder search (it looks in all files inside a folder)

now do a chain search for your code. You are starting from the end-point (script spawn_bandits). Use that name "script_spawn_bandits" to see who calls it. Then who calls that one. And so on. Until you have the entire chain of events and you can understand the who, when, how and why.

this way you can connect stuff like triggers with scripts, mission templates with scripts, scripts with tableaus, and so on.
 
Upvote 0
get a editor like Notepad++ (with explorer plugin) or SublimeText (both are free).

use full folder search (it looks in all files inside a folder)

now do a chain search for your code. You are starting from the end-point (script spawn_bandits). Use that name "script_spawn_bandits" to see who calls it. Then who calls that one. And so on. Until you have the entire chain of events and you can understand the who, when, how and why.

this way you can connect stuff like triggers with scripts, mission templates with scripts, scripts with tableaus, and so on.

After searching as you suggested I think the trigger is on game start (at least that's how I understand it) and its:

module_scripts.py:
Python:
scripts = [


  #script_game_start:
  # This script is called when a new game is started
  # INPUT: none
  ("game_start",
   [
     ...a lot of scripts...

      (try_for_range, ":unused", 0, 10),
        (call_script, "script_spawn_bandits"),
      (try_end),

and the trigger is checked every 36 hours (?)

module_triggers.py:
Python:
  # Spawn some bandits.
  (36,
   [
       (call_script, "script_spawn_bandits"),
    ]),

That's all fine, but what do I add now? I could edit how often the trigger is checked but that's not what I want, what I want is for bandits to stop spawning after destroying their lair (and then start spawning again after some months if possible).

I'm sorry, I know I'm a noob but I'm still learning to use the module system (and Blender and GIMP and now also sublime text XD). Thank you for your patience.
 
Upvote 0
1) look at the comments (documentation) of the script_game_start. As stated, that one is only called once (at the moment you create a new campaign). It is not a repeated event. It is the setup for the campaign.

2) A destroyed bandit camp is a state (party = bandit camp XXX, status = destroyed). You can identify that on your code and add/tweak the rule about spawning bandits

bandit camps are either a static party (like a town) or a dynamic party (like a caravan). Look at your module_parties.py and figure out which one you are using
- static parties are enabled/disabled, never destroyed -> listed on module_parties.py
- dynamic parties are created/destroyed -> the recipe is listed on module_party_templates.py

use that info to figure out the state of a bandit camp (does it exists right now?). Scripts like "spawn_lair" should help. Or search based on the lair slots (search module_constants.py).

Once you know that you can add any rule you want about them or the bandits they control.
 
Upvote 0
1) look at the comments (documentation) of the script_game_start. As stated, that one is only called once (at the moment you create a new campaign). It is not a repeated event. It is the setup for the campaign.

2) A destroyed bandit camp is a state (party = bandit camp XXX, status = destroyed). You can identify that on your code and add/tweak the rule about spawning bandits

bandit camps are either a static party (like a town) or a dynamic party (like a caravan). Look at your module_parties.py and figure out which one you are using
- static parties are enabled/disabled, never destroyed -> listed on module_parties.py
- dynamic parties are created/destroyed -> the recipe is listed on module_party_templates.py

use that info to figure out the state of a bandit camp (does it exists right now?). Scripts like "spawn_lair" should help. Or search based on the lair slots (search module_constants.py).

Once you know that you can add any rule you want about them or the bandits they control.


Si I changed this code from module_game_menus.py:

(try_for_range, ":bandit_template", bandit_party_templates_begin, bandit_party_templates_end), #SB : template range
(party_template_slot_eq, ":bandit_template", slot_party_template_lair_party, "$g_encountered_party"),
(party_template_set_slot, ":bandit_template", slot_party_template_lair_party, 0),

(store_current_hours, ":cur_hours"),
(val_add, ":cur_hours", 168), #spawn again 1 week later
(party_template_set_slot, ":bandit_template", slot_party_template_lair_next_spawn, ":cur_hours"),

(try_end),

To this:

(try_for_range, ":bandit_template", bandit_party_templates_begin, bandit_party_templates_end), #SB : template range
(party_template_slot_eq, ":bandit_template", slot_party_template_lair_party, "$g_encountered_party"),
(party_template_set_slot, ":bandit_template", slot_party_template_lair_party, 0),

(store_current_hours, ":cur_hours"),
(val_add, ":cur_hours", 1512), #spawn again 9 weeks later
(party_template_set_slot, ":bandit_template", slot_party_template_lair_next_spawn, ":cur_hours"),

Then I went to module_scripts.py and changed this:

(try_begin),

(party_template_get_slot, ":bandit_lair_party", "pt_forest_bandits", slot_party_template_lair_party),
(gt, ":bandit_lair_party", 1),

(store_num_parties_of_template, ":num_parties", "pt_forest_bandits"),
(lt,":num_parties",16), #was 14 at mount&blade, 18 in warband, 16 last decision
(store_random,":spawn_point",num_forest_bandit_spawn_points),
(val_add,":spawn_point","p_forest_bandit_spawn_point"),
(set_spawn_radius, 25),
(spawn_around_party,":spawn_point","pt_forest_bandits"),
(try_end),

adding this:

(try_begin),

(party_template_get_slot, ":bandit_lair_party", "pt_forest_bandits", slot_party_template_lair_party),
(gt, ":bandit_lair_party", 1),
(neg|party_has_flag, "pt_forest_bandit_lair", pf_disabled, 1),
(store_num_parties_of_template, ":num_parties", "pt_forest_bandits"),
(lt,":num_parties",16), #
(store_random,":spawn_point",num_forest_bandit_spawn_points),
(val_add,":spawn_point","p_forest_bandit_spawn_point"),
(set_spawn_radius, 5),
(spawn_around_party,":spawn_point","pt_forest_bandits"),
(try_end),

Believe it or not, it took me a while to come out with that line of code. I did the same for every bandit type except looters, but you get the point, no need to copy every single one. Thing is, I'm getting this error message:

Unrecognized opcode -2147479746.; LINE NO: 127:
At script spawn_bandits
At script spawn_bandits
At script spawn_bandits
At script spawn_bandits
Unrecognized opcode -2147479746.; LINE NO: 157:
At script spawn_bandits
At script spawn_bandits
At script spawn_bandits
At script spawn_bandits

Could you please help me figure out what's wrong with the code? Thank you for your help.

Stay healthy.
 
Upvote 0
Back
Top Bottom