local TF_TEAM_RED = 2 local TF_TEAM_BLUE = 3 local CONVERT_CONDITION = 43 ents.AddCreateCallback("obj_attachment_sapper", function(ent) ent.placed = false timer.Create(0.015, function() if not IsValid(ent) then return false end local builder = ent.m_hBuilder local buildweapon = builder:GetPlayerItemBySlot(LOADOUT_POSITION_BUILDING) if ent.placed == false and ent.m_bPlacing == 0 and buildweapon:GetAttributeValueByClass("throwable_damage", 0) == 1 then ent.placed = true local victim = ent.m_hBuiltOnEntity if victim:IsPlayer() and victim.m_bIsMiniBoss == 1 then ent:RemoveHealth(5000) end if victim:IsPlayer() and victim.m_bIsMiniBoss == 0 then builder:RemoveCond(TF_COND_DISGUISED) builder:RemoveCond(TF_COND_DISGUISING) victim:AddCond(TF_COND_REPROGRAMMED, 8, builder) victim:RemoveCond(TF_COND_STUNNED) victim:AddCond(TF_COND_CRITBOOSTED_USER_BUFF, _, builder) victim:RunScriptCode("self.LeaveSquad()", victim) victim:SetFakeClientConVar("name", victim:GetPlayerName() .. " (" .. builder:GetPlayerName() .. ")") victim:AcceptInput("$botcommand", "$switch_action mobber") victim:AcceptInput("$addplayerattribute", "force distribute currency on death|1") victim:AcceptInput("$addplayerattribute", "not solid to players|1") local victimsecondary = victim:GetPlayerItemBySlot(LOADOUT_POSITION_SECONDARY) if victimsecondary and victim.m_hActiveWeapon == victimsecondary and victimsecondary:GetClassname() == "tf_weapon_medigun" then -- do this if this is a medic------------ util.PrintToChatAll("medic actions in effect") victimsecondary.m_hHealingTarget = nil victimsecondary.m_bAttacking = 0 victim:AcceptInput("$botcommand", "$switch_action medic") victim:RunScriptCode("self.AddBotAttribute(1024)", victim) victim.m_afButtonForced = IN_ATTACK victim:AcceptInput("$addplayerattribute", "disable weapon switch|1") timer.Create(0.015, function() if IsValid(victim:GetConditionProvider(TF_COND_REPROGRAMMED)) then buildereyes = builder:GetAbsOrigin() + Vector(0, 0, builder.m_vecViewOffset[3]) action = ("interrupt_action -pos %s %s %s -lookpos %s %s %s -duration 0.1 -distance 150 -killlook"):format( buildereyes[1], buildereyes[2], buildereyes[3], buildereyes[1], buildereyes[2], buildereyes[3] ) victim:AcceptInput("$botcommand", action) util.PrintToChatAll(action) else return false end end, 330, 0) end ------------------------------------------- elseif victim:IsObject() then if victim.m_bMiniBuilding == 0 then miniskin = 0 else miniskin = 2 end if builder.m_iTeamNum == TF_TEAM_RED then victim.m_nSkin = 0 + miniskin else victim.m_nSkin = 1 + miniskin end victim.m_hBuilder = builder victim:SetTeam(builder.m_iTeamNum) timer.Simple(0.03, function() victim.m_bDisabled = 0 victim.m_bHasSapper = 0 end) timer.Simple(4, function() ent:RemoveHealth(5000) end) end ent:AddCallback(ON_REMOVE, function() if victim:IsPlayer() then local provider = victim:GetConditionProvider(CONVERT_CONDITION) if IsValid(provider) and victim.m_bIsMiniBoss == 0 then victim:Suicide() end else victim:RemoveHealth(5000) end end) end end, 0, 0) end) function OnPlayerConnected(player) player:AddCallback(ON_DAMAGE_RECEIVED_PRE, function(_, damageinfo) local attacker = damageinfo.Attacker if IsValid(attacker) and attacker:IsPlayer() then local provider = attacker:GetConditionProvider(CONVERT_CONDITION) if provider then damageinfo.Attacker = attacker:GetConditionProvider(CONVERT_CONDITION) return true end end end) player:AddCallback(ON_DEATH, function() player.m_afButtonForced = 0 end) end