-- this is basically a modified version of scroobs metal popper local function makeGameText(activator) local text = "0" local gametext = ents.CreateWithKeys("game_text", { color = "255 255 255", channel = 4, holdtime = 198444444, effect = 0, fadein = 0, message = text:format("0"), X = 0.35, Y = 0.8 }, true, true) gametext:SetParent(activator) gametext:AcceptInput("Display", true, activator) return gametext end local function setText(gametext, newMessage, activator) gametext:AddOutput("message " .. newMessage) gametext:AcceptInput("Display", true, activator) end local function round(number, numDecimalPlaces) local factor = 10 ^ numDecimalPlaces return math.floor(number * factor + 0.5) / factor end local playsound = false local was_played = false local gameTexts = {} AddEventCallback("player_hurt", function(eventTable) local attacker = ents.GetPlayerByUserId(eventTable.attacker) if not attacker then return end --local melee = attacker:GetPlayerItemBySlot(0) attacker:GetPlayerItemBySlot(2) if attacker:InCond(12) == true then return end if attacker:GetPlayerItemBySlot(1) == nil then return end if attacker:GetPlayerItemBySlot(1):GetItemName() == "Berserker Shotgun" then if gameTexts[eventTable.attacker] == nil then gameTexts[eventTable.attacker] = makeGameText(attacker) end attacker.m_flRageMeter = attacker.m_flRageMeter + (0.06 * eventTable.damageamount) setText(gameTexts[eventTable.attacker], round(attacker.m_flRageMeter, 2) .. "%", attacker) print(gameTexts) if attacker.m_flRageMeter > 100 then setText(gameTexts[eventTable.attacker], "BERSERK READY", attacker) attacker.m_flRageMeter = 100 playsound = true end if playsound and not was_played then local activatorOrigin = attacker:GetAbsOrigin() local berserk_ready = ents.CreateWithKeys("ambient_generic",{ ["health"] = "10", ["message"] = "ptx/weapons/berserk/dreadknight_berserk_ready.wav", ["pitch"] = "85", ["pitchstart"] = "85", ["radius"] = "5000", ["spawnflags"] = "48", ["origin"] = "" .. activatorOrigin[1] .. " " .. activatorOrigin[2] .. " " .. activatorOrigin[3] .. "", ["angles"] = "0 " .. attacker["m_angEyeAngles[1]"] .. " 0", }) attacker:PlaySoundToSelf("=60|ptx/weapons/berserk/dreadknight_berserk_ready.wav") berserk_ready:AcceptInput("PlaySound") was_played = true timer.Simple(3, function() berserk_ready:Remove() end) end print(attacker.m_flRageMeter) end end) local berserk_Attrs = { ["dmg from melee increased"] = 0.375, ["dmg from ranged reduced"] = 0.50, ["air dash count"] = 1, ["melee range multiplier"] = 1.6, ["melee bounds multiplier"] = 1.4, ["melee attack rate bonus"] = 0.8, ["CARD: damage bonus"] = 2.0, ["max health additive bonus"] = 0, ["effect bar recharge rate increased"] = 0.5, ["health from healers reduced"] = 0.1, ["model scale"] = 1.1, ["SET BONUS: move speed set bonus"] = 1.7, ["increased air control"] = 999, ["increased jump height"] = 1.5, ["stomp player damage"] = 10, ["stomp player time"] = 0.5, ["heal on kill"] = 25, } local function applyAttributesOverExisting(target, newAttributes) -- entirely by crilly local checkItemDefinition = true if target:IsPlayer() == true then checkItemDefinition = false end for name, value in pairs(newAttributes) do if target:GetAttributeValue(name, checkItemDefinition) ~= nil then target:SetAttributeValue(name, (value + target:GetAttributeValue(name, checkItemDefinition))) else target:SetAttributeValue(name, value) end end end function berserkCall(condition, caller, activator) if activator:InCond(12) == true or activator.m_flRageMeter ~= 100 then return end local current_weapon = activator:GetPlayerItemBySlot(2):GetItemName() activator:GiveItem("Berserk Hands") activator:GetPlayerItemBySlot(2).m_clrRender = 16776960 local upgradeLevel = (activator:GetPlayerItemBySlot(1):GetAttributeValue("cloak_consume_on_feign_death_activate")) or 1 activator:AddCond(12, 15, activator) activator:AddCond(52, 2, activator) activator:SetAttributeValue("damage bonus HIDDEN", (1 + upgradeLevel / 4)) activator:RemoveCond(7) timer.Simple(0.2, function () activator:WeaponSwitchSlot(2) activator:GetPlayerItemBySlot(2):SetAttributeValue("disable weapon switch", 1) end) applyAttributesOverExisting(activator, berserk_Attrs) local activatorAttributes activator:GetAllAttributeValues(false) local activatorOrigin = activator:GetAbsOrigin() local aOrigin = "" .. activatorOrigin[1] .. " " .. activatorOrigin[2] .. " " .. activatorOrigin[3] .. "" local activatorAngles = "0 " .. activator["m_angEyeAngles[1]"] .. " 0" local activate_particle = ents.CreateWithKeys("info_particle_system", { ["start_active"] = "0", ["flag_as_weather"] = "0", ["effect_name"] = "powerup_supernova_explode_blue", ["origin"] = aOrigin, ["angles"] = "0 0 0", }) local glow_yellow = ents.CreateWithKeys("tf_glow", { GlowColor = "255 255 0 255", targetname = "berserk_glow", target = "bignet", Mode = "0", StartDisabled = 1 }) glow_yellow.m_hTarget = activator local berserk_activation_sound = ents.CreateWithKeys("ambient_generic",{ ["health"] = "10", ["message"] = "ptx/weapons/berserk/dreadknight_berserk_activate.wav", ["pitch"] = "85", ["pitchstart"] = "85", ["radius"] = "5000", ["spawnflags"] = "48", ["origin"] = aOrigin, ["angles"] = activatorAngles, }) local hand_particle = ents.CreateWithKeys("trigger_particle", { particle_name = spell_fireball_small_red_old, attachment_type = 4, attachment_name = "effect_hand_R", spawnflags = 64 }); activator:PlaySoundToSelf("=60|ptx/weapons/berserk/dreadknight_berserk_activate.wav") activate_particle.SetAbsOrigin(aOrigin) activate_particle:AcceptInput("Start") glow_yellow:AcceptInput("Enable") berserk_activation_sound:AcceptInput("PlaySound") local sphereResults = ents.FindInSphere(activator:GetAbsOrigin(), 150) local dmgTable = { Attacker = activator, -- Attacker Inflictor = nil, -- Direct cause of damage, usually a projectile Weapon = activator:GetPlayerItemBySlot(2), Damage = 50 * (1 + upgradeLevel / 2), DamageType = DMG_BLAST, -- Damage type, see DMG_* globals. Can be combined with | operator DamageCustom = nil, -- Custom damage type, see TF_DMG_* globals CritType = 0, -- Crit type, 0 = no crit, 1 = mini crit, 2 = normal crit DamagePosition = nil, -- Where the target was hit at DamageForce = nil, -- Knockback force of the attack ReportedPosition = nil -- Where the attacker attacked from } if sphereResults then for _, entity in pairs(sphereResults) do if entity:IsPlayer() and entity:IsAlive() and entity.m_iTeamNum ~= activator.m_iTeamNum then entity:TakeDamage(dmgTable) end end end activator:AddOutput("BaseVelocity 0 0 500") timer.Simple(3, function() activate_particle:AcceptInput("Stop") activate_particle:Remove() berserk_activation_sound:Remove() end) local function berserkEND(activator, activatorAttributes) if not activator:IsAlive() then return end activator:AddCond(79, 2, activator) for name, value in pairs(berserk_Attrs) do activator:SetAttributeValue(name, nil) end if activator.m_iHealth < 175 then activator:AddHealth((175 - activator.m_iHealth)) end activator.m_flRageMeter = 0 end if activator.m_iHealth < 250 then activator:AddHealth((250 - activator.m_iHealth)) end local timeLeft = 100 local logicLoop logicLoop = timer.Create(0.1, function() timeLeft = timeLeft - 1 setText(gameTexts[activator:GetUserId()], timeLeft .. "%", activator) if activator:IsAlive() == false or timeLeft <= 0 then timer.Stop(logicLoop) activator:GetPlayerItemBySlot(2):SetAttributeValue("disable weapon switch", 0) glow_yellow:AcceptInput("Disable") glow_yellow:Remove() berserkEND(activator, activatorAttributes) activator:GiveItem(current_weapon) activator:SetAttributeValue("damage bonus HIDDEN", 1) was_played = false playsound = false return end end, 100) end