--print("Newest") AddEventCallback("mvm_reset_stats", function () for _, player in pairs(ents.GetAllPlayers()) do player:AcceptInput("addoutput", "rendermode 0", nil, nil) player:AcceptInput("addoutput", "renderamt 255", nil, nil) player:AcceptInput("color", "255 255 255", nil, nil) player:AcceptInput("alpha", "1", nil, nil) --player:ShowToAll() end end) local function removeCallbacks(player, callbacks) if not IsValid(player) then return end for _, callbackId in pairs(callbacks) do player:RemoveCallback(callbackId) end end --setting transparency and resetting it on death are split so botTransparencySet can be used for cool pulsing and transitions without --creating 8 trillion callbacks. function botTransparencySet(activator, alpha, color) if activator:IsAlive() == false then return end activator:AcceptInput("addoutput", "rendermode 1", nil, nil) activator:AcceptInput("alpha", alpha, nil, nil) activator:AcceptInput("addoutput", "renderamt " .. (255 * alpha), nil, nil) activator:AcceptInput("color", color, nil, nil) end function botTransparencyResetOnDeath(activator) local terminated = false local function terminate() if terminated then return end terminated = true removeCallbacks(activator, callbacks) activator:AcceptInput("addoutput", "rendermode 0", nil, nil) end callbacks.died = activator:AddCallback(ON_DEATH, function() terminate() end) callbacks.removed = activator:AddCallback(ON_REMOVE, function() terminate() end) callbacks.spawned = activator:AddCallback(ON_SPAWN, function() terminate() end) end function MidknightSpawn(_, activator) local callbacks = {} local terminated = false --local particleTarget --local eyeParticle2 --local check print("Going off") local function terminate() if terminated then return end terminated = true --particleTarget:Remove() --kills children too, so no need to murder eyeParticle2 --timer.Stop(check) removeCallbacks(activator, callbacks) end --activator.m_iDecapitations = 5 --print(activator.m_iDecapitations) --eyeParticle = ents.CreateWithKeys("trigger_particle",{ -- attachment_name = "eye_1", -- particle_name = "unusual_robot_holo_glow_green", -- spawnflags = "64", -- attachment_type = 4, --}, true, true) --eyeParticle.m_bForcePurgeFixedupStrings = true --eyeParticle:AcceptInput("StartTouch", "", activator, activator) --eyeParticle:Remove() --particleTarget = ents.CreateWithKeys("info_target", { -- spawnflags = 1, --}, true, true) --particleTarget:AcceptInput("SetParentAttachment", "eye_1", activator, activator) --particleTarget:SetAbsOrigin(activator:GetAbsOrigin()) --local eyeParticle2 = ents.CreateWithKeys("info_particle_system", { -- effect_name = "unusual_robot_holo_glow_green", -- start_active = 1, -- flag_as_weather = 0, --}, true, true) --eyeParticle2:AcceptInput("SetParent", particleTarget) --check = timer.Create(0.015, function() -- local pos = particleTarget:GetAbsOrigin() -- local targetAngles = particleTarget:GetAbsAngles() -- print(pos) -- print(targetAngles) -- eyeParticle2:SetAbsOrigin(pos) -- eyeParticle2:SetAbsAngles(targetAngles) --end, 0) callbacks.collision = activator:AddCallback(ON_SHOULD_COLLIDE, function(_, collided) if activator:GetAttributeValue("hidden string attribute 1", false) == "GHOSTMODE" then return false else return true end end) callbacks.died = activator:AddCallback(ON_DEATH, function() terminate() end) callbacks.removed = activator:AddCallback(ON_REMOVE, function() terminate() end) callbacks.spawned = activator:AddCallback(ON_SPAWN, function() terminate() end) end function stragglerSpawn(_, activator) local callbacks = {} local terminated = false local target local validTargets = {} local redTeam = {} local function terminate() if terminated then return end terminated = true if check then timer.Stop(check) end removeCallbacks(activator, callbacks) activator:AcceptInput("addoutput", "rendermode 0", nil, nil) activator:AcceptInput("addoutput", "renderamt 255", nil, nil) activator:AcceptInput("color", "255 255 255", nil, nil) activator:AcceptInput("alpha", "1", nil, nil) --activator:ShowToAll() end --activator:HideToAll() for _, player in pairs(ents.GetAllPlayers()) do if player:IsRealPlayer() == true and player.m_iTeamNum == 2 and player:IsAlive() == true then table.insert(validTargets, player) elseif player:IsAlive() and player.m_iTeamNum == 2 then table.insert(redTeam, player) end end target = validTargets[math.random(#validTargets)] if target == nil then activator:BotCommand("despawn") terminate() return end --print("Target selected, it is: " .. target.m_szNetname) --activator:HideToAll() --activator:ShowTo(target) --target:HideToAll() --target:ShowTo(activator) target:SetAttributeValue("attach particle effect", 3200) activator:SetAttributeValue("attach particle effect", 3200) --for _, player in pairs(redTeam) do -- if player ~= target then -- player:HideTo(target) -- end --end local check print("Going off") local pos = target:GetAbsOrigin() activator:SetAbsOrigin(pos) local phasingOut = false local function phaseOutSequence() if phasingOut == true then return end phasingOut = true local currentAlpha = 1 local phaseOutTime = 2 local phaseOutResolution = 0.01 local phaseTimer = timer.Create(phaseOutResolution, function() botTransparencySet(activator, currentAlpha, "255 255 255") currentAlpha = currentAlpha - (phaseOutResolution / phaseOutTime) end, (phaseOutTime / phaseOutResolution)) timer.Simple(phaseOutTime, function() if IsValid(activator) then activator:BotCommand("despawn") end end) end local function phaseInSequence() local currentAlpha = 0 local phaseInTime = 5 local phaseInResolution = 0.01 local phaseTimer = timer.Create(phaseInResolution, function() botTransparencySet(activator, currentAlpha, "255 255 255") currentAlpha = currentAlpha + (phaseInResolution / phaseInTime) end, (phaseInTime / phaseInResolution)) timer.Simple(phaseInTime, function() activator:AcceptInput("addoutput", "rendermode 0", nil, nil) activator:AcceptInput("addoutput", "renderamt 255", nil, nil) activator:AcceptInput("color", "255 255 255", nil, nil) activator:AcceptInput("alpha", "1", nil, nil) end) end local currentTime = CurTime() local terminationTime = currentTime + 15 local startupTime = currentTime + 5 local isStarted = false activator:StunPlayer(5, 1, TF_STUNFLAGS_LOSERSTATE, nil) phaseInSequence() timer.Simple(20, function() if IsValid(activator) and terminated == false then activator:BotCommand("despawn") end end) check = timer.Create(0.015, function() local gameTime = CurTime() if phasingOut == true then timer.Stop(check) return end if gameTime >= startupTime and isStarted ~= true then local aggroInfo = { Attacker = target, -- Attacker Inflictor = nil, -- Direct cause of damage, usually a projectile Weapon = nil, Damage = 1, DamageType = DMG_GENERIC, -- Damage type, see DMG_* globals. Can be combined with | operator DamageCustom = TF_DMG_CUSTOM_NONE, -- Custom damage type, see TF_DMG_* globals CritType = 0, -- Crit type, 0 = no crit, 1 = mini crit, 2 = normal crit DamagePosition = Vector(0,0,0), -- Where the target was hit at DamageForce = Vector(0,0,0), -- Knockback force of the attack ReportedPosition = Vector(10000,0,0) -- Where the attacker attacked from } activator:TakeDamage(aggroInfo) isStarted = true end if gameTime >= terminationTime then phaseOutSequence() return end local activatorOrigin = activator:GetAbsOrigin() pos = target:GetAbsOrigin() local distance = pos:Distance(activatorOrigin) if distance <= 100 then activator:RunScriptCode("activator.PressFireButton(0.1)", activator) end local targetHead = Vector(pos[1],pos[2],pos[3] + 60) local targetAngles = (targetHead - (activatorOrigin + Vector( 0, 0, activator["m_vecViewOffset[2]"] ))):ToAngles() targetAngles = Vector(targetAngles[1], targetAngles[2], 0) activator:SnapEyeAngles(targetAngles) end, 0) callbacks.collision = activator:AddCallback(ON_SHOULD_COLLIDE, function(_, collided) if collided ~= target or isStarted ~= true then return false end end) callbacks.hurtPre = activator:AddCallback(ON_DAMAGE_RECEIVED_PRE, function(_, eventTable) eventTable.Damage = 0 eventTable.DamageForce = Vector(0,0,0) eventTable.Attacker = target if eventTable.ReportedPosition[1] == 10000 then eventTable.Damage = 1 end return true end) callbacks.died = activator:AddCallback(ON_DEATH, function() terminate() end) callbacks.targetdied = target:AddCallback(ON_DEATH, function() phaseOutSequence() end) callbacks.targethurtPre = target:AddCallback(ON_DAMAGE_RECEIVED_PRE, function(_, eventTable) eventTable.Damage = 0 if eventTable.Attacker == activator then eventTable.Damage = 100000 end return true end) callbacks.removed = activator:AddCallback(ON_REMOVE, function() terminate() end) callbacks.spawned = activator:AddCallback(ON_SPAWN, function() terminate() end) end