Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Hai,

I'm trying to code a dynamically generated health bar above a agent. So for the basics are done, but I am kinda stuck at the moment.

Did anyone every tried to code the same thing? Tried to search it, but couldn't find anything

If not I hope you can help me out with the following code,

Currently only shows up for just 1 agent (needs to be all the agents withing the 50mtr distance of the player).
I also have less knowledge about setting the positions right for the health bar, kinda want them floating above a players head and make the bar smaller if the distance increases. (currently hovers somewhere near the feet of the agent and does not get smaller when the distance is larger)

Code:
	 ("update_health_bars", [
		(set_fixed_point_multiplier, 1000),
		(get_player_agent_no, ":my_agent_id"),
		(agent_get_position, pos0, ":my_agent_id"),
		#(try_for_players, ":player_id", 1),
		(try_for_agents, ":agent_id"),
			(neq, ":my_agent_id", ":agent_id"),
			#(player_is_active, ":player_id"),
			#(player_get_agent_id, ":agent_id", ":player_id"),
			(agent_is_human, ":agent_id"),
			(agent_is_alive, ":agent_id"),
			(agent_get_position, pos1, ":agent_id"),
			(position_move_z, pos1, 150),
			(get_distance_between_positions_in_meters, ":dist", pos0, pos1),
			(try_begin),
				#in range of player
				(lt, ":dist", 50),
				(position_get_screen_projection, pos0, pos1),
				(store_agent_hit_points, ":health", ":agent_id", 0),
				(create_progress_overlay, reg0, 0, 100),
				(overlay_set_val, reg0, ":health"),
				(overlay_set_position, reg0, pos0),
				(position_get_x, ":pos0_x", pos0),
				(val_add, ":pos0_x", ":dist"),
				(position_set_x, pos0, ":pos0_x"),
				(overlay_set_size, reg0, pos0),
			(try_end),
		(try_end),
		(try_begin),
			(key_clicked, key_b),
			(display_message, "@script stopped"),
		(else_try),
			(start_presentation, "prsnt_kaasovic_show_player_health"),
		(try_end),
	 ]),

Really hope you lot can help me out.

Thanks
 
Kaasovic said:
Hai,

I'm trying to code a dynamically generated health bar above a agent. So for the basics are done, but I am kinda stuck at the moment.

Did anyone every tried to code the same thing? Tried to search it, but couldn't find anything

If not I hope you can help me out with the following code,

Currently only shows up for just 1 agent (needs to be all the agents withing the 50mtr distance of the player).
I also have less knowledge about setting the positions right for the health bar, kinda want them floating above a players head and make the bar smaller if the distance increases. (currently hovers somewhere near the feet of the agent and does not get smaller when the distance is larger)

Code:
	 ("update_health_bars", [
		(set_fixed_point_multiplier, 1000),
		(get_player_agent_no, ":my_agent_id"),
		(agent_get_position, pos0, ":my_agent_id"),
		#(try_for_players, ":player_id", 1),
		(try_for_agents, ":agent_id"),
			(neq, ":my_agent_id", ":agent_id"),
			#(player_is_active, ":player_id"),
			#(player_get_agent_id, ":agent_id", ":player_id"),
			(agent_is_human, ":agent_id"),
			(agent_is_alive, ":agent_id"),
			(agent_get_position, pos1, ":agent_id"),
			(position_move_z, pos1, 150),
			(get_distance_between_positions_in_meters, ":dist", pos0, pos1),
			(try_begin),
				#in range of player
				(lt, ":dist", 50),
				(position_get_screen_projection, pos0, pos1),
				(store_agent_hit_points, ":health", ":agent_id", 0),
				(create_progress_overlay, reg0, 0, 100),
				(overlay_set_val, reg0, ":health"),
				(overlay_set_position, reg0, pos0),
				(position_get_x, ":pos0_x", pos0),
				(val_add, ":pos0_x", ":dist"),
				(position_set_x, pos0, ":pos0_x"),
				(overlay_set_size, reg0, pos0),
			(try_end),
		(try_end),
		(try_begin),
			(key_clicked, key_b),
			(display_message, "@script stopped"),
		(else_try),
			(start_presentation, "prsnt_kaasovic_show_player_health"),
		(try_end),
	 ]),

Really hope you lot can help me out.

Thanks

This presentation shows health of horses if they have rider. Im sure you will find some usefull stuff in there, as showing agent health needs just small modification.

Code:
  ("display_agent_health", prsntf_read_only|prsntf_manual_end_only, 0,   display player name and optionally faction name above the heads of nearby agents    emiel
     
	 [(ti_on_presentation_load,
       [(assign, "$g_presentation_agent_labels_overlay_count3", 0),
        (assign, "$g_presentation_agent_labels_update_time3", 0),
        (presentation_set_duration, 999999),
        ]),
		
      (ti_on_presentation_run,
       [(store_trigger_param_1, ":current_time"),
     
	    (set_fixed_point_multiplier, 1000),
        (try_begin),
          (eq, "$g_display_labels", 0),
          (presentation_set_duration, 0),
        (else_try),
         
		  (gt, ":current_time", "$g_presentation_agent_labels_update_time3"),
          (store_add, "$g_presentation_agent_labels_update_time3", ":current_time", 20),   check and update all visible labels every 20 milliseconds
          (multiplayer_get_my_player, ":my_player"),
          (gt, ":my_player", -1),
          (str_clear, s0),
          (mission_cam_get_position, pos11),
		 
          (assign, ":overlay_id2", 0),
          (try_for_agents, ":agent_id"),
         
		  
		    (agent_is_human, ":agent_id"),
            (agent_is_alive, ":agent_id"),
            (agent_get_player_id, ":player_id", ":agent_id"),
            (neq, ":player_id", ":my_player"),
            (agent_get_item_slot, ":body_item_id", ":agent_id", 5),
            (neq, ":body_item_id", "itm_invisible_body"),
            (agent_get_position, pos12, ":agent_id"),
		   
            (assign, reg1, ":agent_id"),
		    (display_message,"@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" ),
		    (display_message,"@agent: {reg1}" ),

		

		 
		 
		 
		 
		 
		   (position_move_z, pos12, 240),
            (agent_get_horse, ":horse", ":agent_id"),
            (try_begin),
              (ge, ":horse", 0),
              (position_move_z, pos12, 80),
            (try_end),
            (get_sq_distance_between_positions, ":sq_distance", pos11, pos12),
            (le, ":sq_distance", 2250000),
		   
            (copy_position, pos11, pos12),
            (position_move_z, pos11, 50),
            (position_get_screen_projection, pos12, pos11),   get the 2D position on screen 50 above the 3D position of the agent
            (position_get_x, ":x_pos", pos12),
            (position_get_y, ":y_pos", pos12),
            (is_between, ":x_pos", -100, 1100),   check if inside the view boundaries or nearly so
            (is_between, ":y_pos", -100, 850),
            (position_has_line_of_sight_to_position, pos11, pos12),
            (try_begin),   create a new overlay if needed
		  
              (ge, ":overlay_id2", "$g_presentation_agent_labels_overlay_count3"),
              (create_text_overlay, reg0, s0, tf_center_justify|tf_with_outline),
              (val_add, "$g_presentation_agent_labels_overlay_count3", 1),
            (try_end),
          
		    (try_begin),
              (try_begin),
				  (player_is_active, ":player_id"),
				  (agent_get_horse, ":horse", ":agent_id"),
				  (ge, ":horse", 0),
				  (store_agent_hit_points, ":hp", ":horse"),
				  (store_agent_hit_points, ":hp", ":agent_id"),
				
				  (assign, reg60, ":hp"),
				  (display_message,"@hp: {reg60}"),
				
				  (try_begin),
					  (eq, ":hp", 100),
					  (assign, ":color", 0x00CC00),
					  (str_store_string, s62, "@ |||||||||||||||||||| "),
				  (else_try),	
					  (le, ":hp", 90),
					  (ge, ":hp", 80),
					  (assign, ":color", 0x00CC00),
					  (str_store_string, s62, "@ ||||||||||||||||||    "),
				  (else_try),	
					  (le, ":hp", 79),
					  (ge, ":hp", 70),
					  (assign, ":color", 0x00CC00),
					  (str_store_string, s62, "@ ||||||||||||||||      "),
				  (else_try),	
					  (le, ":hp", 69),
					  (ge, ":hp", 60),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||||||||        "),
				  (else_try),	
					  (le, ":hp", 59),
					  (ge, ":hp", 50),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||||||          "),
				  (else_try),	
					  (le, ":hp", 49),
					  (ge, ":hp", 40),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||||            "),
				  (else_try),	
					  (le, ":hp", 39),
					  (ge, ":hp", 30),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||              "),
				  (else_try),	
					  (le, ":hp", 29),
					  (ge, ":hp", 20),
					  (assign, ":color", 0xFF0033),
					  (str_store_string, s62, "@ ||||||                "),
				  (else_try),	
					  (le, ":hp", 19),
					  (ge, ":hp", 10),
					  (assign, ":color", 0xFF0033),
					  (str_store_string, s62, "@ ||||                  "),
				  (else_try),	
					  (lt, ":hp", 10),
					
					  (assign, ":color", 0xFF0033),
					  (str_store_string, s62, "@ ||                    "),
				  (try_end),
			  (else_try),
				  (str_clear, s62),
			  (try_end),
             
			  (assign, reg1, ":overlay_id2"),
		   
		      (display_message,"@overlay: {reg1}"),
			
			  (overlay_set_text, ":overlay_id2", s62),
              (overlay_set_color, ":overlay_id2", ":color"),
              (overlay_set_position, ":overlay_id2", pos12),
              (copy_position, pos13, pos12),
              (position_move_z, pos13, 200),   move the 3D position up by 200 and check the 2D distance moved, to get the appropriate text size (reducing with distance)
              (position_get_screen_projection, pos14, pos13),
              (position_get_y, ":y_pos_up", pos14),
              (store_sub, ":height", ":y_pos_up", ":y_pos"),
              (val_mul, ":height", 10),
              (val_max, ":height", 2000),
			  (val_min, ":height", 1000),
              (position_set_y, pos14, ":height"),
              (position_set_x, pos14, ":height"),
              (overlay_set_size, ":overlay_id2", pos14),
              (overlay_set_display, ":overlay_id2", 1),
            (try_end),
            (val_add, ":overlay_id2", 1),
          (try_end),
          (try_begin),
		 
            (store_sub, ":redraw_threshold", "$g_presentation_agent_labels_overlay_count3", 10),
            (lt, ":overlay_id2", ":redraw_threshold"),
            (presentation_set_duration, 0),
            (start_presentation, "prsnt_display_agent_labels"),
          (else_try),
            (try_for_range, ":unused_overlay_id", ":overlay_id2", "$g_presentation_agent_labels_overlay_count3"),
		   
              (overlay_set_display, ":unused_overlay_id", 0),
            (try_end),
          (try_end),
        (try_end),
        ]),
      ]),
 
Kaasovic said:
1) withing the 50mtr distance of the player

2) floating above a players head

3) make the bar smaller if the distance increases

1) use the try_for_agents filtered by distance
Code:
try_for_agents    = 12	# (try_for_agents, <destination>, [<position_no>], [<radius_fixed_point>]), #avoid using pos0
2) get the position of the agents head using bones
Code:
agent_get_bone_position                = 2076 # (agent_get_bone_position, <position_no>, <agent_no>, <bone_no>, [<local_or_global>]), # returns position of bone. Option 0 for local to agent position, 1 for global

3) check distance between them and then use the operation for overlay size to adjust it
 
Kaasovic said:
Hai,

I'm trying to code a dynamically generated health bar above a agent. So for the basics are done, but I am kinda stuck at the moment.

Did anyone every tried to code the same thing? Tried to search it, but couldn't find anything

rubik's custom commander had this. I believe the source code is out there.
 
Is it possible to create faces (keys) for troops in scripts.py?
As you know, faces are created like this in troops.py:
  ["townsman","Townsman","Townsmen",tf_guarantee_boots|tf_guarantee_armor,no_scene,reserved,fac_commoners,  [itm_cleaver,itm_knife,itm_club,itm_quarter_staff,itm_dagger,itm_stones,itm_leather_cap,itm_linen_tunic,itm_coarse_tunic,itm_leather_apron,itm_nomad_boots,itm_wrapping_boots],
  def_attrib|level(4),wp(60),knows_common,mercenary_face_1, mercenary_face_2],
it creates random face key between mercenary_face_1 and mercenary_face_2. I am trying to do the same thing for tpe scaled troops from the scripts.py. To do that, i found this operation in header_operations.py:
Code:
troop_set_face_keys                   = 2751 # (troop_set_face_keys, <troop_no>, <string_no>, [<alt>]), #Sets <troop_no>'s face keys from string. if [<alt>] is non-zero the second pair of face keys is set.
and i used this operation in scripts.py like this:
scripts.py said:
  ("tpe_name_the_scaled_troops",
    [ 
(try_for_range, ":troop_no", tpe_scaled_troops_begin, tpe_scaled_troops_end),
(troop_set_slot, ":troop_no", slot_troop_original_faction, "fac_commoners"),
(assign, ":age", 1:cool:,
                        (troop_set_auto_equip, ":troop_no", 0),
# # Figure out the local town's information.
# (str_store_party_name, s10, "$current_town"),
# # Figure out who owns the town.
#(party_get_slot, ":troop_town_lord", "$current_town", slot_town_lord),
# Figure out the appropriate faction
#(party_get_slot, ":faction_town", "$current_town", slot_center_culture),
                      (str_store_string, s1, "str_tpe_face_key_1"),
                      (troop_set_face_keys, ":troop_no", s1, 1),
strings.py said:
        ("tpe_face_key_1", "0x0000000f45041105241acd2b5a66a86900000000001e98310000000000000000"),
        ("tpe_face_key_2", "0x0000000000002001355335371861249200000000001c96520000000000000000"),
This one was only to try if it works. I don't know how i can set two face keys to set random face between them and it is one of my question. The other question is;
This operation didnt work correctly. That tpe_face_key_1 is Harlaus's face(just to try) and the operation set for all troops (":troop_no") same default face with long red hair instead of Harlaus's face.
Does anyone know how this troop_set_face_keys operation is used or what else i can do to do what i want?
 
litdum said:
Is it possible to create faces (keys) for troops in scripts.py?

check VC modules if you don't have a updated 1.168 header_operations.py. There are operations to copy the face, beard, hair, age, .... Remember you need to set key_1 and key_2 (for the random range) or force key_2 as zero (not random)

Code:
str_store_player_face_keys            = 2747 # (str_store_player_face_keys, <string_no>, <player_id>), #Stores <player_id>'s face key into string.
player_set_face_keys                  = 2748 # (player_set_face_keys, <player_id>, <string_no>), #Sets <player_id>'s face keys from string.
str_store_troop_face_keys             = 2750 # (str_store_troop_face_keys, <string_no>, <troop_no>, [<alt>]), #Stores <troop_no>'s face key into string. if [<alt>] is non-zero the second pair of face keys is stored
troop_set_face_keys                   = 2751 # (troop_set_face_keys, <troop_no>, <string_no>, [<alt>]), #Sets <troop_no>'s face keys from string. if [<alt>] is non-zero the second pair of face keys is set.
face_keys_get_hair                    = 2752 # (face_keys_get_hair, <destination>, <string_no>), #Stores face key's hair value into <destination>
face_keys_set_hair                    = 2753 # (face_keys_set_hair, <string_no>, <value>), #Sets face key's hair value
face_keys_get_beard                   = 2754 # (face_keys_get_beard, <destination>, <string_no>), #Stores face key's beard value into <destination>
face_keys_set_beard                   = 2755 # (face_keys_set_beard, <string_no>, <value>), #Sets face key's beard value
face_keys_get_face_texture            = 2756 # (face_keys_get_face_texture, <destination>, <string_no>), #Stores face key's face texture value into <destination>
face_keys_set_face_texture            = 2757 # (face_keys_set_face_texture, <string_no>, <value>), #Sets face key's face texture value
face_keys_get_hair_texture            = 2758 # (face_keys_get_hair_texture, <destination>, <string_no>), #Stores face key's hair texture value into <destination>
face_keys_set_hair_texture            = 2759 # (face_keys_set_hair_texture, <string_no>, <value>), #Sets face key's hair texture value
face_keys_get_hair_color              = 2760 # (face_keys_get_hair_color, <destination>, <string_no>), #Stores face key's hair color value into <destination>
face_keys_set_hair_color              = 2761 # (face_keys_set_hair_color, <string_no>, <value>), #Sets face key's hair color value
face_keys_get_age                     = 2762 # (face_keys_get_age, <destination>, <string_no>), #Stores face key's age value into <destination>
face_keys_set_age                     = 2763 # (face_keys_set_age, <string_no>, <value>), #Sets face key's age value
face_keys_get_skin_color              = 2764 # (face_keys_get_skin_color, <destination>, <string_no>), #Stores face key's skin color value into <destination>
face_keys_set_skin_color              = 2765 # (face_keys_set_skin_color, <string_no>, <value>), #Sets face key's skin color value
face_keys_get_morph_key               = 2766 # (face_keys_get_morph_key, <destination>, <string_no>, <key_no>), #Stores face key's morph key value (0-7) into <destination>
face_keys_set_morph_key               = 2767 # (face_keys_set_morph_key, <string_no>, <key_no>, <value>), #Sets face key's morph key value (0-7)

as this was mostly done by the engine (so we couldnt see it on modsys), you need to experiment with the combination of operations to see how you can get your end result. I remember when I played with this that I had to create a script that used multiple operations together to create the face I wanted. But that was back in 1.161 ish, so not sure how it works with 1.168.
 
How can i "assign" agent to variable?
So i can lets say measure distance between player agent and that agent.
As in my case he will be only instance of that troop if that helps.
I found some kind of code in belligerent drunk script which used
try for agents and stored all agents in variable and then checked is variable equal to lets say trp_nord.
But when i use it i get in game error invalid agent id..
But i will fix that myself now i just want answer to first question...  :grin:

EDIT:

Code:
(get_player_agent_no, ":plyr"),
		 (try_for_agents, ":agent"),
		  (agent_get_troop_id, ":agent_id", ":agent"),
		  (eq, ":agent_id", "trp_nord"),
Is this only way to get trp_nord assigned to :agent_id (i know that he is not really assigned this just stoped loop at him i guess?)
 
DarkNord said:
How can i "assign" agent to variable?

agent != troop
troop != agent

agent is a instance (made based on) of a troop

you can't use a agent operation on a troop. You can't use a troop operation on a agent. You do have operations to convert one to the other.

Troop #10: agents #1, #20, #50, #88 --> operation will tell you that the troop of agent #20 is #10.

"How can I assign agents to a variable?"
They are referenced by a numeric value. Local, global, registers are numeric. So just assign them, no trick needed here

"How do I loop all agents?"
Use the "try_for_agents" operation. Destination is your variable. Remember this operation should be filtered by radius if possible.

A quick search on Native (or any module) will give you plenty of examples of its usage (without filter). VC has examples with the filter on.

Code:
(try_for_agents, ":cur_agent"),
  #do stuff with each agent
(try_end),
 
Yeah you dont understand me.
Lets say it this way How can i get agents id

Just assign them?
Well
Code:
(assign,":leader","what should go here?most probably agent id but how to get it?"

Code:
I understand it as this 
(try_for_agents,":all_agents"), #this will have all agents id's stored in :all_agents and they will be readily waiting to be taken from there??
(agent_get_troop_id,":agent_type",":all_agents") #what this does?
(eq,":agent_type","trp_kudjd")#this makes rest of code affect only instances of trp_kudjd???
 
DarkNord said:
Yeah you dont understand me.
Lets say it this way How can i get agents id

Just assign them?

I did, young padawan. But you are missing some concepts. So lets continue with the discussion:

1) Depends. Agent ID is a reference. So you need to examine your current case and with it check where to get that reference

A example: if you want the agent ID that just got hit by a sword -> you will use a specific trigger, which has as a entry parameter that is the agent ID

2) The loop works almost like that. The problem is here: ":all_agents"
So lets examine what a loop is -> say you have 20 agents in a scene. Agent #1, #2, ..., #20

By using the loop "try_for_agents" you will get each agent ID, one at time, in order. So the first iteration is for agent #1. When that is done, you will get agent #2, ... until #20.

So your variable is ":agent_ID" (note that the name doesn't matter, its just a text reference for humans, I am talking about the actual value inside it).

3) What the operation get_troop_id does? Its gives you the troop... ID  :mrgreen:

Say you have troop => "trp_nord_recruit". Check file ID_troops.py and you will see this: "trp_nord_recruit = 40". That means that troop ID is #40.

Now read my post again. A agent is made of a troop. So if, as a example, agent #10 is made from "trp_nord_recruit", if you use that operation, the answer will be... 40.
 
How does one limit the distance to which certain sounds can be heard? Ive replaced some voices used by bots but unlike in native their voices can be heard anywhere on the map, which is pretty annoying as theyre mostly grunts for pain and deathcries.
 
MongolFromForest said:
How does one limit the distance to which certain sounds can be heard? Ive replaced some voices used by bots but unlike in native their voices can be heard anywhere on the map, which is pretty annoying as theyre mostly grunts for pain and deathcries.
Unless you didn't change any sound flags, there's no difference.

You could try to lower the base priority of the specific sounds to achieve some kind of distant limit (priority decreases with distance).
Code:
# sound priority of 0-256 (0 hightest 256 lowest) calculated as such:
# float pf = (base_dist / (base_dist + dist)) * ((1.0f - priority_effect) + priority_effect * (priority_squared ? get_priority() * get_priority() : get_priority()));
# sounds prio lower then 225 override other sounds in the list with lowest priority.
sound_base_dist = 3.5
sound_priority_effect = 0.45
sound_priority_squared = 1
log_sound_priority = 0
However it wont be a real distant limit as you might prefer.
Sounds will still be played, but it's more likely that these will get overwritten by higher priority sounds.
 
EmielRegis said:
Kaasovic said:
Hai,

I'm trying to code a dynamically generated health bar above a agent. So for the basics are done, but I am kinda stuck at the moment.

Did anyone every tried to code the same thing? Tried to search it, but couldn't find anything

If not I hope you can help me out with the following code,

Currently only shows up for just 1 agent (needs to be all the agents withing the 50mtr distance of the player).
I also have less knowledge about setting the positions right for the health bar, kinda want them floating above a players head and make the bar smaller if the distance increases. (currently hovers somewhere near the feet of the agent and does not get smaller when the distance is larger)

Code:
	 ("update_health_bars", [
		(set_fixed_point_multiplier, 1000),
		(get_player_agent_no, ":my_agent_id"),
		(agent_get_position, pos0, ":my_agent_id"),
		#(try_for_players, ":player_id", 1),
		(try_for_agents, ":agent_id"),
			(neq, ":my_agent_id", ":agent_id"),
			#(player_is_active, ":player_id"),
			#(player_get_agent_id, ":agent_id", ":player_id"),
			(agent_is_human, ":agent_id"),
			(agent_is_alive, ":agent_id"),
			(agent_get_position, pos1, ":agent_id"),
			(position_move_z, pos1, 150),
			(get_distance_between_positions_in_meters, ":dist", pos0, pos1),
			(try_begin),
				#in range of player
				(lt, ":dist", 50),
				(position_get_screen_projection, pos0, pos1),
				(store_agent_hit_points, ":health", ":agent_id", 0),
				(create_progress_overlay, reg0, 0, 100),
				(overlay_set_val, reg0, ":health"),
				(overlay_set_position, reg0, pos0),
				(position_get_x, ":pos0_x", pos0),
				(val_add, ":pos0_x", ":dist"),
				(position_set_x, pos0, ":pos0_x"),
				(overlay_set_size, reg0, pos0),
			(try_end),
		(try_end),
		(try_begin),
			(key_clicked, key_b),
			(display_message, "@script stopped"),
		(else_try),
			(start_presentation, "prsnt_kaasovic_show_player_health"),
		(try_end),
	 ]),

Really hope you lot can help me out.

Thanks

This presentation shows health of horses if they have rider. Im sure you will find some usefull stuff in there, as showing agent health needs just small modification.

Code:
  ("display_agent_health", prsntf_read_only|prsntf_manual_end_only, 0,   display player name and optionally faction name above the heads of nearby agents    emiel
     
	 [(ti_on_presentation_load,
       [(assign, "$g_presentation_agent_labels_overlay_count3", 0),
        (assign, "$g_presentation_agent_labels_update_time3", 0),
        (presentation_set_duration, 999999),
        ]),
		
      (ti_on_presentation_run,
       [(store_trigger_param_1, ":current_time"),
     
	    (set_fixed_point_multiplier, 1000),
        (try_begin),
          (eq, "$g_display_labels", 0),
          (presentation_set_duration, 0),
        (else_try),
         
		  (gt, ":current_time", "$g_presentation_agent_labels_update_time3"),
          (store_add, "$g_presentation_agent_labels_update_time3", ":current_time", 20),   check and update all visible labels every 20 milliseconds
          (multiplayer_get_my_player, ":my_player"),
          (gt, ":my_player", -1),
          (str_clear, s0),
          (mission_cam_get_position, pos11),
		 
          (assign, ":overlay_id2", 0),
          (try_for_agents, ":agent_id"),
         
		  
		    (agent_is_human, ":agent_id"),
            (agent_is_alive, ":agent_id"),
            (agent_get_player_id, ":player_id", ":agent_id"),
            (neq, ":player_id", ":my_player"),
            (agent_get_item_slot, ":body_item_id", ":agent_id", 5),
            (neq, ":body_item_id", "itm_invisible_body"),
            (agent_get_position, pos12, ":agent_id"),
		   
            (assign, reg1, ":agent_id"),
		    (display_message,"@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" ),
		    (display_message,"@agent: {reg1}" ),

		

		 
		 
		 
		 
		 
		   (position_move_z, pos12, 240),
            (agent_get_horse, ":horse", ":agent_id"),
            (try_begin),
              (ge, ":horse", 0),
              (position_move_z, pos12, 80),
            (try_end),
            (get_sq_distance_between_positions, ":sq_distance", pos11, pos12),
            (le, ":sq_distance", 2250000),
		   
            (copy_position, pos11, pos12),
            (position_move_z, pos11, 50),
            (position_get_screen_projection, pos12, pos11),   get the 2D position on screen 50 above the 3D position of the agent
            (position_get_x, ":x_pos", pos12),
            (position_get_y, ":y_pos", pos12),
            (is_between, ":x_pos", -100, 1100),   check if inside the view boundaries or nearly so
            (is_between, ":y_pos", -100, 850),
            (position_has_line_of_sight_to_position, pos11, pos12),
            (try_begin),   create a new overlay if needed
		  
              (ge, ":overlay_id2", "$g_presentation_agent_labels_overlay_count3"),
              (create_text_overlay, reg0, s0, tf_center_justify|tf_with_outline),
              (val_add, "$g_presentation_agent_labels_overlay_count3", 1),
            (try_end),
          
		    (try_begin),
              (try_begin),
				  (player_is_active, ":player_id"),
				  (agent_get_horse, ":horse", ":agent_id"),
				  (ge, ":horse", 0),
				  (store_agent_hit_points, ":hp", ":horse"),
				  (store_agent_hit_points, ":hp", ":agent_id"),
				
				  (assign, reg60, ":hp"),
				  (display_message,"@hp: {reg60}"),
				
				  (try_begin),
					  (eq, ":hp", 100),
					  (assign, ":color", 0x00CC00),
					  (str_store_string, s62, "@ |||||||||||||||||||| "),
				  (else_try),	
					  (le, ":hp", 90),
					  (ge, ":hp", 80),
					  (assign, ":color", 0x00CC00),
					  (str_store_string, s62, "@ ||||||||||||||||||    "),
				  (else_try),	
					  (le, ":hp", 79),
					  (ge, ":hp", 70),
					  (assign, ":color", 0x00CC00),
					  (str_store_string, s62, "@ ||||||||||||||||      "),
				  (else_try),	
					  (le, ":hp", 69),
					  (ge, ":hp", 60),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||||||||        "),
				  (else_try),	
					  (le, ":hp", 59),
					  (ge, ":hp", 50),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||||||          "),
				  (else_try),	
					  (le, ":hp", 49),
					  (ge, ":hp", 40),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||||            "),
				  (else_try),	
					  (le, ":hp", 39),
					  (ge, ":hp", 30),
					  (assign, ":color", 0xFF9900),
					  (str_store_string, s62, "@ ||||||||              "),
				  (else_try),	
					  (le, ":hp", 29),
					  (ge, ":hp", 20),
					  (assign, ":color", 0xFF0033),
					  (str_store_string, s62, "@ ||||||                "),
				  (else_try),	
					  (le, ":hp", 19),
					  (ge, ":hp", 10),
					  (assign, ":color", 0xFF0033),
					  (str_store_string, s62, "@ ||||                  "),
				  (else_try),	
					  (lt, ":hp", 10),
					
					  (assign, ":color", 0xFF0033),
					  (str_store_string, s62, "@ ||                    "),
				  (try_end),
			  (else_try),
				  (str_clear, s62),
			  (try_end),
             
			  (assign, reg1, ":overlay_id2"),
		   
		      (display_message,"@overlay: {reg1}"),
			
			  (overlay_set_text, ":overlay_id2", s62),
              (overlay_set_color, ":overlay_id2", ":color"),
              (overlay_set_position, ":overlay_id2", pos12),
              (copy_position, pos13, pos12),
              (position_move_z, pos13, 200),   move the 3D position up by 200 and check the 2D distance moved, to get the appropriate text size (reducing with distance)
              (position_get_screen_projection, pos14, pos13),
              (position_get_y, ":y_pos_up", pos14),
              (store_sub, ":height", ":y_pos_up", ":y_pos"),
              (val_mul, ":height", 10),
              (val_max, ":height", 2000),
			  (val_min, ":height", 1000),
              (position_set_y, pos14, ":height"),
              (position_set_x, pos14, ":height"),
              (overlay_set_size, ":overlay_id2", pos14),
              (overlay_set_display, ":overlay_id2", 1),
            (try_end),
            (val_add, ":overlay_id2", 1),
          (try_end),
          (try_begin),
		 
            (store_sub, ":redraw_threshold", "$g_presentation_agent_labels_overlay_count3", 10),
            (lt, ":overlay_id2", ":redraw_threshold"),
            (presentation_set_duration, 0),
            (start_presentation, "prsnt_display_agent_labels"),
          (else_try),
            (try_for_range, ":unused_overlay_id", ":overlay_id2", "$g_presentation_agent_labels_overlay_count3"),
		   
              (overlay_set_display, ":unused_overlay_id", 0),
            (try_end),
          (try_end),
        (try_end),
        ]),
      ]),

Ah yes, this helped me a whole lot! Thanks!

Only problem I have now is setting the size of the generated overlay is kinda glitchy.
When you look to the left while a overlay is on screen, it will resize it in a weird way, almost inverting it.

Any guides on dynamically adjustable sizes for overlays?
 
Does anyone know why a model would look like this in open.brf?

model%20issue_zpszxaochcy.png


It has all the correct files in material and textures as well as the mod folder.
 
MongolFromForest said:
How does one limit the distance to which certain sounds can be heard?

adding to @_Sebastian_ reply:

1) compare your new sound files with the Native ones. You may have them on a different volume. You may also encounter some issues with specific sounds effects, some of them have hardcoded settings that can create weird effects if you change the file.

2) check the flags you are using in module_sounds.py like priority, volume, and 2D x 3D sounds

3) are you playing the sounds using operations? If so, post your code here (from your mission template triggers/scripts)
 
Nameless Warrior said:
kraggrim said:
The normal map is probably saved in the wrong dxt format (should be dxt1 afaik).

Thank you that looks to be the issue. It is saved in DXT 3 (sharp alpha). Is there an easy way to switch the format?

Not that I know of, I just open in photoshop and resave. If you don't have that (or gimp) with the dds plugin just send it to me and I'll do it (my photoshop appears to be working today, :party: miracle).
 
Yeah you have it in photoshop's dropdown menu while saving...
Now one more question

If i use agent set team operation and in mst entries entry of that agent was for team 2 and i assign him to team 3 does it matter that it was team 2?Or i shouldnt pt that flag at all?

And how would i seperate agents from same type like this

Imagine player against 10 nord recruits in scene andafter 5 secs in battle i want 6 of them to change their minds and help player so thats operation Agent set team but to which agent?

Do i get all 6 agents ID and set team one by one or there is easier way?

And about that operation i know what get troop id does but agent get... Does this get id of troop of which agent is instance.(So thats my error in code probably.  do i need to define id of my new troops in Id_troop?As im using new hero in my scene?)


And thanks Kalarhan (my Jedi Master) for great help,sorry for you time... :cool:
 
Status
Not open for further replies.
Back
Top Bottom