Fix some animation when latency, add QBB, clean prints, team select, weapon select tweaks, dom flag logic tweaks

This commit is contained in:
Fesiug 2024-09-16 21:15:11 -04:00
parent 1286e17447
commit 915f463b2a
Signed by: Fesiug
GPG Key ID: 374BFF45E1EEF243
8 changed files with 192 additions and 71 deletions

View File

@ -80,27 +80,40 @@ function ENT:Think()
self:EmitSound("buttons/button9.wav", 70, 100, 1)
end
elseif self:GetTeamOwned() != TeamOnPoint then
-- Enemy or early bird taking this point
local COLLECTED = (1/math.max( 1, 6-amtOnPoint )) * FrameTime()
self:SetCapturePercent( math.Approach( self:GetCapturePercent(), 1, COLLECTED ) )
self:SetTeamTaking( TeamOnPoint )
if self:GetCapturePercent() > 0 and self:GetTeamTaking() != TeamOnPoint then
-- Clearing the progress of another team on yet another team's point
local COLLECTED = (1/math.max( 1, 6-amtOnPoint )) * FrameTime()
self:SetCapturePercent( math.Approach( self:GetCapturePercent(), 0, COLLECTED ) )
if self:GetCapturePercent() == 1 then
-- Point successfully captured!
self:SetTeamOwned( TeamOnPoint )
self:SetTeamTaking( 0 )
self:SetCapturePercent( 0 )
self:EmitSound("buttons/blip1.wav", 70, 100, 1)
end
if self:GetCapturePercent() == 0 then
-- Point successfully cleared
self:SetTeamTaking( 0 )
self:EmitSound("buttons/button6.wav", 70, 100, 1)
end
BlockPoints = true -- Block points for this saboteur
else
-- Enemy or early bird taking this point
local COLLECTED = (1/math.max( 1, 6-amtOnPoint )) * FrameTime()
self:SetCapturePercent( math.Approach( self:GetCapturePercent(), 1, COLLECTED ) )
self:SetTeamTaking( TeamOnPoint )
BlockPoints = true -- Block points for this saboteur
if self:GetCapturePercent() == 1 then
-- Point successfully captured!
self:SetTeamOwned( TeamOnPoint )
self:SetTeamTaking( 0 )
self:SetCapturePercent( 0 )
self:EmitSound("buttons/blip1.wav", 70, 100, 1)
end
for ply, edata in pairs(self.Memory) do
edata.xpcollected = (edata.xpcollected or 0) + (COLLECTED * 200)
local sap = math.floor(edata.xpcollected)
if sap >= 10 then
edata.xpcollected = edata.xpcollected - sap
ply:RewardXP( sap )
BlockPoints = true -- Block points for this saboteur
for ply, edata in pairs(self.Memory) do
edata.xpcollected = (edata.xpcollected or 0) + (COLLECTED * 200)
local sap = math.floor(edata.xpcollected)
if sap >= 10 then
edata.xpcollected = edata.xpcollected - sap
ply:RewardXP( sap )
end
end
end
elseif self:GetTeamOwned() == TeamOnPoint then
@ -114,7 +127,7 @@ function ENT:Think()
if self:GetCapturePercent() == 0 then
-- Point successfully cleared
self:SetTeamTaking( 0 )
self:EmitSound("buttons/button10.wav", 70, 100, 1)
self:EmitSound("buttons/bell1.wav", 70, 100, 1)
end
end

View File

@ -46,6 +46,21 @@ local function dospawn( self )
return
end
local function doteamselect( self )
LocalPlayer():ConCommand( "b-cheat_setteam " .. self.iIndex )
self:GetParent():Remove()
end
local function painterly( self, w, h )
surface.SetDrawColor( self.iFaction.COLOR_DARK )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( self.iFaction.COLOR_MAIN )
surface.DrawOutlinedRect( 1, 1, w-2, h-2, 1 )
draw.SimpleText( l8(self.iData.name), "HUD_24", w/2, 4, self.iFaction.COLOR_MAIN, TEXT_ALIGN_CENTER )
return true
end
local function OpenDebugMenu()
if IsValid(DebugMenu) then DebugMenu:Remove() end
DebugMenu = vgui.Create("DFrame")
@ -81,18 +96,29 @@ local function OpenDebugMenu()
vsplit:SetTop( modeller )
modeller:SetModel( "models/weapons/w_pistol.mdl" )
modeller:SetFOV( 5 )
local original = Vector( 0, 50, 0 )
modeller:SetCamPos( original )
modeller:SetLookAt( vector_origin )
modeller:SetPos( vector_origin )
modeller.Entity:SetAngles( angle_zero )
modeller.Standard = Vector( 0, 100, 0 )
modeller.Finalized = Vector()
function modeller:LayoutEntity( ent )
ent:SetPos( Vector( 0, 0, 0 ) )
ent:SetAngles( Angle( 0, 0 * RealTime() * 10 % 360, 0 ) )
local the = Vector(modeller.Finalized)
the:Rotate( Angle( 0, (360/4) * RealTime() % 360, 0 ) )
modeller:SetCamPos( the )
-- ent:SetPos( Vector( 0, 0, 0 ) )
--ent:SetAngles( Angle( 0, 10 * RealTime() * 10 % 360, 0 ) )
return
end
modeller:SetAmbientLight( HSLToColor( 0, 0, 1.00 ) )
modeller:SetDirectionalLight(BOX_TOP, HSLToColor( 0, 0, 1.00 ) )
modeller:SetDirectionalLight(BOX_FRONT, HSLToColor( 0, 0, 1.00 ) )
modeller:SetAmbientLight( HSLToColor( 0, 0, 0.00 ) )
modeller:SetDirectionalLight(BOX_TOP, HSLToColor( 0, 0, 0.50 ) )
modeller:SetDirectionalLight(BOX_BOTTOM, HSLToColor( 0, 0, 0.50 ) )
modeller:SetDirectionalLight(BOX_FRONT, HSLToColor( 0, 0, 0.50 ) )
modeller:SetDirectionalLight(BOX_BACK, HSLToColor( 0, 0, 0.50 ) )
modeller:SetDirectionalLight(BOX_LEFT, HSLToColor( 0, 0, 1.00 ) )
modeller:SetDirectionalLight(BOX_RIGHT, HSLToColor( 0, 0, 1.00 ) )
function modeller:Update( mdl )
@ -101,15 +127,19 @@ local function OpenDebugMenu()
local worked = self.Entity:PhysicsInit( SOLID_VPHYSICS )
if worked then
-- Factors the USP's bodygroup suppressor for some reason. Great
local mins, maxs = self.Entity:GetCollisionBounds()
-- Factors the USP's bodygroup suppressor for some reason. Great -- Not anymore, changed it to Physics Object AABB
local mins, maxs = self.Entity:GetPhysicsObject():GetAABB()
local wsc = Vector()
wsc:Add( mins )
wsc:Add( maxs )
wsc:Div( 2 )
self:SetLookAt( wsc )
self:SetCamPos( wsc+original )
self.Entity:SetPos( -wsc )
self:SetLookAt( vector_origin )
modeller.Finalized:Set(modeller.Standard)
--self:SetCamPos( modeller.Standard )
-- local HFOV = 45-5
-- local hfovRad = HFOV * math.pi / 180
@ -120,26 +150,26 @@ local function OpenDebugMenu()
-- scale test
if true then for i=1, 50 do
local S1, S2 = false, false
local aimVector = (self:GetLookAt() - self:GetCamPos()):GetNormalized()
local aimVector = (self:GetLookAt() - modeller.Finalized):GetNormalized()
do -- test 1, mins
local entVector = mins - self:GetCamPos()
local entVector = mins - modeller.Finalized
local angCos = aimVector:Dot(entVector) / entVector:Length()
S1 = (angCos >= directionAngCos)
end
do -- test 2: maxs
local entVector = maxs - self:GetCamPos()
local entVector = maxs - modeller.Finalized
local angCos = aimVector:Dot(entVector) / entVector:Length()
S2 = (angCos >= directionAngCos)
end
if S1 and S2 then
self.indicate = "took " .. i
self.vCamPos:Add( Vector( 0, 20, 0 ) )
self.indicate = i
--modeller.Finalized:Add( Vector( 0, 20, 0 ) )
--self.vLookatPos:Add( Vector( 0, 0, 0 ) )
--self.vLookatPos:Set( (mins+maxs)/2 )
break
else
self.indicate = "failed"
self.vCamPos:Sub( (aimVector*20) )
modeller.Finalized:Sub( (aimVector*20) )
end
end end
else
@ -182,12 +212,14 @@ local function OpenDebugMenu()
self:DrawModel()
render.MaterialOverride()
local mins, maxs = self.Entity:GetCollisionBounds()
-- render.SetColorMaterial()
-- render.DrawSphere( mins, .5, 30, 30, Color( 255, 0, 0 ) )
-- render.DrawSphere( maxs, .5, 30, 30, Color( 0, 0, 255 ) )
-- render.DrawWireframeBox( vector_origin, angle_zero, mins, maxs, Color( 0, 0, 0, 127 ))
if false and self.Entity:GetPhysicsObject():IsValid() then
local pos = self.Entity:GetPos()
local mins, maxs = self.Entity:GetPhysicsObject():GetAABB()
render.SetColorMaterial()
render.DrawSphere( pos+mins, .5, 30, 30, Color( 255, 0, 0 ) )
render.DrawSphere( pos+maxs, .5, 30, 30, Color( 0, 0, 255 ) )
render.DrawWireframeBox( pos, angle_zero, mins, maxs, Color( 0, 0, 0, 127 ))
end
render.SuppressEngineLighting( false )
cam.End3D()
@ -195,15 +227,15 @@ local function OpenDebugMenu()
self.LastPaint = RealTime()
end
function modeller:Paint( w, h )
surface.SetDrawColor( color_black )
surface.SetDrawColor( HSLToColor( 0.9, 0.2, 0 ) )
surface.DrawRect( 0, 0, w, h )
self:Paint1( w, h )
if self.Failed then
draw.SimpleText("Failed physinit, not cached?", "HUD_36", w/2, h/2, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
-- if self.indicate then
-- draw.SimpleText(self.indicate, "HUD_36", w/2, h/2 + 48, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
-- end
if self.indicate then
draw.SimpleText(self.indicate, "HUD_16", 4, 4, color_white)
end
end
end
@ -247,9 +279,40 @@ local function OpenDebugMenu()
end
end
local function OpenMyTeamMenu()
if IsValid(DebugMenu) then DebugMenu:Remove() end
DebugMenu = vgui.Create("DFrame")
DebugMenu:SetSize( 200, 300 )
DebugMenu:MakePopup()
DebugMenu:SetKeyboardInputEnabled( false )
DebugMenu:SetSizable(false)
for index, data in ipairs( TEAMS ) do
local faction = FACTIONS[ data.factionid ]
if !faction then continue end
local button = DebugMenu:Add("DButton")
button:Dock( TOP )
button:DockMargin( 0, 0, 0, 5 )
button:SetText( l8( data.name ) )
button.iIndex = index
button.iData = data
button.iFaction = faction
button:SetTall(28)
button.DoClick = doteamselect
button.Paint = painterly
end
DebugMenu:InvalidateLayout( true )
DebugMenu:SizeToChildren( false, true )
DebugMenu:Center()
end
hook.Add("PlayerButtonDown", "PlayerButtonDown_DebugMenu", function( ply, button )
if button == KEY_F1 then
OpenDebugMenu()
elseif button == KEY_F2 then
OpenMyTeamMenu()
end
end)

View File

@ -17,8 +17,6 @@ function BennyGame:GetType()
return cGametype:GetBool() and BG_GTYPE_MP or BG_GTYPE_CAMPAIGN
end
GM.TeamBased = BennyGame:GetType() == BG_GTYPE_MP
function BennyGame:GetMode()
return cGamemode:GetString()
end
@ -30,6 +28,10 @@ end
BennyGame.TeamsInPlay = {
4,
3,
--2,
--1,
--5,
--6,
}
BennyGame.TeamCount = #BennyGame.TeamsInPlay
@ -242,7 +244,6 @@ function BennyGame:EndRound( reason, forceteam )
if HighestScore < ThisScore then
HighestScore = ThisScore
HighestTeam = RealTeamID
print("highest score to do it to em", HighestScore, TEAMS[HighestTeam].name)
winningteam = HighestTeam
end
end
@ -251,9 +252,9 @@ function BennyGame:EndRound( reason, forceteam )
local ThisScore = BennyGame:GetScoreForTeam( RealTeamID )
if RealTeamID == HighestTeam then continue end
if HighestScore < ThisScore then
print("clearly there's been a failure", RealTeamID, ThisScore, HighestTeam, HighestScore)
-- print("clearly there's been a failure", RealTeamID, ThisScore, HighestTeam, HighestScore)
elseif HighestScore == ThisScore then
print("this looks like a tie", RealTeamID, HighestTeam)
-- print("this looks like a tie", RealTeamID, HighestTeam)
winningteam = 0
break
end
@ -272,7 +273,14 @@ function BennyGame:EndRound( reason, forceteam )
PrintMessage(HUD_PRINTCENTER, TheFull)
local roundtime = CurTime() - BennyGame:GetRoundStartedAt()
print( "That round lasted " .. math.ceil(roundtime) .. " seconds." )
local rf = string.FormattedTime( 269 )
local nicely = ""
if rf.h > 0 then
nicely = nicely .. rf.h .. ":"
end
nicely = nicely .. string.format( "%02i:%02i.", rf.m, rf.s )
print( "That round lasted " .. nicely )
end
concommand.Add("b-cheat_scoreset", function( ply, cmd, args )

View File

@ -119,7 +119,7 @@ local function regenfonts()
end
regenfonts()
local FACTIONS = {
FACTIONS = {
["benny"] = {
COLOR_MAIN = Color( 255, 238, 169 ),
COLOR_DARK = Color( 54, 44, 39 ),
@ -428,7 +428,7 @@ function GM:HUDPaint()
local wep = handler:GetActiveR()
if wep and wep.GetClip then
local Bw, Bh = 328, 160
local Bw, Bh = 8+(8+2)*30-2+8, 160
S_Push( w - 20 - Bw, h - 20 - Bh )
hCol( COLOR_DARK )
hRect( 0, 0, Bw, Bh )
@ -689,11 +689,11 @@ function GM:HUDPaint()
if TITLE!="SECURE" then
S_Push( -BWIDE/2, 62 )
hCol( obj:GetContested() and CONTOLER_DARK or COLOR_DARK )
hCol( TAKCOLOR_DARK )
hRect( 0, 0, 180, BTALL )
hCol( obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN )
hCol( TAKCOLOR_MAIN )
hORect( 1, 1, 180-2, BTALL-2 )
hCol( obj:GetContested() and CONTOLER_MAIN or TITLE=="CLEARING" and TAKCOLOR_MAIN or COLOR_MAIN )
hCol( TAKCOLOR_MAIN )
hRect( 3, 3, math.floor((BWIDE-6) * PERCENT), BTALL-6 )
S_Pop()
local x, y = hXY( 0, 78 )

View File

@ -218,7 +218,9 @@ AddItem( "base_firearm", {
p:LagCompensation(false)
local ply = handler:GetOwner()
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["fire"][class.HoldType] ), 0, true )
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["fire"][class.HoldType] ), 0, true )
end
ent:PlayAnimation( ent:LookupSequence("fire") )
end,
@ -237,14 +239,18 @@ AddItem( "base_firearm", {
handler:EmitSound( class.MagOutSound, 70, 100, 0.4, CHAN_STATIC )
ent:SetLoaded( false )
ent:SetClip( 0 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload"][class.HoldType] ), 0, true )
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload"][class.HoldType] ), 0, true )
end
time = 0.4
ent:PlayAnimation( ent:LookupSequence("magout") )
else
handler:EmitSound( class.MagInSound, 70, 100, 0.4, CHAN_STATIC )
ent:SetLoaded( true )
ent:SetRefillTime( CurTime() + 0.5 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload_insert"][class.HoldType] ), 0, true )
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["reload_insert"][class.HoldType] ), 0, true )
end
time = 0.8
ent:PlayAnimation( ent:LookupSequence("magin") )
end
@ -256,7 +262,9 @@ AddItem( "base_firearm", {
ent:SetDelay( CurTime() + 0.5 )
local ply = handler:GetOwner()
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["deploy"][class.HoldType] ), 0, true )
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["deploy"][class.HoldType] ), 0, true )
end
end,
["Holster"] = function( class, ent, handler )
@ -266,7 +274,9 @@ AddItem( "base_firearm", {
ent:SetDelay( CurTime() + 0.25 )
local ply = handler:GetOwner()
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["holster"][class.HoldType] ), 0, true )
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["holster"][class.HoldType] ), 0, true )
end
end,
})
@ -658,6 +668,31 @@ do -- Rifles
end
do -- MGs
AddItem( "qbb", {
PrintName = "#Item.qbb.Name",
Description = "#Item.qbb.Description",
Category = "machinegun",
Base = "base_firearm",
Model = "models/benny/weapons/test_qbb.mdl",
HoldType = "rifle",
ClipSize = 75,
Delay = (60/750),
FireSound = {
"benny/weapons/stoner63/01.ogg",
"benny/weapons/stoner63/02.ogg",
"benny/weapons/stoner63/03.ogg",
},
Accuracy = 1,
Accuracy_Add = 0.4,
Accuracy_Reset = 0.4,
Accuracy_Decay = 12,
})
end
do -- SMGs
AddItem( "tmp", {

View File

@ -32,6 +32,9 @@ L["#Item.fnc.Description"] = "Imported assault rifle"
L["#Item.qbz.Name"] = "QBZ-95"
L["#Item.qbz.Description"] = "Low-profile bullpup assault rifle"
L["#Item.qbb.Name"] = "QBB-LSW"
L["#Item.qbb.Description"] = "Bullpup machine gun"
L["#Item.m16a2.Name"] = "M16A2"
L["#Item.m16a2.Description"] = "Rugged burst rifle"

View File

@ -368,7 +368,9 @@ hook.Add("Move", "Benny_Move", function( ply, mv )
ply:SetGroundEntity( NULL )
ply:SetInDive( true )
ply:SetDivedAt( CurTime() )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_start_handgun" ), 0, true )
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_start_handgun" ), 0, true )
end
if (SERVER) or (CLIENT and IsFirstTimePredicted()) then
local rfil = nil
if SERVER then
@ -378,8 +380,6 @@ hook.Add("Move", "Benny_Move", function( ply, mv )
end
ply:EmitSound("weapons/slam/throw.wav", 70, 100, .25, nil, nil, nil, rfil)
end
ply:SetHull( Vector( -8, -8, 32 ), Vector( 8, 8, 72 ) )
ply:SetHullDuck( Vector( -8, -8, 32 ), Vector( 8, 8, 48 ) )
end
if ply:OnGround() and ply:GetInDive() then
if (SERVER) or (CLIENT and IsFirstTimePredicted()) then
@ -393,12 +393,11 @@ hook.Add("Move", "Benny_Move", function( ply, mv )
end
ply:SetInDive(false)
ply:SetDivedAt( CurTime() )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_end_handgun" ), 0, true )
ply:SetHull( Vector( -8, -8, 0 ), Vector( 8, 8, 72 ) )
ply:SetHullDuck( Vector( -8, -8, 0 ), Vector( 8, 8, 48 ) )
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:LookupSequence( "dive_end_handgun" ), 0, true )
end
mv:SetVelocity( mv:GetVelocity() + Vector( 0, 0, 120 ) )
ply:SetGroundEntity( NULL )
mv:SetOrigin( mv:GetOrigin() + vector_up*32 )
end
--if !ply:OnGround() and ply:GetInDive() then
-- local da = ply:GetDivedAt()

View File

@ -9,7 +9,7 @@ concommand.Add("b-cheat_setteam", function( ply, cmd, args )
print( index .. " - " .. data.id )
end
else
ply:SetTeam( TEAMS_IDorName( args[1] ) )
ply:SetTeam( TEAMS_IDorName( tonumber(args[1]) or args[1] ) )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )