-- resize reanimators at random ents.AddCreateCallback("entity_revive_marker", function(entity) -- 0.3x to 5x local chosenSize = math.random(3, 50) / 10 timer.Simple(0, function () entity.m_flModelScale = chosenSize end) end) local function getEyeAngles(player) local pitch = player["m_angEyeAngles[0]"] local yaw = player["m_angEyeAngles[1]"] return Vector(pitch, yaw, 0) end -- if player is looking straight down or straight up with projectile shield -- damage them with 2 damage every 3 ticks ents.AddCreateCallback("entity_medigun_shield", function(entity) timer.Simple(0, function () if entity.m_iTeamNum == 3 then return end local damageLastTick = 0 entity:AddCallback(ON_TOUCH, function(_, target, hitPos) if target == entity.m_hOwnerEntity and (target["m_angEyeAngles[0]"] >= 70 or target["m_angEyeAngles[0]"] <= -70) then if damageLastTick == 0 then local visualHitPost = hitPos + Vector(0, 0, 50) local medigunSelfDamage = { Attacker = target, Inflictor = nil, Weapon = nil, Damage = 2, DamageType = DMG_SHOCK, DamageCustom = 0, DamagePosition = visualHitPost, ReportedPosition = visualHitPost } target:TakeDamage(medigunSelfDamage) damageLastTick = 2 else damageLastTick = damageLastTick - 1 end end end) end) end) function NoRotate(_, activator) activator:SetCustomModel("models/bots/heavy/bot_heavy.md") activator:SetCustomModelRotates(false) end local SET_SCALE_VSCRIPT = "activator.SetScaleOverride(%s)" local SIZE_MAX = 2.3 local SIZE_MIN = 1 local SIZE_INTERVAL = 0.05 function FunkySize(_, activator) local loop local size = SIZE_MIN local reversed = false loop = timer.Create(0.05, function () if not IsValid(activator) or not activator:IsAlive() then timer.Stop(loop) end local vscript = SET_SCALE_VSCRIPT:format(size) size = size + SIZE_INTERVAL * (reversed and -1 or 1) if size >= SIZE_MAX then size = SIZE_MAX reversed = true elseif size <= SIZE_MIN then size = SIZE_MIN reversed = false end activator:RunScriptCode(vscript, activator) end, 0) end local LERP_INTERVAL = 0.05 function LerpToSize(sizeGoal, activator) sizeGoal = tonumber(sizeGoal) local loop local size = 0.01 loop = timer.Create(0.05, function () if not IsValid(activator) or not activator:IsAlive() then timer.Stop(loop) end local vscript = SET_SCALE_VSCRIPT:format(size) size = size + LERP_INTERVAL if size >= sizeGoal then size = sizeGoal end activator:RunScriptCode(vscript, activator) if size >= sizeGoal then timer.Stop(loop) end end, 0) end local neverDieBot = false function OnWaveStart() neverDieBot = false end function NeverDie(_, activator) local callback print(neverDieBot) neverDieBot = activator callback = activator:AddCallback(ON_DEATH, function() if neverDieBot ~= activator then activator:RemoveCallback(callback) return end timer.Simple(0, function () local origin = activator:GetAbsOrigin() activator:ForceRespawn() activator:SetAbsOrigin(origin) end) end) end local function traceBetween(player, originTarget) local DefaultTraceInfo = { start = player, endpos = originTarget, mask = MASK_SOLID, collisiongroup = COLLISION_GROUP_DEBRIS, } local trace = util.Trace(DefaultTraceInfo) return trace.Hit end --- finds closest red player to use as target local function getPlayerTarget(bot) local botTeam = bot.m_iTeamNum local closest = { nil, 1000000 } local players = ents.GetAllPlayers() local botOrigin = bot:GetAbsOrigin() local origin local distance local function validateTarget(player) if player == bot then return end if not player:IsRealPlayer() then return end if not player:IsAlive() then return end if player.m_iTeamNum ~= botTeam then return end origin = player:GetAbsOrigin() distance = origin:Distance(botOrigin) if distance > closest[2] then return end if traceBetween(bot, origin) then return end closest = { player, distance } end for _, player in pairs(players) do validateTarget(player) end if not closest[1] then -- no target found return false end return closest[1] end -- target and destroy friendly red players function FakeFriendly(_, activator) local killPointerName = "BotKillPointer" .. tostring(handle) local killPointer = Entity("info_particle_system", true) killPointer:SetName(killPointerName) -- local outputCallback = activator:AddCallback(ON_OUTPUT, function(outputName, value) -- print(outputName, value) -- if outputName ~= "$onactiondone" then -- return -- end -- if value ~= "killRed" then -- return -- end -- end) local curTarget local function setTarget(target) curTarget = target killPointer:SetFakeParent(target) local interruptAction = "interrupt_action -posent %s -lookposent %s -killlook -waituntildone -alwayslook -distance 3 -name killRed" interruptAction = interruptAction:format(killPointerName, killPointerName) activator:BotCommand(interruptAction) end local logicLoop logicLoop = timer.Create(0.1, function () if not activator:IsAlive() then timer.Stop(logicLoop) if IsValid(killPointer) then killPointer:Remove() end -- activator:RemoveCallback(outputCallback) return end -- print(curTarget and curTarget:IsAlive()) if curTarget and curTarget:IsAlive() then -- killPointer:SetAbsOrigin(curTarget:GetAbsOrigin()) return end curTarget = nil killPointer:ClearFakeParent() local newTarget = getPlayerTarget(activator) if newTarget then -- print("got new target") setTarget(newTarget) end end, 0) end