Skip to content

Commit

Permalink
merge of bsnuggs-master1 + additional changes to let this work
Browse files Browse the repository at this point in the history
  • Loading branch information
Newbrict committed Jun 21, 2016
1 parent 8e7e968 commit 253f4fc
Show file tree
Hide file tree
Showing 43 changed files with 253 additions and 38 deletions.
Binary file added content/sound/taunts/aaaa.wav
Binary file not shown.
Binary file added content/sound/taunts/ahhhh.wav
Binary file not shown.
Binary file added content/sound/taunts/brr.wav
Binary file not shown.
Binary file added content/sound/taunts/come_to_papa.wav
Binary file not shown.
Binary file added content/sound/taunts/crich.wav
Binary file not shown.
Binary file added content/sound/taunts/epicsax.wav
Binary file not shown.
Binary file added content/sound/taunts/fart01a.wav
Binary file not shown.
Binary file added content/sound/taunts/fart01b.wav
Binary file not shown.
Binary file added content/sound/taunts/fgroan.wav
Binary file not shown.
Binary file added content/sound/taunts/fireassis.wav
Binary file not shown.
Binary file added content/sound/taunts/glados-president.wav
Binary file not shown.
Binary file added content/sound/taunts/gmodgimn.wav
Binary file not shown.
Binary file added content/sound/taunts/hitassist.wav
Binary file not shown.
Binary file added content/sound/taunts/idiotgman.wav
Binary file not shown.
Binary file added content/sound/taunts/kevinmacleodmerrygo.wav
Binary file not shown.
Binary file added content/sound/taunts/kevinmacleodmerrygo2a.wav
Binary file not shown.
Binary file added content/sound/taunts/kevinmacleodmerrygo3a.wav
Binary file not shown.
Binary file added content/sound/taunts/laugh.wav
Binary file not shown.
Binary file added content/sound/taunts/leedleleedleloo.wav
Binary file not shown.
Binary file modified content/sound/taunts/leeroy_jenkins.wav
Binary file not shown.
Binary file added content/sound/taunts/now_what.wav
Binary file not shown.
Binary file added content/sound/taunts/partyrockanthem.wav
Binary file not shown.
Binary file added content/sound/taunts/pe.wav
Binary file not shown.
Binary file added content/sound/taunts/pockemon.wav
Binary file not shown.
Binary file added content/sound/taunts/pssleft.wav
Binary file not shown.
Binary file added content/sound/taunts/pssright.wav
Binary file not shown.
Binary file added content/sound/taunts/rude.wav
Binary file not shown.
Binary file added content/sound/taunts/soul.wav
Binary file not shown.
Binary file added content/sound/taunts/whynunu.wav
Binary file not shown.
Binary file added content/sound/taunts/wooo.wav
Binary file not shown.
Binary file added content/sound/taunts/you_dont_know_the_power.wav
Binary file not shown.
Binary file not shown.
35 changes: 30 additions & 5 deletions gamemode/cl_init.lua
Expand Up @@ -18,6 +18,8 @@ net.Receive( "Prop update", function( length )
local propHeight = tHitboxMax.z - tHitboxMin.z
LocalPlayer().propHeight = propHeight
LocalPlayer().lastPropChange = CurTime()
--LocalPlayer().lastTaunt = CurTime()
--LocalPlayer().autoTauntInterval = 100

-- initialize stuff here
if( LocalPlayer().firstProp ) then
Expand All @@ -26,20 +28,22 @@ net.Receive( "Prop update", function( length )
LocalPlayer().wantAngleSnap = false
LocalPlayer().lastPropChange = 0
LocalPlayer().nextTaunt = 0
LocalPlayer().lastTaunt = 0
LocalPlayer().lastTaunt = CurTime()
LocalPlayer().lastTauntDuration = 1
LocalPlayer().lastTauntPitch = 100
LocalPlayer().firstProp = false
LocalPlayer().autoTauntInterval = OBJHUNT_AUTOTAUNT_INTERVAL + OBJHUNT_HIDE_TIME
end

end )

net.Receive( "Reset Prop", function( length )
-- taunt default
LocalPlayer().nextTaunt = 0
LocalPlayer().lastTaunt = 0
LocalPlayer().lastTaunt = CurTime()
LocalPlayer().lastTauntDuration = 1
LocalPlayer().lastTauntPitch = 100
LocalPlayer().autoTauntInterval = OBJHUNT_AUTOTAUNT_INTERVAL + OBJHUNT_HIDE_TIME

LocalPlayer():ResetHull()
LocalPlayer().firstProp = true
Expand Down Expand Up @@ -95,7 +99,7 @@ net.Receive( "Clear Round State", function()
LocalPlayer().wantAngleLock = false
LocalPlayer().wantAngleSnap = false
for _, v in pairs( player.GetAll() ) do
v.wantAgnleLock = false
v.wantAngleLock = false
v.wantAngleSnap = false
end
end )
Expand All @@ -109,10 +113,19 @@ net.Receive( "Taunt Selection", function()
if not IsValid( ply ) then return end

if( ply == LocalPlayer() ) then
ply.nextTaunt = CurTime() + ( SoundDuration( taunt ) * (100/pitch) )
local soundDur = SoundDuration( taunt ) * (100/pitch)
ply.nextTaunt = CurTime() + soundDur
ply.lastTaunt = CurTime()
ply.lastTauntPitch = pitch
ply.lastTauntDuration = SoundDuration( taunt ) * (100/pitch)
ply.lastTauntDuration = soundDur
ply.autoTauntInterval = OBJHUNT_AUTOTAUNT_INTERVAL + soundDur

net.Start( "Update Taunt Times" )
net.WriteUInt( id, 8 )
net.WriteFloat( ply.nextTaunt )
net.WriteFloat( ply.lastTaunt )
net.WriteFloat( ply.autoTauntInterval )
net.SendToServer()
end

local s = Sound(taunt)
Expand All @@ -132,6 +145,18 @@ net.Receive( "Taunt Selection", function()
--EmitSound( taunt , ply:GetPos(), id, CHAN_AUTO, 1, 100, 2, pitch )
end )

net.Receive( "AutoTaunt Update", function()
local id = net.ReadUInt( 8 )
local ply = player.GetByID( id )
local lastTaunt = net.ReadFloat()
local autoTauntInterval = net.ReadFloat()
if( ply == LocalPlayer() ) then
ply.lastTaunt = lastTaunt
ply.autoTauntInterval = autoTauntInterval
hook.Run("AutoTauntHUDRerender")
end
end)

net.Receive( "Player Death", function()
local id = net.ReadUInt( 8 )
local ply = player.GetByID( id )
Expand Down
97 changes: 97 additions & 0 deletions gamemode/gui/additionalHUDs.lua
@@ -0,0 +1,97 @@
surface.CreateFont( "AutoTauntFont",
{
font = "coolvetica",
size = 30,
weight = 1000,
antialias = true,
outline = false
})

local opacity = .5 * 255
local brightBlue = Color(14, 54, 100, 100)
local brightYellow = Color(150, 54, 100, 100)
local brightRed = Color(255, 54, 100, 100)
local lightGray = Color(80, 80, 80, opacity)
local brightWhite = Color(255, 255, 255, 255)

function draw.Circle( x, y, radius, seg )
local cir = {}

table.insert( cir, { x = x, y = y, u = 0.5, v = 0.5 } )
for i = 0, seg do
local a = math.rad( ( i / seg ) * -360 )
table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )
end

local a = math.rad( 0 ) -- This is need for non absolute segment counts
table.insert( cir, { x = x + math.sin( a ) * radius, y = y + math.cos( a ) * radius, u = math.sin( a ) / 2 + 0.5, v = math.cos( a ) / 2 + 0.5 } )

surface.DrawPoly( cir )
end

function loadExtraHuds()

--Loads the auto-taunt HUD
autotauntHud()

end

function validateProp(ply)
return (ply:IsValid() && ply:Alive() && ply:Team() == TEAM_PROPS )
end

function autotauntHud()

local ply = LocalPlayer()
local padding = 60
local paddingL = 100

-- Check if the player is valid, alive, and is a prop
if ( !validateProp(ply) ) then return end

local radius = 50
local timer = 30.00
local timerRadius = 0

if ply.lastTaunt != nil then
local tDiff = CurTime() - ply.lastTaunt
timer = math.Round(ply.autoTauntInterval - tDiff, 0)
timerRadius = (tDiff/ply.autoTauntInterval) * radius
end

local x = surface.ScreenWidth() - paddingL
local y = surface.ScreenHeight() - padding

--Set the text Position and Text
local timertext = tostring(timer)
if timer <= 0 then
timertext = "!"
end
draw.SimpleText(timertext, "ObjHUDFont", x, y, brightWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)


-- This is the outer circle
surface.SetDrawColor(lightGray)
draw.NoTexture()
draw.Circle( x, y, radius, radius)

-- This is the growing inner circle
local color = nil
local percentage = timerRadius/radius
if (percentage > .8) then
color = brightRed
elseif (percentage > .6) then
color = brightYellow
else
color = brightBlue
end
surface.SetDrawColor(color)
draw.NoTexture()
draw.Circle( x, y, timerRadius , radius)
draw.SimpleText("Auto-Taunt", "AutoTauntFont", x, y - radius, brightWhite, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

end


hook.Add("HUDPaint", "Load Additional HUDS", loadExtraHuds )
hook.Add("AutoTauntHUDRerender", "Re-render Auto Taunt HUD", autotauntHud )
2 changes: 1 addition & 1 deletion gamemode/gui/context_menu.lua
Expand Up @@ -129,7 +129,7 @@ local function DrawContextMenu()

surface.SetFont( "Toggle Buttons" )
surface.SetTextColor( Color( 255,255,255,255 ) )
local text = "Angle Snaping"
local text = "Angle Snapping"
local tw, th = surface.GetTextSize( text )
surface.SetTextPos( w/2 - tw/2, h/2 - th/2 )
surface.DrawText( text )
Expand Down
35 changes: 28 additions & 7 deletions gamemode/init.lua
@@ -1,12 +1,15 @@
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( "shared.lua" )
include( "server/autotaunt.lua" )

function GM:PlayerInitialSpawn( ply )
ply:SetTeam( TEAM_SPECTATOR )
player_manager.SetPlayerClass( ply, "player_spectator" )
ply:SetCustomCollisionCheck( true )
ply.nextTaunt = 0
ply.lastTaunt = CurTime()
ply.autoTauntInterval = OBJHUNT_AUTOTAUNT_INTERVAL + OBJHUNT_HIDE_TIME
net.Start( "Class Selection" )
-- Just used as a hook
net.Send( ply )
Expand All @@ -25,7 +28,6 @@ function GM:ShowHelp( ply )
net.Send( ply )
end


net.Receive("Class Selection", function( len, ply )
local chosen = net.ReadUInt(32)
local playerTable = {}
Expand Down Expand Up @@ -69,15 +71,35 @@ function SendTaunt( ply, taunt, pitch )
if( ply:Team() == TEAM_PROPS && !table.HasValue( PROP_TAUNTS, taunt ) ) then return end
if( ply:Team() == TEAM_HUNTERS && !table.HasValue( HUNTER_TAUNTS, taunt ) ) then return end

ply.nextTaunt = CurTime() + ( SoundDuration( taunt ) * (100/pitch) )
local soundDur = SoundDuration( taunt ) * (100/pitch)
ply.nextTaunt = CurTime() + soundDur
ply.lastTaunt = CurTime()
ply.autoTauntInterval = OBJHUNT_AUTOTAUNT_INTERVAL + soundDur -- Offset the interval by the sound dur

local filter = RecipientFilter();
filter:AddPlayer( ply );

net.Start( "Taunt Selection" )
net.WriteString( taunt )
net.WriteUInt( pitch, 8 )
net.WriteUInt( ply:EntIndex(), 8 )
net.WriteFloat( ply.lastTaunt )
net.WriteFloat( ply.autoTauntInterval )
net.Broadcast()
end

net.Receive( "Update Taunt Times", function()
local id = net.ReadUInt( 8 )
local ply = player.GetByID( id )
local nextTaunt = net.ReadFloat()
local lastTaunt = net.ReadFloat()
local autoTauntInterval = net.ReadFloat()

ply.nextTaunt = nextTaunt
ply.lastTaunt = lastTaunt
ply.autoTauntInterval = autoTauntInterval
end)

function GM:ShowSpare1( ply )
local TAUNTS
if( ply:Team() == TEAM_PROPS ) then
Expand Down Expand Up @@ -216,12 +238,11 @@ hook.Add( "Initialize", "Precache all network strings", function()
util.AddNetworkString( "Prop Angle Lock BROADCAST" )
util.AddNetworkString( "Prop Angle Snap" )
util.AddNetworkString( "Prop Angle Snap BROADCAST" )
util.AddNetworkString( "AutoTaunt Update" )
util.AddNetworkString( "Update Taunt Times" )
end )

--[[ Map Time ]]--
hook.Add( "Initialize", "Set Map Time", function()
mapStartTime = os.time()
end )

--[[ Door Exploit fix ]]--
function GM:PlayerUse( ply, ent )
Expand Down Expand Up @@ -427,8 +448,8 @@ function GM:PlayerSelectSpawn( ply )
local spawns = team.GetSpawnPoints( ply:Team() )
if( !spawns ) then return false end

local ret, _ = table.Random( spawns )
return ret
local ret, _ = table.Random( spawns )
return ret
end

function GM:PlayerCanSeePlayersChat( text, teamOnly, listener, speaker )
Expand Down
1 change: 1 addition & 0 deletions gamemode/player_class/player_hunter.lua
Expand Up @@ -15,6 +15,7 @@ PLAYER.TeammateNoCollide = true
PLAYER.MaxHealth = 100
PLAYER.DuckSpeed = 0.1
PLAYER.UnDuckSpeed = 0.1
PLAYER.lastTaunt = 0.0

function PLAYER:Loadout()

Expand Down
5 changes: 1 addition & 4 deletions gamemode/player_class/player_prop.lua
Expand Up @@ -16,18 +16,15 @@ PLAYER.TeammateNoCollide = false
PLAYER.MaxHealth = 100
PLAYER.DuckSpeed = 0.1
PLAYER.UnDuckSpeed = 0.1
PLAYER.lastTaunt = 0.0


function PLAYER:Loadout()

self.Player:RemoveAllAmmo()

end

function PLAYER:SetupDataTables()

self.Player:NetworkVar( "Entity", 0, "Prop" );

end

player_manager.RegisterClass( "player_prop", PLAYER, "player_default" )
2 changes: 1 addition & 1 deletion gamemode/player_class/player_spectator.lua
Expand Up @@ -10,7 +10,7 @@ PLAYER.DisplayName = "Spectator"
PLAYER.SetObserverMode = 6
PLAYER.CanUseFlashlight = false
PLAYER.AvoidPlayers = false

PLAYER.lastTaunt = 0.0

function PLAYER:Spawn()
self.Player:Spectate( OBS_MODE_ROAMING )
Expand Down
55 changes: 55 additions & 0 deletions gamemode/server/autotaunt.lua
@@ -0,0 +1,55 @@
local function runAutoTaunter()
local players = team.GetPlayers(TEAM_PROPS)
local pRange = TAUNT_MAX_PITCH - TAUNT_MIN_PITCH

--Render the Auto-taunt HUD

for _,ply in pairs(players) do
local taunt = table.Random( PROP_TAUNTS )

if ply:Alive() && ply:Team() == TEAM_PROPS then
if ply.lastTaunt != nil then
local lastAutoTaunt = math.Round(CurTime() - ply.lastTaunt)

--Check if the lastAutoTaunt exceeds the autoTauntInterval
if (lastAutoTaunt > ply.autoTauntInterval) then
--Send the Taunt to the player
local pRange = TAUNT_MAX_PITCH - TAUNT_MIN_PITCH
local pitch = math.random()*pRange + TAUNT_MIN_PITCH
SendTaunt(ply, taunt, pitch )
end
end
end
end
end

function CreateAutoTauntTimer()
timer.Create("AutoTauntTimer", 0.1, 0, runAutoTaunter)
end

hook.Add( "Initialize", "Set Map Time", function ()
mapStartTime = os.time()
CreateAutoTauntTimer()
end)

hook.Add("OBJHUNT_RoundStart", "Restart the Timer", function ()
local players = team.GetPlayers(TEAM_PROPS)
for _,ply in pairs(players) do

ply.autoTauntInterval = OBJHUNT_AUTOTAUNT_INTERVAL + OBJHUNT_HIDE_TIME
ply.lastTaunt = CurTime()

net.Start( "AutoTaunt Update" )
net.WriteUInt( ply:EntIndex(), 8 )
net.WriteFloat( ply.lastTaunt )
net.WriteFloat( ply.autoTauntInterval )
net.Broadcast()
end

if timer.Exists("AutoTauntTimer") then
timer.Start("AutoTauntTimer")
else
CreateAutoTauntTimer()
end

end)
1 change: 1 addition & 0 deletions gamemode/server/rounds.lua
Expand Up @@ -58,6 +58,7 @@ local function WaitRound()
-- make sure we have at least one player on each team
local hunters = team.GetPlayers(TEAM_HUNTERS)
local props = team.GetPlayers(TEAM_PROPS)

if( #props == 0 || #hunters == 0 ) then return end

round.state = ROUND_START
Expand Down
2 changes: 1 addition & 1 deletion gamemode/shared.lua
Expand Up @@ -8,7 +8,7 @@ GM.BaseDir = "ObjHunt/gamemode/"
--[[ Add all the files on server/client ]]--
local resources = {}
resources["server"] = { "server" }
resources["shared"] = { "shared","player_class" }
resources["shared"] = { "shared","player_class", "autotaunt" }
resources["client"] = { "client", "gui" }

local function resourceLoader(dirs, includeFunc)
Expand Down

0 comments on commit 253f4fc

Please sign in to comment.