Compare commits

..

No commits in common. "7fd2fba51efe9c5a0f7d33f2e6ae2c58390367b1" and "3946029046d2de65ad1f92f1f550cbe52dff5d7e" have entirely different histories.

7 changed files with 76 additions and 125 deletions

View File

@ -0,0 +1,26 @@
SWEP.Base = "weapon_base"
function SWEP:PrimaryAttack()
return true
end
function SWEP:SecondaryAttack()
return true
end
function SWEP:Reload()
return true
end
function SWEP:Think()
return true
end
function SWEP:Deploy()
return true
end
function SWEP:Holster()
return true
end

View File

@ -70,7 +70,7 @@ end
function SWEP:SetActive( ent ) function SWEP:SetActive( ent )
local p = self:GetOwner() local p = self:GetOwner()
if ent:GetOwner() != p then return false end if ent:GetOwner() != p then return false end
--if self:GetActiveR():IsValid() then self:Deactive() end if self:GetActiveR():IsValid() then self:Deactive() end
self:SetActiveR( ent ) self:SetActiveR( ent )
if self:ItemR() then if self:ItemR() then
self:ItemR( "Deploy" ) self:ItemR( "Deploy" )
@ -80,6 +80,12 @@ function SWEP:SetActive( ent )
end end
function SWEP:Deactive() function SWEP:Deactive()
local p = self:GetOwner()
if self:ItemR() then
self:ItemR( "Holster" )
self:ItemR():SetNoDraw( true )
end
self:SetActiveR( NULL )
end end
function SWEP:PrimaryAttack() function SWEP:PrimaryAttack()
@ -163,6 +169,7 @@ function SWEP:DropItem()
local ent = self:GetActiveR() local ent = self:GetActiveR()
if ent:IsValid() then if ent:IsValid() then
if CLIENT then print("DropItem called on CLIENT but certain things aren't finished yet.") return end if CLIENT then print("DropItem called on CLIENT but certain things aren't finished yet.") return end
self:Deactive()
self:SetDesireR( NULL ) self:SetDesireR( NULL )
@ -199,44 +206,40 @@ function SWEP:Think()
local p = self:GetOwner() local p = self:GetOwner()
if p:IsValid() then if p:IsValid() then
local DesireR = self:GetDesireR() local DesireR = self:GetDesireR()
local ActiveR = self:GetActiveR() local ActiveR = self:GetActiveR()
local DesireR_Valid = DesireR:IsValid() local DesireR_Valid = DesireR:IsValid()
local ActiveR_Valid = ActiveR:IsValid() local ActiveR_Valid = ActiveR:IsValid()
if DesireR != ActiveR then -- If we're holding the weapon we want...
print(DesireR, ActiveR) if ActiveR == DesireR then
-- Do nothing
-- If we want no weapon equipped
elseif !DesireR_Valid then
if ActiveR_Valid then if ActiveR_Valid then
if ActiveR:GetHolsterIn() == 0 then self:Deactive()
--self:Deactive()
print("hi?")
ActiveR.Class.Holster( ActiveR.Class, ActiveR, self )
else else
-- wait -- We're holding nothing. Do nothing.
end
-- If we want a weapon equipped
elseif DesireR_Valid then
if ActiveR != DesireR then
self:Deactive()
end end
else
if DesireR_Valid then
self:SetActive( DesireR ) self:SetActive( DesireR )
end 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 p:KeyPressed(IN_WEAPON1) then
if !self:ItemR() then
if SERVER then if SERVER then
if !self:ItemR() then
local trace = self:ItemCheckTrace() local trace = self:ItemCheckTrace()
self:EquipItem( trace.Entity ) self:EquipItem( trace.Entity )
end
else else
ActiveR.Class.Drop( ActiveR.Class, ActiveR, self )
if SERVER then
self:DropItem() self:DropItem()
end end
self:SetActiveR( NULL )
end end
end end
if p:KeyPressed(IN_WEAPON2) then if p:KeyPressed(IN_WEAPON2) then
@ -244,6 +247,7 @@ function SWEP:Think()
if p:KeyPressed(IN_ALT1) then if p:KeyPressed(IN_ALT1) then
end end
if p:KeyPressed(IN_ALT2) then if p:KeyPressed(IN_ALT2) then
end end
if p:KeyPressed(IN_GRENADE1) then if p:KeyPressed(IN_GRENADE1) then
if self:ItemR() and self:ItemR().Class.Alt then if self:ItemR() and self:ItemR().Class.Alt then
@ -256,6 +260,7 @@ function SWEP:Think()
if self:ItemR() then if self:ItemR() then
self:ItemR("Think") self:ItemR("Think")
end end
--self:SetHoldType( self:ItemR() and (self:ItemR().Class.HoldType or "rpg") or "normal" )
else else
print( self, "Thinking without an owner." ) print( self, "Thinking without an owner." )
end end

View File

@ -5,7 +5,7 @@
local cam_f = CreateConVar( "b-cam_f", -75 ) local cam_f = CreateConVar( "b-cam_f", -75 )
local cam_r = CreateConVar( "b-cam_r", 12 ) local cam_r = CreateConVar( "b-cam_r", 12 )
local cam_u = CreateConVar( "b-cam_u", 12 ) local cam_u = CreateConVar( "b-cam_u", 0 )
local cam_fov = CreateConVar( "b-cam_fov", 75 ) local cam_fov = CreateConVar( "b-cam_fov", 75 )
local m = 3 local m = 3

View File

@ -747,52 +747,22 @@ function GM:HUDPaint()
-- S_Pop() -- S_Pop()
--local trac = p:GetEyeTrace().HitPos:ToScreen() 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( { local trac2 = util.TraceLine( {
start = CamSpot(), start = CamSpot(),
endpos = CamSpot() + TPSOverride:Forward()*(2^31), endpos = CamSpot() + TPSOverride:Forward()*(2^16),
filter = p, filter = p,
} ).HitPos } ).HitPos:ToScreen()
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 for i=1, 2 do
local shadowtime = i==1 local shadowtime = i==1
local traac = shadowtime and trac2 or trac local traac = shadowtime and trac2 or trac
local cx, cy = math.Round(traac.x), math.Round(traac.y) local cx, cy = math.Round(traac.x), math.Round(traac.y)
local gap = 4
local length = 4
S_Push( cx, cy ) S_Push( cx, cy )
local lol = shadowtime and 0 or 255 local lol = shadowtime and 0 or 255
local lol2 = shadowtime and 127 or 255 surface.SetDrawColor( lol, lol, lol )
local Shadow_Gap = shadowtime and 1 or 0 surface.SetMaterial( shadowtime and xhair_dot_shadow or xhair_dot )
local Shadow_Thickness = shadowtime and 2 or 0 hTrRect( 0, 0, 64, 64, 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() S_Pop()
end end

View File

@ -199,7 +199,7 @@ end)
for i=0, 9 do for i=0, 9 do
local tent = {} local tent = {}
--tent.Base = "goat" tent.Base = "goat"
tent.Goat = i tent.Goat = i
weapons.Register( tent, "goat_" .. i ) weapons.Register( tent, "goat_" .. i )

View File

@ -38,10 +38,6 @@ function AddItem( itemname, item )
end end
end end
function BaseClassGet( item )
-- TODO
end
AddItem( "base", { AddItem( "base", {
PrintName = "Base Item", PrintName = "Base Item",
Description = "Beginning item base.", Description = "Beginning item base.",
@ -60,23 +56,9 @@ AddItem( "base", {
end, end,
["Deploy"] = function( class, ent, handler ) ["Deploy"] = function( class, ent, handler )
ent:SetNoDraw( false )
end,
["Drop"] = function( class, ent, handler )
end, end,
["Holster"] = function( class, ent, handler ) ["Holster"] = function( class, ent, handler )
ent:SetHolsterIn( CurTime() + 0.5 )
end,
["FinishHolster"] = function( class, ent, handler )
handler:SetActiveR( NULL )
ent:SetNoDraw( true )
end,
["UndoHolster"] = function( class, ent, handler )
ent:SetHolsterIn( 0 )
end, end,
["Attack"] = function( class, ent, handler ) ["Attack"] = function( class, ent, handler )
@ -85,14 +67,7 @@ AddItem( "base", {
["AttackAlt"] = function( class, ent, handler ) ["AttackAlt"] = function( class, ent, handler )
end, end,
["Alt"] = function( class, ent, handler )
end,
["Think"] = function( class, ent, handler ) ["Think"] = function( class, ent, handler )
if ent:GetHolsterIn() != 0 and ent:GetHolsterIn() <= CurTime() then
class:FinishHolster( ent, handler )
ent:SetHolsterIn( 0 )
end
end, end,
["Reload"] = function( class, ent, handler ) ["Reload"] = function( class, ent, handler )
@ -126,7 +101,6 @@ local AnimationLookup = {
}, },
} }
local BaseClass = ITEMS.base
AddItem( "base_firearm", { AddItem( "base_firearm", {
PrintName = "Base Firearm", PrintName = "Base Firearm",
Description = "Item base for firearms.", Description = "Item base for firearms.",
@ -171,7 +145,7 @@ AddItem( "base_firearm", {
BoltPullSound = "benny/weapons/fnc/cock.ogg", BoltPullSound = "benny/weapons/fnc/cock.ogg",
["Initialize"] = function( class, ent, handler ) ["Initialize"] = function( class, ent, handler )
BaseClass.Initialize( class, ent, handler ) ITEMS["base"].Initialize( class, ent, handler )
ent:SetClip( class.ClipSize ) ent:SetClip( class.ClipSize )
ent:SetLoaded(true) ent:SetLoaded(true)
@ -186,7 +160,7 @@ AddItem( "base_firearm", {
local BAuto = class.BurstAuto local BAuto = class.BurstAuto
local Firedown = handler:GetOwner():KeyDown( IN_ATTACK ) local Firedown = handler:GetOwner():KeyDown( IN_ATTACK )
if Runaway and InProcess and !Topped then if Runaway and InProcess and !Topped then
class:Attack( ent, handler ) class["Attack"]( class, ent, handler )
else else
if !Firedown then if !Firedown then
if !Topped and InProcess then if !Topped and InProcess then
@ -203,7 +177,6 @@ AddItem( "base_firearm", {
ent:SetClip( class.ClipSize ) ent:SetClip( class.ClipSize )
ent:SetRefillTime( 0 ) ent:SetRefillTime( 0 )
end end
BaseClass.Think( class, ent, handler )
end, end,
["Attack"] = function( class, ent, handler ) ["Attack"] = function( class, ent, handler )
@ -211,7 +184,6 @@ AddItem( "base_firearm", {
if ent:GetDelay() > CurTime() then return end if ent:GetDelay() > CurTime() then return end
if ent:GetDelayBurst() > CurTime() then return end if ent:GetDelayBurst() > CurTime() then return end
if ent:GetBurstCount() >= class.BurstCount then return end if ent:GetBurstCount() >= class.BurstCount then return end
if ent:GetHolsterIn() != 0 then return end
local Runaway = class.BurstRunaway local Runaway = class.BurstRunaway
local BAuto = class.BurstAuto local BAuto = class.BurstAuto
@ -238,7 +210,6 @@ AddItem( "base_firearm", {
Attacker = p, Attacker = p,
Damage = 1, Damage = 1,
Force = 1, Force = 1,
Tracer = 0,
Num = class.Pellets, Num = class.Pellets,
Dir = p:GetAimVector(), Dir = p:GetAimVector(),
Src = p:GetShootPos(), Src = p:GetShootPos(),
@ -255,8 +226,11 @@ AddItem( "base_firearm", {
end, end,
["Reload"] = function( class, ent, handler ) ["Reload"] = function( class, ent, handler )
--if ent:GetClip() >= class.ClipSize then return end
--handler:EmitSound( "weapons/m4a1/m4a1_boltpull.wav", 70, 125, 0.4, CHAN_STATIC )
--ent:SetRefillTime( CurTime() + 0.1 )
--handler:EmitSound( "benny/weapons/basic.ogg", 70, 100, 0.4, CHAN_STATIC )
if ent:GetDelay() > CurTime() then return end if ent:GetDelay() > CurTime() then return end
if ent:GetHolsterIn() != 0 then return end
local ply = handler:GetOwner() local ply = handler:GetOwner()
local time = 0.6 local time = 0.6
@ -293,40 +267,19 @@ AddItem( "base_firearm", {
end end
end, end,
["Drop"] = function( class, ent, handler )
ent:SetRefillTime( 0 )
BaseClass.Drop( class, ent, handler )
end,
["Holster"] = function( class, ent, handler ) ["Holster"] = function( class, ent, handler )
ent:SetRefillTime( 0 ) ent:SetRefillTime( 0 )
handler:EmitSound( "weapons/elite/elite_deploy.wav", 70, 125, 0.4, CHAN_STATIC ) handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
ent:SetDelay( CurTime() + 0.25 ) ent:SetDelay( CurTime() + 0.25 )
ent:SetHolsterIn( CurTime() + 0.25 )
local ply = handler:GetOwner() local ply = handler:GetOwner()
if SERVER or CLIENT and IsFirstTimePredicted() then if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["holster"][class.HoldType] ), 0, true ) ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["holster"][class.HoldType] ), 0, true )
end end
end, end,
["FinishHolster"] = function( class, ent, handler )
handler:EmitSound( "weapons/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
BaseClass.FinishHolster( class, ent, handler )
end,
["UndoHolster"] = function( class, ent, handler )
BaseClass.UndoHolster( class, ent, handler )
handler:EmitSound( "weapons/elite/elite_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
local ply = handler:GetOwner()
if SERVER or CLIENT and IsFirstTimePredicted() then
ply:AddVCDSequenceToGestureSlot( GESTURE_SLOT_ATTACK_AND_RELOAD, ply:LookupSequence( AnimationLookup["deploy"][class.HoldType] ), 0, true )
end
end,
}) })
local BaseClass = ITEMS.base_firearm
AddItem( "base_firearm_ubgl", { AddItem( "base_firearm_ubgl", {
PrintName = "Base Firearm w/ UBGL", PrintName = "Base Firearm w/ UBGL",
Description = "Item base for firearms that include grenade launchers.", Description = "Item base for firearms that include grenade launchers.",
@ -350,7 +303,7 @@ AddItem( "base_firearm_ubgl", {
ClipSize2 = 4, ClipSize2 = 4,
["Initialize"] = function( class, ent, handler ) ["Initialize"] = function( class, ent, handler )
BaseClass.Initialize( class, ent, handler ) ITEMS["base_firearm"].Initialize( class, ent, handler )
ent:SetClip2( class.ClipSize2 ) ent:SetClip2( class.ClipSize2 )
end, end,
@ -359,7 +312,7 @@ AddItem( "base_firearm_ubgl", {
if ent:GetFiremode() == 1 then if ent:GetFiremode() == 1 then
class:Attack2( ent, handler ) class:Attack2( ent, handler )
else else
BaseClass.Attack( class, ent, handler ) ITEMS["base_firearm"].Attack( class, ent, handler )
end end
end, end,
@ -367,7 +320,7 @@ AddItem( "base_firearm_ubgl", {
if ent:GetFiremode() == 1 then if ent:GetFiremode() == 1 then
class:Reload2( ent, handler ) class:Reload2( ent, handler )
else else
BaseClass.Reload( class, ent, handler ) ITEMS["base_firearm"].Reload( class, ent, handler )
end end
end, end,
@ -376,7 +329,7 @@ AddItem( "base_firearm_ubgl", {
end, end,
["Think"] = function( class, ent, handler ) ["Think"] = function( class, ent, handler )
BaseClass.Think( class, ent, handler ) ITEMS["base_firearm"].Think( class, ent, handler )
if ent:GetRefillTime2() != 0 and ent:GetRefillTime2() <= CurTime() then if ent:GetRefillTime2() != 0 and ent:GetRefillTime2() <= CurTime() then
ent:SetClip2( class.ClipSize2 ) ent:SetClip2( class.ClipSize2 )
@ -404,7 +357,6 @@ AddItem( "base_firearm_ubgl", {
end, end,
}) })
local BaseClass = ITEMS.base
AddItem( "satchels", { AddItem( "satchels", {
PrintName = "#Item.satchels.Name", PrintName = "#Item.satchels.Name",
Description = "#Item.satchels.Description", Description = "#Item.satchels.Description",
@ -452,7 +404,6 @@ AddItem( "satchels", {
end, end,
}) })
local BaseClass = ITEMS.base
AddItem( "toolgun", { AddItem( "toolgun", {
PrintName = "#Item.toolgun.Name", PrintName = "#Item.toolgun.Name",
Description = "#Item.toolgun.Description", Description = "#Item.toolgun.Description",
@ -529,7 +480,6 @@ AddItem( "toolgun", {
end, end,
}) })
local BaseClass = ITEMS.base_firearm
do -- Handguns do -- Handguns
AddItem( "mk23", { AddItem( "mk23", {

View File

@ -13,8 +13,8 @@ end
function GM:PlayerSpawn( ply ) function GM:PlayerSpawn( ply )
player_manager.SetPlayerClass( ply, "player_benny" ) player_manager.SetPlayerClass( ply, "player_benny" )
ply:SetViewOffset( Vector( 0, 0, 52 ) ) ply:SetViewOffset( Vector( 0, 0, 64 ) )
ply:SetViewOffsetDucked( Vector( 0, 0, 52 ) ) ply:SetViewOffsetDucked( Vector( 0, 0, 50 ) )
ply:Give( "itemhandler" ) ply:Give( "itemhandler" )
ply:Give( "goat_1" ) ply:Give( "goat_1" )