Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Hello everyone,

First, I am really sorry for my English.  :oops: I will try to explain my problem as clearly as I can.

I'm trying to add personal kill count in battle for my personal mod. So I use"arena_training" code for base in module_presentation.py and merged modified version in troop ratio bar presentation. The problem is that my modified version of personal kill counter only count "enemy knock unconscious by me", not "total casualties inflected by me." (enemy knock unconscious + enemy killed) If that makes any sense.

Please see screenshot below.


As you can see in the screenshot, I killed one looter and knocked unconscious another. But only count knocked unconscious enemy. What I want is both knocked unconscious and killed enemy registered as Kills:

So here is the code I am working.

Code:
        (try_begin),
          (gt, ":cur_time", 200),
          (game_key_clicked, gk_view_orders),
          (try_for_agents, ":cur_agent"),
            (agent_set_slot, ":cur_agent", slot_agent_map_overlay_id, 0),
          (try_end),
          (presentation_set_duration, 0),
		  # Start - Troop Ratio Bar, Battle Mini Map & Personal Kill Count 
		  (try_begin),
			  (this_or_next|eq, "$enable_troop_ratio_bar"),
			  (this_or_next|eq, "$enable_battle_minimap"),
			  (eq, "$enable_killcount"),		  
		      (start_presentation, "prsnt_troop_ratio_bar"),
		  (try_end),
		  # End - Troop Ratio Bar, Battle Mini Map & Personal Kill Count
		(try_end),
        ]),
      ]),
Code:
## Start - Troop Ratio Bar, Battle Mini Map & Personal Kill Count
  ("troop_ratio_bar",prsntf_read_only,0,[
      (ti_on_presentation_load,
       [
        (assign, "$presentation_troop_ratio_bar_active", 1),
        (set_fixed_point_multiplier, 1000),
       
        (create_mesh_overlay, "$g_presentation_obj_1", "mesh_status_troop_ratio_bar"),
		(position_set_x, pos1, -30), # Original value is 30
        (position_set_y, pos1, -700),# Original value is 700
        (overlay_set_position, "$g_presentation_obj_1", pos1),
       
        (position_set_x, pos1, 393), # Original value is 35
        (position_set_y, pos1, 734),# Original value is 713
       
        (create_mesh_overlay, "$g_presentation_obj_2", "mesh_white_plane"),
        (overlay_set_color, "$g_presentation_obj_2", 0xAA1F1F),
        (overlay_set_position, "$g_presentation_obj_2", pos1),
       
        (create_mesh_overlay, "$g_presentation_obj_3", "mesh_white_plane"),
        (overlay_set_color, "$g_presentation_obj_3", 0x1F1FAA),
        (overlay_set_position, "$g_presentation_obj_3", pos1),
     
        (create_mesh_overlay, "$g_presentation_obj_4", "mesh_white_plane"),
        (overlay_set_color, "$g_presentation_obj_4", 0x1FAA1F),
        (overlay_set_position, "$g_presentation_obj_4", pos1),

		## WINDYPLAINS+ ## - Add battle map to the troop ratio bar presentation.
		(try_begin),
			(eq, "$enable_battle_minimap"),
			
			## Clean out battle mini-map overlay ID's.
			(try_for_agents, ":agent_no"),
				(agent_set_slot, ":agent_no", slot_agent_map_overlay_id, 0),
			(try_end),
			
			(get_scene_boundaries, pos2, pos3),
			(position_transform_position_to_local, pos4, pos2, pos3),
			(set_fixed_point_multiplier, 1000),
			(position_get_x, ":map_width", pos4),
			(position_get_y, ":map_height", pos4),
			(set_fixed_point_multiplier, 1000),
			(store_div, ":map_ratio", ":map_height", 100),
			(store_div, ":map_ratio", ":map_width", ":map_ratio"),
			(try_begin),
			  (gt, ":map_ratio", 100),
			  (assign, "$g_battle_map_width", 150),
			  (store_div, "$g_battle_map_scale", ":map_width", "$g_battle_map_width"),
			  (store_div, "$g_battle_map_height", ":map_height", "$g_battle_map_scale"),
			(else_try),
			  (assign, "$g_battle_map_height", 150),
			  (store_div, "$g_battle_map_scale", ":map_height", "$g_battle_map_height"),
			  (store_div, "$g_battle_map_width", ":map_width", "$g_battle_map_scale"),
			(try_end),
			
			(create_image_button_overlay, "$g_battle_map_plane", "mesh_white_plane", "mesh_white_plane"),
			(overlay_set_color, "$g_battle_map_plane", 0),
			(store_add, ":map_bordered_width", "$g_battle_map_width", 20),
			(store_add, ":map_bordered_height", "$g_battle_map_height", 20),
			(store_mul, ":map_scale_x", ":map_bordered_width", 50),
			(store_mul, ":map_scale_y", ":map_bordered_height", 50),
			(position_set_x, pos1, ":map_scale_x"),
			(position_set_y, pos1, ":map_scale_y"),
			(overlay_set_size, "$g_battle_map_plane", pos1),
			(store_sub, ":map_pos_x", 990, ":map_bordered_width"),
			(store_sub, ":map_pos_y", 740, ":map_bordered_height"),
			(position_set_x, pos1, ":map_pos_x"),
			(position_set_y, pos1, ":map_pos_y"),
			(overlay_set_position, "$g_battle_map_plane", pos1),
			(overlay_set_alpha, "$g_battle_map_plane", 0x44),
		(try_end),
		## WINDYPLAINS- ##
		
		## Start - Add personal kill count to the troop ratio bar presentation.
		(try_begin),
			(eq, "$enable_killcount"),
			
            (get_player_agent_no, ":player_agent"),
            (agent_get_kill_count, reg1, ":player_agent", 1),
			(create_text_overlay, "$g_presentation_obj_1", s1),
            (overlay_set_color, "$g_presentation_obj_1", 0xFFFFFF),
            (position_set_x, pos1, 10),
			(position_set_y, pos1, 713),
			(overlay_set_position, "$g_presentation_obj_1", pos1),
			(assign, reg1, 1),
        (try_end),
		## End - Add personal kill count to the troop ratio bar presentation.
		
        (presentation_set_duration, 999999),
       ]),
      (ti_on_presentation_run,
       [
        (store_trigger_param_1, ":cur_time"),
       
        (set_fixed_point_multiplier, 1000),
        (assign, ":player_count", 0),
        (assign, ":ally_count", 0),
        (assign, ":enemy_count", 0),
        (assign, ":total_count", 0),
       
        (try_for_agents, ":cur_agent"),
          (agent_is_human, ":cur_agent"),
          (agent_is_alive, ":cur_agent"),
          (agent_get_party_id, ":agent_party", ":cur_agent"),
          (try_begin),
            (eq, ":agent_party", "p_main_party"),
            (val_add, ":player_count", 1),
          (else_try),
            (agent_is_ally, ":cur_agent"),
            (val_add, ":ally_count", 1),
          (else_try),
            (val_add, ":enemy_count", 1),
          (try_end),
        (try_end),
        (val_add, ":total_count", ":player_count"),
        (val_add, ":total_count", ":ally_count"),
        (val_add, ":total_count", ":enemy_count"),

        (position_set_x, pos1, 12000),
        (position_set_y, pos1, 300),
        (overlay_set_size, "$g_presentation_obj_2", pos1),
     
        (store_add, ":ally_percent", ":player_count", ":ally_count"),
        (val_mul, ":ally_percent", 12000),
        (val_div, ":ally_percent", ":total_count"),
        (position_set_x, pos1, ":ally_percent"),
        (position_set_y, pos1, 300),
        (overlay_set_size, "$g_presentation_obj_3", pos1),
     
        (store_mul, ":player_percent", ":player_count", 12000),
        (val_div, ":player_percent", ":total_count"),
        (position_set_x, pos1, ":player_percent"),
        (position_set_y, pos1, 300),
        (overlay_set_size, "$g_presentation_obj_4", pos1),
       
        (store_add, ":ally_percent_2", ":player_count", ":ally_count"),
        (val_mul, ":ally_percent_2", 240),
        (val_div, ":ally_percent_2", ":total_count"),
        (val_add, ":ally_percent_2", 35),
        (position_set_x, pos1, ":ally_percent_2"),
        (position_set_y, pos1, 700),
       
        (store_mul, ":player_percent_2", ":player_count", 240),
        (val_div, ":player_percent_2", ":total_count"),
        (val_add, ":player_percent_2", 35),
        (position_set_x, pos1, ":player_percent_2"),
        (position_set_y, pos1, 700),

		## BATTLE MAP
		(try_begin),
			(eq, "$enable_battle_minimap"),
			
			(get_scene_boundaries, pos2, pos3),

			(try_for_agents,":cur_agent"),
				(agent_is_human, ":cur_agent"),
				(agent_get_party_id, ":agent_party", ":cur_agent"),
				(agent_get_slot, ":agent_overlay", ":cur_agent", slot_agent_map_overlay_id),
				(try_begin),
					(eq, ":agent_party", "p_main_party"),
					(try_begin),
						(agent_is_alive, ":cur_agent"),
						(call_script, "script_update_agent_position_on_map", ":cur_agent"),          
					(else_try),
						### WINDYPLAINS+ ### - Done to prevent object #0 agents erasing object #0 (troop ratio bar background)
						(neq, ":agent_overlay", 0),
						### WINDYPLAINS- ###
						(overlay_set_alpha, ":agent_overlay", 0),
					(try_end),
				(else_try),
					(agent_is_ally, ":cur_agent"),
					(try_begin),
						(agent_is_alive, ":cur_agent"),
						(call_script, "script_update_agent_position_on_map", ":cur_agent"),
					(else_try),
						### WINDYPLAINS+ ### - Done to prevent object #0 agents erasing object #0 (troop ratio bar background)
						(neq, ":agent_overlay", 0),
						### WINDYPLAINS- ###
						(overlay_set_alpha, ":agent_overlay", 0),
					(try_end),
				(else_try),
					(try_begin),
						(agent_is_alive, ":cur_agent"),
						(call_script, "script_update_agent_position_on_map", ":cur_agent"),
					(else_try),
						### WINDYPLAINS+ ### - Done to prevent object #0 agents erasing object #0 (troop ratio bar background)
						(neq, ":agent_overlay", 0),
						### WINDYPLAINS- ###
						(overlay_set_alpha, ":agent_overlay", 0),
					(try_end),
				(try_end),
			(try_end),
		(try_end),

		## PERSONAL KILL COUNT
		(try_begin),
			(eq, "$enable_killcount"),			
			
			(get_player_agent_no, ":player_agent"),
			 (agent_get_kill_count, reg1, ":player_agent", 1),
			 (str_store_string, s1, "@Kills: {reg1}"),
			 (overlay_set_text, "$g_presentation_obj_1", s1),
		(try_end),
		## PERSONAL KILL COUNT
       
        (try_begin),
          (eq, "$presentation_troop_ratio_bar_active", 1),
          (gt, ":cur_time", 200),
          (game_key_clicked, gk_view_orders),
          (assign, "$presentation_troop_ratio_bar_active", 0),
          (presentation_set_duration, 0),
          (start_presentation, "prsnt_battle"),
        (try_end),
       ]),
     ]),
## End - Troop Ratio Bar, Battle Mini Map & Personal Kill Count

Code:
      common_battle_order_panel,
      common_battle_order_panel_tick,
      (0, 0, ti_once, [], [(start_presentation, "prsnt_troop_ratio_bar")]), # Troop Ratio Bar
    ],

Thanks in advance for your suggestions.

Kind Regards,


 
Hey! Welcome to the forums.

I've always interpreted the comment on agent_get_kill_count
Code:
agent_get_kill_count                     = 1723  # (agent_get_kill_count, <destination>, <agent_id>, [get_wounded]),
                                                 # Retrieves the total number of kills by the specified agent during this battle. 
                                                 # Call with non-zero <get_wounded> parameter to retrieve the total number of enemies the agent has knocked down.
to mean that adding a value will get both wounded and killed troops, but your problem made me look into it a little further and realize I was wrong. So thank you!

You can solve it by changing all instances of
Code:
            (get_player_agent_no, ":player_agent"),
            (agent_get_kill_count, reg1, ":player_agent", 1),

to

Code:
            (get_player_agent_no, ":player_agent"),
            (agent_get_kill_count, ":kill_count", ":player_agent"),
            (agent_get_kill_count, ":wound_count", ":player_agent", 1),
            (store_add, reg1, ":kill_count", ":wound_count"),
 
SupaNinjaMan said:
Hey! Welcome to the forums.

I've always interpreted the comment on agent_get_kill_count
Code:
agent_get_kill_count                     = 1723  # (agent_get_kill_count, <destination>, <agent_id>, [get_wounded]),
                                                 # Retrieves the total number of kills by the specified agent during this battle. 
                                                 # Call with non-zero <get_wounded> parameter to retrieve the total number of enemies the agent has knocked down.
to mean that adding a value will get both wounded and killed troops, but your problem made me look into it a little further and realize I was wrong. So thank you!

You can solve it by changing all instances of
Code:
            (get_player_agent_no, ":player_agent"),
            (agent_get_kill_count, reg1, ":player_agent", 1),

to

Code:
            (get_player_agent_no, ":player_agent"),
            (agent_get_kill_count, ":kill_count", ":player_agent"),
            (agent_get_kill_count, ":wound_count", ":player_agent", 1),
            (store_add, reg1, ":kill_count", ":wound_count"),
Thank you very much, SupaNinjaMan. It works.  :party: Updated version of the codes below:

Code:
		## Start - Add personal kill count to the troop ratio bar presentation.
		(try_begin),
			(eq, "$enable_killcount"),
			
            # (get_player_agent_no, ":player_agent"),
            # (agent_get_kill_count, reg1, ":player_agent", 1),
            (get_player_agent_no, ":player_agent"),
            (agent_get_kill_count, ":kill_count", ":player_agent"),
            (agent_get_kill_count, ":wound_count", ":player_agent", 1), 
            (store_add, reg1, ":kill_count", ":wound_count"),           
			(create_text_overlay, "$g_presentation_obj_1", s1),
            (overlay_set_color, "$g_presentation_obj_1", 0xFFFFFF),
            (position_set_x, pos1, 10),
			(position_set_y, pos1, 713),
			(overlay_set_position, "$g_presentation_obj_1", pos1),
			(assign, reg1, 1),
        (try_end),
		## End - Add personal kill count to the troop ratio bar presentation.
Code:
		## PERSONEL KILL COUNT
		(try_begin),
			(eq, "$enable_killcount"),			
			
			(get_player_agent_no, ":player_agent"),
			 (agent_get_kill_count, reg1, ":player_agent", 1),
			 (agent_get_kill_count, ":kill_count", ":player_agent"),
             (agent_get_kill_count, ":wound_count", ":player_agent", 1),
             (store_add, reg1, ":kill_count", ":wound_count"),
			 (str_store_string, s1, "@Kills: {reg1}"),
			 (overlay_set_text, "$g_presentation_obj_1", s1),
		(try_end),
		## PERSONEL KILL COUNT
 
How would I go about changing how much a board shield rotates when held up?

It doesn't align properly in Viking Conquest so I figured I need to mod it to have it rotate a bit more. Can it be done?
 
TW031 said:
How would I go about changing how much a board shield rotates when held up?
Find shield mesh in OpenBRF and use rmc - Roto-Translate-Rescale option. It is quite hard to test because you will need to close and enter the game after each change, but it works.



Is there any way to allow putting horses in chests?
 
How does one prevent a merchant from selling his own clothing and equiping items he is ony supposed to sell?

Here are my codes:

The troop on module_troops
["geroia_merchant","Giusepe","{!}Giusepe",tf_hero, scn_geroian_camp|tf_is_merchant|entry(5), reserved, fac_commoners,[itm_arena_tunic_yellow,itm_ankle_boots,itm_felt_hat_b],def_attrib|level(5),wp(20),knows_common,0x000000047f0020cf3d1eaa2b5cd1bb1b00000000001e48920000000000000000],

The items he is supposed to sell, define on module_scripts
(troop_add_items, "trp_geroia_merchant", "itm_norman_shield_4", 3),
    (troop_add_items, "trp_geroia_merchant", "itm_mail_with_tunic_yellow", 2),
    (troop_add_items, "trp_geroia_merchant", "itm_sword_medieval_c", 2),
    (troop_add_items, "trp_geroia_merchant", "itm_bascinet_2", 2),

The only dialog line:
[trp_geroia_merchant, "start", [], "Greetings friend. Here to look at the finest Geroian equipment?", "npc_merchant_talk",[]],

My main problem: at the first time I visit the scene, this guy is equiped with the bascinet, mail,sword and shield, rather than the tunic and felt hat I gave him on module_troops.
I can buy everything from him, and visiting him again leaves him naked. Still haven't tested if his inventory refreshes automatically
 
["geroia_merchant","Giusepe","{!}Giusepe",tf_hero|tf_is_merchant, scn_geroian_camp|entry(5), reserved, fac_commoners,[itm_arena_tunic_yellow,itm_ankle_boots,itm_felt_hat_b],def_attrib|level(5),wp(20),knows_common,0x000000047f0020cf3d1eaa2b5cd1bb1b00000000001e48920000000000000000],

Pretty sure you had the tf_is_merchant flag in the wrong part of the troop code.
 
Seek n Destroy said:
["geroia_merchant","Giusepe","{!}Giusepe",tf_hero|tf_is_merchant, scn_geroian_camp|entry(5), reserved, fac_commoners,[itm_arena_tunic_yellow,itm_ankle_boots,itm_felt_hat_b],def_attrib|level(5),wp(20),knows_common,0x000000047f0020cf3d1eaa2b5cd1bb1b00000000001e48920000000000000000],

Pretty sure you had the tf_is_merchant flag in the wrong part of the troop code.

Indeed. Thanks for the insight. I was looking again and again over my lines so many times that I didn't notice the wrong positioning.

BTW, I'm working on adding some merchants on the mercenary camps you created. It was a well written guide, my first strike at using the module system, and it worked flawlessly since the start. Thank you once again, for the amazing OSP and the help with this admitedly obvious misplaced code
 
UndeadDuke said:
TW031 said:
How would I go about changing how much a board shield rotates when held up?
Find shield mesh in OpenBRF and use rmc - Roto-Translate-Rescale option. It is quite hard to test because you will need to close and enter the game after each change, but it works.



Is there any way to allow putting horses in chests?

Thank you!!! Worked like a charm!

I was looking for this solution everywhere!!
 
Now I have another issue. This time with Morgh's Editor ... for some reason it keeps reducing numbers I write into Ironflesh and Power Strike.

I write in 10 and 16 ... when I click on add troop those numbers change to 1 and 6 in ...

I tried changing levels, attribute levels, reducing amounts of other areas that I had allocated points ... but it always reduces these two I need by a significant degree and I can't figure out why.

Picture of my setup: https://i.imgur.com/NAsQxzn.png
 
About Kingdom Reinforcements, is it possible to add more types of reinforcements?(Reinforcement D, Reinforcement E...)
 
kalarhan said:
HelrothHyrmir said:
About Kingdom Reinforcements, is it possible to add more types of reinforcements?(Reinforcement D, Reinforcement E...)

yeap, it is all done on the modsys so you can do whatever you want with it

Well, I actually have problems with adding my new "Kingdom_1_reinforcements_d" template.

Code:
  ("kingdom_1_reinforcements_a", "{!}kingdom_1_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_romaroth_recruit,10,15),(trp_romaroth_seasoned_recruit,20,30), (trp_romaroth_levy_footman,10,15), (trp_romaroth_footman,5,10), (trp_romaroth_veteran_footman,2,5), (trp_romaroth_levy_archer,10,15)]),
  ("kingdom_1_reinforcements_b", "{!}kingdom_1_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_romaroth_footman,20,30),(trp_romaroth_veteran_footman,10,15),(trp_romaroth_infantry,5,10), (trp_romaroth_light_rider,20,30), (trp_romaroth_rider,10,15), (trp_romaroth_heavy_rider,5,10)]),
  ("kingdom_1_reinforcements_c", "{!}kingdom_1_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_romaroth_heavy_rider,15,25),(trp_romaroth_cavalry,10,20),(trp_romaroth_heavy_cavalry,5,10),(trp_romaroth_lancer,15,25),(trp_romaroth_heavy_lancer,10,20),(trp_romaroth_knight,5,10)]), #Swadians are a bit less-powered thats why they have a bit more troops in their modernised party template (3-6, others 3-5)
  ("kingdom_1_reinforcements_d", "{!}kingdom_1_reinforcements_d", 0, 0, fac_commoners, 0, [(trp_romaroth_heavy_infantry,15,25),(trp_romaroth_man_at_arms,10,20),(trp_romaroth_shock_trooper,10,20),(trp_romaroth_master_at_arms,5,10),(trp_romaroth_greatsword,5,10),(trp_romaroth_champion,1,3)]), #Swadians are a bit less-powered thats why they have a bit more troops in their modernised party template (3-6, others 3-5)

Code:
        (try_begin),
          (faction_slot_eq, ":faction_no", slot_faction_culture, "fac_culture_1"),
      
          (faction_set_slot, ":faction_no",  slot_faction_deserter_troop, "trp_swadian_deserter"),
          (faction_set_slot, ":faction_no",  slot_faction_guard_troop, "trp_romaroth_cavalry"),
          (faction_set_slot, ":faction_no",  slot_faction_messenger_troop, "trp_swadian_messenger"),
          (faction_set_slot, ":faction_no",  slot_faction_prison_guard_troop, "trp_swadian_prison_guard"),
          (faction_set_slot, ":faction_no",  slot_faction_castle_guard_troop, "trp_swadian_castle_guard"),
          (faction_set_slot, ":faction_no",  slot_faction_reinforcements_a, "pt_kingdom_1_reinforcements_a"),
          (faction_set_slot, ":faction_no",  slot_faction_reinforcements_b, "pt_kingdom_1_reinforcements_b"),
          (faction_set_slot, ":faction_no",  slot_faction_reinforcements_c, "pt_kingdom_1_reinforcements_c"),
          (faction_set_slot, ":faction_no",  slot_faction_reinforcements_d, "pt_kingdom_1_reinforcements_d"),

The problem : "slot_faction_reinforcements_d" is not defined. I guess I have to add a script for a kingdom to also use "slot_faction_reinforcements_d" for reinforcements, too. But how?
 
You need to add slot_faction_reinforcements_d to module_constants
Code:
slot_faction_reinforcements_a        = 77
slot_faction_reinforcements_b        = 78
slot_faction_reinforcements_c        = 79
and modify cf_reinforce_party to have the chance to select slot_faction_reinforcements_d as part of the options.
 
Code:
      (assign, ":party_template", 0),
      (store_random_in_range, ":rand", 0, 100),
      (try_begin),
        (this_or_next|eq, ":party_type", spt_town),
        (eq, ":party_type", spt_castle),  #CASTLE OR TOWN
        (try_begin),
          (lt, ":rand", 65),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (assign, ":party_template", ":party_template_b"),
        (else_try),
          (assign, ":party_template", ":party_template_c"),
        (try_end),
      (else_try),
        (eq, ":party_type", spt_kingdom_hero_party),
        (try_begin),
          (lt, ":rand", 50),
          (assign, ":party_template", ":party_template_a"),
        (else_try),
          (lt, ":rand", 75),
          (assign, ":party_template", ":party_template_b"),
        (else_try),
          (assign, ":party_template", ":party_template_c"),
        (try_end),
      (else_try),
      (try_end),

      (try_begin),
        (gt, ":party_template", 0),
        (party_add_template, ":party_no", ":party_template"),
      (try_end),

What "Party_Template" is actually doing? Can I create more templates other than 3?
 
Status
Not open for further replies.
Back
Top Bottom