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

View File

@ -5,7 +5,7 @@
local cam_f = CreateConVar( "b-cam_f", -75 )
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 m = 3

View File

@ -747,52 +747,22 @@ function GM:HUDPaint()
-- 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 trac = p:GetEyeTrace().HitPos:ToScreen()
local trac2 = util.TraceLine( {
start = CamSpot(),
endpos = CamSpot() + TPSOverride:Forward()*(2^31),
endpos = CamSpot() + TPSOverride:Forward()*(2^16),
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
} ).HitPos:ToScreen()
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
surface.SetDrawColor( lol, lol, lol )
surface.SetMaterial( shadowtime and xhair_dot_shadow or xhair_dot )
hTrRect( 0, 0, 64, 64, 0 )
S_Pop()
end

View File

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

View File

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

View File

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