PYTHON SCRIPT/SCHEME EXCHANGE

spiritwind

Squire
M&BWB
Best answers
0
Does anyone have the script for automatic weapons.  I know a mod had a gatlin gun, or minigun but no1 seems to know the script that was used...
Also, if there are any python coders out there looking for the mod then please look into the fallout mod!  We greatly need an advanced coder.
If you are interested in joining please contact me.
Our pages are here, http://www.moddb.com/mods/fallout
http://forums.taleworlds.com/index.php/topic,37788.0.html
----
Sorry, not trying to use this as a recruitment page, I really need the script for automatic firing weapons!
 

Garnier

Sergeant
Best answers
0
I made this for my mod, the script picks a random castle from the list of castles belonging to the player's faction.  I use it at the start of the game when the player chooses to start as a lord.
Code:
	# script_choose_starting_castle
	# Called at the beginning if the player chose to be a lord.  This script choses a random castle from the faction the player chose.
  ("choose_starting_castle",
    [
	(assign, ":random_castle_found", 1),
	(try_for_range, ":unused", 0, 40),
	(try_begin),
		(eq, ":random_castle_found",1),
		(store_random_in_range,":center_no",castles_begin,castles_end),
		(store_faction_of_party, ":center_faction", ":center_no"),
		(try_begin),
			(eq, ":center_faction", "$players_kingdom"),
			(assign, "$g_center_to_give_to_player", ":center_no"),
			(assign, ":random_castle_found", 0),
		(try_end),
	(try_end),

	(try_begin), # if it didn't find one, pick the first one this time.
		(eq, ":random_castle_found", 1),
		(try_for_range, ":center_no", castles_begin, castles_end),
			(store_faction_of_party, ":center_faction", ":center_no"),
			(try_begin),
				(eq, ":random_castle_found", 1),
				(eq, ":center_faction", "$players_kingdom"),
				(assign, "$g_center_to_give_to_player", ":center_no"),
				(assign, ":random_castle_found", 0),
			(try_end),
		(try_end),
	(try_end),
	]),
This is what you can use to give the castle to the player:
Code:
        (call_script,"choose_random_castle_for_player"),
        (jump_to_menu,"mnu_give_center_to_player"),
Note the script only works if the player has joined a faction.
 

Amman d Stazia

Master Knight
Best answers
0
jik said:
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...
I think Highlander used this script in Age of Machinery, so he might have the answers for you, jik.
 

Garnier

Sergeant
Best answers
0
Simple Trigger to normalize the player's relations with lords and towns, as well as the player's honor.


What it does:
Each day, there is a separate chance that each of these things (town relations, lord relations and honor) will try to normalize themselves, in other words go toward zero.  For example, say the chance succeeds for honor normalization.  If you have positive honor then your honor is the percent chance that it will drop by one.  So if you have 20 honor, there's a 20% chance that you will lose one.  And on the flip side if you have -20 honor, there is a 20% chance that you will gain one.

The code is in the spoiler;
This is the simple_trigger:
Code:
	  # Normalizations
  (24,
   [
   (set_show_messages,0), 
		#Normalize honor
		(store_random_in_range, ":random", 0, 100),
		(try_begin),
			(lt, ":random", percent_normalization_honor),
			(assign, ":honor", "$player_honor"),
			(try_begin),
				(lt, ":honor", 0),
				(val_mul, ":honor", -1),
				(val_min,":honor",100),
				(store_random_in_range,":random",0,100),
				(try_begin),
					(lt, ":random", ":honor"),
					(call_script, "script_change_player_honor",1),
				(try_end),
			(else_try),
				(gt, ":honor", 0),
				(val_min,":honor",100),
				(store_random_in_range,":random",0,100),
				(try_begin),
					(lt, ":random", ":honor"),
					(call_script, "script_change_player_honor",-1),
				(try_end),
			(try_end),
		(try_end),
		
		#Normalize relations with lords
		(store_random_in_range, ":random", 0, 100),
		(try_begin),
			(lt, ":random", percent_normalization_troop_relation),
			(try_for_range, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end),
				(troop_get_slot, ":relation", ":troop_no", slot_troop_player_relation),
				(try_begin),
					(lt, ":relation", 0),
					(val_mul, ":relation", -1),
					(val_min,":relation",100),
					(store_random_in_range,":random",0,100),
					(try_begin),
						(lt, ":random", ":relation"),
						(call_script, "script_change_player_relation_with_troop", ":troop_no", 1),
					(try_end),
				(else_try),
					(gt, ":relation", 0),
					(val_min,":relation",100),
					(store_random_in_range,":random",0,100),
					(try_begin),
						(lt, ":random", ":relation"),
						(call_script, "script_change_player_relation_with_troop", ":troop_no", -1),
					(try_end),
				(try_end),
			(try_end),
		(try_end),

		#Normalize relations with towns
		(store_random_in_range, ":random", 0, 100),
		(try_begin),
			(lt, ":random", percent_normalization_center_relation),
			(try_for_range, ":center_no", towns_begin, towns_end),
				(troop_get_slot, ":relation", ":center_no", slot_center_player_relation),
				(try_begin),
					(lt, ":relation", 0),
					(val_mul, ":relation", -1),
					(val_min,":relation",100),
					(store_random_in_range,":random",0,100),
					(try_begin),
						(lt, ":random", ":relation"),
						(call_script, "script_change_player_relation_with_center", ":troop_no", 1),
					(try_end),
				(else_try),
					(gt, ":relation", 0),
					(val_min,":relation",100),
					(store_random_in_range,":random",0,100),
					(try_begin),
						(lt, ":random", ":relation"),
						(call_script, "script_change_player_relation_with_center", ":troop_no", -1),
					(try_end),
				(try_end),
			(try_end),
		(try_end),
		(set_show_messages,1), 
    ]),
And these are the three constants used, which can be changed easily to balance the normalization.
Code:
#  Percent chance that honor will be normalized each day.  Normalization average = (honor / 100) * 1
percent_normalization_honor = 10
#  Percent chance that relations with lords will be normalized each day.  Normalization average = (relation / 100) * 1
percent_normalization_troop_relation = 10
#  Percent chance that relations with towns will be normalized each day.  Normalization average = (relation / 100) * 1
percent_normalization_center_relation = 10
 

raowyn

Recruit
Best answers
0
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.

----WHOLE NEW BUNCHA HEROS----
------------------------------
generic dialog for em is in module_strings
module_scripts sets their morality n junk and ties each of em to the dialog in strings
troops contains the new hero units
constants has the constant declaration for ajm_companions_begin/end which is used to iterate thru them all
  inside scripts where it sets them all to use the generic dialog
game menus to make em show up in taverns
------------------------------

CONSTANTS
>chance lords escape after being defeated in battle (this seems to affect them being captured by the player or AI's)

DIALOGS
>halved cost of gifts for improving relations with a lord
>>additionally, you can buy gifts to improve your relations up to 100
>relation changes (with NPCs and locations) are much more dramatic; each has been multiplied by 4
>your ranks in persuasion and the days defenders have spent starving affect your chance to persuade town/castle defenders to surrender.
>>each rank of persuasion increases your forces apparent strength by 5% when persuading the defending commander to surrender
>>for each day the defenders spend starving (no food left), your apparent strength goes up by 50% when persuading for surrender

ITEMS
>tripled food units provided by all food to coincide with food changes in food consumption trigger
>increased speed of non-parry weaps, swapped thrust/swing damage of the knife and dagger
>doubled max ammo of arrows/bolts/thrown weaps since nothing under the sun seems to make npc's more accurate

GAME MENUS
>cattle follow instead of flee
>lord will pay out 12,000 if you request a location you've conquered and he awards it to someone else
>allowed hotkey use in the siege menu (so you can look at inventory, party, etc)
>added menu text for defenders surrendering due to starvation (sieged till they ran outta food)
>>currently this isn't actually seen, it just goes straight to the after-battle freed/captured prisoner interface.
>improvement build times (prison tower, mill, etc...) have been drastically reduced
>you collect taxes from ALL your fiefs by visiting any one of them
>siege towers build faster
>SIEGES
>>defenders will try to wait you out for 3 days after they run outta food
>>>after that time, they will surrender
>>>during that time, defenders may sally out in an attempt to break your siege
>>>>they have a chance to sally out once every 12 hours
>>>>the number of troops advantage/disadvantage will make them more/less likely to sally out
>allow player to attack even if relationship is positive
>you can besiege anyone regardless of relationship
>changed menu text to clearly identify recruiting prisoners as being affected by persuasion
>recruiting from villages is now affected by persuasion.
>>each rank of persuasion increases the number of volunteers by 1 (if there are any volunteers to be had), and reduces the denar cost by 1 (taken out of 11 denars base cost)
>each rank of persuasion increases the amount of supplies villagers bring out for you by 3% when you force them to give you supplies
>each rank of looting increases amt of loot you get for raiding villages by 3%
>each rank of looting increases the number of cattle you steal by 1

SCRIPTS
>companions all get along
>renown increases max party size quicker; every 5 morale increases troop cap by +1 (mostly affects player)
>party size has no affect on morale
>being your king's buddy has 10x more affect on him giving you conquered locations
>the one who initiates a siege has a better chance than before of being awarded the conquered location
>player is always in command of all allies on the field, not some dumbass ai lord
>trade skill reduces trade penalty by 7% per skill rank
>repeatable quests from lords, village elders, etc, are repeatable 2x faster
>the max food stores of towns/castles are now randomly determined each 8 hours, from 10-100 percent of the normal max.
>>actually possible now to starve out a place if you show up at a time when their food stores are 'running low'
>Pretty drastically shifted price determination towards the player's favor
>>those previously puny lord ransoms will seem pretty good now cause 2000 denars will actually buy some stuff now
>the troop wages displayed in the party window include the total amt you must pay to everyone, not just units in your party currently
>the level of prisoners is added to 50 to determine how much you get for selling them
>each rank of prisoner mgmt lets you handle 10 prisoners
>you can handle 5 prisoners even w/o ranks in prisoner management
>persuasion affects number of villagers you recruit and commission of recruiting, as noted under GAME MENUS section
>Siege towers should move a lot faster while moving up to the castle/town
>Leadership is A PARTY SKILL... kinda
>>The highest Leadership skill of the party is used to determine max party size, BUT...
>>only your Leadership skill applies to wage reduction, morale, and recruited prisoner desertion chances
>>IMPORTANT NOTE! Leadership now counts wether the companion is wounded or not,
>>>so you don't have to worry about suddenly losing your army cause your charismatic co-leader
>>>got all gung-ho about running their face into a pointy object

TRIGGERS
>armor/weap merchants have x10 avail gold (between 2-4k), goods/horse merchants have x2 avail gold (between 1-2k)

SIMPLE TRIGGERS
>imprisoned lords escape much less often, and the check is only made 1x per week.
>>Prisoner mgmt skill of the player reduces escape chances
>food consumption easier to predict in-game for player party (1 unit eats 1 food each 24 hrs)
>>Every 24 hours, each unit in your party eats 1 food
>schools add +1 to your relationship with the town each week, instead of +1/month (roughly 4x as much)
>bandit spawning is done every 12 hours, instead of 36. Tired of empty maps and hunting eternally for those 'troublesome looters'
>>Looters are guaranteed to be spawned at the quest-center you got the looters quest from, and they will patrol around it
>>>even if they get chased off, they'll return to patrol around the center
>takes less time to plunder & raze a village
>renown does not deteriorate each week
>prisoner management actually reduces escape chances for your captured lords by 2% per rank
>>base escape chances are 30 in party, 15 in castle/town, 5 in prison tower

MISSION TEMPLATES
>HEY, THIS ISN'T CURRENTLY IN RIGHT NOW. in sieges, normal open-ground battles, and village raids, both attackers and defenders get up to 100 waves of reinforcements.
>>basically, this means battles are start to finish without a menu screen in between battles.

SKILLS
>updated some descriptions to be more informative
link to the mod files: http://www.mediafire.com/?sharekey=9b288b7cd06cde857432d3c9683f450ae04e75f6e8ebb871
Zipped with Winrar, though I think pretty much any zip program will open rars these days.
 

pentagathus

Baron
M&BWB
Best answers
0
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
 

JohnnyThunder

Recruit
Best answers
0
raowyn said:
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 :smile:

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 :smile:
 

Garnier

Sergeant
Best answers
0
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. 
 
Best answers
0
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)
 

Jinnai

Sergeant at Arms
Best answers
0
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
 

Slawomir of Aaarrghh

Grandmaster Knight
M&BWBWF&SNWVC
Best answers
0
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:

#male sounds
#group selection
("order_everyone_male", sf_2d|sf_priority_10|sf_vol_10, ["order_everyone_male.ogg"]),
("order_infantry_male", sf_2d|sf_priority_10|sf_vol_10, ["order_infantry_male.ogg"]),
("order_archers_male", sf_2d|sf_priority_10|sf_vol_10, ["order_archers_male.ogg"]),
("order_cavalry_male", sf_2d|sf_priority_10|sf_vol_10, ["order_cavalry_male.ogg"]),
("order_others_male", sf_2d|sf_priority_10|sf_vol_10, ["order_others_male.ogg"]),
#orders
("order_halt_male", sf_2d|sf_priority_10|sf_vol_10, ["order_halt_male.ogg"]),
("order_follow_male", sf_2d|sf_priority_10|sf_vol_10, ["order_follow_male.ogg"]),
("order_charge_male", sf_2d|sf_priority_10|sf_vol_10, ["order_charge_male.ogg"]),
("order_advance_male", sf_2d|sf_priority_10|sf_vol_10, ["order_advance_male.ogg"]),
("order_fall_back_male", sf_2d|sf_priority_10|sf_vol_10, ["order_fall_back_male.ogg"]),
("order_stand_closer_male", sf_2d|sf_priority_10|sf_vol_10, ["order_stand_closer_male.ogg"]),
("order_spread_out_male", sf_2d|sf_priority_10|sf_vol_10, ["order_spread_out_male.ogg"]),
("order_dismount_male", sf_2d|sf_priority_10|sf_vol_10, ["order_dismount_male.ogg"]),
("order_hold_fire_toggle_male", sf_2d|sf_priority_10|sf_vol_10, ["order_hold_fire_male.ogg"]),
("order_blunt_toggle_male", sf_2d|sf_priority_10|sf_vol_10, ["order_blunt_toggle_male.ogg"]),
#female sounds
#group selection
("order_everyone_female", sf_2d|sf_priority_10|sf_vol_10, ["order_everyone_female.ogg"]),
("order_infantry_female", sf_2d|sf_priority_10|sf_vol_10, ["order_infantry_female.ogg"]),
("order_archers_female", sf_2d|sf_priority_10|sf_vol_10, ["order_archers_female.ogg"]),
("order_cavalry_female", sf_2d|sf_priority_10|sf_vol_10, ["order_cavalry_female.ogg"]),
("order_others_female", sf_2d|sf_priority_10|sf_vol_10, ["order_others_female.ogg"]),
#orders
("order_halt_female", sf_2d|sf_priority_10|sf_vol_10, ["order_halt_female.ogg"]),
("order_follow_female", sf_2d|sf_priority_10|sf_vol_10, ["order_follow_female.ogg"]),
("order_charge_female", sf_2d|sf_priority_10|sf_vol_10, ["order_charge_female.ogg"]),
("order_advance_female", sf_2d|sf_priority_10|sf_vol_10, ["order_advance_female.ogg"]),
("order_fall_back_female", sf_2d|sf_priority_10|sf_vol_10, ["order_fall_back_female.ogg"]),
("order_stand_closer_female", sf_2d|sf_priority_10|sf_vol_10, ["order_stand_closer_female.ogg"]),
("order_spread_out_female", sf_2d|sf_priority_10|sf_vol_10, ["order_spread_out_female.ogg"]),
("order_dismount_female", sf_2d|sf_priority_10|sf_vol_10, ["order_dismount_female.ogg"]),
("order_hold_fire_toggle_female", sf_2d|sf_priority_10|sf_vol_10, ["order_hold_fire_female.ogg"]),
("order_blunt_toggle_female", sf_2d|sf_priority_10|sf_vol_10, ["order_blunt_toggle_female.ogg"]),
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:

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"),
(agent_get_troop_id,":player_id", ":player"),
(troop_get_type, ":gender", ":player_id"),
(val_mul, ":gender", 15), #sets to skip 15 sound files if player is female
(assign, ":command", "snd_order_everyone_male"), # here you enter the name of the FIRST sound file you added
(val_add,":command",":gender"), #skips 15 sound files if player is female - comment or delete this line if you added only male voices
#group selection begin here---------------------------------
(try_begin),
(game_key_clicked, gk_everyone_hear),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_infantry_hear),
(val_add, ":command",1),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_archers_hear),
(val_add, ":command",2),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_cavalry_hear),
(val_add, ":command",3),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_reverse_order_group),
(val_add, ":command",4),
(agent_play_sound, ":player", ":command"),
#orders begin here------------------------------------------
(else_try),
(game_key_clicked, gk_order_halt),
(val_add, ":command",5),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_order_follow),
(val_add, ":command",6),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_order_charge),
(val_add, ":command",7),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_order_advance),
(val_add, ":command",:cool:,
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_order_fall_back),
(val_add, ":command",9),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_order_stand_closer),
(val_add, ":command",10),
(agent_play_sound, ":player", ":command"),
(else_try),
(game_key_clicked, gk_order_spread_out),
(val_add, ":command",11),
(agent_play_sound, ":player", ":command"),
(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),
  ])

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

It's easier to search for other triggers like "common_battle_tab_press," and to add "voice_orders," near them. Like - for example - here:
  (
    "lead_charge",mtf_battle_mode,charge,
    "You lead your men to battle.",
    [
     (1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
     (0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
     (4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
     ],
    [
      (ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (call_script, "script_agent_reassign_team", ":agent_no"),
         ]),


  voice_orders,
      common_battle_tab_press,
 
      (ti_question_answered, 0, 0, [],
       [(store_trigger_param_1,":answer"),
        (eq,":answer",0),
        (assign, "$pin_player_fallen", 0),
        (try_begin),
          (store_mission_timer_a, ":elapsed_time"),
          (gt, ":elapsed_time", 20),
          (str_store_string, s5, "str_retreat"),
          (call_script, "script_simulate_retreat", 10, 20),
        (try_end),
        (call_script, "script_count_mission_casualties_from_agents"),
        (finish_mission,0),]),
 

Lope de Rojas

Grandmaster Knight
M&BWB
Best answers
0
Hi, I noted an error in the last line of module_mission_templates:

Code:
...
     (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

 

KorpiSoturi

Recruit
Best answers
0
NCrawler said:
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:
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:
       (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:
       ("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:
       (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
Best answers
0
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
Best answers
0
If it should work, then I've done something badly wrong... :sad:

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
Best answers
0
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:

Code:
     (1, 4, ti_once, [(main_hero_fallen)],
          [
              (assign, "$pin_player_fallen", 1),
              (str_store_string, s5, "str_retreat"),
              (call_script, "script_simulate_retreat", 10, 20),
              (assign, "$g_battle_result", -1),
              (set_mission_result,-1),
              (call_script, "script_count_mission_casualties_from_agents"),
              (finish_mission,0)]),

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
Best answers
0
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
Best answers
0
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