Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Are you using the Diplomacy mod? in this mod there is a trigger that controls the creation of patrols for the different factions...
(eq, ":party_type", spt_kingdom_patrol), if the constant has not been established/set , it is unlikely that the conditional operation will be true.
To set patrol names: 'party_set_name'

 
Alright guys, here's my question: how to compile module system data files (ground specs, skyboxes and flora kinds). It's written in "STEPS.txt" to run all *py files and then paste newely generated skyboxes, flora kinds and ground specs .txt files in module Data folder. But the problem is that these data *py files ARE NOT compiling anyway
 
Dj_FRedy said:
Copy the content to the source folder.
Add to the build_module.bat file:
Code:
python Flora_kinds.py
python Ground_specs.py
python Skyboxes.py
Thanks alot, your advice really helpful! I had to redact ground_specs.py "process block" for the correct path to header_ground_types.py though, but now everything working just fine
 
Dj_FRedy said:
Are you using the Diplomacy mod? in this mod there is a trigger that controls the creation of patrols for the different factions...
(eq, ":party_type", spt_kingdom_patrol), if the constant has not been established/set , it is unlikely that the conditional operation will be true.
To set patrol names: 'party_set_name'

No, the constant is set, as it should be. There are no errors, not compiling and not in the way they patrol. The problem is that the have their status as 'patrolling' around the player and that those new patrols are treated as the player's patrols, while at the same time being another kingdom's patrols. Also, my patrols are initiated by their own trigger, separate to the Diplomacy ones.
 
Ok, I understand then that you have changed 'spt_pratol' to 'spt_kingdom_patrol'...
The problem is that the have their status as 'patrolling' around the player
Give the patrols a target to patrol, a center, a party, right now their target is '0' (the player).
 
Heh, didn't think of that.  :razz:
As for the constant, no, I didn't change the existing constant of spt_patrol, I wanted those two to coexist. I simply made another constant, a new one. Then, to each place that the scripts called for that, I simple put my new constant.
 
Is there some tool that makes editing strings.txt easier? I know about modifying the mod_sys, but not all mods make the mod_sys available, and I want to make some smaller changes to a particular mod, because the next update is forever-in-the-works. Modifying troops and items is not a problem, thanks to Morgh's Tool, but modifying strings tends to mess them up. So, any suggestions?
 
kalarhan said:
Corbul said:
any suggestions?

create a language pack for translations (windowed mode, see options). Move it to that module language folder. Change/translate from the .csv files.
But I don't want to make a translation, just to edit strings by changing the native companion strings so they fit the setting better (because they mod's devs never got to it originally).
 
I'm trying to code a dynamically generated health bar above a agent. Rubik's custom commander had this but i don't know put it in multiplayer.
It worked but i press tab  or prsnt_multiplayer_escape_menu, choice faction... then game crash .I hope you can help me. Thank you!
Module mission_templates.py
Code:
common_battle_order_panel_tick = (
  0, 0, 0, [],
  [
    (try_begin),
      (neg|is_presentation_active, "prsnt_mini_map"),
      (start_presentation, "prsnt_mini_map"),
    (try_end),
    (try_begin),
      (is_presentation_active, "prsnt_mini_map"),
      (neg|is_presentation_active, "prsnt_multiplayer_escape_menu"),
      (neg|is_presentation_active, "prsnt_multiplayer_team_select"),
      (neg|is_presentation_active, "prsnt_multiplayer_stats_chart_deathmatch"),
      (neg|is_presentation_active, "prsnt_multiplayer_stats_chart"),
      (call_script, "script_update_agent_hp_bar"),
    (try_end),
    ])

Module script.py
Code:
("update_agent_hp_bar",
   [
    (set_fixed_point_multiplier, 1000),
  
    (get_player_agent_no, ":player_agent"),
    (try_for_agents,":agent_no"),
      (agent_is_human, ":agent_no"),
      (neq, ":agent_no", ":player_agent"),
      (agent_get_slot, ":agent_hp_overlay", ":agent_no", slot_agent_hp_bar_overlay_id),
      (agent_get_slot, ":agent_hp_bg_overlay", ":agent_no", slot_agent_hp_bar_bg_overlay_id),
      #(agent_get_slot, ":agent_name_overlay", ":agent_no", slot_agent_name_overlay_id),
      (try_begin),
        (agent_is_alive, ":agent_no"),
        # (agent_get_slot, ":agent_hp_overlay", ":agent_no", slot_agent_hp_bar_overlay_id),
        # (agent_get_slot, ":agent_hp_bg_overlay", ":agent_no", slot_agent_hp_bar_bg_overlay_id),
        # (agent_get_slot, ":agent_name_overlay", ":agent_no", slot_agent_name_overlay_id),
        
        (assign, ":create_hp_bar", 0),
        #(assign, ":create_name", 0),
        (try_begin), # create or not
          (agent_is_ally, ":agent_no"),
          (assign, ":create_hp_bar", 1),
          #(assign, ":create_name", "$g_name_of_ally"),
        (else_try),
          (assign, ":create_hp_bar", 1),
          #(assign, ":create_name", "$g_name_of_enemy"),
        (try_end),
        
        (try_begin),
          (le, ":agent_hp_overlay", 0),
          (le, ":agent_hp_bg_overlay", 0),
          #(le, ":agent_name_overlay", 0),
          (set_fixed_point_multiplier, 1000),
          (try_begin),
            (eq, ":create_hp_bar", 1),
            # hp bg
            (create_mesh_overlay, reg1, "mesh_white_plane"),
            (overlay_set_alpha, reg1, 0x44),
            (agent_set_slot, ":agent_no", slot_agent_hp_bar_bg_overlay_id, reg1),
            (assign, ":agent_hp_bg_overlay", reg1),
            # hp
            (create_mesh_overlay, reg1, "mesh_white_plane"),
            (overlay_set_alpha, reg1, 0x44),
            (agent_set_slot, ":agent_no", slot_agent_hp_bar_overlay_id, reg1),
            (assign, ":agent_hp_overlay", reg1),
          (try_end),
          # (try_begin),
            # (eq, ":create_name", 1),
            ## name
            # (agent_get_troop_id, ":troop_id", ":agent_no"),
            # (str_store_troop_name, s1, ":troop_id"),
            # (create_text_overlay, reg1, "@{s1}", tf_center_justify),
            # (overlay_set_alpha, reg1, 0xCC),
            # (agent_set_slot, ":agent_no", slot_agent_name_overlay_id, reg1),
            # (assign, ":agent_name_overlay", reg1),
          # (try_end),
        (try_end),
        
        # color
        (agent_get_team, ":player_team", ":player_agent"),
        (agent_get_team, ":agent_team", ":agent_no"),
        (agent_get_troop_id, ":troop_id", ":agent_no"),
        (try_begin),
          (eq, ":agent_team", ":player_team"),
          (assign, ":dest_color", 0x00FF00),
        (else_try),
          (agent_is_ally, ":agent_no"),
          (assign, ":dest_color", 0x0000FF),
        (else_try),
          (troop_is_hero, ":troop_id"),
          (assign, ":dest_color", 0xFFFF00),
        (else_try),
          (assign, ":dest_color", 0xFF0000),
        (try_end),
        (try_begin),
          (gt, ":agent_hp_overlay", 0),
          (gt, ":agent_hp_bg_overlay", 0),
          (overlay_set_color, ":agent_hp_overlay", ":dest_color"),
          (overlay_set_color, ":agent_hp_bg_overlay", 0x000000),
        (try_end),
        # (try_begin),
          # (gt, ":agent_name_overlay", 0),
          # (overlay_set_color, ":agent_name_overlay", ":dest_color"),
        # (try_end),
        
        # size & position
        # (this_or_next|gt, ":agent_name_overlay", 0),
        (gt, ":agent_hp_overlay", 0),
        
        # (agent_get_position, pos1, ":agent_no"),
        # (agent_get_horse, ":horse_agent", ":agent_no"),
        # (try_begin),
          # (ge, ":horse_agent", 0),
          # (position_move_z, pos1, 280, 1),
        # (else_try),
          # (position_move_z, pos1, 180, 1),
        # (try_end),
        (agent_get_bone_position, pos1, ":agent_no", 9, 1),
        (position_move_z, pos1, 30, 1),
        
        (position_get_screen_projection, pos2, pos1),
        (position_get_x, ":head_x_pos", pos2),
        (position_get_y, ":head_y_pos", pos2),
        # base size
        (copy_position, pos6, pos1),
        (copy_position, pos7, pos1),
        (position_move_z, pos7, 100, 1),
        (position_get_screen_projection, pos6, pos6),
        (position_get_screen_projection, pos7, pos7),
        (position_get_y, ":screen_y_pos_1", pos6),
        (position_get_y, ":screen_y_pos_2", pos7),
        (store_sub, ":base_x", ":screen_y_pos_2", ":screen_y_pos_1"),
        (val_mul, ":base_x", 3),
        (val_div, ":base_x", 4),
        (val_clamp, ":base_x", 20, 161),
        (store_div, ":base_y", ":base_x", 20),
        (try_begin),
          (is_between, ":head_x_pos", -100, 1100),
          (is_between, ":head_y_pos", -100, 850),
          #(agent_get_position, pos3, ":agent_no"),
          #(agent_get_position, pos4, ":player_agent"),
          (try_begin),
            (agent_is_alive, ":player_agent"),
            (agent_get_bone_position, pos3, ":player_agent", 9, 1),
          (else_try),
            (agent_get_position, pos3, ":player_agent"),
          (try_end),
          (position_move_z, pos3, 30, 1),
          (position_has_line_of_sight_to_position, pos1, pos3),
          (get_distance_between_positions_in_meters, ":distance", pos1, pos3),
          (try_begin),
            (troop_is_hero, ":troop_id"),
            (val_div, ":distance", 2),
          (try_end),
          (le, ":distance", 80),
          # agent no
          # (agent_get_horse, ":horse_agent", ":agent_no"),
          # (try_begin),
            # (ge, ":horse_agent", 0),
            # (position_move_z, pos3, 280, 1),
          # (else_try),
            # (position_move_z, pos3, 180, 1),
          # (try_end),
          # player agent
          # (agent_get_horse, ":player_horse", ":player_agent"),
          # (try_begin),
            # (ge, ":player_horse", 0),
            # (position_move_z, pos4, 280, 1),
          # (else_try),
            # (position_move_z, pos4, 180, 1),
          # (try_end),

          (try_begin),
            (gt, ":agent_hp_overlay", 0),
            (gt, ":agent_hp_bg_overlay", 0),
            ## hp bg & hp
            # position
            (assign, ":x_offset", ":base_x"),
            (val_div, ":x_offset", 2),
            (store_sub, ":hp_x", ":head_x_pos", ":x_offset"),
            (position_set_x, pos1, ":hp_x"),
            (position_set_y, pos1, ":head_y_pos"),
            (overlay_set_position, ":agent_hp_bg_overlay", pos1),
            (overlay_set_position, ":agent_hp_overlay", pos1),
            # alpha
            (overlay_set_alpha, ":agent_hp_bg_overlay", 0x66),
            (overlay_set_alpha, ":agent_hp_overlay", 0x44),
            # hp bg size
            (store_mul, ":bg_width", ":base_x", 50),
            (store_mul, ":bg_height", ":base_y", 50),
            (position_set_x, pos1, ":bg_width"),
            (position_set_y, pos1, ":bg_height"),
            (overlay_set_size, ":agent_hp_bg_overlay", pos1),
            # hp size
            (store_agent_hit_points, ":agent_hp",":agent_no"),
            (store_mul, ":hp_width", ":agent_hp", 50),
            (val_mul, ":hp_width", ":base_x"),
            (val_div, ":hp_width", 100),
            (val_min, ":hp_width", ":bg_width"),
            (position_set_x, pos1, ":hp_width"),
            (position_set_y, pos1, ":bg_height"),
            (overlay_set_size, ":agent_hp_overlay", pos1),
          (try_end),
            
          # name
          # (try_begin),
            # (gt, ":agent_name_overlay", 0),
            # (assign, ":name_x", ":head_x_pos"),
            # (store_add, ":name_y", ":head_y_pos", 5),
            # (position_set_x, pos1, ":name_x"),
            # (position_set_y, pos1, ":name_y"),
            # (overlay_set_position, ":agent_name_overlay", pos1),
            # (store_mul, ":name_size", ":base_x", 9),
            # (position_set_x, pos1, ":name_size"),
            # (position_set_y, pos1, ":name_size"),
            # (overlay_set_size, ":agent_name_overlay", pos1),
            # (overlay_set_alpha, ":agent_name_overlay", 0xCC),
          # (try_end),
        (else_try),
          (overlay_set_alpha, ":agent_hp_overlay", 0),
          (overlay_set_alpha, ":agent_hp_bg_overlay", 0),
          # (overlay_set_alpha, ":agent_name_overlay", 0),
        (try_end),
      (else_try),
        (try_begin),
          (gt, ":agent_hp_overlay", 0),
          (gt, ":agent_hp_bg_overlay", 0),
          (overlay_set_alpha, ":agent_hp_overlay", 0),
          (overlay_set_alpha, ":agent_hp_bg_overlay", 0),
        (try_end),
        # (try_begin),
          # (gt, ":agent_name_overlay", 0),
          # (overlay_set_alpha, ":agent_name_overlay", 0),
        # (try_end),
        (agent_set_slot, ":agent_no", slot_agent_hp_bar_overlay_id, 0),
        (agent_set_slot, ":agent_no", slot_agent_hp_bar_bg_overlay_id, 0),
        #(agent_set_slot, ":agent_no", slot_agent_name_overlay_id, 0),
      (try_end),
    (try_end),
  ]),
 
Dj_FRedy said:
Your 'rgl_log' shows something of why it crashes?
My 'rgl_log' shows :
Code:
 SCRIPT WARNING ON OPCODE 1770: Invalid Agent ID: -1; LINE NO: 32: 
 At script: update_agent_hp_bar. At script: update_agent_hp_bar. SCRIPT WARNING ON OPCODE 1702: Invalid Agent ID: -1; LINE NO: 75: 
 At script: update_agent_hp_bar. At script: update_agent_hp_bar. SCRIPT WARNING ON OPCODE 2076: Invalid Agent ID: -1; LINE NO: 76:
Please help me. Thank you!
 
The log shows different warnings, which on the other hand, even though they are only warnings, cannot be ignored. There are operations in the script not valid for the muti-mode of MBW...
In other words, the script you are using is not made to work in MBW multiplayer mode, you will have to adapt/modify it with the different operations that the multiplayer does support.

If you don't know how to adapt/modify the script, if that's the case, you can visit the documentation & tutorials area of this forum, you will find an ocean of information that will certainly be very useful when modifying the game files.
 
[Bcw]Btm_Earendil said:
get_player_agent_no for example is an operation only getting used at singleplayer, it should be agent_get_player_id (I think, not sure at the moment). Check header_operations for this.
It not worked. I don't know how to fix it.
Module script:
Code:
#$script HP bar
 ("set_hp_bar",
   [
    (set_fixed_point_multiplier, 1000),
	
    (multiplayer_get_my_player, ":my_player"),
    (multiplayer_get_my_team,":my_team"),     
    (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_slot, ":agent_hp_overlay", ":agent_id", slot_agent_hp_bar_overlay_id),
      (agent_get_slot, ":agent_hp_bg_overlay", ":agent_id", slot_agent_hp_bar_bg_overlay_id),      
      (try_begin),      
        (try_begin),
          (le, ":agent_hp_overlay", 0),
          (le, ":agent_hp_bg_overlay", 0),        
          (set_fixed_point_multiplier, 1000),
          (try_begin),           
            # hp bg
            (create_mesh_overlay, reg1, "mesh_white_plane"),
            (overlay_set_alpha, reg1, 0x44),
            (agent_set_slot, ":agent_id", slot_agent_hp_bar_bg_overlay_id, reg1),
            (assign, ":agent_hp_bg_overlay", reg1),
            # hp
            (create_mesh_overlay, reg1, "mesh_white_plane"),
            (overlay_set_alpha, reg1, 0x44),
            (agent_set_slot, ":agent_id", slot_agent_hp_bar_overlay_id, reg1),
            (assign, ":agent_hp_overlay", reg1),
          (try_end),
        (try_end),
        
        # color		       
        (agent_get_team, ":agent_team", ":agent_id"),
        (agent_get_troop_id, ":troop_id", ":agent_id"),
        (try_begin),         
            (this_or_next|eq,":troop_id","trp_luubi"),
            (eq,":troop_id","trp_taothao"),                                
            (assign, ":dest_color", 0xFFE500),
            (else_try),
            (eq, ":agent_team", ":my_team"),
            (assign, ":dest_color", 0x00FF00),
            (else_try),
            (assign, ":dest_color", 0xFF0000),#$0xFF0000 do 
        (try_end),
        
        (try_begin),
          (gt, ":agent_hp_overlay", 0),
          (gt, ":agent_hp_bg_overlay", 0),
          (overlay_set_color, ":agent_hp_overlay", ":dest_color"),
          (overlay_set_color, ":agent_hp_bg_overlay", 0x000000),
        (try_end),
		
        (gt, ":agent_hp_overlay", 0),
        
        (agent_get_position, pos1, ":agent_id"),
        (agent_get_horse, ":horse_agent", ":agent_id"),
        (try_begin),
          (ge, ":horse_agent", 0),
          (position_move_z, pos1, 280, 1),
        (else_try),
          (position_move_z, pos1, 180, 1),
        (try_end),
        (position_get_screen_projection, pos3, pos1),
        (position_get_x, ":head_x_pos", pos3),
        (position_get_y, ":head_y_pos", pos3),
        # base size
        (copy_position, pos6, pos1),
        (copy_position, pos7, pos1),
        (position_move_z, pos7, 100, 1),
        (position_get_screen_projection, pos6, pos6),
        (position_get_screen_projection, pos7, pos7),
        (position_get_y, ":screen_y_pos_1", pos6),
        (position_get_y, ":screen_y_pos_2", pos7),
        (store_sub, ":base_x", ":screen_y_pos_2", ":screen_y_pos_1"),
        (val_mul, ":base_x", 3),
        (val_div, ":base_x", 4),
        (val_clamp, ":base_x", 20, 161),
        (store_div, ":base_y", ":base_x", 15),#$hpbar 20
        (try_begin),
          (is_between, ":head_x_pos", -100, 1100),
          (is_between, ":head_y_pos", -100, 850),
          (agent_get_position, pos2, ":agent_id"),
          (agent_get_position, pos4, ":my_player"),
          (get_distance_between_positions_in_meters, ":distance", pos2, pos4),
          (le, ":distance", 80),#$"$g_hp_bar_dis_limit"
          # agent no
          (agent_get_horse, ":horse_agent", ":agent_id"),
          (try_begin),
            (ge, ":horse_agent", 0),
            (position_move_z, pos2, 280, 1),
          (else_try),
            (position_move_z, pos2, 180, 1),
          (try_end),
          # player agent
          (agent_get_horse, ":my_horse", ":my_player"),
          (try_begin),
            (ge, ":my_horse", 0),
            (position_move_z, pos4, 280, 1),
          (else_try),
            (position_move_z, pos4, 180, 1),
          (try_end),
          (position_move_z, pos2, 50, 1),
          (position_move_z, pos4, 50, 1),
          (position_has_line_of_sight_to_position, pos2, pos4),

          (try_begin),
            (gt, ":agent_hp_overlay", 0),
            (gt, ":agent_hp_bg_overlay", 0),
            ## hp bg
            (assign, ":x_offset", ":base_x"),
            (val_div, ":x_offset", 2),
            (val_add, ":x_offset", 1),
            (store_sub, ":hp_bg_x", ":head_x_pos", ":x_offset"),
            (store_sub, ":hp_bg_y", ":head_y_pos", 1),
            (position_set_x, pos1, ":hp_bg_x"),
            (position_set_y, pos1, ":hp_bg_y"),
            (overlay_set_position, ":agent_hp_bg_overlay", pos1),
            (store_add, ":bg_width", ":base_x", 2),
            (val_mul, ":bg_width", 50),
            (store_add, ":bg_height", ":base_y", 2),
            (val_mul, ":bg_height", 50),
            (position_set_x, pos1, ":bg_width"),
            (position_set_y, pos1, ":bg_height"),
            (overlay_set_size, ":agent_hp_bg_overlay", pos1),
            (overlay_set_alpha, ":agent_hp_bg_overlay", 0x44),
            ## hp
            (store_add, ":hp_x", ":hp_bg_x", 1),
            (store_add, ":hp_y", ":hp_bg_y", 1),
            (position_set_x, pos1, ":hp_x"),
            (position_set_y, pos1, ":hp_y"),
            (overlay_set_position, ":agent_hp_overlay", pos1),
            (store_agent_hit_points, ":agent_hp",":agent_id"),
            (store_mul, ":hp_width", ":agent_hp", 50),
            (val_mul, ":hp_width", ":base_x"),
            (val_div, ":hp_width", 100),
            (val_min, ":hp_width", ":bg_width"),
            (store_mul, ":hp_height", ":base_y", 50),
            (position_set_x, pos1, ":hp_width"),
            (position_set_y, pos1, ":hp_height"),
            (overlay_set_size, ":agent_hp_overlay", pos1),
            (overlay_set_alpha, ":agent_hp_overlay", 0x44),
          (try_end),            
 
        (else_try),
          (overlay_set_alpha, ":agent_hp_overlay", 0),
          (overlay_set_alpha, ":agent_hp_bg_overlay", 0),
        (try_end),
      (else_try),
        (try_begin),
          (gt, ":agent_hp_overlay", 0),
          (gt, ":agent_hp_bg_overlay", 0),
          (overlay_set_alpha, ":agent_hp_overlay", 0),
          (overlay_set_alpha, ":agent_hp_bg_overlay", 0),
        (try_end),
        (agent_set_slot, ":agent_id", slot_agent_hp_bar_overlay_id, 0),
        (agent_set_slot, ":agent_id", slot_agent_hp_bar_bg_overlay_id, 0),
      (try_end),         
    (try_end),
  ]),
My 'rgl' log:
Code:
 SCRIPT ERROR ON OPCODE 922: Invalid Overlay ID: 1; LINE NO: 128: 
 At script: set_hp_bar. At script: set_hp_bar. SCRIPT ERROR ON OPCODE 922: Invalid Overlay ID: 0; LINE NO: 129: 
 At script: set_hp_bar. At script: set_hp_bar. At script: set_hp_bar. At script: set_hp_bar. At script: set_hp_bar. At Mission Template mst_multiplayer_ccoop trigger no: 3 consequences. At Mission Template mst_multiplayer_ccoop trigger no: 3 consequences.
 
I tried to adapt the script to multiplayer mode, now it works in agent_bots this way:
Code:
multiplayer_agent_hp_bar = (
	0, 0, 0,
		[],
		[
			(multiplayer_is_server),
			(start_presentation, "prsnt_multiplayer_agent_hp_bar"),
		])
Code:
multiplayer_agent_hp_bar,
Code:
	("multiplayer_agent_hp_bar", prsntf_read_only, 0,
		[
			(ti_on_presentation_load,
				[
					(set_fixed_point_multiplier, 1000),

					(get_max_players, ":num_players"),
					(try_for_range, ":player_no", 0, ":num_players"),
						(player_is_active, ":player_no"),
						(neg|player_is_busy_with_menus, ":player_no"),

						(player_get_team_no, ":player_team", ":player_no"),
						(lt, ":player_team", multi_team_spectator),

						(player_get_troop_id, ":player_troop", ":player_no"),
						(ge, ":player_troop", 0),

						(player_get_agent_id, ":player_agent", ":player_no"),
						(ge, ":player_agent", 0),

						(try_for_agents, ":agent_no"),
							(agent_is_human, ":agent_no"),
							(neq, ":agent_no", ":player_agent"),

							(try_begin),
								(agent_is_alive, ":agent_no"),
								(agent_get_team, ":agent_team", ":agent_no"),

								#hp bg
								(create_mesh_overlay, ":agent_hp_bg_overlay", "mesh_white_plane"),
								(overlay_set_alpha, ":agent_hp_bg_overlay", 0x44),
								(overlay_set_color, ":agent_hp_bg_overlay", 0x000000),

								#hp
								(create_mesh_overlay, ":agent_hp_overlay", "mesh_white_plane"),
								(overlay_set_alpha, ":agent_hp_overlay", 0x44),
								(try_begin),
									(eq, ":agent_team", ":player_team"),
									(overlay_set_color, ":agent_hp_overlay", 0x00FF00), #green
								(else_try),
									(overlay_set_color, ":agent_hp_overlay", 0xFF0000), #red
								(try_end),

								#size & position
								(agent_get_position, pos1, ":agent_no"),
								(agent_get_horse, ":horse_agent", ":agent_no"),
								(try_begin),
									(ge, ":horse_agent", 0),
									(position_move_z, pos1, 280, 1),
								(else_try),
									(position_move_z, pos1, 180, 1),
								(try_end),
								(position_get_screen_projection, pos2, pos1),
								(position_get_x, ":head_x_pos", pos2),
								(position_get_y, ":head_y_pos", pos2),

								#base size
								(copy_position, pos6, pos1),
								(copy_position, pos7, pos1),
								(position_move_z, pos7, 100, 1),
								(position_get_screen_projection, pos6, pos6),
								(position_get_screen_projection, pos7, pos7),
								(position_get_y, ":screen_y_pos_1", pos6),
								(position_get_y, ":screen_y_pos_2", pos7),
								(store_sub, ":base_x", ":screen_y_pos_2", ":screen_y_pos_1"),
								(val_clamp, ":base_x", 20, 161),
								(store_div, ":base_y", ":base_x", 20),
								(try_begin),
									(is_between, ":head_x_pos", -100, 1100),
									(is_between, ":head_y_pos", -100, 850),
									(agent_get_position, pos3, ":agent_no"),
									(agent_get_position, pos4, ":player_agent"),
									(get_distance_between_positions_in_meters, ":distance", pos3, pos4),
									#---------------------------------------------------------
									(le, ":distance", 80), #distance limit for showing HP bars
									#---------------------------------------------------------

									#agent no
									(agent_get_horse, ":horse_agent", ":agent_no"),
									(try_begin),
										(ge, ":horse_agent", 0),
										(position_move_z, pos3, 280, 1),
									(else_try),
										(position_move_z, pos3, 180, 1),
									(try_end),
									#player agent
									(agent_get_horse, ":player_horse", ":player_agent"),
									(try_begin),
										(ge, ":player_horse", 0),
										(position_move_z, pos4, 280, 1),
									(else_try),
										(position_move_z, pos4, 180, 1),
									(try_end),
									(position_move_z, pos3, 50, 1),
									(position_move_z, pos4, 50, 1),
									(position_has_line_of_sight_to_position, pos3, pos4),

									#hp bg
									(assign, ":x_offset", ":base_x"),
									(val_div, ":x_offset", 2),
									(val_add, ":x_offset", 1),
									(store_sub, ":hp_bg_x", ":head_x_pos", ":x_offset"),
									(store_sub, ":hp_bg_y", ":head_y_pos", 1),
									(position_set_x, pos1, ":hp_bg_x"),
									(position_set_y, pos1, ":hp_bg_y"),
									(overlay_set_position, ":agent_hp_bg_overlay", pos1),
									(store_add, ":bg_width", ":base_x", 2),
									(val_mul, ":bg_width", 50),
									(store_add, ":bg_height", ":base_y", 2),
									(val_mul, ":bg_height", 50),
									(position_set_x, pos1, ":bg_width"),
									(position_set_y, pos1, ":bg_height"),
									(overlay_set_size, ":agent_hp_bg_overlay", pos1),
									(overlay_set_alpha, ":agent_hp_bg_overlay", 0x66),

									#hp
									(store_add, ":hp_x", ":hp_bg_x", 1),
									(store_add, ":hp_y", ":hp_bg_y", 1),
									(position_set_x, pos1, ":hp_x"),
									(position_set_y, pos1, ":hp_y"),
									(overlay_set_position, ":agent_hp_overlay", pos1),
									(store_agent_hit_points, ":agent_hp", ":agent_no"),
									(store_mul, ":hp_width", ":agent_hp", 50),
									(val_mul, ":hp_width", ":base_x"),
									(val_div, ":hp_width", 100),
									(val_min, ":hp_width", ":bg_width"),
									(store_mul, ":hp_height", ":base_y", 50),
									(position_set_x, pos1, ":hp_width"),
									(position_set_y, pos1, ":hp_height"),
									(overlay_set_size, ":agent_hp_overlay", pos1),

									#text (disabled) showing hit points relative
									# (assign, reg7, ":agent_hp"),
									# (create_text_overlay, ":agent_hp_overlay", "@_{reg7}_", tf_center_justify|tf_with_outline),
									# (overlay_set_alpha, ":agent_hp_overlay", 0x44),
									# (try_begin),
										# (eq, ":agent_team", ":player_team"),
										# (overlay_set_color, ":agent_hp_overlay", 0x00FF00), #green
									# (else_try),
										# (overlay_set_color, ":agent_hp_overlay", 0xFF0000), #red
									# (try_end),
									# (position_set_x, pos1, ":hp_bg_x"),
									# (position_set_y, pos1, ":hp_bg_y"),
									# (overlay_set_position, ":agent_hp_overlay", pos1),
									# (position_set_x, pos1, 400),
									# (position_set_y, pos1, 400),
									# (overlay_set_size, ":agent_hp_overlay", pos1),

								(else_try),
									(overlay_set_alpha, ":agent_hp_bg_overlay", 0),
									(overlay_set_alpha, ":agent_hp_overlay", 0),
								(try_end),
							(try_end),
						(try_end),
					(try_end),
				]
			),
		]
	),
I have removed the slots in case you want to delete them from 'module_constants'.
 
Dj_FRedy said:
I tried to adapt the script to multiplayer mode, now it works in agent_bots this way:
Code:
multiplayer_agent_hp_bar = (
	0, 0, 0,
		[],
		[
			(multiplayer_is_server),
			(start_presentation, "prsnt_multiplayer_agent_hp_bar"),
		])
Code:
multiplayer_agent_hp_bar,
Code:
	("multiplayer_agent_hp_bar", prsntf_read_only, 0,
		[
			(ti_on_presentation_load,
				[
					(set_fixed_point_multiplier, 1000),

					(get_max_players, ":num_players"),
					(try_for_range, ":player_no", 0, ":num_players"),
						(player_is_active, ":player_no"),
						(neg|player_is_busy_with_menus, ":player_no"),

						(player_get_team_no, ":player_team", ":player_no"),
						(lt, ":player_team", multi_team_spectator),

						(player_get_troop_id, ":player_troop", ":player_no"),
						(ge, ":player_troop", 0),

						(player_get_agent_id, ":player_agent", ":player_no"),
						(ge, ":player_agent", 0),

						(try_for_agents, ":agent_no"),
							(agent_is_human, ":agent_no"),
							(neq, ":agent_no", ":player_agent"),

							(try_begin),
								(agent_is_alive, ":agent_no"),
								(agent_get_team, ":agent_team", ":agent_no"),

								#hp bg
								(create_mesh_overlay, ":agent_hp_bg_overlay", "mesh_white_plane"),
								(overlay_set_alpha, ":agent_hp_bg_overlay", 0x44),
								(overlay_set_color, ":agent_hp_bg_overlay", 0x000000),

								#hp
								(create_mesh_overlay, ":agent_hp_overlay", "mesh_white_plane"),
								(overlay_set_alpha, ":agent_hp_overlay", 0x44),
								(try_begin),
									(eq, ":agent_team", ":player_team"),
									(overlay_set_color, ":agent_hp_overlay", 0x00FF00), #green
								(else_try),
									(overlay_set_color, ":agent_hp_overlay", 0xFF0000), #red
								(try_end),

								#size & position
								(agent_get_position, pos1, ":agent_no"),
								(agent_get_horse, ":horse_agent", ":agent_no"),
								(try_begin),
									(ge, ":horse_agent", 0),
									(position_move_z, pos1, 280, 1),
								(else_try),
									(position_move_z, pos1, 180, 1),
								(try_end),
								(position_get_screen_projection, pos2, pos1),
								(position_get_x, ":head_x_pos", pos2),
								(position_get_y, ":head_y_pos", pos2),

								#base size
								(copy_position, pos6, pos1),
								(copy_position, pos7, pos1),
								(position_move_z, pos7, 100, 1),
								(position_get_screen_projection, pos6, pos6),
								(position_get_screen_projection, pos7, pos7),
								(position_get_y, ":screen_y_pos_1", pos6),
								(position_get_y, ":screen_y_pos_2", pos7),
								(store_sub, ":base_x", ":screen_y_pos_2", ":screen_y_pos_1"),
								(val_clamp, ":base_x", 20, 161),
								(store_div, ":base_y", ":base_x", 20),
								(try_begin),
									(is_between, ":head_x_pos", -100, 1100),
									(is_between, ":head_y_pos", -100, 850),
									(agent_get_position, pos3, ":agent_no"),
									(agent_get_position, pos4, ":player_agent"),
									(get_distance_between_positions_in_meters, ":distance", pos3, pos4),
									#---------------------------------------------------------
									(le, ":distance", 80), #distance limit for showing HP bars
									#---------------------------------------------------------

									#agent no
									(agent_get_horse, ":horse_agent", ":agent_no"),
									(try_begin),
										(ge, ":horse_agent", 0),
										(position_move_z, pos3, 280, 1),
									(else_try),
										(position_move_z, pos3, 180, 1),
									(try_end),
									#player agent
									(agent_get_horse, ":player_horse", ":player_agent"),
									(try_begin),
										(ge, ":player_horse", 0),
										(position_move_z, pos4, 280, 1),
									(else_try),
										(position_move_z, pos4, 180, 1),
									(try_end),
									(position_move_z, pos3, 50, 1),
									(position_move_z, pos4, 50, 1),
									(position_has_line_of_sight_to_position, pos3, pos4),

									#hp bg
									(assign, ":x_offset", ":base_x"),
									(val_div, ":x_offset", 2),
									(val_add, ":x_offset", 1),
									(store_sub, ":hp_bg_x", ":head_x_pos", ":x_offset"),
									(store_sub, ":hp_bg_y", ":head_y_pos", 1),
									(position_set_x, pos1, ":hp_bg_x"),
									(position_set_y, pos1, ":hp_bg_y"),
									(overlay_set_position, ":agent_hp_bg_overlay", pos1),
									(store_add, ":bg_width", ":base_x", 2),
									(val_mul, ":bg_width", 50),
									(store_add, ":bg_height", ":base_y", 2),
									(val_mul, ":bg_height", 50),
									(position_set_x, pos1, ":bg_width"),
									(position_set_y, pos1, ":bg_height"),
									(overlay_set_size, ":agent_hp_bg_overlay", pos1),
									(overlay_set_alpha, ":agent_hp_bg_overlay", 0x66),

									#hp
									(store_add, ":hp_x", ":hp_bg_x", 1),
									(store_add, ":hp_y", ":hp_bg_y", 1),
									(position_set_x, pos1, ":hp_x"),
									(position_set_y, pos1, ":hp_y"),
									(overlay_set_position, ":agent_hp_overlay", pos1),
									(store_agent_hit_points, ":agent_hp", ":agent_no"),
									(store_mul, ":hp_width", ":agent_hp", 50),
									(val_mul, ":hp_width", ":base_x"),
									(val_div, ":hp_width", 100),
									(val_min, ":hp_width", ":bg_width"),
									(store_mul, ":hp_height", ":base_y", 50),
									(position_set_x, pos1, ":hp_width"),
									(position_set_y, pos1, ":hp_height"),
									(overlay_set_size, ":agent_hp_overlay", pos1),

									#text (disabled) showing hit points relative
									# (assign, reg7, ":agent_hp"),
									# (create_text_overlay, ":agent_hp_overlay", "@_{reg7}_", tf_center_justify|tf_with_outline),
									# (overlay_set_alpha, ":agent_hp_overlay", 0x44),
									# (try_begin),
										# (eq, ":agent_team", ":player_team"),
										# (overlay_set_color, ":agent_hp_overlay", 0x00FF00), #green
									# (else_try),
										# (overlay_set_color, ":agent_hp_overlay", 0xFF0000), #red
									# (try_end),
									# (position_set_x, pos1, ":hp_bg_x"),
									# (position_set_y, pos1, ":hp_bg_y"),
									# (overlay_set_position, ":agent_hp_overlay", pos1),
									# (position_set_x, pos1, 400),
									# (position_set_y, pos1, 400),
									# (overlay_set_size, ":agent_hp_overlay", pos1),

								(else_try),
									(overlay_set_alpha, ":agent_hp_bg_overlay", 0),
									(overlay_set_alpha, ":agent_hp_overlay", 0),
								(try_end),
							(try_end),
						(try_end),
					(try_end),
				]
			),
		]
	),
I have removed the slots in case you want to delete them from 'module_constants'.
It's great. There are no words to show my appreciation!Thank you so much!
 
Status
Not open for further replies.
Back
Top Bottom