Compare commits

..

No commits in common. "main" and "pre-rewrite" have entirely different histories.

69 changed files with 8608 additions and 5357 deletions

View File

@ -6,31 +6,30 @@
@include "base.fgd" @include "base.fgd"
@PointClass base(PlayerClass, Angles) color(255 100 100) studio("models/editor/playerstart.mdl") = benny_playerstart_team1 @PointClass base(Targetname, Angles, Origin) lightprop("models/editor/spot.mdl") halfgridsnap frustum(lightfov,1,100) = benny_camera : "Benny - Camera"
[ [
camera_type(choices) : "Type" : "standard" : "Style of camera" =
[
"standard" : "Standard"
"field" : "Field"
]
lightfov(float) : "FOV" : "90.0" : "FOV"
target(target_destination) : "Camera Target" : : "Bounds that trigger the camera to activate"
lerp0_target(target_destination) : "Lerp 0" : : "Starting point of the lerp for the camera"
lerp1_target(target_destination) : "Lerp 1" : : "Ending point of the lerp for the camera"
lerp1_fov(float) : "End FOV" : : "Ending FOV for the lerp"
] ]
@PointClass base(PlayerClass, Angles) color(100 100 255) studio("models/editor/playerstart.mdl") = benny_playerstart_team2 @PointClass base(Targetname, Angles, Origin) lightprop("models/editor/axis_helper_thick.mdl") halfgridsnap = benny_camera : "Benny - Camera Lerp Point"
[ [
camera_type(choices) : "Type" : "standard" : "Style of camera" =
[
"standard" : "Standard"
"field" : "Field"
]
] ]
@PointClass base(PlayerClass, Angles) color(100 255 100) studio("models/editor/playerstart.mdl") = benny_playerstart_team3 @SolidClass base(Targetname) = benny_camerabounds : "Benny - Camera Bounds"
[ [
target(target_destination) : "Camera Target" : : "Bounds that trigger the camera to activate"
] ]
@PointClass base(PlayerClass, Angles) color(255 255 100) studio("models/editor/playerstart.mdl") = benny_playerstart_team4
[
]
@PointClass base(PlayerClass, Angles) color(255 200 200) studio("models/editor/playerstart.mdl") = benny_playerstart_team5
[
]
@PointClass base(PlayerClass, Angles) color(255 200 255) studio("models/editor/playerstart.mdl") = benny_playerstart_team6
[
]
@PointClass base(Origin, Angles) studio("models/editor/axis_helper_thick.mdl") = benny_domflag
[
]

View File

@ -0,0 +1,59 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.RenderGroup = RENDERGROUP_BOTH
function ENT:Initialize()
self.DieTime = CurTime() + 3
end
function ENT:InitSpecial( model )
self:SetModel( model )
-- Physics stuff
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
-- Init physics only on server, so it doesn't mess up physgun beam
if ( SERVER ) then self:PhysicsInit( SOLID_VPHYSICS ) end
self:SetCollisionGroup( COLLISION_GROUP_PROJECTILE )
-- Make prop to fall on spawn
self:PhysWake()
if SERVER then
local p = self:GetPhysicsObject()
p:SetMass( 0 )
end
end
function ENT:Think()
if SERVER and self.DieTime <= CurTime() then
self:Remove()
end
end
function ENT:PhysicsCollide( data, phys )
if ( data.Speed > 200 ) and data.DeltaTime > 0.2 then
local ent = data.HitEntity
print(ent:Health())
if ent:IsValid() and ent:Health() > 0 then
ent:EmitSound( ")benny/violence/bodysplat_mix2.ogg", 70, 100, 1 )
local dmg = DamageInfo()
dmg:SetDamageType( DMG_CLUB )
dmg:SetDamage( 25 )
dmg:SetAttacker( self:GetOwner() )
dmg:SetInflictor( self )
print( data.HitSpeed, data.HitSpeed:Length() )
dmg:SetDamageForce( data.HitSpeed*-10 )
dmg:SetDamagePosition( data.HitPos )
ent:TakeDamageInfo( dmg )
else
self:EmitSound( "physics/metal/weapon_impact_hard1.wav" )
end
end
end

View File

@ -0,0 +1,3 @@
ENT.Base = "b-item"

View File

@ -1,138 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.BennyItem = true
ENT.AutomaticFrameAdvance = true
function ENT:Initialize()
self:SetModel( self.Class.Model or "models/weapons/w_357.mdl" )
if SERVER then
self:PhysicsInit( SOLID_VPHYSICS )
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self:GetPhysicsObject():Wake()
end
self.Class:Initialize( self )
end
if SERVER then
util.AddNetworkString("Benny_ItemSlept")
else
net.Receive("Benny_ItemSlept", function()
local ent = net.ReadEntity()
if ent:IsValid() then
ent:SetPredictable( false )
print("[prediction] cl stop:", ent)
end
end)
end
function ENT:PlayAnimation( seqid, speed )
self:ResetSequence( seqid )
-- Interpolation
if CLIENT and IsFirstTimePredicted() then
self.CLCycle = 0
self.StartTime = UnPredictedCurTime()
end
end
function ENT:Think()
self:NextThink( CurTime() )
if CLIENT then
self:SetNextClientThink( CurTime()-5 )
-- Interpolation
if self:GetOwner() == LocalPlayer() then
local diff = (UnPredictedCurTime()) - (self.LastThink or UnPredictedCurTime())
if diff then
self.CLCycle = math.Approach( self.CLCycle or 0, 1, ( 1/self:SequenceDuration() ) * diff )
self:SetCycle( self.CLCycle )
self.LastThink = UnPredictedCurTime()
end
end
end
self.Class:EntThink( self )
if CLIENT then return true end
self.BAsleep = self.BAsleep or false
local ph = self:GetPhysicsObject()
if ph:IsValid() and !self:GetOwner():IsValid() then
if ph:IsAsleep() then
if !self.BAsleep then
net.Start("Benny_ItemSlept")
net.WriteEntity(self)
net.Broadcast()
print("[prediction] sv stop:", self)
--self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self.BAsleep = true
end
elseif self.BAsleep then
-- print(self, "Woke up")
self.BAsleep = false
end
end
return true
end
local function recurse( modify, includer )
local basevars = ITEMS[includer].BaseClass
if ITEMS[includer].BaseClass then
recurse( modify, ITEMS[includer].Base )
end
local localvars = ITEMS[includer]:GetRaw("Vars")
if localvars then
for i, v in pairs( localvars ) do
if !modify[i] then modify[i] = {} end
table.Add( modify[i], v )
end
end
end
function ENT:SetupDataTables()
local NWVars = { ["Float"] = { "AnimStartTime", "AnimEndTime" } }
recurse( NWVars, self.ID )
for varname, varlist in pairs(NWVars) do
--local numba = 0
for keyind, keyname in ipairs(varlist) do
self:NetworkVar( varname, keyname )
--numba = numba + 1
end
end
end
if SERVER then
function ENT:PhysicsCollide( data, collider )
self.Class:EntPhysicsCollide( self, data, collider )
if ( data.DeltaTime > 0.1 ) then
--self:EmitSound( str, 70, 100, 1, CHAN_STATIC )
end
return
end
else
hook.Add("NotifyShouldTransmit", "AE_NotifyShouldTransmit", function( ent, shouldtransmit )
if ent.BennyItem then
if shouldtransmit then
if ent:GetOwner() == LocalPlayer() then
ent:SetPredictable( true )
end
else
ent:SetPredictable( false )
end
end
end)
end

View File

@ -41,7 +41,7 @@ if CLIENT then
local s = ScreenScaleH local s = ScreenScaleH
local function DST( text, font, x, y, color ) local function DST( text, font, x, y, color )
for O=1, 1 do for O=1, 2 do
draw.SimpleText( text, font, x-O, y-O, color_black ) draw.SimpleText( text, font, x-O, y-O, color_black )
draw.SimpleText( text, font, x, y-O, color_black ) draw.SimpleText( text, font, x, y-O, color_black )
draw.SimpleText( text, font, x+O, y-O, color_black ) draw.SimpleText( text, font, x+O, y-O, color_black )
@ -213,14 +213,14 @@ ENT.States = {
if (self.NextFire or 0) <= CurTime() then if (self.NextFire or 0) <= CurTime() then
local rp = RecipientFilter() local rp = RecipientFilter()
rp:AddAllPlayers() rp:AddAllPlayers()
self:EmitSound("benny/weapons/usp/01.ogg", 80, 100, 0.2, nil, nil, nil, rp ) self:EmitSound("benny/weapons/usp/01.ogg", 100, 100, 0.2, nil, nil, nil, rp )
--self:FireBullets( { self:FireBullets( {
-- Attacker = self, Attacker = self,
-- Inflictor = self, Inflictor = self,
-- Damage = 3, Damage = 3,
-- Dir = self:EyeAngles():Forward(), Dir = self:EyeAngles():Forward(),
-- Src = self:EyePos() Src = self:EyePos()
--} ) } )
self.NextFire = CurTime() + 0.5 self.NextFire = CurTime() + 0.5
end end
else else

View File

@ -1,29 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
function ENT:Initialize()
self:SetModel("models/hunter/blocks/cube025x025x025.mdl")
if SERVER then
self:PhysicsInit( SOLID_VPHYSICS )
local phy = self:GetPhysicsObject()
phy:Wake()
end
end
function ENT:Detonate()
local effectdata = EffectData()
effectdata:SetOrigin( self:GetPos() )
util.Effect( "Explosion", effectdata, nil, true )
self:Remove()
end

View File

@ -1,168 +0,0 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.DomFlag = true
function ENT:Initialize()
self:SetModel("models/hunter/blocks/cube025x025x025.mdl")
self:AddEFlags( EFL_FORCE_CHECK_TRANSMIT )
self:SetMoveType( MOVETYPE_NONE )
if SERVER then
self:SetTrigger( true )
end
self:AddSolidFlags( bit.bor( FSOLID_TRIGGER, FSOLID_USE_TRIGGER_BOUNDS ) )
local radius, tall = 100, 80
self:SetCollisionBounds( Vector( -radius, -radius, 0 ), Vector( radius, radius, tall ))
self.Memory = {}
self:SetTeamTaking( 0 )
self:SetTeamOwned( 0 )
end
function ENT:UpdateTransmitState()
return TRANSMIT_ALWAYS
end
function ENT:SetupDataTables()
self:NetworkVar( "Float", "CapturePercent" )
self:NetworkVar( "Int", "TeamTaking" )
self:NetworkVar( "Int", "TeamOwned" )
self:NetworkVar( "Bool", "Contested" )
end
function ENT:Think()
if CLIENT then return end
local Contested = false
local TeamOnPoint = nil
local amtOnPoint = 0
for ply, edata in pairs(self.Memory) do
if edata.time+0.1 < CurTime() then
--self.Memory[ply] = nil
continue
end
amtOnPoint = amtOnPoint + 1
if !TeamOnPoint then
TeamOnPoint = ply:Team()
elseif TeamOnPoint != ply:Team() then
Contested = true
end
end
self:SetContested( Contested )
local BlockPoints = false
local RoundActive = BennyGame:GetState() == BG_STATE_ACTIVE
if RoundActive and amtOnPoint > 0 then
-- People on point
if Contested then
-- Point is currently contested
BlockPoints = true -- Block points for this saboteur
else
if self:GetTeamOwned() == 0 and self:GetTeamTaking() != TeamOnPoint then
-- Clearing a neutral point
local COLLECTED = (1/math.max( 1, 6-amtOnPoint )) * FrameTime()
self:SetCapturePercent( math.Approach( self:GetCapturePercent(), 0, COLLECTED ) )
if self:GetCapturePercent() == 0 then
-- Point successfully cleared
self:SetTeamTaking( TeamOnPoint )
self:EmitSound("buttons/button9.wav", 70, 100, 1)
end
elseif self:GetTeamOwned() != TeamOnPoint then
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() == 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 )
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
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
-- Team that owns the point is on the point
if self:GetCapturePercent() > 0 then
-- There's progress on it, revert it
local COLLECTED = (1/math.max( 1, 6-amtOnPoint )) * FrameTime()
self:SetCapturePercent( math.Approach( self:GetCapturePercent(), 0, COLLECTED ) )
if self:GetCapturePercent() == 0 then
-- Point successfully cleared
self:SetTeamTaking( 0 )
self:EmitSound("buttons/bell1.wav", 70, 100, 1)
end
end
end
end
self.LastCaptureTime = CurTime()
end
if RoundActive and !BlockPoints and (self.nextpoints or 0) <= CurTime() and self:GetTeamOwned() > 0 then
-- self:EmitSound("buttons/button10.wav", 70, 100, 1)
self.nextpoints = math.floor( CurTime() + 1 )
BennyGame:AddScoreForTeam( self:GetTeamOwned(), 1 )
end
local per = self:GetCapturePercent()
self:NextThink( CurTime()-1 )
local aa, bb = self:GetCollisionBounds()
debugoverlay.Box( self:GetPos(), aa, bb, 0, Color( 255, 255*(1-per), 255*(1-per), 0 ))
debugoverlay.Text( self:GetPos(), math.floor(self:GetCapturePercent()*100), 0 )
debugoverlay.Text( self:GetPos()-vector_up*8, self:GetTeamOwned(), 0 )
debugoverlay.Text( self:GetPos()-vector_up*16, self:GetTeamTaking(), 0 )
return true
end
function ENT:Touch( ent )
if ent:IsPlayer() then
ent:SetTouchedObjective( self )
ent:SetTouchedObjectiveTime( CurTime() )
if !self.Memory[ent] then
self.Memory[ent] = {}
end
self.Memory[ent].time = CurTime()
end
end

View File

@ -1,4 +0,0 @@
AddCSLuaFile()
ENT.Type = "point"

View File

@ -1,4 +0,0 @@
AddCSLuaFile()
ENT.Type = "point"

View File

@ -1,4 +0,0 @@
AddCSLuaFile()
ENT.Type = "point"

View File

@ -1,4 +0,0 @@
AddCSLuaFile()
ENT.Type = "point"

View File

@ -1,4 +0,0 @@
AddCSLuaFile()
ENT.Type = "point"

View File

@ -1,4 +0,0 @@
AddCSLuaFile()
ENT.Type = "point"

View File

@ -0,0 +1,95 @@
function SWEP:DrawWorldModel()
local p = self:GetOwner()
do
local wm = self.CWM
local class = self:bWepClass( false )
if class then
if !IsValid(wm) then
wm = ClientsideModel( class.WModel )
self.CWM = wm
end
wm:SetModel( class.WModel )
wm:SetNoDraw( true )
if class.MAdj then
if wm:IsEffectActive( EF_BONEMERGE ) then
wm:RemoveEffects( EF_BONEMERGE )
end
-- Specify a good position
local offsetVec = class.MAdj
local offsetAng = class.MAdjA or angle_zero
local boneid = p:LookupBone("ValveBiped.Bip01_R_Hand") -- Right Hand
if !boneid then return end
local matrix = p:GetBoneMatrix(boneid)
if !matrix then return end
local newPos, newAng = LocalToWorld(offsetVec, offsetAng, matrix:GetTranslation(), matrix:GetAngles())
wm:SetPos(newPos)
wm:SetAngles(newAng)
wm:SetupBones()
else
if !wm:IsEffectActive( EF_BONEMERGE ) then
wm:AddEffects( EF_BONEMERGE )
end
wm:SetPos(self:GetPos())
wm:SetAngles(self:GetAngles())
end
wm:SetParent( p )
if true or self:GetUserAim() then wm:DrawModel() end
else
if IsValid(wm) then wm:Remove() end
end
end
do
local wm = self.CWM_Left
local class = self:bWepClass( true )
if class then
if !IsValid(wm) then
wm = ClientsideModel( class.WModel )
self.CWM_Left = wm
end
wm:SetModel( class.WModel )
wm:SetNoDraw( true )
if IsValid(p) then
-- Specify a good position
wm:SetPos( vector_origin )
wm:SetAngles( angle_zero )
wm:SetupBones()
local pv = wm:GetBoneMatrix( wm:LookupBone( "ValveBiped.Bip01_R_Hand" ) ):GetTranslation()
local pa = wm:GetBoneMatrix( wm:LookupBone( "ValveBiped.Bip01_R_Hand" ) ):GetAngles()
pv.x = -pv.x
pv.y = pv.y
pv.z = -pv.z
pa.p = -pa.p
pa.r = pa.r + 180
local boneid = p:LookupBone("ValveBiped.Bip01_L_Hand") -- Right Hand
if !boneid then return end
local matrix = p:GetBoneMatrix(boneid)
if !matrix then return end
local newPos, newAng = LocalToWorld(pv, pa, matrix:GetTranslation(), matrix:GetAngles())
wm:SetPos(newPos)
wm:SetAngles(newAng)
wm:SetupBones()
else
wm:SetPos(self:GetPos())
wm:SetAngles(self:GetAngles())
wm:SetupBones()
end
if true or self:GetUserAim() then wm:DrawModel() end
else
if IsValid(wm) then wm:Remove() end
end
end
end

View File

@ -0,0 +1,34 @@
function SWEP:Drop( hand )
if self:bWepClass( hand ) then
local p = self:GetOwner()
self:EmitSound( "weapons/slam/throw.wav", 70, 100, 1, CHAN_STATIC )
if SERVER then
local throw = ents.Create( "b-item" )
throw:SetPos( p:EyePos() + p:EyeAngles():Forward()*16 )
throw:SetAngles( p:EyeAngles() )
throw:SetOwner( p )
throw:InitSpecial(self:bWepClass( hand ).WModel)
throw:SetPhysicsAttacker( p )
throw:Spawn()
local throwp = throw:GetPhysicsObject()
assert( throwp:IsValid(), "Benny Drop: Physics object invalid" )
throwp:SetVelocityInstantaneous( (p:EyeAngles()+Angle(-7,0,0)):Forward()*1000 )
if self:bWepClass( hand ).ClassName == "m16a2" then
throwp:SetAngleVelocityInstantaneous( Vector( 360*-0.2, 360*1, 360*0 ) )
else
throwp:SetAngleVelocityInstantaneous( Vector( 360*-0.25, 360*10, 360*0.25 ) )
end
end
if SERVER or CLIENT and IsFirstTimePredicted() then
--InvDiscard( p, self:bGetInvID( hand ) )
end
self:SetJustThrew( CurTime() + 0.25 )
self:SetJustThrewHand( hand )
self:bWepTable( hand ).Thrown = true
p:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, p:SelectWeightedSequence( ACT_HL2MP_GESTURE_RANGE_ATTACK_MELEE ), 0, true )
end
end

View File

@ -0,0 +1,84 @@
function SWEP:PrimaryAttack()
if self:bWepTable( self:hFlipHand( false ) ) and self:bWepTable( self:hFlipHand( false ) ).Thrown then return true end
self:BFireLogic( self:hFlipHand( false ) )
return true
end
function SWEP:SecondaryAttack()
if self:bWepTable( self:hFlipHand( true ) ) and self:bWepTable( self:hFlipHand( true ) ).Thrown then return true end
self:BFireLogic( self:hFlipHand( true ) )
return true
end
function SWEP:BFireLogic( hand )
if self:bWepClass( hand ) then
self:BFire( hand )
elseif self:bWepClass( !hand ) then
self:BFireAlt( !hand )
end
end
function SWEP:BFire( hand )
if self:bWepClass( hand ) and self:bWepClass( hand ).Func_Attack then
if self:bWepClass( hand ).Func_Attack( self, hand ) then return end
end
end
function SWEP:BFireAlt( hand )
if self:bWepClass( hand ) and self:bWepClass( hand ).Func_AttackAlt then
if self:bWepClass( hand ).Func_AttackAlt( self, hand ) then return end
end
end
local bc = { effects = true, damage = true }
function SWEP:CallFire( hand )
local p = self:GetOwner()
local class = self:bWepClass( hand )
local spread = self:BSpread( hand )
for i=1, self:GetStat( hand, "Pellets" ) do
local dir = self:GetOwner():EyeAngles()
local radius = util.SharedRandom("benny_distance_"..tostring(hand), 0, 1, i )
local circ = util.SharedRandom("benny_radius_"..tostring(hand), 0, math.rad(360), i )
dir:RotateAroundAxis( dir:Right(), spread * radius * math.sin( circ ) )
dir:RotateAroundAxis( dir:Up(), spread * radius * math.cos( circ ) )
dir:RotateAroundAxis( dir:Forward(), 0 )
local tr = util.TraceLine( {
start = p:EyePos(),
endpos = p:EyePos() + dir:Forward() * 8192,
filter = p
} )
self:FireBullets( {
Attacker = p,
Damage = class.Damage,
Force = ( class.Damage / 10 ) * self:GetStat( hand, "Pellets" ),
Src = p:EyePos(),
Dir = dir:Forward(),
Tracer = 0,
IgnoreEntity = p,
Callback = function( atk, tr, dmginfo )
if CLIENT and IsFirstTimePredicted() then
self:FireCL( hand, tr )
end
return bc
end,
} )
end
end
function SWEP:FireCL( hand, tr )
-- PROTO: This is shit! Replace it with a function that gets the right model.
local vStart = (hand and self.CWM_Left or self.CWM):GetAttachment( 1 ).Pos
local vPoint = tr.HitPos
local effectdata = EffectData()
effectdata:SetStart( vStart )
effectdata:SetOrigin( vPoint )
effectdata:SetEntity( self )
effectdata:SetScale( 1025*12 )
effectdata:SetFlags( 1 )
util.Effect( "Tracer", effectdata )
end

View File

@ -0,0 +1,155 @@
-- Holdtype thingys
do
local ActIndex = {
[ "pistol" ] = ACT_HL2MP_IDLE_PISTOL,
[ "smg" ] = ACT_HL2MP_IDLE_SMG1,
[ "grenade" ] = ACT_HL2MP_IDLE_GRENADE,
[ "ar2" ] = ACT_HL2MP_IDLE_AR2,
[ "shotgun" ] = ACT_HL2MP_IDLE_SHOTGUN,
[ "rpg" ] = ACT_HL2MP_IDLE_RPG,
[ "physgun" ] = ACT_HL2MP_IDLE_PHYSGUN,
[ "crossbow" ] = ACT_HL2MP_IDLE_CROSSBOW,
[ "melee" ] = ACT_HL2MP_IDLE_MELEE,
[ "slam" ] = ACT_HL2MP_IDLE_SLAM,
[ "normal" ] = ACT_HL2MP_IDLE,
[ "fist" ] = ACT_HL2MP_IDLE_FIST,
[ "melee2" ] = ACT_HL2MP_IDLE_MELEE2,
[ "passive" ] = ACT_HL2MP_IDLE_PASSIVE,
[ "knife" ] = ACT_HL2MP_IDLE_KNIFE,
[ "duel" ] = ACT_HL2MP_IDLE_DUEL,
[ "camera" ] = ACT_HL2MP_IDLE_CAMERA,
[ "magic" ] = ACT_HL2MP_IDLE_MAGIC,
[ "revolver" ] = ACT_HL2MP_IDLE_REVOLVER,
[ "suitcase" ] = ACT_HL2MP_IDLE,
[ "melee_angry" ] = ACT_HL2MP_IDLE_MELEE_ANGRY,
[ "angry" ] = ACT_HL2MP_IDLE_ANGRY,
[ "scared" ] = ACT_HL2MP_IDLE_SCARED,
[ "zombie" ] = ACT_HL2MP_IDLE_ZOMBIE,
[ "cower" ] = ACT_HL2MP_IDLE_COWER,
}
--[[---------------------------------------------------------
Name: SetWeaponHoldType
Desc: Sets up the translation table, to translate from normal
standing idle pose, to holding weapon pose.
-----------------------------------------------------------]]
function SWEP:SetWeaponHoldType( t )
t = string.lower( t )
local index = ActIndex[ t ]
if ( index == nil ) then
Msg( "SWEP:SetWeaponHoldType - ActIndex[ \"" .. t .. "\" ] isn't set! (defaulting to normal)\n" )
t = "normal"
index = ActIndex[ t ]
end
self.ActivityTranslate = {}
self.ActivityTranslate[ ACT_MP_STAND_IDLE ] = index
self.ActivityTranslate[ ACT_MP_WALK ] = index + 1
self.ActivityTranslate[ ACT_MP_RUN ] = index + 2
self.ActivityTranslate[ ACT_MP_CROUCH_IDLE ] = index + 3
self.ActivityTranslate[ ACT_MP_CROUCHWALK ] = index + 4
self.ActivityTranslate[ ACT_MP_ATTACK_STAND_PRIMARYFIRE ] = index + 5
self.ActivityTranslate[ ACT_MP_ATTACK_CROUCH_PRIMARYFIRE ] = index + 5
self.ActivityTranslate[ ACT_MP_RELOAD_STAND ] = index + 6
self.ActivityTranslate[ ACT_MP_RELOAD_CROUCH ] = index + 6
self.ActivityTranslate[ ACT_MP_JUMP ] = index + 7
self.ActivityTranslate[ ACT_RANGE_ATTACK1 ] = index + 8
self.ActivityTranslate[ ACT_MP_SWIM ] = index + 9
-- "normal" jump animation doesn't exist
if ( t == "normal" ) then
self.ActivityTranslate[ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM
end
if ( t == "suitcase" ) then
self.ActivityTranslate[ ACT_MP_STAND_IDLE ] = ACT_HL2MP_IDLE_SUITCASE
self.ActivityTranslate[ ACT_MP_WALK ] = ACT_HL2MP_WALK_SUITCASE
self.ActivityTranslate[ ACT_MP_JUMP ] = ACT_HL2MP_JUMP_SLAM
end
if ( t == "passive" ) then
self.ActivityTranslate[ ACT_MP_CROUCH_IDLE ] = ACT_HL2MP_IDLE_CROUCH_SLAM
self.ActivityTranslate[ ACT_MP_CROUCHWALK ] = ACT_HL2MP_WALK_CROUCH_SLAM
end
if ( t == "rpg" ) then
self.ActivityTranslate[ ACT_MP_CROUCH_IDLE ] = ACT_HL2MP_IDLE_CROUCH_AR2
self.ActivityTranslate[ ACT_MP_CROUCHWALK ] = ACT_HL2MP_WALK_CROUCH_AR2
end
--self:SetupWeaponHoldTypeForAI( t )
end
-- Default hold pos is the pistol
SWEP:SetWeaponHoldType( "pistol" )
--[[---------------------------------------------------------
Name: weapon:TranslateActivity()
Desc: Translate a player's Activity into a weapon's activity
So for example, ACT_HL2MP_RUN becomes ACT_HL2MP_RUN_PISTOL
Depending on how you want the player to be holding the weapon
-----------------------------------------------------------]]
function SWEP:TranslateActivity( act )
if ( self.Owner:IsNPC() ) then
if ( self.ActivityTranslateAI[ act ] ) then
return self.ActivityTranslateAI[ act ]
end
return -1
end
if ( self.ActivityTranslate[ act ] != nil ) then
return self.ActivityTranslate[ act ]
end
return -1
end
end
SWEP.GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN, 0.85 }
SWEP.GestureReload = { ACT_FLINCH_STOMACH, 0.3 }
SWEP.GestureDraw = { ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND, 0.75 }
SWEP.GestureHolster = { ACT_GMOD_GESTURE_MELEE_SHOVE_1HAND, 0.65 }
function SWEP:TPFire( hand )
if CLIENT and !IsFirstTimePredicted() then return end
local target = self:bWepClass( hand ) and self:bWepClass( hand ).GestureFire
if !target then
target = self.GestureFire
end
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
end
function SWEP:TPCustom( tg1, tg2 )
if CLIENT and !IsFirstTimePredicted() then return end
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(tg1), tg2, true )
end
function SWEP:TPReload( hand )
if CLIENT and !IsFirstTimePredicted() then return end
local target = self:bWepClass( hand ) and self:bWepClass( hand ).GestureReload
if !target then
target = self.GestureReload
end
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
end
function SWEP:TPDraw( hand )
if CLIENT and !IsFirstTimePredicted() then return end
local target = self:bWepClass( hand ) and self:bWepClass( hand ).GestureDraw
if !target then
target = self.GestureDraw
end
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
end
function SWEP:TPHolster( hand )
if CLIENT and !IsFirstTimePredicted() then return end
local target = self:bWepClass( hand ) and self:bWepClass( hand ).GestureHolster
if !target then
target = self.GestureHolster
end
self:GetOwner():AddVCDSequenceToGestureSlot( GESTURE_SLOT_GRENADE, self:GetOwner():SelectWeightedSequence(target[1]), target[2], true )
end

View File

@ -0,0 +1,97 @@
function SWEP:GetStat( hand, stat )
local Hand = ((hand==true and "Left Hand") or (hand==false and "Right Hand"))
assert( self:bWepClass( hand ), "No weapon in " .. Hand .. " (Trying to get stat " .. stat .. ")" )
local thereturn = (self:bWepClass( hand ) and self:bWepClass( hand )[stat])
assert( thereturn, "No stat for " .. stat .. " ( " .. Hand .. " )" )
return thereturn
end
function BENNY_GetStat( class, stat )
assert( class, "No class" )
local thereturn = class[stat]
assert( thereturn, "No stat for " .. stat )
return thereturn
end
function SWEP:hFlipHand( hand )
hand = hand or false
local p = self:GetOwner()
local lt = self:bWepClass( true )
local flip = false
if lt then
if lt.Features == "firearm" then
flip = p:GetInfoNum( "benny_wep_ao_firearms", 1 )==1
elseif lt.Features == "grenade" then
flip = p:GetInfoNum( "benny_wep_ao_grenades", 0 )==1
else
flip = p:GetInfoNum( "benny_wep_ao_junk", 0 )==1
end
else
--return false
end
return ((flip and !hand) or (!flip and hand))
end
function SWEP:C_AttackDown( hand )
if self:hFlipHand() then hand = !hand end
return (hand == true) and self:GetOwner():KeyDown( IN_ATTACK2 ) or (hand == false) and self:GetOwner():KeyDown( IN_ATTACK )
end
function SWEP:BDeploy( hand, id )
assert( isbool(hand), "You forgot the hand." )
assert( isstring(id), "You forgot the ID." )
if self:bGetInvID( hand ) == id then
-- This breaks prediction somewhat!!
-- return -- PROTO: If you're in the middle of holstering, cancel it
elseif self:bGetInvID( hand ) != "" then
return--self:BHolster( hand )
end
local p = self:GetOwner()
local inv = p:INV_Get()
local item = inv[id]
local class = WeaponGet(item.Class)
assert( item, "That item doesn't exist. " .. tostring(item) )
self:bSetInvID( hand, id )
self:bSetMagInvID( hand, "" )
self:bSetIntClip( hand, 0 )
self:bSetSpread( hand, 0 )
self:bSetIntDelay( hand, CurTime() + 0.35 )
B_Sound( self, "Common.Deploy" )
if item.Loaded and item.Loaded != "" then
local mid = item.Loaded
local midi = inv[ mid ]
if !midi then
item.Loaded = ""
error( "Deploy: Magazine doesn't exist in the inventory!! " .. tostring(mid) .. " item.Loaded removed." )
end
self:bSetMagInvID( hand, mid )
self:bSetIntClip( hand, midi.Ammo )
end
end
function SWEP:BHolster( hand )
if self:bGetInvID( hand ) == "" then
return -- What the hell are you holstering..?
end
local p = self:GetOwner()
--B_Sound( self, "Common.Holster" )
local item = self:bWepTable( hand )
if item then
local class = WeaponGet(item.Class)
if class.Custom_Holster then class.Custom_Holster( self, item, class, hand ) end
end
self:bSetInvID( hand, "" )
self:bSetMagInvID( hand, "" )
self:bSetIntClip( hand, 0 )
end
function SWEP:BSpread( hand )
return self:bWepClass( hand ).Spread + self:bGetSpread( hand )
end

View File

@ -0,0 +1,135 @@
-- Reload logic
function SWEP:Reload( hand )
if hand == nil then return end -- Needs to be called from the custom ones
local p = self:GetOwner()
local inv = p:INV_Get()
local wep_table = self:bWepTable( hand )
local wep_class = self:bWepClass( hand )
if wep_table then
if self:bWepClass( hand ) and self:bWepClass( hand ).Func_Reload then
if self:bWepClass( hand ).Func_Reload( self, hand ) then return end
end
if wep_class.Custom_Reload then
if wep_class.Custom_Reload( self, wep_table ) then return end
end
if self:bGetIntDelay( hand ) > CurTime() then
return false
end
local rt = self:bGetReloadTime( hand )
if rt > 0 then
local rtt = self:bGetReloadType( hand )
-- TODO: Unshitify this.
if rtt == 1 then
if (rt+self:GetStat( hand, "Reload_MagIn_Bonus1" )) <= RealTime() and RealTime() <= (rt+self:GetStat( hand, "Reload_MagIn_Bonus2" )) then
self:bSetReloadTime( hand, 0 )
return true
else
B_Sound( self, "Common.ReloadFail" )
self:bSetReloadTime( hand, RealTime() )
return false
end
else
return false
end
end
local curmag = self:bGetMagInvID( hand )
if curmag != "" then
self:bSetReloadTime( hand, RealTime() )
self:bSetReloadType( hand, 2 )
B_Sound( self, wep_class.Sound_MagOut )
self:Reload_MagOut( hand, self:bGetMagInvID( hand ), inv )
elseif self:GetBestLoadableMagazine( hand, wep_table.Class, inv, wep_table ) then
self:bSetReloadTime( hand, RealTime() )
self:bSetReloadType( hand, 1 )
B_Sound( self, wep_class.Sound_MagIn )
else
B_Sound( self, "Common.NoAmmo" )
end
self:TPReload( hand )
end
return true
end
function SWEP:Reload_MagOut( hand, curmag, optinv, optwep_table, optwep_class )
local p = self:GetOwner()
local inv = optinv or p:INV_Get()
local wep_table = optwep_table or self:bWepTable( hand )
local wep_class = optwep_class or self:bWepClass( hand )
if !inv[curmag] then
-- PROTO: This happens sometimes. I'm commenting it so it doesn't look like anything broke, because it didn't.
-- ErrorNoHalt( "Mag isn't a valid item" )
self:bSetMagInvID( hand, "" )
wep_table.Loaded = ""
elseif inv[curmag].Ammo == 0 then
if SERVER or (CLIENT and IsFirstTimePredicted()) then
p:INV_Discard( curmag )
end
end
self:bSetMagInvID( hand, "" )
self:bSetIntClip( hand, 0 )
--B_Sound( self, wep_class.Sound_MagOut )
wep_table.Loaded = ""
end
function SWEP:GetLoadableMagazines( hand, class, optinv, optwep_table )
local p = self:GetOwner()
local inv = optinv or p:INV_Get()
local wep_table = optwep_table or self:bWepTable( hand )
local maglist = p:INV_FindMag( wep_table.Class )
local usedlist = {}
for _id, mrow in pairs( inv ) do
if mrow.Loaded and mrow.Loaded != "" then
usedlist[mrow.Loaded] = true
end
end
return maglist
end
function SWEP:GetBestLoadableMagazine( hand, class, optinv, optwep_table )
local p = self:GetOwner()
local inv = optinv or p:INV_Get()
local wep_table = optwep_table or self:bWepTable( hand )
local maglist = p:INV_FindMag( wep_table.Class )
local mag = false
local usedlist = {}
for _id, mrow in pairs( inv ) do
if mrow.Loaded and mrow.Loaded != "" then
usedlist[mrow.Loaded] = true
end
end
for num, mid in ipairs( maglist ) do
if usedlist[mid] then
else
mag = mid
break
end
end
return mag
end
function SWEP:Reload_MagIn( hand, curmag, optinv, optwep_table, optwep_class )
local p = self:GetOwner()
local inv = optinv or p:INV_Get()
local wep_table = optwep_table or self:bWepTable( hand )
local wep_class = optwep_class or self:bWepClass( hand )
local mag = self:GetBestLoadableMagazine( hand, wep_table.Class )
if mag then
self:bSetMagInvID( hand, mag )
self:bSetIntClip( hand, inv[mag].Ammo )
wep_table.Loaded = mag
B_Sound( self, wep_class.Sound_Cock )
else
B_Sound( self, "Common.NoAmmo" )
end
end

View File

@ -0,0 +1,156 @@
-- Stat2
function SWEP:bWepTable( alt )
return self:GetOwner():INV_Get()[ ((alt==true) and self:GetWep2()) or ((alt==false) and self:GetWep1()) ]
end
function SWEP:bWepClass( alt )
local ta = self:bWepTable( alt )
if ta then
return WeaponGet( ta.Class )
else
return false
end
end
function SWEP:bMagTable( alt )
return self:GetOwner():INV_Get()[ ((alt==true) and self:GetWep2_Clip()) or ((alt==false) and self:GetWep1_Clip()) ]
end
function SWEP:bMagClass( alt )
local ta = self:bMagTable( alt )
if ta then
return WeaponGet( ta.Class )
else
return false
end
end
-- Weapon ID
function SWEP:bGetInvID( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2() or (hand == false) and self:GetWep1()
end
function SWEP:bSetInvID( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2( value ) or (hand == false) and self:SetWep1( value )
end
-- Wep. Clip ID
function SWEP:bGetMagInvID( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_Clip() or (hand == false) and self:GetWep1_Clip()
end
function SWEP:bSetMagInvID( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_Clip( value ) or (hand == false) and self:SetWep1_Clip( value )
end
-- Weapon Firemode
function SWEP:bGetFiremode( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_Firemode() or (hand == false) and self:GetWep1_Firemode()
end
function SWEP:bSetFiremode( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_Firemode( value ) or (hand == false) and self:SetWep1_Firemode( value )
end
-- Weapon Burst
function SWEP:bGetBurst( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_Burst() or (hand == false) and self:GetWep1_Burst()
end
function SWEP:bSetBurst( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_Burst( value ) or (hand == false) and self:SetWep1_Burst( value )
end
-- Weapon Spread
function SWEP:bGetSpread( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_Spread() or (hand == false) and self:GetWep1_Spread()
end
function SWEP:bSetSpread( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_Spread( value ) or (hand == false) and self:SetWep1_Spread( value )
end
-- Weapon Spread
function SWEP:bGetShotTime( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_ShotTime() or (hand == false) and self:GetWep1_ShotTime()
end
function SWEP:bSetShotTime( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_ShotTime( value ) or (hand == false) and self:SetWep1_ShotTime( value )
end
-- Weapon Holstering Time
function SWEP:bGetHolsterTime( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_Holstering() or (hand == false) and self:GetWep1_Holstering()
end
function SWEP:bSetHolsterTime( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_Holstering( value ) or (hand == false) and self:SetWep1_Holstering( value )
end
-- Weapon Reloading Time
function SWEP:bGetReloadTime( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_Reloading() or (hand == false) and self:GetWep1_Reloading()
end
function SWEP:bSetReloadTime( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_Reloading( value ) or (hand == false) and self:SetWep1_Reloading( value )
end
-- Weapon Reload Type
function SWEP:bGetReloadType( hand )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:GetWep2_ReloadType() or (hand == false) and self:GetWep1_ReloadType()
end
function SWEP:bSetReloadType( hand, value )
assert( hand!=nil, "Missing hand argument" )
return (hand == true) and self:SetWep2_ReloadType( value ) or (hand == false) and self:SetWep1_ReloadType( value )
end
-- Weapon Player Requesting ID
function SWEP:bGetReqInvID( hand )
local p = self:GetOwner()
return (hand == true) and p:GetReqID2() or (hand == false) and p:GetReqID1()
end
function SWEP:bSetReqInvID( hand, value )
local p = self:GetOwner()
return (hand == true) and p:SetReqID2( value ) or (hand == false) and p:SetReqID1( value )
end
-- Internal SWEP Delay
function SWEP:bGetIntDelay( hand )
return (hand == true) and self:GetDelay2() or (hand == false) and self:GetDelay1()
end
function SWEP:bSetIntDelay( hand, value )
return (hand == true) and self:SetDelay2( value ) or (hand == false) and self:SetDelay1( value )
end
-- Internal SWEP Clip
function SWEP:bGetIntClip( hand )
return (hand == true) and self:Clip2() or (hand == false) and self:Clip1()
end
function SWEP:bSetIntClip( hand, value )
return (hand == true) and self:SetClip2( value ) or (hand == false) and self:SetClip1( value )
end

View File

@ -0,0 +1,34 @@
if SERVER then
util.AddNetworkString( "Benny_StatRegen" )
function SWEP:BSend( ... )
net.Start( "Benny_StatRegen" )
net.WriteUInt( #{ ... }, 4 )
for i, v in ipairs( { ... } ) do
net.WriteString( v[1] )
net.WriteBool( v[2] )
if v[2] then
net.WriteString( v[3] )
else
net.WriteDouble( v[3] )
end
end
net.Send( self:GetOwner() )
end
else
net.Receive( "Benny_StatRegen", function( len, ply )
local count = net.ReadUInt( 4 )
for i=1, count do
local stat = net.ReadString()
local str = net.ReadBool()
local data
if str then
data = net.ReadString()
else
data = net.ReadDouble()
end
LocalPlayer():GetActiveWeapon():bWepTable()[stat] = data
end
end)
end

View File

@ -0,0 +1,311 @@
-- The benny weapon handles the weapon pickups you find throughout the game.
SWEP.Base = "weapon_base"
SWEP.PrintName = "Benny Weapon Handler"
SWEP.ViewModel = "models/weapons/c_pistol.mdl"
SWEP.ViewModelFOV = 10
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.Primary.ClipSize = 0
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = true
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = true
SWEP.Secondary.Ammo = "none"
AddCSLuaFile( "sh_statregen.lua" )
include ( "sh_statregen.lua" )
AddCSLuaFile( "sh_firing.lua" )
include ( "sh_firing.lua" )
AddCSLuaFile( "sh_inv.lua" )
include ( "sh_inv.lua" )
AddCSLuaFile( "sh_stat2.lua" )
include ( "sh_stat2.lua" )
AddCSLuaFile( "sh_holdtypes.lua" )
include ( "sh_holdtypes.lua" )
AddCSLuaFile( "sh_reload.lua" )
include ( "sh_reload.lua" )
AddCSLuaFile( "sh_drop.lua" )
include ( "sh_drop.lua" )
AddCSLuaFile( "cl_wm.lua" )
if CLIENT then
include ( "cl_wm.lua" )
end
function SWEP:SetupDataTables()
self:NetworkVar( "Float", 0, "Aim" )
self:NetworkVar( "Float", 1, "Delay1" )
self:NetworkVar( "Float", 2, "Delay2" )
self:NetworkVar( "Float", 3, "GrenadeDownStart" )
self:NetworkVar( "Float", 4, "Wep1_Spread" )
self:NetworkVar( "Float", 5, "Wep2_Spread" )
self:NetworkVar( "Float", 6, "Wep1_ShotTime" )
self:NetworkVar( "Float", 7, "Wep2_ShotTime" )
self:NetworkVar( "Float", 8, "Wep1_Holstering" )
self:NetworkVar( "Float", 9, "Wep2_Holstering" )
self:NetworkVar( "Float", 10, "Wep1_Reloading" )
self:NetworkVar( "Float", 11, "Wep2_Reloading" )
self:NetworkVar( "Float", 12, "JustThrew" )
self:NetworkVar( "String", 0, "Wep1" )
self:NetworkVar( "String", 1, "Wep2" )
self:NetworkVar( "String", 2, "Wep1_Clip" )
self:NetworkVar( "String", 3, "Wep2_Clip" )
self:NetworkVar( "Int", 0, "Wep1_Burst" )
self:NetworkVar( "Int", 1, "Wep2_Burst" )
self:NetworkVar( "Int", 2, "Wep1_Firemode" )
self:NetworkVar( "Int", 3, "Wep2_Firemode" )
self:NetworkVar( "Int", 4, "Wep1_ReloadType" )
self:NetworkVar( "Int", 5, "Wep2_ReloadType" )
self:NetworkVar( "Bool", 0, "UserAim" )
self:NetworkVar( "Bool", 1, "GrenadeDown" )
self:NetworkVar( "Bool", 2, "JustThrewHand" )
self:SetWep1_Firemode( 1 )
self:SetWep2_Firemode( 1 )
self:SetWep1_Holstering( -1 )
self:SetWep2_Holstering( -1 )
self:SetWep1_Reloading( -1 )
self:SetWep2_Reloading( -1 )
end
function SWEP:B_Ammo( hand, value )
local p = self:GetOwner()
local inv = p:INV_Get()
self:bSetIntClip( hand, value )
assert( self:bGetMagInvID( hand ) != "", "There is no magazine loaded!" )
inv[ self:bGetMagInvID( hand ) ].Ammo = value
end
function SWEP:B_Firemode( alt )
return self:bWepClass( alt ).Firemodes[ self:bGetFiremode( alt ) ]
end
function SWEP:B_FiremodeName( alt )
local mode = self:B_Firemode( alt ).Mode
if mode == 1 then
return "SEMI"
elseif mode == math.huge then
return "AUTO"
else
return mode .. "RND"
end
end
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_TempForAim", function( ply, button )
local wep = ply:BennyCheck()
if wep then
if button == KEY_F then
if tobool(ply:GetInfoNum("benny_wep_toggleaim", 1)) then
wep:SetUserAim( !wep:GetUserAim() )
else
wep:SetUserAim( true )
end
end
if button == ply:GetInfoNum("benny_bind_reload", KEY_R) then
wep:Reload( wep:hFlipHand( false ) )
end
if button == ply:GetInfoNum("benny_bind_reloada", KEY_T) then
wep:Reload( wep:hFlipHand( true ) )
end
if button == ply:GetInfoNum("benny_bind_drop", KEY_G) then
wep:Drop( wep:hFlipHand( false ) )
end
if button == ply:GetInfoNum("benny_bind_dropa", KEY_H) then
wep:Drop( wep:hFlipHand( true ) )
end
end
end)
hook.Add( "PlayerButtonUp", "Benny_PlayerButtonUp_TempForAim", function( ply, button )
local wep = ply:BennyCheck()
if wep then
if button == KEY_F then
if !tobool(ply:GetInfoNum("benny_wep_toggleaim", 0)) then
wep:SetUserAim( false )
end
end
end
end)
function SWEP:BStartHolster( hand )
if self:bGetHolsterTime( hand ) == -1 then
B_Sound( self, "Common.Holster" )
-- print( "Holstering the " .. (hand and "LEFT" or "RIGHT") )
self:bSetHolsterTime( hand, 0 )
self:bSetReloadTime( hand, -1 )
self:bSetReloadType( hand, 0 )
end
end
function SWEP:BThinkHolster( hand )
if self:bGetHolsterTime( hand ) >= 0 then
self:bSetHolsterTime( hand, math.Approach( self:bGetHolsterTime( hand ), 1, FrameTime() / 0.35 ) )
end
if self:bGetHolsterTime( hand ) == 1 then
self:bSetHolsterTime( hand, -1 )
self:bSetReloadTime( hand, -1 )
self:bSetReloadType( hand, 0 )
self:BHolster( hand )
local p = self:GetOwner()
local req = self:bGetReqInvID( hand )
local inv = p:INV_Get()
if req != "" and inv[req] then
self:BDeploy( hand, req )
end
end
end
function SWEP:Think()
local p = self:GetOwner()
local inv = p:INV_Get()
local wep1 = self:bWepTable( false )
local wep1c = self:bWepClass( false )
local wep2 = self:bWepTable( true )
local wep2c = self:bWepClass( true )
if self:bGetReqInvID( false ) != "" and self:bGetReqInvID( true ) != "" and self:bGetReqInvID( false ) == self:bGetReqInvID( true ) then
self:bSetReqInvID( false, "" )
self:bSetReqInvID( true, "" )
if CLIENT then chat.AddText( "Same weapons on ReqID, both holstered" ) end
end
for i=1, 2 do
local hand = i==2
if self:bGetReqInvID( hand ) != "" and !inv[self:bGetReqInvID( hand )] then
self:bSetReqInvID( hand, "" )
end
local req = self:bGetReqInvID( hand )
local req_o = self:bGetReqInvID( !hand )
local curr = self:bGetInvID( hand )
local curr_o = self:bGetInvID( !hand )
if req != curr then
-- Don't allow holstering from this weapon if...
-- Just know, this feels bad.
if self:bGetReloadTime( hand ) > 0 then
-- hold
elseif self:GetJustThrew() > CurTime() then
-- hold
elseif self:bWepClass( hand ) and self:bGetShotTime( hand ) + self:GetStat( hand, "ShootHolsterTime" ) > CurTime() then
-- hold
else
if curr != "" then
-- require holster first
self:BStartHolster( hand )
else
local otherhasthis = curr_o == req
if req != "" then
if otherhasthis then
self:BStartHolster( !hand )
else
self:BDeploy( hand, req )
end
else
self:BStartHolster( hand )
end
end
end
end
self:BThinkHolster( hand )
if self:GetJustThrew() != 0 and self:GetJustThrew() <= CurTime() then
if SERVER then
InvDiscard( p, self:bGetInvID( self:GetJustThrewHand() ) )
end
self:SetJustThrew( 0 )
end
do -- Reload logic
if self:bGetReloadTime( hand ) != -1 then
local rlt = self:bGetReloadType( hand )
-- TODO: Unshitify this.
if RealTime() >= self:bGetReloadTime( hand ) + (rlt == 1 and self:GetStat( hand, "Reload_MagIn" ) or rlt == 2 and self:GetStat( hand, "Reload_MagOut" )) then
if rlt == 1 then
if SERVER or (CLIENT and IsFirstTimePredicted() ) then
self:Reload_MagIn( hand, self:bGetMagInvID( hand ), inv )
end
elseif rlt == 2 then
end
self:bSetReloadTime( hand, -1 )
self:bSetReloadType( hand, 0 )
-- Do reload stuff.
end
end
end
end
self:SetAim( math.Approach( self:GetAim(), self:GetUserAim() and 1 or 0, FrameTime()/0.2 ) )
for i=1, 2 do
local hand = i==2
if !self:C_AttackDown( hand ) then
self:bSetBurst( hand, 0 )
end
end
for i=1, 2 do
local hand = i==2
local wep, wepc = self:bWepTable( hand ), self:bWepClass( hand )
if wepc and wepc.Features == "firearm" and self:bGetIntDelay( hand ) < CurTime()-0.01 then
local mweh = math.Remap( CurTime(), self:bGetShotTime( hand ), self:bGetShotTime( hand ) + self:GetStat( hand, "SpreadDecay_RampTime" ), 0, 1 )
mweh = math.Clamp( mweh, 0, 1 )
local decayfinal = Lerp( math.ease.InExpo( mweh ), self:GetStat( hand, "SpreadDecay_Start" ), self:GetStat( hand, "SpreadDecay_End" ) )
self:bSetSpread( hand, math.Approach( self:bGetSpread( hand ), 0, decayfinal * FrameTime() ) )
end
end
local ht = "normal"
if self:bWepClass( false ) and self:bGetHolsterTime( false ) < 0 then
ht = "passive"
if self:GetUserAim() then
if self:GetJustThrew() != 0 then
ht = "melee"
elseif self:bWepClass( true ) then
ht = "duel"
else
ht = self:GetStat( false, "HoldType" )
end
end
end
if ht == "normal" and self:GetHoldType() != "normal" then
self:TPHolster( false )
elseif ht != "normal" and self:GetHoldType() == "normal" then
self:TPDraw( false )
end
for i=1, 2 do
local hand = i==2
if self:bWepClass( hand ) then
if self:bWepClass( hand ).Custom_Think then
self:bWepClass( hand ).Custom_Think( self, self:bWepTable( hand ), self:bWepClass( hand ), hand )
end
end
end
self:SetWeaponHoldType(ht)
self:SetHoldType(ht)
return true
end
function SWEP:Deploy()
return true
end
function SWEP:Holster()
return true
end

View File

@ -1,266 +0,0 @@
AddCSLuaFile()
SWEP.Base = "weapon_base"
SWEP.BennyItemHandler = true
SWEP.ViewModel = "models/weapons/c_pistol.mdl"
SWEP.ViewModelFOV = 74
SWEP.ViewModelFlip = false
SWEP.UseHands = true
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
SWEP.DrawWorldModel = true
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Ammo = "none"
SWEP.Primary.Automatic = true
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Ammo = "none"
SWEP.Secondary.Automatic = true
function SWEP:SetupDataTables()
self:NetworkVar( "Entity", "ActiveR" )
self:NetworkVar( "Entity", "ActiveL" )
self:NetworkVar( "Entity", "DesireR" )
self:NetworkVar( "Entity", "DesireL" )
end
function SWEP:ItemR( run )
local active = self:GetActiveR()
if run and active:IsValid() then
return active.Class[run]( active.Class, active, self )
else
return active:IsValid() and active or false
end
end
function SWEP:ItemL( run )
local active = self:GetActiveL()
if run and active:IsValid() then
active.Class[run]( active.Class, active, self )
else
return active:IsValid() and active or false
end
end
function SWEP:Initialize()
end
local size = 8/2
local tracedef = {
mins = Vector( -size, -size, -size ),
maxs = Vector( size, size, size ),
}
function SWEP:ItemCheckTrace()
local p = self:GetOwner()
p:LagCompensation( true )
tracedef.filter = p
tracedef.start = p:EyePos()
tracedef.endpos = p:EyePos() + (p:GetAimVector() * 90)
local trace = util.TraceHull(tracedef)
--print(trace.StartPos:Distance(trace.HitPos))
p:LagCompensation( false )
return trace
end
function SWEP:SetActive( ent )
local p = self:GetOwner()
if ent:GetOwner() != p then return false end
--if self:GetActiveR():IsValid() then self:Deactive() end
self:SetActiveR( ent )
if self:ItemR() then
self:ItemR( "Deploy" )
self:ItemR():SetNoDraw( false )
end
return true
end
function SWEP:Deactive()
end
function SWEP:PrimaryAttack()
local p = self:GetOwner()
if self:ItemR() then
self:ItemR("Attack")
end
end
function SWEP:Reload()
if self:ItemR() then
self:ItemR("Reload")
end
end
function SWEP:SecondaryAttack()
local p = self:GetOwner()
if self:ItemR() then
self:ItemR("AttackAlt")
end
end
if SERVER then
util.AddNetworkString("AEINV_PredictItem")
else
net.Receive("AEINV_PredictItem", function()
local ent = net.ReadEntity()
if ent:IsValid() then
ent:SetPredictable( net.ReadBool() )
print("[prediction] cl prediction start:", ent)
else
print("[prediction] cl tried to predict invalid ent")
end
end)
end
function SWEP:EquipItem( ent )
local p = self:GetOwner()
if CLIENT then print("FUCK OFF") debug.Trace() return end
if IsValid(ent) and ent.BennyItem then
if ent:GetOwner() != NULL then
print( "[equip]", ent, "belongs to", ent:GetOwner(), "not equipping" )
return
elseif p:GetInventory()[ent] then
print( "[equip]", ent, "already belongs to", p )
return
end
print("[equip]", ent)
self:SetDesireR( ent )
ent:AddEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:AddEffects( EF_BONEMERGE )
ent:PhysicsInit( SOLID_NONE )
ent:SetMoveType( MOVETYPE_NONE )
ent:SetNoDraw( true )
ent:SetParent( p )
ent:SetOwner( p )
ent:SetLocalPos( vector_origin )
ent:SetLocalAngles( angle_zero )
ent:SetAcquisition( CurTime() )
ent:EmitSound( "ae/items/pickup.ogg", 70, 100, 1, CHAN_STATIC )
--self:SetActive( ent )
local inv = p:GetInventory()
inv[ent] = true
inv:Sync()
net.Start("AEINV_PredictItem")
net.WriteEntity( ent )
net.WriteBool( true )
net.Send( p )
end
end
function SWEP:DropItem()
local p = self:GetOwner()
local ent = self:GetActiveR()
if ent:IsValid() then
if CLIENT then print("[drop] DropItem called on cl not allowed") return end
self:SetDesireR( NULL )
ent:SetParent( NULL )
ent:SetOwner( NULL )
ent:RemoveEFlags( EFL_KEEP_ON_RECREATE_ENTITIES )
ent:RemoveEffects( EF_BONEMERGE )
ent:PhysicsInit( SOLID_VPHYSICS )
ent:SetMoveType( MOVETYPE_VPHYSICS )
ent:SetCollisionGroup( COLLISION_GROUP_PROJECTILE )
ent:SetNoDraw( false )
ent:SetPos( p:EyePos() + p:GetAimVector() * 0 )
ent:SetAngles( p:EyeAngles() + Angle( 0, 180, 0 ) )
local inv = p:GetInventory()
inv[ent] = nil
inv:Sync()
local ep = ent:GetPhysicsObject()
ep:SetVelocity( p:GetAimVector() * 800 )
ep:SetAngleVelocity( Vector( 0, -360*3, 0 ) )
ep:Wake()
--net.Start("AEINV_PredictItem")
-- net.WriteEntity( ent )
-- net.WriteBool( false )
--net.Send( p )
end
end
function SWEP:Think()
local p = self:GetOwner()
if p:IsValid() then
local DesireR = self:GetDesireR()
local ActiveR = self:GetActiveR()
local DesireR_Valid = DesireR:IsValid()
local ActiveR_Valid = ActiveR:IsValid()
if DesireR != ActiveR then
if ActiveR_Valid then
if ActiveR:GetHolsterIn() == 0 then
ActiveR.Class.Holster( ActiveR.Class, ActiveR, self )
else
-- Waiting for holster to finish
end
else
if DesireR_Valid then
self:SetActive( DesireR )
end
end
else
if ActiveR_Valid and ActiveR:GetHolsterIn() != 0 then
ActiveR.Class.UndoHolster( ActiveR.Class, ActiveR, self )
end
end
if p:KeyPressed(IN_WEAPON1) then
if self:GetDesireR() == NULL then
if SERVER then
local trace = self:ItemCheckTrace()
self:EquipItem( trace.Entity )
end
else
if self:GetActiveR() != NULL then
ActiveR.Class.Drop( ActiveR.Class, ActiveR, self )
if SERVER then
self:DropItem()
end
self:SetActiveR( NULL )
end
end
end
if p:KeyPressed(IN_WEAPON2) then
end
if p:KeyPressed(IN_ALT1) then
end
if p:KeyPressed(IN_ALT2) then
end
if p:KeyPressed(IN_GRENADE1) then
if self:ItemR() and self:ItemR().Class.Alt then
self:ItemR("Alt")
end
end
if p:KeyPressed(IN_GRENADE2) then
end
if self:ItemR() then
self:ItemR("Think")
end
else
print( self, "Thinking without an owner." )
end
end
function SWEP:Deploy()
end
function SWEP:Holster( ent )
return false
end

View File

@ -1,215 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
BENNY.AddConvar( "cam_f", -75 )
BENNY.AddConvar( "cam_r", 12 )
BENNY.AddConvar( "cam_u", 12 )
BENNY.AddConvar( "cam_fov", 75 )
BENNY.AddConvar( "cam_fp", 0 )
BENNY.AddConvar( "cam_fp_fov", 75 )
local lastfp
local m = 3
local m2 = Vector( m, m, m )
local m1 = m2:GetNegated()
TPSOverride = TPSOverride or Angle( 0, 0, 0 )
function CamSpot( ang, pos )
if !ang then ang = TPSOverride end
if !pos then pos = LocalPlayer():EyePos() end
local f, r, u = TPSOverride:Forward(), TPSOverride:Right(), TPSOverride:Up()
local tr = {
start = pos,
endpos = pos + (f*c_cam_f:GetFloat()) + (r*c_cam_r:GetFloat()) + (u*c_cam_u:GetFloat()),
filter = LocalPlayer(), -- ply,
mins = m1,
maxs = m2,
}
if c_cam_fp:GetBool() then
tr.endpos = LocalPlayer():EyePos()
end
tr = util.TraceHull(tr)
return tr.HitPos
end
function Convert( fovDegrees, ratio )
local halfAngleRadians = fovDegrees * ( 0.5 * math.pi / 180 )
local t = math.tan( halfAngleRadians )
t = t * ratio
local retDegrees = ( 180 / math.pi ) * math.atan( t )
return retDegrees * 2
end
function QConvert( fovDegrees )
return Convert( fovDegrees, (3/4)/(ScrH()/ScrW()) )
end
function GM:PreDrawViewModels()
local fp = c_cam_fp:GetBool()
if fp then
cam.Start3D( nil, nil, QConvert( c_cam_fp_fov:GetFloat() ) )
cam.IgnoreZ( true )
local p = LocalPlayer()
p.IWantDraw = true
p:DrawModel()
local w = p:HandlerCheck()
if w:GetActiveR():IsValid() then
w:GetActiveR():DrawModel()
end
p.IWantDraw = false
cam.IgnoreZ( false )
cam.End3D()
end
end
function GM:PrePlayerDraw( ply, flags )
local fp = c_cam_fp:GetBool()
if fp and ply == LocalPlayer() and !ply.IWantDraw then
return true
end
end
function GM:CalcView( ply, pos, ang, fov )
local view = {
origin = CamSpot(TPSOverride), -- pos includes the smoothstair offset which looks stupid here
angles = TPSOverride,
fov = c_cam_fov:GetFloat(),
drawviewer = true
}
local fp = c_cam_fp:GetBool()
if fp then
ply:SetupBones()
local bm = ply:GetBoneMatrix(ply:LookupBone("DEF-spine.003"))
view.origin = bm:GetTranslation()
view.origin:Add( vector_up*10 )
if ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun") then
local progress = ply:GetLayerCycle( GESTURE_SLOT_JUMP )
progress = math.TimeFraction( 0.15, 0.7, progress )
progress = math.Clamp( progress, 0, 1 )
progress = math.ease.OutCirc( progress )
local Dir = ply:GetVelocity()
Dir.z = 0
Dir:Normalize()
Dir:Rotate( Angle( 0, view.angles.y, 0 ) )
Dir:Negate()
local Addition = Angle( (progress*360), 0, 0 )
local new = Angle( view.angles )
new:Add( Addition )
view.angles = new
end
local special = math.Remap( ang.p, 0, 79, 0, 1 )
special = math.Clamp(special, 0, 1 )
special = math.ease.InCubic( special )
local special2 = math.Remap( ang.p, -79, 0, 0, 1 )
special2 = math.Clamp(special2, 0, 1 )
special2 = special2 * (1-special)
view.origin:Sub(ang:Forward()*2)
view.origin:Add(ang:Up()*4*special2)
view.origin:Add(ang:Up()*4*special)
end
if lastfp == nil then lastfp = !fp end
if lastfp and !fp then
local bid = ply:LookupBone("DEF-spine.006")
ply:ManipulateBoneScale( bid, Vector(1, 1, 1) )
local bid = ply:LookupBone("DEF-spine.005")
ply:ManipulateBoneScale( bid, Vector(1, 1, 1) )
lastfp = fp
-- print("show")
elseif !lastfp and fp then
local bid = ply:LookupBone("DEF-spine.006")
ply:ManipulateBoneScale( bid, vector_origin )
local bid = ply:LookupBone("DEF-spine.005")
ply:ManipulateBoneScale( bid, vector_origin )
lastfp = fp
-- print("hide")
end
return view
end
-- During a full update, bone manipulations will be reset to the server's value. Fix that
gameevent.Listen( "OnRequestFullUpdate" )
hook.Add( "OnRequestFullUpdate", "Benny_OnRequestFullUpdate_CameraFP", function( data )
if CLIENT then
local ply = LocalPlayer()
if !ply:IsValid() then return end
local fp = c_cam_fp:GetBool()
if lastfp == nil then lastfp = !fp end
timer.Simple( 0, function()
if !fp then
local bid = ply:LookupBone("DEF-spine.006")
if !bid then return end
ply:ManipulateBoneScale( bid, Vector(1, 1, 1) )
local bid = ply:LookupBone("DEF-spine.005")
if !bid then return end
ply:ManipulateBoneScale( bid, Vector(1, 1, 1) )
lastfp = fp
-- print("fullupdate: show")
elseif fp then
local bid = ply:LookupBone("DEF-spine.006")
if !bid then return end
ply:ManipulateBoneScale( bid, vector_origin )
local bid = ply:LookupBone("DEF-spine.005")
if !bid then return end
ply:ManipulateBoneScale( bid, vector_origin )
lastfp = fp
-- print("fullupdate: hide")
end
end)
end
end )
hook.Add( "InputMouseApply", "Benny_InputMouseApply", function( cmd, x, y, ang )
local p = LocalPlayer()
local w = p:HandlerCheck()
if w then--and (y!=0 or x!=0) then
if x != 0 then
TPSOverride.y = TPSOverride.y + (-x*0.022)
end
if y != 0 then
TPSOverride.p = math.Clamp( TPSOverride.p + (y*0.022), -80, 80 )
end
return true
end
end)
hook.Add("CreateMove", "Benny_CreateMove_Camera", function( cmd )
local p = LocalPlayer()
if p:GetMoveType() == MOVETYPE_NOCLIP then
cmd:SetViewAngles( TPSOverride )
else
local tr_forward = util.TraceLine( {
start = CamSpot(TPSOverride),
endpos = CamSpot(TPSOverride)+(TPSOverride:Forward()*(2^16)),
filter = p,
mask = MASK_SHOT,
} )
local planner = (tr_forward.HitPos-p:EyePos()):Angle()
planner:Normalize()
cmd:SetViewAngles( planner )
local moveintent = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0 )
local fixang = Angle()
fixang.y = cmd:GetViewAngles().y - TPSOverride.y
moveintent:Rotate( fixang )
cmd:SetForwardMove( moveintent.x )
cmd:SetSideMove( moveintent.y )
end
end)

View File

@ -1,2 +1,4 @@
-- Thing
include( "shared.lua" ) include( "shared.lua" )

View File

@ -1,16 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
function BENNY.AddConvar( name, value, flags, mins, maxs )
local CV = CreateConVar( "b-" .. name, value, flags, l8( "#Convar." .. name .. ".Description" ), mins, maxs )
_G["c_" .. name] = CV
-- print( "Created Convar: " .. name .. " : " .. l8( "#Convar." .. name .. ".Name" ) .. " : " .. l8( "#Convar." .. name .. ".Description" ) )
return CV
end
function BENNY.AddClientConvar( name, value, flags, mins, maxs )
if SERVER then return end
return BENNY.AddConvar( name, value, flags, mins, maxs )
end

View File

@ -1,373 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
if SERVER then
util.AddNetworkString( "Benny_DebugMenuSpawn" )
net.Receive( "Benny_DebugMenuSpawn", function( len, ply )
if !ply:IsAdmin() then return end
local ent = ents.Create( "b-item_" .. net.ReadString() )
ent:Spawn()
local TRACE = ply:GetEyeTrace()
local thespawnpos = TRACE.HitPos
thespawnpos:Add( TRACE.HitNormal * 16 )
local WORLDAA, WORLDBB = ent:GetCollisionBounds()
local tr = util.TraceHull( {
start = thespawnpos,
endpos = thespawnpos - (vector_up*32),
mins = WORLDAA,
maxs = WORLDBB,
collisiongroup = COLLISION_GROUP_WEAPON,
})
thespawnpos:Set( tr.HitPos )
ent:SetPos( thespawnpos )
--[[local WORLDAA, WORLDBB = ent:GetCollisionBounds()
local WORLDC = ent:WorldSpaceCenter()
local TRACE = ply:GetEyeTrace()
local thespawnpos = TRACE.HitPos
thespawnpos:Add( WORLDC/2 )
thespawnpos:Add( ((WORLDBB * TRACE.HitNormal) - (WORLDAA * TRACE.HitNormal)) )
ent:SetPos( thespawnpos )]]
debugoverlay.Box( thespawnpos, WORLDAA, WORLDBB, 4, Color( 255, 255, 255, 0) )
end)
return
end
local function dospawn( self )
net.Start( "Benny_DebugMenuSpawn" )
net.WriteString( self.iName )
net.SendToServer()
DebugMenu:Remove()
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 preferredcategoryorder = { "pistol", "smg", "assaultrifle", "machinegun", "shotgun", "utility" }
local function OpenDebugMenu()
if IsValid(DebugMenu) then DebugMenu:Remove() end
DebugMenu = vgui.Create("DFrame")
DebugMenu:SetSize( 600, 500 )
DebugMenu:Center()
DebugMenu:MakePopup()
DebugMenu:SetKeyboardInputEnabled( false )
DebugMenu:SetSizable(true)
local splitter = DebugMenu:Add("DHorizontalDivider")
splitter:Dock( FILL )
splitter:SetLeftWidth(200)
local opt = DebugMenu:Add("DScrollPanel")
--opt:Dock( FILL )
splitter:SetLeft( opt )
local vsplit = DebugMenu:Add("DVerticalDivider")
splitter:SetRight( vsplit )
vsplit:SetTopHeight( 500/2 )
local texter = DebugMenu:Add("DTextEntry")
texter:SetFont( "HUD_24" )
texter:SetMultiline( true )
vsplit:SetBottom( texter )
local matColor = Material( "models/debug/debugwhite" )
local modeller = DebugMenu:Add("DModelPanel")
do
vsplit:SetTop( modeller )
modeller:SetModel( "models/weapons/w_pistol.mdl" )
modeller:SetFOV( 5 )
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 )
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, 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( idata )
if self.Entity:GetModel() == idata.Model then return end
self.Entity:SetModel( idata.Model )
for i=0, self.Entity:GetNumBodyGroups()-1 do
self.Entity:SetBodygroup( i, 0 )
end
for k, v in ipairs(idata.DefaultBodygroups) do
if v then
self.Entity:SetBodygroup( k-1, v )
end
end
local worked = self.Entity:PhysicsInit( SOLID_VPHYSICS )
if worked then
-- 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.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
-- local vfovRad = 2*math.atan(math.tan(hfovRad/2)*(self:GetTall()/self:GetWide()))
-- local VFOV = math.ceil(vfovRad* 180 / math.pi)
local directionAngCos = math.cos( math.rad(5/2) )
-- scale test
if true then for i=1, 50 do
local S1, S2 = false, false
local aimVector = (self:GetLookAt() - modeller.Finalized):GetNormalized()
do -- test 1, mins
local entVector = mins - modeller.Finalized
local angCos = aimVector:Dot(entVector) / entVector:Length()
S1 = (angCos >= directionAngCos)
end
do -- test 2: maxs
local entVector = maxs - modeller.Finalized
local angCos = aimVector:Dot(entVector) / entVector:Length()
S2 = (angCos >= directionAngCos)
end
if S1 and S2 then
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"
modeller.Finalized:Sub( (aimVector*20) )
end
end end
else
self.indicate = false
self:SetLookAt( vector_origin )
self:SetCamPos( original )
end
self.Failed = !worked
end
local material = Material( "sprites/splodesprite" )
function modeller:Paint1( w, h )
if ( !IsValid( self.Entity ) ) then return end
local x, y = self:LocalToScreen( 0, 0 )
self:LayoutEntity( self.Entity )
local ang = self.aLookAngle
if ( !ang ) then
ang = ( self.vLookatPos - self.vCamPos ):Angle()
end
cam.Start3D( self.vCamPos, ang, self.fFOV, x, y, w, h, 5, self.FarZ )
render.SuppressEngineLighting( true )
render.SetLightingOrigin( vector_origin )
render.ResetModelLighting( self.colAmbientLight.r / 255, self.colAmbientLight.g / 255, self.colAmbientLight.b / 255 )
render.SetColorModulation( self.colColor.r / 255, self.colColor.g / 255, self.colColor.b / 255 )
render.SetBlend( ( self:GetAlpha() / 255 ) * ( self.colColor.a / 255 ) ) -- * surface.GetAlphaMultiplier()
for i = 0, 6 do
local col = self.DirectionalLight[ i ]
if ( col ) then
render.SetModelLighting( i, col.r / 255, col.g / 255, col.b / 255 )
end
end
render.MaterialOverride(matColor)
self:DrawModel()
render.MaterialOverride()
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()
self.LastPaint = RealTime()
end
function modeller:Paint( w, h )
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_16", 4, 4, color_white)
end
end
end
local categories = {}
-- preferred order
for index, category in SortedPairs( preferredcategoryorder ) do
if category == "base" then continue end
if !categories[category] then
local cate = opt:Add("DCollapsibleCategory")
cate:Dock(TOP)
cate:SetLabel(category)
local plist = vgui.Create("DPanelList")
cate:SetContents(plist)
categories[category] = plist
end
end
for iname, idata in SortedPairs( ITEMS ) do
if idata.Category == "base" then continue end
if !categories[idata.Category] then
local cate = opt:Add("DCollapsibleCategory")
cate:Dock(TOP)
cate:SetLabel(idata.Category)
local plist = vgui.Create("DPanelList")
cate:SetContents(plist)
categories[idata.Category] = plist
end
local plist = categories[idata.Category]
local button = plist:Add("DButton")
button:Dock( TOP )
button:DockMargin( 0, 0, 0, 0 )
button:SetText( l8( idata.PrintName ) )
button:SetTall(32)
button.iName = iname
button.iData = idata
button.DoClick = dospawn
function button:Think()
if self:IsHovered() then
texter:SetText( l8(idata.Description) .. "\n\nClipsize: " .. (idata.ClipSize or "?") )
modeller:Update( idata )
end
end
end
local button = DebugMenu:Add("DButton")
button:Dock( BOTTOM )
button:DockMargin( 4, 4, 4, 4 )
button:SetText( "CLOSE" )
button:SetTall( 36 )
button.DoClick = function( self )
DebugMenu:Remove()
end
end
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", "Benny_PlayerButtonDown_DebugMenu", function( ply, button )
if CLIENT and IsFirstTimePredicted() then
if button == KEY_F1 then
OpenDebugMenu()
elseif button == KEY_F2 then
OpenMyTeamMenu()
end
end
end)
local c_id = Color( 255, 200, 200 )
local c_name = Color( 200, 255, 255 )
local c_white = Color( 255, 255, 255 )
local function recursebones( ent, O_id, level )
local gap = ""
for i=1, level do gap = gap .. " " end
for index, id in ipairs( ent:GetChildBones( O_id ) ) do
MsgC( gap, c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) .. "\n" )
recursebones( ent, id, level+1 )
end
end
function printallbones( ent )
if !ent:IsValid() then print("invalid ent") return end
for id=0, ent:GetBoneCount()-1 do
if ent:GetBoneName(id) == "__INVALIDBONE__" then continue end
if ent:GetBoneParent(id) != -1 then continue end
MsgC( c_id, tostring(id), c_white, " - ", c_name, ent:GetBoneName(id) .. "\n" )
recursebones( ent, id, 1 )
end
end
concommand.Add("b-debug_listbones", function( ply, cmd )
printallbones( ply )
end)

View File

@ -1,398 +0,0 @@
BennyGame = BennyGame or {}
BG_GTYPE_CAMPAIGN = 0
BG_GTYPE_MP = 1
BENNY.AddConvar("gametype", 1)
BENNY.AddConvar("gamemode", "dom")
BENNY.AddConvar("g_minplayers", 2)
BENNY.AddConvar("g_pregame", 15)
BENNY.AddConvar("g_postgame", 15)
BENNY.AddConvar("g_intermission", 10)
function BennyGame:GetType()
return c_gametype:GetBool() and BG_GTYPE_MP or BG_GTYPE_CAMPAIGN
end
function BennyGame:GetMode()
return c_gamemode:GetString()
end
function BennyGame:GetModeData()
return BennyGame.Gamemodes[ BennyGame:GetMode() ]
end
BennyGame.TeamsInPlay = {
4,
3,
--2,
--1,
--5,
--6,
}
BennyGame.RTeamID = table.Flip( BennyGame.TeamsInPlay )
BennyGame.TeamCount = #BennyGame.TeamsInPlay
BennyGame.Gamemodes = {
["free"] = {
name = "#Gamemode.free.Name",
description = "#Gamemode.free.Description",
},
["tdm"] = {
name = "#Gamemode.tdm.Name",
description = "#Gamemode.tdm.Description",
scorelimit = BENNY.AddConvar("g_tdm_scorelimit", 75 ),
timelimit = BENNY.AddConvar("g_tdm_timelimit", 10*60 ),
},
["ffa"] = {
name = "#Gamemode.ffa.Name",
description = "#Gamemode.ffa.Description",
scorelimit = BENNY.AddConvar("g_ffa_scorelimit", 30 ),
timelimit = BENNY.AddConvar("g_ffa_timelimit", 10*60 ),
},
["snd"] = {
name = "#Gamemode.snd.Name",
description = "#Gamemode.snd.Description",
scorelimit = BENNY.AddConvar("g_snd_scorelimit", 6 ),
timelimit = BENNY.AddConvar("g_snd_timelimit", 2.5*60 ),
},
["ctf"] = {
name = "#Gamemode.ctf.Name",
description = "#Gamemode.ctf.Description",
scorelimit = BENNY.AddConvar("g_ctf_scorelimit", 3 ),
timelimit = BENNY.AddConvar("g_ctf_timelimit", 10*60 ),
},
["dom"] = {
name = "#Gamemode.dom.Name",
description = "#Gamemode.dom.Description",
scorelimit = BENNY.AddConvar("g_dom_scorelimit", 1000 ),
timelimit = BENNY.AddConvar("g_dom_timelimit", 10*60 ),
roundlimit = BENNY.AddConvar("g_dom_roundlimit", 1 ),
},
["dem"] = {
name = "#Gamemode.dem.Name",
description = "#Gamemode.dem.Description",
scorelimit = BENNY.AddConvar("g_dem_scorelimit", 3 ),
timelimit = BENNY.AddConvar("g_dem_timelimit", 5*60 ),
roundlimit = BENNY.AddConvar("g_dom_roundlimit", 2 ),
},
["hp"] = {
name = "#Gamemode.hp.Name",
description = "#Gamemode.hp.Description",
scorelimit = BENNY.AddConvar("g_hp_scorelimit", 300 ),
timelimit = BENNY.AddConvar("g_hp_timelimit", 10*60 ),
},
}
local thetypes = {
"Float",
"Int",
"Bool",
"Entity",
}
function BennyGame:Accessor( name, typey, default )
local World = game.GetWorld()
if typey == "Float" then
BennyGame["Get" .. name] = function( self )
return World:GetNW2Float( name, default )
end
BennyGame["Set" .. name] = function( self, val )
World:SetNW2Float( name, val )
end
return
end
if typey == "Int" then
BennyGame["Get" .. name] = function( self )
return World:GetNW2Int( name, default )
end
BennyGame["Set" .. name] = function( self, val )
World:SetNW2Int( name, val )
end
return
end
if typey == "Bool" then
BennyGame["Get" .. name] = function( self )
return World:GetNW2Bool( name, default )
end
BennyGame["Set" .. name] = function( self, val )
World:SetNW2Bool( name, val )
end
return
end
if typey == "Entity" then
BennyGame["Get" .. name] = function( self )
return World:GetNW2Entity( name, default )
end
BennyGame["Set" .. name] = function( self, val )
World:SetNW2Entity( name, val )
end
return
end
end
BG_STATE_WAITINGFORPLAYERS = 0
BG_STATE_PRE = 1
BG_STATE_ACTIVE = 2
BG_STATE_POST = 3
hook.Add("InitPostEntity", "Benny_Gamestate_InitPostEntity", function()
BennyGame:Accessor( "RoundStartedAt", "Float", 0 )
BennyGame:Accessor( "PregameStartedAt", "Float", 0 )
BennyGame:Accessor( "RoundFinishedAt", "Float", 0 )
BennyGame:Accessor( "State", "Int", 0 )
BennyGame:Accessor( "Round", "Int", 1 )
BennyGame:Accessor( "SwappedAtRound", "Int", 1 )
BennyGame:Accessor( "TimeExtension", "Int", 0 )
BennyGame:Accessor( "UUID", "Int", 0 )
BennyGame:Accessor( "Team1_Score", "Int", 0 )
BennyGame:Accessor( "Team2_Score", "Int", 0 )
BennyGame:Accessor( "Team3_Score", "Int", 0 )
BennyGame:Accessor( "Team4_Score", "Int", 0 )
BennyGame:Accessor( "Team5_Score", "Int", 0 )
BennyGame:Accessor( "Team6_Score", "Int", 0 )
BennyGame:Accessor( "TeamsSwapped", "Bool", false )
if SERVER then
BennyGame:SetUUID( math.random( -(2^31), (2^31)-1 ) )
end
end)
function BennyGame:GetScoreLimit()
if !BennyGame.Gamemodes[BennyGame:GetMode()].scorelimit then return false end
return BennyGame.Gamemodes[BennyGame:GetMode()].scorelimit:GetInt()
end
function BennyGame:GetTimeLimit()
if !BennyGame.Gamemodes[BennyGame:GetMode()].timelimit then return false end
return BennyGame.Gamemodes[BennyGame:GetMode()].timelimit:GetInt() + BennyGame:GetTimeExtension()
end
function BennyGame:GetRoundLimit()
if !BennyGame.Gamemodes[BennyGame:GetMode()].roundlimit then return false end
return BennyGame.Gamemodes[BennyGame:GetMode()].roundlimit:GetInt()
end
function BennyGame:GetPregameTime()
return c_g_pregame:GetInt()
end
function BennyGame:GetPostgameTime()
return c_g_postgame:GetInt()
end
function BennyGame:GetIntermissionTime()
return c_g_intermission:GetInt()
end
function BennyGame:GetScoreForTeam( teamid )
return BennyGame["GetTeam" .. teamid .. "_Score"]( self )
end
function BennyGame:SetScoreForTeam( teamid, var )
return BennyGame["SetTeam" .. teamid .. "_Score"]( self, var )
end
function BennyGame:AddScoreForTeam( teamid, var )
if Nuke then return end
if BennyGame:GetState() != BG_STATE_ACTIVE then return end
self:SetScoreForTeam( teamid, self:GetScoreForTeam( teamid ) + (var or 1) )
if self:GetScoreForTeam( teamid ) >= BennyGame:GetScoreLimit() then
BennyGame:EndRound( BG_ER_SCORELIMIT, teamid )
end
end
BG_ER_TIMELIMIT = 0
BG_ER_SCORELIMIT = 1
BG_ER_NUKE = 2
BG_ER_FORCE = 3
function BennyGame:StartRound()
PrintMessage(HUD_PRINTCENTER, "Round start!")
BennyGame:SetState( BG_STATE_ACTIVE )
BennyGame:SetRoundStartedAt( CurTime() )
game.CleanUpMap()
for _, ply in player.Iterator() do
ply:Spawn()
end
end
function BennyGame:EndRound( reason, forceteam )
local winningteam = forceteam
BennyGame:SetState( BG_STATE_POST )
BennyGame:SetRoundFinishedAt( CurTime() )
if !winningteam then
-- who has the most score
local HighestScore, HighestTeam = 0, 0
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
local ThisScore = BennyGame:GetScoreForTeam( RealTeamID )
if HighestScore < ThisScore then
HighestScore = ThisScore
HighestTeam = RealTeamID
winningteam = HighestTeam
end
end
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
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)
elseif HighestScore == ThisScore then
-- print("this looks like a tie", RealTeamID, HighestTeam)
winningteam = 0
break
end
end
end
local TheFull = "["
TheFull = TheFull .. ((reason==0 and "TIME END!] ") or (reason==1 and "SCORE END!] ") or ("MISSING END!] "))
if winningteam == 0 then
TheFull = "It's a tie! "
else
TheFull = TheFull .. l8(TEAMS[winningteam].name) .. " wins! "
end
TheFull = TheFull .. c_g_postgame:GetInt() .. "s until the next round."
PrintMessage(HUD_PRINTCENTER, TheFull)
local roundtime = CurTime() - BennyGame:GetRoundStartedAt()
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 )
if !args[1] then
print( "Needs a team ID." )
for index, data in ipairs( TEAMS ) do
print( index .. " - " .. data.id )
end
elseif !args[2] then
print( "Needs an integer." )
else
BennyGame:SetScoreForTeam( TEAMS_IDorName( args[1] ), args[2] )
print( "Team " .. args[1] .. " score now " .. BennyGame:GetScoreForTeam( TEAMS_IDorName( args[1] ) ) )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
concommand.Add("b-cheat_scoreadd", function( ply, cmd, args )
if !args[1] then
print( "Needs a team ID." )
for index, data in ipairs( TEAMS ) do
print( index .. " - " .. data.id )
end
else
BennyGame:AddScoreForTeam( TEAMS_IDorName( args[1] ), args[2] )
print( "Team " .. args[1] .. " score now " .. BennyGame:GetScoreForTeam( TEAMS_IDorName( args[1] ) ) )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
concommand.Add("b-cheat_setstate", function( ply, cmd, args )
if !args[1] then
print( "Needs an integer 0 waiting for palyers 1 pre 2 active 3 post" )
else
BennyGame:SetState( args[1] )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
concommand.Add("b-cheat_endround", function( ply, cmd, args )
BennyGame:EndRound( args[1] or BG_ER_FORCE, args[2] )
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
hook.Add("Think", "Benny_Gamestate_Think", function()
if SERVER then
local World = Entity(0)
if BennyGame:GetType() == BG_GTYPE_MP then
local roundstate = BennyGame:GetState()
if roundstate == BG_STATE_WAITINGFORPLAYERS then
-- Waiting for players
local count = 0
for index, ply in player.Iterator() do
if ply:Team() == TEAM_CONNECTING then continue end
if ply:Team() == TEAM_UNASSIGNED then continue end
if ply:Team() == TEAM_SPECTATOR then continue end
count = count + 1
end
if count >= c_g_minplayers:GetInt() then
roundstate = BG_STATE_PRE
BennyGame:SetState( roundstate )
BennyGame:SetPregameStartedAt( CurTime() )
PrintMessage(HUD_PRINTCENTER, "Pregame. " .. c_g_pregame:GetInt() .. "s until the round starts")
end
end
if roundstate == BG_STATE_PRE then
-- Pregame
if BennyGame:GetPregameStartedAt() + BennyGame:GetPregameTime() <= CurTime() then
BennyGame:StartRound()
end
elseif roundstate == BG_STATE_POST then
-- Postgame
if BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime() <= CurTime() then
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
BennyGame:SetScoreForTeam( RealTeamID, 0 )
end
BennyGame:SetState( BG_STATE_WAITINGFORPLAYERS )
end
elseif roundstate == BG_STATE_ACTIVE then
-- Active round
if (BennyGame:GetRoundStartedAt()+BennyGame:GetTimeLimit()) <= CurTime() then
-- Round time expired
BennyGame:EndRound( BG_ER_TIMELIMIT )
end
end
end
end
end)
-- Map functions
function BennyGame:GetMapName()
return "SixT"
end

View File

@ -1,948 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
-- Stack related
function xy( x, y )
return {x, y}
end
function hXY( x, y )
local rx, ry = 0, 0
for key, value in ipairs(stack) do
rx = rx + value[1]
ry = ry + value[2]
end
if x then rx = rx + x end
if y then ry = ry + y end
return rx, ry
end
function S_Push( x, y )
stack:Push( xy( x, y ) )
end
function S_Pop( x, y )
stack:Pop()
end
function hCol( r, g, b, a )
if IsColor(r) and g then
return surface.SetDrawColor( ColorAlpha( r, g ) )
end
return surface.SetDrawColor( r, g, b, a )
end
function hRect( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawRect( x, y, w, h )
end
function hRRect( x, y, w, h, r )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
draw.RoundedBox( r, x, y, w, h, surface.GetDrawColor() )
end
function hTRect( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawTexturedRect( x, y, w, h )
end
function hTrRect( x, y, w, h, d )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawTexturedRectRotated( x, y, w, h, d )
end
function hORect( x, y, w, h, r )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
surface.DrawOutlinedRect( x, y, w, h, r )
end
function hScis( x, y, w, h )
gx, gy = hXY()
x = (x or 0) + gx
y = (y or 0) + gy
render.SetScissorRect( x, y, x+w, y+h, true )
end
function hScisoff()
render.SetScissorRect( 0, 0, 0, 0, false )
end
function qt( text, font, x, y, col, xalign, yalign, col2 )
draw.SimpleText( text, font, x-1, y-1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y-1, col2, xalign, yalign )
draw.SimpleText( text, font, x+1, y-1, col2, xalign, yalign )
draw.SimpleText( text, font, x-1, y, col2, xalign, yalign )
draw.SimpleText( text, font, x+1, y, col2, xalign, yalign )
draw.SimpleText( text, font, x-1, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x+1, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y, col, xalign, yalign )
end
function hText( text, font, x, y, col, xalign, yalign )
local x, y = hXY( x, y )
draw.SimpleText( text, font, x, y, col, xalign, yalign )
end
function hTextQ( text, font, x, y, col, xalign, yalign, col2 )
local x, y = hXY( x, y )
qt( text, font, x, y, col, xalign, yalign, col2 )
end
function hTextS( text, font, x, y, col, xalign, yalign, col2 )
local x, y = hXY( x, y )
draw.SimpleText( text, font, x+1, y+1, col2, xalign, yalign )
draw.SimpleText( text, font, x, y, col, xalign, yalign )
end
local sizes = {
8, 10, 16, 24, 36, 48
}
local function regenfonts()
for index, scale in ipairs( sizes ) do
surface.CreateFont("HUD_" .. scale, {
font = "Carbon Plus Bold",
size = scale,
weight = 0,
extended = false,
italic = false,
antialias = true,
})
end
end
regenfonts()
FACTIONS = {
["benny"] = {
COLOR_MAIN = Color( 255, 238, 169 ),
COLOR_DARK = Color( 54, 44, 39 ),
CHARNAME = "BENNY",
},
["nikki"] = {
COLOR_MAIN = Color( 255, 174, 210 ),
COLOR_DARK = Color(37, 12, 40 ),
CHARNAME = "NIKKI",
},
["igor"] = {
COLOR_MAIN = Color( 253, 208, 207 ),
COLOR_DARK = Color( 32, 14, 12 ),
CHARNAME = "IGOR",
},
["yanghao"] = {
COLOR_MAIN = Color( 157, 187, 253 ),
COLOR_DARK = Color( 19, 21, 28 ),
CHARNAME = "YANG-HAO",
},
-- MP
["mp_cia"] = {
COLOR_MAIN = Color( 255, 255, 255),
COLOR_DARK = Color( 25, 23, 47 ),
CHARNAME = "CIA",
},
["mp_halo"] = {
COLOR_MAIN = Color( 130, 255, 255 ),
COLOR_DARK = Color( 40, 40, 58 ),
CHARNAME = "HALO",
},
["mp_plasof"] = {
COLOR_MAIN = Color( 255, 153, 153 ),
COLOR_DARK = Color( 45, 10, 10 ),
CHARNAME = "PLASOF",
},
["mp_arng"] = {
COLOR_MAIN = Color( 198, 255, 192 ),
COLOR_DARK = Color( 23, 32, 23 ),
CHARNAME = "NATGUARD",
},
["mp_militia"] = {
COLOR_MAIN = Color( 255, 219, 153 ),
COLOR_DARK = Color( 33, 18, 18 ),
CHARNAME = "MILITIA",
},
["mp_viper"] = {
COLOR_MAIN = Color( 248, 191, 225 ),
COLOR_DARK = Color( 50, 20, 50 ),
CHARNAME = "VIPER",
},
["unassigned"] = {
COLOR_MAIN = Color( 220, 220, 220 ),
COLOR_DARK = Color( 40, 40, 40),
CHARNAME = "Unassigned...",
},
}
local CURRCHAR = "mp_arng"
local COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
local COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
local COLOR_BRIGHT = Color( 94, 94, 94 )
local alphabet = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
local xhair_dot = Material( "benny/hud/xhair/dotx.png", "mips smooth" )
local xhair_dot_shadow = Material( "benny/hud/xhair/dot_s.png", "mips smooth" )
local fmlookup = {
[1] = "SEMI",
[math.huge] = "AUTO",
}
local function QuickDrawBar( BARWIDE, BARTALL, RealTeamID, TeamID, way )
local faction_info = FACTIONS[ TEAMS[RealTeamID].factionid ]
hCol( faction_info.COLOR_DARK )
hRect( 0, 0, BARWIDE, BARTALL )
hCol( faction_info.COLOR_MAIN )
hORect( 1, 1, BARWIDE-2, BARTALL-2, 1 )
local count = 6
local Score_Current = BennyGame:GetScoreForTeam( RealTeamID )
local Score_ToWin = BennyGame:GetScoreLimit()
local perc = Score_Current/Score_ToWin
local width = math.ceil( (BARWIDE-6)*perc )
if way then
hRect( BARWIDE - 3 - width, 3, width, BARTALL-6 )
else
hRect( 3, 3, width, BARTALL-6 )
end
for i=1, count-1 do
local bleh
if way then
bleh = (i/count)<(1-perc)
else
bleh = (i/count)>perc
end
hCol( bleh and faction_info.COLOR_MAIN or faction_info.COLOR_DARK )
hRect( 3 + (BARWIDE-7)*(i/count), 4, 1, BARTALL-8 )
end
if way then
hTextQ( faction_info.CHARNAME, "HUD_36", BARWIDE - 5, 0, faction_info.COLOR_DARK, TEXT_ALIGN_RIGHT, nil, faction_info.COLOR_MAIN )
hTextQ( Score_Current .. " / " .. Score_ToWin, "HUD_24", BARWIDE, BARTALL, faction_info.COLOR_MAIN, TEXT_ALIGN_RIGHT, nil, faction_info.COLOR_DARK )
else
hTextQ( faction_info.CHARNAME, "HUD_36", 5, 0, faction_info.COLOR_DARK, nil, nil, faction_info.COLOR_MAIN )
hTextQ( Score_Current .. " / " .. Score_ToWin, "HUD_24", 0, BARTALL, faction_info.COLOR_MAIN, nil, nil, faction_info.COLOR_DARK )
end
-- Players alive
if false then
for i=1, 6 do
local o = i-1
local lol = i>=3
if way then
S_Push( BARWIDE - i*(16+2), BARTALL + 2 )
else
S_Push( o*(16+2), BARTALL + 2 )
end
hCol( lol and faction_info.COLOR_DARK or faction_info.COLOR_MAIN )
hRect( 0, 0, 16, 16 )
hCol( lol and faction_info.COLOR_MAIN or faction_info.COLOR_DARK )
hORect( 1, 1, 16-2, 16-2, 1 )
S_Pop()
end
end
end
-- Drawing
function GM:HUDPaint()
local p = LocalPlayer()
local w, h = ScrW(), ScrH()
local handler = p:HandlerCheck()
stack = util.Stack()
local myteam = p:Team()
local CURRCHAR
if BennyGame:GetType() == BG_GTYPE_CAMPAIGN then
CURRCHAR = "benny"
else
if TEAMS[myteam] then
CURRCHAR = TEAMS[myteam].factionid
else
CURRCHAR = "unassigned"
end
end
local COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
local COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
local MP = BennyGame:GetType() == BG_GTYPE_MP
-- S_Push( math.random( -4, 4 ), math.random( -4, 4 ) )
S_Push( 20, h - 20 - 65 )
hCol( COLOR_DARK )
hRect( 0, 0, 328, 65 )
hTextQ( CHARNAME, "HUD_48", 10, 4, COLOR_DARK, nil, nil, COLOR_MAIN )
local HEALTHPER = p:GetHealth_Blood()/1000
--HEALTHPER = 11/100
hCol( COLOR_MAIN )
hRect( 8, 8, (320-4-4) * HEALTHPER, 41-4-4 )
hORect( 8, 8, (320-4-4), 41-4-4, 1 )
hCol( COLOR_DARK )
hORect( 8+1, 8+1, (320-4-4)-2, 41-4-4-2, 1 )
hCol( COLOR_MAIN )
hScis( 8, 8, (320-4-4) * HEALTHPER, 41-4-4 )
hText( CHARNAME, "HUD_48", 10, 4, COLOR_DARK )
hScisoff()
local slen = (320-4-4-4-4-4)
hCol( COLOR_MAIN )
hRect( 8, 45, slen*0.25, 12 )
hRect( 8 + (slen*0.25+4), 45, slen*0.25, 12 )
hRect( 8 + (slen*0.25+4)*2, 45, slen*0.25, 12 )
hRect( 8 + (slen*0.25+4)*3, 45, slen*0.25, 12 )
hCol( COLOR_DARK )
hORect( 8+1, 45+1, slen*0.25 - 2, 12-2, 1 )
hORect( 8+1 + (slen*0.25+4), 45+1, slen*0.25 - 2, 12-2, 1 )
hORect( 8+1 + (slen*0.25+4)*2, 45+1, slen*0.25 - 2, 12-2, 1 )
hORect( 8+1 + (slen*0.25+4)*3, 45+1, slen*0.25 - 2, 12-2, 1 )
if MP then -- MP
S_Push( 0, -8 - 2 )
local targetlength = 328
local segments = 10
local gap = 2
targetlength = targetlength - gap*(segments-1)
local chunk = 1/segments
for i=1, segments do
local z = i-1
local chunk0, chunk1 = chunk*z, chunk*i
local filled = math.Remap( p:GetLevel_XP()/15000, chunk0, chunk1, 0, 1 )
filled = math.Clamp( filled, 0, 1 )
local a1, a2, a3, a4 = ( (targetlength/segments) * z ) + (gap*z), 0, (targetlength/segments), 8
if i == segments then a3 = math.ceil(a3) end
if filled == 1 then
hCol( COLOR_MAIN )
hRect( a1, a2, a3, a4 )
hCol( COLOR_DARK )
hORect( a1, a2, a3, a4, 1 )
elseif filled == 0 then
hCol( COLOR_DARK )
hRect( a1, a2, a3, a4 )
else
hCol( COLOR_DARK )
hRect( a1, a2, a3, a4 )
hCol( COLOR_MAIN )
hRect( a1, a2, a3*filled, a4 )
hCol( COLOR_DARK )
hORect( a1, a2, a3, a4, 1 )
end
end
hTextQ( p:GetLevel_XP() .. " / 15000", "HUD_16", 0, -14, COLOR_MAIN, nil, nil, COLOR_DARK )
S_Pop()
end
S_Pop()
if handler then
-- Inventory
local Pw, Ph, Pg = 110, 30, 10
local thespace = 0
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
thespace = thespace + Pw + Pg
end
thespace = thespace - Pg
thespace = thespace/2
S_Push( ScrW()/2 - thespace, ScrH() - 20 - Ph )
for i, v in ipairs( p:GetInventory():GetWeighted() ) do
hCol( v == handler:GetDesireR() and COLOR_BRIGHT or COLOR_DARK )
hRect( (i-1)*(Pw+Pg), 0, Pw, Ph )
if v == handler:GetActiveR() then
hCol( COLOR_MAIN )
hORect( (i-1)*(Pw+Pg)+1, 1, Pw-2, Ph-2, 1 )
end
local x, y = (i-1)*(Pw+Pg), 0
hText( l8( v.Class.PrintName ), "HUD_24", x + Pw/2, y + 5, COLOR_MAIN, TEXT_ALIGN_CENTER )
hText( i, "HUD_16", x + 4, y + 2, COLOR_MAIN )
end
S_Pop()
local wep = handler:GetDesireR()
if wep and wep.GetClip then
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 )
S_Push( 0, 0 )
hCol( COLOR_MAIN )
local leng = Bw-8-8
hRect( 8, 8, leng-70, 26 )
hRect( 8 + leng - 70 + 4, 8, leng-(leng-70)-4, 26 )
hText( l8( wep.Class.PrintName ), "HUD_36", 12, 6, COLOR_DARK )
local bc = wep.Class.BurstCount
hText( fmlookup[bc] or bc .. "RND", "HUD_24", 10 + (leng - 70) + 70/2, 11, COLOR_DARK, TEXT_ALIGN_CENTER )
S_Pop()
local Tw, Th = 6, 18
if wep.Class.ClipSize>45 then
Tw = 3
Th = 13
elseif wep.Class.ClipSize<14 then
Tw = 8
Th = 22
end
S_Push( Bw - Tw - 8, Bh - Th - 8 )
for i=0, wep.Class.ClipSize-1 do
if i>29 then
hCol( COLOR_DARK )
hRect( (0 - Tw - 2)*i-4, -4, Tw+2, Th+8 )
end
end
for i=0, wep.Class.ClipSize-1 do
if wep:GetClip() >= (i+1) then
hCol( COLOR_MAIN )
hRect( (0 - Tw - 2)*i, 0, Tw, Th )
hCol( COLOR_DARK )
hRect( (0 - Tw - 2)*i, Th-4, Tw, 2 )
else
hCol( COLOR_BRIGHT )
hORect( (0 - Tw - 2)*i, 0, Tw, Th )
--hORect( (0 - 8 - 2)*i+1, 1, 8-2, 18-2 )
end
end
S_Pop()
S_Pop()
end
end
if MP then S_Push( w/2, 20 )
local BARWIDE, BARTALL, GAP = 240, 30, 100
-- Score
local count = 1
if BennyGame.RTeamID[myteam] then -- My team
local o = count-1
S_Push( count%2==1 and (-BARWIDE - 1 - GAP) or (0 + 1 + GAP), (BARTALL+2+16+2)*math.floor(o/2) )
QuickDrawBar( BARWIDE, BARTALL, myteam, BennyGame.RTeamID[myteam], count%2==0 )
S_Pop()
count = count + 1
end
-- Every other team
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
local o = count-1
S_Push( count%2==1 and (-BARWIDE - 1 - GAP) or (0 + 1 + GAP), (BARTALL+2+16+2)*math.floor(o/2) )
QuickDrawBar( BARWIDE, BARTALL, RealTeamID, TeamID, count%2==0 )
S_Pop()
count = count + 1
end
-- Timer
local DISPLAYWIDE, DISPLAYTALL = 150, 48
S_Push( -DISPLAYWIDE/2, 0 )
hCol( COLOR_DARK )
hRect( 0, 0, DISPLAYWIDE, DISPLAYTALL )
hCol( COLOR_MAIN )
hORect( 2, 2, DISPLAYWIDE-4, DISPLAYTALL-4, 1 )
local stupidtime = CurTime()
if BennyGame:GetState() == BG_STATE_ACTIVE then
stupidtime = BennyGame:GetRoundStartedAt() + BennyGame:GetTimeLimit() - CurTime()
elseif BennyGame:GetState() == BG_STATE_PRE then
stupidtime = BennyGame:GetPregameStartedAt() + BennyGame:GetPregameTime() - CurTime()
elseif BennyGame:GetState() == BG_STATE_POST then
stupidtime = BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime() - CurTime()
end
if BennyGame:GetState() != BG_STATE_WAITINGFORPLAYERS then
local d1, d2
local tt = string.FormattedTime( math.max( stupidtime, 0 ) )
if tt.h > 0 then
d1 = string.format( "%01i:%02i:%02i", tt.h, tt.m, tt.s )
elseif tt.m > 0 then
d1 = string.format( "%01i:%02i", tt.m, tt.s )
else
d1 = string.format( "%02i", tt.s )
d2 = string.format( ".%02i", tt.ms )
end
surface.SetFont("HUD_48")
local twid = surface.GetTextSize(d1)
if d2 then
surface.SetFont("HUD_36")
twid = twid + surface.GetTextSize(".00")
end
hText( d1, "HUD_48", DISPLAYWIDE/2 + 0 - twid/2, 4, COLOR_MAIN )
local twid2 = surface.GetTextSize(d1)
if d2 then
hText( d2, "HUD_36", DISPLAYWIDE/2 + twid2 - twid/2, 11, COLOR_MAIN )
end
end
local TITLE
if BennyGame:GetState() == BG_STATE_PRE then
TITLE = "PREGAME"
elseif BennyGame:GetState() == BG_STATE_POST then
TITLE = "POSTGAME"
elseif BennyGame:GetState() == BG_STATE_WAITINGFORPLAYERS then
TITLE = "WAITING FOR PLAYERS"
end
if TITLE then
hTextS( TITLE, "HUD_24", DISPLAYWIDE/2, -18, COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
end
if false then
local myteamwins = 2
local enemywins = 3
local count = 7
-- Round counter
local wideness = (20+2)*count-2
for i=1, count do
local o = i-1
S_Push( DISPLAYWIDE/2 - wideness/2 + o*(20+2), DISPLAYTALL+4 )
local COLOR_DARK = COLOR_DARK
local COLOR_MAIN = COLOR_MAIN
local filled = false
if i<=myteamwins then
filled = true
elseif (count-o)<=enemywins then
COLOR_DARK = E_COLOR_DARK
COLOR_MAIN = E_COLOR_MAIN
filled = true
else
COLOR_DARK = Color( 040, 040, 040 )
COLOR_MAIN = Color( 080, 080, 080 )
filled = true
end
hCol( filled and COLOR_MAIN or COLOR_DARK )
hRect( 0, 0, 20, 8 )
hCol( filled and COLOR_DARK or COLOR_MAIN )
hORect( 1, 1, 20-2, 8-2, 1 )
S_Pop()
end
end
-- Domination flag status
if true then
local AllFlags = ents.FindByClass("benny_domflag")
S_Push( 0, 0 )
local count = #AllFlags
local wideness = (48+2)*count-2
for i, ent in ipairs( AllFlags ) do--for i=1, count do
local o = i-1
local faction_name = TEAMS[ent:GetTeamOwned()].factionid
local faction_info = FACTIONS[faction_name]
local taking_faction_name = TEAMS[ent:GetTeamTaking()].factionid
local taking_faction_info = FACTIONS[taking_faction_name]
local capturepercent = ent:GetCapturePercent()--math.Remap( CurTime()%4, 0, 3, 0, 1 )
--capturepercent = math.Clamp(capturepercent, 0, 1)
local mine, enemy = false, true
--if i==3 then mine = !mine enemy = !enemy end
if (capturepercent>=1) then
mine = !mine
enemy = !enemy
end
S_Push( DISPLAYWIDE/2 - wideness/2 + o*(48+2), DISPLAYTALL+4 )
hCol( faction_info.COLOR_DARK )
hRect( 0, 0, 48, 48 )
hCol( faction_info.COLOR_MAIN )
hRect( 1, 1, 48-2, 48-2, 1 )
if capturepercent<1 then
hCol( taking_faction_info.COLOR_MAIN )
hORect( 1, 1, 48-2, 48-2, math.floor(23 * capturepercent) )
end
hTextQ( alphabet[i] or i, "HUD_36", 48/2, 9, faction_info.COLOR_MAIN, TEXT_ALIGN_CENTER, nil, faction_info.COLOR_DARK )
S_Pop()
end
S_Pop()
end
S_Pop()
do
local AllFlags = ents.FindByClass("benny_domflag")
local AllFlagFlip = table.Flip(AllFlags)
-- Current Objective
local obj = p:GetTouchedObjective()
if obj:IsValid() then
S_Push( 0, 200 )
local TITLE = "CAPTURING"
local PERCENT = obj:GetCapturePercent()
if obj:GetContested() then
TITLE = "CONTESTED"
elseif obj:GetTeamOwned() == myteam then
if obj:GetCapturePercent() > 0 then
TITLE = "CLEARING"
else
TITLE = "SECURE"
PERCENT = 1
end
elseif obj:GetTeamOwned() == 0 and obj:GetTeamTaking() != myteam then
TITLE = "CLEARING"
end
local BARCOLOR = FACTIONS[ TEAMS[obj:GetTeamOwned()].factionid ]
local TAKCOLOR = FACTIONS[ TEAMS[obj:GetTeamTaking()].factionid ]
local CONTOLER = FACTIONS[ "unassigned" ]
BARCOLOR_MAIN = BARCOLOR.COLOR_MAIN
BARCOLOR_DARK = BARCOLOR.COLOR_DARK
TAKCOLOR_MAIN = TAKCOLOR.COLOR_MAIN
TAKCOLOR_DARK = TAKCOLOR.COLOR_DARK
CONTOLER_MAIN = CONTOLER.COLOR_MAIN
CONTOLER_DARK = CONTOLER.COLOR_DARK
local BWIDE, BTALL = 180, 16
hCol( BARCOLOR_DARK )
hRect( -80, 0, 160, 38 )
hCol( BARCOLOR_DARK )
hRect( -100, 35, 200, 76 )
hCol( BARCOLOR_MAIN )
hORect( -100+1, 35+1, 200-2, 76-2 )
hCol( BARCOLOR_MAIN )
hORect( -80+1, 1, 160-2, 38-2, 1 )
hTextQ( "POINT " .. (alphabet[ AllFlagFlip[obj] ] or AllFlagFlip[obj]), "HUD_36", 0, 4, BARCOLOR_MAIN, TEXT_ALIGN_CENTER, nil, BARCOLOR_DARK )
hTextQ( TITLE, "HUD_24", 0, TITLE=="SECURE" and 62 or 40, obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
if TITLE!="SECURE" then
S_Push( -BWIDE/2, 62 )
hCol( TAKCOLOR_DARK )
hRect( 0, 0, 180, BTALL )
hCol( TAKCOLOR_MAIN )
hORect( 1, 1, 180-2, BTALL-2 )
hCol( TAKCOLOR_MAIN )
hRect( 3, 3, math.floor((BWIDE-6) * PERCENT), BTALL-6 )
S_Pop()
hTextQ( math.floor(PERCENT*100) .. "%", "HUD_36", 0, 78, obj:GetContested() and CONTOLER_MAIN or COLOR_MAIN, TEXT_ALIGN_CENTER, nil, obj:GetContested() and CONTOLER_DARK or COLOR_DARK )
end
S_Pop()
end
end
S_Pop() end
--local itemcheck = handler:ItemCheckTrace()
-- Hints
if true then
S_Push( w - 20, 20 )
local hints = {}
table.insert( hints, { "[SHIFT]", "DIVE" } )
table.insert( hints, { "", "INTO PRONE", "HOLD" } )
if handler:ItemR() then
table.insert( hints, { "", "- - - - - - - - - - - -" } )
table.insert( hints, { "[M1]", "FIRE" } )
table.insert( hints, { "[C]", "FIREMODE" } )
table.insert( hints, { "[E]", "THROW" } )
table.insert( hints, { "[R]", "RELOAD" } )
table.insert( hints, { "", "RETAIN MAG", "HOLD" } )
--elseif itemcheck.Entity:IsValid() and itemcheck.Entity.BennyItem then
-- table.insert( hints, { "", "- - - - - - - - - - - -" } )
-- table.insert( hints, { "[E]", "PICK UP" } )
end
for i, v in ipairs( hints ) do
hTextS( v[1], "HUD_24", -150, (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
hTextS( v[2], "HUD_24", 0, (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_RIGHT, nil, COLOR_DARK )
if v[3] then
hTextS( v[3], "HUD_16", -150, 3 + (24*(i-1)), COLOR_MAIN, TEXT_ALIGN_CENTER, nil, COLOR_DARK )
end
end
S_Pop()
end
-- S_Pop()
--local trac = p:GetEyeTrace().HitPos:ToScreen()
local trac = util.TraceLine( {
start = p:GetPos() + Vector( 0, 0, 52 ),
endpos = p:GetPos() + Vector( 0, 0, 52 ) + p:EyeAngles():Forward()*(2^31),
filter = p,
} ).HitPos
local trac2 = util.TraceLine( {
start = CamSpot(),
endpos = CamSpot() + TPSOverride:Forward()*(2^31),
filter = p,
} ).HitPos
local tol = false
if trac:IsEqualTol( trac2, 2 ) then -- within two inches
trac2 = trac2:ToScreen()
trac = trac2
tol = true
else
trac = trac:ToScreen()
trac2 = trac2:ToScreen()
end
for i=1, 2 do
local shadowtime = i==1
local traac = shadowtime and trac2 or trac
local cx, cy = math.Round(traac.x), math.Round(traac.y)
local gap = 4
local length = 4
S_Push( cx, cy )
local lol = shadowtime and 0 or 255
local lol2 = shadowtime and 127 or 255
local Shadow_Gap = shadowtime and 1 or 0
local Shadow_Thickness = shadowtime and 2 or 0
surface.SetDrawColor( lol, lol, lol, lol2 )
--surface.SetMaterial( shadowtime and xhair_dot_shadow or xhair_dot )
hRect( -1 - Shadow_Gap, gap - Shadow_Gap, 2 + Shadow_Thickness, length + Shadow_Thickness )
hRect( gap - Shadow_Gap, -1 - Shadow_Gap, length + Shadow_Thickness, 2 + Shadow_Thickness )
-- top and left
hRect( -1 - Shadow_Gap, -length - gap - Shadow_Gap, 2 + Shadow_Thickness, length + Shadow_Thickness )
hRect( -length - gap - Shadow_Gap, -1 - Shadow_Gap, length + Shadow_Thickness, 2 + Shadow_Thickness )
if !shadowtime and !tol then
surface.SetDrawColor( 255, 0, 0 )
hRect( -1, -1, 2, 2 )
end
S_Pop()
end
if stack:Size() != 0 then print("Stack unfinished.") end
return
end
-- Not drawing
local hide = {
["CHudHealth"] = true,
["CHudBattery"] = true,
["CHudAmmo"] = true,
["CHudSecondaryAmmo"] = true,
["CHudDamageIndicator"] = true,
["CHudCloseCaption"] = true,
["CHudCrosshair"] = true,
["CHudSuitPower"] = true,
["CHUDQuickInfo"] = true,
["CHudZoom"] = true,
}
function GM:HUDShouldDraw( name )
if hide[ name ] then
return false
else
return true
end
end
--local players = {
-- { name = "Jim", Team = "mp_arng" },
-- { name = "Sas", Team = "mp_arng" },
-- { name = "Greg", Team = "mp_arng" },
-- { name = "Nate", Team = "mp_arng" },
--
-- { name = "Ion", Team = "mp_plasof" },
-- { name = "Beo", Team = "mp_plasof" },
-- { name = "Poe", Team = "mp_plasof" },
-- { name = "Zio", Team = "mp_plasof" },
--}
local things = {
{ name = "Score", size = 100,
get = function( ply )
return 0
end,},
{ name = "Kills", size = 50,
get = function( ply )
return ply:Frags()
end,},
{ name = "Deaths", size = 50,
get = function( ply )
return ply:Deaths()
end,},
{ name = "Time", size = 50,
get = function( ply )
return ":00"
end,},
{ name = "Ping", size = 50,
get = function( ply )
return ply:Ping()
end,} -- Ping
}
local function QuickDrawStat( wide, data, first )
local gap = 0
local teamd
local faction
if TEAMS[data.id] then
teamd = TEAMS[data.id]
faction = FACTIONS[teamd.factionid]
else
teamd = TEAMS[0]
faction = FACTIONS[teamd.factionid]
end
local TeamName = l8( teamd.name )
hTextQ( TeamName, "HUD_36", 0, 0, faction.COLOR_MAIN, nil, nil, faction.COLOR_DARK )
gap = gap + 30
hCol( faction.COLOR_DARK )
hRect( -5+1, gap+1, wide+10, 2 )
hCol( faction.COLOR_MAIN )
hRect( -5, gap, wide+10, 2 )
gap = gap + 6
local blep = wide
for i, v in ipairs(things) do blep = blep - v.size end
if first then
local bloop = 0
for i, v in ipairs(things) do
hCol( 127, 127, 127, 80 )
local x, y = blep+bloop, 12
if v.name then
hTextS( v.name, "HUD_16", x+(v.size/2), y, color_white, TEXT_ALIGN_CENTER, nil, color_black )
end
bloop = bloop + v.size
end
end
for i, ply in ipairs( data.players ) do
local bloop = 0
hCol( faction.COLOR_MAIN, 30 )
hRect( 0, gap, wide, 30 )
hCol( faction.COLOR_DARK )
hORect( 3, gap+3, wide-4, 30-4, 1 )
hCol( faction.COLOR_MAIN )
hORect( 2, gap+2, wide-4, 30-4, 1 )
hTextQ( ply:GetLevel(), "HUD_16", 18, gap+8, Color( 255, 255, 0 ), TEXT_ALIGN_CENTER, nil, color_black )
hTextQ( ply:Nick(), "HUD_24", 32, gap+5, color_white, nil, nil, color_black )
local bloop = 0
for i, v in ipairs(things) do
hCol( 255, 0, 0 )
local x, y = blep+bloop, gap+8
hTextS( v.get( ply ), "HUD_16", x+(v.size/2), y, color_white, TEXT_ALIGN_CENTER, nil, color_black )
bloop = bloop + v.size
end
gap = gap + 32
end
return gap
end
local ScoreWide = 600
function GM:ScoreboardShow()
drawscoreboard = true
end
function GM:ScoreboardHide()
drawscoreboard = false
end
function GM:HUDDrawScoreBoard()
if !drawscoreboard then return end
local p = LocalPlayer()
local w, h = ScrW(), ScrH()
local handler = p:HandlerCheck()
stack = util.Stack()
local myteam = p:Team()
local CURRCHAR
if BennyGame:GetType() == BG_GTYPE_CAMPAIGN then
CURRCHAR = "benny"
else
if TEAMS[myteam] then
CURRCHAR = TEAMS[myteam].factionid
else
CURRCHAR = "unassigned"
end
end
local COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
local COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
local MP = BennyGame:GetType() == BG_GTYPE_MP
if MP then
S_Push( w/2 - ScoreWide/2, h/2 - 400/2 )
local OrganizedTeams = {}
local IDtoOrg = {}
local MyCreation = { id = myteam, players = {} }
table.insert( OrganizedTeams, MyCreation )
IDtoOrg[myteam] = MyCreation
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
local MyCreation = { id = RealTeamID, players = {} }
table.insert( OrganizedTeams, MyCreation )
IDtoOrg[RealTeamID] = MyCreation
end
for _, ply in player.Iterator() do
local thisteam = ply:Team()
if !IDtoOrg[thisteam] then
local MyCreation = { id = thisteam, players = {} }
table.insert( OrganizedTeams, MyCreation )
IDtoOrg[thisteam] = MyCreation
end
table.insert( IDtoOrg[thisteam].players, ply )
end
local gap = 0
for index, data in ipairs( OrganizedTeams ) do
S_Push( 0, 0 + gap )
gap = gap + QuickDrawStat( ScoreWide, data, index==1 )
S_Pop()
end
S_Pop()
else
-- Timer, player & team score
end
if stack:Size() != 0 then print("Stack unfinished.") end
return
end

View File

@ -1,77 +0,0 @@
local show_letters = {
{ "q", "w", "e", "r", "t", "y" },
{ "a", "s", "d", "f", "g", "h" },
{ "shift", "z", "x", "c", "v", "b", "n" },
{ "ctrl", "alt", "space" },
}
local translate_letters = {
["e"] = "weapon 1",
["q"] = "weapon 2",
["c"] = "grenade 1",
["z"] = "grenade 2",
["r"] = "alt 1",
["t"] = "alt 2",
["x"] = "bullrush",
["shift"] = "speed",
}
local function commoncode( set )
for index, letter in ipairs( set ) do
local lettercode = input.GetKeyCode( letter )
local keydown = input.IsKeyDown( lettercode )
local thecolor = keydown and COLOR_MAIN or COLOR_DARK
local fakecolor = ColorAlpha( COLOR_BRIGHT, 60 )
hCol( fakecolor )
local LetterWidth = 80
local LetterGap = 4
hRect( (index-1)*(LetterWidth+4), 0, LetterWidth, 40, 2 )
hCol( thecolor )
hORect( (index-1)*(LetterWidth+4), 0, LetterWidth, 40, 2 )
local x, y = hXY( (index-1)*(LetterWidth+4) + LetterWidth/2, 20+3 )
draw.SimpleText( letter:upper(), "HUD_36", x, y, thecolor, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
local tlated = translate_letters[letter]
if tlated then
local x, y = hXY( (index-1)*(LetterWidth+4) + LetterWidth/2, 20 + 6 )
draw.SimpleText( tlated, "HUD_16", x, y, thecolor, TEXT_ALIGN_CENTER )
end
end
end
hook.Add( "HUDPaint", "Benny_HUDPaint_KeyboardOverlay", function()
--if false then return end
local p = LocalPlayer()
local myteam = p:Team()
local CURRCHAR
if BennyGame:GetType() == BG_GTYPE_CAMPAIGN then
CURRCHAR = "benny"
else
CURRCHAR = TEAMS[myteam].factionid
end
local COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
local COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
stack = util.Stack()
S_Push( 100, h - 300 )
S_Push( 0, 0 )
commoncode( show_letters[1] )
S_Pop()
S_Push( 18, 40+4 )
commoncode( show_letters[2] )
S_Pop()
S_Push( 18+24 - (40+24), 40+4+40+4 )
commoncode( show_letters[3] )
S_Pop()
S_Push( 0, 40+4+40+4+40+4 )
commoncode( show_letters[4] )
S_Pop()
S_Pop()
if stack:Size() != 0 then print("Stack unfinished: KeyboardOverlay") end
end)

View File

@ -1,4 +1,6 @@
-- Thing
AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" ) AddCSLuaFile( "shared.lua" )

View File

@ -1,207 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
local PT = FindMetaTable("Player")
function PT:GetItems()
return
end
InventoryMeta = {}
function InventoryMeta:Destroy()
local p = self[0].Owner
p.Inventory = nil
p:GetInventory()
end
function InventoryMeta:BugCheck()
for i, v in pairs(self) do
if i != 0 and !i:IsValid() then
self[i] = nil
end
end
end
function InventoryMeta:GetWeighted()
local itemlist = {}
for i, v in pairs(self) do
if i == 0 then continue end
table.insert( itemlist, i )
end
table.sort( itemlist, function( a, b )
return a:GetAcquisition() < b:GetAcquisition()
end)
return itemlist
end
function InventoryMeta:Sync()
if SERVER then
net.Start("AEINV_InvSync")
local count = table.Count( self )-1 -- The header is included
net.WriteUInt( count, 8 )
for key, _ in pairs( self ) do
if key == 0 then continue end
net.WriteEntity( key )
end
net.Send( self[0].Owner )
end
end
InventoryMeta.__index = InventoryMeta
function PT:GetInventory()
if !self.Inventory then
print("[inventory] new inventory created: ", self)
self.Inventory = {}
self.Inventory[0] = { Owner = self }
setmetatable( self.Inventory, InventoryMeta )
if SERVER then
for i, v in pairs( self:GetChildren() ) do
if v.AEItem then
print( "[inventory] regen: adding", v)
self.Inventory[v] = true
end
end
self.Inventory:Sync()
end
end
self.Inventory:BugCheck()
return self.Inventory
end
gameevent.Listen( "OnRequestFullUpdate" )
hook.Add( "OnRequestFullUpdate", "Benny_OnRequestFullUpdate_Inventory", function( data )
local name = data.name // Same as Player:Nick()
local steamid = data.networkid // Same as Player:SteamID()
local id = data.userid // Same as Player:UserID()
local index = data.index // Same as Entity:EntIndex() minus one
if SERVER then
print("[inventory]", Player(id), "FullUpdate resync")
Player(id):GetInventory():Sync()
end
end )
if SERVER then
util.AddNetworkString("AEINV_InvSync")
else
net.Receive("AEINV_InvSync", function()
print("[inventory] sync start:")
local p = LocalPlayer()
p.Inventory = nil
if p.GetInventory then
local inv = p:GetInventory()
local count = net.ReadUInt(8)
for i=1, count do
local key = net.ReadEntity()
print( "\tadded", key)
inv[key] = true
end
else
print("\ti don't have an inventory, maybe you asked too early!!")
end
print("\tsync done")
end)
end
do
local qt2 = {
["slot1"] = 1,
["slot2"] = 2,
["slot3"] = 3,
["slot4"] = 4,
["slot5"] = 5,
["slot6"] = 6,
["slot7"] = 7,
["slot8"] = 8,
["slot9"] = 9,
["slot0"] = 0,
}
local qt = {
["invprev"] = -1,
["invnext"] = 1,
}
hook.Add( "PlayerBindPress", "Benny_PlayerBindPress_Original", function( ply, bind, pressed, code )
if qt2[bind] then
local Num = qt2[bind]
if pressed then
local inv = ply:GetInventory():GetWeighted()
local wep = ply:HandlerCheck()
local invf = table.Flip( inv )
local NumOfActive = 0
NumOfActive = invf[wep:GetDesireR()]
if Num == NumOfActive then
Num = 0
end
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
end
return true
end
if qt[bind] then
if pressed then
local Num = 0
local inv = ply:GetInventory():GetWeighted()
local wep = ply:HandlerCheck()
local invf = table.Flip( inv )
local invc = #inv
Num = wep:GetDesireR() and invf[wep:GetDesireR()] or 0
Num = Num + qt[bind]
if Num > invc then
Num = 0
elseif Num < 0 then
Num = invc
end
input.SelectWeapon( ply:GetWeapon("goat_"..Num) )
end
return true
end
end)
end
-- breaks GESTURE_SLOT_ATTACK_AND_RELOAD and I can't fucking have that
hook.Add("DoAnimationEvent", "Benny_DoAnimationEvent_FixAnimations", function( ply, event, data )
return ACT_INVALID
end)
hook.Add( "PlayerSwitchWeapon", "Benny_PlayerSwitchWeapon_Goat", function( ply, old, ent )
if ent.BennyItemHandler then return true end -- what happened?
local wep = ply:HandlerCheck()
if !wep then print("PlayerSwitchWeapon Benny Handler Missing!!") return false end
if ent:IsValid() and ent.Goat then
local inv = ply:GetInventory():GetWeighted()
if ent.Goat == 0 then wep:SetDesireR( NULL ) return false end
local ent = inv[ent.Goat]
if ent then
wep:SetDesireR( ent )
end
end
return false
end)
for i=0, 9 do
local tent = {}
--tent.Base = "goat"
tent.Goat = i
weapons.Register( tent, "goat_" .. i )
end

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
Languages = {}
function l8( inp )
if inp[1] == "#" then inp = inp:Right(-2) else return "Untranslatable: '" .. inp .. "'" end
return Languages["en-us"][inp] or Languages["en-us"][inp] or ("No translation: '" .. inp .. "'")
end
local AD, IN = AddCSLuaFile, include
AD("languages/en-us.lua")
IN("languages/en-us.lua")

View File

@ -1,224 +0,0 @@
local L = {}
Languages["en-us"] = L
L["Name"] = "English (United States)"
-- Convars
L["Convar.cam_f.Name"] = "Camera Forward Offset"
L["Convar.cam_f.Description"] = ""
L["Convar.cam_fov.Name"] = "Camera FOV"
L["Convar.cam_fov.Description"] = "Field-of-view of the camera, horizontally, in 4:3 (further in higher aspect-ratios)"
L["Convar.cam_fp.Name"] = "First-person Mode"
L["Convar.cam_fp.Description"] = "First-person perspective"
L["Convar.cam_fp_fov.Name"] = "First-person weapon FOV"
L["Convar.cam_fp_fov.Description"] = "How close objects in the player's hand will appear"
L["Convar.cam_r.Name"] = "Camera Right Offset"
L["Convar.cam_r.Description"] = ""
L["Convar.cam_u.Name"] = "Camera Up Offset"
L["Convar.cam_u.Description"] = ""
L["Convar.cheat_endround.Name"] = "Cheat: End Round"
L["Convar.cheat_endround.Description"] = "Cheat"
L["Convar.cheat_rewardxp.Name"] = "Cheat: Reward XP"
L["Convar.cheat_rewardxp.Description"] = "Cheat"
L["Convar.cheat_setxp.Name"] = "Cheat: Set XP"
L["Convar.cheat_setxp.Description"] = "Cheat"
L["Convar.cheat_scoreadd.Name"] = "Cheat: Add Score"
L["Convar.cheat_scoreadd.Description"] = "Cheat"
L["Convar.cheat_scoreset.Name"] = "Cheat: Set Score"
L["Convar.cheat_scoreset.Description"] = "Cheat"
L["Convar.cheat_setstate.Name"] = "Cheat: Set Game State"
L["Convar.cheat_setstate.Description"] = "Cheat"
L["Convar.cheat_setteam.Name"] = "Cheat: Set Team"
L["Convar.cheat_setteam.Description"] = "Cheat"
L["Convar.debug_listbones.Name"] = "debug_listbones"
L["Convar.debug_listbones.Description"] = "List all bones of the current character"
L["Convar.g_intermission.Name"] = "g_intermission"
L["Convar.g_intermission.Description"] = "Intermission time"
L["Convar.g_minplayers.Name"] = "g_minplayers"
L["Convar.g_minplayers.Description"] = "Minimal players necessary to start the game"
L["Convar.g_pregame.Name"] = "g_pregame"
L["Convar.g_pregame.Description"] = "Pre-game time"
L["Convar.g_postgame.Name"] = "g_postgame"
L["Convar.g_postgame.Description"] = "Post-game time"
L["Convar.g_snd_scorelimit.Name"] = "g_snd_scorelimit"
L["Convar.g_snd_scorelimit.Description"] = "Search and Destroy: Score Limit"
L["Convar.g_snd_timelimit.Name"] = "g_snd_timelimit"
L["Convar.g_snd_timelimit.Description"] = "Search and Destroy: Time Limit"
L["Convar.g_tdm_scorelimit.Name"] = "g_tdm_scorelimit"
L["Convar.g_tdm_scorelimit.Description"] = "Team Deathmatch: Score Limit"
L["Convar.g_tdm_timelimit.Name"] = "g_tdm_timelimit"
L["Convar.g_tdm_timelimit.Description"] = "Team Deathmatch: Time Limit"
L["Convar.g_ctf_scorelimit.Name"] = "g_ctf_scorelimit"
L["Convar.g_ctf_scorelimit.Description"] = "Capture the Flag: Score Limit"
L["Convar.g_ctf_timelimit.Name"] = "g_ctf_timelimit"
L["Convar.g_ctf_timelimit.Description"] = "Capture the Flag: Time Limit"
L["Convar.g_dem_scorelimit.Name"] = "g_dem_scorelimit"
L["Convar.g_dem_scorelimit.Description"] = "Demolition: Score Limit"
L["Convar.g_dem_timelimit.Name"] = "g_dem_timelimit"
L["Convar.g_dem_timelimit.Description"] = "Demolition: Time Limit"
L["Convar.g_dom_roundlimit.Name"] = "g_dom_roundlimit"
L["Convar.g_dom_roundlimit.Description"] = "Domination: Round Limit"
L["Convar.g_dom_scorelimit.Name"] = "g_dom_scorelimit"
L["Convar.g_dom_scorelimit.Description"] = "Domination: Score Limit"
L["Convar.g_dom_timelimit.Name"] = "g_dom_timelimit"
L["Convar.g_dom_timelimit.Description"] = "Domination: Time Limit"
L["Convar.g_ffa_scorelimit.Name"] = "g_ffa_scorelimit"
L["Convar.g_ffa_scorelimit.Description"] = "Free For All: Score Limit"
L["Convar.g_ffa_timelimit.Name"] = "g_ffa_timelimit"
L["Convar.g_ffa_timelimit.Description"] = "Free For All: Time Limit"
L["Convar.g_hp_scorelimit.Name"] = "g_hp_scorelimit"
L["Convar.g_hp_scorelimit.Description"] = "Hardpoint: Score Limit"
L["Convar.g_hp_timelimit.Name"] = "g_hp_timelimit"
L["Convar.g_hp_timelimit.Description"] = "Hardpoint: Time Limit"
L["Convar.gamemode.Name"] = "Gamemode"
L["Convar.gamemode.Description"] = "Game mode"
L["Convar.gametype.Name"] = "Gametype"
L["Convar.gametype.Description"] = "Game type: SP or MP"
-- Gamemodes
L["Gamemode.free.Name"] = "Freeplay"
L["Gamemode.free.Description"] = "Objectiveless free-roam."
L["Gamemode.tdm.Name"] = "Team Deathmatch"
L["Gamemode.tdm.Description"] = "Several teams fight to the death for the most kills."
L["Gamemode.ffa.Name"] = "Free-for-all"
L["Gamemode.ffa.Description"] = "Every man for himself."
L["Gamemode.snd.Name"] = "Search and Destroy"
L["Gamemode.snd.Description"] = "One half tries to plant a bomb while the other half attempts to stop it."
L["Gamemode.ctf.Name"] = "Capture the Flag"
L["Gamemode.ctf.Description"] = "Bring your enemies flags to your base."
L["Gamemode.dom.Name"] = "Domination"
L["Gamemode.dom.Description"] = "Several teams fight to hold capture points for the longest amount of time"
L["Gamemode.dem.Name"] = "Demolition"
L["Gamemode.dem.Description"] = "One half tries to destroy the other halves objectives."
L["Gamemode.hp.Name"] = "Hardpoint"
L["Gamemode.hp.Description"] = "Several teams fight to hold a singular capture point for the longest amount of time."
-- Teams
L["Team.cia.Name"] = "CIA"
L["Team.cia.Description"] = "CIA black ops, coverup crew"
L["Team.halo.Name"] = "HALO"
L["Team.halo.Description"] = "Assassination agency?"
L["Team.plasof.Name"] = "PLASOF"
L["Team.plasof.Description"] = "People's Liberation Army Special Operations Forces"
L["Team.arng.Name"] = "NATIONAL GUARD"
L["Team.arng.Description"] = "United States National Guard"
L["Team.militia.Name"] = "MILITIA"
L["Team.militia.Description"] = "Brazilian militia??? what"
L["Team.viper.Name"] = "VIPERS"
L["Team.viper.Description"] = "Gang"
-- Items
L["Item.mk23.Name"] = "MK.23"
L["Item.mk23.Description"] = "Special forces sidearm"
L["Item.cz75.Name"] = "CZ-75"
L["Item.cz75.Description"] = "Rugged semi-automatic handgun"
L["Item.g18.Name"] = "G18"
L["Item.g18.Description"] = "Automatic machine pistol"
L["Item.fnc.Name"] = "FNC Para"
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.stoner.Name"] = "STONER-63"
L["Item.stoner.Description"] = "Modular machine gun"
L["Item.hk21.Name"] = "HK-21"
L["Item.hk21.Description"] = "Powerful medium machine gun"
L["Item.m16a2.Name"] = "M16A2"
L["Item.m16a2.Description"] = "Rugged burst rifle"
L["Item.oicw.Name"] = "OICW"
L["Item.oicw.Description"] = "Advanced combat rifle"
L["Item.spas12.Name"] = "SPAS-12"
L["Item.spas12.Description"] = "Chrome-lined autoshotgun"
L["Item.tmp.Name"] = "TMP"
L["Item.tmp.Description"] = "Concealable machine pistol"
L["Item.mp5k.Name"] = "MP5K"
L["Item.mp5k.Description"] = "High-quality SMG"
L["Item.mp7.Name"] = "MP7"
L["Item.mp7.Description"] = "Special forces PDW"
L["Item.mac11.Name"] = "MAC-11"
L["Item.mac11.Description"] = "Tiny hornet gun"
L["Item.1887.Name"] = "1887"
L["Item.1887.Description"] = "Lever-action"
L["Item.db.Name"] = "DB"
L["Item.db.Description"] = "Side-by-side shotgun"
L["Item.aa12.Name"] = "AA-12"
L["Item.aa12.Description"] = "Automatic combat shotgun"
L["Item.striker.Name"] = "Streetsweeper"
L["Item.striker.Description"] = "Semi-automatic drum-fed shotgun"
L["Item.r870.Name"] = "R870"
L["Item.r870.Description"] = "Sawn-off pump-action shotgun"
L["Item.spas15.Name"] = "SPAS-15"
L["Item.spas15.Description"] = "Mag-fed pump-action shotgun"
L["Item.satchels.Name"] = "Satchels"
L["Item.satchels.Description"] = "Packs of bombs and a detonator"
L["Item.toolgun.Name"] = "Tool gun"
L["Item.toolgun.Description"] = "Developer tools"

View File

@ -0,0 +1,42 @@
-- Benny quirk system
PERKS = {}
CAT_MENTAL = 1
CAT_PHYSICAL = 2
CAT_TRAINING = 3
CAT_OPERATIONAL = 4
PERKS[CAT_MENTAL] = {}
PERKS[CAT_PHYSICAL] = {}
PERKS[CAT_TRAINING] = {}
PERKS[CAT_OPERATIONAL] = {}
PERKS[CAT_MENTAL]["overprepared"] = 1 -- Magazines & grenades take less inventory space
PERKS[CAT_MENTAL]["resilience"] = 1 -- Near immunity to fall damage
PERKS[CAT_MENTAL]["paranoid"] = 2 -- Indicator when being targeted from outside your FoV.
PERKS[CAT_MENTAL]["stoic"] = 2 -- Flinch less from damage.
PERKS[CAT_MENTAL]["bloodthirsty"] = 2 -- Instantly regenerate health from melee and thrown kills
PERKS[CAT_MENTAL]["relentless"] = 3 -- Faster melee swings on a hit.
PERKS[CAT_PHYSICAL]["sling"] = 1 -- Hipfire accuracy increase
PERKS[CAT_PHYSICAL]["armpadding"] = 2 -- No health damage when blocking blunt melee, but stamina damage still applies
PERKS[CAT_PHYSICAL]["stabkevlar"] = 2 -- Half health damage when blocking sharp melee, but stamina damage still applies
PERKS[CAT_PHYSICAL]["tacticalgloves"] = 2 -- Switch weapons faster
PERKS[CAT_PHYSICAL]["platecarrier"] = 3 -- More inventory slots (+2?)
PERKS[CAT_PHYSICAL]["lightweight"] = 3 -- Aim down sights faster.
PERKS[CAT_TRAINING]["freerunner"] = 1 -- Faster movement, shorter cooldowns, quicker movement actions.
PERKS[CAT_TRAINING]["legday"] = 1 -- Higher vaulting & jumping.
PERKS[CAT_TRAINING]["readyup"] = 1 -- Weapon is ready faster after sprinting
PERKS[CAT_TRAINING]["hitman"] = 2 -- Take down enemies without revealing their location
PERKS[CAT_TRAINING]["athletic"] = 2 -- Infinite sprint
PERKS[CAT_TRAINING]["counters"] = 3 -- Perfect blocks on melee damage stuns enemies.
PERKS[CAT_OPERATIONAL]["blindeye"] = 1 -- Enemy electronics take much longer to spot you.
PERKS[CAT_OPERATIONAL]["scavenger"] = 1 -- Replenish ammo from enemy corpses.
PERKS[CAT_OPERATIONAL]["deadsilence"] = 2 -- Move almost quietly.
PERKS[CAT_OPERATIONAL]["blastresponse"] = 2 -- Enemies damaged by explosions show up on radar.
PERKS[CAT_OPERATIONAL]["offthegrid"] = 3 -- Don't show up on radar
PERKS[CAT_OPERATIONAL]["wiretap"] = 3 -- Hack into enemy equipment

View File

@ -0,0 +1,78 @@
-- Audio & caption system
CAPTIONS = {}
CAPTIONS["en-us"] = {}
function RegisterCaption( Name, Subject, Color, Text, TypeTime, LifeTime, Bold, Italic )
CAPTIONS["en-us"][Name] = {
Name = Subject,
Color = Color,
Text = Text,
TypeTime = TypeTime,
LifeTime = LifeTime,
Bold = Bold,
Italic = Italic,
}
end
RegisterCaption("1911.Fire", "Cobra .45", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("1911.Reload", "Cobra .45", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("Bizon.Fire", "Bizon", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("Bizon.Reload", "Bizon", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("TMP.Fire", "TMP", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("TMP.Reload", "TMP", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("USP.Fire", "USP", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("USP.Reload", "USP", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("Glock.Fire", "Glock", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("Glock.Reload", "Glock", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("MP5K.Fire", "MP5K", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("MP5K.Reload", "MP5K", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("MAC11.Fire", "MAC11", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("MAC11.Reload", "MAC11", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("MP7.Fire", "MP7", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("MP7.Reload", "MP7", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("Anaconda.Fire", "Anaconda", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("Anaconda.Reload", "Anaconda", color_white, "[reload]", 0.1, 0.5, false, true )
RegisterCaption("Nambu.Fire", "Nambu", color_white, "[fire]", 0.1, 0.5, false, true )
RegisterCaption("Nambu.Reload", "Nambu", color_white, "[reload]", 0.1, 0.5, false, true )
SOUNDS = {}
function AddSound( name, path, sndlevel, pitch, volume, channel )
SOUNDS[name] = {
path = path,
sndlevel = sndlevel or 70,
pitch = pitch or 100,
volume = volume or 1,
channel = channel or CHAN_STATIC,
}
end
local screwup = SERVER and Color(150, 255, 255) or Color(255, 200, 150)
function B_Sound( ent, tag )
if !tag then return end
local tagt = SOUNDS[tag]
if !tagt then MsgC( screwup, "Invalid sound " .. tag .. "\n" ) return end
local path, sndlevel, pitch, volume, channel = tagt.path, tagt.sndlevel, tagt.pitch, tagt.volume, tagt.channel
if istable( path ) then
path = path[math.Round(util.SharedRandom( "B_Sound", 1, #path ))]
end
ent:EmitSound( path, sndlevel, pitch, volume, channel )
if CLIENT and IsFirstTimePredicted() then
if CAPTIONS[tag] then
local capt = CAPTIONS[tag]
AddCaption( capt.Name, capt.Color, capt.Text, capt.TypeTime, capt.LifeTime )
else
MsgC( screwup, "No caption defined for " .. tag .. "\n" )
end
end
end
RegisterCaption("Common.Deploy", "DEBUG", color_white, "[deploy]", 0.1, 0.5, false, true )
RegisterCaption("Common.Holster", "DEBUG", color_white, "[holster]", 0.1, 0.5, false, true )
RegisterCaption("Common.ReloadFail", "DEBUG", color_white, "[fail]", 0.1, 0.5, false, true )
CAPTIONS = CAPTIONS["en-us"]

View File

@ -0,0 +1,10 @@
local UUID_chars = "0123456789ABCDEF"
function UUID_generate()
local str = ""
for i=1, 8 do
str = str .. UUID_chars[ math.random( 1, #UUID_chars ) ]
end
return str
end

View File

@ -0,0 +1,93 @@
-- Meanings: Default, Min, Max, Replicated, Archived, Hint
-- Replicated is Userinfo in Client.
CONVARS_SV = {}
CONVARS_SV["cam_override"] = { "", nil, nil, true, false, "X Y Z P Y R FOV" }
CONVARS_SV["cam_unlock"] = { 0, 0, 1, true, false, "First person (sort of)" }
CONVARS_SV["net_easyway"] = { 0, 0, 1, true, false, "Use a disgusting way of networking inventories for minimal desync." }
CONVARS_SV["cheat_infiniteammo"] = { 0, 0, 1, true, false, "Cheat: Don't expend ammo." }
CONVARS_SV["tempchar"] = { "benny", nil, nil, true, false, "Temporary character." }
CONVARS_SV_GEN = {}
for i, v in pairs( CONVARS_SV ) do
CONVARS_SV_GEN[i] = CreateConVar( "benny_" .. i, v[1], (v[4] and FCVAR_REPLICATED or 0) + (v[5] and FCVAR_ARCHIVE or 0), v[6], v[2], v[3] )
end
function ConVarSV( name )
return CONVARS_SV_GEN[name]
end
function ConVarSV_Bool( name )
return ConVarSV( name ):GetBool()
end
function ConVarSV_String( name )
return ConVarSV( name ):GetString()
end
function ConVarSV_Int( name )
return ConVarSV( name ):GetInt()
end
function ConVarSV_Float( name )
return ConVarSV( name ):GetFloat()
end
if CLIENT then -- CL CL CL
CONVARS_CL = {}
CONVARS_CL["hud_scale"] = { 2, 1, 4, false, true, "HUD integer scaling" }
CONVARS_CL["hud_tempactive"] = { "benny", nil, nil, false, true, "HUD color scheme temporary" }
CONVARS_CL["hud_enable_health"] = { 1, nil, nil, false, true, "Draw Health panel" }
CONVARS_CL["hud_enable_hotbar"] = { 1, nil, nil, false, true, "Draw Hotbar panel" }
CONVARS_CL["hud_enable_active"] = { 1, nil, nil, false, true, "Draw Active Weapons panel" }
CONVARS_CL["hud_enable_hints"] = { 1, nil, nil, false, true, "Draw Hints panel" }
CONVARS_CL["wep_toggleaim"] = { 1, 0, 1, true, true, "Hold or toggle to aim weapon." }
CONVARS_CL["wep_ao_firearms"] = { 1, 0, 1, true, true, "Whether offhand firearms overrides primary attack." }
CONVARS_CL["wep_ao_grenades"] = { 0, 0, 1, true, true, "Whether offhand grenades overrides primary attack." }
CONVARS_CL["wep_ao_junk"] = { 0, 0, 1, true, true, "Whether offhand junk overrides primary attack." }
CONVARS_CL["wep_toolgun"] = { "", nil, nil, true, true, "Toolgun tool." }
CONVARS_CL["cam_override"] = { "", nil, nil, false, true, "Override camera" }
CONVARS_CL["cam_unlock"] = { 0, 0, 1, false, false, "Unlock camera" }
CONVARS_CL["bind2_reload"] = { KEY_R, nil, nil, true, true, "Bind for Reload" }
CONVARS_CL["bind2_reloada"] = { KEY_T, nil, nil, true, true, "Bind for ReloadAlt" }
CONVARS_CL_GEN = {}
for i, v in pairs( CONVARS_CL ) do
CONVARS_CL_GEN[i] = CreateConVar( "benny_" .. i, v[1], (v[4] and FCVAR_USERINFO or 0) + (v[5] and FCVAR_ARCHIVE or 0), v[6], v[2], v[3] )
end
function ConVarCL( name )
return CONVARS_CL_GEN[name]
end
function ConVarCL_Bool( name )
return ConVarCL( name ):GetBool()
end
function ConVarCL_String( name )
return ConVarCL( name ):GetString()
end
function ConVarCL_Int( name )
return ConVarCL( name ):GetInt()
end
function ConVarCL_Float( name )
return ConVarCL( name ):GetFloat()
end
end -- CL end CL end CL end

View File

@ -0,0 +1,416 @@
-- Deadeye Choreographer
local function QUICKDIRT( self, w, h, no_bg )
if !no_bg then
local r, g, b = schemes["benny"]["bg"]:Unpack()
surface.SetDrawColor( r, g, b, 200 )
surface.DrawRect( 0, 0, w, h )
end
surface.SetDrawColor( schemes["benny"]["fg"] )
surface.DrawOutlinedRect( 0, 0, w, h, 1 )
end
local function QUICKEARTH( self, w, h )
local r, g, b = schemes["benny"]["fg"]:Unpack()
surface.SetDrawColor( r, g, b, 200 )
surface.DrawRect( 0, 0, w, h )
end
local function QUICKNIL( self, w, h )
end
local FIRST = {
"left_lowerer",
"left_outer_raiser",
"left_inner_raiser",
"left_cheek_puffer",
"left_cheek_raiser",
"left_lid_closer",
"left_lid_droop",
"left_lid_raiser",
"left_lid_tightener",
"left_mouth_drop",
"left_upper_raiser",
"left_dimpler",
"left_funneler",
"left_part",
"left_puckerer",
"left_stretcher",
"left_corner_depressor",
"left_corner_puller",
}
local SECOND = {
"jaw_clencher",
"jaw_drop",
"jaw_sideways",
"lip_bite",
"lower_lip",
"presser",
"tightener",
"wrinkler",
"dilator",
"bite",
"blink",
"half_closed",
"chin_raiser",
"mouth_sideways",
"sneer_left",
"body_rightleft",
"chest_rightleft",
"eyes_rightleft",
"eyes_updown",
"gesture_rightleft",
"gesture_updown",
"head_forwardback",
"head_rightleft",
"head_tilt",
"head_updown",
}
local SIDE_L = {
["left_cheek_puffer"] = "right_cheek_puffer",
["left_cheek_raiser"] = "right_cheek_raiser",
["left_corner_depressor"] = "right_corner_depressor",
["left_corner_puller"] = "right_corner_puller",
["left_lid_closer"] = "right_lid_closer",
["left_lid_droop"] = "right_lid_droop",
["left_lid_raiser"] = "right_lid_raiser",
["left_lid_tightener"] = "right_lid_tightener",
["left_upper_raiser"] = "right_upper_raiser",
["left_outer_raiser"] = "right_outer_raiser",
["left_inner_raiser"] = "right_inner_raiser",
["left_mouth_drop"] = "right_mouth_drop",
["left_dimpler"] = "right_dimpler",
["left_funneler"] = "right_funneler",
["left_part"] = "right_part",
["left_puckerer"] = "right_puckerer",
["left_stretcher"] = "right_stretcher",
["left_lowerer"] = "right_lowerer",
}
local SIDE_R = {
["right_cheek_puffer"] = "left_cheek_puffer",
["right_cheek_raiser"] = "left_cheek_raiser",
["right_corner_depressor"] = "left_corner_depressor",
["right_corner_puller"] = "left_corner_puller",
["right_lid_closer"] = "left_lid_closer",
["right_lid_droop"] = "left_lid_droop",
["right_lid_raiser"] = "left_lid_raiser",
["right_lid_tightener"] = "left_lid_tightener",
["right_upper_raiser"] = "left_upper_raiser",
["right_outer_raiser"] = "left_outer_raiser",
["right_inner_raiser"] = "left_inner_raiser",
["right_mouth_drop"] = "left_mouth_drop",
["right_dimpler"] = "left_dimpler",
["right_funneler"] = "left_funneler",
["right_part"] = "left_part",
["right_puckerer"] = "left_puckerer",
["right_stretcher"] = "left_stretcher",
["right_lowerer"] = "left_lowerer",
}
local PRETTY = {
["left_outer_raiser"] = "Brow Outer Raiser",
["left_inner_raiser"] = "Brow Inner Raiser",
["left_lowerer"] = "Brow Lowerer",
["left_cheek_puffer"] = "Cheek Puffer",
["left_cheek_raiser"] = "Cheek Raiser",
["left_lid_closer"] = "Lid Closer",
["left_lid_droop"] = "Lid Droop",
["left_lid_raiser"] = "Lid Raiser",
["left_lid_tightener"] = "Lid Tightener",
["left_mouth_drop"] = "Mouth Drop",
["left_upper_raiser"] = "Lip Upper Raiser",
["left_dimpler"] = "Lip Dimpler",
["left_funneler"] = "Lip Funneler",
["left_part"] = "Lip Part",
["left_puckerer"] = "Lip Puckerer",
["left_stretcher"] = "Lip Stretcher",
["left_corner_depressor"] = "Lip Corner Depr.",
["left_corner_puller"] = "Lip Corner Puller",
["right_outer_raiser"] = "Brow Outer Raiser",
["right_inner_raiser"] = "Brow Inner Raiser",
["right_lowerer"] = "Brow Lowerer",
["right_cheek_puffer"] = "Cheek Puffer",
["right_cheek_raiser"] = "Cheek Raiser",
["right_lid_closer"] = "Lid Closer",
["right_lid_droop"] = "Lid Droop",
["right_lid_raiser"] = "Lid Raiser",
["right_lid_tightener"] = "Lid Tightener",
["right_mouth_drop"] = "Mouth Drop",
["right_upper_raiser"] = "Lip Upper Raiser",
["right_dimpler"] = "Lip Dimpler",
["right_funneler"] = "Lip Funneler",
["right_part"] = "Lip Part",
["right_puckerer"] = "Lip Puckerer",
["right_stretcher"] = "Lip Stretcher",
["right_corner_depressor"] = "Lip Corner Depr.",
["right_corner_puller"] = "Lip Corner Puller",
["jaw_clencher"] = "Jaw Clencher",
["jaw_drop"] = "Jaw Drop",
["jaw_sideways"] = "Jaw Sideways",
["lip_bite"] = "Lip Bite",
["lower_lip"] = "Lip Lower Depr.",
["presser"] = "Lip Presser",
["tightener"] = "Lip Tightener",
["wrinkler"] = "Nose Wrinkler",
["dilator"] = "Nose Dilator",
["bite"] = "Bite",
["blink"] = "Blink",
["half_closed"] = "Half Closed",
["chin_raiser"] = "Chin Raiser",
["mouth_sideways"] = "Mouth Sideways",
["sneer_left"] = "Sneer Left",
["body_rightleft"] = "Body Rightleft",
["chest_rightleft"] = "Chest Rightleft",
["eyes_rightleft"] = "Eyes Rightleft",
["eyes_updown"] = "Eyes Updown",
["gesture_rightleft"] = "Gesture Rightleft",
["gesture_updown"] = "Gesture Updown",
["head_forwardback"] = "Head Forwardback",
["head_rightleft"] = "Head Rightleft",
["head_tilt"] = "Head Tilt",
["head_updown"] = "Head Updown",
}
local function makeme( id, parent, ent, no_dock )
local SLIDER = parent:Add( "DNumSlider" )
SLIDER:SetText( PRETTY[ ent:GetFlexName( id ) ] or ent:GetFlexName( id ) )
local min, max = ent:GetFlexBounds( id )
SLIDER:SetMin( min )
SLIDER:SetMax( max )
SLIDER:SetDecimals( 2 )
SLIDER:SetTall( 18 )
if !no_dock then
SLIDER:Dock( TOP )
SLIDER:DockMargin( 10, 0, 10, 0 )
end
SLIDER.Label:SetWide( 90 )
function SLIDER:PerformLayout() return end
function SLIDER:OnValueChanged( val )
if !DEADEYE_MEM.Flex then DEADEYE_MEM.Flex = {} end
DEADEYE_MEM.Flex[ ent:GetFlexName( id ) ] = val
end
function SLIDER:Think()
if DEADEYE_MEM.Flex then
self:SetValue( DEADEYE_MEM.Flex[ ent:GetFlexName( id ) ] )
end
end
return SLIDER
end
DEADEYE_MEM = DEADEYE_MEM or {}
function OpenDeadeye()
if IsValid( GOD ) then GOD:Remove() end
GOD = vgui.Create( "DFrame" )
GOD:SetTitle( "Deadeye Choreographer" )
GOD:SetSize( ScrW()*0.9, ScrH()*0.9 )
GOD:Center()
GOD:MakePopup()
GOD:SetSizable( true )
GOD.Paint = QUICKDIRT
do -- Menubar
local MENUBAR = GOD:Add( "DMenuBar" )
MENUBAR:Dock( TOP )
MENUBAR:DockMargin( -5, -5, -5, 8 )
MENUBAR.Paint = QUICKDIRT
local MENU_FILE = MENUBAR:AddMenu( "File" )
MENU_FILE:AddOption( "New", function() table.Empty( DEADEYE_MEM ) OpenDeadeye() end )
MENU_FILE:AddOption( "Open", function() end )
local MENU_EDIT = MENUBAR:AddMenu( "Edit" )
local MENU_ABOUT = MENUBAR:AddMenu( "About" )
end
local NAME = {
"X",
"Y",
"Z",
"P",
"Y",
"R",
}
do -- Main
local MAIN = GOD:Add( "DPanel" )
MAIN:Dock( FILL )
MAIN.Paint = QUICKNIL
local SIDE_MODEL = MAIN:Add( "DPanel" )
SIDE_MODEL.Paint = QUICKNIL
local SIDE_CHOREO = MAIN:Add( "DPanel" )
SIDE_CHOREO.Paint = QUICKDIRT
local SIDEDIV = MAIN:Add( "DVerticalDivider" )
SIDEDIV:Dock( FILL )
SIDEDIV:SetTop( SIDE_MODEL )
SIDEDIV:SetBottom( SIDE_CHOREO )
SIDEDIV:SetDividerHeight( 8 )
SIDEDIV:SetTopMin( 20 )
SIDEDIV:SetBottomMin( 240 )
SIDEDIV:SetTopHeight( 500 )
do -- Model side (top)
local MODEL = SIDE_MODEL:Add( "DAdjustableModelPanel" )
MODEL:SetFOV( 30 )
MODEL:SetModel( "models/alyx.mdl" )
MODEL:SetLookAng( Angle( 0, 180, 0 ) )
MODEL:SetCamPos( Vector( 64, 0, 64 ) )
function MODEL:LayoutEntity( Entity )
if DEADEYE_MEM.Flex then
for i=0, Entity:GetFlexNum()-1 do
if !DEADEYE_MEM.Flex[ Entity:GetFlexName( i ) ] then continue end
Entity:SetFlexWeight( i, DEADEYE_MEM.Flex[ Entity:GetFlexName( i ) ] )
end
else
DEADEYE_MEM.Flex = {}
for i=0, Entity:GetFlexNum()-1 do
DEADEYE_MEM.Flex[ Entity:GetFlexName( i ) ] = 0--Entity:GetFlexWeight( i )
end
end
self.Entity:SetEyeTarget( self:GetCamPos() )
return
end
function MODEL:PaintOver( w, h )
QUICKDIRT( self, w, h, true )
local fuckp, fucka = MODEL:GetCamPos(), MODEL:GetLookAng()
local PX, PY, PZ, AP, AY, AR = fuckp.x, fuckp.y, fuckp.z, fucka.p, fucka.y, fucka.r
PX, PY, PZ, AP, AY, AR = math.Round( PX ), math.Round( PY ), math.Round( PZ ), math.Round( AP ), math.Round( AY ), math.Round( AR )
draw.SimpleText( "pos: " .. PX .. " " .. PY .. " " .. PZ, "Trebuchet24", 8, 4, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( "ang: " .. AP .. " " .. AY .. " " .. AR, "Trebuchet24", 8, 4+24, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( "fov: " .. math.Round( MODEL:GetFOV() ), "Trebuchet24", 8, 4+48, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
end
local MODELPSHEET = SIDE_MODEL:Add( "DPropertySheet" )
MODELPSHEET.Paint = QUICKDIRT
local MODELSETTINGS = SIDE_MODEL:Add( "DScrollPanel" )
MODELSETTINGS.Paint = QUICKDIRT
MODELPSHEET:AddSheet( "Actor Alyx", MODELSETTINGS )
local flexlist = {}
for i=0, MODEL.Entity:GetFlexNum()-1 do -- Model settings
flexlist[MODEL.Entity:GetFlexName( i )] = true
end
local madelist = {}
local MARKF = MODELSETTINGS:Add( "DHorizontalDivider" )
MARKF:Dock( TOP )
MARKF:DockMargin( 130, 0, -140, 0 )
MARKF:SetDividerWidth( 0 )
local LABELR = MODELSETTINGS:Add("DLabel")
LABELR:SetText( "Right" )
local LABELL = MODELSETTINGS:Add("DLabel")
LABELL:SetText( "Left" )
MARKF:SetLeft( LABELR )
MARKF:SetRight( LABELL )
local old = MARKF.PerformLayout
function MARKF:PerformLayout( w, h )
self:SetLeftWidth( w / 2 )
old( self, w, h )
end
for v, i in ipairs( FIRST ) do
local MARK = MODELSETTINGS:Add( "DHorizontalDivider" )
MARK:Dock( TOP )
MARK:DockMargin( 10, -4, 10, -4 )
MARK:SetDividerWidth( 0 )
local SLIDERA = makeme( MODEL.Entity:GetFlexIDByName( SIDE_L[i] ), MODELSETTINGS, MODEL.Entity, true )
local SLIDERB = makeme( MODEL.Entity:GetFlexIDByName( i ), MODELSETTINGS, MODEL.Entity, true )
madelist[SIDE_L[i]] = true
madelist[i] = true
MARK:SetLeft( SLIDERA )
MARK:SetRight( SLIDERB )
local old = MARK.PerformLayout
function MARK:PerformLayout( w, h )
self:SetLeftWidth( w / 2 )
old( self, w, h )
end
end
for v, i in SortedPairs( SECOND ) do
if !madelist[i] then
local id = MODEL.Entity:GetFlexIDByName( i )
makeme( id, MODELSETTINGS, MODEL.Entity )
madelist[i] = true
end
end
for i, v in SortedPairs( flexlist ) do
if !madelist[i] then
local id = MODEL.Entity:GetFlexIDByName( i )
makeme( id, MODELSETTINGS, MODEL.Entity )
madelist[i] = true
end
end
local DIVIDER = SIDE_MODEL:Add( "DHorizontalDivider" )
DIVIDER:Dock( FILL )
DIVIDER:SetLeft( MODEL )
DIVIDER:SetRight( MODELPSHEET )
DIVIDER:SetDividerWidth( 8 )
DIVIDER:SetLeftMin( 20 )
DIVIDER:SetRightMin( 240 )
DIVIDER:SetLeftWidth( 800 )
end
do -- Choreo side (bottom)
local PLAY = SIDE_CHOREO:Add( "DButton" )
PLAY:SetPos( 4, 4 )
PLAY:SetSize( 80, 20 )
PLAY:SetText( "Play/Pause" )
PLAY.Paint = QUICKDIRT
local SPEED = SIDE_CHOREO:Add( "DNumSlider" )
SPEED:SetPos( 4+4+80, 4 )
SPEED:SetSize( 180, 20 )
SPEED:SetText( "Speed" )
SPEED.Label:SetWide( 0 )
function SPEED:PerformLayout()
return true
end
SPEED:SetMin( 0 )
SPEED:SetMax( 100 )
SPEED:SetValue( 100 )
SPEED:SetDecimals( 0 )
SPEED.Paint = QUICKDIRT
do
local BLINKY = SIDE_CHOREO:Add( "DPanel" )
BLINKY:SetPos( 4, 4+4+20 )
BLINKY.Paint = QUICKDIRT
function BLINKY:PerformLayout( w, h )
local par = SIDE_CHOREO
BLINKY:SetSize( par:GetWide() - 8, par:GetTall() - 20 - 12 )
end
end
end
end
end
if IsValid( GOD ) then OpenDeadeye() end
concommand.Add("benny_ui_deadeye", function()
OpenDeadeye()
end)

View File

@ -0,0 +1,189 @@
-- Dev inventory
local function regen_items( itemlist )
local ply = LocalPlayer()
local inv = ply:INV_Get()
local active = GetConVar("benny_hud_tempactive"):GetString()
itemlist:Clear()
local maidlist = {}
local catesmade = {}
for i, v in pairs( ply:INV_ListFromBuckets() ) do
local class = inv[v].Class
local Class = WeaponGet(class)
if !catesmade[Class.Category] then
catesmade[Class.Category] = true
local cate = vgui.Create( "DButton" )
itemlist:AddItem( cate )
cate:SetSize( 1, ss(12) )
cate:Dock( TOP )
cate:DockMargin( 0, 0, 0, ss(2) )
cate.Text_Name = Class.Category
function cate:Paint( w, h )
surface.SetDrawColor( schemes[active]["bg"] )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( schemes[active]["fg"] )
surface.DrawOutlinedRect( 0, 0, w, h, ss(0.5) )
surface.SetTextColor( schemes[active]["fg"] )
surface.SetFont( "Benny_10" )
surface.SetTextPos( ss(2), ss(2) )
surface.DrawText( self.Text_Name )
return true
end
end
local button = vgui.Create( "DButton" )
itemlist:AddItem( button )
button:SetSize( 1, ss(24) )
button:Dock( TOP )
button:DockMargin( 0, 0, 0, ss(2) )
button.ID = v
local mag = false
if class:Left( 4 ) == "mag_" then
mag = true
button:SetTall( ss(11) )
end
if !maidlist[class] then
maidlist[class] = table.Flip( ply:INV_Find( class ) )
end
local ml = maidlist[class]
button.Text_Name = Class.Name
button.Text_Desc = Class.Description
button.Text_ID = "[" .. ml[v] .. "] " .. button.ID
-- PROTO: These functions don't need to be remade over and over like this.
function button:DoClick()
do return end
local Menu = DermaMenu()
local opt1 = Menu:AddOption( "Equip Right", function()
RunConsoleCommand( "benny_inv_equip", button.ID, "false" )
end)
opt1:SetIcon( "icon16/resultset_last.png" )
local opt3 = Menu:AddOption( "Equip Right, Move Left", function()
RunConsoleCommand( "benny_inv_equip", button.ID, "false", "true" )
end)
opt3:SetIcon( "icon16/resultset_next.png" )
Menu:AddSpacer()
local opt2 = Menu:AddOption( "Equip Left", function()
RunConsoleCommand( "benny_inv_equip", button.ID, "true" )
end)
opt2:SetIcon( "icon16/resultset_first.png" )
local opt4 = Menu:AddOption( "Equip Left, Move Right", function()
RunConsoleCommand( "benny_inv_equip", button.ID, "true", "true" )
end)
opt4:SetIcon( "icon16/resultset_previous.png" )
Menu:AddSpacer()
local opt5 = Menu:AddOption( "Holster", function()
RunConsoleCommand( "benny_inv_holster", button.ID )
end)
opt5:SetIcon( "icon16/control_pause_blue.png" )
local opt6 = Menu:AddOption( "Discard", function()
RunConsoleCommand("benny_inv_discard", button.ID)
self:Remove()
end)
opt6:SetIcon( "icon16/bin.png" )
Menu:Open()
-- timer.Simple( 0.1, function() if IsValid( itemlist ) then regen_items( itemlist ) end end )
end
button.DoRightClick = function( self )
do return end
RunConsoleCommand("benny_inv_discard", button.ID)
self:Remove()
end
function button:Paint( w, h )
surface.SetDrawColor( schemes[active]["fg"] )
surface.DrawRect( 0, 0, w, h )
surface.SetTextColor( schemes[active]["bg"] )
surface.SetFont( !mag and "Benny_16" or "Benny_10" )
surface.SetTextPos( ss(2), ss(2) )
surface.DrawText( self.Text_Name )
if !mag then
surface.SetFont( "Benny_12" )
surface.SetTextPos( ss(2), ss(2 + 11) )
surface.DrawText( self.Text_Desc )
end
local wep = ply:BennyCheck()
if wep then
local handed_r = wep:bGetInvID( false ) == v
local handed_l = wep:bGetInvID( true ) == v
if handed_r or handed_l then
draw.SimpleText( handed_l and "LEFT" or "RIGHT", "Benny_18", w/2, h/2 + ss(1), schema_c("bg"), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
end
surface.SetFont( "Benny_10" )
local tx = surface.GetTextSize( self.Text_ID )
surface.SetTextPos( w - ss(2) - tx, ss(2) )
surface.DrawText( self.Text_ID )
return true
end
button.B = button:Add("DButton")
button.B:Dock( RIGHT )
function button.B:DoClick()
button:Remove()
return RunConsoleCommand( "benny_inv_discard", button.ID )
end
function button.B:Paint( w, h )
surface.SetDrawColor( schema( "fg" ) )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( schema( "bg" ) )
surface.DrawOutlinedRect( 0, 0, w, h, ss(1) )
draw.SimpleText( "DISCARD", "Benny_10", w/2, h/2 + ss(1), schema_c("bg"), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
return true
end
button.B:DockMargin( ss(2), ss(2), ss(2), ss(2) )
button.B:SetSize( ss(36), ss(24) )
function button:Think()
local visible = self.B:IsHovered() or self:IsHovered()
self.B:SetVisible( visible )
end
end
end
function OpenDebugInv()
if IsValid( base ) then base:Remove() return end
base = vgui.Create("BFrame")
base:SetSize( ss(400), ss(400) )
base:SetTitle("Developer Inventory")
base:MakePopup()
base:SetKeyboardInputEnabled( false )
base:Center()
local itemlist = base:Add("DScrollPanel")
itemlist:Dock( FILL )
regen_items( itemlist )
end
concommand.Add("benny_ui_inv", function()
OpenDebugInv()
end)

View File

@ -0,0 +1,2 @@
-- Final inventory customizer for MP

View File

@ -0,0 +1,97 @@
-- Main menu
local meow = {
"RESUME",
"",
"START GAME",
"LOAD GAME",
"",
"JOIN SERVER",
"START SERVER",
"",
"OPTIONS",
"QUIT",
}
local function unimplemented()
if mb and mb:IsValid() then mb:Remove() end
mb = vgui.Create( "BFrame" )
mb:SetSize( ss(160), ss(50) )
mb:Center()
mb:MakePopup()
mb:SetTitle( "Woops!" )
local oldpaint = mb.Paint
function mb:Paint( w, h )
oldpaint( self, w, h )
surface.SetDrawColor( schema("fg") )
surface.DrawOutlinedRect( 0, 0, w, h, ss(1) )
draw.SimpleText( "That isn't implemented yet.", "Benny_12", w/2, ss(18), schema_c("fg"), TEXT_ALIGN_CENTER )
end
local okbutton = mb:Add("DButton")
okbutton:SetText("")
okbutton:SetSize( ss(30), ss(12) )
okbutton:SetPos( mb:GetWide()/2 - okbutton:GetWide()/2, mb:GetTall() - okbutton:GetTall() - ss(6) )
function okbutton:Paint( w, h )
surface.SetDrawColor( schema("bg") )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( schema("fg") )
surface.DrawOutlinedRect( 0, 0, w, h, ss(1) )
draw.SimpleText( "OK", "Benny_10", w/2, ss(2), schema_c("fg"), TEXT_ALIGN_CENTER )
end
function okbutton:DoClick()
mb:Remove()
end
end
function CreateMainMenu()
if mm and mm:IsValid() then mm:Remove() end
mm = vgui.Create( "BFrame" )
mm:SetSize( ScrW(), ScrH() )
mm:Center()
mm:MakePopup()
mm:SetPopupStayAtBack( true )
mm:SetTitle("Main Menu")
local oldpaint = mm.Paint
function mm:Paint( w, h )
oldpaint( self, w, h )
draw.SimpleText( "YOUR", "Benny_48", ss(34), self:GetTall()/2 - ss(54 + (28*3)), schema_c("fg") )
draw.SimpleText( "NAME", "Benny_48", ss(34), self:GetTall()/2 - ss(54 + (28*2)), schema_c("fg") )
draw.SimpleText( "IS", "Benny_48", ss(34), self:GetTall()/2 - ss(54 + (28*1)), schema_c("fg") )
draw.SimpleText( "BENNY", "Benny_72", ss(32), self:GetTall()/2 - ss(58 + (28*0)), schema_c("fg") )
end
local bump = -ss(32)
for i=#meow, 1, -1 do
local label = meow[i]
local spacer = label == ""
local button = mm:Add("DButton")
button:SetText("")
button:SetSize( ss(256), ss(spacer and 0 or 16) )
button:SetPos( ss(32), mm:GetTall() + ss(bump) )
function button:Paint( w, h )
if !spacer then
surface.SetDrawColor( schema("bg") )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( schema("fg") )
surface.DrawOutlinedRect( 0, 0, w, h, ss(0.5) )
draw.SimpleText( label, "Benny_16", ss(4+16), ss(2), schema_c("fg") )
end
end
button.DoClick = unimplemented
bump = bump - (spacer and 12 or (16+4))
end
end
concommand.Add("benny_ui_mainmenu", function()
CreateMainMenu()
end)

View File

@ -0,0 +1,142 @@
-- Settings panel
-- 0 = checkbox, 1 = slider, 2 = string, 3 = binder
local conf = {
[1] = {
{ 0, "benny_hud_enable_health", "Health", },
{ 0, "benny_hud_enable_active", "Active Weapon", },
{ 0, "benny_hud_enable_hints", "Hints", },
{ 0, "benny_hud_enable_hotbar", "Hotbar", },
{ 1, "benny_hud_scale", "Scale", 1, 4, 0 },
},
[2] = {
{ 0, "benny_wep_ao_firearms", "Firearms Override Primary Attack" },
{ 2, "Like traditional akimbo, pressing Left Mouse will shoot an offhand firearm." },
{ 0, "benny_wep_ao_grenades", "Grenades Override Primary Attack" },
{ 2, "Pressing Left Mouse will throw an offhand grenade." },
{ 0, "benny_wep_ao_junk", "Junk Overrides Primary Attack" },
{ 2, "Pressing Left Mouse will throw offhand junk." },
{ 3, "benny_bind_reload", "Reload" },
{ 3, "benny_bind_reloada", "Reload Alt" },
},
[3] = {
{ 4, function( Scroll )
local Butt = Scroll:Add("DLabel")
Butt:Dock(TOP)
Butt:DockMargin( ss(24+4), 0, 0, 0 )
Butt:SetText( "Character Appearance" )
local Down = Scroll:Add("DComboBox")
Down:Dock( TOP )
Down:DockMargin( ss(24), 0, ss(24), ss(2) )
Down:SetValue( ConVarSV_String("tempchar") )
Down:AddChoice( "Benny", "benny" )
Down:AddChoice( "Nikki", "nikki" )
Down:AddChoice( "Igor", "igor" )
Down:AddChoice( "Yang-Hao", "yanghao" )
Down:AddChoice( "z: CIA", "mp_cia" )
Down:AddChoice( "z: PLASOF", "mp_plasof" )
Down:AddChoice( "z: MILITIA", "mp_militia" )
Down:AddChoice( "z: ARNG", "mp_natguard" )
Down:AddChoice( "z: VIPER", "mp_viper" )
Down:AddChoice( "z: HALO", "mp_halo" )
function Down:OnSelect( index, value, data )
RunConsoleCommand( "benny_tempchar", data )
RunConsoleCommand( "benny_hud_tempactive", data )
end
end },
},
}
local function genpan( Base, Sect, Conf )
local Scroll = Base:Add("DPanel")
Scroll:DockPadding( 10, 5, 10, 5 )
Scroll.Paint = function() end
Sect:SetContents( Scroll )
for i, v in ipairs( Conf ) do
if v[1] == 0 then
local Butt = Scroll:Add("DCheckBoxLabel")
Butt:Dock(TOP)
Butt:DockMargin( 0, ss(2), 0, ss(2) )
Butt:SetText( v[3] )
Butt:SetConVar( v[2] )
elseif v[1] == 1 then
local Butt = Scroll:Add("DNumSlider")
Butt:Dock(TOP)
Butt:DockMargin( 0, ss(2), 0, ss(2) )
Butt:SetText( v[3] )
Butt:SetConVar( v[2] )
Butt:SetMin( v[4] )
Butt:SetMax( v[5] )
Butt:SetDecimals( v[6] )
elseif v[1] == 2 then
local Butt = Scroll:Add("DLabel")
Butt:Dock(TOP)
Butt:DockMargin( ss(12), ss(-4), 0, 0 )
Butt:SetText( v[2] )
elseif v[1] == 3 then
local Butt = Scroll:Add("DLabel")
Butt:Dock(TOP)
Butt:DockMargin( ss(24+4), 0, 0, 0 )
Butt:SetText( v[3] )
local Butt = Scroll:Add("DBinder")
Butt:Dock(TOP)
Butt:DockMargin( ss(24), 0, ss(24), ss(2) )
Butt:SetText( v[2] )
function Butt:OnChange( num )
RunConsoleCommand( v[2], num )
end
elseif v[1] == 4 then
v[2]( Scroll )
end
end
end
function OpenSettingsMenu()
if IsValid( SettingsMenu ) then SettingsMenu:Remove() return end
local Base = vgui.Create("BFrame")
SettingsMenu = Base
Base:SetTitle("Settings")
Base:SetSize( ss(300), ss(300) )
Base:Center()
Base:MakePopup()
Base:SetKeyboardInputEnabled( false )
do -- Sect 1
local Sect = Base:Add("BCollapsibleCategory")
Sect:Dock(TOP)
Sect:DockMargin( 0, 0, 0, ss(2) )
Sect:SetLabel("HUD")
genpan( Base, Sect, conf[1] )
end
do -- Sect 2
local Sect = Base:Add("BCollapsibleCategory")
Sect:Dock(TOP)
Sect:DockMargin( 0, 0, 0, ss(2) )
Sect:SetLabel("Controls")
genpan( Base, Sect, conf[2] )
end
do -- Sect 3
local Sect = Base:Add("BCollapsibleCategory")
Sect:Dock(TOP)
Sect:DockMargin( 0, 0, 0, ss(2) )
Sect:SetLabel("Preferences")
genpan( Base, Sect, conf[3] )
end
end
concommand.Add("benny_ui_settings", function()
OpenSettingsMenu()
end)

View File

@ -0,0 +1,529 @@
-- Dev spawnmenu
function GM:OnSpawnMenuOpen()
end
function GM:OnSpawnMenuClose()
end
local function yea()
return true
end
local function rmt1( val, min, max )
return math.Remap( val, min, max, 0, 1 )
end
local function rmt1c( val, min, max )
return math.Clamp( rmt1( val, min, max, 0, 1 ), 0, 1 )
end
local mewer = {
{
Func = function( class )
return class.Name
end,
Size = 18,
SizeMultiline = 18,
Font = "Benny_18",
},
{
Func = function( class )
return class.Description
end,
Size = 14,
SizeMultiline = 12,
Font = "Benny_12",
-- "How easily and quickly the weapon can take out a single target.\nDoes not consider armor penetration.\nAffected by Damage and RPM."
},
{
Name = "Lethality",
Size = 12,
Font = "Benny_10",
Stat = function( class )
local bwep = math.Clamp( math.Remap( BENNY_GetStat( class, "Damage" ) * ( BENNY_GetStat( class, "Pellets" ) or 1 ), 14, 80, 0, 1 ), 0, 1 )
local meowzor = math.ease.OutQuart( bwep )
return meowzor
end,
-- "How much the weapon's point of aim will move around.\nAffected by various Sway stats."
},
{
Name = "Suppression",
Size = 12,
Font = "Benny_10",
Stat = function( class )
local weight_1, weight_2 = 1, 3
local totalscore = (weight_1 + weight_2)
weight_1, weight_2 = weight_1/totalscore, weight_2/totalscore
local score_1, score_2 = 1, 1
local truedelay = ( 1 / BENNY_GetStat( class, "Delay" ) )
if BENNY_GetStat( class, "Firemodes" )[1].Mode == 1 then
truedelay = math.min( truedelay, 60/300 )
end
score_1 = rmt1c( BENNY_GetStat( class, "Damage" ) * truedelay, 100, 350 )
score_1 = score_1 * weight_1
score_2 = rmt1c( BENNY_GetStat( class, "AmmoStd" ), 16, 42 )
score_2 = score_2 * weight_2
return score_1 + score_2
end,
-- "How much damage the weapon can output over a long period of time.\nDoes not consider armor penetration.\nAffected by Damage, RPM, Capacity and Reload Time."
},
--
-- Name = "Range",
-- Size = 12,
-- Font = "Benny_10",
-- Stat = function( class )
-- return 0
-- end,
-- -- "How well the weapon gains or loses damage over long distances.\nAffected by Minimum Range, Maximum Range, and damage falloff."
-- },
{
Name = "Precision",
Size = 12,
Font = "Benny_10",
Stat = function( class )
return math.Clamp( math.Remap( BENNY_GetStat( class, "Spread" ), 1/60, 2, 1, 0 ), 0, 1 )
end,
-- "How accurate the weapon is when firing single shots or short bursts.\nAffected by Spread and various Recoil stats."
},
{
Name = "Control",
Size = 12,
Font = "Benny_10",
Stat = function( class )
return math.Clamp( math.Remap( BENNY_GetStat( class, "SpreadAdd" ) * ( 1 / BENNY_GetStat( class, "Delay" ) ), 1, 13, 1, 0 ), 0, 1 )
end,
-- "How managable the weapon's recoil and spread is under sustained fire.\nAffected by RPM and various Recoil stats."
},
-- {
-- Name = "Handling",
-- Size = 12,
-- Font = "Benny_10",
-- Stat = function( class )
-- return 0
-- end,
-- -- "How quickly this weapon readies from sprinting, aiming and deploying.\nAffected by Aim Down Sights Time, Sprint To Fire Time, and Deploy Time."
-- },
--{
-- Name = "Maneuvering",
-- Size = 12,
-- Font = "Benny_10",
-- Stat = function( class )
-- return 0
-- end,
-- -- "How accurate the weapon is while not aiming.\nAffected by Hipfire Spread, Mid-air Spread, Sway, and Free Aim Angle."
--},
{
Name = "Mobility",
Size = 12,
Font = "Benny_10",
Stat = function( class )
local weight_moving, weight_aiming, weight_reloading, weight_firing = 5, 5, 2, 1
local totalscore = (weight_moving + weight_aiming + weight_reloading + weight_firing)
weight_moving, weight_aiming, weight_reloading, weight_firing = weight_moving/totalscore, weight_aiming/totalscore, weight_reloading/totalscore, weight_firing/totalscore
local score_moving, score_aiming, score_reloading, score_firing = 1, 1, 1, 1
score_moving = rmt1c( BENNY_GetStat( class, "Speed_Move" ), 0.8, 1 )
score_moving = score_moving * weight_moving
score_aiming = rmt1c( BENNY_GetStat( class, "Speed_Aiming" ), 0.8, .98 )
score_aiming = score_aiming * weight_aiming
score_reloading = rmt1c( BENNY_GetStat( class, "Speed_Reloading" ), 0.75, 0.95 )
score_reloading = score_reloading * weight_reloading
score_firing = rmt1c( BENNY_GetStat( class, "Speed_Firing" ), 0.75, 0.95 )
score_firing = score_firing * weight_firing
return score_moving + score_aiming + score_reloading + score_firing
end,
-- "How fast the user can move while using this weapon.\nAffected by various Speed stats."
},
-- {
-- Name = "Stability",
-- Size = 12,
-- Font = "Benny_10",
-- Stat = function( class )
-- return 0
-- end,
-- "How much the weapon's point of aim will move around.\nAffected by various Sway stats."- },
}
local function multlinetext(text, maxw, font)
local content = {}
local tline = ""
local x = 0
surface.SetFont(font)
local newlined = string.Split(text, "\n")
for _, line in pairs(newlined) do
local words = string.Split(line, " ")
for _, word in pairs(words) do
local tx = surface.GetTextSize(word)
if x + tx >= maxw then
table.insert(content, tline)
tline = ""
x = surface.GetTextSize(word)
end
tline = tline .. word .. " "
x = x + surface.GetTextSize(word .. " ")
end
table.insert(content, tline)
tline = ""
x = 0
end
return content
end
local h_F, s_F, v_F = 224, 0.00, 0.40
local h_D, s_D, v_D = 180, 0.40, 0.40
local h_C, s_C, v_C = 140, 0.40, 0.50
local h_B, s_B, v_B = 40, 0.60, 0.90
local h_A, s_A, v_A = 24, 0.70, 0.90
local h_S, s_S, v_S = 0, 0.75, 0.90
local function rank( perc )
local letter
local color
if perc <= 1/10 then
letter = "F"
color = HSVToColor(
h_F,
s_F,
v_F
)
elseif perc <= 3/10 then
letter = "D"
color = HSVToColor(
h_D,
s_D,
v_D
)
elseif perc <= 5/10 then
letter = "C"
color = HSVToColor(
h_C,
s_C,
v_C
)
elseif perc <= 7/10 then
letter = "B"
color = HSVToColor(
h_B,
s_B,
v_B
)
elseif perc <= 9/10 then
letter = "A"
color = HSVToColor(
h_A,
s_A,
v_A
)
elseif perc <= 1 then
letter = "S"
color = HSVToColor(
h_S,
s_S,
v_S
)
end
return letter, color
end
function OpenSMenu()
if IsValid( smenu ) then smenu:Remove() return end
local active = GetConVar("benny_hud_tempactive"):GetString()
smenu = vgui.Create("BFrame")
smenu:SetSize( ss(350), ss(360) )
smenu:SetTitle("Developer Spawnmenu")
smenu:MakePopup()
smenu:SetKeyboardInputEnabled( false )
smenu:Center()
local itemlist = smenu:Add("DScrollPanel")
itemlist:Dock( FILL )
smenu:Center()
itemlist:GetVBar():SetWide( 0 )
local statlist = smenu:Add("DPanel")
statlist:SetWide( ss(220) )
statlist:Dock( RIGHT )
statlist:DockMargin( ss(2), 0, 0, 0 )
statlist:DockPadding( ss(2), ss(2), ss(2), ss(2) )
function statlist:Paint( w, h )
surface.SetDrawColor( schema("fg") )
surface.DrawOutlinedRect( 0, 0, w, h, ss(0.5) )
end
-- PROTO: Do regen stats.
do
local BAR_NAME = statlist:Add( "DLabel" )
BAR_NAME:SetTall( ss(18) )
BAR_NAME:Dock( TOP )
BAR_NAME:DockMargin( 0, 0, 0, ss(2) )
function BAR_NAME:Paint( w, h )
surface.SetDrawColor( schema("fg") )
surface.DrawRect( 0, 0, w, h )
if pan_active then
local rang = WeaponGet( pan_active )
draw.SimpleText( rang.Name, "Benny_18", ss(2), ss(2), schema_c("bg") )
end
return true
end
end
do
local BAR_DESC = statlist:Add( "DLabel" )
BAR_DESC:SetTall( ss(18) )
BAR_DESC:Dock( TOP )
BAR_DESC:DockMargin( 0, 0, 0, ss(2) )
local lastheight = 0
function BAR_DESC:Paint( w, h )
surface.SetDrawColor( schema("fg") )
surface.DrawRect( 0, 0, w, h )
if pan_active then
local rang = WeaponGet( pan_active )
local multiline = multlinetext( rang.Description, w-ss(2), "Benny_12" )
for i, v in ipairs( multiline ) do
local line = i-1
local height = ss( 14 + (#multiline-1)*12 )
if lastheight != height then
BAR_DESC:SetTall( height )
lastheight = height
end
draw.SimpleText( v, "Benny_12", ss(2), ss(2+12*line), schema_c("bg") )
end
end
return true
end
end
for i, us in ipairs( mewer ) do
do continue end
local fucker = statlist:Add( "DLabel" )
fucker:SetTall( ss(us.Size) )
fucker:Dock( TOP )
fucker:DockMargin( 0, 0, 0, ss(2) )
local lastheight = 0
function fucker:Paint( w, h )
if us.Stat then
surface.SetDrawColor( schema("fg") )
surface.DrawOutlinedRect( 0, 0, w, h, ss(0.5) )
else
surface.SetDrawColor( schema("fg") )
surface.DrawRect( 0, 0, w, h )
end
local rang = WeaponGet( pan_active )
if rang then
if us.SizeMultiline then
local multiline = multlinetext( us.Func and us.Func( rang ) or us.Name, w-ss(2), us.Font )
for i, v in ipairs( multiline ) do
local line = i-1
local height = ss( us.Size + ((#multiline-1)*us.SizeMultiline) )
if lastheight != height then
fucker:SetTall( height )
lastheight = height
end
draw.SimpleText( v, us.Font, ss(2), ss(2)+ss(us.SizeMultiline*line), schema_c(us.Stat and "fg" or "bg") )
end
else
draw.SimpleText( us.Func and us.Func( rang ) or us.Name, us.Font, ss(2), ss(2), schema_c(us.Stat and "fg" or "bg") )
end
if us.Stat then
local perc = us.Stat( rang )
--perc = (CurTime()*0.2+i/4) % 2
--if perc > 1 then
-- perc = 2-perc
--end
--perc = math.Remap( perc, 0, 1, 0.3, 0.8)
local rank, col = rank( perc )
surface.SetDrawColor( schema("fg") )
surface.DrawRect( ss(60), 0, ss(1), h )
draw.SimpleText( rank, us.Font, ss(60+4), ss(2), col )
surface.DrawRect( ss(60)+h, 0, ss(1), h )
surface.SetDrawColor( col )
local width = w-(ss(60+1.5)+h)
surface.DrawRect( ss(60+1)+h, ss(3), math.max( ss(1), width*perc ), h-ss(6) )
--surface.SetDrawColor( schema("bg") )
--surface.DrawOutlinedRect( ss(60+1)+h, ss(0.5), width, h-ss(1), ss(2) )
for i=1, 10 do
if i==1 then continue end
surface.SetDrawColor( schema("fg", i%2==1 and 0.008 or 0.12) )
surface.DrawRect( ss(60)+h + width*(i-1)/10, 0, ss(1), h )
end
end
end
return true
end
end
do
local fucker = statlist:Add( "DLabel" )
fucker:SetTall( ss(14) )
fucker:Dock( TOP )
fucker:DockMargin( 0, 0, 0, ss(2) )
function fucker:Paint( w, h )
do return true end
if pan_active then
local hm = WeaponGet( pan_active )
surface.SetDrawColor( schema("fg") )
surface.DrawRect( 0, 0, w, h )
draw.SimpleText( BENNY_GetStat( hm, "AmmoStd" ) .. " rounds", "Benny_12", ss(2), ss(2), schema_c("bg") )
end
return true
end
end
do
local fucker = statlist:Add( "DLabel" )
fucker:SetTall( ss(14) )
fucker:Dock( TOP )
fucker:DockMargin( 0, 0, 0, ss(2) )
function fucker:Paint( w, h )
do return true end
if pan_active then
local hm = WeaponGet( pan_active )
surface.SetDrawColor( schema("fg") )
surface.DrawRect( 0, 0, w, h )
local fm = BENNY_GetStat( hm, "Firemodes" )
local fms = ""
for i,v in ipairs( fm) do
local m =v.Mode
if m == math.huge then
fms = fms .. "AUTO"
elseif m == 1 then
fms = fms .. "SEMI"
else
fms = fms .. m .. "-BURST"
end
if i != #fm then
fms = fms .. " / "
end
end
draw.SimpleText( fms, "Benny_12", ss(2), ss(2), schema_c("bg") )
end
return true
end
end
local createlist = {}
for ClassName, Class in pairs( WEAPONS ) do
if rawget(Class, "Hide") then continue end
if !createlist[Class.Category] then
createlist[Class.Category] = {}
end
table.insert( createlist[Class.Category], { ClassName = ClassName, Class = Class } )
end
for i, v in SortedPairs( createlist ) do
local Collapse = itemlist:Add( "BCollapsibleCategory" )
Collapse:Dock( TOP )
Collapse:SetLabel( i )
Collapse:SetExpanded( false )
Collapse:DockMargin( 0, 0, 0, ss(2) )
Collapse:DockPadding( ss(2), ss(2), ss(2), ss(2) )
for Mew, New in ipairs( v ) do
local button = Collapse:Add( "DButton" )
button:SetSize( 0, ss(10) )
button:DockMargin( 0, 0, 0, ss(0) )
button.Text_Name = New.Class.Name
button.Text_Desc = New.Class.Description
-- PROTO: These functions don't need to be remade over and over like this.
function button:DoClick()
RunConsoleCommand( "benny_debug_give", New.ClassName )
chat.AddText( "Gave " .. New.Class.Name )
end
function button:DoRightClick()
if ItemDef("mag_"..New.ClassName) then
RunConsoleCommand( "benny_debug_give", "mag_" .. New.ClassName )
chat.AddText( "Gave " .. ItemDef("mag_"..New.ClassName).Name )
else
chat.AddText( "That item doesn't exist. " .. "mag_"..New.ClassName )
end
end
function button:Think()
if self:IsHovered() then
pan_active = New.ClassName
end
end
function button:Paint( w, h )
local z = 0.5
if self:IsHovered() then
local nx, ny = 0, 0
for i=1, 9 do
-- PROTO: ...
if i==1 then
nx, ny = -1, -1
elseif i==2 then
nx, ny = 0, -1
elseif i==3 then
nx, ny = 1, -1
elseif i==4 then
nx, ny = -1, 0
elseif i==5 then
continue
elseif i==6 then
nx, ny = 1, 0
elseif i==7 then
nx, ny = -1, 1
elseif i==8 then
nx, ny = 0, 1
elseif i==9 then
nx, ny = 1, 1
end
nx, ny = ss(nx), ss(ny)
draw.SimpleText( self.Text_Name, "Benny_14", ss(2)+nx, ss(-1)+ny, schema_c("fg") )
end
draw.SimpleText( self.Text_Name, "Benny_14", ss(2), ss(-1), schema_c("bg") )
else
draw.SimpleText( self.Text_Name, "Benny_14", ss(2), ss(-1), schema_c("fg") )
end
--surface.SetDrawColor( schema("fg") )
--surface.DrawOutlinedRect( 0, 0, surface.GetTextSize(self.Text_Name)+ss(2+2), h )
--surface.SetDrawColor( schema("fg") )
--surface.DrawRect( ss(2), h-ss(1), surface.GetTextSize(self.Text_Name), ss(0.5) )
--draw.SimpleText( self.Text_Desc, "Benny_8", w/2, ss(2+8), schema_c("fg"), TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP )
return true
end
end
end
end
concommand.Add("benny_ui_spawnmenu", function()
OpenSMenu()
end)

View File

@ -0,0 +1,10 @@
-- Singleplayer score panel
function OpenScorePanel()
end
concommand.Add("benny_ui_score", function()
OpenScorePanel()
end)

View File

@ -0,0 +1,53 @@
--[[
Your Name Is Benny
Item definition
]]
-- Not 100% sure how metastuff works yet.
-- Global weapons table
WEAPONS = {}
function WeaponGet(class)
return ItemDef(class)
end
-- ItemDef metatable
ItemDef = {}
ItemDefHelpers = {
Get = function( self, key )
return self.key
end,
GetRaw = function( self, key )
return rawget( self, key )
end,
}
function ItemDef.__index( self, key )
if ItemDefHelpers[key] then return ItemDefHelpers[key] end
if rawget(self, "BaseClass") then
return rawget(self, "BaseClass")[key]
end
end
function ItemDef:new( classname, classtable )
if classtable then
local newdef = classtable
newdef.ClassName = classname
newdef.BaseClass = WEAPONS[newdef.Base]
setmetatable( newdef, ItemDef )
WEAPONS[classname] = newdef
return newdef
else
return WEAPONS[classname]
end
end
function ItemDef:__tostring()
return "ItemDef [" .. self.ClassName .. "]"
end
setmetatable( ItemDef, { __call = ItemDef.new } )

View File

@ -0,0 +1,5 @@
--[[
Your Name Is Benny
Item existance
]]

View File

@ -0,0 +1,527 @@
--
local debugcolor = Color( 255, 0, 255, 1 )
local function QuickDrag( self, dist, ply )
local spos = ply:GetPos()
self.QuickDrag = self.QuickDrag or Vector()
-- debugoverlay.Box( self.last, Vector( -dist, -dist, 0 ), Vector( dist, dist, 64 ), 0, Color( 0, 0, 255, 0 ) )
if spos.x > (self.QuickDrag.x+dist) then
self.QuickDrag.x = spos.x-dist
elseif spos.x < (self.QuickDrag.x-dist) then
self.QuickDrag.x = spos.x+dist
end
if spos.y > (self.QuickDrag.y+dist) then
self.QuickDrag.y = spos.y-dist
elseif spos.y < (self.QuickDrag.y-dist) then
self.QuickDrag.y = spos.y+dist
end
return spos
end
tempmapcameras = {}
tempmapcameras["benny_caramelldansen"] = {}
tempmapcameras["benny_caramelldansen"]["main"] = {
Type = "Standard",
Pos = Vector( -510, 0, 128 ),
Ang = Angle( 44, 0, 0 ),
FOV = 90,
Checks = {
{
Vector( -512, -512, 64 ),
Vector( 512, 512, -64 ),
},
},
Special = function( self, ply )
local pos = Vector()
pos:Set( self.Pos )
local ang = Angle()
ang:Set( self.Ang )
pos:Set( QuickDrag( self, 40, ply ) )
pos.x = pos.x - 130
pos.z = 180
return pos, ang, self.FOV
end
}
tempmapcameras["benny_test"] = {}
tempmapcameras["benny_test"]["main"] = {
Type = "Standard",
Pos = Vector( -692, 0, 268 ),
Ang = Angle( 55, 0, 0 ),
FOV = 90,
Checks = {
{
Vector( -390, 510, 0 ),
Vector( -924, -509, -90 ),
},
},
iX1 = -550,
iX2 = -800,
Special = function( self, ply )
local pos = Vector()
pos:Set( self.Pos )
local ang = Angle()
ang:Set( self.Ang )
local ppos = ply:GetPos()
pos.y = ppos.y
do -- Angle
local amt = math.TimeFraction( self.iX1, self.iX2, ppos.x )
debugoverlay.Line( Vector( self.iX1, 0, 0 ), Vector( self.iX2, 0, 0 ), 0, debugcolor, true )
amt = math.Clamp( amt, 0, 1 )
amt = math.ease.InOutCubic( amt )
ang.p = ang.p + ( 25 * (amt) )
pos.x = pos.x - ( 170 * (amt) )
end
return pos, ang, self.FOV
end
}
tempmapcameras["benny_test"]["grass"] = {
Pos = Vector( -1622, -214, 284 ),
Ang = Angle( 70, 0, 0 ),
FOV = 90,
Checks = {
{
Vector( -931, -130, 0 ),
Vector( -1311, -319, -70 ),
},
{
Vector( -1321, 506, 0 ),
Vector( -1813, -503, -70 ),
},
},
iX1 = -900,
iX2 = -1330,
iX3 = -1400,
iX4 = -1750,
Special = function( self, ply )
local pos = Vector()
pos:Set( self.Pos )
local ang = Angle()
ang:Set( self.Ang )
local fov = self.FOV
local ppos = ply:GetPos()
pos.y = ppos.y
do -- far
local amt = math.TimeFraction( self.iX1, self.iX2, ppos.x )
debugoverlay.Line( Vector( self.iX1, ppos.y, ppos.z ), Vector( self.iX2, ppos.y, ppos.z ), 0, debugcolor, true )
amt = 1-math.Clamp( amt, 0, 1 )
amt = math.ease.InOutSine( amt )
ang.p = ang.p - ( 11 * amt )
pos.x = pos.x + ( 400 * amt )
fov = fov - ( 22 * amt )
end
do -- close
local amt = math.TimeFraction( self.iX3, self.iX4, ppos.x )
debugoverlay.Line( Vector( self.iX3, ppos.y, ppos.z ), Vector( self.iX4, ppos.y, ppos.z ), 0, debugcolor, true )
amt = math.Clamp( amt, 0, 1 )
amt = math.ease.InOutCubic( amt )
pos.x = pos.x - ( 150 * (amt) )
ang.p = ang.p + ( 0 * (amt) )
end
return pos, ang, fov
end
}
tempmapcameras["benny_test"]["barber"] = {
Pos = Vector( -64, 0, 80 ),
Ang = Angle( 34, 0, 0 ),
FOV = 90,
Checks = {
{
Vector( -382, 128, 0 ),
Vector( 128, -128, -70 ),
},
},
Special = function( self, ply )
local pos = Vector()
pos:Set( self.Pos )
local ang = Angle()
ang:Set( self.Ang )
local fov = self.FOV
local ppos = ply:GetPos()
pos.x = pos.x + ppos.x
pos.y = pos.y + ppos.y
pos.x = math.max( pos.x, -400 )
return pos, ang, fov
end
}
BENNY_ACTIVECAMERA = nil
local si = 4
local ctrace = {
start = nil,
endpos = nil,
mins = Vector( -si, -si, -si ),
maxs = Vector( si, si, si ),
mask = MASK_SHOT_HULL,
filter = nil,
}
local tempcam = {
FOV = 90,
Special = function( self, ply )
local pos = Vector()
local ang = Angle( 22, 0, 0 )
pos:Set( QuickDrag( self, 40, ply ) )
pos.x = pos.x - 30
pos.z = pos.z + 80
return pos, ang, self.FOV
end
}
local fixer = Angle( 0, -90, 90 )
local fixer2 = Angle( 0, -90, 90 )
local cscam = {
Special = function( self, ply )
local pos = Vector()
local ang = Angle()
local fov = 90
cuts:SetupBones()
local mat = cuts:GetBoneMatrix( cuts:LookupBone( "camera" ) )
local matf = cuts:GetBoneMatrix( cuts:LookupBone( "camera.fov" ) )
pos:Set( mat:GetTranslation() )
ang:Set( mat:GetAngles() )
ang:Sub( fixer )
local fix, fixa = matf:GetTranslation(), matf:GetAngles()
fix:Sub( cuts:GetPos() )
fov = fix.z
do
local x, y, z = pos.x, pos.y, pos.z
end
do
local p, y, r = ang.p, ang.y, ang.r
ang.p = -r
ang.r = 0
end
fov = Convert( fov, (4/3) ) -- Convert to vertical FOV.. somehow
fov = Convert( fov, (ScrH()/ScrW())/(3/4) ) -- Shut up default Source FOV widescreen magic
return pos, ang, fov
end
}
local function decide_active()
-- print( LocalPlayer():GetPos() )
-- BENNY_ACTIVECAMERA = tempcam
local csent = ents.FindByClass( "benny_cutscene" )[1]
if IsValid( csent ) then
BENNY_ACTIVECAMERA = cscam
cuts = csent
return true
end
if tempmapcameras[ game.GetMap() ] then
for name, camera in pairs( tempmapcameras[ game.GetMap() ] ) do
if camera.Checks then
for i, v in ipairs(camera.Checks) do
-- debugoverlay.Box( vector_origin, v[1], v[2], 0, debugcolor )
if LocalPlayer():GetPos():WithinAABox( v[1], v[2] ) then
BENNY_ACTIVECAMERA = camera
return true
end
end
end
end
end
return false
end
function bennyfp( origin, angles, fov )
local ply = LocalPlayer()
if !IsValid( ply:GetActiveWeapon() ) then return origin, angles, fov end
local pos, ang = ply:CamSpot( TPSOverride )
return pos, ang, 90
end
hook.Add( "CalcView", "Benny_CalcView", function( ply, pos, ang, fov )
if ConVarCL_Bool("cam_unlock") then return end
if ply:NoclippingAndNotVaulting() then return end
decide_active()
local camera = BENNY_ACTIVECAMERA
local view = {}
view.origin = pos
view.angles = ang
view.fov = 90
if false and camera then
view.origin = camera.Pos
view.angles = camera.Ang
view.fov = camera.FOV or 60
if camera.Special then
view.origin, view.angles, view.fov = camera.Special( camera, ply )
end
end
local wep = ply:BennyCheck()
if wep then -- and ply:GetActiveWeapon():GetAim() > 0 then
local cv = wep:bWepClass( true ) and wep:bWepClass( true ).Custom_CalcView or wep:bWepClass( false ) and wep:bWepClass( false ).Custom_CalcView
local halt = false
if cv then
halt = cv( wep, view, view.origin, view.angles, view.fov )
end
if !halt then
view.drawviewer = true
view.origin, view.angles, view.fov = bennyfp( view.origin, view.angles, view.fov )
end
end
local st = ConVarCL_String("cam_override")
if st != "" then
local st = string.Explode( " ", st )
view.origin.x = tonumber(st[1])
view.origin.y = tonumber(st[2])
view.origin.z = tonumber(st[3])
view.angles.x = tonumber(st[4])
view.angles.y = tonumber(st[5])
view.angles.z = tonumber(st[6])
view.fov = tonumber(st[7])
end
if globhit then
globhit:Set( view.origin )
globang:Set( view.angles )
end
view.fov = Convert( view.fov, (ScrH()/ScrW())/(3/4) )
return view
end )
function Convert( fovDegrees, ratio )
local halfAngleRadians = fovDegrees * ( 0.5 * math.pi / 180 )
local t = math.tan( halfAngleRadians )
t = t * ratio
local retDegrees = ( 180 / math.pi ) * math.atan( t )
return retDegrees * 2
end
concommand.Add("benny_cam_panel", function()
if IsValid( CamPanel ) then CamPanel:Remove() end
CamPanel = vgui.Create( "DFrame" )
local a = CamPanel
a:SetSize( 320, 280 )
a:Center()
a:MakePopup()
local st = c_over:GetString()
if st == "" then
st = "0 0 0 0 0 0 90"
end
st = string.Explode( " ", st )
for i=1, 3 do
local t = a:Add("DLabel")
t:SetSize( 300, 14 )
t:DockMargin( 20, 2, 20, 2 )
t:Dock( TOP )
t:SetText( i==1 and "Hold CONTROL to Right/Forward/Up" or
i==2 and "Hold SHIFT to multiply 10x" or
i==3 and "Hold ALT to multiply 2x" )
end
local bloink = {}
for i=1, 3 do
local b = vgui.Create("DNumberWang")
bloink[i] = b
b:SetSize( 200, 20 )
b:DockMargin( 20, 2, 20, 2 )
b:SetText( st[i] )
b:SetMinMax( -math.huge, math.huge )
b.OnValueChanged = function(self)
st[i] = self:GetValue()
c_over:SetString( table.concat( st, " " ) )
end
local d = vgui.Create("DPanel")
for u=1, 6 do
local bu = d:Add("DButton")
bu:Dock( LEFT )
bu:SetSize( 29, 24 )
bu:DockMargin( 0, 0, 2, 0 )
local wa = 0
if u==1 then
wa = -10
elseif u==2 then
wa = -5
elseif u==3 then
wa = -1
elseif u==4 then
wa = 1
elseif u==5 then
wa = 5
elseif u==6 then
wa = 10
end
bu:SetText( wa )
function bu:DoClick( )
local wa = wa
if input.IsKeyDown( KEY_LALT ) then
wa = wa * 2
end
if input.IsKeyDown( KEY_LSHIFT ) then
wa = wa * 10
end
if input.IsKeyDown( KEY_LCONTROL ) then
local wawa = Vector()
local new = Angle( st[4], st[5], st[6] )
wawa = i==1 and new:Right() or i==2 and new:Forward() or new:Up()
wawa:Mul(wa)
st[1] = st[1] + wawa[1]
st[2] = st[2] + wawa[2]
st[3] = st[3] + wawa[3]
bloink[1]:SetValue( st[1] )
bloink[2]:SetValue( st[2] )
bloink[3]:SetValue( st[3] )
return
end
b:SetValue( b:GetValue() + wa )
end
end
local c = a:Add("DHorizontalDivider")
c:Dock( TOP )
c:DockMargin( 10, 0, 10, 0 )
c:SetLeft(b)
c:SetRight(d)
end
for i=1, 3 do
local b = a:Add("DNumSlider")
bloink[i+3] = b
b:SetSize( 200, 20 )
b:Dock( TOP )
b:DockMargin( 20, 2, 20, 2 )
b:SetText( i==1 and "Pitch" or i==2 and "Yaw" or "Roll" )
b:SetMin( -360 )
b:SetMax( 360 )
b:SetValue( st[i+3] )
b:SetDecimals( 1 )
b.OnValueChanged = function( self, val )
val = math.NormalizeAngle( val )
self:SetValue( val )
st[i+3] = val
c_over:SetString( table.concat( st, " " ) )
end
end
do
local b = a:Add("DNumSlider")
bloink[7] = b
b:SetSize( 200, 20 )
b:Dock( TOP )
b:DockMargin( 20, 2, 20, 2 )
b:SetText( "Field of View" )
b:SetMin( 0 )
b:SetMax( 90 )
b:SetValue( st[7] )
b.OnValueChanged = function(self)
st[7] = self:GetValue()
c_over:SetString( table.concat( st, " " ) )
end
end
do
local b = vgui.Create("DButton")
b:SetText( "Steal from current" )
function b:DoClick()
local ply = LocalPlayer()
local ppos = ply:EyePos()
local pang = ply:EyeAngles()
for i=1, 7 do
if i==1 then
bloink[i]:SetValue( ppos[1] )
elseif i==2 then
bloink[i]:SetValue( ppos[2] )
elseif i==3 then
bloink[i]:SetValue( ppos[3] )
elseif i==4 then
bloink[i]:SetValue( pang[1] )
elseif i==5 then
bloink[i]:SetValue( pang[2] )
elseif i==6 then
bloink[i]:SetValue( pang[3] )
elseif i==7 then
bloink[i]:SetValue( 90 )
end
c_over:SetString( table.concat( st, " " ) )
end
end
local d = vgui.Create("DButton")
d:SetText( "Reset" )
function d:DoClick()
for i=1, 7 do
bloink[i]:SetValue( i==7 and 90 or 0 )
end
c_over:SetString("")
end
local c = a:Add("DHorizontalDivider")
c:Dock( TOP )
c:DockMargin( 10, 0, 10, 0 )
c:SetLeft(b)
c:SetRight(d)
end
end)
concommand.Add( "benny_dev_eyetrace", function( ply )
local tr = ply:GetEyeTrace()
print( string.format("Vector( %i, %i, %i )", math.Round( tr.HitPos.x ), math.Round( tr.HitPos.y ), math.Round( tr.HitPos.z ) ) )
print( tr.Entity )
end)
if game.GetMap():Left( 13 ) == "bennysurvive_" then
local ourMat = Material( "color" )
hook.Add("PostDraw2DSkyBox", "ExampleHook", function()
local r, g, b = render.GetFogColor()
r=(r+1)/255
g=(g+1)/255
b=(b+1)/255
local v = Vector( r, g, b )
render.OverrideDepthEnable( true, false ) -- ignore Z to prevent drawing over 3D skybox
ourMat:SetVector( "$color", v )
render.SetMaterial( ourMat )
render.DrawScreenQuadEx( 0, 0, ScrW(), ScrH() )
render.OverrideDepthEnable( false, false )
end)
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,131 @@
if SERVER then
util.AddNetworkString( "benny_sendinvitem" )
util.AddNetworkString( "benny_discardinvitem" )
end
function BENNY.CreateItem( classname )
local class = ItemDef(classname)
assert( class, "Invalid Class " .. tostring(classname) )
local item = {
Class = classname,
Acquisition = CurTime(),
}
class.Init_Item( class, item )
--if class.Features == "firearm" then
-- item.Loaded = ""
--elseif class.Features == "magazine" then
-- item.Ammo = class.Ammo
--end
--
return item
end
concommand.Add("benny_debug_give", function(ply, cmd, args)
assert(SERVER, "not server")
local inv = ply:INV_Get()
local str = UUID_generate()
local newitem = BENNY.CreateItem( args[1] )
inv[str] = newitem
-- PROTO: WriteTable.
net.Start( "benny_sendinvitem" )
net.WriteString( str )
net.WriteTable( newitem )
net.Send( ply )
end,
function(cmd, args)
args = string.Trim(args:lower())
local meow = {}
for i, v in SortedPairs( WEAPONS ) do
if string.lower(i):find(args) then
table.insert( meow, cmd .. " " .. i )
end
end
return meow
end, "arg 1: classname")
if CLIENT then
net.Receive( "benny_sendinvitem", function()
LocalPlayer():INV_Get()[net.ReadString()] = net.ReadTable()
end)
net.Receive( "benny_discardinvitem", function()
LocalPlayer():INV_Get()[net.ReadString()] = nil
end)
end
function InvDiscard( ply, ID )
local inv = ply:INV_Get()
local wep = ply:GetActiveWeapon()
local item = inv[ID]
-- PROTO: Check that this is the correct 'benny' weapon.
assert( item, "That item doesn't exist. " .. tostring(item) )
inv[ID] = nil
net.Start( "benny_discardinvitem" )
net.WriteString( ID )
net.Send( ply )
if wep:bGetInvID( false ) == ID then
print( "Disequipped " .. ID .. " for " .. tostring(wep) )
wep:SetWep1( "" )
wep:SetWep1_Clip( "" )
wep:SetClip1( 0 )
end
if wep:bGetInvID( true ) == ID then
print( "Disequipped " .. ID .. " for " .. tostring(wep) )
wep:SetWep2( "" )
wep:SetWep2_Clip( "" )
wep:SetClip2( 0 )
end
if wep:bGetMagInvID( false ) == ID then
print( "Unloaded " .. ID .. " for " .. tostring(wep) )
inv[wep:bGetInvID( false )].Loaded = ""
wep:SetWep1_Clip( "" )
wep:SetClip1( 0 )
end
if wep:bGetMagInvID( true ) == ID then
print( "Unloaded " .. ID .. " for " .. tostring(wep) )
inv[wep:bGetInvID( true )].Loaded = ""
wep:SetWep2_Clip( "" )
wep:SetClip2( 0 )
end
end
concommand.Add("benny_inv_discard", function( ply, cmd, args )
InvDiscard( ply, args[1] )
end)
hook.Add( "PlayerDeathSound", "Benny_PlayerDeathSound", function( ply )
return true -- we don't want the default sound!
end )
if CLIENT then
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Dev", function( ply, button )
local wep = ply:BennyCheck()
if IsFirstTimePredicted() then
if button == KEY_F1 then
OpenSettingsMenu()
elseif button == KEY_F2 then
OpenDebugInv()
elseif button == KEY_F3 then
OpenSMenu()
elseif button == KEY_F4 then
-- OpenDeadeye()
elseif button == KEY_F5 then
elseif button == KEY_F6 then
elseif button == KEY_F7 then
elseif button == KEY_F8 then
elseif button == KEY_F9 then
elseif button == KEY_F11 then
elseif button == KEY_F12 then
end
end
end)
end

View File

@ -0,0 +1,182 @@
local easywaycvar = CreateConVar( "benny_net_easyway", 0, FCVAR_ARCHIVE + FCVAR_REPLICATED, "Use a disgusting way of networking inventories for maximum duplication." )
local easyway = easywaycvar:GetBool()
local UINTBITS = 8
if easyway then
if SERVER then
gameevent.Listen( "player_activate" )
hook.Add( "player_activate", "Benny_Activate", function( data )
Player(data.userid).CheckerReady = true
end )
local checkerinterval = 1
util.AddNetworkString( "Benny_Checker" )
hook.Add( "PlayerTick", "Benny_Checker", function( ply )
if ply.CheckerReady then
if (ply.CheckerLast or 0) + checkerinterval <= CurTime() then
local inv = ply:INV_Get()
net.Start( "Benny_Checker" )
net.WriteUInt( table.Count(inv), UINTBITS )
for i, v in pairs( inv ) do
net.WriteString( i )
net.WriteTable( v )
end
print( ply, net.BytesWritten() )
net.Send( ply )
ply.CheckerLast = CurTime()
end
end
end)
else -- client begin
net.Receive( "Benny_Checker", function( len, ply )
local ply = LocalPlayer()
local inv = ply:INV_Get()
local amt = net.ReadUInt( UINTBITS )
for i=1, amt do
local id = net.ReadString()
inv[id] = net.ReadTable()
end
end)
end -- client end
else -- hardway
if SERVER then
gameevent.Listen( "player_activate" )
hook.Add( "player_activate", "Benny_Activate", function( data )
Player(data.userid).CheckerReady = true
end )
local checkerinterval = 1
util.AddNetworkString( "Benny_Checker" )
util.AddNetworkString( "Benny_Checker_CL_Request" )
hook.Add( "PlayerTick", "Benny_Checker", function( ply )
if ply.CheckerReady then
if (ply.CheckerLast or 0) + checkerinterval <= CurTime() then
local inv = ply:INV_Get()
net.Start( "Benny_Checker" )
net.WriteUInt( table.Count(inv), UINTBITS )
for i, v in pairs( inv ) do
net.WriteString( i )
net.WriteBool( v.Loaded )
if v.Loaded then net.WriteString( v.Loaded ) end
end
net.Send( ply )
ply.CheckerLast = CurTime()
end
end
end)
net.Receive("Benny_Checker_CL_Request", function( len, ply )
if (ply.CheckerRequestBan or 0) <= CurTime() then
local amt = net.ReadUInt( UINTBITS )
local inv = ply:INV_Get()
local regenlist = {}
-- Make sure they all exist first
for i=1, amt do
local id = net.ReadString()
if inv[id] then
table.insert( regenlist, id )
else
-- Punish
print( ply, "The item the client requested, '" .. tostring(id) .."' didn't exist. Malicious?") -- Matters in public servers!! -- Not supporting for 5 seconds." )
-- ply.CheckerRequestBan = CurTime() + 5
-- return
end
end
net.Start("Benny_Checker_CL_Request")
net.WriteUInt( #regenlist, UINTBITS )
for i, id in ipairs( regenlist ) do
if inv[id] then
print( "Doing " .. id )
net.WriteString( id )
net.WriteTable( inv[id] )
end
end
net.Send( ply )
end
end)
else
net.Receive( "Benny_Checker", function( len, ply )
local ply = LocalPlayer()
-- Get started
local amt = net.ReadUInt( UINTBITS )
local evallist = {}
for i=1, amt do
local id = net.ReadString()
local loaded_exists = net.ReadBool()
local loaded = nil
if loaded_exists then
loaded = net.ReadString()
end
evallist[id] = loaded or true
end
local inv = ply:INV_Get()
-- Check which items DO NOT exist
local missinglist = {}
for i, v in pairs( evallist ) do
if inv[i] then
-- Success
if isstring(v) then
inv[i].Loaded = v
end
else
missinglist[i] = true
end
end
-- Check any ghost items we have
local ghostlist = {}
for i, v in pairs( inv ) do
if evallist[i] then
-- Success
else
ghostlist[i] = true
end
end
-- Regenerate missing items
if table.Count(missinglist) > 0 then
local concat = ""
for i, v in pairs( missinglist ) do
concat = concat .. "'" .. i .. "' "
end
print( "[".. string.FormattedTime( CurTime(), "%02i:%02i") .. "] [Checker]: You are missing items " .. concat )
net.Start( "Benny_Checker_CL_Request" )
net.WriteUInt( table.Count( missinglist ), UINTBITS )
for i, v in pairs( missinglist ) do
net.WriteString( i )
end
net.SendToServer()
end
-- Remove ghost items
for i, v in pairs( ghostlist ) do
inv[i] = nil
print( "[".. string.FormattedTime( CurTime(), "%02i:%02i") .. "] [Checker]: Removed a ghost item with ID '" .. i .. "'" )
end
end )
net.Receive( "Benny_Checker_CL_Request", function( len, ply )
local ply = LocalPlayer()
local inv = ply:INV_Get()
local amt = net.ReadUInt( UINTBITS )
for i=1, amt do
local id = net.ReadString()
print( "[".. string.FormattedTime( CurTime(), "%02i:%02i") .. "] [Checker]: Restoring " .. id )
inv[id] = net.ReadTable()
end
end)
end
end -- hardway

View File

@ -0,0 +1,74 @@
-- Predicted weapon switching
local dads = {
[KEY_1] = 1,
[KEY_2] = 2,
[KEY_3] = 3,
[KEY_4] = 4,
[KEY_5] = 5,
[KEY_6] = 6,
[KEY_7] = 7,
[KEY_8] = 8,
[KEY_9] = 9,
[KEY_0] = 0,
}
local function beatup( ply, num )
local weighted = ply:INV_Weight()
local inv = ply:INV_Get()
local wep = ply:BennyCheck()
local iflip = table.Flip( inv )
local hand = ply:KeyDown(IN_ZOOM)
local invid = 0
if CLIENT and !IsFirstTimePredicted() then return end
for _, item in pairs( weighted ) do
local class = WeaponGet(item.Class)
local id = iflip[item]
if class.Equipable or class.Features == "firearm" or class.Features == "grenade" or class.Features == "melee" then
invid = invid + 1
if num == 0 then num = 10 end
if num == invid then
if id == wep:bGetReqInvID( hand ) then
-- If we are selected our currently equipped weapon, holster it.
return wep:bSetReqInvID( hand, "" )
else
if wep:bGetReqInvID( hand ) != "" then
-- Something is in this hand
if wep:bGetReqInvID( !hand ) != "" then
-- Something in the other hand
wep:bSetReqInvID( !hand, wep:bGetReqInvID( hand ) )
wep:bSetReqInvID( hand, id )
return
else
-- Nothing in the other hand
wep:bSetReqInvID( !hand, "" )
wep:bSetReqInvID( hand, id )
return
end
else
-- Nothing in this hand.
if wep:bGetReqInvID( !hand ) == id then
-- Weapon we want is in the other hand.
wep:bSetReqInvID( !hand, "" )
wep:bSetReqInvID( hand, id )
return
end
end
return wep:bSetReqInvID( hand, id )
end
end
end
end
return wep:bSetReqInvID( hand, "" )
end
hook.Add( "PlayerButtonDown", "Benny_PlayerButtonDown_Inv", function( ply, button )
local wep = ply:BennyCheck()
if dads[button] then
beatup( ply, dads[button] )
end
end)

View File

@ -0,0 +1,155 @@
-- Movement
local blop = Angle()
if CLIENT then
lastmoveangle = lastmoveangle or 0
lastmoveangle_lerp = lastmoveangle_lerp or nil
TPSOverride = TPSOverride or Angle()
end
hook.Add( "PlayerNoClip", "Benny_PlayerNoClip", function( ply, desiredNoClipState )
if CLIENT then
if desiredNoClipState then
ply:SetEyeAngles( TPSOverride )
else
TPSOverride:Set( LocalPlayer():EyeAngles() )
lastmoveangle = LocalPlayer():EyeAngles().y
lastmoveangle_lerp = LocalPlayer():EyeAngles().y
end
end
end)
hook.Add( "InputMouseApply", "Benny_InputMouseApply", function( cmd, x, y, ang )
local p = LocalPlayer()
local w = p:BennyCheck()
local cdis = false
if w and w:bWepClass( false ) and w:bWepClass( false ).Custom_DisableSpecialMovement and w:bWepClass( false ).Custom_DisableSpecialMovement( w ) then cdis = true end
if w and w:bWepClass( true ) and w:bWepClass( true ).Custom_DisableSpecialMovement and w:bWepClass( true ).Custom_DisableSpecialMovement( w ) then cdis = true end
if GetConVar("benny_cam_override"):GetString() != "" then cdis = true end
if p:NoclippingAndNotVaulting() then cdis = true end
if w and !cdis and (y!=0 or x!=0) then
TPSOverride:Add( Angle( y*0.022, -x*0.022, 0 ) )
return true
end
end)
hook.Add( "CreateMove", "Benny_CreateMove", function( cmd )
if false and BENNY_ACTIVECAMERA and !LocalPlayer():NoclippingAndNotVaulting() then
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
local lx=input.GetAnalogValue(ANALOG_JOY_X) // Left X Axis: left -, right +
local ly=input.GetAnalogValue(ANALOG_JOY_Y) // Left Y Axis: up -, bottom +
local lr=input.GetAnalogValue(ANALOG_JOY_R) // Right X Axis: left -, right +
local lu=input.GetAnalogValue(ANALOG_JOY_U) // Right Y Axis: up -, bottom +
lx=lx/32768; ly=ly/32768; lr=lr/32768; lu=lu/32768; // Conversion to floats -1.0 - 1.0
if lx != 0 or ly != 0 then
x, y = ly * -320, lx * 320
end
local ad = Vector( x, y, 0 )
local an = Angle()
an:Set( RenderAngles() )
an.p = 0
local am = Angle()
am:Set( cmd:GetViewAngles() )
am.p = 0
ad:Rotate( am )
ad:Rotate( -an )
-- ad:Normalize()
-- ad:Mul(320)
--cmd:ClearMovement()
cmd:SetForwardMove( ad.x )
cmd:SetSideMove( ad.y )
if x != 0 or y != 0 then
local thing = Vector( x, -y, 0 ):Angle()
thing.y = thing.y + an.y
blop.y = math.ApproachAngle( blop.y, thing.y, FrameTime() * 360 )
end
cmd:SetViewAngles( blop )
end
local p = LocalPlayer()
local w = p:BennyCheck()
local cdis = false
if w then
if w:bWepClass( false ) and w:bWepClass( false ).Custom_DisableSpecialMovement and w:bWepClass( false ).Custom_DisableSpecialMovement( w ) then cdis = true end
if w:bWepClass( true ) and w:bWepClass( true ).Custom_DisableSpecialMovement and w:bWepClass( true ).Custom_DisableSpecialMovement( w ) then cdis = true end
end
if GetConVar("benny_cam_override"):GetString() != "" then cdis = true end
if LocalPlayer():NoclippingAndNotVaulting() then cdis = true end
if w and !cdis then -- FPS cam
local aimed = w:GetUserAim()
local opos, ang = p:CamSpot( TPSOverride )
local lx=input.GetAnalogValue(ANALOG_JOY_X) // Left X Axis: left -, right +
local ly=input.GetAnalogValue(ANALOG_JOY_Y) // Left Y Axis: up -, bottom +
local lr=input.GetAnalogValue(ANALOG_JOY_R) // Right X Axis: left -, right +
local lu=input.GetAnalogValue(ANALOG_JOY_U) // Right Y Axis: up -, bottom +
lx=lx/32768; ly=ly/32768; lr=lr/32768; lu=lu/32768; // Conversion to floats -1.0 - 1.0
local moveintent
if lx != 0 or ly != 0 then
moveintent = Vector( ly * -320, lx * 320, 0 )
else
moveintent = Vector( cmd:GetForwardMove(), cmd:GetSideMove(), 0 )
end
local dir_p, dir_y = lr>0, lu>0
dir_p = dir_p and 1 or -1
dir_y = dir_y and -1 or 1
local look_p, look_y = dir_p * math.ease.InCirc( math.abs(lr) ), dir_y * math.ease.InCirc( math.abs(lu) )
-- ang:Add( Angle( cmd:GetMouseY()*0.022, -cmd:GetMouseX()*0.022, 0 ) )
ang:Add( Angle( look_p * 180 * 0.5 * FrameTime(), look_y * 180 * FrameTime(), 0 ) )
ang.p = math.Clamp( ang.p, -89.9, 89.9 )
ang:Normalize()
if aimed then
local tr = util.TraceLine( {
start = opos,
endpos = opos+(ang:Forward()*(2^16)),
filter = p,
mask = MASK_SHOT,
} )
local planner = (tr.HitPos-p:EyePos()):Angle()
planner:Normalize()
cmd:SetViewAngles( planner )
lastmoveangle = planner.y
end
if !aimed then
if !moveintent:IsEqualTol( vector_origin, 1 ) then
lastmoveangle = ang.y - moveintent:Angle().y
end
lastmoveangle_lerp = math.ApproachAngle( lastmoveangle_lerp or lastmoveangle, lastmoveangle, FrameTime() * 360 )
cmd:SetViewAngles( Angle( ang.p, lastmoveangle_lerp, 0 ) )
else
lastmoveangle_lerp = lastmoveangle
end
local fixang = Angle()
fixang.y = cmd:GetViewAngles().y - ang.y
moveintent:Rotate( fixang )
-- cmd:ClearMovement()
cmd:SetForwardMove( moveintent.x )
cmd:SetSideMove( moveintent.y )
end
end)
function GM:PlayerNoClip()
return true
end

View File

@ -0,0 +1,207 @@
local small = Vector( 1, 1, 1 )
local smale = -small
local moe = Vector( 0, 0, 1/16 )
local dmaxs = Vector( 1, 1, 1 )
local dmins = -dmaxs
local dcol = Color( 255, 0, 255, 0 )
local dW = Color( 255, 255, 255, 0 )
local dB = Color( 0, 0, 0, 0 )
local dS = Color( 255, 0, 0, 0 )
local dC = Color( 0, 0, 255, 0 )
hook.Add( "PlayerTick", "Benny_PlayerTick", function( ply, mv )
if ply:GetVaultTransition() == 0 then
ply:SetVaultDebuff( math.Approach( ply:GetVaultDebuff(), 0, FrameTime()/0.25 ) )
end
end)
hook.Add( "SetupMove", "Benny_SetupMove", function( ply, mv, cmd )
if !ply:OnGround() and mv:KeyDown( IN_DUCK ) then
local newbuttons = bit.band(mv:GetButtons(), bit.bnot(IN_DUCK))
mv:SetButtons(newbuttons)
end
end)
local function Vault_GetAngle( ply, pos, ang, vel )
return true
end
local VAULTCHECKDIST = 8
local VAULTMOVEDIST = 32
local MAXVAULTHEIGHT = 64
local MAXVAULTHEIGHT_FUCKERY = MAXVAULTHEIGHT+1
local MAXVAULTHEIGHT_V = Vector( 0, 0, MAXVAULTHEIGHT_FUCKERY )
if CLIENT then
hook.Add( "CreateMove", "Benny_ADV_CreateMove", function( cmd )
local ply = LocalPlayer()
if ply:KeyDown( IN_SPEED ) then
cmd:AddKey( IN_ALT1 )
end
end)
end
hook.Add( "StartCommand", "Benny_StartCommand", function( ply, cmd )
end)
hook.Add( "Move", "Benny_Move", function( ply, mv )
local ang = mv:GetMoveAngles()
local pos = mv:GetOrigin()
local vel = mv:GetVelocity()
local speed = mv:GetMaxSpeed() * (1-ply:GetVaultDebuff())
mv:SetMaxSpeed( speed )
mv:SetMaxClientSpeed( speed )
local forw, side = mv:GetForwardSpeed(), mv:GetSideSpeed()
local ba, bb = ply:GetHull()
if ply:Crouching() then ba, bb = ply:GetHullDuck() end
local WishDir = Vector( forw, -side, 0 ):GetNormalized()
WishDir:Rotate( Angle( 0, ang.y, 0 ) )
local Target = Vector( pos )
local TargetNor = Vector()
if !WishDir:IsZero() then
TargetNor:Set( WishDir )
elseif vel:Length2D() > 100 then
local NoZ = Vector( vel )
NoZ.z = 0
NoZ:Normalize()
TargetNor:Set( NoZ )
else
local NoUp = Angle( ang )
NoUp.p = 0
TargetNor = NoUp:Forward()
end
local CR = HSVToColor( math.Rand( 0, 360 ), 1, 1 )
CR.a = 8
--debugoverlay.Box( Target, ba, bb, 0, CR )
local Checker = Target + TargetNor*VAULTCHECKDIST
local Desire = Target + TargetNor*VAULTMOVEDIST
local T1 = util.TraceHull( {
start = Target,
endpos = Checker,
mins = ba,
maxs = bb,
filter = ply,
} )
if CLIENT then vaultsave = false end
if ply:GetVaultDebuff() == 0 and !ply:NoclippingAndNotVaulting() and T1.Hit then -- A challenger approaches
-- How tall is it, basically? We still need to do a ledge check
local T2 = util.TraceHull( {
start = Desire + MAXVAULTHEIGHT_V,
endpos = Desire,
mins = ba,
maxs = bb,
filter = ply,
} )
-- debugoverlay.Box( T2.HitPos, ba, bb, 0, CR )
-- Let's check our vertical clearance
local Clearance = Vector( Target.x, Target.y, T2.HitPos.z )
local T3 = util.TraceHull( {
start = Target,
endpos = Clearance,
mins = ba,
maxs = bb,
filter = ply,
} )
-- debugoverlay.SweptBox( T3.StartPos, T3.HitPos, ba, bb, angle_zero, 0, CR )
local VertClearance = T3.HitPos.z - T3.StartPos.z
-- If we try to go so high and it's TOO high then give up
if VertClearance > ply:GetStepSize() and VertClearance <= MAXVAULTHEIGHT then
-- Trace from clearance to final
local T4 = util.TraceHull( {
start = T3.HitPos,
endpos = T2.HitPos,
mins = ba,
maxs = bb,
filter = ply,
} )
-- debugoverlay.SweptBox( T4.StartPos, T4.HitPos, ba, bb, angle_zero, 0, CR )
local Compare1, Compare2 = Vector( Target.x, Target.y, 0 ), Vector( T4.HitPos.x, T4.HitPos.y, 0 )
if !Compare1:IsEqualTol( Compare2, 1/16 ) then
if CLIENT then vaultsave = true end
if mv:KeyDown( IN_JUMP ) then
ply:SetVaultPos1( ply:GetPos() )
ply:SetVaultPos2( T4.HitPos )
ply:SetVaultTransition( 1 )
ply:SetVaultDebuff( 1 )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:SelectWeightedSequence( ACT_GMOD_GESTURE_BOW ), 0.75, true )
--mv:SetOrigin( T4.HitPos )
return true
end
end
end
end
if ply:GetVaultTransition() != 0 then
ply:SetVaultTransition( math.Approach( ply:GetVaultTransition(), 0, FrameTime()/0.25 ) )
local t, vp1, vp2 = ply:GetVaultTransition(), ply:GetVaultPos1(), ply:GetVaultPos2()
local Meow = Vector( Lerp( (1-t), vp1.x, vp2.x ), Lerp( (1-t), vp1.y, vp2.y ), Lerp( math.ease.OutQuint(1-t), vp1.z, vp2.z ) )
mv:SetOrigin( Meow )
mv:SetVelocity( Vector( 0, 0, 0 ) )
ply:SetVaultDebuff( 1 )
ply:SetMoveType( (ply:GetVaultTransition() == 0) and MOVETYPE_WALK or MOVETYPE_NOCLIP )
return true
end
local w = ply:BennyCheck()
local hand = false
if w and w:bWepClass( hand ) then
local targetspeed = mv:GetMaxSpeed()
targetspeed = targetspeed * w:GetStat( hand, "Speed_Move" )
targetspeed = targetspeed * Lerp( w:GetAim(), 1, w:GetStat( hand, "Speed_Aiming" ) )
local st = w:bGetShotTime( hand )
targetspeed = targetspeed * (st+w:GetStat( hand, "Speed_FiringTime" ) > CurTime() and w:GetStat( hand, "Speed_Firing" ) or 1)
targetspeed = targetspeed * (w:bGetReloadTime( hand ) > 0 and w:GetStat( hand, "Speed_Reloading" ) or 1)
mv:SetMaxSpeed( targetspeed )
mv:SetMaxClientSpeed( targetspeed )
end
if ply:GetJumpBoost() == 0 then
if mv:KeyDown( IN_ALT1 ) then
local dig = Vector( mv:GetForwardSpeed()+0.01, mv:GetSideSpeed(), 0 ):GetNormalized()
local dug = Angle( 0, ply:EyeAngles().y, 0 )
local upspeed = 180
local movespeed = 250
dig:Mul( movespeed )
if !ply:OnGround() then upspeed = mv:GetVelocity().z end
ply:SetGroundEntity( NULL )
mv:SetVelocity( dug:Forward()*dig.x + dug:Right()*dig.y + (vector_up*upspeed) )
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_JUMP, ply:SelectWeightedSequence( ACT_GMOD_GESTURE_RANGE_ZOMBIE_SPECIAL ), 0.6, true )
ply:SetJumpBoost( 1 )
if CLIENT and IsFirstTimePredicted() then
ply:EmitSound( "weapons/slam/throw.wav", 70, 200, 0.5 )
end
end
elseif ply:OnGround() then
if mv:KeyDown( IN_ALT1 ) then
ply:SetJumpBoost( -1 )
else
ply:SetJumpBoost( 0 )
end
end
--debugoverlay.Box( Target+(TargetNor*16), ba, bb, 0, CR )
end)

View File

@ -0,0 +1,354 @@
function GM:PlayerSpawn( ply )
player_manager.SetPlayerClass( ply, "player_benny" )
ply:SetViewOffset( Vector( 0, 0, 64 ) )
ply:SetViewOffsetDucked( Vector( 0, 0, 50 ) )
ply:Give( "benny" )
ply:SetStamina( 1 )
ply:SetCrouchedWalkSpeed( 0.3 )
ply:SetDuckSpeed( 0.1 )
ply:SetUnDuckSpeed( 0.1 )
ply:SetSlowWalkSpeed( 100 )
ply:SetWalkSpeed( 200 )
ply:SetRunSpeed( 200 )
ply:SetStepSize( 16 )
ply:SetCanZoom( false )
ply:MakeCharacter()
end
local PT = FindMetaTable( "Player" )
local bgl = {
["benny"] = {
[0] = Vector( 0.275, 0.7, 0.7 ),
[1] = 17,
[2] = 7,
[3] = 2,
[4] = 11,
[5] = 3,
[6] = 0,
[7] = 0,
[8] = 3,
[9] = 0,
[10] = 0,
[11] = 0,
[12] = 3,
[13] = 0,
},
["nikki"] = {
[0] = Vector( 0.9, 0.3, 0.9 ),
[1] = 17,
[2] = 7,
[3] = 2,
[4] = 11,
[5] = 3,
[6] = 0,
[7] = 0,
[8] = 2,
[9] = 1,
[10] = 5,
[11] = 0,
[12] = 3,
[13] = 0,
},
["igor"] = {
[0] = Vector( 0.776, 0.929, 0.89 ),
[1] = 4,
[2] = 6,
[3] = 2,
[4] = 3,
[5] = 1,
[6] = 0,
[7] = 2,
[8] = 3,
[9] = 3,
[10] = 6,
[11] = 2,
[12] = 1,
[13] = 0,
},
["yanghao"] = {
[0] = Vector( 0.627, 0.21, 0.186 ),
[1] = 13,
[2] = 2,
[3] = 0,
[4] = 3,
[5] = 0,
[6] = 1,
[7] = 3,
[8] = 0,
[9] = 3,
[10] = 4,
[11] = 0,
[12] = 0,
[13] = 0,
},
["mp_cia"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_plasof"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_militia"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_natguard"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_viper"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_halo"] = {
[0] = Vector( 1, 1, 1 )
},
}
function PT:MakeCharacter()
local char = ConVarSV_String("tempchar")
self:SetModel( "models/player/infoplayerrealism.mdl" )
self:SetPlayerColor( bgl[char][0] )
self:SetBodygroup( 0, 0 )
self:SetSkin( 3 )
for i, v in ipairs( bgl[char] ) do
self:SetBodygroup( i, v )
end
end
function PT:BennyCheck()
local wep = self:GetActiveWeapon()
return ( wep:IsValid() and wep:GetClass() == "benny" and wep.GetUserAim ) and wep or false
end
function PT:CamSpot( ang )
local w = self:GetActiveWeapon()
if !IsValid( w ) then w = false end
local aim = w and w:GetAim() or 0
if w then aim = w:GetUserAim() and math.ease.OutCubic( aim ) or math.ease.InCubic( aim ) end
local pos = self:GetPos()
local perc = math.TimeFraction( self:GetViewOffset().z, self:GetViewOffsetDucked().z, self:GetCurrentViewOffset().z )
pos.z = pos.z + Lerp( perc, 64, 52 )
pos:Add( Lerp( aim, 16, 16 ) * ang:Right() )
pos:Add( Lerp( aim, -64, -32 ) * ang:Forward() )
pos:Add( 0 * ang:Up() )
pos:Add( Lerp( aim, 16, 16 ) * ang:Up() * (ang.p/90) )
local tr = util.TraceHull( {
start = self:GetPos() + Vector( 0, 0, Lerp( perc, 64, 52 ) ),
endpos = pos,
mins = -Vector( 4, 4, 4 ),
maxs = Vector( 4, 4, 4 ),
filter = self
})
return tr.HitPos, ang, 90
end
function PT:NoclippingAndNotVaulting()
return (self:GetMoveType() == MOVETYPE_NOCLIP and self:GetVaultTransition() == 0)
end
function PT:INV_Get()
if !self.INV then
print( "Inventory created for " .. tostring(self) )
self.INV = {}
end
return self.INV
end
function PT:INV_Discard( id )
if self:INV_Get()[ id ] then
self:INV_Get()[ id ] = nil
end
end
SORTS = {
["Acquisition"] = function( a, b ) return inv[b]["Acquisition"] > inv[a]["Acquisition"] end,
}
function PT:INV_Find( class, exclude )
local inv = self:INV_Get()
local results = {}
for i, v in pairs( inv ) do
if v.Class == class and i != (exclude or "") then
table.insert( results, i )
end
end
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION AND MIGHT RUN EVERY FRAME!!!
table.sort( results, function( a, b ) return inv[b]["Acquisition"] > inv[a]["Acquisition"] end )
-- table.sort( results, SORTS["Acquisition"] )
return results
end
local T_WEIGHT = {
["sniper"] = 45,
["machinegun"] = 40,
["rifle"] = 35,
["shotgun"] = 30,
["smg"] = 25,
["pistol"] = 20,
["melee"] = 15,
["special"] = 10,
["utility"] = 05,
["equipment"] = 00,
["grenade"] = -10,
["magazine"] = -100,
["base"] = -1000,
}
function PT:INV_Weight()
local inv = self:INV_Get()
local results = {}
for i, v in pairs( inv ) do
if WeaponGet(v.Class).Features != "magazine" then
table.insert( results, { inv[i], WeaponGet(v.Class) } )
end
end
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION AND MIGHT RUN EVERY FRAME!!!
table.sort( results, function( a, b )
return (T_WEIGHT[b[2]["Category"]] - b[1]["Acquisition"]*(1e-5))
< (T_WEIGHT[a[2]["Category"]] - a[1]["Acquisition"]*(1e-5))
end )
local finale = {}
for i, v in ipairs( results ) do
table.insert( finale, v[1] )
end
return finale
end
function PT:INV_FindMag( class, exclude )
local inv = self:INV_Get()
local results = {}
for i, v in pairs( inv ) do
-- PROTO: STANAG mags and such should share, and this'll need to be changed.
if v.Class == ("mag_" .. class) and (exclude and !exclude[i] or !exclude and true) then
table.insert( results, i )
end
end
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION AND MIGHT RUN EVERY FRAME!!!
table.sort( results, function( a, b ) return (inv[b]["Ammo"] - (inv[b]["Acquisition"]*(1e-5))) < (inv[a]["Ammo"] - (inv[a]["Acquisition"]*(1e-5))) end )
return results
end
function PT:INV_FindMagSmart( class, loader )
local inv = self:INV_Get()
local loadm = inv[loader]
local addexc = {}
for i, v in pairs( inv ) do
if v.Loaded and v.Loaded != "" then
addexc[v.Loaded] = true
end
end
local findmag = self:INV_FindMag( class, addexc )
local f_maginv = {}
if addexc[loadm.Loaded] or loadm.Loaded != "" then table.insert( f_maginv, loadm.Loaded ) end
for i, v in ipairs( findmag ) do
table.insert( f_maginv, v )
end
return f_maginv
end
do
local translat = {
["melee"] = { 1, 1 },
["special"] = { 1, 2 },
["pistol"] = { 2, 1 },
["smg"] = { 3, 1 },
["shotgun"] = { 4, 1 },
["sniper"] = { 5, 1 },
["rifle"] = { 5, 2 },
["machinegun"] = { 5, 3 },
["grenade"] = { 6, 1 },
["utility"] = { 6, 2 },
["equipment"] = { 7, 1 },
["magazine"] = { 8, 1 },
["base"] = { 8, 2 },
}
-- PROTO: Cache this!
function PT:INV_Buckets()
local inventorylist = {
[1] = {},
[2] = {},
[3] = {},
[4] = {},
[5] = {},
[6] = {},
[7] = {},
[8] = {},
}
-- PROTO: HOLY SHIT THIS SUCKS, MAKES A FUNCTION EVERY FRAME, AND RUNS EVERY FRAME!!!
local inv = self:INV_Get()
local function BucketSorter(a, b)
return (inv[b[1]]["Acquisition"] + (b[2]*10000)) > (inv[a[1]]["Acquisition"] + (a[2]*10000))
end
for i, bucket in ipairs( inventorylist ) do
local temp = {}
for id, data in pairs( inv ) do
local idata = WeaponGet(data.Class)
local translated = translat[idata.Category]
if i == translated[1] then
table.insert( temp, { id, translated[2] } )
end
end
table.sort( temp, BucketSorter )
for i, v in ipairs( temp ) do
table.insert( bucket, v[1] )
end
end
return inventorylist
end
function PT:INV_ListFromBuckets()
local buckets = self:INV_Buckets()
local complete = {}
for n, bucket in ipairs( buckets ) do
for i, v in ipairs( bucket ) do
table.insert( complete, v )
end
end
return complete
end
end
-- weapon select
hook.Add("StartCommand", "Benny_INV_StartCommand", function( ply, cmd )
-- local wep = ply:BennyCheck()
-- if wep then
-- local hand = wep:GetTempHandedness()
-- local inv = ply:INV_Get()
-- local inv_bucketlist = ply:INV_ListFromBuckets()
-- local inv_bucketlist_flipped = table.Flip( inv_bucketlist )
-- if CLIENT and ply.CLIENTDESIRE and inv[ply.CLIENTDESIRE ] and inv_bucketlist_flipped[ ply.CLIENTDESIRE ] then
-- cmd:SetUpMove( inv_bucketlist_flipped[ ply.CLIENTDESIRE ] )
-- end
-- if CLIENT and (wep:bGetInvID( hand ) == ply.CLIENTDESIRE) then
-- ply.CLIENTDESIRE = 0
-- print("Fixed")
-- end
-- local id = cmd:GetUpMove()
-- if id > 0 and inv_bucketlist[id] and inv[inv_bucketlist[id]] then
-- wep:BDeploy( hand, inv_bucketlist[ id ] )
-- end
-- end
end)
-- cmd:KeyDown( IN_WEAPON1 )
-- cmd:KeyDown( IN_WEAPON2 )
-- cmd:KeyDown( IN_BULLRUSH )
-- cmd:KeyDown( IN_GRENADE1 )
-- cmd:KeyDown( IN_GRENADE2 )

View File

@ -0,0 +1,45 @@
AddCSLuaFile()
local PLAYER = {}
PLAYER.DisplayName = "Benny Player Class"
PLAYER.SlowWalkSpeed = 200
PLAYER.WalkSpeed = 250
PLAYER.RunSpeed = 280
PLAYER.CrouchedWalkSpeed = 0.3
PLAYER.DuckSpeed = 0.3
PLAYER.UnDuckSpeed = 0.3
PLAYER.JumpPower = 200
PLAYER.CanUseFlashlight = false
PLAYER.MaxHealth = 100
PLAYER.MaxArmor = 100
PLAYER.StartHealth = 100
PLAYER.StartArmor = 0
PLAYER.DropWeaponOnDie = false
PLAYER.TeammateNoCollide = true
PLAYER.AvoidPlayers = true
PLAYER.UseVMHands = true
function PLAYER:Init()
self.Player:AddEFlags( EFL_NO_DAMAGE_FORCES )
end
function PLAYER:SetupDataTables()
self.Player:NetworkVar( "Bool", 0, "Shoulder" )
self.Player:NetworkVar( "Int", 0, "JumpBoost" )
self.Player:NetworkVar( "Float", 0, "VaultDebuff" )
self.Player:NetworkVar( "Float", 1, "VaultTransition" )
self.Player:NetworkVar( "Float", 2, "Stamina" )
self.Player:NetworkVar( "Vector", 0, "VaultPos1")
self.Player:NetworkVar( "Vector", 1, "VaultPos2")
self.Player:NetworkVar( "String", 0, "ReqID1")
self.Player:NetworkVar( "String", 1, "ReqID2")
end
player_manager.RegisterClass( "player_benny", PLAYER, "player_default" )

View File

@ -0,0 +1,318 @@
local PANEL = {
Init = function( self )
end,
DoClick = function( self )
self:GetParent():Toggle()
end,
UpdateColours = function( self, skin )
end,
Paint = function( self )
return true
end,
GenerateExample = function()
end
}
derma.DefineControl( "BCategoryHeader", "Category Header", PANEL, "DButton" )
local PANEL = {}
AccessorFunc( PANEL, "m_bSizeExpanded", "Expanded", FORCE_BOOL )
AccessorFunc( PANEL, "m_iContentHeight", "StartHeight" )
AccessorFunc( PANEL, "m_fAnimTime", "AnimTime" )
AccessorFunc( PANEL, "m_bDrawBackground", "PaintBackground", FORCE_BOOL )
AccessorFunc( PANEL, "m_bDrawBackground", "DrawBackground", FORCE_BOOL ) -- deprecated
AccessorFunc( PANEL, "m_iPadding", "Padding" )
AccessorFunc( PANEL, "m_pList", "List" )
function PANEL:Init()
self.Header = vgui.Create( "BCategoryHeader", self )
self.Header:Dock( TOP )
self.Header:SetSize( ss(12), ss(12) )
self:SetSize( ss(8), ss(8) )
self:SetExpanded( true )
self:SetMouseInputEnabled( true )
self:SetAnimTime( 0.2 )
self.animSlide = Derma_Anim( "Anim", self, self.AnimSlide )
self:SetPaintBackground( true )
end
function PANEL:Add( strName )
local button = vgui.Create( "DButton", self )
button.Paint = function( panel, w, h ) end
button.UpdateColours = function( button, skin )
if ( button.AltLine ) then
if ( button.Depressed || button.m_bSelected ) then return button:SetTextStyleColor( skin.Colours.Category.LineAlt.Text_Selected ) end
if ( button.Hovered ) then return button:SetTextStyleColor( skin.Colours.Category.LineAlt.Text_Hover ) end
return button:SetTextStyleColor( skin.Colours.Category.LineAlt.Text )
end
if ( button.Depressed || button.m_bSelected ) then return button:SetTextStyleColor( skin.Colours.Category.Line.Text_Selected ) end
if ( button.Hovered ) then return button:SetTextStyleColor( skin.Colours.Category.Line.Text_Hover ) end
return button:SetTextStyleColor( skin.Colours.Category.Line.Text )
end
button:SetHeight( ss(8) )
button.DoClickInternal = function()
if ( self:GetList() ) then
self:GetList():UnselectAll()
else
self:UnselectAll()
end
button:SetSelected( true )
end
button:Dock( TOP )
self:InvalidateLayout( true )
self:UpdateAltLines()
return button
end
function PANEL:UnselectAll()
for k, v in ipairs( self:GetChildren() ) do
if ( v.SetSelected ) then
v:SetSelected( false )
end
end
end
function PANEL:UpdateAltLines()
for k, v in ipairs( self:GetChildren() ) do
v.AltLine = k % 2 != 1
end
end
function PANEL:Think()
self.animSlide:Run()
end
function PANEL:SetLabel( strLabel )
self.Header:SetText( strLabel )
end
function PANEL:SetHeaderHeight( height )
self.Header:SetTall( height )
end
function PANEL:GetHeaderHeight()
return self.Header:GetTall()
end
function PANEL:Paint( w, h )
local h1 = self:GetHeaderHeight()
local ex = self:GetExpanded()
if ex then
surface.SetDrawColor( schema( "fg" ) )
surface.DrawRect( 0, 0, w, h1, ss(0.5) )
else
surface.SetDrawColor( schema( "fg" ) )
surface.DrawOutlinedRect( 0, 0, w, h1, ss(0.5) )
end
surface.SetDrawColor( schema( "fg" ) )
surface.DrawOutlinedRect( 0, h1, w, h-h1, ss(0.5) )
draw.SimpleText( (ex and "- " or "> "), "Benny_12", ss(3), ss(0.5), schema_c(ex and "bg" or "fg"), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
draw.SimpleText( self.Header:GetText(), "Benny_12", ss(3+8), ss(1), schema_c(ex and "bg" or "fg"), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
return false
end
function PANEL:SetContents( pContents )
self.Contents = pContents
self.Contents:SetParent( self )
self.Contents:Dock( FILL )
if ( !self:GetExpanded() ) then
self.OldHeight = self:GetTall()
elseif ( self:GetExpanded() && IsValid( self.Contents ) && self.Contents:GetTall() < 1 ) then
self.Contents:SizeToChildren( false, true )
self.OldHeight = self.Contents:GetTall()
self:SetTall( self.OldHeight )
end
self:InvalidateLayout( true )
end
function PANEL:SetExpanded( expanded )
self.m_bSizeExpanded = tobool( expanded )
if ( !self:GetExpanded() ) then
if ( !self.animSlide.Finished && self.OldHeight ) then return end
self.OldHeight = self:GetTall()
end
end
function PANEL:Toggle()
self:SetExpanded( !self:GetExpanded() )
self.animSlide:Start( self:GetAnimTime(), { From = self:GetTall() } )
self:InvalidateLayout( true )
self:GetParent():InvalidateLayout()
self:GetParent():GetParent():InvalidateLayout()
local open = "1"
if ( !self:GetExpanded() ) then open = "0" end
self:SetCookie( "Open", open )
self:OnToggle( self:GetExpanded() )
end
function PANEL:OnToggle( expanded )
-- Do nothing / For developers to overwrite
end
function PANEL:DoExpansion( b )
if ( self:GetExpanded() == b ) then return end
self:Toggle()
end
function PANEL:PerformLayout()
if ( IsValid( self.Contents ) ) then
if ( self:GetExpanded() ) then
self.Contents:InvalidateLayout( true )
self.Contents:SetVisible( true )
else
self.Contents:SetVisible( false )
end
end
if ( self:GetExpanded() ) then
if ( IsValid( self.Contents ) && #self.Contents:GetChildren() > 0 ) then self.Contents:SizeToChildren( false, true ) end
self:SizeToChildren( false, true )
else
if ( IsValid( self.Contents ) && !self.OldHeight ) then self.OldHeight = self.Contents:GetTall() end
self:SetTall( self:GetHeaderHeight() )
end
-- Make sure the color of header text is set
self.Header:ApplySchemeSettings()
self.animSlide:Run()
self:UpdateAltLines()
end
function PANEL:OnMousePressed( mcode )
if ( !self:GetParent().OnMousePressed ) then return end
return self:GetParent():OnMousePressed( mcode )
end
function PANEL:AnimSlide( anim, delta, data )
self:InvalidateLayout()
self:InvalidateParent()
if ( anim.Started ) then
if ( !IsValid( self.Contents ) && ( self.OldHeight || 0 ) < self.Header:GetTall() ) then
-- We are not using self.Contents and our designated height is less
-- than the header size, something is clearly wrong, try to rectify
self.OldHeight = 0
for id, pnl in ipairs( self:GetChildren() ) do
self.OldHeight = self.OldHeight + pnl:GetTall()
end
end
if ( self:GetExpanded() ) then
data.To = math.max( self.OldHeight, self:GetTall() )
else
data.To = self:GetTall()
end
end
if ( IsValid( self.Contents ) ) then self.Contents:SetVisible( true ) end
self:SetTall( Lerp( delta, data.From, data.To ) )
end
function PANEL:LoadCookies()
local Open = self:GetCookieNumber( "Open", 1 ) == 1
self:SetExpanded( Open )
self:InvalidateLayout( true )
self:GetParent():InvalidateLayout()
self:GetParent():GetParent():InvalidateLayout()
end
function PANEL:GenerateExample( ClassName, PropertySheet, Width, Height )
local ctrl = vgui.Create( ClassName )
ctrl:SetLabel( "Category List Test Category" )
ctrl:SetSize( 300, 300 )
ctrl:SetPadding( 10 )
ctrl:SetHeaderHeight( 32 )
-- The contents can be any panel, even a DPanelList
local Contents = vgui.Create( "DButton" )
Contents:SetText( "This is the content of the control" )
ctrl:SetContents( Contents )
ctrl:InvalidateLayout( true )
PropertySheet:AddSheet( ClassName, ctrl, nil, true, true )
end
derma.DefineControl( "BCollapsibleCategory", "Collapsable Category Panel", PANEL, "Panel" )

View File

@ -0,0 +1,202 @@
local tall = 12
local PANEL = {}
AccessorFunc( PANEL, "m_bIsMenuComponent", "IsMenu", FORCE_BOOL )
AccessorFunc( PANEL, "m_bDraggable", "Draggable", FORCE_BOOL )
AccessorFunc( PANEL, "m_bSizable", "Sizable", FORCE_BOOL )
AccessorFunc( PANEL, "m_bScreenLock", "ScreenLock", FORCE_BOOL )
AccessorFunc( PANEL, "m_bDeleteOnClose", "DeleteOnClose", FORCE_BOOL )
AccessorFunc( PANEL, "m_bPaintShadow", "PaintShadow", FORCE_BOOL )
AccessorFunc( PANEL, "m_iMinWidth", "MinWidth", FORCE_NUMBER )
AccessorFunc( PANEL, "m_iMinHeight", "MinHeight", FORCE_NUMBER )
AccessorFunc( PANEL, "m_bBackgroundBlur", "BackgroundBlur", FORCE_BOOL )
PANEL.Title = "No title"
function PANEL:Init()
self:SetFocusTopLevel( true )
self:SetPaintShadow( true )
self.btnClose = vgui.Create( "DButton", self )
self.btnClose:SetText( "" )
self.btnClose.DoClick = function ( button ) self:Close() end
self.btnClose.Paint = function( panel, w, h )
surface.SetDrawColor( schema( "fg" ) )
surface.DrawRect( 0, 0, w, h )
draw.SimpleText( "X", "Benny_10", ss(3.3), ss(0), schema_c( "bg" ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP)
return true
end
self:SetDraggable( true )
self:SetSizable( false )
self:SetScreenLock( false )
self:SetDeleteOnClose( true )
self:SetTitle( "Window" )
self:SetMinWidth( ss(50) )
self:SetMinHeight( ss(50) )
-- This turns off the engine drawing
self:SetPaintBackgroundEnabled( false )
self:SetPaintBorderEnabled( false )
self.m_fCreateTime = SysTime()
self:DockPadding( ss(2), ss(2+tall), ss(2), ss(2) )
end
function PANEL:ShowCloseButton( bShow )
self.btnClose:SetVisible( bShow )
end
function PANEL:GetTitle()
return self.Title
end
function PANEL:SetTitle( strTitle )
self.Title = strTitle
end
function PANEL:Close()
self:SetVisible( false )
if ( self:GetDeleteOnClose() ) then
self:Remove()
end
self:OnClose()
end
function PANEL:OnClose()
end
function PANEL:Center()
self:InvalidateLayout( true )
self:CenterVertical()
self:CenterHorizontal()
end
function PANEL:IsActive()
if ( self:HasFocus() ) then return true end
if ( vgui.FocusedHasParent( self ) ) then return true end
return false
end
function PANEL:Think()
local mousex = math.Clamp( gui.MouseX(), 1, ScrW() - 1 )
local mousey = math.Clamp( gui.MouseY(), 1, ScrH() - 1 )
if ( self.Dragging ) then
local x = mousex - self.Dragging[1]
local y = mousey - self.Dragging[2]
-- Lock to screen bounds if screenlock is enabled
if ( self:GetScreenLock() ) then
x = math.Clamp( x, 0, ScrW() - self:GetWide() )
y = math.Clamp( y, 0, ScrH() - self:GetTall() )
end
self:SetPos( x, y )
end
if ( self.Sizing ) then
local x = mousex - self.Sizing[1]
local y = mousey - self.Sizing[2]
local px, py = self:GetPos()
if ( x < self.m_iMinWidth ) then x = self.m_iMinWidth elseif ( x > ScrW() - px && self:GetScreenLock() ) then x = ScrW() - px end
if ( y < self.m_iMinHeight ) then y = self.m_iMinHeight elseif ( y > ScrH() - py && self:GetScreenLock() ) then y = ScrH() - py end
self:SetSize( x, y )
self:SetCursor( "sizenwse" )
return
end
local screenX, screenY = self:LocalToScreen( 0, 0 )
if ( self.Hovered && self.m_bSizable && mousex > ( screenX + self:GetWide() - 20 ) && mousey > ( screenY + self:GetTall() - 20 ) ) then
self:SetCursor( "sizenwse" )
return
end
if ( self.Hovered && self:GetDraggable() && mousey < ( screenY + ss(tall) ) ) then
self:SetCursor( "sizeall" )
return
end
self:SetCursor( "arrow" )
-- Don't allow the frame to go higher than 0
if ( self.y < 0 ) then
self:SetPos( self.x, 0 )
end
end
function PANEL:Paint( w, h )
surface.SetDrawColor( schema( "bg" ) )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( schema( "fg" ) )
surface.DrawOutlinedRect( 0, 0, w, ss(tall), ss(0.5) )
draw.SimpleText( self.Title, "Benny_12", ss(2), ss(1), schema_c( "fg" ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
return true
end
function PANEL:OnMousePressed()
local screenX, screenY = self:LocalToScreen( 0, 0 )
if ( self.m_bSizable && gui.MouseX() > ( screenX + self:GetWide() - 20 ) && gui.MouseY() > ( screenY + self:GetTall() - 20 ) ) then
self.Sizing = { gui.MouseX() - self:GetWide(), gui.MouseY() - self:GetTall() }
self:MouseCapture( true )
return
end
if ( self:GetDraggable() && gui.MouseY() < ( screenY + ss(tall) ) ) then
self.Dragging = { gui.MouseX() - self.x, gui.MouseY() - self.y }
self:MouseCapture( true )
return
end
end
function PANEL:OnMouseReleased()
self.Dragging = nil
self.Sizing = nil
self:MouseCapture( false )
end
function PANEL:PerformLayout()
self.btnClose:SetPos( self:GetWide() - ss(12+2), ss(2) )
self.btnClose:SetSize( ss(12), ss(tall-4) )
end
derma.DefineControl( "BFrame", "A simple window", PANEL, "EditablePanel" )

View File

@ -0,0 +1,735 @@
do -- Toolgun
WEAPONS["camera"] = {
Name = "CAMERA",
Description = "Developer development device",
Type = "special",
WModel = "models/maxofs2d/camera.mdl",
HoldType = "camera",
GestureDraw = { ACT_HL2MP_GESTURE_RELOAD_REVOLVER, 0.8 },
Delay = (60/300),
Firemodes = FIREMODE_SEMI,
Custom_Fire = function( self, data )
if self:GetDelay1() > CurTime() then
return true
end
self:SetDelay1( CurTime() + 0.2 )
local p = self:GetOwner()
if CLIENT and IsFirstTimePredicted() then
local zp, za, zf = p:EyePos(), p:EyeAngles(), 90
RunConsoleCommand( "benny_cam_override", zp.x .. " " .. zp.y .. " " .. zp.z .. " " .. za.p .. " " .. za.y .. " " .. za.r .. " " .. zf )
end
-- Return true to skip weapon logic
return true
end,
Custom_Reload = function( self, data )
RunConsoleCommand( "benny_cam_override", "" )
-- Return true to skip weapon logic
return true
end,
Custom_DisableSpecialMovement = function( self, data )
-- Return true to skip weapon logic
if self:GetUserAim() then
return true
end
end,
Custom_CalcView = function( self, data )
if self:GetUserAim() and GetConVar("benny_cam_override"):GetString() == "" then
data.drawviewer = false
data.origin = self:GetOwner():EyePos()
data.angles = self:GetOwner():EyeAngles()
return true -- Return true to halt
end
end,
Features = "firearm",
}
end
do -- Handguns
end
do -- SMGs & PDWs
end
do -- Shotguns
WEAPONS["spas12"] = {
Name = "SPAS-12",
Description = "Heavy metal pump-action shotgun.",
Type = "shotgun",
WModel = "models/weapons/w_shotgun.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, 0.5 },
Sound_Fire = "SPAS12.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "SPAS12.MagOut",
Sound_MagIn = "SPAS12.MagIn",
Delay = (60/120),
Firemodes = FIREMODE_SEMI,
Ammo = 8,
Damage = 10,
Pellets = 8,
Spread = 150/60,
SpreadAdd = 150/60,
SpreadAddMax = 20,
SpreadDecay_Start = 2,
SpreadDecay_End = 30,
SpreadDecay_RampTime = 0.7,
Speed_Move = 0.93,
Speed_Aiming = 0.95,
Speed_Reloading = 0.85,
Speed_Firing = 0.75,
Features = "firearm",
}
WEAPONS["doublebarrel"] = {
Name = "D/B",
Description = "Pocket-sized double-barrelled rocket of fun!",
Type = "shotgun",
WModel = "models/weapons/w_shot_shorty.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, 0.5 },
Sound_Fire = "SPAS12.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "SPAS12.MagOut",
Sound_MagIn = "SPAS12.MagIn",
Delay = (60/120),
Firemodes = FIREMODE_SEMI,
Ammo = 2,
Damage = 10,
Pellets = 8,
Spread = 300/60,
SpreadAdd = 150/60,
SpreadAddMax = 20,
SpreadDecay_Start = 10,
SpreadDecay_End = 30,
SpreadDecay_RampTime = 0.5,
Speed_Move = 0.95,
Speed_Aiming = 0.95,
Speed_Reloading = 0.9,
Speed_Firing = 0.9,
Features = "firearm",
}
WEAPONS["overunder"] = {
Name = "O/U",
Description = "Full-length double-barrelled bar fight finisher.",
Type = "shotgun",
WModel = "models/weapons/w_shot_kozlice.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, 0.5 },
Sound_Fire = "SPAS12.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "SPAS12.MagOut",
Sound_MagIn = "SPAS12.MagIn",
Delay = (60/120),
Firemodes = FIREMODE_SEMI,
Ammo = 2,
Damage = 10,
Pellets = 8,
Spread = 130/60,
SpreadAdd = 130/60,
SpreadAddMax = 20,
SpreadDecay_Start = 10,
SpreadDecay_End = 30,
SpreadDecay_RampTime = 0.5,
Speed_Move = 0.93,
Speed_Aiming = 0.95,
Speed_Reloading = 0.85,
Speed_Firing = 0.85,
Features = "firearm",
}
WEAPONS["aa12"] = {
Name = "AA-12",
Description = "Magazine fed powerhouse.",
Type = "shotgun",
WModel = "models/weapons/w_shot_br99.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, 0.5 },
Sound_Fire = "AA12.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "AA12.MagOut",
Sound_MagIn = "AA12.MagIn",
Delay = (60/180),
Firemodes = FIREMODE_AUTO,
Ammo = 8,
Damage = 8,
Pellets = 8,
Spread = 250/60,
SpreadAdd = 150/60,
SpreadAddMax = 20,
SpreadDecay_Start = 700/60,
SpreadDecay_End = 30,
SpreadDecay_RampTime = 1,
Reload_MagOut = 0.5,
Reload_MagIn = 1.5,
Reload_MagIn_Bonus1 = 1.2,
Reload_MagIn_Bonus2 = 1.2+0.1,
Speed_Move = 0.92,
Speed_Aiming = 0.92,
Speed_Reloading = 0.5,
Speed_Firing = 0.334,
Speed_FiringTime = 0.5,
Features = "firearm",
}
end
do -- Rifles
WEAPONS["fnc"] = {
Name = "FNC PARA",
Description = "Run of the mill automatic assault rifle.",
Type = "rifle",
Icon = Material( "benny/weapons/fnc.png", "smooth" ),
WModel = "models/weapons/w_rif_ar556.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, 0.3 },
Sound_Fire = "FNC.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "FNC.MagOut",
Sound_MagIn = "FNC.MagIn",
Sound_Cock = "FNC.Cock",
Delay = (60/700),
Firemodes = FIREMODE_AUTOSEMI,
Ammo = 30,
Damage = 30,
Spread = 30/60,
SpreadAdd = 22/60,
SpreadAddMax = 10,
SpreadDecay_Start = 0,
SpreadDecay_End = 12,
SpreadDecay_RampTime = 0.2,
Reload_MagOut = 0.3,
Reload_MagIn = 1.3,
Reload_MagIn_Bonus1 = 0.8,
Reload_MagIn_Bonus2 = 0.8+0.1,
Speed_Move = 0.95,
Speed_Aiming = 0.95,
Speed_Reloading = 0.95,
Speed_Firing = 0.95,
Features = "firearm",
}
WEAPONS["qbz"] = {
Name = "QBZ-95",
Description = "Bullpup assault rifle. Low profile, great in close quarters.",
Type = "rifle",
Icon = Material( "benny/weapons/fnc.png", "smooth" ),
WModel = "models/weapons/w_rif_bakm.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, 0.3 },
Sound_Fire = "QBBLSW.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "FNC.MagOut",
Sound_MagIn = "FNC.MagIn",
Sound_Cock = "FNC.Cock",
Delay = (60/800),
Firemodes = FIREMODE_AUTOSEMI,
Ammo = 30,
Damage = 28,
Spread = 45/60,
SpreadAdd = 35/60,
SpreadAddMax = 10,
SpreadDecay_Start = 12,
SpreadDecay_End = 36,
SpreadDecay_RampTime = 0.6,
Reload_MagOut = 0.4,
Reload_MagIn = 1.5,
Reload_MagIn_Bonus1 = 0.8,
Reload_MagIn_Bonus2 = 0.8+0.1,
Speed_Move = 0.975,
Speed_Aiming = 0.975,
Speed_Reloading = 0.975,
Speed_Firing = 0.975,
Features = "firearm",
}
WEAPONS["m16a2"] = {
Name = "M16A2",
Description = "Burst-fire assault rifle. Precise and effective at range.",
Type = "rifle",
Icon = Material( "benny/weapons/m16a2.png", "smooth" ),
WModel = "models/weapons/w_rif_m16a2.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, 0.3 },
Sound_Fire = "M16A2.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "M16A2.MagOut",
Sound_MagIn = "M16A2.MagIn",
Sound_Cock = "M16A2.Cock",
Delay = (60/700),
Firemodes = {
{ Mode = 3 },
{ Mode = 1 },
},
Ammo = 30,
Damage = 32,
Spread = 22/60,
SpreadAdd = 11/60,
SpreadAddMax = 10,
SpreadDecay_Start = 0,
SpreadDecay_End = 12,
SpreadDecay_RampTime = 0.3,
Reload_MagOut = 0.3,
Reload_MagIn = 1.3,
Reload_MagIn_Bonus1 = 0.6,
Reload_MagIn_Bonus2 = 0.6+0.1,
Speed_Move = 0.95,
Speed_Aiming = 0.9,
Speed_Reloading = 0.95,
Speed_Firing = 0.9,
Features = "firearm",
}
end
do -- Sniper rifles
WEAPONS["barrett"] = {
Name = "BARRETT .50c",
Description = "Semi-automatic .50 slinger. Turns people into slushie!",
Type = "sniper",
Icon = Material( "benny/weapons/m16a2.png", "smooth" ),
WModel = "models/weapons/w_snip_awp.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, 0.1 },
Sound_Fire = "Barrett.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "Barrett.MagOut",
Sound_MagIn = "Barrett.MagIn",
Sound_Cock = "Barrett.Cock",
ShootHolsterTime = 1,
Delay = (60/140),
Firemodes = FIREMODE_SEMI,
Ammo = 5,
Damage = 99,
Spread = 5/60,
SpreadAdd = 9,
SpreadAddMax = 18,
SpreadDecay_Start = 4,
SpreadDecay_End = 22,
SpreadDecay_RampTime = 1,
Reload_MagOut = 0.5,
Reload_MagIn = 1.5,
Reload_MagIn_Bonus1 = 1.0,
Reload_MagIn_Bonus2 = 1.0+0.1,
Speed_Move = 0.75,
Speed_Aiming = 0.75,
Speed_Reloading = 0.5,
Speed_Firing = 0.334,
Speed_FiringTime = 1,
Features = "firearm",
}
end
do -- Machine guns
WEAPONS["stoner63"] = {
Name = "STONER 63",
Description = "Box-fed light machine gun that maintains mid-range authority.",
Type = "machinegun",
WModel = "models/weapons/w_mach_hk21e.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_REVOLVER, 0.3 },
Sound_Fire = "Stoner63.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "M16A2.MagOut",
Sound_MagIn = "M16A2.MagIn",
Delay = (60/650),
Firemodes = FIREMODE_AUTOSEMI,
Ammo = 75,
Damage = 32,
Spread = 26/60,
SpreadAdd = 22/60,
SpreadAddMax = 10,
SpreadDecay_Start = 4,
SpreadDecay_End = 36,
SpreadDecay_RampTime = 0.6,
Speed_Move = 0.8,
Speed_Aiming = 0.75,
Speed_Reloading = 0.5,
Speed_Firing = 0.334,
Features = "firearm",
}
WEAPONS["qbblsw"] = {
Name = "QBB-LSW-42",
Description = "Bullpup mag-fed light machine gun that excels in close quarters.",
Type = "machinegun",
WModel = "models/weapons/w_mach_mg36.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_REVOLVER, 0.3 },
Sound_Fire = "QBBLSW.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "M16A2.MagOut",
Sound_MagIn = "M16A2.MagIn",
Delay = (60/850),
Firemodes = FIREMODE_AUTOSEMI,
Ammo = 60,
Damage = 29,
Spread = 36/60,
SpreadAdd = 33/60,
SpreadAddMax = 15,
SpreadDecay_Start = 6,
SpreadDecay_End = 36,
SpreadDecay_RampTime = 0.4,
Speed_Move = 0.8,
Speed_Aiming = 0.8,
Speed_Reloading = 0.75,
Speed_Firing = 0.334,
Features = "firearm",
}
end
do -- Grenades, nothing here is guaranteed.
local function GrenadeFire( self, data, class, hand )
local p = self:GetOwner()
if self:GetGrenadeDown() then
return true
end
if self:bGetHolsterTime( hand ) > 0 then
return true
end
self:SetGrenadeDown( true )
self:SetGrenadeDownStart( CurTime() )
return true
end
local function GrenadeReload( self, data )
return true
end
local function GrenadeCreate( self, data )
-- PROTO: See to getting this done better. Maybe it's spawned while priming the nade for low CL-SV/phys delay?
local p = self:GetOwner()
local class = WeaponGet(data.Class)
local GENT = ents.Create( class.GrenadeEnt )
GENT:SetOwner( p )
local ang = p:EyeAngles()
ang.p = ang.p - 5
GENT:SetPos( p:EyePos() + (ang:Forward()*16) )
GENT:SetAngles( ang + Angle( 0, 0, -90 ) )
GENT.Fuse = self:GetGrenadeDownStart() + class.GrenadeFuse
GENT:Spawn()
local velocity = ang:Forward() * 1500
velocity:Mul( Lerp( math.TimeFraction( 90, 0, ang.p ), 0, 1 ) )
-- velocity:Add( p:EyeAngles():Up() * 500 * Lerp( math.TimeFraction( 0, -90, p:EyeAngles().p ), 0, 1 ) )
GENT:GetPhysicsObject():SetVelocity( velocity )
end
local function GrenadeThrow( self, data )
local p = self:GetOwner()
local class = WeaponGet(data.Class)
self:SetGrenadeDown( false )
-- TEMP: Do this right!
if !class.GrenadeCharge then self:SetGrenadeDownStart( CurTime() ) end
--
local hand = (self:bWepTable( true ) and self:bWepTable( true ).Class == data.Class) or false
self:TPFire( hand )
if SERVER then GrenadeCreate( self, data ) end
local id = self:bGetInvID( hand )
self:BHolster( hand )
if SERVER or (CLIENT and IsFirstTimePredicted()) then
p:INV_Discard( id )
end
-- local subsequent = p:INV_Find( data.Class )[1]
-- if subsequent then
-- self:BDeploy( hand, subsequent )
-- end
end
local function GrenadeThink( self, data, class, hand )
local p = self:GetOwner()
local class = WeaponGet(data.Class)
if self:GetGrenadeDown() then
if true or ( CurTime() >= (self:GetGrenadeDownStart() + class.GrenadeFuse) ) then
GrenadeThrow( self, data )
end
end
return true
end
local function GrenadeHolster( self, data )
if self:GetGrenadeDown() then
GrenadeThrow( self, data )
end
return true
end
WEAPONS["g_frag"] = {
Name = "FRAG GRENADE",
Description = "Pull the pin and throw it the hell away!",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_frag",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_fraggrenade.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_semtex"] = {
Name = "SEMTEX GRENADE",
Description = "Long, audible fuse, but sticks to whatever it touches.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_semtex",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_molotov"] = {
Name = "MOLOTOV COCKTAIL",
Description = "Alcoholic bottle of flame!",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_molotov",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_tknife"] = {
Name = "THROWING KNIFE",
Description = "Lightweight knife to throw and pick back up.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_tknife",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_smoke"] = {
Name = "SMOKE GRENADE",
Description = "Smoke bomb used to conceal a position, and makes enemies cough.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_smoke",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_flashbang"] = {
Name = "FLASHBANG",
Description = "Stun grenade that gives off a bright flash and a loud 'bang'.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_flashbang",
GrenadeFuse = 2,
GrenadeCharge = false,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_prox"] = {
Name = "PROXIMITY MINE",
Description = "Mine that bounces into the air.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_prox",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
end
do -- Equipment, nothing here is guaranteed.
WEAPONS["e_medkit"] = {
Name = "MEDKIT",
Description = "Station that regenerates a portion of health.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_ammo"] = {
Name = "AMMO CRATE",
Description = "Station that replenishes ammo.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
end
-- Ammo generator
for class, data in SortedPairs( WEAPONS ) do
if data.Features == "firearm" then
WEAPONS["mag_" .. class] = {
Name = "MAG: " .. WEAPONS[class].Name,
Description = "Magazine for the " .. WEAPONS[class].Name .. ".",
Type = "magazine",
WModel = "models/weapons/w_pist_glock18.mdl",
HoldType = "slam",
Ammo = WEAPONS[class].Ammo,
Features = "magazine",
}
end
end

View File

@ -0,0 +1,326 @@
--[[
WEAPONS["m92"] = {
Name = "M92FS",
Description = "Accurate pistol, but low caliber won't do much against armor.",
Type = "pistol",
Icon = Material( "benny/weapons/mk23.png", "smooth" ),
WModel = "models/weapons/w_pist_elite_single.mdl",
HoldType = "revolver",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, 0.2 },
GestureDraw = { ACT_HL2MP_GESTURE_RELOAD_REVOLVER, 0.8 },
Sound_Fire = "M92.Fire",
Sound_DryFire = "Common.Dryfire.Pistol",
Sound_Reload = "USP.Reload",
Sound_MagOut = "USP.MagOut",
Sound_MagIn = "USP.MagIn",
Delay = (60/400),
Firemodes = FIREMODE_SEMI,
Ammo = 15,
Damage = 30,
Features = "firearm",
}
WEAPONS["p226"] = {
Name = "P226",
Description = "Special forces pistol in fast .357 ammo.",
Type = "pistol",
Icon = Material( "benny/weapons/mk23.png", "smooth" ),
WModel = "models/weapons/w_pist_p228.mdl",
HoldType = "revolver",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL, 0.2 },
GestureDraw = { ACT_HL2MP_GESTURE_RELOAD_REVOLVER, 0.8 },
Sound_Fire = "P226.Fire",
Sound_DryFire = "Common.Dryfire.Pistol",
Sound_Reload = "USP.Reload",
Sound_MagOut = "P226.MagOut",
Sound_MagIn = "P226.MagIn",
Delay = (60/350),
Firemodes = FIREMODE_SEMI,
Ammo = 13,
Damage = 30,
Features = "firearm",
}
WEAPONS["cqb70"] = {
Name = "CS-70",
Description = "meow",
Type = "shotgun",
WModel = "models/weapons/w_shot_cs3.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, 0.5 },
Sound_Fire = "AA12.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "AA12.MagOut",
Sound_MagIn = "AA12.MagIn",
Delay = (60/120),
Firemodes = FIREMODE_SEMI,
Ammo = 4,
Damage = 10,
Pellets = 8,
Spread = 150/60,
Features = "firearm",
}
WEAPONS["m12ak"] = {
Name = "M12AK",
Description = "meow",
Type = "shotgun",
WModel = "models/weapons/w_shot_saiga.mdl",
HoldType = "rpg",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW, 0.5 },
Sound_Fire = "AA12.Fire",
Sound_DryFire = "Common.Dryfire.Rifle",
Sound_MagOut = "AA12.MagOut",
Sound_MagIn = "AA12.MagIn",
Delay = (60/160),
Firemodes = FIREMODE_SEMI,
Ammo = 5,
Damage = 10,
Pellets = 8,
Spread = 150/60,
Features = "firearm",
}
WEAPONS["g_gas"] = {
Name = "GAS GRENADE",
Description = "Short burst of gas that slows and disorient targets.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_gas",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_claymore"] = {
Name = "CLAYMORE",
Description = "Mine that shoots shrapnel in a cone.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_claymore",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_scrambler"] = {
Name = "SCRAMBLER",
Description = "Disrupts enemy radar based on proximity.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_scrambler",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_emp"] = {
Name = "EMP NADE",
Description = "Disrupts enemy equipment based on proximity.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_emp",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_shockcharge"] = {
Name = "SHOCK CHARGE",
Description = "Charge that stuns and forces enemies to fire their weapons.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_shockcharge",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["g_thermobaric"] = {
Name = "THERMOBARIC GRENADE",
Description = "Burns through armor.",
Type = "grenade",
Custom_Fire = GrenadeFire,
Custom_Reload = GrenadeReload,
Custom_Think = GrenadeThink,
Custom_Holster = GrenadeHolster,
GrenadeEnt = "b-gr_thermobaric",
GrenadeFuse = 4,
GrenadeCharge = true,
WModel = "models/weapons/w_eq_flashbang.mdl",
HoldType = "grenade",
GestureFire = { ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE, 0 },
Features = "grenade",
}
WEAPONS["e_tacinsertion"] = {
Name = "TACTICAL INSERTION",
Description = "Flare that changes your deployment location.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_cover"] = {
Name = "DEPLOYABLE COVER",
Description = ".",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_ddos"] = {
Name = "DDOS",
Description = ".",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_trophysystem"] = {
Name = "TROPHY SYSTEM",
Description = "Disrupts enemy equipment.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_portableradar"] = {
Name = "PORTABLE RADAR",
Description = "Detects nearby enemies based on proximity.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_cameraspike"] = {
Name = "CAMERA SPIKE",
Description = "Mountable camera that gives you a live video feed.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_recondrone"] = {
Name = "RECON DRONE",
Description = "Pilotable hovering recon drone that automatically marks enemies.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_gasdrone"] = {
Name = "GAS DRONE",
Description = "Drone that dispenses toxic gas onto an area.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_suppressionmine"] = {
Name = "SUPPRESSION MINE",
Description = "Mine that detonates to dispense hard-to-see sleeping gas.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
WEAPONS["e_antiarmor"] = {
Name = "ANTI-ARMOR ROUNDS",
Description = "Ammo crate that dispenses armor to disable vehicles.",
Type = "equipment",
WModel = "models/weapons/w_eq_flashbang.mdl",
Features = "grenade",
}
]]

File diff suppressed because it is too large Load Diff

View File

@ -1,160 +0,0 @@
local COLOR_MAIN
local COLOR_DARK
local function qpaint( self, w, h )
surface.SetDrawColor( COLOR_DARK )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( COLOR_MAIN )
surface.DrawOutlinedRect( 1, 1, w-2, h-2, 1 )
draw.SimpleText( self.text, "HUD_36", w/2, 4, COLOR_MAIN, TEXT_ALIGN_CENTER )
end
local settings = {
{
name = "Camera",
items = {
{ type = TYPE_NUMBER, cvar = "cam_f", min = -200, max = 200 },
{ type = TYPE_NUMBER, cvar = "cam_r", min = -30, max = 30 },
{ type = TYPE_NUMBER, cvar = "cam_u", min = -30, max = 30 },
{ type = TYPE_NUMBER, cvar = "cam_fov", min = 30, max = 120 },
{ type = TYPE_BOOL, cvar = "cam_fp" },
{ type = TYPE_NUMBER, cvar = "cam_fp_fov", min = 30, max = 120 },
}
},
{
name = "Gameplay",
items = {
}
},
}
local entries = {
{
name = "RESUME",
DoClick = function( self )
PauseMenu:Remove()
end,
},
{
name = "LOADOUTS",
DoClick = function( self )
PauseMenu:Remove()
end,
},
{
name = "CHANGE TEAM",
DoClick = function( self )
PauseMenu:Remove()
OpenMyTeamMenu()
end,
},
{
name = "SETTINGS",
DoClick = function( self )
if SettingsMenu and SettingsMenu:IsValid() then SettingsMenu:Remove() return end
SettingsMenu = vgui.Create("EditablePanel")
SettingsMenu:SetSize( 300, 500 )
SettingsMenu:NoClipping( true )
function SettingsMenu:Paint( w, h )
surface.SetDrawColor( COLOR_DARK )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( COLOR_MAIN )
surface.DrawOutlinedRect( 1, 1, w-2, h-2, 1 )
end
SettingsMenu:DockPadding( 10, 10, 10, 10 )
function SettingsMenu:PerformLayout( w, h )
local x, y, w, h = PauseMenu:GetBounds()
self:SetPos( x + w + 10, y )
end
local SP = SettingsMenu:Add("DScrollPanel")
SP:Dock(FILL)
for index, data in ipairs( settings ) do
local Cat = SettingsMenu:Add("DCollapsibleCategory")
Cat:SetLabel(data.name)
Cat:Dock(TOP)
SP:AddItem(Cat)
for index, data in ipairs( data.items ) do
if !data.cvarpointer then data.cvarpointer = GetConVar("b-" .. data.cvar) end
if data.type == TYPE_BOOL then
local Changer = vgui.Create("DCheckBoxLabel", Cat)
Changer:Dock( TOP )
Changer:SetConVar( "b-" .. data.cvar )
Changer:SetText( l8( "#Convar." .. data.cvar .. ".Name" ) )
elseif data.type == TYPE_NUMBER then
local Changer = vgui.Create("DNumSlider", Cat)
Changer:Dock( TOP )
Changer:SetConVar( "b-" .. data.cvar )
Changer:SetText( l8( "#Convar." .. data.cvar .. ".Name" ) )
Changer:SetMin( data.min )
Changer:SetMax( data.max )
Changer:SetDecimals( 0 )
Changer:SetDefaultValue( data.cvarpointer:GetDefault() )
end
end
end
end,
},
{
name = "QUIT",
DoClick = function( self )
PauseMenu:Remove()
end,
},
}
local function StartPauseMenu()
if PauseMenu and PauseMenu:IsValid() then PauseMenu:Remove() return end
PauseMenu = vgui.Create("EditablePanel")
PauseMenu:SetSize( 300, 300 )
PauseMenu:SetPos( ScrW()/2 - 300 - 5, ScrH()/2 - 300/2 )
PauseMenu:MakePopup()
PauseMenu:SetKeyboardInputEnabled( true )
local p = LocalPlayer()
local myteam = p:Team()
local MP = BennyGame:GetType() == BG_GTYPE_MP
local CURRCHAR
if BennyGame:GetType() == BG_GTYPE_CAMPAIGN then
CURRCHAR = "benny"
else
CURRCHAR = TEAMS[myteam].factionid
end
COLOR_MAIN = FACTIONS[CURRCHAR].COLOR_MAIN
COLOR_DARK = FACTIONS[CURRCHAR].COLOR_DARK
local CHARNAME = FACTIONS[CURRCHAR].CHARNAME
function PauseMenu:Paint( w, h )
surface.SetDrawColor( COLOR_DARK )
surface.DrawRect( 0, 0, w, h )
surface.SetDrawColor( COLOR_MAIN )
surface.DrawOutlinedRect( 1, 1, w-2, h-2, 1 )
end
PauseMenu:DockPadding( 10, 10, 10, 10 )
function PauseMenu:OnRemove()
if SettingsMenu and SettingsMenu:IsValid() then SettingsMenu:Remove() end
end
for index, data in ipairs( entries ) do
local button = PauseMenu:Add("DButton")
button:Dock(TOP)
button:DockMargin( 0, 0, 0, 10 )
button:SetText( "" )
button:SetTall( 40 )
button.text = data.name
button.Paint = qpaint
button.DoClick = data.DoClick
end
end
function GM:OnPauseMenuShow()
StartPauseMenu()
return false
end

View File

@ -1,425 +0,0 @@
---------------------
-- Your Name is Benny
---------------------
function GM:PlayerInitialSpawn( ply, transiton )
if BennyGame:GetType() == BG_GTYPE_MP then
ply:SetTeam( BennyGame:BestAutoJoinTeam() )
else
ply:SetTeam( 7 )
end
end
function GM:PlayerSpawn( ply )
player_manager.SetPlayerClass( ply, "player_benny" )
ply:SetViewOffset( Vector( 0, 0, 52 ) )
ply:SetViewOffsetDucked( Vector( 0, 0, 52 ) )
ply:Give( "itemhandler" )
ply:Give( "goat_1" )
ply:Give( "goat_2" )
ply:Give( "goat_3" )
ply:Give( "goat_4" )
ply:Give( "goat_5" )
ply:Give( "goat_6" )
ply:Give( "goat_7" )
ply:Give( "goat_8" )
ply:Give( "goat_9" )
ply:Give( "goat_0" )
ply:SetActiveWeapon( ply:GetWeapon( "itemhandler" ) )
ply:SetStamina( 1 )
ply:SetCrouchedWalkSpeed( 0.3 )
ply:SetDuckSpeed( 0.1 )
ply:SetUnDuckSpeed( 0.1 )
ply:SetSlowWalkSpeed( 100 )
ply:SetWalkSpeed( 200 )
ply:SetRunSpeed( 200 )
ply:SetStepSize( 18 )
ply:SetCanZoom( false )
ply:SetHealth_Blood( 1000 )
ply:SetHealth_Stamina( 1000 )
ply:MakeCharacter()
end
function GM:PlayerPostThink( ply )
if ply:GetTouchedObjective():IsValid() then
if ply:GetTouchedObjectiveTime()+0.1 <= CurTime() then
ply:SetTouchedObjective( NULL )
end
end
end
function GM:PlayerNoClip()
return true
end
local PT = FindMetaTable( "Player" )
concommand.Add("b-cheat_setxp", function( ply, cmd, args )
if !ply or !ply:IsValid() then return end
ply:SetLevel_XP( args[1] )
end)
concommand.Add("b-cheat_rewardxp", function( ply, cmd, args )
if !ply or !ply:IsValid() then return end
ply:RewardXP( args[1] )
end)
function PT:RewardXP( amt )
if CLIENT then return end
--self.amountcollected = (self.amountcollected or 0) + amt
self:SetLevel_XP( self:GetLevel_XP() + amt )
--self:ChatPrint( "Rewarded " .. amt .. " XP" )
end
function PT:RewardScore()
if CLIENT then return end
end
local bgl = {
["benny"] = {
[0] = Vector( 0.275, 0.7, 0.7 ),
[1] = 17,
[2] = 7,
[3] = 2,
[4] = 11,
[5] = 3,
[6] = 0,
[7] = 0,
[8] = 3,
[9] = 0,
[10] = 0,
[11] = 0,
[12] = 3,
[13] = 0,
},
["nikki"] = {
[0] = Vector( 0.9, 0.3, 0.9 ),
[1] = 17,
[2] = 7,
[3] = 2,
[4] = 11,
[5] = 3,
[6] = 0,
[7] = 0,
[8] = 2,
[9] = 1,
[10] = 5,
[11] = 0,
[12] = 3,
[13] = 0,
},
["igor"] = {
[0] = Vector( 0.776, 0.929, 0.89 ),
[1] = 4,
[2] = 6,
[3] = 2,
[4] = 3,
[5] = 1,
[6] = 0,
[7] = 2,
[8] = 3,
[9] = 3,
[10] = 6,
[11] = 2,
[12] = 1,
[13] = 0,
},
["yanghao"] = {
[0] = Vector( 0.627, 0.21, 0.186 ),
[1] = 13,
[2] = 2,
[3] = 0,
[4] = 3,
[5] = 0,
[6] = 1,
[7] = 3,
[8] = 0,
[9] = 3,
[10] = 4,
[11] = 0,
[12] = 0,
[13] = 0,
},
["mp_cia"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_plasof"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_militia"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_natguard"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_viper"] = {
[0] = Vector( 1, 1, 1 )
},
["mp_halo"] = {
[0] = Vector( 1, 1, 1 )
},
}
function PT:MakeCharacter()
local char = "benny"
--self:SetModel( "models/player/infoplayerrealism.mdl" )
self:SetModel( "models/benny/player/benny_placeholder3.mdl" )
--self:SetPlayerColor( bgl[char][0] )
--self:SetBodygroup( 0, 0 )
--self:SetSkin( 3 )
--for i, v in ipairs( bgl[char] ) do
-- self:SetBodygroup( i, v )
--end
end
function PT:HandlerCheck()
local wep = self:GetActiveWeapon()
return ( wep:IsValid() and wep:GetClass() == "itemhandler" and wep.GetActiveR ) and wep or false
end
-- Temporary
function GM:UpdateAnimation( ply, vel, maxseqgroundspeed )
ply:SetPlaybackRate( 1 )
local normal = vel:GetNormalized()
local len2d = vel:Length2D()
normal:Rotate( Angle( 0, -ply:EyeAngles().y, 0 ) )
local speed = (len2d/200)
--print( string.format( "x: %G, y: %G", normal.x, normal.y ))
local biggerone = math.max( math.abs(normal.x), math.abs(normal.y) )
local needer = 1+((1-biggerone)/biggerone)
normal.x = normal.x * needer
normal.y = normal.y * needer
local diveend = ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_end_handgun")
local divestart = ply:GetLayerSequence( GESTURE_SLOT_JUMP ) == ply:LookupSequence("dive_start_handgun")
if ply:GetInDive() or diveend then speed = 1 end
ply:SetPoseParameter( "move_x", normal.x * speed )
ply:SetPoseParameter( "move_y", normal.y * speed )
local magic = ply:EyeAngles().y
magic = -(magic - ply:GetRenderAngles().y)
--magic = magic % 180
if magic < -180 then
magic = magic + 360
elseif magic > 180 then
magic = magic - 360
end
magic = magic * 0.75
ply:SetPoseParameter( "aim_p", -ply:EyeAngles().p/90 )
ply:SetPoseParameter( "aim_y", 0 )--magic/90 )
ply:SetAllowFullRotation( false )
--ply:SetAngles( Angle( 0, ply:EyeAngles().y, 0 ) )
ply:SetRenderAngles( Angle( 0, ply:EyeAngles().y, 0 ) )
if diveend then
local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP )
magicnumber = math.Remap( magicnumber, 0.5, 0.75, 1, 0 )
magicnumber = math.Clamp( magicnumber, 0, 1 )
ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber )
elseif divestart then
local magicnumber = ply:GetLayerCycle( GESTURE_SLOT_JUMP )
magicnumber = math.Remap( magicnumber, 0.1, 0.6, 1, 0 )
magicnumber = math.Clamp( magicnumber, 0, 1 )
ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, magicnumber )
else
ply:AnimSetGestureWeight( GESTURE_SLOT_JUMP, 1 )
end
--local dir = ply:GetVelocity():GetNormalized()
--local dira
--if dir:IsZero() or ply:GetVelocity():Length2D() < 50 then
-- dira = ply:EyeAngles().y
--else
-- dira = dir:Angle().y
--end
--ply:SetAngles( Angle( 0, dira, 0 ) )
end
ANIM_IDLE = 0
ANIM_IDLE_RIFLE = 1
ANIM_IDLE_DUCK = 2
ANIM_RUN = 3
ANIM_RUN_RIFLE = 4
local Animations = {
["idle"] = {
["none"] = "idle",
["handgun"] = "idle_handgun",
["rifle"] = "idle_rifle",
},
["run"] = {
["none"] = "run",
["handgun"] = "run_handgun",
["rifle"] = "run_rifle",
},
}
function GM:CalcMainActivity( ply, velocity )
local plyTable = ply:GetTable()
plyTable.CalcIdeal = -1
local w = ply:HandlerCheck()
local wpntype = "none"
if w then
if w:ItemR() and w:ItemR().Class.HoldType then
wpntype = w:ItemR().Class.HoldType
end
end
plyTable.CalcSeqOverride = ply:LookupSequence( Animations["idle"][wpntype] )
if ply:Crouching() then
plyTable.CalcSeqOverride = ply:LookupSequence( "idle_duck" )
end
self:HandlePlayerLanding( ply, velocity, plyTable.m_bWasOnGround )
if true or !( self:HandlePlayerNoClipping( ply, velocity, plyTable ) ||
self:HandlePlayerDriving( ply, plyTable ) ||
self:HandlePlayerVaulting( ply, velocity, plyTable ) ||
self:HandlePlayerJumping( ply, velocity, plyTable ) ||
self:HandlePlayerSwimming( ply, velocity, plyTable ) ||
self:HandlePlayerDucking( ply, velocity, plyTable ) ) then
local len2d = velocity:Length2D()
if ( len2d > 10 ) then plyTable.CalcSeqOverride = ply:LookupSequence( Animations["run"][wpntype] ) end
end
if ply:GetInDive() then
plyTable.CalcSeqOverride = ply:LookupSequence( "dive_idle_handgun" )
end
plyTable.m_bWasOnGround = ply:IsOnGround()
plyTable.m_bWasNoclipping = ( ply:GetMoveType() == MOVETYPE_NOCLIP && !ply:InVehicle() )
return plyTable.CalcIdeal, plyTable.CalcSeqOverride
end
function GM:HandlePlayerJumping( ply, vel )
return false
end
function GM:HandlePlayerVaulting( ply, vel )
return false
end
function GM:HandlePlayerLanding( ply, vel, onground )
return false
end
function GM:HandlePlayerNoClipping( ply, vel )
return false
end
hook.Add( "EntityTakeDamage", "EntityDamageExample", function( target, dmginfo )
if target:IsPlayer() then
dmginfo:ScaleDamage( 0 )
end
end )
if CLIENT then
hook.Add("CreateMove", "Benny_CreateMove_Controls", function( cmd )
if !gui.IsGameUIVisible() then
if input.IsButtonDown( KEY_E ) then
cmd:AddKey( IN_WEAPON1 )
end
if input.IsButtonDown( KEY_Q ) then
cmd:AddKey( IN_WEAPON2 )
end
if input.IsButtonDown( KEY_C ) then
cmd:AddKey( IN_GRENADE1 )
end
if input.IsButtonDown( KEY_Z ) then
cmd:AddKey( IN_GRENADE2 )
end
if input.IsButtonDown( KEY_R ) then
cmd:AddKey( IN_ALT1 )
end
if input.IsButtonDown( KEY_T ) then
cmd:AddKey( IN_ALT2 )
end
if input.IsButtonDown( KEY_X ) then
cmd:AddKey( IN_BULLRUSH )
end
end
end)
end
hook.Add("Move", "Benny_Move", function( ply, mv )
if mv:KeyDown( IN_SPEED ) and !ply:GetInDive() and (ply:GetDivedAt() + 0.5 <= CurTime()) then
local cool = Vector( mv:GetForwardSpeed(), -mv:GetSideSpeed(), 0 )
cool:Normalize()
cool:Rotate( Angle( 0, mv:GetMoveAngles().y, 0 ) )
cool:Mul( 250 )
cool.z = 150
mv:SetVelocity( cool )--(Angle( -30, ply:EyeAngles().y, 0 ):Forward()*250) )
ply:SetGroundEntity( NULL )
ply:SetInDive( true )
ply:SetDivedAt( CurTime() )
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
rfil = RecipientFilter()
rfil:AddPAS(ply:GetPos())
rfil:RemovePlayer( ply )
end
ply:EmitSound("weapons/slam/throw.wav", 70, 100, .25, nil, nil, nil, rfil)
end
end
if ply:OnGround() and ply:GetInDive() then
if (SERVER) or (CLIENT and IsFirstTimePredicted()) then
local rfil = nil
if SERVER then
rfil = RecipientFilter()
rfil:AddPAS(ply:GetPos())
rfil:RemovePlayer( ply )
end
ply:EmitSound("npc/combine_soldier/gear1.wav", 70, 100, .25, nil, nil, nil, rfil)
end
ply:SetInDive(false)
ply:SetDivedAt( CurTime() )
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 )
end
--if !ply:OnGround() and ply:GetInDive() then
-- local da = ply:GetDivedAt()
-- local supertime = math.Remap( CurTime(), da + 0.5, da + 1, 300, 0 )
-- supertime = math.Clamp( supertime, 0, 300 )
-- local vel = mv:GetVelocity()
-- vel.z = vel.z + supertime*FrameTime()
-- mv:SetVelocity( vel )
--end
end)

View File

@ -1,56 +0,0 @@
AddCSLuaFile()
local PLAYER = {}
PLAYER.DisplayName = "Benny Player Class"
PLAYER.SlowWalkSpeed = 200
PLAYER.WalkSpeed = 250
PLAYER.RunSpeed = 280
PLAYER.CrouchedWalkSpeed = 0.3
PLAYER.DuckSpeed = 0.3
PLAYER.UnDuckSpeed = 0.3
PLAYER.JumpPower = 200
PLAYER.CanUseFlashlight = false
PLAYER.MaxHealth = 100
PLAYER.MaxArmor = 100
PLAYER.StartHealth = 100
PLAYER.StartArmor = 0
PLAYER.DropWeaponOnDie = false
PLAYER.TeammateNoCollide = true
PLAYER.AvoidPlayers = true
PLAYER.UseVMHands = true
function PLAYER:Init()
self.Player:AddEFlags( EFL_NO_DAMAGE_FORCES )
end
STANCE_STAND = 0
STANCE_DUCK = 1
STANCE_PRONE = 2
function PLAYER:SetupDataTables()
self.Player:NetworkVar( "Bool", "Shoulder" )
self.Player:NetworkVar( "Bool", "InDive" )
self.Player:NetworkVar( "Int", "JumpBoost" )
self.Player:NetworkVar( "Int", "Health_Blood" )
self.Player:NetworkVar( "Int", "Health_Stamina" )
self.Player:NetworkVar( "Int", "Stance" )
self.Player:NetworkVar( "Int", "Level" )
self.Player:NetworkVar( "Int", "Level_XP" )
self.Player:NetworkVar( "Float", "VaultDebuff" )
self.Player:NetworkVar( "Float", "VaultTransition" )
self.Player:NetworkVar( "Float", "Stamina" )
self.Player:NetworkVar( "Float", "DivedAt" )
self.Player:NetworkVar( "Float", "TouchedObjectiveTime" )
self.Player:NetworkVar( "Entity", "TouchedObjective" )
self.Player:NetworkVar( "Vector", "VaultPos1")
self.Player:NetworkVar( "Vector", "VaultPos2")
end
player_manager.RegisterClass( "player_benny", PLAYER, "player_default" )

View File

@ -1,177 +0,0 @@
if SERVER then return end
if util.IsBinaryModuleInstalled("gdiscord") then
require("gdiscord")
local RPC_AppID = "1287531216630976603"
function DiscordUpdate()
local rpc_data = {}
rpc_data["buttonPrimaryLabel"] = "Join Server"
rpc_data["buttonPrimaryUrl"] = "steam://open/friends"-- .. "108.5.3.134:27015"
rpc_data["buttonSecondaryLabel"] = "Join Server"
rpc_data["buttonSecondaryUrl"] = "steam://open/friends"-- .. "108.5.3.134:27015"
rpc_data["partySize"] = player.GetCount()
rpc_data["partyMax"] = game.MaxPlayers()
rpc_data["largeImageKey"] = "benny_1"--"map_b-mp_6t"
rpc_data["largeImageText"] = "The Six Team Map"
--rpc_data["smallImageKey"] = "doof2"
--rpc_data["smallImageText"] = "Domination"
local NewTime = os.time() - math.floor(CurTime())
local modedata = BennyGame:GetModeData()
local modename = modedata and l8( modedata.name ) or "(unknown)"
local details = modename .. " on " .. BennyGame:GetMapName()
local title = ""
if BennyGame:GetState() == BG_STATE_ACTIVE then
rpc_data["startTimestamp"] = NewTime + BennyGame:GetRoundStartedAt()
rpc_data["endTimestamp"] = NewTime + BennyGame:GetRoundStartedAt() + BennyGame:GetTimeLimit()
local myteam = LocalPlayer():Team()
local myteamscore = BennyGame:GetScoreForTeam( myteam )
if BennyGame.RTeamID[ myteam ] then
-- In play
local BiggestScore = 0
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
BiggestScore = math.max( BiggestScore, BennyGame:GetScoreForTeam( RealTeamID ) )
end
if myteamscore > BiggestScore then
details = details .. " ▪ Winning"
elseif myteamscore == BiggestScore then
details = details .. " ▪ Tied"
else
details = details .. " ▪ Losing"
end
else
details = details .. " ▪ Spectating"
end
local first = true
if BennyGame.RTeamID[ myteam ] then
details = details .. "" .. myteamscore
first = false
else
details = details .. ""
end
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
details = details .. (first and "" or "-") .. BennyGame:GetScoreForTeam( RealTeamID ) -- placeholder, i need a thing
first = false
end
elseif BennyGame:GetState() == BG_STATE_PRE then
rpc_data["startTimestamp"] = NewTime + BennyGame:GetPregameStartedAt()
rpc_data["endTimestamp"] = NewTime + BennyGame:GetPregameStartedAt() + BennyGame:GetPregameTime()
title = "Pregame"
elseif BennyGame:GetState() == BG_STATE_POST then
rpc_data["startTimestamp"] = NewTime + BennyGame:GetRoundFinishedAt()
rpc_data["endTimestamp"] = NewTime + BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime()
title = "Postgame"
elseif BennyGame:GetState() == BG_STATE_WAITINGFORPLAYERS then
rpc_data["startTimestamp"] = nil--NewTime + BennyGame:GetRoundFinishedAt() + BennyGame:GetPostgameTime()
rpc_data["endTimestamp"] = nil
title = "Waiting for Players"
end
rpc_data["details"] = details
rpc_data["state"] = title
DiscordUpdateRPC(rpc_data)
end
hook.Add("Think", "RPresence_Think_Discord", function()
if !RPC_Initialized then
DiscordRPCInitialize(RPC_AppID)
DiscordUpdate()
RPC_Initialized = true
RPC_NextUpdate = RealTime() + 1
end
if RPC_NextUpdate <= RealTime() then
DiscordUpdate()
RPC_NextUpdate = RealTime() + 1
end
end)
else
print("A module is missing: gdiscord")
end
if util.IsBinaryModuleInstalled("steamrichpresencer") then
require("steamrichpresencer")
function SteamUpdate()
local title = "Your Name Is Benny"
--title = " ▪ Domination on SixT"
--title = " ▪ Winning"
--title = " ▪ 999-10"
local modedata = BennyGame:GetModeData()
local modename = modedata and l8( modedata.name ) or "(unknown)"
title = title .. "" .. modename .. " on " .. BennyGame:GetMapName()
if BennyGame:GetState() == BG_STATE_ACTIVE then
local myteam = LocalPlayer():Team()
local myteamscore = BennyGame:GetScoreForTeam( myteam )
if BennyGame.RTeamID[ myteam ] then
-- In play
local BiggestScore = 0
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
BiggestScore = math.max( BiggestScore, BennyGame:GetScoreForTeam( RealTeamID ) )
end
if myteamscore > BiggestScore then
title = title .. " ▪ Winning"
elseif myteamscore == BiggestScore then
title = title .. " ▪ Tied"
else
title = title .. " ▪ Losing"
end
else
title = title .. " ▪ Spectating"
end
local first = true
if BennyGame.RTeamID[ myteam ] then
title = title .. "" .. myteamscore
first = false
else
title = title .. ""
end
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if RealTeamID == myteam then continue end
title = title .. (first and "" or "-") .. BennyGame:GetScoreForTeam( RealTeamID ) -- placeholder, i need a thing
first = false
end
elseif BennyGame:GetState() == BG_STATE_PRE then
title = title .. " ▪ Pregame"
elseif BennyGame:GetState() == BG_STATE_POST then
title = title .. " ▪ Postgame"
elseif BennyGame:GetState() == BG_STATE_WAITINGFORPLAYERS then
title = title .. " ▪ Waiting for Players"
end
steamworks.SetRichPresence("generic", title)
steamworks.SetRichPresence("steam_player_group", tostring(BennyGame:GetUUID()) )
steamworks.SetRichPresence("steam_player_group_size", tostring(#player.GetHumans()) )
end
hook.Add("Think", "RPresence_Think_Steam", function()
if (Steam_NextUpdate or 0) <= RealTime() then
SteamUpdate()
Steam_NextUpdate = RealTime() + 1
end
end)
else
print("A module is missing: steamrichpresencer")
end

View File

@ -1,77 +1,39 @@
-- Thing
GM.Name = "Your Name Is Benny" GM.Name = "Your Name Is Benny"
GM.Author = "Fesiug, Oranche, Alex" GM.Author = "Fesiug, Oranche"
GM.Email = "N/A" GM.Email = "N/A"
GM.Website = "N/A" GM.Website = "N/A"
BENNY = {} BENNY = {}
function BENNY.SimpleAutoComplete( cmd, args, ... ) -- just stole it from the wiki -- Load modules
local possibleArgs = { ... } local path = GM.FolderName .. "/gamemode/modules/"
local autoCompletes = {} local modules, folders = file.Find(path .. "*", "LUA")
--TODO: Handle "test test" "test test" type arguments for _, folder in SortedPairs(folders, false) do
args = args:upper() if folder == "." or folder == ".." then continue end
local arg = string.Split( args:TrimLeft(), " " )
local lastItem = nil -- Shared modules
for i, str in pairs( arg ) do for _, f in SortedPairs(file.Find(path .. folder .. "/sh_*.lua", "LUA"), false) do
if ( str == "" && ( lastItem && lastItem == "" ) ) then table.remove( arg, i ) end AddCSLuaFile(path .. folder .. "/" .. f)
lastItem = str include(path .. folder .. "/" .. f)
end -- Remove empty entries. Can this be done better?
local numArgs = #arg
local lastArg = table.remove( arg, numArgs )
local prevArgs = table.concat( arg, " " )
if ( #prevArgs > 0 ) then prevArgs = " " .. prevArgs end
local possibilities = possibleArgs[ numArgs ] or { lastArg }
for _, acStr in pairs( possibilities ) do
if ( !acStr:StartsWith( lastArg ) ) then continue end
table.insert( autoCompletes, cmd .. prevArgs .. " " .. acStr )
end end
return autoCompletes -- Server modules
if SERVER then
for _, f in SortedPairs(file.Find(path .. folder .. "/sv_*.lua", "LUA"), false) do
include(path .. folder .. "/" .. f)
end
end
-- Client modules
for _, f in SortedPairs(file.Find(path .. folder .. "/cl_*.lua", "LUA"), false) do
AddCSLuaFile(path .. folder .. "/" .. f)
if CLIENT then
include(path .. folder .. "/" .. f)
end
end
end end
local AC, IN = AddCSLuaFile, include
local CL = SERVER and AddCSLuaFile or include
function TSelShared( tbl, seed )
return tbl[math.Round( util.SharedRandom( seed, 1, #tbl ) )]
end
-- Language might want to be loaded first
-- Otherwise things will fail to call 'l8'
AC("language.lua")
IN("language.lua")
AC("convars.lua")
IN("convars.lua")
AC("camera.lua")
IN("camera.lua")
AC("items.lua")
IN("items.lua")
AC("player.lua")
IN("player.lua")
AC("player_class.lua")
IN("player_class.lua")
AC("inventory.lua")
IN("inventory.lua")
AC("gamestate.lua")
IN("gamestate.lua")
AC("teams.lua")
IN("teams.lua")
AC("pausemenu.lua")
IN("pausemenu.lua")
AC("richpresence_test.lua")
if CLIENT then
IN("richpresence_test.lua")
end
AC("debugmenu.lua")
IN("debugmenu.lua")
CL("hud.lua")

View File

@ -1,161 +0,0 @@
concommand.Add("b-cheat_setteam", function( ply, cmd, args )
if !ply or !ply:IsValid() then return end
if !args[1] then
print( "Needs an integer." )
for index, data in ipairs( TEAMS ) do
print( index .. " - " .. data.id )
end
else
ply:SetTeam( TEAMS_IDorName( tonumber(args[1]) or args[1] ) )
end
end, function( cmd, args )
return BENNY.SimpleAutoComplete( cmd, args, TEAMS_IDs )
end )
TEAMS = {
[0] = {
name = "unassigned",
description = "unassigned",
factionid = "unassigned",
id = "UNASSIGNED",
},
{
name = "#Team.cia.Name",
description = "#Team.cia.Description",
factionid = "mp_cia",
id = "CIA",
},
{
name = "#Team.halo.Name",
description = "#Team.halo.Description",
factionid = "mp_halo",
id = "HALO",
},
{
name = "#Team.plasof.Name",
description = "#Team.plasof.Description",
factionid = "mp_plasof",
id = "PLASOF",
},
{
name = "#Team.arng.Name",
description = "#Team.arng.Description",
factionid = "mp_arng",
id = "ARNG",
},
{
name = "#Team.militia.Name",
description = "#Team.militia.Description",
factionid = "mp_militia",
id = "MILITIA",
},
{
name = "#Team.viper.Name",
description = "#Team.viper.Description",
factionid = "mp_viper",
id = "VIPER",
},
{
name = "campaign",
description = "internal campaign faction",
factionid = "campaign",
id = "CAMPAIGN",
},
}
-- "PLASOF" -> Team info
TEAMS_IDtoData = {
[TEAMS[0].id] = TEAMS[0],
[TEAMS[1].id] = TEAMS[1],
[TEAMS[2].id] = TEAMS[2],
[TEAMS[3].id] = TEAMS[3],
[TEAMS[4].id] = TEAMS[4],
[TEAMS[5].id] = TEAMS[5],
[TEAMS[6].id] = TEAMS[6],
}
-- "mp_plasof" -> Team info
TEAMS_FIDtoData = {
[TEAMS[0].factionid] = TEAMS[0],
[TEAMS[1].factionid] = TEAMS[1],
[TEAMS[2].factionid] = TEAMS[2],
[TEAMS[3].factionid] = TEAMS[3],
[TEAMS[4].factionid] = TEAMS[4],
[TEAMS[5].factionid] = TEAMS[5],
[TEAMS[6].factionid] = TEAMS[6],
}
-- 3 -> "PLASOF"
TEAMS_IDs = {
TEAMS[1].id,
TEAMS[2].id,
TEAMS[3].id,
TEAMS[4].id,
TEAMS[5].id,
TEAMS[6].id,
}
-- "PLASOF" -> 3
TEAM_IDs2 = table.Flip( TEAMS_IDs )
function TEAMS_IDorName( id )
if isnumber( id ) then
return id
else
return TEAM_IDs2[string.upper(id)]
end
end
function GM:CreateTeams()
for index, data in ipairs( TEAMS ) do
team.SetUp( index, data.name, Color( 0, 0, 255 ) )
team.SetSpawnPoint( index, {"benny_playerstart_team" .. index} )
end
team.SetSpawnPoint( TEAM_SPECTATOR, "worldspawn" )
end
function GM:PlayerSelectTeamSpawn( TeamID, ply )
local SpawnPoints = team.GetSpawnPoints( TeamID )
if ( !SpawnPoints || table.IsEmpty( SpawnPoints ) ) then return end
local ChosenSpawnPoint = nil
for i = 0, 6 do
ChosenSpawnPoint = table.Random( SpawnPoints )
if ( hook.Call( "IsSpawnpointSuitable", GAMEMODE, ply, ChosenSpawnPoint, i == 6 ) ) then
return ChosenSpawnPoint
end
end
return ChosenSpawnPoint
end
function GM:PlayerSelectSpawn( ply, transition )
if ( transition ) then return end
if BennyGame:GetType() == BG_GTYPE_MP then
local ent = self:PlayerSelectTeamSpawn( ply:Team(), ply )
if IsValid( ent ) then return ent end
end
end
function BennyGame:BestAutoJoinTeam()
local SmallestTeam = BennyGame.TeamsInPlay[math.random( 1, BennyGame.TeamCount )]
local SmallestPlayers = 1000
for TeamID, RealTeamID in ipairs( BennyGame.TeamsInPlay ) do
if ( RealTeamID != TEAM_SPECTATOR && RealTeamID != TEAM_UNASSIGNED && RealTeamID != TEAM_CONNECTING ) then
local PlayerCount = team.NumPlayers( RealTeamID )
if PlayerCount < SmallestPlayers or (PlayerCount == SmallestPlayers and RealTeamID < SmallestTeam ) then
SmallestPlayers = PlayerCount
SmallestTeam = RealTeamID
end
end
end
return SmallestTeam
end