Author Topic: PYTHON SCRIPT/SCHEME EXCHANGE  (Read 286626 times)

0 Members and 1 Guest are viewing this topic.

Big Bad Pent

  • Baron
  • *
    • View Profile
  • Faction: Vaegir
  • M&BWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #345 on: January 25, 2009, 04:06:02 PM »
Garnier, if I changed the 2nd player_kingdom to player_faction would I be able to give the player a castle without them belonging to a faction?
Also, does anyone know where I can find Mirathies formation script on it's own? He posted it in the formations + morale thread but that one doesn't seem to work on v.1
Hit me at 40 and there's an 80% chance I'll die.
Hit me at 30 and there's an 80% chance I'll live.
Hit me at 80 and it's clear I shouldn't play on the motorway.

Thank god for hitler.

JohnnyThunder

  • Recruit
  • *
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #346 on: January 27, 2009, 07:34:38 AM »
YAY I finally got registered. Been busily coding away a few different things, and wanted to post everything as a reference for anybody that wanted to look. A lot of the credit goes to Magelord, at least indirectly, for the 83 tweaks thread. I took a lot of those ideas and rendered them .py. Changelog + link to my .py files below. Last note: within the .py files, you can search for these changes by searching for '#ajm' case insensitive no quotes- Every change should have one of those by it.

Add: my first post, so YAY M&B rocks.

Hey raowyn

Thanks for this excelent resource, I was intending to do the same but you'ev just saved me the trouble :)

Now all I have to do is figure out how to get my new player faction troops associated to a village when I capture it, and how to set up the player faction so it has the troops assigned and I'll be golden :)

Garnier

  • Sergeant
  • *
    • View Profile
    • www.philipmcg.com
  • Faction: Vaegir
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #347 on: January 27, 2009, 03:31:17 PM »
Quote
Garnier, if I changed the 2nd player_kingdom to player_faction would I be able to give the player a castle without them belonging to a faction?
Probably but you'd have to change other things in the script because currently it only works if the player is in a kingdom, because it selects the random castle from the ones in said kingdom. 

FrankElliott

  • Forum Legend
  • *
    • Skype - frankelliott555
    • Steam - frank_tw
    • Twitter - frankelliott_
    • View Profile
  • Faction: Bandit
  • MP nick: Frank
  • M&BWBWF&SNWVC
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #348 on: February 11, 2009, 11:35:30 PM »
PM me if you want all you companions to get along. (or hate each other)

this way you can have all (16) companions. (without making more)
Follow me on the twitters @frankelliott_

Jinnai

  • Sergeant at Arms
  • *
    • View Profile
  • Faction: Khergit
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #349 on: February 19, 2009, 09:28:09 PM »
I dislike getting lots of messages on the forum, so I created a thread with the code.

What this code does is let you create customizable sparring matches.  When you go to a town and talk to the arena master there will be a new option to spar with your troops.  You then get to select how many teams will be fighting (2 to 4) and you are assigned to the first team.  Then you get to choose which troops from your party will fill out the rest of each team with up to 8 people per team.  Once you've selected it all you get thrown into the arena and the battle commences.  No damage is permanent and everyone has their standard gear.  If the player is knocked out, the battle does not end, that way you can watch how the battle goes between the remaining troops.  Hit tab to end the scene.

Found here: http://forums.taleworlds.com/index.php/topic,57741.0.html
Native Expansion - A mod for M&B version 1.010/11

Slawomir of Aaarrghh

  • Grandmaster Knight
  • *
    • YouTube - daedalus1pl
    • View Profile
    • The Deluge
  • Faction: Neutral
  • MP nick: Daedalus
  • WBM&BWF&SVCNW
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #350 on: March 05, 2009, 02:25:30 PM »
Some people asked me to post my scripts for shouting orders on battlefield, but with support for females, so here it is once again:

First you'll need the proper sound 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 add the files to module_sounds. Like here:

(click to show/hide)
I've added 15 (important value! this will be used later in a script!) sound files for males and females.
You can use your own names for the files, it don't have to be "order_follow_male" etc. What is really important here it's a right order (sequence) of the files. Thats because the script below will NOT trigger the sounds by their name, but by their location in module_sounds.py


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

(click to show/hide)

Then, in every mission template, that you wish to hear the voices, add this:
(click to show/hide)

It's easier to search for other triggers like "common_battle_tab_press," and to add "voice_orders," near them. Like - for example - here:
(click to show/hide)
« Last Edit: March 06, 2009, 01:56:13 PM by Slawomir of Aaarrghh »

Lope de Rojas

  • Grandmaster Knight
  • *
  • It's Party time!
    • View Profile
  • Faction: Swadian
  • MP nick: IG_Ctz_Lua
  • M&BWB
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #351 on: March 06, 2009, 01:23:45 PM »
Hi, I noted an error in the last line of module_mission_templates:

Code: [Select]
...
     (else_try),
         (game_key_clicked, gk_order_dismount),
         (val_add, ":command",12),
         (agent_play_sound, ":player", ":command"),
      (else_try),
         (game_key_clicked, gk_order_hold_fire_toggle),
         (val_add, ":command",13),
         (agent_play_sound, ":player", ":command"),
      (else_try),
         (game_key_clicked, gk_order_blunt_weapons_toggle),
         (val_add, ":command",14),
         (agent_play_sound, ":player", ":command"),
   (try_end),
  ]),

the last comma should not be there

For 24 years I've waited to see or hear from Santa Claus and when he finally shows himself you guys **** permanent ban him. :(

timedanze

  • Knight at Arms
  • *
  • Permanently Banned
  • MaranZaaaBoY aT YouR CoMMannNnnD!!
    • View Profile
  • Faction: Swadian
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #352 on: March 06, 2009, 01:26:09 PM »
why?? I did the same... and it worked!?!?!?  :idea:
BEING A MACHINE - KNIGHT OF THE UNIVERSE

Slawomir of Aaarrghh

  • Grandmaster Knight
  • *
    • YouTube - daedalus1pl
    • View Profile
    • The Deluge
  • Faction: Neutral
  • MP nick: Daedalus
  • WBM&BWF&SVCNW
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #353 on: March 06, 2009, 01:59:32 PM »
the last comma should not be there
Yes, you're right. Fixed. Thanks.

KorpiSoturi

  • Recruit
  • *
  • M&B, best game ever!
    • View Profile
  • Faction: Nord
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #354 on: March 08, 2009, 06:16:51 PM »
Chel's Wound/Recovery Scheme (Optimized)

After looking over Chel's excellent script for death/wound/recovery, I've taken the liberty of streamlining and optimizing it.  I removed the player death and charms from the code, so this scheme is only for character wounding.

First, open header_mission_templates.py and add the following to the top:
Code: [Select]
from header_skills import *

Next, open module_mission_templates.py and add the following code to all of the combat related missions and change "(1, 12, ti_once, [(main_hero_fallen)]," to at least 10-12 seconds for those missions.
Code: [Select]
       (0,
2,
ti_once,
[
(main_hero_fallen)
],
[
(display_message,"@You have received a serious blow. The pain is unbearable.")
]
),

(0,
4,
ti_once,
[
(main_hero_fallen)
],
[
(display_message,"@Breathe in...")
]
),

(0,
6,
ti_once,
[
(main_hero_fallen)
],
[
(display_message,"@Breathe out...")
]
),

(0,
8,
ti_once,
[
(main_hero_fallen)
],
[
(display_message,"@You make an effort to take another breath... "),
(store_random_in_range,":wound_chance_roll",1,101),  ## chance
(store_random_in_range,":wound_type_roll",1,101),  ## wound type
(store_skill_level,":skill_ironflesh",skl_ironflesh,"trp_player"),
(store_skill_level,":skill_first_aid",skl_first_aid,"trp_player"),
(store_skill_level,":skill_wound_treatment",skl_wound_treatment,"trp_player"),
(store_skill_level,":skill_surgery",skl_surgery,"trp_player"),
(store_attribute_level,":attrib_charisma","trp_player",ca_charisma),
## bonuses to outcome of knockout
(val_sub,":attrib_charisma",10),
(store_add,":modifier",":attrib_charisma",":skill_ironflesh"),
(val_add,":wound_chance_roll",":modifier"),
## decide outcome
(try_begin),
(is_between,":wound_chance_roll",51,100), # complete recovery, scratches bruises, no wounds
(display_message,"@You will recover from this blow completely."),
(else_try),
(is_between,":wound_chance_roll",26,50), # 26-50 light wound
(store_current_day,":currentday"),
(assign,":healtime",31),
(val_sub,":healtime",":skill_first_aid"),
(val_sub,":healtime",":skill_wound_treatment"),
(val_sub,":healtime",":skill_surgery"),
(store_add,"$heal_day",":currentday",":healtime"),
# wound type
(try_begin),
(is_between,":wound_type_roll",76,100),
(display_message,"@You suffer a deep cut on your arm. (-1 strength)"),
(assign,"$wound_type",1),
(troop_raise_attribute,"trp_player",ca_strength,-1),
(else_try),
(is_between,":wound_type_roll",51,75),
(display_message,"@You suffer a nasty cut on your torso. (-1 strength, -1 agility)"),
(assign,"$wound_type",2),
(troop_raise_attribute,"trp_player",ca_strength,-1),
(troop_raise_attribute,"trp_player",ca_agility,-1),
(else_try),
(is_between,":wound_type_roll",26,50),
(display_message,"@You suffer a blow to the head. (-1 intelligence)"),
(assign,"$wound_type",3),
(troop_raise_attribute,"trp_player",ca_intelligence,-1),
(else_try),
(display_message,"@You suffer a severe blow to your leg. (-1 agility)"),
(assign,"$wound_type",4),
(troop_raise_attribute,"trp_player",ca_agility,-1),
(try_end),
(else_try),
(is_between,":wound_chance_roll",0,25), ## 0-25 serious wound
(store_current_day,":currentday"),
(assign,":healtime",31),
(val_sub,":healtime",":skill_first_aid"),
(val_sub,":healtime",":skill_wound_treatment"),
(val_sub,":healtime",":skill_surgery"),
(store_add,"$heal_day",":currentday",":healtime"),
(try_begin),
(is_between,":wound_type_roll",76,100),
(display_message,"@You suffer a broken arm. (-3 strength, -1 power strike, -1 power draw)"),
(assign,"$wound_type",5),
(troop_raise_attribute,"trp_player",ca_strength,-3),
(troop_raise_skill, "trp_player",skl_power_strike,-1),
(troop_raise_skill, "trp_player",skl_power_draw,-1),
(else_try),
(is_between,":wound_type_roll",51,75),
(display_message,"@You suffer a broken rib. (-2 strength, -2 agility, -1 ironflesh)"),
(assign,"$wound_type",6),
(troop_raise_attribute,"trp_player",ca_strength,-2),
(troop_raise_attribute,"trp_player",ca_agility,-2),
(troop_raise_skill, "trp_player",skl_ironflesh,-1),
(else_try),
(is_between,":wound_type_roll",26,50),
(display_message,"@You suffer a heavy blow to the head. (-2 intelligence, -1 leadership, -1 tactics)"),
(assign,"$wound_type",7),
(troop_raise_attribute,"trp_player",ca_intelligence,-2),
(troop_raise_skill, "trp_player",skl_leadership,-1),
(troop_raise_skill, "trp_player",skl_tactics,-1),
(else_try),
(display_message,"@You suffer a broken leg. (-3 agility, -1 athletics, -1 riding)"),
(assign,"$wound_type",8),
(troop_raise_attribute,"trp_player",ca_agility,-3),
(troop_raise_skill, "trp_player",skl_riding,-1),
(troop_raise_skill, "trp_player",skl_athletics,-1),
(try_end),
(try_end),
]
),

Next, open module_game_menus.py and add the listed variables to the character gender selection sections:
Code: [Select]
       ("start_game_1",
0,
"Welcome, adventurer, to Mount&Blade. Before you start the game, you must create a character. To begin, select your character's gender.",
"none",
[],
[
("start_male",
[],
"Male",
[
(troop_set_type,"trp_player",0),
(assign,"$character_gender",0),
(assign,"$wound_type",0), # 0-8 (0=not wounded, 1-8=type of wound)
(assign,"$heal_day",0),   # day that wound heals
(jump_to_menu,"mnu_start_game_2")
]
),
("start_female",
[],
"Female",
[
(troop_set_type,"trp_player",1),
(assign,"$character_gender",1),
(assign,"$wound_type",0), # 0-8 (0=not wounded, 1-8=type of wound)
(assign,"$heal_day",0),   # day that wound heals
(jump_to_menu,"mnu_start_game_2")
]
),

Lastly, open module_triggers.py and add the following trigger:
Code: [Select]
       (0.0,
0,
24.0,
[
(store_current_day,":currentday"),
(eq,":currentday","$heal_day")
],
[
(try_begin),
(eq,"$wound_type",1), #Slight - Cut Arm
(display_message,"@Your cut arm finally heals."),
(troop_raise_attribute,"trp_player",ca_strength,1),
(else_try),
(eq,"$wound_type",2), #Slight - Cut Torso
(display_message,"@The cut on your torso finally heals."),
(troop_raise_attribute,"trp_player",ca_strength,1),
(troop_raise_attribute,"trp_player",ca_agility,1),
(else_try),
(eq,"$wound_type",3), #Slight - Blow to Head
(display_message,"@Your thoughts clear."),
(troop_raise_attribute,"trp_player",ca_intelligence,1),
(else_try),
(eq,"$wound_type",4), #Slight - Blow to Leg
(display_message,"@Your leg finally heals."),
(troop_raise_attribute,"trp_player",ca_agility,1),
(else_try),
(eq,"$wound_type",5), #Severe - Broken Arm
(display_message,"@Your broken arm finally heals."),
(troop_raise_attribute,"trp_player",ca_strength,3),
(troop_raise_skill, "trp_player",skl_power_strike,1),
(troop_raise_skill, "trp_player",skl_power_draw,1),
(else_try),
(eq,"$wound_type",6), #Severe - Broken Rib
(display_message,"@Your broken rib finally heals."),
(troop_raise_attribute,"trp_player",ca_strength,2),
(troop_raise_attribute,"trp_player",ca_agility,2),
(troop_raise_skill, "trp_player",skl_ironflesh,1),
(else_try),
(eq,"$wound_type",7), #Severe - Heavy Blow to Head
(display_message,"@Your headache is finally gone."),
(troop_raise_attribute,"trp_player",ca_intelligence,2),
(troop_raise_skill, "trp_player",skl_leadership,1),
(troop_raise_skill, "trp_player",skl_tactics,1),
(else_try),
(eq,"$wound_type",8), #Severe - Broken Leg
(display_message,"@Your broken leg finally heals."),
(troop_raise_attribute,"trp_player",ca_agility,3),
(troop_raise_skill, "trp_player",skl_riding,1),
(troop_raise_skill, "trp_player",skl_athletics,1),
(try_end),
(assign,"$wound_type",0),
(assign,"$heal_day",0)
]
),

These changes should help a bit with memory consumption and should make the scheme a bit more human-readable...


NC

Could somebody tell how to make this work in the recent version (1.011) of Mount&Blade?

MartinF

  • Squire
  • *
  • Down Under
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #355 on: March 08, 2009, 06:25:58 PM »
have you tried it? looks pretty good still... can't find any whacky commands or anything

I might change and move the trigger into simple triggers since it doesn't really need the sophisticated tuple format, but that shouldn't change much in the way it works.

As long as you follow what he says about the normal (main_hero_fallen) trigger, it should work just fine.


KorpiSoturi

  • Recruit
  • *
  • M&B, best game ever!
    • View Profile
  • Faction: Nord
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #356 on: March 08, 2009, 06:45:26 PM »
If it should work, then I've done something badly wrong... :(

Thing is that I'm not very good a modder, and things that I can do are mainly focused on module_items and module_troops.

So could somebody please give me exact instructions what to do in each section of Chel's Wound/Recovery Scheme?

MartinF

  • Squire
  • *
  • Down Under
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #357 on: March 08, 2009, 07:18:49 PM »
well I haven't tried it so I don't know, but it looks like it might work.. can't see much wrong with it tbh..

The instructions are pretty decent as is.. put the extra global variable in the game menu for both of the starting sexes, put the trigger in the module_triggers and put the mission template trigger (the one with (main_hero_fallen) stuff ) into every template in mission_templates that you want to use this trigger in. For now, just put it in lead_charge, since that's the one you'll use most.


Then make sure you change the delay on the current (main_hero_fallen) trigger to at least twelve seconds. Right now it's at four:

(click to show/hide)

So change that 4 to a 12 otherwise it'll drop you out of the mission before the trigger has a chance to do anything.

Also, at the top of the mission_templates file, add the 'from header_skills include' thing



KorpiSoturi

  • Recruit
  • *
  • M&B, best game ever!
    • View Profile
  • Faction: Nord
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #358 on: March 08, 2009, 08:18:31 PM »
I always get a SyntaxError when I try to put the extra global variable in the game menu. I don't get what's wrong with it?!

MartinF

  • Squire
  • *
  • Down Under
    • View Profile
  • Faction: Neutral
Re: PYTHON SCRIPT/SCHEME EXCHANGE
« Reply #359 on: March 08, 2009, 08:26:55 PM »
shouldn't be a problem.. obviously the menu looks a bit different now but it's still a menu.

You could always do this. Add a simple_trigger:

(1, [

(eq, $g_wounds_init, 0),
(assign,"$wound_type",0), # 0-8 (0=not wounded, 1-8=type of wound)
(assign,"$heal_day",0),   # day that wound heals
(assign, "$g_wounds_init", 1),
(display_message, "@initialized wound globals"), #for testing
]),

That will trigger once only and set the global vars properly. A cleaner way would be to do it in script "game_start", right at the top of the script file, or you could make a normal trigger that fires only once.

But for testing it now, this would be an easy way to do it.

Most globals now use the format $g_variable_name but as long as the dollar sign is there it should work.. the name doesn't really matter, at least I don't think so