PYTHON SCRIPT/SCHEME EXCHANGE

Users who are viewing this thread

pengbuster said:
Hey, does anyone have an automatic rifle script for crossbows? Like pew pew pew, reload pew pew pew reload. I intend to use this for NW muskets so if it comes pre made with that but if it comes for a crossbow thats fine. Also, I would like for this to be server side so the client doesnt have to download anything. Any help would be appreciated

This isnt request thread...
Additionally, you already received help and ignored it.
 
EmielRegis said:
pengbuster said:
Hey, does anyone have an automatic rifle script for crossbows? Like pew pew pew, reload pew pew pew reload. I intend to use this for NW muskets so if it comes pre made with that but if it comes for a crossbow thats fine. Also, I would like for this to be server side so the client doesnt have to download anything. Any help would be appreciated

This isnt request thread...
Additionally, you already received help and ignored it.
I did and I couldnt find anything
 
pengbuster said:
EmielRegis said:
pengbuster said:
Hey, does anyone have an automatic rifle script for crossbows? Like pew pew pew, reload pew pew pew reload. I intend to use this for NW muskets so if it comes pre made with that but if it comes for a crossbow thats fine. Also, I would like for this to be server side so the client doesnt have to download anything. Any help would be appreciated

This isnt request thread...
Additionally, you already received help and ignored it.
I did and I couldnt find anything

Spamming in unrelated topic wont help you in any way. Read basic tutorials,  and learn how to use module system before asking more specific questions. Dont answer me, its enough offtop here.
 
Hey guys, listen, there are some interesting scripts on PW? I would be very grateful to look at them and try to use
 
Let's say for some reason you need to get the price modifier for item modifiers.  By default it isn't possible as far as I can tell.  This fixes this issue, though it only works as long as you don't modify data\item_modifiers.txt after you compile.  If you do change item_modifiers.txt, just compile your source again and it will update the values automatically.

Place this in module constants
#prater
slot_troop_imod_value_array_0 = 300
#... 300 ... 342
slot_troop_imod_value_array_42 = 342


IMOD_START = slot_troop_imod_value_array_0
#prater

Place this in module_troops (I place my array troops as the very last troops)
["imod_value_array", "{!}imod_value_array","{!}imod_value_array",0,0,0,fac_kingdom_4,
  [], 0,0,0,nord_face_middle_1, nord_face_older_2],

Place this after the comments section in module_scripts but before scripts = [
Replace the c:\program...item_modifiers.txt with the path to the item_modifiers.txt for your mod
#prater
fo = open("ID_IMODS.py", "wb")
fi = open("C:\Program Files (x86)\Steam\steamapps\common\MountBlade Warband\Modules\YOURMOD\Data\item_modifiers.txt", "r")
index = 0
for line in fi:
parts = line.split()
value = parts[2]
value = value.replace("\n", "")
value = float(value) * 100
value = int(value)
fo.write("imod_"+str(index)+"="+str(value)+"\n")
index+=1
fi.close()
fo.close()

from ID_IMODS import *
#prater

Place this in the script game_start
#prater
(call_script, "script_prater_init_imods"),
#prater

Place this somewhere in module scripts
  ("prater_init_imods",
  [
(troop_set_slot, "trp_imod_value_array", 300, imod_0),
(troop_set_slot, "trp_imod_value_array", 301, imod_1),
(troop_set_slot, "trp_imod_value_array", 302, imod_2),
(troop_set_slot, "trp_imod_value_array", 303, imod_3),
(troop_set_slot, "trp_imod_value_array", 304, imod_4),
(troop_set_slot, "trp_imod_value_array", 305, imod_5),
(troop_set_slot, "trp_imod_value_array", 306, imod_6),
(troop_set_slot, "trp_imod_value_array", 307, imod_7),
(troop_set_slot, "trp_imod_value_array", 308, imod_:cool:,
(troop_set_slot, "trp_imod_value_array", 309, imod_9),
(troop_set_slot, "trp_imod_value_array", 310, imod_10),
(troop_set_slot, "trp_imod_value_array", 311, imod_11),
(troop_set_slot, "trp_imod_value_array", 312, imod_12),
(troop_set_slot, "trp_imod_value_array", 313, imod_13),
(troop_set_slot, "trp_imod_value_array", 314, imod_14),
(troop_set_slot, "trp_imod_value_array", 315, imod_15),
(troop_set_slot, "trp_imod_value_array", 316, imod_16),
(troop_set_slot, "trp_imod_value_array", 317, imod_17),
(troop_set_slot, "trp_imod_value_array", 318, imod_1:cool:,
(troop_set_slot, "trp_imod_value_array", 319, imod_19),
(troop_set_slot, "trp_imod_value_array", 320, imod_20),
(troop_set_slot, "trp_imod_value_array", 321, imod_21),
(troop_set_slot, "trp_imod_value_array", 322, imod_22),
(troop_set_slot, "trp_imod_value_array", 323, imod_23),
(troop_set_slot, "trp_imod_value_array", 324, imod_24),
(troop_set_slot, "trp_imod_value_array", 325, imod_25),
(troop_set_slot, "trp_imod_value_array", 326, imod_26),
(troop_set_slot, "trp_imod_value_array", 327, imod_27),
(troop_set_slot, "trp_imod_value_array", 328, imod_2:cool:,
(troop_set_slot, "trp_imod_value_array", 329, imod_29),
(troop_set_slot, "trp_imod_value_array", 330, imod_30),
(troop_set_slot, "trp_imod_value_array", 331, imod_31),
(troop_set_slot, "trp_imod_value_array", 332, imod_32),
(troop_set_slot, "trp_imod_value_array", 333, imod_33),
(troop_set_slot, "trp_imod_value_array", 334, imod_34),
(troop_set_slot, "trp_imod_value_array", 335, imod_35),
(troop_set_slot, "trp_imod_value_array", 336, imod_36),
(troop_set_slot, "trp_imod_value_array", 337, imod_37),
(troop_set_slot, "trp_imod_value_array", 338, imod_3:cool:,
(troop_set_slot, "trp_imod_value_array", 339, imod_39),
(troop_set_slot, "trp_imod_value_array", 340, imod_40),
(troop_set_slot, "trp_imod_value_array", 341, imod_41),
(troop_set_slot, "trp_imod_value_array", 342, imod_42),

  ]),

To use, just do the following:
Code:
#requires ":item_modifier" as input.  See script_game_get_item_extra_text for an example
#requires ":item_no"
#this gets the base value of item_no, then gets the imod modifier value, multiplies the base value by the modifier value, then divides by 100 to get the price of the modified item (such as chipped, bent, balanced, etc).
(store_item_value,reg0,":item_no"),
#if buying or selling, get sell/buy price factor and modify the item base value here.
(store_add, ":imod_slot", ":item_modifier", IMOD_START),
(troop_get_slot, ":imodv", "trp_imod_value_array", ":imod_slot"),
(val_mul, reg0, ":imodv"),
(val_div, reg0, 100),

Why is this useful?  Let's say you replace the money system with something like the Pound sterling and you want to include shilling and pence:  "£{reg1}, {reg2}s, {reg3}d".  Or you want to use a dollar system like the 1866 Western mod does and you want the items to display the correct dollars and cents"${reg1}.{reg2}".  To do this you add a line in script_game_get_item_extra_text, but it shows the incorrect value unless you are looking at a plain item.  Using the above, you can replace the buy price/sell price/value with your own line in game_get_item_extra_text and it will give you the correct value.  Just remember that if item_modifiers.txt is modified after you compile your module (by the player for some reason or you later), it will show the incorrect values until you compile your module again.
 
PERSUADRATON

I wanna contribute with something rather small, but I hope funny. Some of you probably remember pc game Syndicate (oh, there is a newer version too).

So, this item made people to follow your orders. I made an item that makes your enemies on the battlefield your friends.

First you need to create an item, persuadraton. Mine is like that:
in items module paste this:
Code:
["persuadraton", "Necrocorp Persuadraton", [("persuadraton_action",0)], itp_type_one_handed_wpn|itp_primary, itcf_thrust_onehanded|itcf_carry_sword_left_hip, 2000, weight(1)|difficulty(4)|spd_rtng(115)|weapon_length(48)|swing_damage(1,blunt)|thrust_damage(1,blunt), imodbits_sword_high, [(ti_on_weapon_attack,[(play_sound,"snd_persuadraton"),(position_move_x,pos1,27),(position_move_y,pos1,36),(particle_system_burst,"psys_pistol_flare",pos1,6)])] ,[fac_kingdom_2] ],

You should change snd_persuadraton to any sound you have/like in your mod. Also you should find a good mesh for it.

then in mission_templates (above
Code:
 mission_templates
) paste this:

Code:
 #script on attacker persuading defender to change faction during the batlle
common_battle_persuadraton = (
  ti_on_agent_hit, 0, 0, [],
  [
    (store_trigger_param, ":agent_no", 2), #attacker
    (store_trigger_param, ":troop_id", 1), #defender

	
	(try_begin),
	
        (agent_get_wielded_item, ":item_w", ":agent_no", 0),    
        (eq, ":item_w", "itm_persuadraton"), #does attacker wields persuadraton
	
 
  
  (store_skill_level, ":persuasion_defender", "skl_persuasion", ":troop_id"),
  (store_skill_level, ":persuasion_attacker", "skl_persuasion", ":agent_no"),
   
(val_mul, ":persuasion_defender", 4),   
(val_mul, ":persuasion_attacker", 4),
  
 (val_sub, ":persuasion_attacker", ":persuasion_defender"),

 
            (try_begin),
	   	        		
	       (store_random_in_range, ":persuasion_chance", 0, 100),  #randomize chance to persuade and...
	       (ge,":persuasion_attacker", ":persuasion_chance"), 		# check if persuasion skill is greater, then
		
		      (agent_get_team, ":persuaded_faction",":agent_no"),
	          #MOST IMPORTANT: DEFEDER TROOP BECOMES ATTACKER TROOP
	          (agent_set_team, ":troop_id", ":persuaded_faction"),
	          (display_message, "@Attempted pesuasion succesful! Persuaded enemy to join you!"), #debug info
   	   
			(try_end), 
	   
	(try_end),        
  ])

You have to place
Code:
common_battle_persuadraton
at every place you want it to work (for example for every mission that has common_init_banner).

When you equip persuadraton on each hit persuasion of an attacker and a defender will be checked. Multipled by 4.

Then his multiplied persuasion of attacker is substracted by multipled persuasion of defender.

Then there is randomizing 1-100. If random is lower than equasion above the defender will change sides and fight for attackers team.

This also works for all npc, if you make them wield persuadratons.
 
Sailing/Rowing under bridges in Viking Conquest RE (2.032+)

Somehow I assumed that someone would have already done this, considering that most bridges effectively create rivers that you, by default, cannot sail/row past - meaning you have to disembark at the bridge and go the rest of the way on foot (which is usually slower). Which tbh has bugged me since getting VC - I thought one of trademarks of the Vikings was cruising all the way down inland rivers for raiding?

Anyway, the below code snippets (which will probably work with any version from 2.025 onwards) will allow you and any lords following you to sail (or row) under any of the bridges in VC - albeit via a lame insta-teleport after you confirm you want to cross via a triggered menu (I'm open to input on how to improve this btw!).

The first snippet goes into module_simple_triggers.py:

Code:
#SQUID - Hack to sail under bridges to get to other side
     (0.1,
      [
	(try_begin),
          #Check for nearby bridge
          (party_slot_eq, "p_main_party", slot_party_on_water, 1),
          (set_fixed_point_multiplier, 100),
          (assign, ":bridge_in_range", -1),
          (assign, ":end", "p_ferry_1a"),
          (try_for_range, ":cur_party", "p_Bridge_1", ":end"),
            (store_distance_to_party_from_party, ":cur_distance", ":cur_party", "p_main_party"),
            (lt, ":cur_distance", 2),
	    (assign, ":end", ":cur_party"),		#Loop breaker
	    (assign, ":bridge_in_range", ":cur_party"),
          (try_end),
	  (try_begin),		#Account for "extra" bridge
	    (eq, ":bridge_in_range", -1),
	    (store_distance_to_party_from_party, ":cur_distance", "p_Bridge_18", "p_main_party"),
	    (lt, ":cur_distance", 2),
	    (assign, ":bridge_in_range", "p_Bridge_18"),
	  (try_end),
          (gt, ":bridge_in_range", -1),
	  (party_get_position, pos1, ":bridge_in_range"),
	  (party_get_position, pos3, "p_main_party"),
	  (position_get_x, ":bridge_posx", pos1),
	  (position_get_x, ":party_posx", pos3),
	  (store_sub, ":pos_x", ":bridge_posx", ":party_posx"),
	  (val_add, ":pos_x", ":bridge_posx"),
	  (position_get_y, ":bridge_posy", pos1),
	  (position_get_y, ":party_posy", pos3),
	  (store_sub, ":pos_y", ":bridge_posy", ":party_posy"),
	  (val_add, ":pos_y", ":bridge_posy"),
	  (copy_position, pos4, pos3),
	  (position_set_x, pos4, ":pos_x"),
	  (position_set_y, pos4, ":pos_y"),
	  (map_get_water_position_around_position, pos2, pos4, 1),
          (party_set_position, "p_landing_point2", pos2),
       	  (jump_to_menu, "mnu_bridge_travel"),
	(try_end),
    ]),

The second snippet goes into module_game_menus.py:
Code:
#SQUID: Bridge travel
  ("bridge_travel",0,
   "You are at a bridge. Do you want to row under it? {s1} {s2}",
   "none",
   [
     # The below checks to see if lords following you will be OK or left behind,
     # and informs the player of this. Should work whether marshal or not.
     (set_background_mesh, "mesh_pic_fleet"),
      
     (str_clear, s1),
     (str_clear, s2),
     (assign, ":can_join", 0),
     (assign, ":cant_join", 0),
     (try_for_parties, ":cur_party"),
       (party_slot_eq, ":cur_party", slot_party_type, spt_kingdom_hero_party),
       (party_is_active, ":cur_party"),
       (store_faction_of_party, ":cur_party_faction", ":cur_party"),
       (eq, ":cur_party_faction", "$players_kingdom"),
       (get_party_ai_object, ":cur_party_ai_object", ":cur_party"),
       (eq, ":cur_party_ai_object", "p_main_party"),
       (party_slot_eq, ":cur_party", slot_party_on_water, 1),
       (store_distance_to_party_from_party, ":distance", "p_main_party", ":cur_party"),
       (try_begin),
         (le, ":distance", 5),
         (val_add, ":can_join", 1),
       (else_try),
         (val_add, ":cant_join", 1),
       (end_try),
     (try_end),
      
     (try_begin),
       (eq, ":can_join", 1),
       (str_store_string, s1, "@One lord can disembark here with you."),
     (else_try),
       (gt, ":can_join", 0),
       (assign, reg1, ":can_join"),
       (str_store_string, s1, "@{reg1} lords can disembark here with you."),
     (try_end),
     (try_begin),
       (eq, ":can_join", 1),
       (str_store_string, s2, "@One lord will lose track of you. He must disembark at the next port and then come find you."),
     (else_try),
       (gt, ":cant_join", 0),
       (assign, reg1, ":cant_join"),
       (str_store_string, s2, "@{reg1} lords will lose track of you. They must disembark at the next port and then come find you."),
     (try_end),

   ],
   [
     ("yes",[],"Yes - sail/row under the bridge.",
       [
	 #Teleport the ship to the new location
	 #TODO: but make the ship "travel" instead of teleporting...
         (jump_to_menu, "mnu_auto_return_to_map"),
	 (party_get_position, pos1, "p_landing_point2"),
	 (call_script, "script_get_next_water_position",1),
	 (party_set_position, "p_main_party", pos2),
	
	 #Check for lords following player - anyone within range will also end up on the other side (with the player)
	 (try_for_parties, ":cur_party"),
           (party_slot_eq, ":cur_party", slot_party_type, spt_kingdom_hero_party),
           (party_is_active, ":cur_party"),
           (store_faction_of_party, ":cur_party_faction", ":cur_party"),
           (eq, ":cur_party_faction", "$players_kingdom"),
           (get_party_ai_object, ":cur_party_ai_object", ":cur_party"),
           (eq, ":cur_party_ai_object", "p_main_party"),
           (party_slot_eq, ":cur_party", slot_party_on_water, 1),
           (store_distance_to_party_from_party, ":distance", "p_main_party", ":cur_party"),
           (le, ":distance", 5),
           (party_set_position, ":cur_party", pos2),
         (try_end),

       ]
     ),
     ("leave",[],"No.",
       [
	 (jump_to_menu, "mnu_auto_return_to_map"),
       ]
     ),
   ]
  ),
Note that I reuse the landing_point2 party (since it's still there but not currently used as far as I can tell).

Note that although other parties can follow you even if you're not marshal (I haven't added a check for this), they will get stuck if you decide to disembark anywhere on the side of the river that's cut off by the bridge. So just be careful to not go under bridges with AI parties following you, unless you're the marshal - they will likely get stuck permanently.

Note also that only you and parties currently following you (if in range) will be able to travel under bridges - the AI won't be able to do this by itself, so AI ships still won't ever appear on the "cut off" section of bridges.
 
Somehow I assumed that someone would have already done this, considering that most bridges effectively create rivers that you, by default, cannot sail/row past - meaning you have to disembark at the bridge and go the rest of the way on foot (which is usually slower). Which tbh has bugged me since getting VC - I thought one of trademarks of the Vikings was cruising all the way down inland rivers for raiding?

Interestingly, vikings rarely ventured past bridges.
 
JuJu70 said:
Somehow I assumed that someone would have already done this, considering that most bridges effectively create rivers that you, by default, cannot sail/row past - meaning you have to disembark at the bridge and go the rest of the way on foot (which is usually slower). Which tbh has bugged me since getting VC - I thought one of trademarks of the Vikings was cruising all the way down inland rivers for raiding?

Interestingly, vikings rarely ventured past bridges.

That is interesting - is there any likely reason for this? Superstition? Or perhaps they thought it could collapse and trap them?

Also, while we're on the topic, does this mean that the bridges in VC are placed more to enable easier land movement, or are they actually (for the most part) historically accurate? I guess the same question goes for the rivers?

And although I'm not sure Vikings ever actually raided Jorvik via following the rivers, but I thought that parts of Jorvik were accessible by river?

Same question as above for Caer Maguidd - IIRC this has a harbor (of sorts) with ships in it, so it's definitely located on/near a river? Is there a historical reason Caer Meguidd was not made a port city, or is it just one of those things that you didn't have time for in the end?
 
EvilSquid said:
JuJu70 said:
Somehow I assumed that someone would have already done this, considering that most bridges effectively create rivers that you, by default, cannot sail/row past - meaning you have to disembark at the bridge and go the rest of the way on foot (which is usually slower). Which tbh has bugged me since getting VC - I thought one of trademarks of the Vikings was cruising all the way down inland rivers for raiding?

Interestingly, vikings rarely ventured past bridges.



And although I'm not sure Vikings ever actually raided Jorvik via following the rivers, but I thought that parts of Jorvik were accessible by river
Jorvik was an important port. http://viking.archeurope.info/index.php?page=jorvik-the-viking-city-of-york
 
NPC99 said:
EvilSquid said:
JuJu70 said:
Somehow I assumed that someone would have already done this, considering that most bridges effectively create rivers that you, by default, cannot sail/row past - meaning you have to disembark at the bridge and go the rest of the way on foot (which is usually slower). Which tbh has bugged me since getting VC - I thought one of trademarks of the Vikings was cruising all the way down inland rivers for raiding?

Interestingly, vikings rarely ventured past bridges.



And although I'm not sure Vikings ever actually raided Jorvik via following the rivers, but I thought that parts of Jorvik were accessible by river
Jorvik was an important port. http://viking.archeurope.info/index.php?page=jorvik-the-viking-city-of-york

Cheers for the link. Now I'm tempted to extend that river so that Jorvik can become a port in-game...
 
That is interesting - is there any likely reason for this? Superstition? Or perhaps they thought it could collapse and trap them?

There were very few real bridges in Britannia at the time, Saxons used fords. Bridges were basically built to block the rivers in a way, to prevent large forces to sail unopposed.

Also, while we're on the topic, does this mean that the bridges in VC are placed more to enable easier land movement, or are they actually (for the most part) historically accurate? I guess the same question goes for the rivers?

No bridges in VC are simply a matter of convenience, so armies don't have to march around for ages everywhere. Same for ferries.

And although I'm not sure Vikings ever actually raided Jorvik via following the rivers, but I thought that parts of Jorvik were accessible by river?

Yes York is on the river and was captured by vikings sailing up the river. however, in VC it was decided not to have inland ports.
 
JuJu70 said:
That is interesting - is there any likely reason for this? Superstition? Or perhaps they thought it could collapse and trap them?

There were very few real bridges in Britannia at the time, Saxons used fords. Bridges were basically built to block the rivers in a way, to prevent large forces to sail unopposed.

Interesting, didn't know that. Don't suppose you have a link to any source material on this?

Also, while we're on the topic, does this mean that the bridges in VC are placed more to enable easier land movement, or are they actually (for the most part) historically accurate? I guess the same question goes for the rivers?

No bridges in VC are simply a matter of convenience, so armies don't have to march around for ages everywhere. Same for ferries.

Figured this to be the reason. Both bridges and ferries are definitely welcome in-game.

And although I'm not sure Vikings ever actually raided Jorvik via following the rivers, but I thought that parts of Jorvik were accessible by river?

Yes York is on the river and was captured by vikings sailing up the river. however, in VC it was decided not to have inland ports.

Damn. Oh well, perhaps when a Viking-flavored mod comes out for Bannerlord? :wink:
 
A little code to auto-indent files:

Code:
import sys

print "Write module file name:"
sys.stdout.flush()

file = raw_input()
with open("module_" + file + ".py",'r') as inputF:
	with open("module_" + file + '_new.py','w') as outputF:
		ident_level  = 0
		#lastLine = None
		for iLine in inputF:
			iLine = iLine.lstrip().rstrip()
			oLine = iLine

			#if iLine == "" and lastLine == "": continue

			inStr = False
			comment = len(iLine)+1
			for i in xrange(len(iLine)):
				c = iLine[i]
				if c == '"': inStr = not inStr
				if c == '#' and not inStr:
					comment = i
					break

			iLine = iLine[:comment-1]

			if not iLine.startswith("#"):
				for pattern in ["else_try","try_end","end_try"]:
					ident_level -= iLine.count(pattern)

			for _ in xrange(ident_level): oLine = "\t" + oLine

			if not iLine.startswith("#"):
				for pattern in ["try_begin","try_for_range","try_for_range_backwards","try_for_parties","try_for_agents","try_for_prop_instances","try_for_players","else_try"]:
					ident_level += iLine.count(pattern)
				if iLine.startswith("def "):
					ident_level += 1
				if iLine.startswith("return "):
					ident_level -= 1

			if not iLine.startswith("#"):
				ident_level += iLine.count("[")
				ident_level += iLine.count("(")
				ident_level += iLine.count("{")
				ident_level -= iLine.count("}")
				ident_level -= iLine.count(")")
				ident_level -= iLine.count("]")

			oLine += "\n"

			outputF.write(oLine)
		outputF.close()
	inputF.close()

this will ask for a file name to read "troops" for "module_troops.py" and generate a new file "module_troops_new.py" that is (hopefully) with a better indentation
 
A small code to automatically replace different item stats of multiple items to adjust the balance:

Code:
import sys

with open("module_items.py",'r') as inputF:
	with open("module_items" + '_new.py','w') as outputF:
		curline = inputF.readline()
		cnt = 1
		while curline:
			if (cnt >= 2806) and (cnt < 2933): #here you set a range of lines you want to edit
				try:
					wordind = curline.index('spd_rtng') #here you set a variable you want to edit
					bracketbegind = curline.index('(', wordind)
					numind = bracketbegind + 1
					bracketendind = curline.index(')', wordind)
					numberneeded = int(curline[numind:bracketendind])
					
					newnumber = numberneeded + ((120 - numberneeded)/7) #here you code your algorythm/formula for editing this variable 
					
					linelength = len(curline)+1
					outputline = curline[0:bracketbegind] + '(' + str(newnumber) + curline[bracketendind:linelength]
					print("Line {}: {} => {}".format(cnt, numberneeded, newnumber))
					outputF.write(outputline)
				except ValueError:
					outputF.write(curline)
					print("Line {} skipped".format(cnt))
			curline = inputF.readline()
			cnt += 1
		outputF.close()
	inputF.close()

For example, (like me) one day you decided that your two-handed weapons need a buff to speed, so you set a range of lines in your module_items file where you store your two-handed weapons, then you write a simple formula according to which the speed will be changed - and voila - the code creates a new file - module_items_new - where you will see the selected range of items with automatically adjusted speed. Then you just copy the whole range back to your main file. 
If you don't keep similar items together - well, then you will have to make adjustments to this code by making it search for a weapon type (the same way I search 'spd_rtng') and doing try-except thing.
If you want to edit damage done - in case of bracketendind search for "," instead of ")".
Also if you want to edit prices, it's best to do this in process_items by replacing
Code:
  for item in items:
with (example)
Code:
  for itid, item in enumerate(items):
    if (itid >= itm_arabian_horse_b) and (itid < itm_dedal_kufel):
      item[5] = item[5] * 2 / 3

I did it! My first real code in Python. :grin:
Worked for me, hopefully will work for you too.
 
I don't know if you have known already this but, I found something interesting for me and I would like to share with you.

I was curious of how ti_once in triggers works. I found that ti_once is fired when the conditions of trigger became true.

Example;

Code:
(1, 0.5, ti_once,
    [
      (eq, "$dialog_anim", 1), #assigned global from a specific dialog.
    ],
    [
     (try_for_agents, ":agents"), #get all agents
    (agent_get_troop_id, ":troop_no", ":agents"), #find their id
          (is_between, ":troop_no", "trp_swadian_merchant", "trp_startup_merchants_end"), #if their id is between those
(agent_set_animation, ":agents", "anim_cheer"),# Victorieee!!!
(try_end),
    ]),

So, agent plays the animation just once when the condition comes true.



are there any tricky parts of mb code like this?  :grin:
 
HyperCharge said:
I was curious of how ti_once in triggers works.

Code:
# 3) Re-arm interval
Code:
ti_once        = 100000000.0

100,000,000 hours (world map/campaign). That is 100 million hours. One year has ~9000 hours. So you would need to play a lot of years (beyond what you can do in Warband) to trigger that again.

for a scene (mission) it is in seconds
 
kalarhan said:
100,000,000 hours. That is 100 million hours.

Ackkckctually it's 100 million seconds which is just over 3 years.

HyperCharge said:
I know this. But I thought that the ti_once doesn't wait until condition is true.  :grin:

As it says, just fire "ti_once".  :roll:

ti_once is just a number. By setting the re-arm value to ti_once you're ensuring it will never be re-armed. There's a similar value for presentations.
 
Back
Top Bottom