PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

hello i'm a begginer coder :smile:

So i want to ask you guys something.

1. I want to do a bribe mod something like the player must pay tribute to kingdom of swadia and if you don't have money you'll recive a message for warning an after this if you don't pay the relation with that kingdom be -50.
2. I made some parties of mercs and i want to pay them to join me.
3. I want to remove that menu when you chose what kind of men you want to be and that with the face editing.

Thanks a lot.
 



Har, har, I'm awesome and I know it :razz:
Nothing complicated or elegant but regardless...

How to make set items;
First decide which items you want to a part of set. Breaking the order of Module_items and moving them to the bottom of the list is recommended if you are going to make them available as merchandise, that way they will be on top of the merchants inventory.

In this example I chose Light Leather Set, which is the most obivious choice.

Second Step is to set extra item texts see below (add those to script_game_get_item_extra_text);

Code:
		(else_try),
        (is_between, ":item_no", set1_begin, set1_end), #Those are defined in constants itm_black_hood and itm_itm_byzantion_helmet_a
			(try_begin),
          (eq, ":extra_text_id", 0),
          (set_result_string, "@Light Leather Set:^+1 Power Draw When Complete"),
          (set_trigger_result, 0xffc125),  #Always Gold
		  (else_try),
		  (eq, ":extra_text_id", 1),
		  (set_result_string, "@_"), #The second line, empty, could have been the second line of first id...
		  (set_trigger_result, 0xc4c4c4),
		(else_try),
		  (eq, ":extra_text_id", 2),
(try_begin),
(troop_get_inventory_slot,":head","trp_player",ek_head),
(eq, ":head", "itm_black_hood"),
(set_result_string, "@Black Hood"),
(set_trigger_result, 0x00ff7f), #Green Equipped By Player
(else_try),
(troop_get_inventory_slot,":head","$g_talk_troop",ek_head),
(eq, ":head", "itm_black_hood"),
(set_result_string, "@Black Hood"),
(set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
(else_try),
		  (set_result_string, "@Black Hood"),
		  (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
(try_end),

		(else_try),
		(eq, ":extra_text_id", 3),
(try_begin),
(troop_get_inventory_slot,":head","trp_player",ek_body),
(eq, ":head", "itm_light_leather"),
(set_result_string, "@Leather Armour"),
(set_trigger_result, 0x00ff7f), #Green Equipped By Player
(else_try),
(troop_get_inventory_slot,":head","$g_talk_troop",ek_body),
(eq, ":head", "itm_light_leather"),
(set_result_string, "@Leather Armour"),
(set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
(else_try),
		  (set_result_string, "@Leather Armour"),
		  (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
(try_end),

		(else_try),
		  (eq, ":extra_text_id", 4),
(try_begin),
(troop_get_inventory_slot,":head","trp_player",ek_foot),
(eq, ":head", "itm_light_leather_boots"),
(set_result_string, "@Leather Boots"),
(set_trigger_result, 0x00ff7f), #Green Equipped By Player
(else_try),
(troop_get_inventory_slot,":head","$g_talk_troop",ek_foot),
(eq, ":head", "itm_light_leather_boots"),
(set_result_string, "@Leather Boots"),
(set_trigger_result, 0x1e90ff), #Blue Equipped By Companion
(else_try),
		  (set_result_string, "@Leather Boots"),
		  (set_trigger_result, 0xc4c4c4), #Gray - Not equipped
(try_end),

So as you could have figured it out we make a inventory slot check to see if item is properly equipped, if you want weapons in set items use a (try_for_range, ":cur_slot", 0, 4), so you will pick up :cur_slot as any of the weapon slots (see Fisheyes Chart; http://mbx.streetofeyes.com/index.php/topic,972.0.html).

What we have so far is when an item of the set is equipped the Gray text turns Green or Blue. And when put back into inventory Green Or Blue become Gray.

Now, next step far easier goes into  script_game_get_skill_modifier_for_troop
Code:
	(else_try),
	(eq, ":skill_no", "skl_power_draw"),
			(troop_get_inventory_slot,":cur_item1",":troop_no",ek_head),
			(troop_get_inventory_slot,":cur_item2",":troop_no",ek_body),
			(troop_get_inventory_slot,":cur_item3",":troop_no",ek_foot),
			(eq, ":cur_item1", "itm_black_hood"),
			(eq, ":cur_item2", "itm_light_leather"),
			(eq, ":cur_item3", "itm_light_leather_boots"),
      (val_add, ":modifier_value", 1), 

Again we use inventory slot checks to make sure player has items in the proper slots and we do the rest just like books. So if a troop (player, companions... any troop) has all items in proper slots will get the bonus. (Note to self; Use incremental bonuses like 2 items give +1 full set gives +3... etc.)

Conclusion; M&B:grin:iablo was apperantly possible since .903 :razz:
 
This is really cool! I was just trying to do this myself.  I got as far as creating a sword that gives +1 to ironflesh but it does it in the inventory as well as when equipped and I couldn't figure out how to make the text "adds +1 to ironflesh" show up in the item description... my searching has come to an end! You rock!

-Tiwaz

Edit: wow, you found my other post just as I found this one  :lol:
 
Here a heavily commented version on how to do it for single items, this one is for a weapon/shield.

Code:
  #script_game_get_skill_modifier_for_troop
  # This script is called from the game engine when a skill's modifiers are needed
  # INPUT: arg1 = troop_no, arg2 = skill_no
  # OUTPUT: trigger_result = modifier_value
  ("game_get_skill_modifier_for_troop",
   [(store_script_param, ":troop_no", 1),#This script is called by engine whenever it needs to calculate skills of a troop.  This script should not be called from any other script or trigger.
    (store_script_param, ":skill_no", 2),#Both of these parameters are called for every trp_ and skl_ by the game.
    (assign, ":modifier_value", 0),#This is the modifier value, it must have a value for the final operation, thus it is assigned 0. So it will have a value even if all the tries below fail.
    (try_begin),#Begins Trying For Skills
      (eq, ":skill_no", "skl_wound_treatment"), #This is the skill we are trying.
      (call_script, "script_get_troop_item_amount", ":troop_no", "itm_book_wound_treatment_reference"), #This a check, it will get number of "itm_book_wound_treatment_reference" items.
      (gt, reg0, 0), #The above script registers number of "itm_book_wound_treatment_reference" player has in invetory to reg0. This is a condition, if reg0 is greater 1 this try will succed.
      (val_add, ":modifier_value", 1),#This adds 1 to ":modifier_value", so the value is now 1.
    (else_try),#Once the try above fails, (if skl_ it is looking for is not skl_wound_treatment), it will try this one, untill it finds the skl_ it is looking for.
      (eq, ":skill_no", "skl_trainer"),
      (call_script, "script_get_troop_item_amount", ":troop_no", "itm_book_training_reference"),
      (gt, reg0, 0),
      (val_add, ":modifier_value", 1),
    (else_try),
      (eq, ":skill_no", "skl_surgery"),
      (call_script, "script_get_troop_item_amount", ":troop_no", "itm_book_surgery_reference"),
      (gt, reg0, 0),
      (val_add, ":modifier_value", 1),
#This is try checks for if item is equipped in a slot
(else_try),
  (eq, ":skill_no", "skl_power_draw"),
  (troop_get_inventory_slot,":cur_item1",":troop_no",ek_item_0),#Here we are getting items from slots 0,1,2,3
  (troop_get_inventory_slot,":cur_item2",":troop_no",ek_item_1),#Those slots are where weapons are placed.
  (troop_get_inventory_slot,":cur_item3",":troop_no",ek_item_2),#We get them all to a different :local. Now all those :local variables are equal to one of the items in slots.
  (troop_get_inventory_slot,":cur_item4",":troop_no",ek_item_3),#Then we check each item, if it is the one we want.
  (this_or_next|eq, ":cur_item1", "itm_bonus_giving_item"),#These are conditions similar to the conditions above.
  (this_or_next|eq, ":cur_item2", "itm_bonus_giving_item"),#But we check multiple variables, so we use this_or_next|
  (this_or_next|eq, ":cur_item3", "itm_bonus_giving_item"),#As the name suggests it is either this contion or the next.
  (eq, ":cur_item4", "itm_bonus_giving_item"),#Since this one is the last one we don't need this_or_next. When any of the items is the item we want the script succeds.
  (val_add, ":modifier_value", 1),#And when succeded adds 1.
    (try_end),#Ends Trying For Skills.
    (set_trigger_result, ":modifier_value"),#This the execution of the scipt: :troop_no gets :modifier_value bonus to :skill_no.
    ]),
 
Garnier's Bank of Calradia code -- written for 0.960!

I put together some code for a central bank of Calradia, where you can store money or take loans.  The specifics are;
You go to a town, and click "visit the bank".
To take a loan, you pay 100 denars immediately, and 1000 in debt to the bank.  You can repay the loan at any time.  Interest on the loan is 200% per year, so each week you pay 40 denars interest on each 1000 denar loan.
You have to have 100 real denars to take a loan, real meaning your total cash minus your total debt has to be 100 or more.  So you can't keep taking out loans forever.
If you cannot pay the interest on your loans in a given week, the unpaid sum is added to your debt, and next week you are expected to pay interest again, which in turn is added to the debt if you can't pay. 
You can deposit money at the bank, and gain 20% per year in interest, so 4 d/week on a 1000 deposit.  You can withdraw the deposit at any time.

Global Variables created;

$g_player_debt
$g_player_deposit


Add this to the game start script;  #Defines the global variables used.
Code:
      (store_add, "$g_player_debt",0,0),
      (store_add, "$g_player_deposit",0,0),

Add these menus to game_menus.py;  #The first menu is a weekly interest payment menu, and the second is the bank menu where you handle deposits/loans.
Code:
  (
    "debt_interest",mnf_scale_picture|mnf_disable_all_keys,
    "{s2}",
    "none",
    [

	  (store_div, ":debt_interest","$g_player_debt",25),
          (assign, reg11, ":debt_interest"),
          (store_troop_gold, ":player_wealth", "trp_player"),
          (assign, reg8, ":player_wealth"),
	(try_begin),
	  (ge,"$g_player_debt",1),
	  (try_begin),
            (ge, ":player_wealth", ":debt_interest"),
            (troop_remove_gold, "trp_player",":debt_interest"),
            (store_sub, reg9, reg8, reg11),
            (str_store_string, s2, "@You paid {reg11} of your {reg8} denars in interest on your debt. You have {reg9} denars left."),
          (else_try),
	    (gt, ":debt_interest",":player_wealth"),
	    (gt, ":player_wealth",0),
	    (store_sub, ":unpaid_interest", ":debt_interest",":player_wealth"),
            (troop_remove_gold, "trp_player",":player_wealth"),
            (assign, reg10, ":unpaid_interest"),
            (val_add, "$g_player_debt",":unpaid_interest"),
            (str_store_string, s2, "@You paid all of your {reg8} denars in interest on your debt.  There were still {reg10} denars of the interest unpaid, which has been added to your debt.  You have 0 denars left."),
          (else_try),
	    (gt, "$g_player_debt",0),
	    (eq, ":player_wealth",0),
	    (store_sub, ":unpaid_interest", ":debt_interest",":player_wealth"),
            (val_add, "$g_player_debt",":unpaid_interest"),
            (str_store_string, s2, "@You had 0 denars left to pay the interest on your debt.  The interest of {reg10} denars has been added to your debt."),
          (else_try),
            (str_store_string, s2, "@You have no debts to pay interest on."),
	  (try_end),
	(try_end),
    ],
    [
      ("continue",[],"Continue...",
       [
        (change_screen_return,0),
        ]
       ),
    ]
  ),
  (
    "bank",0,
    "You visit the bank.\
 Here you can deposit money and earn interest over time, or take a loan.\
 You currently have {reg6} denars deposited here.\
 You currently have {reg7} denars borrowed from the bank.",
    "none",
    [
    (assign, reg6, "$g_player_deposit"),
    (assign, reg7, "$g_player_debt"),
    ],
    [
      ("take_loan",[(store_troop_gold, ":player_wealth", "trp_player"),(store_sub, ":player_real_wealth", ":player_wealth", "$g_player_debt"),(gt,":player_real_wealth",100)],"Take a loan of 1000 denars.",
       [
	   (troop_remove_gold, "trp_player", 100),
           (troop_add_gold, "trp_player", 1000),
           (val_add, "$g_player_debt", 1000),
        ]),
      ("give_loan",[(store_troop_gold, ":player_wealth", "trp_player"),(gt,":player_wealth",1000),(gt,"$g_player_debt",1000)],"Repay 1000 denars of your debt.",
       [
	   (troop_remove_gold, "trp_player", 1000),
           (val_sub, "$g_player_debt", 1000),
        ]),
      ("give_loan_all",[(store_troop_gold, ":player_wealth", "trp_player"),(gt,":player_wealth","$g_player_debt"),(gt,"$g_player_debt",0)],"Repay all of your debt.",
       [
	   (troop_remove_gold, "trp_player", "$g_player_debt"),
           (val_sub, "$g_player_debt", "$g_player_debt"),
        ]),
      ("give_deposit",[(store_troop_gold, ":player_wealth", "trp_player"),(gt,":player_wealth",1000)],"Deposit 1000 denars in the bank.",
       [
	   (troop_remove_gold, "trp_player", 1000),
           (val_add, "$g_player_deposit", 1000),
        ]),
      ("take_deposit",[(ge,"$g_player_deposit",1000)],"Withdraw 1000 denars from your deposit.",
       [
	   (troop_add_gold, "trp_player", 1000),
           (val_sub, "$g_player_deposit", 1000),
        ]),
      ("take_deposit_all",[(ge,"$g_player_deposit",1)],"Withdraw your entire deposit.",
       [
	   (troop_add_gold, "trp_player", reg6),
           (val_sub, "$g_player_deposit", reg6),
        ]),
      ("back_to_town_menu",[],"Head back.",
       [
           (jump_to_menu,"mnu_town"),
        ]),
    ]
  ),

And this again to game_menus.py, just after the "visit the tavern" entry;  ##This is the text "Visit the bank" when you are in a town.
Code:
      ("town_bank",
       [],
       "Visit the bank.",
       [
           (jump_to_menu,"mnu_bank"),
        ]),

And this to simple_triggers.py,  ##These trigger the interest on debt payment menu, and the automatic interest on deposits
Code:
  #Interest on deposits.
  (24 * 7,
   [
    (try_begin),
       (gt, "$g_player_deposit", 0),
       (store_div,":interest_deposit","$g_player_deposit",250),
       (troop_add_gold, "trp_player",":interest_deposit"),
    (try_end),
    ]),
  #Interest on debts.
  (24 * 7,
   [
     (try_begin),
       (gt, "$g_player_debt", 0),
       (jump_to_menu,"mnu_debt_interest"),
     (try_end),
    ]),

This is just the basic code, I probably will add random events like the bank being robbed and your deposits being cut, and perhaps a debtors prison where you serve time if you can't pay interest after 8 weeks or something.  (In my mod you lost more renown, as well as weapon proficiencies over time, so spending time in prison would not be good). 
 
if you want it to be more money-lender type, make it 100% per week, or tie the base interest into the wealth level of the town - if the town is rich, you get a better interest rate, if town poor then a gradually increasing interest rate. maw
 
Here's a script I made to reduce the player's weapon proficiencies each week, so if you sit around not practising for too long, you lose your skill at arms.  In this code:
If your proficiency is greater than 125, then you lose 2 points for every 25 more than 125 that you have.  So if you have 150, you lose 2 points, if you have 400 you lose 12 points.  This works in 1.010.
Code:
  # Reduce proficiencies slightly every week
  (7 * 24,
   [
       (store_proficiency_level,":wp_prof_one_handed_weapon","trp_player",wpt_one_handed_weapon),
       (store_proficiency_level,":wp_prof_two_handed_weapon","trp_player",wpt_two_handed_weapon),
       (store_proficiency_level,":wp_prof_polearm","trp_player",wpt_polearm),
       (store_proficiency_level,":wp_prof_archery","trp_player",wpt_archery),
       (store_proficiency_level,":wp_prof_crossbow","trp_player",wpt_crossbow),
       (store_proficiency_level,":wp_prof_throwing","trp_player",wpt_throwing),

       (try_begin),
        (ge, ":wp_prof_one_handed_weapon", 125),
        (val_sub, ":wp_prof_one_handed_weapon", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_one_handed_weapon", 25),
        (val_sub, ":wp_prof_one_handed_weapon", ":wp_prof_decrease"),
        (val_add, ":wp_prof_one_handed_weapon", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, ":wp_prof_one_handed_weapon"),
       (try_end),
       (try_begin),
        (ge, ":wp_prof_two_handed_weapon", 125),
        (val_sub, ":wp_prof_two_handed_weapon", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_two_handed_weapon", 25),
        (val_sub, ":wp_prof_two_handed_weapon", ":wp_prof_decrease"),
        (val_add, ":wp_prof_two_handed_weapon", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, ":wp_prof_two_handed_weapon"),
       (try_end),
       (try_begin),
        (ge, ":wp_prof_polearm", 125),
        (val_sub, ":wp_prof_polearm", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_polearm", 25),
        (val_sub, ":wp_prof_polearm", ":wp_prof_decrease"),
        (val_add, ":wp_prof_polearm", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_polearm, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_polearm, ":wp_prof_polearm"),
       (try_end),
       (try_begin),
        (ge, ":wp_prof_archery", 125),
        (val_sub, ":wp_prof_archery", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_archery", 25),
        (val_sub, ":wp_prof_archery", ":wp_prof_decrease"),
        (val_add, ":wp_prof_archery", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_archery, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_archery, ":wp_prof_archery"),
       (try_end),
       (try_begin),
        (ge, ":wp_prof_crossbow", 125),
        (val_sub, ":wp_prof_crossbow", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_crossbow", 25),
        (val_sub, ":wp_prof_crossbow", ":wp_prof_decrease"),
        (val_add, ":wp_prof_crossbow", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_crossbow, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_crossbow, ":wp_prof_crossbow"),
       (try_end),
       (try_begin),
        (ge, ":wp_prof_throwing", 125),
        (val_sub, ":wp_prof_throwing", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_throwing", 25),
        (val_sub, ":wp_prof_throwing", ":wp_prof_decrease"),
        (val_add, ":wp_prof_throwing", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_throwing, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_throwing, ":wp_prof_throwing"),
       (try_end),
    ])
 
if you want it to be more money-lender type, make it 100% per week

100% per week is crazy, but any interest is going to be crazy given that native is geared towards the player becoming unreasonably wealthy.
 
I think he meant paying 100% interest per week on loans the player took out.  That's a bit much, especially as I've given no way to abandon your debt.  If you went broke it'd be the end of the game as any money you'd get would go to paying interest, and unpaid interest is added to your debt.  Taking a loan early on the buy some equipment will probably be useful.

I made a lot of improvements on the bank script though, there is now a different bank in each capital so your money is specifically stored there, and stuff like that.
 
so make it a month, instead of a week. you're an adventurer - they die like flies in calradia - and how many scoot off to live in far-off no-place ville under an assumed name?

which may give rise to a cool mission - Gilbert the Moneylender asks you to collect a debt... maybe remind the customer to not be late... in a memorable way...

might be better to have the local merchant outfit you, for a cut of goods brought in until the debt, doubled, is paid. he lends 5,000 you gotta bring in 10,000 in goods for him, or pay 10k in cash. reasonable? maw
 
Garnier said:
Bla, bla, bla..

Impressive! :shock:


Altgouh:

I get this when i build it:

Initializing...
Compiling all global variables...
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
Exporting tableau materials data...
Exporting presentations...
Exporting party_template data...
Exporting parties
Exporting quest data...
Exporting scripts...
Traceback (most recent call last):
  File "process_scripts.py", line 35, in <module>
    save_python_header()
  File "process_scripts.py", line 29, in save_python_header
    file.write("script_%s = %d\n"%(convert_to_identifier(scripts[i_script][0]),i
_script))
  File "C:\Program Files\Mount&Blade\1.010\Modules\WIP Bushido\Module System Bus
hido\process_common.py", line 5, in convert_to_identifier
    s1 = string.replace(s0," ","_")
  File "C:\Python25\lib\string.py", line 517, in replace
    return s.replace(old, new, maxsplit)
AttributeError: 'int' object has no attribute 'replace'

Exporting mission_template data...
Exporting game menus data...
exporting simple triggers...
exporting triggers...
exporting dialogs...
Checking global variable usages...
WARNING: Global variable never used: qst_bring_back_runaway_serfs_num_parties_fl
eed
WARNING: Global variable never used: qst_follow_spy_run_away
WARNING: Global variable never used: qst_follow_spy_meeting_counter
WARNING: Global variable never used: qst_follow_spy_spy_back_in_town
WARNING: Global variable never used: qst_follow_spy_partner_back_in_town
WARNING: Global variable never used: npc_with_personality_match
WARNING: Global variable never used: g_player_banner_granted
WARNING: Global variable never used: merchant_quest_last_offerer
WARNING: Global variable never used: thanked_by_ally_leader
WARNING: Global variable never used: last_defeated_hero
WARNING: Global variable never used: last_freed_hero
WARNING: Global variable never used: capture_screen_shown
WARNING: Global variable never used: pin_number
WARNING: Global variable never used: loot_screen_shown
WARNING: Global variable never used: cant_talk_to_enemy
WARNING: Global variable never used: g_battle_simulation_auto_enter_town_after_b
attle
WARNING: Global variable never used: g_tournament_last_bet_tier
WARNING: Global variable never used: g_training_ground_training_count
WARNING: Global variable never used: temp_3
WARNING: Global variable never used: pin_player_fallen
WARNING: Global variable never used: g_battle_us_ready
WARNING: Global variable never used: g_battle_us_wounded
WARNING: Global variable never used: g_battle_us_dead
WARNING: Global variable never used: g_battle_enemies_ready
WARNING: Global variable never used: g_battle_enemies_wounded
WARNING: Global variable never used: g_battle_enemies_dead
WARNING: Global variable never used: g_battle_allies_ready
WARNING: Global variable never used: g_battle_allies_wounded
WARNING: Global variable never used: g_battle_allies_dead
WARNING: Global variable never used: g_election_date
WARNING: Global variable never used: g_player_party_icon
WARNING: Global variable never used: g_training_ground_ranged_distance
WARNING: Global variable never used: g_player_party_morale_modifier_party_size
WARNING: Global variable never used: g_player_party_morale_modifier_leadership
WARNING: Global variable never used: g_player_party_morale_modifier_no_food
WARNING: Global variable never used: spy_quest_troop
WARNING: Global variable never used: g_ransom_offer_party
WARNING: Global variable never used: g_cur_week_half_daily_wage_payments
Finner ikke C:\Program Files\Mount&Blade\1.010\Modules\WIP Bushido\Module System
Bushido\*.pyc

______________________________

Script processing has ended.
Press any key to exit. . .

End of scripts.py:
  # Reduce proficiencies slightly every week (Tag: Thymo) - Scriptcredit:
  (7 * 24,
  [
      (store_proficiency_level,":wp_prof_one_handed_weapon","trp_player",wpt_one_handed_weapon),
      (store_proficiency_level,":wp_prof_two_handed_weapon","trp_player",wpt_two_handed_weapon),
      (store_proficiency_level,":wp_prof_polearm","trp_player",wpt_polearm),
      (store_proficiency_level,":wp_prof_archery","trp_player",wpt_archery),
      (store_proficiency_level,":wp_prof_crossbow","trp_player",wpt_crossbow),
      (store_proficiency_level,":wp_prof_throwing","trp_player",wpt_throwing),

      (try_begin),
        (ge, ":wp_prof_one_handed_weapon", 125),
        (val_sub, ":wp_prof_one_handed_weapon", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_one_handed_weapon", 25),
        (val_sub, ":wp_prof_one_handed_weapon", ":wp_prof_decrease"),
        (val_add, ":wp_prof_one_handed_weapon", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, ":wp_prof_one_handed_weapon"),
      (try_end),
      (try_begin),
        (ge, ":wp_prof_two_handed_weapon", 125),
        (val_sub, ":wp_prof_two_handed_weapon", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_two_handed_weapon", 25),
        (val_sub, ":wp_prof_two_handed_weapon", ":wp_prof_decrease"),
        (val_add, ":wp_prof_two_handed_weapon", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, ":wp_prof_two_handed_weapon"),
      (try_end),
      (try_begin),
        (ge, ":wp_prof_polearm", 125),
        (val_sub, ":wp_prof_polearm", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_polearm", 25),
        (val_sub, ":wp_prof_polearm", ":wp_prof_decrease"),
        (val_add, ":wp_prof_polearm", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_polearm, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_polearm, ":wp_prof_polearm"),
      (try_end),
      (try_begin),
        (ge, ":wp_prof_archery", 125),
        (val_sub, ":wp_prof_archery", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_archery", 25),
        (val_sub, ":wp_prof_archery", ":wp_prof_decrease"),
        (val_add, ":wp_prof_archery", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_archery, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_archery, ":wp_prof_archery"),
      (try_end),
      (try_begin),
        (ge, ":wp_prof_crossbow", 125),
        (val_sub, ":wp_prof_crossbow", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_crossbow", 25),
        (val_sub, ":wp_prof_crossbow", ":wp_prof_decrease"),
        (val_add, ":wp_prof_crossbow", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_crossbow, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_crossbow, ":wp_prof_crossbow"),
      (try_end),
      (try_begin),
        (ge, ":wp_prof_throwing", 125),
        (val_sub, ":wp_prof_throwing", 100),
        (store_div, ":wp_prof_decrease", ":wp_prof_throwing", 25),
        (val_sub, ":wp_prof_throwing", ":wp_prof_decrease"),
        (val_add, ":wp_prof_throwing", 100),
        (troop_raise_proficiency_linear, "trp_player", wpt_throwing, -10000),
        (troop_raise_proficiency_linear, "trp_player", wpt_throwing, ":wp_prof_throwing"),
      (try_end),
    ])

]

I'm not familiar with scripts of this caliber (hehe) so, if possible, could you maybe brief me about what's wrong?


Edit: Thanks! :wink:


~ Thymo
 
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).
 
Large arrays 

Here are a little crazy thing I made based on fujiwara's arrays idea.
I was going to handle array with above 1,5K+ elements. Don't ask why :smile:  Now I'm sure 400 is enough, but still use the same code.

Additional party for dynamic arrays creating.
Code:
  ('array','array',pf_disabled,0,fac_neutral,0,[]),

Scripts for handing.
Code:
  # script_init_array
  # Input: 
  #arg1=length, 
  #arg2=array
  # Output: none
  ("init_array",
    [
      (store_script_param, ":length", 1),
      (store_script_param, ":array", 2),
      (try_begin),
      	(troop_slot_eq,":array",0,0),#if not zero means array already been inited, to avoid memory leak.
	(store_div,":num_of_box",":length",256),
	(try_begin),
		(store_mod,reg0,":length",256),
		(neq,reg0,0),
		(val_add,":num_of_box",1),
	(try_end),
	(troop_set_slot,":array",0,":length"),
	(try_for_range,":i",0,":num_of_box"),		 
        	(store_random_in_range,reg1,"p_zendar","p_village_90"),
       		(set_spawn_radius,20),
       		(spawn_around_party,reg1,'pt_array'),       
		(store_add,":i_s",":i",1),
	(try_end),
      (try_end),

      ]), 
Usage (call_script,"script_init_array",":length","trp_array"),
init_array creates new array with arbitrary ":length" and  control varible "trp_array".
I am in need of very limited number of such arrays, so I use troops as control variable. But i can be changed to dynamic fujiwara's parties arrays.

Code:
              
  # script_array_set
  # Input: 
  #  arg1=array
  #  arg2=index
  #  arg3=value
  # Output: none
  ("array_set",
    [
      (store_script_param, ":array", 1),
      (store_script_param, ":index", 2),
      (store_script_param, ":value", 3),
      (store_div,":box",":index",256),
      (val_add,":box",1),#cause 0 is rezerved for array size
      (val_mod,":index",256),      	
      (troop_get_slot,reg0,":array",":box"),       		
      (party_set_slot,reg0,":index",":value"),       		

      ]), 
 
Usage (call_script,"script_array_set","trp_array",":index",":value"),
array_set puts value ":value" into ":index" position of "trp_array" (trp_array[index]=value).

Code:
                    
  # script_array_set
  # Input: 
  #  arg1=array  
  #  arg2=index
  # Output: 
  #  reg0=value
  ("array_get",
    [
      (store_script_param, ":array", 1),
      (store_script_param, ":index", 2),      
      (store_div,":box",":index",256),
      (val_add,":box",1),#cause 0 is rezerved for array size
      (val_mod,":index",256),      	
      (troop_get_slot,reg0,":array",":box"),       		
      (party_get_slot,reg0,reg0,":index"),       		

      ]),  	         
Usage (call_script,"script_array_set","trp_array",":index"),
array_get retrives value from ":index" position of "trp_array" and return it in reg0 (reg0=trp_array[index]).
 
Hi.

Here is a very simple way to add voices for player commands during the battles. It's simplified version of my voice_orders scripts (this version is not supporting toggable commands. Full version is working fine, but it's a little "messy" and I have to clear it before releasing). Here you go:

First you'll need the proper files for group selection and orders. I asume you have such files. Put them im "Sounds" folder of your mod, make sure you have "scan_module_sounds = 1" in your module.ini, and the you can move to adding the files to module_sounds:

Code:
#-------daedalus' voice orders start
#group selection
("order_everyone", sf_priority_10|sf_vol_10, ["order_everyone.ogg"]),
("order_infantry", sf_priority_10|sf_vol_10, ["order_infantry.ogg"]),
("order_archers", sf_priority_10|sf_vol_10, ["order_archers.ogg"]),
("order_cavalry", sf_priority_10|sf_vol_10, ["order_cavalry.ogg"]),
("order_others", sf_priority_10|sf_vol_10, ["order_others.ogg"]),
#orders
("order_hold_pos", sf_priority_10|sf_vol_10, ["order_hold_pos.ogg"]),
("order_follow", sf_priority_10|sf_vol_10, ["order_follow.ogg"]),
("order_charge", sf_priority_10|sf_vol_10, ["order_charge.ogg"]),
("order_dismount", sf_priority_10|sf_vol_10, ["order_dismount.ogg"]),
("order_advance", sf_priority_10|sf_vol_10, ["order_advance.ogg"]),
("order_fall_back", sf_priority_10|sf_vol_10, ["order_fall_back.ogg"]),
("order_stand_closer", sf_priority_10|sf_vol_10, ["order_stand_closer.ogg"]),
("order_spread_out", sf_priority_10|sf_vol_10, ["order_spread_out.ogg"]),
("order_hold_fire_toggle", sf_priority_10|sf_vol_10, ["order_hold_fire_toggle.ogg"]),
("order_blunt_toggle", sf_priority_10|sf_vol_10, ["order_blunt_toggle.ogg"]),
#--------daedalus' voice orders end

Change bolded to the real names of your sound files.

Now move to mission_templates and add this somewhere at the begining:

Code:
#-------daedalus' voice orders start
voice_orders = (
   0, 0, 0, [(this_or_next|game_key_clicked, gk_infantry_hear),
           (this_or_next|game_key_clicked, gk_archers_hear),
           (this_or_next|game_key_clicked, gk_cavalry_hear),
           (this_or_next|game_key_clicked, gk_everyone_hear),
           (this_or_next|game_key_clicked, gk_reverse_order_group),
       (this_or_next|game_key_clicked, gk_order_halt),
           (this_or_next|game_key_clicked, gk_order_follow),
           (this_or_next|game_key_clicked, gk_order_charge),
           (this_or_next|game_key_clicked, gk_order_dismount),
           (this_or_next|game_key_clicked, gk_order_advance),
           (this_or_next|game_key_clicked, gk_order_fall_back),
           (this_or_next|game_key_clicked, gk_order_stand_closer),
           (this_or_next|game_key_clicked, gk_order_spread_out),
           (this_or_next|game_key_clicked, gk_order_hold_fire_toggle),
           (game_key_clicked, gk_order_blunt_weapons_toggle),
           ],
   [(get_player_agent_no, ":player"),
                (try_begin),
#group selection starts here------------------------------------------   
          (game_key_clicked, gk_infantry_hear),
          (agent_play_sound, ":player", "snd_order_infantry"),
        (else_try),
          (game_key_clicked, gk_archers_hear),
          (agent_play_sound, ":player", "snd_order_archers"),
        (else_try),   
          (game_key_clicked, gk_cavalry_hear),
          (agent_play_sound, ":player", "snd_order_cavalry"),
        (else_try),
          (game_key_clicked, gk_everyone_hear),
          (agent_play_sound, ":player", "snd_order_everyone"),
        (else_try),
          (game_key_clicked, gk_reverse_order_group),
          (agent_play_sound, ":player", "snd_order_others"),
#orders starts here------------------------------------------       
        (else_try),
          (game_key_clicked, gk_order_halt),
          (agent_play_sound, ":player", "snd_order_hold_pos"),
        (else_try),
          (game_key_clicked, gk_order_follow),
          (agent_play_sound, ":player", "snd_order_follow"),
        (else_try),
          (game_key_clicked, gk_order_charge),
          (agent_play_sound, ":player", "snd_order_charge"),
        (else_try),
          (game_key_clicked, gk_order_dismount),
          (agent_play_sound, ":player", "snd_order_dismount"),
        (else_try),
          (game_key_clicked, gk_order_advance),
          (agent_play_sound, ":player", "snd_order_advance"),
        (else_try),
          (game_key_clicked, gk_order_fall_back),
          (agent_play_sound, ":player", "snd_order_fall_back"),
        (else_try),
          (game_key_clicked, gk_order_stand_closer),
          (agent_play_sound, ":player", "snd_order_stand_closer"),
        (else_try),
          (game_key_clicked, gk_order_spread_out),
          (agent_play_sound, ":player", "snd_order_spread_out"),
        (else_try),
          (game_key_clicked, gk_order_hold_fire_toggle),
          (agent_play_sound, ":player", "snd_order_hold_fire_toggle"),
        (else_try),
          (game_key_clicked, gk_order_blunt_weapons_toggle),
          (agent_play_sound, ":player", "snd_order_blunt_toggle"),
        (try_end),
])
#------daedalus' voice orders end

Then, in every mission template, that you wish to hear the voices, add this:
Code:
voice_orders,

Save changes, compile module, run the game and "Chaaaaaaargeeee!!!" the enemies. :grin:

Have fun shouting at your men, :wink:
Daedalus

PS. You may want to add player gender check, so that females won't be screaming orders for troops with male voice. :razz: I ripped the trigger of any other additional variables to make it as clear as possible, so even beginner modders could use (and understand) the code.
 
Is Chel still around?

I was wondering if you have a posting for your morale script?  I love that one.  wanted to see it and see if it is possible to add Renown bonuses per battle based on how many units you personally kill.  It would be even better if the bonus was based on the level of difficulty the game is set to...
 
Slawomir of Aaarrghh said:
Hi.

Here is a very simple way to add voices for player commands during the battles. It's simplified version of my voice_orders scripts (this version is not supporting toggable commands. Full version is working fine, but it's a little "messy" and I have to clear it before releasing). Here you go:

First you'll need the proper files for group selection and orders. I asume you have such files. Put them im "Sounds" folder of your mod, make sure you have "scan_module_sounds = 1" in your module.ini, and the you can move to adding the files to module_sounds:

#-------daedalus' voice orders start
#group selection
("order_everyone", sf_priority_10|sf_vol_10, ["order_everyone.ogg"]),
("order_infantry", sf_priority_10|sf_vol_10, ["order_infantry.ogg"]),
("order_archers", sf_priority_10|sf_vol_10, ["order_archers.ogg"]),
("order_cavalry", sf_priority_10|sf_vol_10, ["order_cavalry.ogg"]),
("order_others", sf_priority_10|sf_vol_10, ["order_others.ogg"]),
#orders
("order_hold_pos", sf_priority_10|sf_vol_10, ["order_hold_pos.ogg"]),
("order_follow", sf_priority_10|sf_vol_10, ["order_follow.ogg"]),
("order_charge", sf_priority_10|sf_vol_10, ["order_charge.ogg"]),
("order_dismount", sf_priority_10|sf_vol_10, ["order_dismount.ogg"]),
("order_advance", sf_priority_10|sf_vol_10, ["order_advance.ogg"]),
("order_fall_back", sf_priority_10|sf_vol_10, ["order_fall_back.ogg"]),
("order_stand_closer", sf_priority_10|sf_vol_10, ["order_stand_closer.ogg"]),
("order_spread_out", sf_priority_10|sf_vol_10, ["order_spread_out.ogg"]),
("order_hold_fire_toggle", sf_priority_10|sf_vol_10, ["order_hold_fire_toggle.ogg"]),
("order_blunt_toggle", sf_priority_10|sf_vol_10, ["order_blunt_toggle.ogg"]),
#--------daedalus' voice orders end

Change bolded to the real names of your sound files.

Now move to mission_templates and add this somewhere at the begining:

#-------daedalus' voice orders start
voice_orders = (
  0, 0, 0, [(this_or_next|game_key_clicked, gk_infantry_hear),
          (this_or_next|game_key_clicked, gk_archers_hear),
          (this_or_next|game_key_clicked, gk_cavalry_hear),
          (this_or_next|game_key_clicked, gk_everyone_hear),
          (this_or_next|game_key_clicked, gk_reverse_order_group),
  (this_or_next|game_key_clicked, gk_order_halt),
          (this_or_next|game_key_clicked, gk_order_follow),
          (this_or_next|game_key_clicked, gk_order_charge),
          (this_or_next|game_key_clicked, gk_order_dismount),
          (this_or_next|game_key_clicked, gk_order_advance),
          (this_or_next|game_key_clicked, gk_order_fall_back),
          (this_or_next|game_key_clicked, gk_order_stand_closer),
          (this_or_next|game_key_clicked, gk_order_spread_out),
          (this_or_next|game_key_clicked, gk_order_hold_fire_toggle),
          (game_key_clicked, gk_order_blunt_weapons_toggle),
  ],
  [(get_player_agent_no, ":player"),
                (try_begin),
#group selection starts here------------------------------------------
  (game_key_clicked, gk_infantry_hear),
  (agent_play_sound, ":player", "snd_order_infantry"),
(else_try),
  (game_key_clicked, gk_archers_hear),
  (agent_play_sound, ":player", "snd_order_archers"),
(else_try),
  (game_key_clicked, gk_cavalry_hear),
  (agent_play_sound, ":player", "snd_order_cavalry"),
(else_try),
  (game_key_clicked, gk_everyone_hear),
  (agent_play_sound, ":player", "snd_order_everyone"),
(else_try),
  (game_key_clicked, gk_reverse_order_group),
  (agent_play_sound, ":player", "snd_order_others"),
#orders starts here------------------------------------------
(else_try),
  (game_key_clicked, gk_order_halt),
  (agent_play_sound, ":player", "snd_order_hold_pos"),
(else_try),
  (game_key_clicked, gk_order_follow),
  (agent_play_sound, ":player", "snd_order_follow"),
(else_try),
  (game_key_clicked, gk_order_charge),
  (agent_play_sound, ":player", "snd_order_charge"),
(else_try),
  (game_key_clicked, gk_order_dismount),
  (agent_play_sound, ":player", "snd_order_dismount"),
(else_try),
  (game_key_clicked, gk_order_advance),
  (agent_play_sound, ":player", "snd_order_advance"),
(else_try),
  (game_key_clicked, gk_order_fall_back),
  (agent_play_sound, ":player", "snd_order_fall_back"),
(else_try),
  (game_key_clicked, gk_order_stand_closer),
  (agent_play_sound, ":player", "snd_order_stand_closer"),
(else_try),
  (game_key_clicked, gk_order_spread_out),
  (agent_play_sound, ":player", "snd_order_spread_out"),
(else_try),
  (game_key_clicked, gk_order_hold_fire_toggle),
  (agent_play_sound, ":player", "snd_order_hold_fire_toggle"),
(else_try),
  (game_key_clicked, gk_order_blunt_weapons_toggle),
  (agent_play_sound, ":player", "snd_order_blunt_toggle"),
(try_end),
])
#------daedalus' voice orders end

Then, in every mission template, that you wish to hear the voices, add this:
voice_orders,

Save changes, compile module, run the game and "Chaaaaaaargeeee!!!" the enemies. :grin:

Have fun shouting at your men, :wink:
Daedalus

PS. You may want to add player gender check, so that females won't be screaming orders for troops with male voice. :razz: I ripped the trigger of any other additional variables to make it as clear as possible, so even beginner modders could use (and understand) the code.


DID IT! RESULT = NOTHING

ok... summary...
you meant this files:

module_mission_template.py
module_sounds.txt

or??


 
Back
Top Bottom