Compare commits

...

4 Commits

Author SHA1 Message Date
Fesiug 7fd2fba51e
Improved holstering and baseclass code 2024-09-21 14:08:48 -04:00
Fesiug e87245c419
Raise campos height 2024-09-21 14:07:59 -04:00
Fesiug 5172dcb5d1
Lower playereyes 2024-09-21 14:07:03 -04:00
Fesiug 890b1c5b94
Crosshair edit 2024-09-21 14:06:45 -04:00
7 changed files with 125 additions and 76 deletions

View File

@ -1,26 +0,0 @@
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,12 +80,6 @@ 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()
@ -169,8 +163,7 @@ 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 )
@ -206,40 +199,44 @@ 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 we're holding the weapon we want...
if ActiveR == DesireR then
-- Do nothing
-- If we want no weapon equipped
elseif !DesireR_Valid then
if DesireR != ActiveR then
print(DesireR, ActiveR)
if ActiveR_Valid then
self:Deactive()
if ActiveR:GetHolsterIn() == 0 then
--self:Deactive()
print("hi?")
ActiveR.Class.Holster( ActiveR.Class, ActiveR, self )
else
-- wait
end
else
-- We're holding nothing. Do nothing.
if DesireR_Valid then
self:SetActive( DesireR )
end
end
-- If we want a weapon equipped
elseif DesireR_Valid then
if ActiveR != DesireR then
self:Deactive()
else
if ActiveR_Valid and ActiveR:GetHolsterIn() != 0 then
ActiveR.Class.UndoHolster( ActiveR.Class, ActiveR, self )
end
self:SetActive( DesireR )
end
if p:KeyPressed(IN_WEAPON1) then
if SERVER then
if !self:ItemR() then
if !self:ItemR() then
if SERVER then
local trace = self:ItemCheckTrace()
self:EquipItem( trace.Entity )
else
end
else
ActiveR.Class.Drop( ActiveR.Class, ActiveR, self )
if SERVER then
self:DropItem()
end
self:SetActiveR( NULL )
end
end
if p:KeyPressed(IN_WEAPON2) then
@ -247,7 +244,6 @@ 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
@ -260,7 +256,6 @@ 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", 0 )
local cam_u = CreateConVar( "b-cam_u", 12 )
local cam_fov = CreateConVar( "b-cam_fov", 75 )
local m = 3

View File

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

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,6 +38,10 @@ function AddItem( itemname, item )
end
end
function BaseClassGet( item )
-- TODO
end
AddItem( "base", {
PrintName = "Base Item",
Description = "Beginning item base.",
@ -56,9 +60,23 @@ 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 )
@ -67,7 +85,14 @@ 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 )
@ -101,6 +126,7 @@ local AnimationLookup = {
},
}
local BaseClass = ITEMS.base
AddItem( "base_firearm", {
PrintName = "Base Firearm",
Description = "Item base for firearms.",
@ -145,7 +171,7 @@ AddItem( "base_firearm", {
BoltPullSound = "benny/weapons/fnc/cock.ogg",
["Initialize"] = function( class, ent, handler )
ITEMS["base"].Initialize( class, ent, handler )
BaseClass.Initialize( class, ent, handler )
ent:SetClip( class.ClipSize )
ent:SetLoaded(true)
@ -160,7 +186,7 @@ AddItem( "base_firearm", {
local BAuto = class.BurstAuto
local Firedown = handler:GetOwner():KeyDown( IN_ATTACK )
if Runaway and InProcess and !Topped then
class["Attack"]( class, ent, handler )
class:Attack( ent, handler )
else
if !Firedown then
if !Topped and InProcess then
@ -177,6 +203,7 @@ AddItem( "base_firearm", {
ent:SetClip( class.ClipSize )
ent:SetRefillTime( 0 )
end
BaseClass.Think( class, ent, handler )
end,
["Attack"] = function( class, ent, handler )
@ -184,6 +211,7 @@ 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
@ -210,6 +238,7 @@ AddItem( "base_firearm", {
Attacker = p,
Damage = 1,
Force = 1,
Tracer = 0,
Num = class.Pellets,
Dir = p:GetAimVector(),
Src = p:GetShootPos(),
@ -226,11 +255,8 @@ 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
@ -266,20 +292,41 @@ 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/m4a1/m4a1_deploy.wav", 70, 125, 0.4, CHAN_STATIC )
handler:EmitSound( "weapons/elite/elite_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.",
@ -303,7 +350,7 @@ AddItem( "base_firearm_ubgl", {
ClipSize2 = 4,
["Initialize"] = function( class, ent, handler )
ITEMS["base_firearm"].Initialize( class, ent, handler )
BaseClass.Initialize( class, ent, handler )
ent:SetClip2( class.ClipSize2 )
end,
@ -312,7 +359,7 @@ AddItem( "base_firearm_ubgl", {
if ent:GetFiremode() == 1 then
class:Attack2( ent, handler )
else
ITEMS["base_firearm"].Attack( class, ent, handler )
BaseClass.Attack( class, ent, handler )
end
end,
@ -320,7 +367,7 @@ AddItem( "base_firearm_ubgl", {
if ent:GetFiremode() == 1 then
class:Reload2( ent, handler )
else
ITEMS["base_firearm"].Reload( class, ent, handler )
BaseClass.Reload( class, ent, handler )
end
end,
@ -329,7 +376,7 @@ AddItem( "base_firearm_ubgl", {
end,
["Think"] = function( class, ent, handler )
ITEMS["base_firearm"].Think( class, ent, handler )
BaseClass.Think( class, ent, handler )
if ent:GetRefillTime2() != 0 and ent:GetRefillTime2() <= CurTime() then
ent:SetClip2( class.ClipSize2 )
@ -357,6 +404,7 @@ AddItem( "base_firearm_ubgl", {
end,
})
local BaseClass = ITEMS.base
AddItem( "satchels", {
PrintName = "#Item.satchels.Name",
Description = "#Item.satchels.Description",
@ -404,6 +452,7 @@ AddItem( "satchels", {
end,
})
local BaseClass = ITEMS.base
AddItem( "toolgun", {
PrintName = "#Item.toolgun.Name",
Description = "#Item.toolgun.Description",
@ -480,6 +529,7 @@ 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, 64 ) )
ply:SetViewOffsetDucked( Vector( 0, 0, 50 ) )
ply:SetViewOffset( Vector( 0, 0, 52 ) )
ply:SetViewOffsetDucked( Vector( 0, 0, 52 ) )
ply:Give( "itemhandler" )
ply:Give( "goat_1" )