﻿-- chunkname: @scripts/settings/buff/weapon_traits_buff_templates/weapon_traits_bespoke_ogryn_heavystubber_p2_buff_templates.lua

local Ammo = require("scripts/utilities/ammo")
local BaseWeaponTraitBuffTemplates = require("scripts/settings/buff/weapon_traits_buff_templates/base_weapon_trait_buff_templates")
local BuffSettings = require("scripts/settings/buff/buff_settings")
local ConditionalFunctions = require("scripts/settings/buff/helper_functions/conditional_functions")
local FireStepFunctions = require("scripts/settings/buff/fire_step_functions")
local stat_buffs = BuffSettings.stat_buffs
local templates = {}

table.make_unique(templates)

templates.weapon_trait_bespoke_ogryn_heavystubber_p2_consecutive_hits_increases_ranged_power_parent = table.clone(BaseWeaponTraitBuffTemplates.consecutive_hits_increases_ranged_power_parent)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_consecutive_hits_increases_ranged_power_child = table.clone(BaseWeaponTraitBuffTemplates.consecutive_hits_increases_ranged_power_child)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_consecutive_hits_increases_ranged_power_parent.child_buff_template = "weapon_trait_bespoke_ogryn_heavystubber_p2_consecutive_hits_increases_ranged_power_child"
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_power_bonus_on_continuous_fire = table.merge({
	conditional_stat_buffs = {
		[stat_buffs.power_level_modifier] = 0.02,
	},
	continuous_fire_step_func = FireStepFunctions.default_continuous_fire_step_func,
}, BaseWeaponTraitBuffTemplates.stacking_buff_on_continuous_fire)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_toughness_on_continuous_fire = table.merge({
	toughness_fixed_percentage = 0.1,
	continuous_fire_step_func = function (template_data, template_context)
		if ConditionalFunctions.is_reloading(template_data, template_context) then
			return 0
		end

		local inventory_slot_component = template_data.inventory_slot_component

		if not inventory_slot_component then
			return 0
		end

		local max_ammunition_clip = Ammo.max_ammo_in_clips(inventory_slot_component)

		return math.max(1, math.floor(max_ammunition_clip * 0.05))
	end,
}, BaseWeaponTraitBuffTemplates.toughness_on_continuous_fire)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_increased_suppression_on_continuous_fire = table.merge({
	conditional_stat_buffs = {
		[stat_buffs.suppression_dealt] = 0.5,
		[stat_buffs.damage_vs_suppressed] = 0.06,
	},
	continuous_fire_step_func = FireStepFunctions.suppression_continuous_fire_step_func,
}, BaseWeaponTraitBuffTemplates.stacking_buff_on_continuous_fire)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_movement_speed_on_continous_fire = table.merge({
	conditional_stat_buffs = {
		[stat_buffs.alternate_fire_movement_speed_reduction_modifier] = 0.5,
		[stat_buffs.weapon_action_movespeed_reduction_multiplier] = 0.5,
	},
	continuous_fire_step_func = FireStepFunctions.movement_speed_continuous_fire_step_func,
}, BaseWeaponTraitBuffTemplates.stacking_buff_on_continuous_fire)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_suppression_on_close_kill = table.clone(BaseWeaponTraitBuffTemplates.suppression_on_close_kill)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_increase_power_on_close_kill_parent = table.clone(BaseWeaponTraitBuffTemplates.increase_power_on_close_kill_parent)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_increase_power_on_close_kill_parent.child_buff_template = "weapon_trait_bespoke_ogryn_heavystubber_p2_increase_power_on_close_kill_child"
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_increase_power_on_close_kill_child = table.clone(BaseWeaponTraitBuffTemplates.increase_power_on_close_kill_child)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_ammo_from_reserve_on_crit = table.clone(BaseWeaponTraitBuffTemplates.move_ammo_from_reserve_to_clip_on_crit)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_increase_close_damage_on_close_kill_parent = table.clone(BaseWeaponTraitBuffTemplates.increase_close_damage_on_close_kill_parent)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_increase_close_damage_on_close_kill_parent.child_buff_template = "weapon_trait_bespoke_ogryn_heavystubber_p2_increase_close_damage_on_close_kill_child"
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_increase_close_damage_on_close_kill_child = table.clone(BaseWeaponTraitBuffTemplates.increase_close_damage_on_close_kill_child)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_recoil_reduction_and_suppression_increase_on_close_kills = table.clone(BaseWeaponTraitBuffTemplates.recoil_reduction_and_suppression_increase_on_close_kills)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stagger_count_bonus_damage = table.clone(BaseWeaponTraitBuffTemplates.stagger_count_bonus_damage)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_burninating_on_crit = table.clone(BaseWeaponTraitBuffTemplates.burninating_on_crit_ranged)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_crit_weakspot_finesse = table.clone(BaseWeaponTraitBuffTemplates.crit_weakspot_finesse)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_suppression_negation_on_weakspot = table.clone(BaseWeaponTraitBuffTemplates.suppression_negation_on_weakspot)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_crit_chance_based_on_aim_time = table.clone(BaseWeaponTraitBuffTemplates.chance_based_on_aim_time)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_crit_chance_on_weakspot_parent = table.clone(BaseWeaponTraitBuffTemplates.stacking_crit_chance_on_weakspot_parent)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_crit_chance_on_weakspot_parent.child_buff_template = "weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_crit_chance_on_weakspot_child"
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_crit_chance_on_weakspot_child = table.clone(BaseWeaponTraitBuffTemplates.stacking_crit_chance_on_weakspot_child)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_power_bonus_on_staggering_enemies_parent = table.clone(BaseWeaponTraitBuffTemplates.stacking_power_bonus_on_staggering_enemies_parent)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_power_bonus_on_staggering_enemies_parent.child_buff_template = "weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_power_bonus_on_staggering_enemies_child"
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_power_bonus_on_staggering_enemies_child = table.clone(BaseWeaponTraitBuffTemplates.stacking_power_bonus_on_staggering_enemies_child)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_power_bonus_on_first_shot = table.clone(BaseWeaponTraitBuffTemplates.power_bonus_on_first_shot)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_toughness_on_elite_kills = table.clone(BaseWeaponTraitBuffTemplates.toughness_on_elite_kills)
templates.weapon_trait_bespoke_ogryn_heavystubber_p2_stacking_crit_bonus_on_continuous_fire = table.merge({
	conditional_stat_buffs = {
		[stat_buffs.critical_strike_chance] = 0.01,
	},
	continuous_fire_step_func = FireStepFunctions.default_continuous_fire_step_func,
}, BaseWeaponTraitBuffTemplates.stacking_buff_on_continuous_fire)

return templates
