PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

Ritter Lanzelot said:
Code:
typeError: 'tuple' object is not callable
The line above the one mentioned in the output (i.e. line 198:cool: does not have a comma at its end.

It's good to see that you're trying to work on what I could not help you with, but this thread is for ready scripts and stuff. Ask your questions in the Q&A thread, please.
 
Here's a little something: A handful of scripts that allow you to set a position's rotation around an axis.

Fiddling with positions recently and scouting through header_operations convinced me that there are no operations that would set a position's rotation around an axis to N angles. There is position_get_rotation_around_*, there is position_rotate_*, but there is not position_set_rotation_around_*. (Of if there is, I never found it.)
This is what made me write a simple script that does the job for the X axis, then two more for the others, so I figured I'd drop them here. Nothing too complicated or special, but if you suck horribly at maths are too lazy to create something like this on your own and you'd rather work on your more complicated features, feel free to use these. I'd be glad if I saved five minutes of someone's time which went into something more interesting.

Code:
Code:
#-## Rotation setting begin
## Lumos: I couldn't find an operation to do this, so here they are...
("position_set_rotation_around_x",[  
	(store_script_param, ":pos", 1),
	(store_script_param, ":target", 2),
	(val_mod, ":target", 360),
	(position_get_rotation_around_x, ":angle", ":pos"),
	(val_mul, ":angle", -1),
	(val_add, ":angle", ":target"),
	(position_rotate_x, ":pos", ":angle"),
]),

("position_set_rotation_around_y",[  
	(store_script_param, ":pos", 1),
	(store_script_param, ":target", 2),
	(val_mod, ":target", 360),
	(position_get_rotation_around_y, ":angle", ":pos"),
	(val_mul, ":angle", -1),
	(val_add, ":angle", ":target"),
	(position_rotate_x, ":pos", ":angle"),
]),

("position_set_rotation_around_z",[  
	(store_script_param, ":pos", 1),
	(store_script_param, ":target", 2),
	(val_mod, ":target", 360),
	(position_get_rotation_around_z, ":angle", ":pos"),
	(val_mul, ":angle", -1),
	(val_add, ":angle", ":target"),
	(position_rotate_x, ":pos", ":angle"),
]),
#-## Rotation setting end
Drop this code into your module_scripts.py.

Usage:
It's simple. Just call the script with the first parameter being the position, and the second - the angle you wish the given rotation to be. Example:
Code:
[color=navy](call_script, "script_position_set_rotation_around_x", pos1, 90),[/color]
This will cause pos1 to have its X angle set to 90°.

That's about it. Hope someone finds this useful, some day. Although I would feel rather stupid if it turned out in the end that an operation for this existed.
 
Lumos said:
Yeah, I allow for heraldic placeholder-meshed items to occupy two lines of screen space. But no other exceptions!

Of course we can do something about it too, my friend.
Code:
# Dunde's 1 Liner Heraldic Code
def heraldic(item_tableau):
  return (ti_on_init_item, [(store_trigger_param_1, ":agent_no"),(store_trigger_param_2, ":troop_no"),(call_script, "script_shield_item_set_banner", item_tableau, ":agent_no", ":troop_no")])

Usage :
Code:
 ["heraldic_mail_with_surcoat", "Heraldic Mail with Surcoat", [("heraldic_armor_new_a",0)], itp_merchandise| itp_type_body_armor  |itp_covers_legs ,0,
 3454 , weight(22)|abundance(100)|head_armor(0)|body_armor(49)|leg_armor(17)|difficulty(7) ,imodbits_armor,
 [heraldic("tableau_heraldic_armor_a")]],
["heraldic_mail_with_tunic", "Heraldic Mail", [("heraldic_armor_new_b",0)], itp_merchandise| itp_type_body_armor  |itp_covers_legs ,0,
 3520 , weight(22)|abundance(100)|head_armor(0)|body_armor(50)|leg_armor(16)|difficulty(7) ,imodbits_armor,
 [heraldic("tableau_heraldic_armor_b")]],
["heraldic_mail_with_tunic_b", "Heraldic Mail", [("heraldic_armor_new_c",0)], itp_merchandise| itp_type_body_armor  |itp_covers_legs ,0,
 3610 , weight(22)|abundance(100)|head_armor(0)|body_armor(50)|leg_armor(16)|difficulty(7) ,imodbits_armor,
 [heraldic("tableau_heraldic_armor_c")]],
["heraldic_mail_with_tabard", "Heraldic Mail with Tabard", [("heraldic_armor_new_d",0)], itp_merchandise| itp_type_body_armor  |itp_covers_legs ,0,
 3654 , weight(21)|abundance(100)|head_armor(0)|body_armor(51)|leg_armor(15)|difficulty(7) ,imodbits_armor,
 [heraldic("tableau_heraldic_armor_d")]],
 
hey folks, silly question perhaps, but I've added in a dialogue option which I want ONLY to work if the conversation-partner is the faction leader or marshall:
I'm using (eq|this or next, $G_talk_troop, faction_leader), (eq, $G_talk_troop, faction_marshall)
but the dialogue (a) gets triggered by every ****er I speak to and (b) then dumps me in an encounter-battle instead of back to the generic 'start' dialogue...

any suggestions as to what this is?  Should I name the troop, rather than trying slot=factionleader?
Should I limit it to either leader or marshall, not both?
 
(this_or_next|faction_slot_eq, "$g_talk_troop_faction", slot_faction_leader, "$g_talk_troop"),
(faction_slot_eq, "$g_talk_troop_faction", slot_faction_marshall, "$g_talk_troop"),
 
Greetings everyone. Here's a little something I figured could be of some use to someone - a list system.
As you know, we do lack some of the nicer data structures invented by humanity when we're talking about the ModSys, and I found myself baffled when I needed to retrieve two random items from a sequence. A list, I thought, would do the job perfectly, but did I have a list at my disposal? Nope. Only static arrays, and they lack the option to remove an element from their sequences (given that I needed to use values both greater than, smaller than or equal to zero in my variables). For this reason and a few more that I won't be listing here, I finally cursed it all and just wrote this small and nifty list system. Of course, it's not OO and you can only have one list at all times, but I reckon this should be enough, and you can always expand it if you want.
And yes, I know it's a trivial thing to make, but as I know how exactly lazy I am, I'm thinking that there could be others like me around here. :razz:

Features (i.e. currently existing functions):
- Adding an element at the end;
- Adding an element at an arbitrary index;
- Removing an element from the end;
- Removing an element at an arbitrary index;
- Counting the amount of elements present;
- Returning a random element from the list (along with its index);
- Clearing the list from all elements.

Anyways, without further ado, here's the codes:
Code:
tlst = "trp_tlst" ## Lumos: This is so we can reference it easily if we need to
Code:
## Lumos: This is the troop which will act as the list "object"
  ["tlst", "{!}List", "{!}List to be used for all purposes deemed necessary", tf_hero, no_scene, reserved, fac_neutral,[],ultra_attrib|level(60),wp(800),knows_high_level,merchant_face_1, merchant_face_2],
Code:
#-## List management
## The list's zero slot holds the number of current items in it
# script_list_clear
# Clears all items from the list
# INPUT: none
# OUTPUT: none
("list_clear", [
	(troop_get_slot, ":num_elements", tlst, 0),
	(val_add, ":num_elements", 1),
	(try_for_range, ":slot", 1, ":num_elements"),
		(troop_set_slot, tlst, ":slot", 0),
	(try_end),
	(troop_set_slot, tlst, 0, 0), # Reset number of elements
]),

# script_list_add
# Appends an item to the list
# INPUT: arg1 - the value which we will add to the list
# OUTPUT: none
("list_add", [
	(store_script_param, ":value", 1),
	(troop_get_slot, ":num_elements", tlst, 0),
	(val_add, ":num_elements", 1),
	(troop_set_slot, tlst, ":num_elements", ":value"),
	(troop_set_slot, tlst, 0, ":num_elements"),
]),

# script_list_add_at
# Appends an item to the list, at the specified index
# INPUT: arg1 - the value which we will add to the list, arg2 - where we want it (ONE-BASED!)
# OUTPUT: none
("list_add_at", [
	(store_script_param, ":value", 1),
	(store_script_param, ":index", 2),
	(troop_get_slot, ":num_elements", tlst, 0),
	(try_begin),
		(gt, ":index", ":num_elements"),
		(assign, ":index", ":num_elements"),
	(try_end),
	(val_add, ":num_elements", 1),
	(try_for_range_backwards, ":slot", ":index", ":num_elements"),
		(store_add, ":target", ":slot", 1),
		(troop_get_slot, ":val", tlst, ":slot"),
		(troop_set_slot, tlst, ":target", ":val"),
	(try_end),
	(troop_set_slot, tlst, ":index", ":value"),
	(troop_set_slot, tlst, 0, ":num_elements"),
]),

# script_list_remove
# Removes an item from the list
# INPUT: none
# OUTPUT: none
("list_remove", [
	(troop_get_slot, ":num_elements", tlst, 0),
	(troop_set_slot, tlst, ":num_elements", 0),
	(val_sub, ":num_elements", 1),
	(troop_set_slot, tlst, 0, ":num_elements"),
]),

# script_list_remove_at
# Removes an item from the list, at the specified index
# INPUT: arg1 - the index we'll remove from (ONE-BASED!)
# OUTPUT: none
("list_remove_at", [
	(store_script_param, ":index", 1),
	(troop_get_slot, ":num_elements", tlst, 0),
	(try_begin),
		(gt, ":index", ":num_elements"),
		(assign, ":index", ":num_elements"),
	(try_end),
	(store_add, ":end", ":num_elements", 1),
	(val_sub, ":num_elements", 1),
	(store_add, ":start", ":index", 1),
	(try_for_range, ":slot", ":start", ":end"),
		(troop_get_slot, ":val", tlst, ":slot"),
		(troop_set_slot, tlst, ":index", ":val"),
		(val_add, ":index", 1),
	(try_end),
	(troop_set_slot, tlst, 0, ":num_elements"),
]),

# script_list_index_of
# Removes the index of something from the list
# INPUT: arg1 - the value we're looking for
# OUTPUT: reg1 - the index (-1 if not found)
("list_index_of", [
	(store_script_param, ":val", 1),
	(assign, ":index", -1),
	(troop_get_slot, ":num_elements", tlst, 0),
	(val_add, ":num_elements", 1),
	(try_for_range, ":slot", 1, ":num_elements"),
		(troop_slot_eq, tlst, ":slot", ":val"),
		(assign, ":index", ":slot"),
		(break_loop),
	(try_end),
	(assign, reg1, ":index"),
]),

# script_list_count
# Returns how many items there are in the list
# INPUT: none
# OUTPUT: reg1 - the list's length
("list_count", [
	(troop_get_slot, reg1, tlst, 0),
]),

# script_list_random
# Returns a random element from the list, along with its index
# INPUT: none
# OUTPUT: reg1 - the value of the item, reg2 - its index
("list_random", [
	(troop_get_slot, ":num_elements", tlst, 0),
	(val_add, ":num_elements", 1),
	(store_random_in_range, reg2, 1, ":num_elements"),
	(troop_get_slot, reg1, tlst, reg2),
]),
#-## List management end

Usage example:
Let's say that you want to select two kings at random, which you're then to use for something, like scripting a duel or whatever you want.
Here's how you could use a list for this purpose:
Code:
(call_script, "script_list_clear"), # Clear the list so we can safely use it now
(try_for_range, ":king", kings_begin, kings_end), # Add all kings to our list
	(call_script, "script_list_add", ":king"),
(try_end),
# Now, let's get our first king from the list:
(call_script, "script_list_random"),
(assign, ":king_1", reg1),
(call_script, "script_list_remove_at", reg2), # Remove king_1 from the list so we don't select him again
# Get the second one
(call_script, "script_list_random"),
(assign, ":king_2", reg1),
# Clear the list after using it if you want
# (call_script, "script_list_clear"),
And there we go, now we've got our kings stored as
Code:
[color=navy]":king_1"[/color]
and
Code:
[color=navy]":king_2"[/color]
, and it's been quick and efficient without lots of checks and stuff like that.

I would write a description about each of the scripts present, but I've already made a list of the functions (one script per each, of course), and the scripts themselves are documented, so look at them if you need to.

EDIT: I have not performed extensive testing on the functions, only a bit, but they should work OK at all times.

Hope this helps somebody so I can feel like a good person.
Lumos out.
 
Neat code, lumos. It should be very useful.
If we need multiple lists on our mods, it will be simpler if the tlist is included to scripts' parameter, so we don't need to write the scripts for each list.
 
Lav casts "Raise Undead Thread".
Thread raises from the dead.
Lav's Thread Necromancy skill increased by +2 to 17.


A small (or rather medium) script which can be used to identify any item prerequisites. Might be useful for AI deciding whether or not it's interested in something or not, or for various presentations where you need to display item information.

Code:
gip_dummy = "trp_merchants_end"
Code:
  # script_get_item_prerequisites:
  #  Use this script to identify item's prerequisites (what attribute/skill and at what level character must have to equip the item).
  #  It uses "trp_merchants_end" troop by default, but can use any other if necessary, for as long as it's tf_hero and NOT tf_inactive.
  #  Input:
  #   arg1 - item_id
  #   arg2 - item_modifier
  #  Output:
  #   reg0 - prerequisite type. 0 == No Prerequisite; 1 == Attribute Prereq, 2 == Skill Prereq
  #   reg1 - prerequisite id. Contains skill ID for skill prereq and attribute ID for attr prereqs (though it's always ca_strength and thus 0).
  #   reg2 - prerequisite value. Note that zero reg2 in combination with non-zero reg0/reg1 means the script FAILED to identify prerequisite value for whatever reason.
  ("get_item_prerequisites",
    [
      (store_script_param_1, ":item_id"),
      (item_get_type, ":item_type", ":item_id"),
      (store_script_param_2, ":item_modifier_id"),
      (assign, ":preq_type", 0),
      (assign, ":preq_atsk", 0),
      (assign, ":preq_value", 0),
      # Identify prerequisite type and relevant skill
      (assign, ":max_preq", 11), # We check for skill values of up to 10. Increase this if your mod has higher prerequisites.
      (try_begin),
        (this_or_next|eq, ":item_type", itp_type_one_handed_wpn),
        (this_or_next|eq, ":item_type", itp_type_two_handed_wpn),
        (this_or_next|eq, ":item_type", itp_type_polearm),
        (this_or_next|eq, ":item_type", itp_type_crossbow),
        (this_or_next|eq, ":item_type", itp_type_head_armor),
        (this_or_next|eq, ":item_type", itp_type_body_armor),
        (this_or_next|eq, ":item_type", itp_type_foot_armor),
        (eq, ":item_type", itp_type_hand_armor),
        (assign, ":preq_type", 1),
        (assign, ":max_preq", 21), # We check for STR values of up to 20. Increase this if your mod has higher prerequisites.
      (else_try),
        (eq, ":item_type", itp_type_horse),
        (assign, ":preq_type", 2),
        (assign, ":preq_atsk", "skl_riding"),
      (else_try),
        (eq, ":item_type", itp_type_shield),
        (assign, ":preq_type", 2),
        (assign, ":preq_atsk", "skl_shield"),
      (else_try),
        (eq, ":item_type", itp_type_bow),
        (assign, ":preq_type", 2),
        (assign, ":preq_atsk", "skl_power_draw"),
      (else_try),
        (eq, ":item_type", itp_type_thrown),
        (assign, ":preq_type", 2),
        (assign, ":preq_atsk", "skl_power_throw"),
      (try_end),
      # Identify prerequisite value
      (try_begin),
        (neq, ":preq_type", 0),
        # Cleanup temp troop inventory and attr/skill
        (troop_set_auto_equip, gip_dummy, 0),
        (troop_clear_inventory, gip_dummy),
        (try_for_range, ":slot_id", 0, num_equipment_kinds),
          (troop_set_inventory_slot, gip_dummy, ":slot_id", -1),
        (try_end),
        (try_begin),
          (eq, ":preq_type", 1),
          (store_attribute_level, ":previous", gip_dummy, ca_strength),
          (val_mul, ":previous", -1),
          (troop_raise_attribute, gip_dummy, ca_strength, ":previous"),
        (else_try),
          (store_skill_level, ":previous", ":preq_atsk", gip_dummy),
          (val_mul, ":previous", -1),
          (troop_raise_skill, gip_dummy, ":preq_atsk", ":previous"),
        (try_end),
        # Give a replica of our item to test troop
        (troop_set_inventory_slot, gip_dummy, num_equipment_kinds, ":item_id"),
        (troop_set_inventory_slot_modifier, gip_dummy, num_equipment_kinds, ":item_modifier_id"),
        # If we are checking a shield, we need to provide the troop with a zero-prerequisite one-handed weapon.
        (try_begin),
          (eq, ":item_type", itp_type_shield),
          (troop_set_inventory_slot, gip_dummy, ek_item_0, "itm_club"),
        (try_end),
        # Attempt to equip while zero attr/skill
        (troop_equip_items, gip_dummy),
        (try_begin),
          (troop_get_inventory_slot, ":now", gip_dummy, num_equipment_kinds),
          (eq, ":now", ":item_id"), # If the item is still there, the troop failed to equip it, so now we need to find the prerequisite
          # Now checking
          (try_for_range, ":value", 1, ":max_preq"),
            (eq, ":preq_value", 0), # We still haven't found a valid prerequisite
            # Increase prerequisite attr/skill by 1
            (try_begin),
              (eq, ":preq_type", 1), # STR check?
              (troop_raise_attribute, gip_dummy, ca_strength, 1),
            (else_try),
              (troop_raise_skill, gip_dummy, ":preq_atsk", 1),
            (try_end),
            # Attempt to equip the item
            (troop_equip_items, gip_dummy),
            (try_begin),
              (troop_get_inventory_slot, ":now", gip_dummy, num_equipment_kinds),
              (eq, ":now", -1), # If no item is there, then troop must have equipped the item.
              (assign, ":preq_value", ":value"), # We found the prerequisite value! Store it.
              #(assign, ":value", ":max_preq"), # Try to break the cycle (not sure if it works, but won't hurt anyway).
            (try_end),
          (try_end),
        (else_try),
          # We have successfully equipped the item with zero attr/skill. So it doesn't have any prereqs after all.
          (assign, ":preq_type", 0),
          (assign, ":preq_atsk", 0),
        (try_end),
        # Cleanup temp troop inventory after we finished processing
        (troop_clear_inventory, gip_dummy),
        (try_for_range, ":slot_id", 0, num_equipment_kinds),
          (troop_set_inventory_slot, gip_dummy, ":slot_id", -1),
        (try_end),
      (try_end),
      # Return results
      (assign, reg0, ":preq_type"),
      (assign, reg1, ":preq_atsk"),
      (assign, reg2, ":preq_value"),
    ]
  ),
 
This thread is code repository, not Q&A.

Please use this thread for questions: http://forums.taleworlds.com/index.php/topic,6575.0.html
 
Simple little bit of code to export & import NPC heros from the Character/Statistics screen:

From module_dialogs.py: Additions in Red
  [anyone,"member_trade", [], "Very well, it's all here...", "do_member_trade",[(set_player_troop, "trp_player"),(change_screen_equip_other)]], #set back to trp_player before open equipment or you get two screens of the NPCs equipment.
  [anyone,"view_member_char_requested", [], "All right, let me tell you...", "do_member_view_char", [(set_player_troop,"$g_talk_troop"),[change_screen_view_character]]],
  [anyone|plyr,"member_talk", [], "Never mind.", "close_window",[(set_player_troop, "trp_player")]], #set back to trp_player at the end or you'll become the troop.

Then also code to export and import non-hero troops from Character/Statistics screen:

From module_dialogs.py: Additions in Red
  [anyone,"view_regular_char_requested", [], "Aye {sir/madam}. Let me tell you all there is to know about me.", "do_regular_member_view_char", [(set_player_troop,"$g_talk_troop"), [change_screen_view_character]]],
  [anyone|plyr,"regular_member_talk", [], "Nothing. Keep moving.", "close_window",[(set_player_troop, "trp_player")]], #set back to trp_player at the end or you will become the troop.

The same can be done for anybody who will show you their statistics (character) screen.
 
In the hopes of creating a more active counter part of the 3D Art and Sceners guild thread, i moved this over into the main section.  :wink:
 
How to change the damage-dealing weapon (and possibly more) in ti_on_agent_hit
Code:
(ti_on_agent_hit , 0, 0, [], [
    #The data you will need.
    (store_trigger_param_1, ":victim"), 
    (store_trigger_param_2, ":dealer"),
    (store_trigger_param,     ":damage", 3), 
    
    #The code
        (try_begin),
	    (eq, "$inner_hit_trigger", 0), #Initialize this to 0 somewhere safe
	    (store_agent_hit_points, ":hp_percent", ":victim", 0),
        (try_begin),
            (eq, ":hp_percent", 100), #can't add 1 to maxed-out health, so we'll add it back after we do damage.
	    (assign, "$inner_hit_trigger", 1),
            (agent_deliver_damage_to_agent, ":dealer", ":victim", 1, "itm_your_item"), 
            (store_agent_hit_points, ":hp", ":victim", 1),
            (val_add, ":hp", 1),
            (agent_set_hit_points, ":victim", ":hp", 1),
        (else_try),
            #Add one health and do one damage
            (store_agent_hit_points, ":hp", ":victim", 1),
            (val_add, ":hp", 1),
            (agent_set_hit_points, ":victim", ":hp", 1),
            (assign, "$inner_hit_trigger", 1),
            (agent_deliver_damage_to_agent, ":dealer", ":victim", 1, "itm_your_item"), 
        (try_end),
            (assign, "$inner_hit_trigger", 0),
    (try_end)
    (set_trigger_result, ":damage"), #Just in case damage gets overwritten
]),

I don't know how exactly it works, but after some experimenting, I can make an educated guess:

Calling agent_deliver_damage_to_agent results in a ti_on_agent_hit_trigger, so calling it inside a ti_on_agent_hit trigger results in an "inner" ti_on_agent_hit_trigger. When this happens, some (probably all, not sure) of the trigger params are overwritten by the inner trigger--including the inflicting weapon--and are not restored when the inner trigger exits.

However, if you kill the agent in the inner trigger, it counts as two kills (both the inner and the outer trigger will consider the agent dead), so you have to avoid doing that, that's why I add one health and only do one damage--to prevent killing the agent (or, if the health is already 100 percent, do one damage then add one health, which works unless the agent has a max health of one, which will probably never happen).

The inner_hit_trigger global variable is used to prevent infinite inner_triggers from happening. You can do this other ways as well (by testing for weapon, agent ids, etc as long as you prevent infinite triggers from going off).

I use this to change the weapon icon of the multiplayer kill message, but (if all the data gets overwritten), you could also effectively use this effect to change who's dealing damage or who gets hit or get some damage calculation from a different item.

Edit: It does look like all the data gets overwritten (except maybe the inflicted agent id). I just made the game think an agent killed himself when I last-hit him.
 
Geoffrey Ashe said:
Okay here it goes, the sources of the NNY mod. I hope they are getting used:

Explanation how to the read/insert the code
filename
#######

this file is meant, till another one is mentioned.


code1
#----------------------------------------------------------------------------------
code2
#----------------------------------------------------------------------------------
code3

code 2 is new and is supposed t o be inserted between code1 and code3 (they are mentioned to find where exactly the code is supposed to go)


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-

Desperation between each code piece

Talk to village elder/guild master
module_game_menus.py
####################

        ], "Door to the castle."),
#----------------------------------------------------------------------------------
    ("talk_mayor",[
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
          (this_or_next|eq,"$entry_to_town_forbidden",0),
          (eq, "$sneaked_into_town",1)]
      ,"Talk to the Guild Master.",
      [
          (assign, "$talk_context", 0),
          (try_begin),
            (call_script, "script_cf_enter_center_location_bandit_check"),
          (else_try),
            (party_get_slot, ":town_scene", "$current_town", slot_town_center),
            (modify_visitors_at_site, ":town_scene"),
            (reset_visitors),
            (assign, "$g_mt_mode", tcm_default),
            (store_faction_of_party, ":town_faction","$current_town"),
            (try_begin),
              (neq, ":town_faction", "fac_player_supporters_faction"),
              (faction_get_slot, ":troop_prison_guard", "$g_encountered_party_faction", slot_faction_prison_guard_troop),
              (faction_get_slot, ":troop_castle_guard", "$g_encountered_party_faction", slot_faction_castle_guard_troop),
              (set_visitor, 23, ":troop_castle_guard"),
              (set_visitor, 24, ":troop_prison_guard"),
            (try_end),
            (faction_get_slot, ":tier_2_troop", ":town_faction", slot_faction_tier_2_troop),
            (faction_get_slot, ":tier_3_troop", ":town_faction", slot_faction_tier_3_troop),

            (try_begin),
              (gt,":tier_2_troop", 0),
              (assign,reg(0),":tier_3_troop"),
              (assign,reg(1),":tier_3_troop"),
              (assign,reg(2),":tier_2_troop"),
              (assign,reg(3),":tier_2_troop"),
            (else_try),
              (assign,reg(0),"trp_vaegir_infantry"),
              (assign,reg(1),"trp_vaegir_infantry"),
              (assign,reg(2),"trp_vaegir_archer"),
              (assign,reg(3),"trp_vaegir_footman"),
            (try_end),
            (shuffle_range,0,4),
            (set_visitor,25,reg(0)),
            (set_visitor,26,reg(1)),
            (set_visitor,27,reg(2)),
            (set_visitor,28,reg(3)),

            (party_get_slot, ":spawned_troop", "$current_town", slot_town_armorer),
            (set_visitor, 9, ":spawned_troop"),
            (party_get_slot, ":spawned_troop", "$current_town", slot_town_weaponsmith),
            (set_visitor, 10, ":spawned_troop"),
            (party_get_slot, ":spawned_troop", "$current_town", slot_town_horse_merchant),
            (set_visitor, 12, ":spawned_troop"),
            (party_get_slot, ":spawned_troop", "$current_town", slot_town_elder),
            (set_visitor, 11, ":spawned_troop"),

            (call_script, "script_init_town_walkers"),
            (set_jump_mission,"mt_town_center"),
            (assign, ":eek:verride_state", af_override_horse),
            (try_begin),
              (eq, "$sneaked_into_town", 1), #setup disguise
              (assign, ":eek:verride_state", af_override_all),
            (try_end),
            (mission_tpl_entry_set_override_flags, "mt_town_center", 0, ":eek:verride_state"),
            (mission_tpl_entry_set_override_flags, "mt_town_center", 2, ":eek:verride_state"),
            (mission_tpl_entry_set_override_flags, "mt_town_center", 3, ":eek:verride_state"),
            (mission_tpl_entry_set_override_flags, "mt_town_center", 4, ":eek:verride_state"),
            (mission_tpl_entry_set_override_flags, "mt_town_center", 5, ":eek:verride_state"),
            (mission_tpl_entry_set_override_flags, "mt_town_center", 6, ":eek:verride_state"),
            (mission_tpl_entry_set_override_flags, "mt_town_center", 7, ":eek:verride_state"),
            (try_begin),
              (eq, "$town_entered", 0),
              (assign, "$town_entered", 1),
              (eq, "$town_nighttime", 0),
              (set_jump_entry, 1),
            (try_end),
            (jump_to_scene, ":town_scene"),
            (change_screen_map_conversation, ":spawned_troop"),
          (try_end),
        ],"Door to the town center."),
#----------------------------------------------------------------------------------     
      ("town_center",[



#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-



          (jump_to_menu, "mnu_center_manage"),
        ]),
#---------------------------------------------------------------------------------- 
      ("village_elder_talk",[(neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
                        (neg|party_slot_eq, "$current_town", slot_village_state, svs_being_raided),
                        (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),]
      ,"Speak with the Village Elder.",
      [
        (try_begin),
          (call_script, "script_cf_enter_center_location_bandit_check"),
        (else_try),
          (party_get_slot, ":village_scene", "$current_town", slot_castle_exterior),
          (modify_visitors_at_site,":village_scene"),
          (reset_visitors),
          (party_get_slot, ":village_elder_troop", "$current_town",slot_town_elder),
          (set_visitor, 11, ":village_elder_troop"),

          (call_script, "script_init_town_walkers"),

          (try_begin),
            (check_quest_active, "qst_hunt_down_fugitive"),
            (neg|is_currently_night),
            (quest_slot_eq, "qst_hunt_down_fugitive", slot_quest_target_center, "$current_town"),
            (neg|check_quest_succeeded, "qst_hunt_down_fugitive"),
            (neg|check_quest_failed, "qst_hunt_down_fugitive"),
            (set_visitor, 45, "trp_fugitive"),
          (try_end),

          (set_jump_mission,"mt_village_center"),
          (jump_to_scene,":village_scene"),

          (change_screen_map_conversation, ":village_elder_troop"),
        (try_end),
        ],"Door to the village center."),
#---------------------------------------------------------------------------------- 
      ("recruit_volunteers",[(call_script, "script_cf_village_recruit_volunteers_cond"),]

Bandit bribery
module_dialog.py
################

    ], "{s5}", "close_window",[encounter_attack]],
#----------------------------------------------------------------------------------
[anyone|plyr,"bandit_meet", [], "I spare your life if you join me", "bandit_recruit",[]],

[anyone,"bandit_recruit", [
(store_random_in_range,":rand",0,20),
(gt,"$player_honor",":rand"),
], "A {boy/girl} like you, who could do no misdeeds? Heck no. We will slit your throat for your impudence!","close_window",[encounter_attack]],#needs dialog rewrite

[anyone,"bandit_recruit",[
(store_encountered_party,":party"),
(store_party_size,":size",":party"),
(store_mul,":size",":size",50),
(assign, reg0, ":size"),
],"we consider your offer for {reg0} denars","bandit_recruit_2",[]],

[anyone|plyr,"bandit_recruit_2",
[
        (store_troop_gold, ":gold", "trp_player"),
        (ge, ":gold", reg0),
(party_can_join),
],"Okay","close_window",
[
(troop_remove_gold, "trp_player", reg0),
(party_join),
(assign, "$g_leave_encounter", 1)
]],

 
[anyone|plyr,"bandit_recruit_2",[],"Nevermind","bandit_meet",[]],
#----------------------------------------------------------------------------------
  [anyone|plyr,"bandit_meet", [], "Never mind, I have no business with you.", "close_window",[(assign, "$g_leave_encounter", 1)]],

Tavern recruitment and ale
module_dialog.py
################


      (assign, "$buy_drinks_last_time", ":cur_hours"),
      ]],
#----------------------------------------------------------------------------------
  [anyone|plyr,"tavernkeeper_talk", [
      (store_current_hours,":cur_hours"),
      (val_sub, ":cur_hours", 24),
      (gt, ":cur_hours", "$buy_drinks_last_time"),
      ], "I'd like to buy me and my men a barrel of your best ale.", "tavernkeeper_buy_drinks_troops",[]],

  [anyone,"tavernkeeper_buy_drinks_troops",
  [
    ], "Of course, {my lord/my lady}. I reckon {reg5} denars should be enough for that. What should I tell the lads?", "tavernkeeper_buy_drinks_troops_2",[
        (assign, "$temp", 20),
(store_party_size_wo_prisoners, reg5, "p_main_party"),
(store_mul, "$temp", "$temp", reg5),
        (assign, reg5, "$temp"),
        ]],

  [anyone|plyr,"tavernkeeper_buy_drinks_troops_2",
  [
        (store_troop_gold, ":gold", "trp_player"),
        (ge, ":gold", "$temp"),
        (str_store_party_name, s10, "$current_town"),
    ], "The price is fair enough, let my men have at it.", "tavernkeeper_buy_drinks_troops_end",[
       
        ]],

  [anyone,"tavernkeeper_buy_drinks_troops_end",
  [], "Don't worry {sir/madam}. Your men will enjoy their pints.", "tavernkeeper_pretalk",
  [
      (troop_remove_gold, "trp_player", "$temp"),
  (call_script, "script_change_player_party_morale", 20),
      (store_current_hours,":cur_hours"),
      (assign, "$buy_drinks_last_time", ":cur_hours"),
  (rest_for_hours, 2, 5, 0)
      ]],

  [anyone|plyr,"tavernkeeper_buy_drinks_troops_2", [], "Actually, cancel that order.", "tavernkeeper_pretalk",[]],
#----------------------------------------------------------------------------------
  [anyone|plyr,"tavernkeeper_talk", [], "It's time for me to leave.", "close_window",[]],#I altered that line...


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


    (call_script, "script_end_quest", "qst_deliver_wine"),
  ]],
#----------------------------------------------------------------------------------
  [anyone|plyr,"tavernkeeper_talk", [], "I need to hire some soldiers. Can you help me?", "tavernkeeper_buy_peasants",[]],
  [anyone,"tavernkeeper_buy_peasants",
  [
      (store_encountered_party,reg(3)),
      (store_faction_of_party,reg(4),reg(3)),
      (store_relation,reg(5),"fac_player_supporters_faction",reg(4)),
      (lt, reg(5), -3),
    ], "I don't think anyone from this town will follow somebody like you. Try your luck elsewhere.", "tavernkeeper_buy_peasants_2",[]],
  [anyone,"tavernkeeper_buy_peasants", [], "I know a few fellows who would follow you if you paid for their equipment.", "tavernkeeper_buy_peasants_2",[(store_encountered_party,reg(2)),(party_get_slot,"$tavernkeeper_party",reg(2)),slot_town_mercs),(set_mercenary_source_party,"$tavernkeeper_party"),(change_screen_buy_mercenaries)]],
  [anyone,"tavernkeeper_buy_peasants_2", [], "Anything else?", "tavernkeeper_talk",[]],
#----------------------------------------------------------------------------------
##  [anyone|plyr,"tavernkeeper_talk", [], "I want to rest for a while.", "tavernkeeper_rest",[]],

Note: thanks vonmistont for the fix.

#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


module_scripts.py
#################


#        (party_set_slot,":town_no", slot_town_seneschal, ":cur_object_no"),
#----------------------------------------------------------------------------------
(store_add, ":cur_object_no", "p_town_merc_1", ":eek:ffset"),
(party_set_slot,":town_no", slot_town_mercs,":cur_object_no"),
#----------------------------------------------------------------------------------
        (store_add, ":cur_object_no", "scn_town_1_center", ":eek:ffset"),


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


at the end of module_script.py
#----------------------------------------------------------------------------------
#no input/output
#could need a faction check
#that's from the 808 module system

("add_tavern_troops",
[
(try_for_range,reg(2),merc_parties_begin,merc_parties_end),
        (store_party_size,reg(6),reg(2)),
(lt,reg(6),30), #never have many more than 20 troops in the tavern
(store_random,reg(7),:cool:,
(party_add_members,reg(2),"trp_townsman",reg(7)),
(store_random,reg(:cool:,5),
(party_add_members,reg(2),"trp_refugee",reg(:cool:),
(store_random,reg(9),5),
(party_add_members,reg(2),"trp_manhunter",reg(9)),
(try_end),
 
]),
#----------------------------------------------------------------------------------
before the last ]


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


Note: You can modify the join cost in "game_get_join_cost"


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


        (call_script, "script_spawn_bandits"),
      (try_end),
#----------------------------------------------------------------------------------
(call_script, "script_add_tavern_troops"),
#----------------------------------------------------------------------------------
      (set_spawn_radius, 50),


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


module_constants.py
###################


at the end of module_constants.py
#----------------------------------------------------------------------------------
merc_parties_begin = "p_town_merc_1"
merc_parties_end = "p_castle_1"
#----------------------------------------------------------------------------------


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


module_parties.py
#################

#  ("village_reinforcements","village_reinforcements",pf_is_static|pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(1,1),[]),
#----------------------------------------------------------------------------------
  ("town_merc_1","sargoth_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_2","tihr_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_3","veluca_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_4","suno_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_5","jelkala_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_6","praven_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_7","uxkhal_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_8","reyvadin_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_9","khudan_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_10","tulga_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_11","curaw_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_12","wercheg_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_13","rivacheg_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_14","halmar_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_15","yalen_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_16","dhirim_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_17","ichamur_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
  ("town_merc_18","narra_mercs",pf_disabled, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(0,0),[]),
#----------------------------------------------------------------------------------
  ("zendar","Zendar",pf_disabled|icon_town|pf_is_static|pf_always_visible|pf_hide_defenders, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(18,60),[]),


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


module_triggers.py
##################


    (call_script, "script_update_companion_candidates_in_taverns"),
    ],
  []
  ),
#----------------------------------------------------------------------------------
  (24.0, 0, 0.0, [],
[
(call_script, "script_add_tavern_troops"),
 
],
  ),
#----------------------------------------------------------------------------------
#Process morale and determine personality clashes

Patrol
module_party_templates.py
#########################


  ("looters","Looters",icon_axeman|carries_goods(:cool:,0,fac_outlaws,bandit_personality,[(trp_looter,4,25)]),
#----------------------------------------------------------------------------------
("player_patrol","Patrol",icon_gray_knight,0,fac_player_faction,hold_personality,[]),
#----------------------------------------------------------------------------------
  ("manhunters","Manhunters",icon_gray_knight,0,fac_manhunters,soldier_personality,[(trp_manhunter,9,40)]),


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


module_scripts.py
#################

at the end of module_script.py
#----------------------------------------------------------------------------------
#identify party as patrol
#input: party
#output: reg0
#0 yes, 1 no

("cf_is_patrol",
[
(store_script_param, ":cur_party", 1),
(assign,reg0,0),
(store_faction_of_party,":cur_faction",":cur_party"),
(eq, ":cur_faction", "fac_player_faction"),
(party_stack_get_troop_id,":cur_troop",":cur_party",0),
(neq,":cur_troop","trp_player"),
(try_for_range,":num",companions_begin,heroes_end),
  (eq,":cur_troop",":num"),
  (assign, reg0,1),
(try_end),
]
),

#find all patrols and count them
#input: none
#output: reg0
#amount of existing patrols

("check_for_patrols",
[
(assign,":num",0),
(try_for_parties,":cur_party"),
  (call_script, "script_cf_is_patrol",":cur_party"),
  (eq,reg0,0),
  (val_add,":num",1),
(try_end),
(assign,reg0,":num"),
]
),

#enforce patrol party size limit
#it is assumed that the party prisoner limit equals zero
#except for npc prisoners

#input: party, mode
#mode 0: delete all troops w/o doing anything else
#mode 1: all deleted troops are being added to the player party

#output: none (it uses reg0, but the information is useless outside of this script and its recursive brother)

("cf_fix_party_size",
[
(store_script_param, ":cur_party", 1),
(store_script_param, ":mode", 2),
(call_script, "script_cf_is_patrol",":cur_party"),
(try_begin),
  (eq,reg0,0),
  (call_script,"script_game_get_party_companion_limit",3),
  (call_script,"script_cf_fix_party_size_recursive",":cur_party",":mode"),

  (assign,":bool",0),
  (party_get_num_prisoner_stacks, ":num_stacks",":cur_party"),
  (try_for_range_backwards,":index",0,":num_stacks"),
    (party_prisoner_stack_get_troop_id,":cur_troop",":cur_party",":index"),
    (party_prisoner_stack_get_size,":cur_size",":cur_party",":index"),
(try_for_range,":num",companions_begin,heroes_end),
      (eq,":cur_troop",":num"),
  (assign,":bool",1),
(try_end),
(try_begin),
  (neq,":bool",1),
      (party_remove_prisoners,":cur_party",":cur_troop",":cur_size"),
(try_end),
  (try_end),
(try_end),
]
),

#a while do loop for cf_fix_party_size
#don't use it outside of the previous script

("cf_fix_party_size_recursive", #I am not exactly happy about the recursive
[
(store_script_param, ":cur_party", 1),
(store_script_param, ":mode", 2),
(assign,":reg0_backup",reg0),
(store_party_size_wo_prisoners,":num",":cur_party"),
(try_begin),
  (gt,":num",reg0),
  (neq,0,reg0),
  (store_sub,":delta",":num",reg0),
  (party_get_num_companion_stacks,":num_stacks",":cur_party"),
  (assign, ":to_del_stack",0),
  (assign, ":checker", 100),
  (try_for_range,":index",0,":num_stacks"),
    (party_stack_get_troop_id,":cur_troop",":cur_party",":index"),
    (store_character_level,":cur_level",":cur_troop"),
    (le,":cur_level",":checker"),
    (assign,":checker",":cur_level"),
    (assign,":to_del_stack",":index"),
  (try_end),
  (party_stack_get_size,":num_troop",":cur_party",":to_del_stack"),
  (party_stack_get_troop_id,":cur_troop",":cur_party",":to_del_stack"),
  (try_begin),
    (le,":num_troop",":delta"),
    (assign, ":delta", ":num_troop"),
  (try_end),
  (party_remove_members,":cur_party",":cur_troop",":delta"),
  (try_begin),
    (eq,":mode",1),
    (party_add_members,"p_main_party",":cur_troop",":delta"),
  (try_end),
  (assign,reg0,":reg0_backup"),
  (call_script,"script_cf_fix_party_size_recursive",":cur_party",":mode"),
(try_end),
]
),
#----------------------------------------------------------------------------------
before the last ]


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


in "game_event_simulate_battle"
...
              (call_script, "script_clear_party_group", ":root_defeated_party"),
#----------------------------------------------------------------------------------
  (call_script,"script_cf_fix_party_size", "p_temp_party",0),
#----------------------------------------------------------------------------------
            (try_end),

Note: this is not tested


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-

in "let_nearby_parties_join_current_battle"
...
          (display_message, "str_s1_joined_battle_enemy"),
#----------------------------------------------------------------------------------
(else_try),
  (eq, ":besiege_mode", 0),
          (lt, ":reln_with_player", 0),
          (gt, ":reln_with_enemy", 0),
  (store_faction_of_party,":cur_faction","$g_encountered_party"),
  (this_or_next|eq,":cur_faction","fac_outlaws"),
  (this_or_next|eq,":cur_faction","fac_deserters"),
  (this_or_next|eq,":cur_faction","fac_mountain_bandits"),
  (eq,":cur_faction","fac_forest_bandits"),
  (store_faction_of_party,":cur_faction",":party_no"),
  (this_or_next|eq,":cur_faction","fac_outlaws"),
  (this_or_next|eq,":cur_faction","fac_deserters"),
  (this_or_next|eq,":cur_faction","fac_mountain_bandits"),
  (eq,":cur_faction","fac_forest_bandits"),
          (party_quick_attach_to_current_battle, ":party_no", ":enemy_side"), #attach as enemy
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_enemy"),
(else_try),
          (eq, ":dont_add_friends", 0),
  (gt, ":reln_with_player", 0),
          (lt, ":reln_with_enemy", 0),
  (store_faction_of_party,":cur_faction",":party_no"),
  (eq,":cur_faction","fac_player_faction"),
          (party_quick_attach_to_current_battle, ":party_no", 0), #attach as ally
          (str_store_party_name, s1, ":party_no"),
          (display_message, "str_s1_joined_battle_friend"),
#----------------------------------------------------------------------------------
        (else_try),
          (eq, ":dont_add_friends", 0),


Note: this also allows other bandit parties to join the fight if you are fighting a bandit party.


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


replace "calculate_player_faction_wage" with this:
#----------------------------------------------------------------------------------
  # script_calculate_player_faction_wage
  # Input: arg1 = party_no
  # Output: reg0 = weekly wage
  ("calculate_player_faction_wage",
    [(assign, ":nongarrison_wages", 0),
    (assign, ":garrison_wages", 0),
    (try_for_parties, ":party_no"),
      (assign, ":garrison_troop", 0),
  (assign, ":ungarrison_troop", 0),
      (try_begin),
        (this_or_next|party_slot_eq, ":party_no", slot_party_type, spt_town),
        (party_slot_eq, ":party_no", slot_party_type, spt_castle),
        (party_slot_eq, ":party_no", slot_town_lord, "trp_player"),
        (assign, ":garrison_troop", 1),
      (try_end),
  (try_begin),
    (call_script, "script_cf_is_patrol",":party_no"),
    (eq,reg0,0),
    (assign, ":ungarrison_troop", 1),
(try_end),
      (this_or_next|eq, ":party_no", "p_main_party"),
      (this_or_next|eq, ":garrison_troop", 1),
  (eq, ":ungarrison_troop", 1),
      (party_get_num_companion_stacks, ":num_stacks",":party_no"),
      (try_for_range, ":i_stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":stack_troop",":party_no",":i_stack"),
        (party_stack_get_size, ":stack_size",":party_no",":i_stack"),
        (call_script, "script_game_get_troop_wage", ":stack_troop", ":party_no"),
        (assign, ":cur_wage", reg0),
        (val_mul, ":cur_wage", ":stack_size"),
        (try_begin),
          (eq, ":garrison_troop", 1),
          (val_add, ":garrison_wages", ":cur_wage"),
        (else_try),
  (try_begin),
    (eq,":ungarrison_troop",1),
    (val_mul, ":cur_wage",3),
    (val_div, ":cur_wage",2),
  (try_end),
          (val_add, ":nongarrison_wages", ":cur_wage"),
        (try_end),
      (try_end),
    (try_end),
    (val_div, ":garrison_wages", 2),#Half payment for garrisons
    (store_sub, ":total_payment", 14, "$g_cur_week_half_daily_wage_payments"), #between 0 and 7
    (val_mul, ":nongarrison_wages", ":total_payment"),
    (val_div, ":nongarrison_wages", 14),
    (store_add, reg0, ":nongarrison_wages", ":garrison_wages"),
    ]),
#----------------------------------------------------------------------------------

Note: Currently patrols got an extra upkeep of +50%, see below (eq,":ungarrison_troop",1),


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


module_game_menus.py
####################

in "total_victory"
...
            (call_script, "script_party_add_party", "$g_ally_party", "p_temp_party"), #Add remaining prisoners to ally TODO: FIX it.
#----------------------------------------------------------------------------------
            (call_script,"script_cf_fix_party_size", "$g_ally_party",0),
#----------------------------------------------------------------------------------
          (else_try),

...
(call_script, "script_party_add_party", ":helper_party", "p_temp_party"), #Add remaining prisoners to our reinforcements
#----------------------------------------------------------------------------------
            (call_script,"script_cf_fix_party_size", ":helper_party",0),
#----------------------------------------------------------------------------------
          (try_end),


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


module_dialogs.py
#################


Replace everything:

######################################
# GENERIC MEMBER CHAT
######################################
#----------------------------------------------------------------------------------
  [anyone,"member_chat", [], "Your orders {sir/madam}?", "regular_member_talk",[]],
  [anyone|plyr,"regular_member_talk", [], "Tell me about yourself", "view_regular_char_requested",[]],
  [anyone,"view_regular_char_requested", [], "Aye {sir/madam}. Let me tell you all there is to know about me.", "do_regular_member_view_char",[[change_screen_view_character]]],
  [anyone,"do_regular_member_view_char", [], "Anything else?", "regular_member_talk",[]],
  [anyone|plyr,"regular_member_talk", [], "Become Party", "mate_check_leadership",[]],
  [anyone,"mate_check_leadership", [
(call_script, "script_check_for_patrols"),
(store_skill_level,":max_amount",skl_leadership,"trp_player"),
(troop_get_slot, ":renown", "trp_player", slot_troop_renown),
(val_div, ":renown", 250),
(val_add, ":max_amount",":renown"),
(try_for_range,":num",walled_centers_begin,walled_centers_end),
              (party_slot_eq, ":num", slot_town_lord, "trp_player"),
  (val_add,":max_amount",1),
(try_end),
(gt,":max_amount",reg0),
],"Very well.","close_window",[
(store_conversation_troop,":soldier"),
(remove_member_from_party,":soldier"),
(spawn_around_party,"p_main_party","pt_player_patrol"),
(party_add_members,reg(0),":soldier",1),
(party_set_ai_behavior,reg(0),ai_bhvr_hold),
]],

  [anyone,"mate_check_leadership", [],"I am sorry, but we don't think that you are capable of leading more parties.","member_chat",[]],
 
  [anyone|plyr,"regular_member_talk", [], "Nothing. Keep moving.", "close_window",[]],

 
 
  [anyone,"start", [(store_encountered_party,"$temp"),
(store_faction_of_party, ":cur_faction", "$temp"),
                    (eq,":cur_faction","fac_player_faction"),
                    ],
  "Yes?", "mate_chat_talk",[(assign, "$g_leave_encounter", 1)]],
 
 
  [anyone|plyr,"mate_chat_talk",[],"I have a new task for you.", "mate_give_order_ask",[]],

  [anyone,"mate_give_order_ask", [],
  "What do you wish?", "mate_give_order",[]],
 
  [anyone|plyr,"mate_give_order",[],"Follow me","mate_follow",[]],
  [anyone,"mate_follow",[],"All right","close_window",[
(party_set_ai_object,"$temp","p_main_party"),
(party_set_ai_behavior,"$temp",ai_bhvr_escort_party),
]],
  [anyone|plyr,"mate_give_order",[],"Stay here","mate_stay",[]],
  [anyone,"mate_stay",[],"All right","close_window",[
(party_set_ai_behavior,"$temp",ai_bhvr_hold),
(party_get_position, pos1, "$temp"),
(party_set_ai_target_position,"$temp",pos1),
]],
  [anyone|plyr,"mate_give_order",[],"Patrol this area","mate_patrol",[]],
  [anyone,"mate_patrol",[],"All right","close_window",[
(party_set_ai_behavior,"$temp",ai_bhvr_patrol_location),
(party_get_position, pos1, "$temp"),
(party_set_ai_target_position,"$temp",pos1),
]],
 
  [anyone|plyr,"mate_give_order", [],"Go to...", "mate_give_order_details_ask",[(assign, "$temp_1", spai_holding_center),]],
  [anyone|plyr,"mate_give_order", [],"Patrol around...", "mate_give_order_details_ask",[(assign, "$temp_1", spai_patrolling_around_center),]],
  [anyone|plyr,"mate_give_order", [],"Forget it.", "mate_chat_pre_talk",[]],
 

  [anyone,"mate_give_order_details_ask", [],
  "Where?", "mate_give_order_details",[]],
 
  [anyone|plyr|repeat_for_parties, "mate_give_order_details",
  [
    (store_repeat_object, ":party_no"),
    (assign, ":continue", 0),
    (try_begin),
      (eq, "$temp_1", spai_holding_center),
      (try_begin),
        (this_or_next|party_slot_eq, ":party_no", slot_party_type, spt_castle),
        (party_slot_eq, ":party_no", slot_party_type, spt_town),
        (assign, ":continue", 1),
      (try_end),
    (else_try),
      (eq, "$temp_1", spai_patrolling_around_center),
      (try_begin),
        (is_between, ":party_no", centers_begin, centers_end),
        (assign, ":continue", 1),
      (try_end),
    (try_end),
    (eq, ":continue", 1),
    (neq, ":party_no", "$g_encountered_party"),
    (str_store_party_name, s1, ":party_no")],
  "{s1}", "mate_give_order_details_done",
  [
    (store_repeat_object, "$temp_2"),
    ]],

  [anyone,"mate_give_order_details_done", [],"Okay","close_window",[
(try_begin),
  (eq,"$temp_1", spai_holding_center),
  (party_set_ai_behavior,"$temp",ai_bhvr_travel_to_point),
  (party_get_position, pos1, "$temp_2"),
  (map_get_land_position_around_position, pos1, pos1,1),
  (party_set_ai_target_position,"$temp",pos1),
(try_end),
(try_begin),
  (eq,"$temp_1", spai_patrolling_around_center),
  (party_set_ai_behavior,"$temp",ai_bhvr_patrol_party),
  (party_set_ai_object,"$temp","$temp_2"),
  (party_set_ai_patrol_radius ,"$temp",1),
(try_end),
]],
 

  [anyone|plyr,"mate_chat_talk", [], "I want to give you troops.", "mate_give_troops",[(call_script,"script_game_get_party_companion_limit",3),(display_message, "@allowed party size {reg0}"),(change_screen_give_members),]],
  [anyone,"mate_give_troops", [], "Yes...", "mate_give_troops_end",[]],
  [anyone,"mate_give_troops_end", [], "That are good lads.", "mate_chat_pre_talk",[
(store_encountered_party,":cur_party"),
(call_script,"script_cf_fix_party_size",":cur_party",1),
]],
  [anyone,"mate_chat_pre_talk", [], "Anything else?", "mate_chat_talk",[]],
 
  [anyone|plyr,"mate_chat_talk", [], "I want to you to join me again.", "mate_chat_rejoin",[]],
  [anyone,"mate_chat_rejoin", [(party_can_join)], "Very Well.", "close_window",[(party_join),]],
  [anyone,"mate_chat_rejoin", [(neg|party_can_join)], "We can't follow you, you haven't got enough capacity","mate_chat_talk",[]],

  [anyone|plyr,"mate_chat_talk", [], "Nevermind", "close_window",[]],
#----------------------------------------------------------------------------------
######################################
# GENERIC PARTY ENCOUNTER
######################################


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


header_parties.py

at the end
hold_personality = aggressiveness_0 | courage_15


#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#--#-


Note: It is not very important, but you might want to change the faction color
replace this line for the current deep blue.
#----------------------------------------------------------------------------------
  ("player_faction","Player Faction",0, 0.9, [], [],0x000000FF),
#----------------------------------------------------------------------------------

I hope I didn't forget anything and please keep the discussion in the NNY thread.

06.12.08 fixed talk to village elder/guild master feature (replace it again, if you were already using it)
05.12.08 fixed tavern recruitment, thanks to vonmistont (green text).

hello

I need How to add this function to the rest of outlaws game?

Please help ^^
 
Use the Q&A Thread for help. This is for sharing code and schemes. This is already made clear in the OP, but i will alter it in a way to make clear that there are thread specific rules. Breaking them will result in warnings.
 
A small anti-import hack temporarily randomizing the player's name:
  ("game_character_sheet", 0, "tableau_with_transparency", 1024, 1024, 0, 0, 266, 532,
  [
      (store_script_param, ":troop_no", 1),
      (cur_tableau_set_background_color, 0xFF88888:cool:,
      (cur_tableau_set_ambient_light, 10,11,15),
      (set_fixed_point_multiplier, 100),
      (cur_tableau_set_camera_parameters, 0, 40, 40, 0, 100000),

#######################################################
        (call_script, "script_init_anti_import", ":troop_no"),
#######################################################
 
 
      (init_position, pos1),
      (position_set_z, pos1, 100),
      (position_set_x, pos1, -20),
      (position_set_y, pos1, -20),
      (cur_tableau_add_tableau_mesh, "tableau_troop_character_color", ":troop_no", pos1, 0, 0),
      (position_set_z, pos1, 200),
      (cur_tableau_add_tableau_mesh, "tableau_troop_character_alpha_mask", ":troop_no", pos1, 0, 0),
      (position_set_z, pos1, 300),
      ]),
  #script_game_get_statistics_line:
  # This script is called from the game engine when statistics page is opened.
  # INPUT:
  # param1: line_no
  ("game_get_statistics_line",
    [
      (store_script_param_1, ":line_no"),
      (try_begin),
        (eq, ":line_no", 0),
        (get_player_agent_kill_count, reg1),
        (str_store_string, s1, "str_number_of_troops_killed_reg1"),
        (set_result_string, s1),
      (else_try),
        (eq, ":line_no", 1),
        (get_player_agent_kill_count, reg1, 1),
        (str_store_string, s1, "str_number_of_troops_wounded_reg1"),
        (set_result_string, s1),
      (else_try),
        (eq, ":line_no", 2),
        (get_player_agent_own_troop_kill_count, reg1),
        (str_store_string, s1, "str_number_of_own_troops_killed_reg1"),
        (set_result_string, s1),
      (else_try),
        (eq, ":line_no", 3),
        (get_player_agent_own_troop_kill_count, reg1, 1),
        (str_store_string, s1, "str_number_of_own_troops_wounded_reg1"),
        (set_result_string, s1),
      (try_end),
  #####################################################  
  (try_begin),
  (eq, "$player_char_window_opened", 1),
  (assign, "$return_from_stats_page", 1),
      (troop_set_name, "trp_player", s0),
  (try_end),
  #####################################################

  ]),

("init_anti_import",
    [  
      (store_script_param_1, ":troop_no"),
        (try_begin),
    (eq, ":troop_no", "trp_player"),
(assign, "$player_char_window_opened", 1),
(store_random_in_range, ":random_troop", "trp_multiplayer_profile_troop_male", "trp_relative_of_merchants_end"),
    (str_store_troop_name,s0, ":random_troop"),
(try_begin),
(neq, "$return_from_stats_page", 1),
    (str_store_troop_name,s2, "trp_player"),       
(else_try),
(troop_set_name, "trp_player", s2),
(assign, "$return_from_stats_page", 0),
(try_end),
(else_try),
(assign, "$player_char_window_opened", 0),
        (try_end),
      ]),
However, it has a small visual glitch in that the player's name is actually restored as soon as you go back from the stats screen, but it looks otherwise there the first time. In addition, you lose your changes when you open the stats page right after renaming your char.
Also, you can circumvent it by exporting the char first (to see the randomized name), then renaming an old file and the one specified inside it to the name when the game is minimized. Then again, not everyone will figure it out.
 
Back
Top Bottom