WB Coding Raising Troop Attributes in both client and server side

Users who are viewing this thread

Naber La

Sergeant at Arms
WBNWWF&SVCM&B
Hello fellow modders I wish to ask a question about one operation in a spesific situation on warband. So I was using troop raise skill and troop raise attribute on server side which troop was in use by a player. I couldn't test it properly if it affects agility or athletics skill properly for server side and client side as well. But as far as i notice that it doesn't change value of skill level or attribute level in client side. (i am not sure about the benefits with the level as well as moving faster with agility or the skills). When i try to print my troop skill or attribute level on a presentation i made for a character sheet on a multiplayer scene. It wasn't changing so i stored troop attribute and skill level in server side and sent it to client side and stored it in global variables. Is it me mistaken with something or is it about the warband engine? Thanks for your patience and interest in this matter.

Code:
(neg|multiplayer_is_server),
(eq, ":event_type", server_event_set_stats),
(store_script_param, ":stat", 3),
(store_script_param, ":value", 4),

(try_begin),
    (eq, ":stat", ca_strength),
    (assign, "$g_character_sheet_str", ":value"),
(else_try),
    (eq, ":stat", ca_agility),
    (assign, "$g_character_sheet_agi", ":value"),
(else_try),
    (eq, ":stat", ca_intelligence),
    (assign, "$g_character_sheet_int", ":value"),
(else_try),
    (eq, ":stat", "skl_herding"),
    (assign, "$g_character_sheet_herding", ":value"),
(else_try),
    (eq, ":stat", "skl_prospecting"),
    (assign, "$g_character_sheet_prospecting", ":value"),
(else_try),
    (eq, ":stat", "skl_forestry"),
    (assign, "$g_character_sheet_forestry", ":value"),
(else_try),
    (eq, ":stat", "skl_labouring"),
    (assign, "$g_character_sheet_labouring", ":value"),
(else_try),
    (eq, ":stat", "skl_engineer"),
    (assign, "$g_character_sheet_engineer", ":value"),
(else_try),
    (eq, ":stat", "skl_first_aid"),
    (assign, "$g_character_sheet_first_aid", ":value"),
(else_try),
    (eq, ":stat", "skl_surgery"),
    (assign, "$g_character_sheet_surgery", ":value"),
(else_try),
    (eq, ":stat", "skl_wound_treatment"),
    (assign, "$g_character_sheet_wound_treatment", ":value"),
(else_try),
    (eq, ":stat", "skl_tracking"),
    (assign, "$g_character_sheet_tracking", ":value"),
(else_try),
    (eq, ":stat", "skl_trainer"),
    (assign, "$g_character_sheet_trainer", ":value"),
(else_try),
    (eq, ":stat", "skl_tailoring"),
    (assign, "$g_character_sheet_tailoring", ":value"),
(else_try),
    (eq, ":stat", "skl_weapon_smithing"),
    (assign, "$g_character_sheet_weapon_smithing", ":value"),
(else_try),
    (eq, ":stat", "skl_armour_smithing"),
    (assign, "$g_character_sheet_armour_smithing", ":value"),
(else_try),
    (eq, ":stat", "skl_white_smithing"),
    (assign, "$g_character_sheet_white_smithing", ":value"),
(else_try),
    (eq, ":stat", "skl_horse_archery"),
    (assign, "$g_character_sheet_horse_archery", ":value"),
(else_try),
    (eq, ":stat", "skl_riding"),
    (assign, "$g_character_sheet_riding", ":value"),
(else_try),
    (eq, ":stat", "skl_athletics"),
    (assign, "$g_character_sheet_athletics", ":value"),
(else_try),
    (eq, ":stat", "skl_shield"),
    (assign, "$g_character_sheet_shield", ":value"),
(else_try),
    (eq, ":stat", "skl_weapon_master"),
    (assign, "$g_character_sheet_weapon_master", ":value"),
(else_try),
    (eq, ":stat", "skl_power_draw"),
    (assign, "$g_character_sheet_power_draw", ":value"),
(else_try),
    (eq, ":stat", "skl_power_throw"),
    (assign, "$g_character_sheet_power_throw", ":value"),
(else_try),
    (eq, ":stat", "skl_power_strike"),
    (assign, "$g_character_sheet_power_strike", ":value"),
(else_try),
    (eq, ":stat", "skl_ironflesh"),
    (assign, "$g_character_sheet_ironflesh", ":value"),
(try_end),

Code:
(multiplayer_is_server),
(eq, ":event_type", multiplayer_event_send_stats),
(store_script_param, ":player_id", 3),

(player_get_troop_id, ":troop_id", ":player_id"),

(try_for_range, ":skl", "skl_herding", "skl_reserved_14"),
    (this_or_next|neq, ":skl", "skl_persuasion"),
    (this_or_next|neq, ":skl", "skl_inventory_management"),
    (this_or_next|neq, ":skl", "skl_spotting"),
    (this_or_next|neq, ":skl", "skl_pathfinding"),
    (this_or_next|neq, ":skl", "skl_tactics"),
    (this_or_next|neq, ":skl", "skl_looting"),
    (this_or_next|neq, ":skl", "skl_reserved_9"),
    (this_or_next|neq, ":skl", "skl_reserved_10"),
    (this_or_next|neq, ":skl", "skl_reserved_11"),
    (this_or_next|neq, ":skl", "skl_reserved_12"),
    (neq, ":skl", "skl_reserved_13"),
    (store_skill_level, ":skl_lvl", ":skl", ":troop_id"),
    (multiplayer_send_2_int_to_player, ":player_id", server_event_set_stats, ":skl", ":skl_lvl"),
(try_end),
(try_for_range, ":attr", ca_strength, ca_charisma),
    (store_attribute_level, ":attr_lvl", ":troop_id", ":attr"),
    (multiplayer_send_2_int_to_player, ":player_id", server_event_set_stats, ":attr", ":attr_lvl"),
(try_end),

Code:
("character_sheet", prsntf_manual_end_only, 0,
[
    (ti_on_presentation_load,
    [
        (set_fixed_point_multiplier, 1000),

        (create_mesh_overlay, reg0, "mesh_character_window"),
        (position_set_x, pos0, 0),
        (position_set_y, pos0, 0),
        (overlay_set_position, reg0, pos0),
        (position_set_x, pos0, 1000),
        (position_set_y, pos0, 1000),
        (overlay_set_size, reg0, pos0),

        (multiplayer_get_my_player, ":player_id"),
        (player_get_troop_id, ":trp_id", ":player_id"),

        (multiplayer_send_int_to_server, multiplayer_event_send_stats, ":player_id"),

        (store_attribute_level, reg1, ":trp_id", ca_strength),
        (store_attribute_level, reg2, ":trp_id", ca_agility),
        (store_attribute_level, reg3, ":trp_id", ca_intelligence),

        (assign, ":start_x", 50),
        (assign, ":mid_x", 175),
        (assign, ":cur_y", 200),

        (create_text_overlay, reg0, "@Strength:"),
        (overlay_set_color, reg0, 0x000000),
        (position_set_x, pos0, ":start_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, reg0, pos0),

        (create_text_overlay, "$g_presentation_character_button_sheet_obj_1", "@{reg1}"),
        (overlay_set_color, "$g_presentation_character_button_sheet_obj_1", 0x000000),
        (position_set_x, pos0, ":mid_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, "$g_presentation_character_button_sheet_obj_1", pos0),

        (val_sub, ":cur_y", escape_menu_item_height),

        (create_text_overlay, reg0, "@Agility:"),
        (overlay_set_color, reg0, 0x000000),
        (position_set_x, pos0, ":start_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, reg0, pos0),

        (create_text_overlay, "$g_presentation_character_button_sheet_obj_2", "@{reg2}"),
        (overlay_set_color, "$g_presentation_character_button_sheet_obj_2", 0x000000),
        (position_set_x, pos0, ":mid_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, "$g_presentation_character_button_sheet_obj_2", pos0),

        (val_sub, ":cur_y", escape_menu_item_height),

        (create_text_overlay, reg0, "@Intelligence:"),
        (overlay_set_color, reg0, 0x000000),
        (position_set_x, pos0, ":start_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, reg0, pos0),

        (create_text_overlay, "$g_presentation_character_button_sheet_obj_3", "@{reg3}"),
        (overlay_set_color, "$g_presentation_character_button_sheet_obj_3", 0x000000),
        (position_set_x, pos0, ":mid_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, "$g_presentation_character_button_sheet_obj_3", pos0),

        (presentation_set_duration, 1000000),
    ]),
    #(ti_on_presentation_event_state_change,
    #[
    #    (store_trigger_param_1, "bject"),
    #
    #    (presentation_set_duration, 0),
    #]),
    (ti_on_presentation_run,
    [
        (store_trigger_param_1, ":cur_time"),

        (try_begin),
            (this_or_next|key_clicked, key_escape),
            (this_or_next|game_key_clicked, gk_character_window),
            (key_clicked, key_xbox_start),
            (gt, ":cur_time", 200),
            (presentation_set_duration, 0),
        (else_try),
            (assign, reg0, "$g_character_sheet_str"),
            (assign, reg1, "$g_character_sheet_agi"),
            (assign, reg2, "$g_character_sheet_int"),

            (overlay_set_text, "$g_presentation_character_button_sheet_obj_1", "@{reg0}"),
            (overlay_set_text, "$g_presentation_character_button_sheet_obj_2", "@{reg1}"),
            (overlay_set_text, "$g_presentation_character_button_sheet_obj_3", "@{reg2}"),
        (try_end),
    ]),
]),

When i simplify it with deleting network messages and storing it inside presentations it just shows default character skill level or attribute level. Default skill level is 0 and attribute level is 6. (Don't mind the variable names as button obj. Actually most of them are text obj. I forgot to change it in last build.)
 
Solution
Sorry for Double posting but I had find the answer and I would like to share it with you. My findings is that you have to warn the client side about the troop skill changes and attributes. And i have a last build which works correctly according to these. Tested it and I would guarantee the success.

So I have removed multiplayer_event_send_stats from game_receive_network_message in module_scripts.py and changed others to connect them via game variables -which is attributes and skills- not custom.


Code:
(neg|multiplayer_is_server),
(eq, ":event_type", server_event_set_stats),
(store_script_param, ":stat", 3),
(store_script_param, ":value", 4),

(multiplayer_get_my_player, ":player_id"),
(player_is_active, ":player_id")...

Naber La

Sergeant at Arms
WBNWWF&SVCM&B
Sorry for Double posting but I had find the answer and I would like to share it with you. My findings is that you have to warn the client side about the troop skill changes and attributes. And i have a last build which works correctly according to these. Tested it and I would guarantee the success.

So I have removed multiplayer_event_send_stats from game_receive_network_message in module_scripts.py and changed others to connect them via game variables -which is attributes and skills- not custom.


Code:
(neg|multiplayer_is_server),
(eq, ":event_type", server_event_set_stats),
(store_script_param, ":stat", 3),
(store_script_param, ":value", 4),

(multiplayer_get_my_player, ":player_id"),
(player_is_active, ":player_id"),
(player_get_agent_id, ":agent_id", ":player_id"),
(neg|agent_is_non_player, ":agent_id"),
(agent_is_active, ":agent_id"),
(agent_is_human, ":agent_id"),
(agent_is_alive, ":agent_id"),

(player_get_troop_id, ":troop_id", ":player_id"),

(try_begin),
    (this_or_next|neq, ":stat", ca_strength),
    (this_or_next|neq, ":stat", ca_agility),
    (this_or_next|neq, ":stat", ca_intelligence),
    (neq, ":stat", ca_charisma),
    (troop_raise_skill, ":troop_id", ":stat", ":value"),
(try_end),

(try_begin),
    (this_or_next|eq, ":stat", ca_strength),
    (this_or_next|eq, ":stat", ca_agility),
    (this_or_next|eq, ":stat", ca_intelligence),
    (eq, ":stat", ca_charisma),
    (troop_raise_attribute, ":troop_id", ":stat", ":value"),
(try_end),


Code:
("character_sheet", prsntf_manual_end_only, 0,
[
    (ti_on_presentation_load,
    [
        (set_fixed_point_multiplier, 1000),

        (create_mesh_overlay, reg0, "mesh_character_window"),
        (position_set_x, pos0, 0),
        (position_set_y, pos0, 0),
        (overlay_set_position, reg0, pos0),
        (position_set_x, pos0, 1000),
        (position_set_y, pos0, 1000),
        (overlay_set_size, reg0, pos0),

        (multiplayer_get_my_player, ":player_id"),
        (player_get_troop_id, ":trp_id", ":player_id"),

        (store_attribute_level, reg1, ":trp_id", ca_strength),
        (store_attribute_level, reg2, ":trp_id", ca_agility),
        (store_attribute_level, reg3, ":trp_id", ca_intelligence),

        (assign, ":start_x", 50),
        (assign, ":mid_x", 175),
        (assign, ":cur_y", 200),

        (create_text_overlay, reg0, "@Strength:"),
        (overlay_set_color, reg0, 0x000000),
        (position_set_x, pos0, ":start_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, reg0, pos0),

        (create_text_overlay, "$g_presentation_character_button_sheet_obj_1", "@{reg1}"),
        (overlay_set_color, "$g_presentation_character_button_sheet_obj_1", 0x000000),
        (position_set_x, pos0, ":mid_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, "$g_presentation_character_button_sheet_obj_1", pos0),

        (val_sub, ":cur_y", escape_menu_item_height),

        (create_text_overlay, reg0, "@Agility:"),
        (overlay_set_color, reg0, 0x000000),
        (position_set_x, pos0, ":start_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, reg0, pos0),

        (create_text_overlay, "$g_presentation_character_button_sheet_obj_2", "@{reg2}"),
        (overlay_set_color, "$g_presentation_character_button_sheet_obj_2", 0x000000),
        (position_set_x, pos0, ":mid_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, "$g_presentation_character_button_sheet_obj_2", pos0),

        (val_sub, ":cur_y", escape_menu_item_height),

        (create_text_overlay, reg0, "@Intelligence:"),
        (overlay_set_color, reg0, 0x000000),
        (position_set_x, pos0, ":start_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, reg0, pos0),

        (create_text_overlay, "$g_presentation_character_button_sheet_obj_3", "@{reg3}"),
        (overlay_set_color, "$g_presentation_character_button_sheet_obj_3", 0x000000),
        (position_set_x, pos0, ":mid_x"),
        (position_set_y, pos0, ":cur_y"),
        (overlay_set_position, "$g_presentation_character_button_sheet_obj_3", pos0),

        (presentation_set_duration, 1000000),
    ]),
    #(ti_on_presentation_event_state_change,
    #[
    #    (store_trigger_param_1, ":object"),
    #
    #    (presentation_set_duration, 0),
    #]),
    (ti_on_presentation_run,
    [
        (store_trigger_param_1, ":cur_time"),

        (try_begin),
            (this_or_next|key_clicked, key_escape),
            (this_or_next|game_key_clicked, gk_character_window),
            (key_clicked, key_xbox_start),
            (gt, ":cur_time", 200),
            (presentation_set_duration, 0),
        (else_try),
            (multiplayer_get_my_player, ":player_id"),
            (player_get_troop_id, ":trp_id", ":player_id"),
            (store_attribute_level, reg0, ":trp_id", ca_strength),
            (store_attribute_level, reg1, ":trp_id", ca_agility),
            (store_attribute_level, reg2, ":trp_id", ca_intelligence),

            (overlay_set_text, "$g_presentation_character_button_sheet_obj_1", "@{reg0}"),
            (overlay_set_text, "$g_presentation_character_button_sheet_obj_2", "@{reg1}"),
            (overlay_set_text, "$g_presentation_character_button_sheet_obj_3", "@{reg2}"),
        (try_end),
    ]),
]),

If you have read all of the codes and understand it you would be wondering that there is no triggering event happens to raise skill or attribute. Which I do it in some circumstances. So to test it you have to just raise your attributes in multiplayer by using like this:
Code:
(multiplayer_send_2_int_to_player, ":player_id", server_event_set_stats, "skl_athletics", ":addition"),
and this:
Code:
(multiplayer_send_2_int_to_player, ":player_id", server_event_set_stats, ca_agility, ":addition"),

instead of athletics or agility you could use whatever you want as skill or attribute.
 
Upvote 0
Solution

Eärendil Ardamírë

Subforum Moderator
WBWF&SM&B
Nice that you have already found a solution for your problem and especially that you shared it with us. Others might find it useful when facing a similar problem, so thanks for that :smile:
 
Upvote 0
Top Bottom