Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
How would you go about auto-assigning a particular troop to a player: e.g. player selects a nation and is automatically assigned a particular troop type?

I ultimately want to make players only become cav class, so it would be equally helpful if there was some way to 'grey out' the infantry classes (like you see when you use the code to not allow cav on a particular map).
 
KnightV said:
i will use but how game will get to know what troops to spawn? What triggers /codes do this?

follow the code. For SP it starts from the world event (field) or the game menu (sieges), calling a script/piece of code, that directs to a series of scripts for setup and the spawn of troops (based on the encountered parties). Triggers of the mission template do some of the work, and also handle the reinforcement code. If in doubt just look for who calls that mission template, and the template own triggers.

for MP you will need to check MP own code.

remember to follow the recipe for the mission template flags and how it handles the entry rows (for the EP).



pete99 said:
How would you go about auto-assigning a particular troop to a player: e.g. player selects a nation and is automatically assigned a particular troop type?
MP? If so, see section Z24 (Lav's header_operations.py) for operations on player (like player_set_troop_id).

For SP you can check the other sections from the same reference.
 
kalarhan said:
KnightV said:
i will use but how game will get to know what troops to spawn? What triggers /codes do this?

follow the code. For SP it starts from the world event (field) or the game menu (sieges), calling a script/piece of code, that directs to a series of scripts for setup and the spawn of troops (based on the encountered parties). Triggers of the mission template do some of the work, and also handle the reinforcement code. If in doubt just look for who calls that mission template, and the template own triggers.

for MP you will need to check MP own code.

remember to follow the recipe for the mission template flags and how it handles the entry rows (for the EP).



pete99 said:
How would you go about auto-assigning a particular troop to a player: e.g. player selects a nation and is automatically assigned a particular troop type?
MP? If so, see section Z24 (Lav's header_operations.py) for operations on player (like player_set_troop_id).

For SP you can check the other sections from the same reference.

Thanks. would you or anyone else know also how to 'grey' the options out so you can't select a particular class (like when horses aren't allowed on a map)? And yes, this is for multiplayer.
Thanks.
 
I was looking at some code in the module system some time ago and I saw a slot operation that didn't use a slot. There were only 2 parameters, the id of the thing and the value. I don't understand how this is possible.
I can't find it now, unfortunately.
 
kalarhan said:
Nameless Warrior said:
Any idea what can cause a phantom quickstring?

likely a syntax error or a invalid character (that breaks the string split). Easiest way to track it down is to search the module file, as they are created in order. Find "closed the gate" and "to party morale" on your module_scripts.py and see what is between it.

you can also inject a logger on your process_XXX.py file if the manual search failed.

Code:
def load_quick_strings(export_dir):

def save_quick_strings(export_dir, quick_strings):

Thanks. It turns out that {s0} is added in by modmerger and has always been there but missed it making me think that 569 one was wrong but now looking at it is indeed correct. The search continues.

Edit: for anyone who has this issue and finds this post I had a display message with no text after the @. That string will take an id but not a position in the txt file which will mess up everything underneath.
 
pete99 said:
would you or anyone else know also how to 'grey' the options out so you can't select a particular class (like when horses aren't allowed on a map)? And yes, this is for multiplayer.

I dont play MP, so I will assume you are talking about a presentation. Presentation is a custom UI with widgets. Check the documentation related to it and what you can do with them, like

Code:
# [ Z23 ] PRESENTATIONS

overlay_set_display                               =  947  # (overlay_set_display, <overlay_id>, <value>),
                                                          # Shows (value = 1) or hides (value = 0) the specified overlay.

Usually you will see this:
1) replace a selection widget (like a combobox) with a text display (text is fixed)
2) remove the options from the widget (from a list of options to just one option, thus no way to edit/change the value)
3) remove the widget (hide it)

if you are talking about something else it always help to be precise (add details), as we have no idea if you are talking about Native or a obscure mod with a unique implementation (that does things differently)



erennuman_mb said:
I was looking at some code in the module system some time ago and I saw a slot operation that didn't use a slot.
Code:
troop_set_slot                           =  500  # (troop_set_slot, <troop_id>, <slot_no>, <value>),
if you forget a parameter (which is not optional, like the 3 above), the compiler wont check for it. It will generate the list of numbers to be parsed by the engine. If nothing breaks on the parser, the likely scenario is that it will bug your code on runtime (when it will use the operation ID for the next line as a parameter instead)

operation count_parameters para1 para2 para3
operation count_parameters para1 para2 para3

2133 3 1 1 2133 3 1 1 1

remember that compiler does just a few sanity checks. The game parser checks a few more. Execution code can blow up from bugs (even syntax bugs), not just logic bugs.
 
Your relation with <trp=414>Lord  Arnord</> has increased from 0 to 28.
You gain right to rule.
Load the game with WSE Loader to get heraldic horses
vdt_regular discard_buffer()
Entry points for scene 203 : 24 23 22 21 20 19 18 17 16 9 0 11 10 8 7 6 5 4 3 2 1
Total entry points for scene 203 : 21
vdt_regular discard_buffer()
Entry points for scene 796 : 1 0 14 13 15
Total entry points for scene 796 : 5
vdt_regular discard_buffer()
vdt_regular discard_buffer()
vdt_regular discard_buffer()
vdt_regular discard_buffer()
You don't have enough money
You don't have enough money
vdt_regular discard_buffer()
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
Our party ran out of food!
<fac=45>Green Turks</> has declared war against <fac=29>Tanguts</>.

vdt_regular discard_buffer() - what does it mean?
 
prop_instance_is_valid                      = 1838  # (prop_instance_is_valid, <scene_prop_instance_id>),
                                                    # Checks that the reference to a scene prop instance is valid (i.e. it was not removed).

It suggests in this operation description that there is a way to remove scene props from a battlefield. Does anyone know the way to do that? as there is no remove_scene_prop like there is a remove_agent and as there is a scene_prop_fade_in I don't think fade_out it works in that fashion.

What I am looking to do is spawn a scene prop and then remove it so that later calls of (try_for_prop_instances,":instances"), will not include these instances in the cycle.

I have done some testing and it seems that even after activating ti_on_scene_prop_destroy the prop is still considered on the battlefield and part of that loop.
 
Nameless Warrior said:
It suggests in this operation description that there is a way to remove scene props from a battlefield.

Code:
scene_prop_fade_out                         = 1822  # (scene_prop_fade_out, <scene_prop_id>, <fade_out_time>)
                                                    # Version 1.153+. Makes the scene prop instance disappear within specified time.
?

you can also use slots if you need to store any ID for later tests/uses

oh also

Code:
try_for_prop_instances  =   16  # (try_for_prop_instances, <destination>, [<object_id>], [<object_type>]),
                                # Version 1.161+. if object_id  and object_type is not given, it loops through all instances. For object types see list of "somt_" in header_common.py
see the newest version of this operation (if you are using older modsys)
 
pete99 said:
Sorry, I would like to create a trigger where when the correct conditions are met it resets the map/round (like the option in the admin panel to reset map). I was wondering if there is a straightforward way (like a callable script) to go about doing this?


Idk really, but you can look there for something interesting. I think somewhere here it should be.


Code:
         #initialize my team at start of round (it will be assigned again at next round's first death)
         (assign, "$my_team_at_start_of_round", -1),

         #clear scene and end round
         (multiplayer_clear_scene),

         (call_script, "script_multiplayer_initialize_belfry_wheel_rotations"),

         (try_begin),
           (eq, "$g_battle_death_mode_started", 2),
           (call_script, "script_move_death_mode_flags_down"),
         (try_end),

         (assign, "$g_battle_death_mode_started", 0),
         (assign, "$g_reduced_waiting_seconds", 0),
         
         #initialize moveable object positions
         (call_script, "script_multiplayer_close_gate_if_it_is_open"),
         (call_script, "script_multiplayer_move_moveable_objects_initial_positions"),
                  
         (assign, "$g_round_ended", 0), 

         (assign, "$g_multiplayer_num_bots_required_team_1", "$g_multiplayer_num_bots_team_1"), 
         (assign, "$g_multiplayer_num_bots_required_team_2", "$g_multiplayer_num_bots_team_2"), 

         (store_mission_timer_a, "$g_round_start_time"),
         (call_script, "script_initialize_all_scene_prop_slots"),

         #initialize round start times for clients
         (get_max_players, ":num_players"),
         (try_for_range, ":player_no", 0, ":num_players"),
           (player_is_active, ":player_no"),
           (multiplayer_send_int_to_player, ":player_no", multiplayer_event_set_round_start_time, -9999), #this will also initialize moveable object slots.
         (try_end),         
       ]),

      (0, 0, 0, [], #if there is nobody in any teams do not reduce round time.
       [
         #(multiplayer_is_server),
         (assign, ":human_agents_spawned_at_team_1", "$g_multiplayer_num_bots_team_1"),
         (assign, ":human_agents_spawned_at_team_2", "$g_multiplayer_num_bots_team_2"),
         
         (get_max_players, ":num_players"),
         (try_for_range, ":player_no", 0, ":num_players"),
           (player_is_active, ":player_no"),
           (player_get_team_no, ":player_team", ":player_no"), 
           (try_begin),
             (eq, ":player_team", 0),
             (val_add, ":human_agents_spawned_at_team_1", 1),
           (else_try),
             (eq, ":player_team", 1),
             (val_add, ":human_agents_spawned_at_team_2", 1),
           (try_end),
         (try_end),

         (try_begin),
           (this_or_next|eq, ":human_agents_spawned_at_team_1", 0),
           (eq, ":human_agents_spawned_at_team_2", 0),

           (store_mission_timer_a, ":seconds_past_since_round_started"),
           (val_sub, ":seconds_past_since_round_started", "$g_round_start_time"),
           (le, ":seconds_past_since_round_started", 2),
                  
           (store_mission_timer_a, "$g_round_start_time"),
         (try_end),
       ]),    
           
      (1, 0, 0, [],
       [
         (multiplayer_is_server),
         (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"),
           (try_begin),
             (player_slot_eq, ":player_no", slot_player_spawned_this_round, 0),

             (player_get_team_no, ":player_team", ":player_no"), #if player is currently spectator do not spawn his agent
             (lt, ":player_team", multi_team_spectator),

             (player_get_troop_id, ":player_troop", ":player_no"), #if troop is not selected do not spawn his agent
             (ge, ":player_troop", 0),

             (assign, ":spawn_new", 0), 
             (assign, ":num_active_players_in_team_0", 0),
             (assign, ":num_active_players_in_team_1", 0),
             (try_begin),
               (assign, ":num_active_players", 0),
               (get_max_players, ":num_players"),
               (try_for_range, ":player_no_2", 0, ":num_players"),
                 (player_is_active, ":player_no_2"),
                 (val_add, ":num_active_players", 1),
                 (player_get_team_no, ":player_team_2", ":player_no_2"),
                 (try_begin),
                   (eq, ":player_team_2", 0),
                   (val_add, ":num_active_players_in_team_0", 1),
                 (else_try),
                   (eq, ":player_team_2", 1),
                   (val_add, ":num_active_players_in_team_1", 1),
                 (try_end),
               (try_end),

               (store_mul, ":multipication_of_num_active_players_in_teams", ":num_active_players_in_team_0", ":num_active_players_in_team_1"),

               (store_mission_timer_a, ":round_time"),
               (val_sub, ":round_time", "$g_round_start_time"),

               (this_or_next|lt, ":round_time", multiplayer_new_agents_finish_spawning_time),
               (this_or_next|le, ":num_active_players", 2),
               (eq, ":multipication_of_num_active_players_in_teams", 0),
         
               (eq, "$g_round_ended", 0),
               (assign, ":spawn_new", 1),
             (try_end),
             (eq, ":spawn_new", 1),
             (try_begin),
               (eq, ":player_team", 0),
               (assign, ":entry_no", multi_initial_spawn_point_team_1),
             (else_try),
               (eq, ":player_team", 1),
               (assign, ":entry_no", multi_initial_spawn_point_team_2),
             (try_end),
             (call_script, "script_multiplayer_buy_agent_equipment", ":player_no"),
             (player_spawn_new_agent, ":player_no", ":entry_no"),
             (player_set_slot, ":player_no", slot_player_spawned_this_round, 1),
           (else_try), #spawning as a bot (if option ($g_multiplayer_player_respawn_as_bot) is 1)
             (eq, "$g_multiplayer_player_respawn_as_bot", 1),
             (player_get_agent_id, ":player_agent", ":player_no"),
             (ge, ":player_agent", 0),
             (neg|agent_is_alive, ":player_agent"),
             (agent_get_time_elapsed_since_removed, ":elapsed_time", ":player_agent"),
             (gt, ":elapsed_time", "$g_multiplayer_respawn_period"),

             (player_get_team_no, ":player_team", ":player_no"),
             (assign, ":is_found", 0),
             (try_for_agents, ":cur_agent"),
               (eq, ":is_found", 0),
               (agent_is_alive, ":cur_agent"),
               (agent_is_human, ":cur_agent"),
               (agent_is_non_player, ":cur_agent"),
               (agent_get_team ,":cur_team", ":cur_agent"),
               (eq, ":cur_team", ":player_team"),
               (assign, ":is_found", 1),
               #(player_control_agent, ":player_no", ":cur_agent"),
             (try_end),

             (try_begin),
               (eq, ":is_found", 1),
               (call_script, "script_find_most_suitable_bot_to_control", ":player_no"),
               (player_control_agent, ":player_no", reg0),

               (player_get_slot, ":num_spawns", ":player_no", slot_player_spawned_this_round),
               (val_add, ":num_spawns", 1),
               (player_set_slot, ":player_no", slot_player_spawned_this_round, ":num_spawns"),
             (try_end),
           (try_end),
         (try_end),
         ]),

      multiplayer_server_spawn_bots, 
      multiplayer_server_manage_bots, 

      multiplayer_server_check_end_map,



Also you can check Gotha Adimi Tools (OSP). So You can track prsnt about reset map and find the right code for reseting the map.
 
Nameless Warrior said:
I have the latest module download on the forum which has  a header operations titled "header_operations expanded v.1.0.1" but the coding is as you say different on yours. What is that version called?  I just downloaded lavs and that also has the old code.

VC modsys merged with Lav's headers, as operations for 1.153+ were created for the DLC. I also used it for the tweaks tool and the code can be found https://github.com/KalarhanWB/VC_Tweaks_Tool/tree/master/app

when you destroy a object it can take some time to cycle out of memory, so check the status by using a parameter like HP or a slot to filter it out. See how long they remain in use.

you can also maintain your own list of objects as they are created/destroyed, instead of relying on the engine to tell you who they are. There are even OSP code to implement lists, arrays, etc based on slots for easy coding (they are based on fake objects like a troop and slots).
 
kalarhan said:
Nameless Warrior said:
I have the latest module download on the forum which has  a header operations titled "header_operations expanded v.1.0.1" but the coding is as you say different on yours. What is that version called?  I just downloaded lavs and that also has the old code.

VC modsys merged with Lav's headers, as operations for 1.153+ were created for the DLC. I also used it for the tweaks tool and the code can be found https://github.com/KalarhanWB/VC_Tweaks_Tool/tree/master/app

when you destroy a object it can take some time to cycle out of memory, so check the status by using a parameter like HP or a slot to filter it out. See how long they remain in use.

you can also maintain your own list of objects as they are created/destroyed, instead of relying on the engine to tell you who they are. There are even OSP code to implement lists, arrays, etc based on slots for easy coding (they are based on fake objects like a troop and slots).

Thanks Kalarhan, some of those operation changes look very interesting. Shame the instance is still not being recorded at reg0 for spawn_scene_prop. Strange that has never worked when it does for spawn agent and horse.

Yes I use the troop based lists a lot, they are an amazing addition to community tools. I haven't used them for testing purposes yet but it is always an option. Luckily I didn't need to this time.

I created a scene_prop_activation_stage slot to monitor the scene prop status every second but the problem was I used reg1, reg2 and reg3 within the try_for_scene_prop loop and this gave me false readings. Once I used local variables and converted it to registers once the loop had finished it then gave me the correct reading and I can see that destroying the scene prop does indeed remove that instance number from the battle.



 
Does anybody know any guides which describe how to add a new faces in game or replace existing?

Does anyone know why there isn't musket animation while in battle? troops use pistol animation but i have musket one
 
Status
Not open for further replies.
Back
Top Bottom