Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Seek n Destroy said:
xPearse said:
Where would it define what this guy where's here in the multiplayer menu.

multiplayer_profile_troop_male and multiplayer_profile_troop_female

Thanks, your always helpful. Thought this would be somewhere in the scripts and not troops, didn't even think to look there.
 
so i am trying to make a presentations that will look exactly like the ingame inventory window.
first step that i did i added the mesh (inventory_window.dds is in the texture folder from the game folder)
Code:
("inventory_window", 0, "inventory_window", 0, 0, 0, 0, 0, 0, 1, 1, 1),

then i made the presentation
Code:
 ("inventory",prsntf_read_only|prsntf_manual_end_only,mesh_inventory_window,[#  (start_background_presentation, "prsnt_sync"),
		  (ti_on_presentation_load,
		   [
		    (create_text_overlay, "$g_little_pos_helper", "@00,00"),
			(overlay_set_color, "$g_little_pos_helper", 0xFFFFFFFF),
			(position_set_x, pos1, 10),
			(position_set_y, pos1, 700),
			(overlay_set_position, "$g_little_pos_helper", pos1),
			(presentation_set_duration, 999999),
		   ]),
		 (ti_on_presentation_run,
           [
		   (mouse_get_position, pos1),
			(position_get_x, reg1, pos1),
			(position_get_y, reg2, pos1),
			(overlay_set_text, "$g_little_pos_helper", "@{reg1},{reg2}"),
			(try_begin),
				(map_free),
				(presentation_set_duration, 0),
			(else_try),
				(key_clicked,key_escape),
				(presentation_set_duration, 0),
			(try_end),
			]),
			sync,
	 ]),

but the problem is that when i run the presentation, the image does not auto scale to the current resolution. how can i fix it?

this is what i get ingame
uBRr0uu.jpg
 
Perhaps you can also scale it in your module_meshes definition:

Code:
("inventory_window", 0, "inventory_window", 0, 0, 0, 0, 0, 0, 1, 0.75, 1),
 
How can I reduce map lag?

I have replaced the code updating the player map icon with this; maybe that's the problem?
Code:
  # Updating player icon in every frame
  (0, [
  	(try_for_range, ":kingdom_hero", active_npcs_begin, active_npcs_end),
		(troop_get_slot, ":party", ":kingdom_hero", slot_troop_leaded_party),
		(troop_slot_eq, ":kingdom_hero", slot_troop_occupation, slto_kingdom_hero),
		(party_get_current_terrain, ":terrain", ":party"),
		(try_begin),
			(eq, ":terrain", rt_bridge),
			(party_set_icon, ":party", "icon_ship"),
		(else_try),
			(party_get_icon, ":icon", ":party"),
			(eq, ":icon", "icon_ship"),
			(party_set_icon, ":party", "icon_flagbearer_a"),
		(try_end),
	(try_end),
	
(troop_get_inventory_slot, ":cur_horse", "trp_player", 8), #horse slot
(party_get_current_terrain, ":terrain", "p_main_party"),
    (assign, ":new_icon", "icon_player"),
    (try_begin),
      (eq, "$g_player_icon_state", pis_normal),
      (try_begin),
       (eq, ":terrain", rt_bridge),
       (assign, ":new_icon", "icon_ship"),
      (else_try),
        (ge, ":cur_horse", 0),
        (assign, ":new_icon", "icon_player_horseman"),
      (else_try),
      (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
      (assign, ":num_men", 0),
      (try_for_range, ":i_stack", 1, ":num_stacks"),
        (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"),
        (try_begin),
          (troop_is_hero, ":stack_troop"),
          (val_add, ":num_men", 1), #it was 3 in "Mount&Blade", now it is 1 in Warband
        (else_try),
          (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
          (val_add, ":num_men", ":stack_size"),
        (try_end),
        (gt, ":num_men", 8),
        (assign, ":new_icon", "icon_player_with_party"),
      (try_end),
    (else_try),
      (eq, "$g_player_icon_state", pis_camping),
      (assign, ":new_icon", "icon_camp"),
    (else_try),
      (eq, "$g_player_icon_state", pis_ship),
      (assign, ":new_icon", "icon_ship"),
    (try_end),
    (neq, ":new_icon", "$g_player_party_icon"),
    (assign, "$g_player_party_icon", ":new_icon"),
    (party_set_icon, "p_main_party", ":new_icon"),
  ]),
 
Yes. There's absolutely no reason for you to be checking every single kingdom lord every single frame. Those checks are quite inefficient and you should really be caching those results instead of going lord->party->terrain->icon hundreds of times. In addition your check for icon_player_with_party is also wrong as it screws up with the original loop structure.
 
How do i make it so none of the troops of a specific faction desert? I want to get rid of the option for just one faction. This would also eliminate the faction_deserter_troop.

Then my second question would be, how to disable lords defecting for that specific faction?
 
Somebody said:
Yes. There's absolutely no reason for you to be checking every single kingdom lord every single frame. Those checks are quite inefficient and you should really be caching those results instead of going lord->party->terrain->icon hundreds of times. In addition your check for icon_player_with_party is also wrong as it screws up with the original loop structure.


So, how can I fix this?

Thanks for the quick answer! :smile:
 
Is there any way to check if it's raining/snowing or not? or will I have to write a series of triggers that decide precipitation and replace the native system just to be able to do something if it's raining?

Thanks.
 
Docm30 said:
Is there any way to check if it's raining/snowing or not? or will I have to write a series of triggers that decide precipitation and replace the native system just to be able to do something if it's raining?

Thanks.
What about getting the global cloud amount (get_global_cloud_amount, ":whatever"), not sure if this would work for you though - I think that this value only corresponds to the likelihood of it raining/snowing, e.g. a value of 80 would mean that it is quite likely that it will be raining but not definate - I would need to test it to be sure though
 
The_dragon said:
255 (not sure)? i mean you can have 255 player slots, 255 party slots and soo on...
I've used numbers as high as 400 and they've worked so I don't think 255 is the number.

Somebody said:
You can have more than that (for parties and troops at least), but remember that the savegame will allocate the same array size for all objects of that type.
Right. Damn, I forgot. Thinking about how to reduce the map lag I'm getting. I'm suspecting it's because of all the triggers that do try_for_parties and because I've got an absolute load of parties at all times. So I was thinking, if I index each and every party inside an array upon its spawning, surely it would be faster to loop through the arrays, no?
Actually, perhaps it wouldn't be, and besides, the drawback of allocating 6000 slots for each and every party would be catastrophic if it's even possible. I'll just have to rewrite the triggers like I did with game_start...
 
try_for_parties is quite problematic in that in many cases it's only used for finding 1 particular party or counting, iterating through thousands finding just a handful that match the criteria (which are often not well-designed). It is highly dubious that any loop you design will be faster than the engine's loops though. The trick is to design smarter loops. I've designed linked lists, but those are quite fragile if you don't iterate through it properly. A while ago I wrote a bandit management loop (directing them to/from villages as well as lairs to drop off/convert prisoners), but it wasn't the most efficient.
 
What is the operation for asking if a troop has an item in their inventory, but not equipped?


I've tried troop_has_item but it doesn't exist.


troop_has_item_equipped doesn't work for me, because I just want it to be in the inventory, not equipped.
 
cmpxchg8b said:
Thanks!

Somebody said:
try_for_parties is quite problematic in that in many cases it's only used for finding 1 particular party or counting, iterating through thousands finding just a handful that match the criteria (which are often not well-designed). It is highly dubious that any loop you design will be faster than the engine's loops though. The trick is to design smarter loops. I've designed linked lists, but those are quite fragile if you don't iterate through it properly. A while ago I wrote a bandit management loop (directing them to/from villages as well as lairs to drop off/convert prisoners), but it wasn't the most efficient.
Yeah, figures. I guess I'll rack my brains when I get to it, and hopefully come up with something usable.
 
Does anyone know what texture file has those two shields up in the top left corner, I have been searching around the multiplayer ones but have had no luck so far.
 
Status
Not open for further replies.
Back
Top Bottom