Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
luadog said:
Look for the comment "Consuming food at every 14 hours" in module_simple_triggers. You should be able to do what you want from there.

i am trying to edit a previous mod and the simple triggers and triggers.txt in the module section only have numbers
could you give me a step by step solution?
Thx in advance
Your answer was just above your post:
Somebody said:
luadog said:
i am trying to edit a previous mod and the simple triggers and triggers.txt in the module section only have numbers
could you give me a step by step solution?
Thx in advance
In Native this should be the only entry in simple_triggers that start with 14.000000.
2133 2 1224979098644774913 0 Base consumption amount. After this point, the number of people in your party is added up.
2108 2 1224979098644774913 3 That amount is then divided by 3. You can change this or change 2108 to 2107 for multiply.
 
Bayard-X said:
Where are these things defined? Can I define some of my own?

:smile:
header_operations, though checkout Lav's expanded version for further explanation of some functions: http://forums.taleworlds.com/index.php/topic,213060.0.html

And, no, you can't define your own. If they are mathematical things, you'll need to use the operations and combine them as needed in a script perhaps. Though the Warband Script Enhancer adds a number of operations.
 
gaham1 said:
I wish to rotate a shield so when its in the relaxed position it will be up against his side and not going off to the left. How do I do that?


I think changing the animation is what you need
 
Thanks!


How would I then make a script with a variable amount of local variables? So that I can call something like:


(store_check_factors, ":local_bool", "$global_variable_stuff", ":number_1", ":number_2", ... ":number_last")



Cheers,
Bayard
 
Bayard-X said:
How would I then make a script with a variable amount of local variables? So that I can call something like:

(store_check_factors, ":local_bool", "$global_variable_stuff", ":number_1", ":number_2", ... ":number_last")
That's a variable number of parameters, not local variables. :smile:

There's no way for a script to know the number of parameters it was called with, and if your script exceeds the number of actually passed parameters, it will throw error messages. So you have to pass the total number of parameters per each call like this:

Code:
(call_script, "script_any_number_of_params", 4, ":param1", ":param2", ":param3", ":param4"),
 
There cannot be two scripts with identical names. So no, you don't have to.

Just retrieve the number of dynamic parameters, and then iterate them in a try_for_range loop.
 
Lav said:
There cannot be two scripts with identical names. So no, you don't have to.

Just retrieve the number of dynamic parameters, and then iterate them in a try_for_range loop.

Just confirming. Can 2nd operand of store_script_param be a local variable instead of a constant?
 
HIHO,
i have an question again.On this side: mbmodwiki.ollclan.eu/Seafaring is a code for seafaring.
But by one of the last steps
Code:
The options to "land" and "send the ship to a town" will not show up if the player tries to do it at a steep cliff (based on the height difference of the positions), because otherwise the player might get stuck there and break his game. Its still possible to do, but this was the closest we could get to fixing this.

Troops need to be paid wages so we better include all the crews the player assigns to his ships (beware this fuses into the diplomacy presentation):

      ##diplomacy begin
      (try_begin),
        (this_or_next|gt, "$g_player_minister", 0),
        (this_or_next|troop_slot_ge, "trp_player", slot_troop_spouse, 0),
        (this_or_next|gt, "$g_player_chamberlain", 0),
        (gt, "$g_player_constable", 0),
        (val_add, ":num_lines", 1), # staff salary
      (try_end),
 
      (try_begin),
        (gt, "$g_player_chamberlain", 0),
        (val_add, ":num_lines", 2), #earlier cash, new cash
      (try_end),
      ##diplomacy end   
	  #FLORIS BEGIN
      (try_begin),
        (faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
        (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
        (val_add, ":num_lines", 1),
      (try_end),
		(try_for_parties, ":party_no"),
			(party_slot_ge,":party_no", slot_ship_center, 1), #Ships are identified by 4 states, towns/player/wilderness/wilderness w/o guard
			(assign, reg20, 2),
		(try_end),
		(try_begin),
			(eq, reg20,2),
			(val_add, ":num_lines", 1),
		(try_end),
      #FLORIS END  
      (val_add, ":num_lines", 3),
      (store_mul, ":cur_y", 27, ":num_lines"),
      (assign, ":net_change", 0), #this is the amount added
      (try_for_range, ":center_no", centers_begin, centers_end),		
		#Enterprise


          (str_store_string, s0, "str_s0s_party"),
        (try_end),				
        (create_text_overlay, reg1, "str_wages_for_s0", 0),
        (position_set_x, pos1, 900),
        (position_set_y, pos1, 900),
        (overlay_set_size, reg1, pos1),
        (position_set_x, pos1, 25),
        (position_set_y, pos1, ":cur_y"),
        (overlay_set_position, reg1, pos1),
        (try_begin),
          (lt, ":total_wage", 0),
          (assign, reg0, ":total_wage"),
          (create_text_overlay, reg1, "@{!}{reg0}", tf_right_align|tf_single_line),
          (overlay_set_color, reg1, 0xFF0000),
        (else_try),
          (create_text_overlay, reg1, "@None", tf_right_align|tf_single_line),
        (try_end),
        (position_set_x, pos1, 900),
        (position_set_y, pos1, 900),
        (overlay_set_size, reg1, pos1),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, ":cur_y"),
        (overlay_set_position, reg1, pos1),
        (val_sub, ":cur_y", 27),
      (try_end),
 
	  #Floris Addendum / Crew Wages / Seafaring
		(assign, ":crew_wage", 0),	
		(assign, reg20, 0),
		(try_for_parties, ":party_no"),
			(party_slot_ge,":party_no", slot_ship_center, 1), #Ships are identified by 4 states, towns/player/wilderness/wilderness w/o guard
			(party_get_num_companion_stacks, ":num_stacks", ":party_no"), #Calculating Wages
			(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"),
				(val_mul, ":cur_wage", -1),
				(val_add, ":crew_wage", ":cur_wage"),
			(try_end),
			(assign, reg20, 1),
		(try_end),
		(try_begin),
			(eq, reg20, 1),
			(assign, reg0, ":crew_wage"),
			(val_add, ":net_change", ":crew_wage"),			
			(create_text_overlay, reg1, "@Wages for your Shipcrew/s:", 0),
			(position_set_x, pos1, 900),
			(position_set_y, pos1, 900),
			(overlay_set_size, reg1, pos1),
			(position_set_x, pos1, 25),
			(position_set_y, pos1, ":cur_y"),
			(overlay_set_position, reg1, pos1),
 
			(create_text_overlay, reg1, "@{!}{reg0}", tf_right_align|tf_single_line), #Display Wages
			(overlay_set_color, reg1, 0xFF0000),
			(position_set_x, pos1, 900),
			(position_set_y, pos1, 900),
			(overlay_set_size, reg1, pos1),
			(position_set_x, pos1, 500),
			(position_set_y, pos1, ":cur_y"),
			(overlay_set_position, reg1, pos1),
			(val_sub, ":cur_y", 27),
		(try_end),
 
	#Floris End
 
 
 
      (try_begin),
        (gt, "$g_player_debt_to_party_members", 0),
        (val_sub, ":net_change", "$g_player_debt_to_party_members"),
        (create_text_overlay, reg1, "str_earlier_debts", 0),



To finish off - a few minor menu fixes and additions (be aware this is based on FEMP, you might not have the same code, but you will need to alter "Resume Travelling" and "Wait here for some time"):

     ("camp_wait_here",[],"Wait here for some time.",
       [
           (assign,"$g_camp_mode", 1),
           (assign, "$g_infinite_camping", 0),
           (assign, "$g_player_icon_state", pis_camping),
#		   (party_set_slot,"p_main_party",slot_party_entrenched,0), #TEMPERED ADDED LINE FOR NO ENTRENCHMENT
#		   (assign,"$current_camp_party",-1), #TEMPERED ADDED LINE FOR NO ENTRENCHMENT
 
           (try_begin),
             (party_is_active, "p_main_party"),
             (party_get_current_terrain, ":cur_terrain", "p_main_party"),
             (try_begin),
               (eq, ":cur_terrain", rt_desert),
               (unlock_achievement, ACHIEVEMENT_SARRANIDIAN_NIGHTS),		#Floris Seafaring Addendum
			 (else_try),
				(eq, ":cur_terrain", 0), #Sea
				(assign, "$g_player_icon_state", pis_ship),
				(party_set_flags, "p_main_party", pf_is_ship, 1),
             (try_end),  
           (try_end),  
           (rest_for_hours_interactive, 24 * 365, 5, 1), #rest while attackable                     
            (change_screen_map),
        ]
       ),
 
	   ("camp_fishing", #Floris Fishing
	   [	(party_get_current_terrain, ":terrain", "p_main_party"),
			(eq, ":terrain", 0),
	   ],
	   "Try to catch some fish.",
	   [
			(store_current_hours, ":time"),
			(val_add, ":time", 24),
			(party_set_slot, "p_main_party", slot_ship_time, ":time"),
			(assign,"$g_camp_mode", 1),
			(assign, "$g_infinite_camping", 0),
			(rest_for_hours_interactive, 24 * 365, 5, 1),
			(assign, "$g_player_icon_state", pis_ship),
			(change_screen_map),
		]),	
 
 
#Tempered inspect camp
      ("camp_inspect",
	  [	(party_get_current_terrain, ":terrain", "p_main_party"),
		(neq, ":terrain", 0),
	  ],"Inspect your camp.",
       [
			(call_script,"script_visit_camp"),
        ]
       ),	   
#TEMPERED  CHANGES BEGIN  ADDED ENTRENCHMENT MENU OPTION                                	   
      ("camp_entrench",[ 	(party_get_current_terrain, ":terrain", "p_main_party"),
							(neq, ":terrain", 0),
							(party_slot_eq,"p_main_party",slot_party_entrenched,0),
							(assign,":continue",0),
							(try_for_parties,":camp_site"),
								(eq,":continue",0),
								(party_slot_eq,":camp_site",slot_party_type,spt_entrenchment),
								(store_distance_to_party_from_party, ":distance", ":camp_site", "p_main_party"),
								(try_begin),
									(le,":distance",1),
									(str_store_string,s1,"@Return to your fortifications."),
									(assign,":continue",1),
									(assign,"$current_camp_party",":camp_site"),
								(try_end),
							(try_end),		
							(try_begin),
								(eq,":continue",0),
								(call_script,"script_party_entrench_time"),
								(str_store_string,s1,"@Spend {reg5} hours entrenching your camp site."),
								(assign,"$current_camp_party",-1),
							(try_end),													
						],"{s1}",
       [	
			(assign,":continue",0),
			(store_current_hours,":cur_hour"),
			(try_begin),
				(player_has_item,"itm_tools"),
				(assign,":continue",1),
			(try_end),
			(try_begin),
				(eq,":continue",1),
				(try_begin),
					(lt,"$current_camp_party",0),
					(call_script,"script_party_entrench_time"),
					(store_add,"$entrench_time",":cur_hour",reg5),
					(call_script,"script_change_player_party_morale",-10),					
					(party_set_slot,"p_main_party",slot_party_entrenched,-1),
					(assign,"$g_camp_mode", 1),
					(assign, "$g_infinite_camping", 0),
					(assign, "$g_player_icon_state", pis_camping),												
					(rest_for_hours_interactive, 24 * 7, 5, 1), #rest while attackable
					(change_screen_return),					
				(else_try),
					(gt,"$current_camp_party",0),
					(party_set_slot,"p_main_party",slot_party_entrenched,1),
					(display_message,"@_You have returned to a fortified position."),
					(party_set_slot,"$current_camp_party",slot_village_state,1),
					(party_clear_particle_systems, "$current_camp_party"),
					(assign,"$entrench_time",0),
					(assign,"$g_camp_mode", 1),
					(assign, "$g_infinite_camping", 0),
					(assign, "$g_player_icon_state", pis_camping),												
					(jump_to_menu,"mnu_camp"),					
				(try_end),
			(else_try),
				(eq,":continue",0),
				(display_message,"@_You must have tools in inventory to entrench your camp site."),
				(jump_to_menu,"mnu_camp"),
			(try_end),
        ]
       ),
 
#	   ("game_options",[],"Adjust mod settings.",
#       [
#			(jump_to_menu,"mnu_options"),
#        ]
#       ),
#TEMPERED  CHANGES END
 
      ("camp_cheat",
       [(ge, "$cheat_mode", 1)
        ], "CHEAT MENU!",
       [(jump_to_menu, "mnu_camp_cheat"),
        ],
       ),
      ("resume_travelling",[],"Resume travelling.",
       [
			(party_get_current_terrain, ":terrain", "p_main_party"), #Floris Addendum / Seafaring
			(try_begin),
				(neq, ":terrain", 0),
				(assign, "$g_player_icon_state", pis_normal),
				(assign,"$g_camp_mode", 0),
			(else_try),
				(assign, "$g_player_icon_state", pis_ship),
				(assign,"$g_camp_mode", 0),
			(try_end),
			(change_screen_map),
        ]
       ),
      ]
  ),
don't stand where i must add this.I think it's module_presentations.py ir module_game_menus.py .
Anyone know which is the right?

Roemerboy
 
I've run into a problem while editing my troops with Morgh's editor, the troop name and upgrade tree changes are the way they should be and the troops use the equipment I've assigned them but the stat changes I've made don't seem to be having any effect, what have I done wrong?

Also, what determines which equipment a unit spawns with? I've assigned several different pieces of equipment for each slot but my units are only spawning with one combination, is there a way to force some diversity?
 
Yorker said:
I've run into a problem while editing my troops with Morgh's editor, the troop name and upgrade tree changes are the way they should be and the troops use the equipment I've assigned them but the stat changes I've made don't seem to be having any effect, what have I done wrong?
Stats get somewhat randomized on the start of a new game. The more unused points (given the troop's level), the more they are randomized it seems. Some folks give tons of charisma or useless skills to try to prevent this.

Yorker said:
Also, what determines which equipment a unit spawns with? I've assigned several different pieces of equipment for each slot but my units are only spawning with one combination, is there a way to force some diversity?
They should randomly select items of the same type...if the troops have the stats to use the item.
 
No, I mean my change doesn't show up at all.

In the editor I've got level(30) and def_attrib in the attribute section and knows_common, knows_ironflesh_5, knows_power_strike_5, knows_athletics_6 and knows_shield_6 in the skill sections, but in game these are the stats:

2mJDE.jpg
 
Lav said:
There cannot be two scripts with identical names. So no, you don't have to.

Just retrieve the number of dynamic parameters, and then iterate them in a try_for_range loop.


I have

Code:
  ("check_if_these_are_factors",
   [
         (store_script_param, ":number_to_check", 1), # I want to know of this number if the following are factors.
         (store_script_param, ":number_of_loops", 2), # run loops
         (assign, ":this_count", 2), # initialise loops
         (assign, ":factors_bool",0), # initialise boolean to return
         (try_for_range, 1, ":number_of_loops"),
             (val_add, ":this_count", 1),
             (store_script_param, ":this_factor", ":this_count"), 
             (store_mod, ":check", ":number_to_check", ":this_factor"),
             (eq, ":check", 0),
             (assign, ":factors_bool",1),
         (try_end),
         (assign, reg0, ":factors_bool"),            
   ]),

... but it does not seem to work :sad:


Edit:

I call with

Code:
        (call_script, "script_check_if_these_are_factors", "$bayards_counter", 2, 1102, 6395457),
        (assign, ":check", reg0),
        (eq,":check", 1), 
 
I have this code of a grenade, I think it is of Specialist http://forums.taleworlds.com/index.php?action=profile;u=129797 , but does not work when I play with bots (not kill anyone), not the effects of explosion (where I put it?)

anyone can help me (I put this code in module_item.py)

Code:
["Grenades", "Grenades", [("Grenades",0)], itp_type_thrown|itp_primary ,itcf_throw_axe, 500 , weight(4)|difficulty(0)|spd_rtng(85) | shoot_speed(30) | thrust_damage(1 ,  blunt)|max_ammo(6)|weapon_length(8),imodbits_none,

[(ti_on_missile_hit, [
   (store_trigger_param_1,":agent"),
        (try_for_agents,":target"),
            (agent_get_position,pos2,":target"),
            (get_distance_between_positions,":dist",pos1,pos2),

       (try_begin),
               (lt,":dist",250),
               (store_agent_hit_points,":hp",":target",1),
      (store_random_in_range,":dmg",60,100),
      (val_sub,":hp",":dmg"),

      (agent_set_hit_points,":target",":hp",1),
      (agent_deliver_damage_to_agent,":agent",":target"),
       (try_end),
      ])]],
 
Actually, it was first belonging to beaver, I just reposted to help someone. The code needs
(multiplayer_is_server), at the very top to work in MP
 
Bayard-X said:
Code:
  ("check_if_these_are_factors",
   [
         (store_script_param, ":number_to_check", 1), # I want to know of this number if the following are factors.
         (store_script_param, ":number_of_loops", 2), # run loops
         (assign, ":this_count", 2), # initialise loops
         (assign, ":factors_bool",0), # initialise boolean to return
         (try_for_range, 1, ":number_of_loops"),
             (val_add, ":this_count", 1),
             (store_script_param, ":this_factor", ":this_count"), 
             (store_mod, ":check", ":number_to_check", ":this_factor"),
             (eq, ":check", 0),
             (assign, ":factors_bool",1),
         (try_end),
         (assign, reg0, ":factors_bool"),            
   ]),

... but it does not seem to work :sad:


Edit:

I call with

Code:
        (call_script, "script_check_if_these_are_factors", "$bayards_counter", 2, 1102, 6395457),
        (assign, ":check", reg0),
        (eq,":check", 1), 

In your script, your try_for_range is missing the "destination"/iterated variable.

I would fix it like this:
Code:
("check_if_these_are_factors",
   [
         (store_script_param, ":number_to_check", 1), # I want to know of this number if the following are factors.
         (store_script_param, ":number_of_loops", 2), # run loops
         (assign, ":factors_bool",0), # initialise boolean to return
         (val_add, ":number_of_loops", 3),
         (try_for_range, ":i", 3, ":number_of_loops"),
             (store_script_param, ":this_factor", ":i"), 
             (store_mod, ":check", ":number_to_check", ":this_factor"),
             (eq, ":check", 0),
             (assign, ":factors_bool",1),
         (try_end),
         (assign, reg0, ":factors_bool"),            
   ]),
Note that reg0 will be 1 if any of the numbers passed are a factor, not necessary all of them will be factors.

You could also make the script able to fail by adding cf_ to the name and using your  (eq,":check", 1), type test within the script itself since you're likely always going to use a conditional after running the script.
 
Caba`drin said:
("check_if_these_are_factors",
  [
        (store_script_param, ":number_to_check", 1), # I want to know of this number if the following are factors.
        (store_script_param, ":number_of_loops", 2), # run loops
        (assign, ":factors_bool",0), # initialise boolean to return
        (val_add, ":number_of_loops", 3),
        (try_for_range, ":i", 3, ":number_of_loops"),         
            (store_script_param, ":this_factor", ":i"),
            (store_mod, ":check", ":number_to_check", ":this_factor"),
            (eq, ":check", 0),
            (assign, ":factors_bool",1),
            (assign, ":number_of_loops", ":i"),         
          (try_end),
        (assign, reg0, ":factors_bool"),           
  ]),
]
Inserting the green line to stop checking loop once we find out that the number has a factor.
 
Thanks  :grin:


I tested the code and it does what I want to.


I also renamed the script to:

check_if_one_or_more_of_these_are_factors



The CanFail architecture seems interesting to me, but I seem to lack the knowledge in how to make the script then.

However, even in the current state, I am happy, because I can now do some intersting things on the ReMo.
 
Status
Not open for further replies.
Back
Top Bottom