local BASE_DAMAGE = 90 local WEAPON_STICKY_GRENADE = 3 local VALID_WEAPON_CLASSES = {"tf_weapon_rocketlauncher", "tf_weapon_rocketlauncher_directhit", "tf_weapon_rocketlauncher_airstrike", "tf_weapon_flaregun_revenge", "tf_weapon_cleaver"} local function weaponMimic(properties) local mimic = ents.CreateWithKeys("tf_point_weapon_mimic", properties) return mimic end --print("15") local function addGlobalDamageCallback(player) -- Weird hack to fix conch not healing with penetration (thanks Orin xoxo) player:AddCallback(ON_DAMAGE_RECEIVED_PRE, function(_, damageinfo) -- Ugly way to check for rocket penetrations if damageinfo.Inflictor == nil then return end if damageinfo.Inflictor:GetClassname() ~= "tf_projectile_pipe" then return end if damageinfo.Weapon ~= nil then return end damageinfo.Weapon = damageinfo.Attacker:GetPlayerItemBySlot(LOADOUT_POSITION_PRIMARY) return true end) end function OnPlayerConnected(player) addGlobalDamageCallback(player) end local function addPenetration(projectile, useDamageTable, useDamageTableAlt) timer.Simple(0, function() if not IsValid(projectile) then return end local owner = projectile.m_hOwnerEntity --print(owner) if not owner then local originalLauncher = projectile.m_hOriginalLauncher owner = originalLauncher.m_hOwner end --combat tanks, and weapon mimics if not owner:IsPlayer() then return end local primary --print(owner) if not useDamageTable then primary = owner:GetPlayerItemBySlot(LOADOUT_POSITION_PRIMARY) else primary = owner:GetPlayerItemBySlot(1) end local classMatch = false local decidedClass for _, className in pairs(VALID_WEAPON_CLASSES) do if primary:GetClassname() == className then classMatch = true decidedClass = className end end if classMatch == false then return end local maxPenetrationCount = primary:GetAttributeValue("projectile penetration") if not maxPenetrationCount then --print("No penetration attribute") return end local callback; local isCrit = projectile.m_bCritical local penetrated = {} local penetrations = 0 callback = projectile:AddCallback(ON_SHOULD_COLLIDE, function(_, collided) -- CTFPlayer, then NextBotCombatCharacter, then CTFBaseObject if not collided:IsPlayer() and not collided:IsNPC() and not collided:IsObject() and not collided:GetClassname() == "entity_medigun_shield" then return end if collided.m_iTeamNum == owner.m_iTeamNum then return false end if collided:GetClassname() == "entity_medigun_shield" then return false end -- Make sure it hasn't been penetrated already local index = collided:GetHandleIndex() if penetrated[index] then return false end -- Boring shit if penetrations >= maxPenetrationCount then projectile:RemoveCallback(callback) return end penetrations = penetrations + 1 penetrated[index] = true -- Good shit local damageBonusMult = primary:GetAttributeValueByClass("mult_dmg", 1) local damage = BASE_DAMAGE * damageBonusMult if decidedClass ~= "tf_weapon_cleaver" and decidedClass ~= "tf_weapon_flaregun_revenge" then local blastRadisuMult = primary:GetAttributeValueByClass("mult_explosion_radius", 1) local blastRadius = 146 * blastRadisuMult if collided:IsPlayer() and primary:GetAttributeValue("rocket specialist", true) ~= nil then collided:StunPlayer(1, 1, TF_STUNFLAG_SLOWDOWN, owner) local damageTable = { Attacker = owner, Inflictor = projectile, Weapon = primary, Damage = damage, DamageType = DMG_BLAST, DamageCustom = TF_DMG_CUSTOM_NONE, CritType = isCrit, DamagePosition = projectile:GetAbsOrigin(), ReportedPosition = projectile:GetAbsOrigin(), } collided:TakeDamage(damageTable) damage = damage * 0.3 end local mimic = weaponMimic({ TeamNum = owner.m_iTeamNum, WeaponType = WEAPON_STICKY_GRENADE, -- sticky Damage = damage, Crits = isCrit, SplashRadius = blastRadius, SpeedMax = 0, SpeedMin = 0, ["$dmgtype"] = 69420, ["$killicon"] = "player_penetration", origin = tostring(projectile:GetAbsOrigin()), angles = tostring(Vector(0, 0, 0)), }) mimic["$SetOwner"](mimic, owner) mimic:FireOnce() mimic:DetonateStickies() timer.Simple(0.1, function() mimic:Remove() end) return false elseif decidedClass == "tf_weapon_flaregun_revenge" then local base_damage = 30 local baseDamageTypes = DMG_BURN|DMG_IGNITE if isCrit ~= 0 then baseDamageTypes = DMG_BURN|DMG_CRITICAL|DMG_IGNITE end local damageTable = { Attacker = owner, Inflictor = projectile, Weapon = primary, Damage = base_damage * damageBonusMult, DamageType = baseDamageTypes, DamageCustom = TF_DMG_CUSTOM_BURNING, CritType = isCrit, DamagePosition = projectile:GetAbsOrigin(), ReportedPosition = projectile:GetAbsOrigin(), } collided:TakeDamage(damageTable) return false elseif decidedClass == "tf_weapon_cleaver" then local base_damage = 50 local baseDamageTypes = DMG_MELEE damageBonusMult = primary:GetAttributeValueByClass("mult_dmg_vs_players", 1) if isCrit ~= 0 then baseDamageTypes = DMG_MELEE|DMG_CRITICAL end local damageTable = { Attacker = owner, Inflictor = projectile, Weapon = primary, Damage = base_damage * damageBonusMult, DamageType = baseDamageTypes, DamageCustom = TF_DMG_CUSTOM_BLEEDING, CritType = isCrit, DamagePosition = projectile:GetAbsOrigin(), ReportedPosition = projectile:GetAbsOrigin(), } collided:TakeDamage(damageTable) --collided:BleedPlayer(10) return false end return false end) end) end ents.AddCreateCallback("tf_projectile_flare", function(projectile) addPenetration(projectile, true) end) ents.AddCreateCallback("tf_projectile_rocket", function(projectile) addPenetration(projectile) end) ents.AddCreateCallback("tf_projectile_cleaver", function(projectile) addPenetration(projectile, true) end)