Weapons, NPC firsts, wephooks, xhair, captions

This commit is contained in:
Fesiug 2023-10-02 01:25:47 -04:00
parent 09d56cfaf7
commit 0b062dccbf
7 changed files with 409 additions and 44 deletions

View File

@ -0,0 +1,41 @@
AddCSLuaFile()
ENT.Base = "base_nextbot"
ENT.Spawnable = true
if CLIENT then
return
end
function ENT:Initialize()
self:SetModel( "models/barney.mdl" )
self.loco:SetDesiredSpeed( 100 ) -- Walk speed
self.loco:SetStepHeight( 22 )
end
function ENT:RunBehaviour()
while ( true ) do
-- find the furthest away hiding spot
local pos = self:FindSpot( "random", { type = 'hiding', radius = 1000 } )
if pos then
self:StartActivity( ACT_WALK )
self:MoveToPos( pos )
self:StartActivity( ACT_IDLE )
end
coroutine.wait(1)
coroutine.yield()
end
end
function ENT:OnContact( ent )
if ent != game.GetWorld() then
print( ent )
end
end
function ENT:Think()
end

View File

@ -33,6 +33,9 @@ function SWEP:PrimaryAttack()
if !self:BTable() then
return
end
if self:BClass().Fire then
if self:BClass( false ).Fire( self, false ) then return end
end
if self:GetDelay1() > CurTime() then
return
end
@ -42,9 +45,37 @@ function SWEP:PrimaryAttack()
return
end
B_Sound( self, self:BClass( false ).Sound_Fire )
self:B_Ammo( false, self:Clip1() - 1 )
B_Sound( self, self:BClass( false ).Sound_Fire )
if CLIENT and IsFirstTimePredicted() then
local tr = self:GetOwner():GetEyeTrace()
do
local vStart = self:GetAttachment( 1 ).Pos
local vPoint = tr.HitPos
local effectdata = EffectData()
effectdata:SetStart( vStart )
effectdata:SetOrigin( vPoint )
effectdata:SetEntity( self )
effectdata:SetScale( 5000 )
effectdata:SetFlags( 1 )
util.Effect( "Tracer", effectdata )
end
-- util.DecalEx( Material( util.DecalMaterial( "Impact.Concrete" ) ), tr.Entity, tr.HitPos, tr.HitNormal, color_white, 1, 1 )
do
local effectdata = EffectData()
effectdata:SetOrigin( tr.HitPos )
effectdata:SetStart( tr.StartPos )
effectdata:SetSurfaceProp( tr.SurfaceProps )
effectdata:SetEntity( tr.Entity )
effectdata:SetDamageType( DMG_BULLET )
util.Effect( "Impact", effectdata )
end
end
self:SetDelay1( CurTime() + self:BClass( false ).Delay )
return true
end
@ -95,6 +126,9 @@ end
function SWEP:Reload()
if self:BTable( false ) then
if self:BClass().Reload then
if self:BClass( false ).Reload( self, false ) then return end
end
if self:GetDelay1() > CurTime() then
return false
end

View File

@ -4,43 +4,39 @@
CAPTIONS = {}
CAPTIONS["en-us"] = {}
CAPTIONS["en-us"]["1911.Fire"] = {
Name = "Cobra .45",
Color = color_white,
Text = "[fire]",
Bold = false,
Italic = true,
TypeTime = 0.1,
LifeTime = 0.5,
}
CAPTIONS["en-us"]["1911.Reload"] = {
Name = "Cobra .45",
Color = color_white,
Text = "[reload]",
Bold = false,
Italic = true,
TypeTime = 0.1,
LifeTime = 0.5,
}
CAPTIONS["en-us"]["Bizon.Fire"] = {
Name = "Bizon",
Color = color_white,
Text = "[fire]",
Bold = false,
Italic = true,
TypeTime = 0.1,
LifeTime = 0.5,
}
CAPTIONS["en-us"]["Bizon.Reload"] = {
Name = "Bizon",
Color = color_white,
Text = "[reload]",
Bold = false,
Italic = true,
TypeTime = 0.1,
LifeTime = 0.5,
}
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 )
CAPTIONS = CAPTIONS["en-us"]

View File

@ -293,7 +293,7 @@ hook.Add( "CalcView", "MyCalcView", function( ply, pos, ang, fov )
view.origin = pos
view.angles = ang
view.fov = 90
if camera then
if false and camera then
view.origin = camera.Pos
view.angles = camera.Ang
view.fov = camera.FOV or 60
@ -322,6 +322,11 @@ hook.Add( "CalcView", "MyCalcView", function( ply, pos, ang, fov )
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 )

View File

@ -151,6 +151,22 @@ end
local color_caption = Color( 0, 0, 0, 127 )
local mat_grad = Material( "benny/hud/grad.png", "mips smooth" )
-- Stew port
globhit = Vector()
globang = Angle()
tr1f = Vector()
tr2f = Vector()
local col_1 = Color(255, 255, 255, 200)
local col_2 = Color(0, 0, 0, 255)
local col_3 = Color(255, 127, 127, 255)
local col_4 = Color(255, 222, 222, 255)
local mat_dot = Material("benny/hud/xhair/dot.png", "mips smooth")
local mat_long = Material("benny/hud/xhair/long.png", "mips smooth")
local mat_dot_s = Material("benny/hud/xhair/dot_s.png", "mips smooth")
local mat_long_s = Material("benny/hud/xhair/long_s.png", "mips smooth")
local spacer_long = 2 -- screenscaled
local gap = 24
hook.Add( "HUDPaint", "Benny_HUDPaint", function()
local sw, sh = ScrW(), ScrH()
local b = ss(20)
@ -196,6 +212,7 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
end
do -- Weapon
assert( IsValid(wep) and wep:GetClass() == "benny", "Failed to retrieve 'benny' weapon!" )
local inv = p:INV_Get()
local wep1 = wep:BTable( false )
local wep1c = wep:BClass( false )
@ -316,6 +333,179 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
ind = ind + 1
end
end
do -- Crosshair
local s, w, h = ss, ScrW(), ScrH()
local pl_x, pl_y = w/2, h/2
do
local tr1 = util.TraceLine({
start = p:EyePos(),
endpos = p:EyePos() + (p:EyeAngles():Forward()*16000),
filter = p
})
local tr2 = util.TraceLine({
start = globhit,
endpos = globhit + (globang:Forward()*16000),
filter = p
})
tr1f:Set(tr1.HitPos)
tr2f:Set(tr2.HitPos)
end
pl_x = tr2f:ToScreen().x
pl_y = tr2f:ToScreen().y
ps_x = tr2f:ToScreen().x
ps_y = tr2f:ToScreen().y
local touse1 = col_1
local touse2 = col_2
if ve then
pl_x = tr1f:ToScreen().x
pl_y = tr1f:ToScreen().y
ps_x = tr1f:ToScreen().x
ps_y = tr1f:ToScreen().y
elseif util.TraceLine({start = tr2f, endpos = tr1f, filter = p}).Fraction != 1 and !tr2f:IsEqualTol(tr1f, 1) then
touse1 = col_4
touse2 = col_3
pl_x = tr1f:ToScreen().x
pl_y = tr1f:ToScreen().y
end
for i=1, 2 do
local cooler = i == 1 and touse2 or touse1
local poosx, poosy = i == 1 and ps_x or pl_x, i == 1 and ps_y or pl_y
local mat1 = i == 1 and mat_long_s or mat_long
local mat2 = i == 1 and mat_dot_s or mat_dot
surface.SetDrawColor( cooler )
if wep.XHairMode == "rifle" then
surface.SetMaterial( mat1 )
surface.DrawTexturedRectRotated( poosx - s(spacer_long) - gap, poosy, s(16), s(16), 0 )
surface.DrawTexturedRectRotated( poosx + s(spacer_long) + gap, poosy, s(16), s(16), 0 )
surface.SetMaterial( mat2 )
surface.DrawTexturedRectRotated( poosx, poosy - gap, s(16), s(16), 0 )
surface.DrawTexturedRectRotated( poosx, poosy + gap, s(16), s(16), 0 )
elseif wep.XHairMode == "smg" then
surface.SetMaterial( mat1 )
surface.DrawTexturedRectRotated( poosx, poosy + gap + s(spacer_long), s(16), s(16), 90 )
surface.DrawTexturedRectRotated( poosx - (math.sin(math.rad(45))*gap) - (math.sin(math.rad(45))*s(spacer_long)), poosy - (math.sin(math.rad(45))*gap) - (math.sin(math.rad(45))*s(spacer_long)), s(16), s(16), -45 )
surface.DrawTexturedRectRotated( poosx + (math.sin(math.rad(45))*gap) + (math.sin(math.rad(45))*s(spacer_long)), poosy - (math.sin(math.rad(45))*gap) - (math.sin(math.rad(45))*s(spacer_long)), s(16), s(16), 45 )
surface.SetMaterial( mat2 )
surface.DrawTexturedRectRotated( poosx, poosy, s(16), s(16), 0 )
else -- pistol
surface.SetMaterial( mat2 )
surface.DrawTexturedRectRotated( poosx - gap, poosy, s(24), s(24), 0 )
surface.DrawTexturedRectRotated( poosx + gap, poosy, s(24), s(24), 0 )
surface.SetMaterial( mat2 )
surface.DrawTexturedRectRotated( poosx, poosy - gap, s(24), s(24), 0 )
surface.DrawTexturedRectRotated( poosx, poosy + gap, s(24), s(24), 0 )
end
end
end
end
do -- Quickinv
local inv = p:INV_Get()
local gap = ss(1)
local size_textx = ss(96)
local size_texty = ss(12)
local size_num = ss(12)
local size_thi = ss(0.5)
local nextwe = ss(96+2)
local nextwe_no = ss(12+2)
local item_start = ss(14)
local item_gap = ss(12+2)
local translat = {
["melee"] = { 1, 1 },
["special"] = { 1, 2 },
["pistol"] = { 2, 1 },
["smg"] = { 3, 1 },
["rifle"] = { 3, 2 },
["shotgun"] = { 3, 3 },
}
local inventorylist = {
[1] = {},
[2] = {},
[3] = {},
[4] = {},
}
for i, bucket in ipairs( inventorylist ) do
local temp = {}
for id, data in pairs( inv ) do
local idata = WEAPONS[data.Class]
local translated = translat[idata.Type]
if i == translated[1] then
table.insert( temp, { data, translated[2] } )
end
end
table.sort( temp, function(a, b) return b[2] > a[2] end )
for i, v in ipairs( temp ) do
table.insert( bucket, v[1] )
end
end
-- PrintTable( it )
local bump = 0
for i, bucket in ipairs( inventorylist ) do
surface.SetDrawColor( scheme["bg"] )
surface.DrawRect( bump + b, b, size_num, size_num )
if i==2 then
surface.SetDrawColor( scheme["fg"] )
surface.DrawRect( bump + b + gap, b + gap, size_num - (gap*2), size_num - (gap*2) )
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( bump + b + ss(3), b + ss(1) )
surface.DrawText( i )
else
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["fg"] )
surface.SetTextPos( bump + b + ss(3), b + ss(1) )
surface.DrawText( i )
end
if i!=2 then
for d, item in ipairs( bucket ) do
surface.SetDrawColor( scheme["bg"] )
surface.DrawRect( bump + b, (item_start+item_gap*(d-1)) + b, size_texty, size_texty )
end
bump = bump + (nextwe_no)
else
for d, item in ipairs( bucket ) do
local idata = WEAPONS[item.Class]
surface.SetDrawColor( scheme["bg"] )
surface.DrawRect( bump + b, (item_start+item_gap*(d-1)) + b, size_textx, size_texty )
if d==2 then
surface.SetDrawColor( scheme["fg"] )
surface.DrawRect( bump + b + gap, (item_start+item_gap*(d-1)) + b + gap, size_textx - (gap*2), size_texty - (gap*2) )
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["bg"] )
surface.SetTextPos( bump + b + ss(3), (item_start+item_gap*(d-1)) + b + ss(1) )
surface.DrawText( idata.Name )
else
surface.SetFont( "Benny_12" )
surface.SetTextColor( scheme["fg"] )
surface.SetTextPos( bump + b + ss(3), (item_start+item_gap*(d-1)) + b + ss(1) )
surface.DrawText( idata.Name )
end
end
bump = bump + (nextwe)
end
end
end
do -- Captions

View File

@ -6,7 +6,7 @@ local wa, wb = 0, 0
local blop = Angle()
hook.Add( "CreateMove", "CamFuck", function( cmd )
if BENNY_ACTIVECAMERA and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
if false and BENNY_ACTIVECAMERA and LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
local lx=input.GetAnalogValue(ANALOG_JOY_X) // Left X Axis: left -, right +

View File

@ -96,10 +96,80 @@ AddSound( "Common.Dryfire.Pistol", "benny/weapons/common/06-13.ogg", 70, 100, 0.
AddSound( "Common.Dryfire.Rifle", "benny/weapons/common/06-12.ogg", 70, 100, 0.5, CHAN_STATIC )
AddSound( "Common.NoAmmo", "benny/weapons/noammo.ogg", 70, 100, 0.5, CHAN_STATIC )
local wep = {}
WEAPONS["toolgun"] = wep
wep.Name = "TOOL GUN"
wep.Description = "Developer development device"
wep.Type = "special"
wep.WModel = "models/weapons/w_toolgun.mdl"
wep.Delay = (60/300)
wep.Firemodes = FIREMODE_SEMI
wep.Ammo = 0
wep.Damage = 0
function wep.Fire( self, slot )
if self:GetDelay1() > CurTime() then
return true
end
self:SetDelay1( CurTime() + 0.2 )
local p = self:GetOwner()
local tr = p:GetEyeTrace()
if SERVER then
local summon = ents.Create( "bnpc_human" )
-- summon:SetModel( "models/props_junk/cardboard_box001a.mdl" )
-- summon:Give( "weapon_stunstick")
summon:SetPos( tr.HitPos )
summon:Spawn()
end
if CLIENT and IsFirstTimePredicted() then
local vStart = self:GetAttachment( 1 ).Pos
local vPoint = tr.HitPos
local effectdata = EffectData()
effectdata:SetStart( vStart )
effectdata:SetOrigin( vPoint )
util.Effect( "ToolTracer", effectdata )
end
-- Return true to skip weapon logic
return true
end
function wep.Reload( self, slot )
if self:GetOwner():KeyPressed( IN_RELOAD ) then
print( self )
end
-- Return true to skip weapon logic
return true
end
local wep = {}
WEAPONS["melee_bat"] = wep
wep.Name = "BASEBALL BAT"
wep.Description = "meow"
wep.Type = "melee"
wep.WModel = "models/weapons/w_crowbar.mdl"
local wep = {}
WEAPONS["melee_baton"] = wep
wep.Name = "POLICE BATON"
wep.Description = "meow"
wep.Type = "melee"
wep.WModel = "models/weapons/w_crowbar.mdl"
local wep = {}
WEAPONS["1911"] = wep
wep.Name = "COBRA .45"
wep.Description = "Hits hard. They don't make them like they used to!"
wep.Type = "pistol"
wep.WModel = "models/weapons/w_pist_usp.mdl"
wep.Sound_Fire = "1911.Fire"
@ -117,6 +187,7 @@ local wep = {}
WEAPONS["usp"] = wep
wep.Name = "USP .45"
wep.Description = "If it works for hardasses around the world, it works for you."
wep.Type = "pistol"
wep.WModel = "models/weapons/w_pist_usp.mdl"
wep.Sound_Fire = "USP.Fire"
@ -134,6 +205,7 @@ local wep = {}
WEAPONS["glock"] = wep
wep.Name = "GLOCK-18"
wep.Description = "Bullet storm. Lasts about a second or so, just like you!"
wep.Type = "pistol"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "Glock.Fire"
@ -150,6 +222,7 @@ local wep = {}
WEAPONS["nambu"] = wep
wep.Name = "NAMBU .38"
wep.Description = "Eastern revolver that hits as hard as it costs."
wep.Type = "pistol"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "Nambu.Fire"
@ -166,6 +239,7 @@ local wep = {}
WEAPONS["anaconda"] = wep
wep.Name = "ANACONDA"
wep.Description = "Precise and kicks like a mule."
wep.Type = "pistol"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "Anaconda.Fire"
@ -182,6 +256,7 @@ local wep = {}
WEAPONS["tmp"] = wep
wep.Name = "TMP"
wep.Description = "Precise and sharp, like a damn suit's pet."
wep.Type = "smg"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "TMP.Fire"
@ -198,7 +273,8 @@ wep.Damage = 18
local wep = {}
WEAPONS["mp7"] = wep
wep.Name = "MP7"
wep.Description = "Small, pistol-sized, and simple."
wep.Description = "Small, pistol-sized."
wep.Type = "smg"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "MP7.Fire"
@ -209,13 +285,14 @@ wep.Sound_MagIn = "MP7.MagIn" -- placeholder
wep.Delay = (60/700)
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 15
wep.Ammo = 20
wep.Damage = 16
local wep = {}
WEAPONS["mp5k"] = wep
wep.Name = "MP5K"
wep.Description = "Quality manufacturing, but cumbersome."
wep.Type = "smg"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "MP5K.Fire"
@ -233,6 +310,7 @@ local wep = {}
WEAPONS["mac11"] = wep
wep.Name = "MAC-11"
wep.Description = "More fit for combat in a phone booth."
wep.Type = "smg"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "MAC11.Fire"
@ -250,6 +328,7 @@ local wep = {}
WEAPONS["bizon"] = wep
wep.Name = "BIZON"
wep.Description = "Unwieldy bullet storm."
wep.Type = "smg"
wep.WModel = "models/weapons/w_pist_glock18.mdl"
wep.Sound_Fire = "Bizon.Fire"
@ -260,5 +339,25 @@ wep.Sound_MagIn = "Bizon.MagIn" -- placeholder
wep.Delay = (60/600)
wep.Firemodes = FIREMODE_AUTOSEMI
wep.Ammo = 30
wep.Damage = 16
wep.Ammo = 40
wep.Damage = 16
-- Shotguns
local wep = {}
WEAPONS["spas12"] = wep
wep.Name = "SPAS-12"
wep.Description = "meow"
wep.Type = "shotgun"
wep.WModel = "models/weapons/w_crowbar.mdl"
-- Rifles
local wep = {}
WEAPONS["fnc"] = wep
wep.Name = "FNC PARA"
wep.Description = "meow"
wep.Type = "rifle"
wep.WModel = "models/weapons/w_crowbar.mdl"