Hello folks, just thought I'd share a trigger that made for in-battle weapon breaking.
Whenever you hit an enemy there is a chance that your weapon will be destroyed/lost (Simulates weapon wear and weapons being stuck in enemy or lances shattering completely.)
Different break rates.
All weapons are a little more likely to be lost on horseback.
Polearms are lost MUCH more when on horseback.
Polearms on foot are lost a little more than other weapons.
Two handed weapons are lost a little more than one handed weapons.
When you lose your weapon it is gone forever, remember that you can get spare weapons from your box when they break.
Code:
Numbers can be changed based on your preference, remember not to use decimals! That is why I multiply by 101 ect and then divide by 100.
common_weapon_break will need to be added to each mission template you want it in, WARNING:It does not work as-is on multiplayer, if you want to figure that out yourself go ahead.
Any questions, please ask.
Whenever you hit an enemy there is a chance that your weapon will be destroyed/lost (Simulates weapon wear and weapons being stuck in enemy or lances shattering completely.)
Different break rates.
All weapons are a little more likely to be lost on horseback.
Polearms are lost MUCH more when on horseback.
Polearms on foot are lost a little more than other weapons.
Two handed weapons are lost a little more than one handed weapons.
When you lose your weapon it is gone forever, remember that you can get spare weapons from your box when they break.
Code:
common_weapon_break = (
0.4, 0, 0,
[
#(player_get_agent_id, ":player_agent", ":player_no"),
(get_player_agent_no, ":player_agent"),
(agent_get_attack_action, ":playeraction", ":player_agent"), #returned values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7
(try_begin),
(eq,":playeraction",3),
(agent_get_wielded_item,":breakweapon",":player_agent",0),
(gt,":breakweapon",2),
(item_get_type, ":weapontype", ":breakweapon"),
(agent_get_horse,":playermounted",":player_agent"),
(store_random_in_range,":weaponbreakchance",1,100),
(try_begin),
(ge,":playermounted",0),
# (display_message, "@Mounted."),
(val_mul,":weaponbreakchance",104),
(val_div,":weaponbreakchance",100),
(eq,itp_type_polearm,":weapontype"),
(val_mul,":weaponbreakchance",110),
(val_div,":weaponbreakchance",100),
(try_end),
(try_begin),
(eq,itp_type_polearm,":weapontype"),
# (display_message, "@Polearm"),
(val_mul,":weaponbreakchance",102),
(val_div,":weaponbreakchance",100),
(try_end),
(try_begin),
(eq,itp_type_two_handed_wpn,":weapontype"),
# (display_message, "@2 hander"),
(val_mul,":weaponbreakchance",101),
(val_div,":weaponbreakchance",100),
(try_end),
(try_begin),
(eq,itp_type_one_handed_wpn,":weapontype"),
# (display_message, "@1 hander"),
(val_mul,":weaponbreakchance",1),
(try_end),
(try_begin),
(assign, reg8, ":weaponbreakchance"),
# (display_message, "@{reg8}"),
(ge,":weaponbreakchance",9,
(agent_unequip_item,":player_agent",":breakweapon"),
(play_sound,"snd_shield_broken",),
(troop_remove_item, "trp_player", ":breakweapon"),
(display_message, "@Hah! Your weapon broke."),
(lt,":playermounted",0),
(agent_set_animation, ":player_agent", "anim_strike_chest_front"),
(try_end),
(try_end),
], [])
0.4, 0, 0,
[
#(player_get_agent_id, ":player_agent", ":player_no"),
(get_player_agent_no, ":player_agent"),
(agent_get_attack_action, ":playeraction", ":player_agent"), #returned values: free = 0, readying_attack = 1, releasing_attack = 2, completing_attack_after_hit = 3, attack_parried = 4, reloading = 5, after_release = 6, cancelling_attack = 7
(try_begin),
(eq,":playeraction",3),
(agent_get_wielded_item,":breakweapon",":player_agent",0),
(gt,":breakweapon",2),
(item_get_type, ":weapontype", ":breakweapon"),
(agent_get_horse,":playermounted",":player_agent"),
(store_random_in_range,":weaponbreakchance",1,100),
(try_begin),
(ge,":playermounted",0),
# (display_message, "@Mounted."),
(val_mul,":weaponbreakchance",104),
(val_div,":weaponbreakchance",100),
(eq,itp_type_polearm,":weapontype"),
(val_mul,":weaponbreakchance",110),
(val_div,":weaponbreakchance",100),
(try_end),
(try_begin),
(eq,itp_type_polearm,":weapontype"),
# (display_message, "@Polearm"),
(val_mul,":weaponbreakchance",102),
(val_div,":weaponbreakchance",100),
(try_end),
(try_begin),
(eq,itp_type_two_handed_wpn,":weapontype"),
# (display_message, "@2 hander"),
(val_mul,":weaponbreakchance",101),
(val_div,":weaponbreakchance",100),
(try_end),
(try_begin),
(eq,itp_type_one_handed_wpn,":weapontype"),
# (display_message, "@1 hander"),
(val_mul,":weaponbreakchance",1),
(try_end),
(try_begin),
(assign, reg8, ":weaponbreakchance"),
# (display_message, "@{reg8}"),
(ge,":weaponbreakchance",9,
(agent_unequip_item,":player_agent",":breakweapon"),
(play_sound,"snd_shield_broken",),
(troop_remove_item, "trp_player", ":breakweapon"),
(display_message, "@Hah! Your weapon broke."),
(lt,":playermounted",0),
(agent_set_animation, ":player_agent", "anim_strike_chest_front"),
(try_end),
(try_end),
], [])
Numbers can be changed based on your preference, remember not to use decimals! That is why I multiply by 101 ect and then divide by 100.
common_weapon_break will need to be added to each mission template you want it in, WARNING:It does not work as-is on multiplayer, if you want to figure that out yourself go ahead.
Any questions, please ask.