InvulnerableCondTable = { TF_COND_INVULNERABLE, TF_COND_INVULNERABLE_HIDE_UNLESS_DAMAGED, TF_COND_INVULNERABLE_USER_BUFF, TF_COND_INVULNERABLE_CARD_EFFECT, } Wavebar = ents.FindByClass("tf_objective_resource") function IsInvulnerable(player) for _, cond in pairs(InvulnerableCondTable) do if player:InCond(cond) then break return true end end return false end function BustletDetonate(bot) local mimic = ents.CreateWithKeys("tf_point_weapon_mimic", { ["$weaponname"] = "bustlet detonator", teamnum = bot.m_iTeamNum, targetname = "boom", }, true, true) local shake = ents.CreateWithKeys("env_shake", { radius = 500, frequency = 200, amplitude = 150, duration = 1, targetname = "boom", }) bot:PlaySound("NilValue.Bustlet_Explode") util.ParticleEffect("Explosions_UW_Debris001", bot:GetAbsOrigin() + Vector(0,0,50), nil, bot) mimic:SetAbsOrigin(bot:GetAbsOrigin() + Vector(0, 0, 25)) shake:SetAbsOrigin(bot:GetAbsOrigin() + Vector(0, 0, 50)) bot:Suicide() mimic:SetOwner(bot) mimic:FireOnce() shake:StartShake() timer.Simple(0.2, function() mimic:Remove() shake:Remove() end) if bot.m_hRagdoll ~= nil then bot.m_hRagdoll:Remove() end end --------------- function OnPlayerConnected(player) player.bBustlet = 0 player:AddCallback(ON_DEATH, function() player.bBustlet = 0 end) player:AddCallback(ON_DAMAGE_RECEIVED_PRE, function(_, damageinfo) local attacker = damageinfo.Attacker local weapon = damageinfo.Weapon local inflictor = damageinfo.Inflictor local dtype = damageinfo.DamageType if player.bBustlet == 1 and IsInvulnerable(player) == false and (attacker == nil or attacker ~= nil and attacker.m_iTeamNum ~= player.m_iTeamNum) then player.m_hGroundEntity = nil if not player:InCond(TF_COND_STUNNED) and player.m_iStunFlags & TF_STUNFLAG_BONKSTUCK == 0 then if attacker == nil then attacker = player end player:StunPlayer(4, 1, TF_STUNFLAG_BONKSTUCK | TF_STUNFLAG_SLOWDOWN | TF_STUNFLAG_LIMITMOVEMENT, attacker) --player:PlaySound("NilValue.Bustlet_Stun") player:RunScriptCode("self.StopSound(`TFPlayer.StunImpact`)") damageinfo.Damage = 0 else if damageinfo.DamageType & DMG_CLUB == 0 then BustletDetonate(player) end end end return true end) end function OnGameTick() for _, ambient in pairs(ents.FindAllByClass("info_target")) do if ambient.m_hOwnerEntity ~= nil then ambient:Teleport(ambient.m_hOwnerEntity:GetAbsOrigin()) end end for _, player in pairs(ents.GetAllPlayers()) do if player.bBustlet == 1 then local mins = Vector(-25, -25, -83) local maxs = mins * -1 local org = player:GetAbsOrigin() for _, ent in pairs(ents.FindInBox(org + mins, org + maxs)) do if ent:IsPlayer() or ent:IsObject() then if ent:IsAlive() and ent.m_iTeamNum ~= player.m_iTeamNum then BustletDetonate(player) end end end end end end function OnWaveSpawnBot(bot) timer.Simple(0.1, function() if bot.bBustlet == 1 then bot:RunScriptCode("self.RemoveBotTag(`common`)") end end) end