I was trying to add constant damage per shield and shield skill to add a bonus, I noticed a tiny mistake,
agent_id is not equal to troop_id
Code:
(store_skill_level,":a_shield",skl_shield,":victim"),
(store_skill_level,":v_shield",skl_shield,":agent"),
Those lines check totally unrelated troops skills.
Edit;
Whoops forgot my addon
#Fixx0red script, remove the debug stuff
("cf_agent_shield_bash",
[(store_script_param, ":agent",1),
(store_script_param, ":shield", 2),
(agent_get_position,pos1,":agent"),
(agent_set_animation, ":agent", "anim_release_bash"),
(agent_play_sound,":agent","snd_man_grunt"),
(assign,":victim",-1),
(try_for_agents,":possible_victim"),
(agent_is_alive,":possible_victim"),
(agent_is_human,":possible_victim"),
(neq,":possible_victim",":agent"),
(agent_get_class ,":class", ":possible_victim"),
(neq,":class",grc_cavalry),
(agent_get_position,pos2,":possible_victim"),
(get_distance_between_positions,":dist",pos1,pos2),
(lt,":dist",150),
(neg|position_is_behind_position,pos2,pos1),
(assign,":victim",":possible_victim"),
(end_try),
#Random not...
(gt,":victim",-1),
(store_agent_hit_points,":hp",":victim",1),
(store_random_in_range,":hit_reaction",1,101),
#This doesn't work like that, agent_id is not equal to troop_id
# (store_skill_level,":a_shield",skl_shield,":victim"),
# (store_skill_level,":v_shield",skl_shield,":agent"),
(agent_get_troop_id,":victim_trp_id", ":victim"),
(agent_get_troop_id,":agent_trp_id", ":agent"),
(store_skill_level,":v_shield",skl_shield,":victim_trp_id"),
(store_skill_level,":a_shield",skl_shield,":agent_trp_id"),
#Let's get skl_shield involved more, every 2 points add 1 damage, so the most damaging shield can plant a nice 9 damage
(item_get_slot,":shield_str", ":shield",slot_shield_damage_value),
(assign, ":shield_skl_dmg_bonus", ":a_shield"),
(val_div, ":shield_skl_dmg_bonus", 2),
(store_add, ":shield_damage", ":shield_str", ":shield_skl_dmg_bonus"),
(str_store_item_name, s1, ":shield"),
(str_store_troop_name,s2,":victim_trp_id"),
(str_store_troop_name,s3,":agent_trp_id"),
(assign, reg0, ":shield_damage"),
(assign, reg1, ":shield_skl_dmg_bonus"),
(assign, reg2, ":shield_str"),
(display_message, "@Calculated Damage {reg0} (shield damage was {reg2} bonus was; {reg1} for {s1}"),
(display_message, "@Victim was {s2} Agent was {s3}"),
(val_sub,":hp",":shield_damage"),
(try_begin),
(gt,":hp",0),
(agent_set_hit_points,":victim",":hp",1),
(agent_play_sound,":agent","snd_shield_hit_wood_wood"),
(agent_play_sound,":victim","snd_blunt_hit"),
(try_begin),
(gt,":a_shield", ":v_shield"),
(try_begin),
(is_between,":hit_reaction",0,10),
(agent_set_animation, ":victim", "anim_bash_unsuccessful"),
(else_try),
(is_between,":hit_reaction",11,20),
(agent_set_animation, ":victim", "anim_bash_crouch"),
(else_try),
(is_between,":hit_reaction",21,30),
(agent_set_animation, ":victim", "anim_bash_mini_stun"),
(else_try),
(is_between,":hit_reaction",31,79),
(agent_set_animation, ":victim", "anim_bash_stun"),
(else_try),
(is_between,":hit_reaction",80,100),
(agent_set_animation, ":victim", "anim_bash_knocked"),
(end_try),
(else_try),
(lt,":a_shield", ":v_shield"),
(try_begin),
(is_between,":hit_reaction",0,20),
(agent_set_animation, ":victim", "anim_bash_unsuccessful"),
(else_try),
(is_between,":hit_reaction",21,42),
(agent_set_animation, ":victim", "anim_bash_crouch"),
(else_try),
(is_between,":hit_reaction",43,65),
(agent_set_animation, ":victim", "anim_bash_mini_stun"),
(else_try),
(is_between,":hit_reaction",66,92),
(agent_set_animation, ":victim", "anim_bash_stun"),
(else_try),
(is_between,":hit_reaction",93,100),
(agent_set_animation, ":victim", "anim_bash_knocked"),
(end_try),
(else_try),
(eq,":a_shield", ":v_shield"),
(try_begin),
(is_between,":hit_reaction",0,16),
(agent_set_animation, ":victim", "anim_bash_unsuccessful"),
(else_try),
(is_between,":hit_reaction",17,33),
(agent_set_animation, ":victim", "anim_bash_crouch"),
(else_try),
(is_between,":hit_reaction",34,50),
(agent_set_animation, ":victim", "anim_bash_mini_stun"),
(else_try),
(is_between,":hit_reaction",51,89),
(agent_set_animation, ":victim", "anim_bash_stun"),
(else_try),
(is_between,":hit_reaction",90,100),
(agent_set_animation, ":victim", "anim_bash_knocked"),
(end_try),
(end_try),
(else_try),
(agent_play_sound,":agent","snd_shield_hit_wood_wood"),
(agent_play_sound,":victim","snd_blunt_hit"),
(agent_deliver_damage_to_agent,":agent",":victim"),
(end_try),
]),
add to game_start, I just needed different values to test the script...
#Set Shield Damage Values
# itm_wooden_shield, itm_tab_shield_kite_a
(try_for_range, ":cur_item", "itm_wooden_shield","itm_heraldic_mail_with_surcoat"),
(try_begin),
# itm_wooden_shield, itm_tab_shield_kite_a
(is_between, ":cur_item", "itm_wooden_shield", "itm_tab_shield_kite_a"),
(item_set_slot,":cur_item",slot_shield_damage_value,1),
(else_try),
# itm_tab_shield_kite_a itm_tab_shield_pavise_a
(is_between, ":cur_item", "itm_tab_shield_kite_a", "itm_tab_shield_pavise_a"),
(item_set_slot,":cur_item",slot_shield_damage_value,2),
(else_try),
# itm_tab_shield_pavise_a itm_tab_shield_small_round_a
(is_between, ":cur_item", "itm_tab_shield_pavise_a", "itm_tab_shield_small_round_a"),
(item_set_slot,":cur_item",slot_shield_damage_value,3),
(else_try),
# itm_tab_shield_small_round_a itm_heraldic_mail_with_surcoat
(is_between, ":cur_item", "itm_tab_shield_small_round_a", "itm_heraldic_mail_with_surcoat"),
(item_set_slot,":cur_item",slot_shield_damage_value,1),
(try_end),
(try_end),
#exceptions; itm_steel_shield
(item_set_slot,"itm_steel_shield",slot_shield_damage_value,4),
Mission Template Changes, so that we know the shield,
(0, 0, 0, [(game_key_is_down, gk_defend),(game_key_clicked, gk_attack),],
[(assign,":continue",0),
(get_player_agent_no,":player"),
(agent_is_alive,":player"),
(try_for_range,":shield","itm_wooden_shield","itm_heraldic_mail_with_surcoat"),
(agent_has_item_equipped,":player",":shield"),
(assign, ":wielded_shield", ":shield"),
(assign,":continue",1),
(end_try),
(eq,":continue",1),
(agent_get_horse,":horse",":player"),
(neg|gt,":horse",0),
(ge,"$bash_readiness",10),
(assign,"$bash_readiness",0),
(call_script,"script_cf_agent_shield_bash",":player", ":wielded_shield"),
]),
(1.0, 0, 0, [],
[(get_player_agent_no,":player"),
(try_for_agents,":agent"),
(agent_is_alive,":agent"),
(agent_is_human,":agent"),
(neq,":agent",":player"),
(agent_get_class ,":class", ":agent"),
(neq,":class",grc_cavalry),
(assign,":continue",0),
(try_for_range,":shield","itm_wooden_shield","itm_heraldic_mail_with_surcoat"),
(agent_has_item_equipped,":agent",":shield"),
(assign, ":wielded_shield", ":shield"),
(assign,":continue",1),
(end_try),
(eq,":continue",1),
(assign,":chances",0),
(agent_get_team,":team",":agent"),
(agent_get_position,pos1,":agent"),
(try_for_agents,"
ther"),
(agent_is_alive,"
ther"),
(agent_is_human,"
ther"),
(agent_get_class ,":class", "
ther"),
(neq,":class",grc_cavalry),
(agent_get_team,"
therteam","
ther"),
(neq,":team","
therteam"),
(agent_get_position,pos2,"
ther"),
(get_distance_between_positions,":dist",pos1,pos2),
(neg|position_is_behind_position,pos2,pos1),
(lt,":dist",200),
(val_add,":chances",1),
(end_try),
(store_agent_hit_points,":health",":agent",0),
(val_mul,":health",-1),
(val_add,":health",100),
(val_div,":health",10),
(val_mul,":chances",":health"),
(store_random_in_range,":rand",1,25),
(lt,":rand",":chances"),
(call_script,"script_cf_agent_shield_bash",":agent", ":wielded_shield"),
(end_try),]),
ofcourse it is useless without this in constants;
slot_shield_damage_value = 5
finally game_get_item_extra_text to show how much base damage shield has in item description...
(else_try),
(is_between, ":item_no", "itm_wooden_shield","itm_heraldic_mail_with_surcoat"),
(try_begin),
(eq, ":extra_text_id", 0),
(item_get_slot, reg1, ":item_no", slot_shield_damage_value),
(set_result_string, "@Bashing Damage {reg1}b"),
(set_trigger_result, 0xFFEEDD),
(try_end),