Camera kissy
This commit is contained in:
parent
0268d06360
commit
6fe7725ebd
|
@ -0,0 +1,33 @@
|
|||
|
||||
SWEP.Base = "weapon_base"
|
||||
|
||||
SWEP.PrintName = "Benny Weapon Handler"
|
||||
|
||||
SWEP.ViewModel = "models/weapons/c_pistol.mdl"
|
||||
SWEP.WorldModel = "models/weapons/w_pistol.mdl"
|
||||
|
||||
function SWEP:PrimaryAttack()
|
||||
return true
|
||||
end
|
||||
|
||||
function SWEP:SecondaryAttack()
|
||||
return true
|
||||
end
|
||||
|
||||
function SWEP:Reload()
|
||||
return true
|
||||
end
|
||||
|
||||
function SWEP:Think()
|
||||
self:SetWeaponHoldType("normal")
|
||||
self:SetHoldType("normal")
|
||||
return true
|
||||
end
|
||||
|
||||
function SWEP:Deploy()
|
||||
return true
|
||||
end
|
||||
|
||||
function SWEP:Holster()
|
||||
return true
|
||||
end
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
local debugcolor = Color( 255, 0, 255, 1 )
|
||||
|
||||
BENNY.Cameras = {}
|
||||
tempmapcameras = {}
|
||||
|
||||
BENNY.Cameras["main"] = {
|
||||
tempmapcameras["benny_test"] = {}
|
||||
|
||||
tempmapcameras["benny_test"]["main"] = {
|
||||
Type = "Standard",
|
||||
Pos = Vector( -692, 0, 268 ),
|
||||
Ang = Angle( 55, 0, 0 ),
|
||||
|
@ -41,7 +43,7 @@ BENNY.Cameras["main"] = {
|
|||
end
|
||||
}
|
||||
|
||||
BENNY.Cameras["grass"] = {
|
||||
tempmapcameras["benny_test"]["grass"] = {
|
||||
Pos = Vector( -1622, -214, 284 ),
|
||||
Ang = Angle( 70, 0, 0 ),
|
||||
FOV = 90,
|
||||
|
@ -94,7 +96,7 @@ BENNY.Cameras["grass"] = {
|
|||
end
|
||||
}
|
||||
|
||||
BENNY.Cameras["barber"] = {
|
||||
tempmapcameras["benny_test"]["barber"] = {
|
||||
Pos = Vector( -64, -126, 54 ),
|
||||
Ang = Angle( 15, 45, 0 ),
|
||||
FOV = 90,
|
||||
|
@ -121,109 +123,69 @@ BENNY.Cameras["barber"] = {
|
|||
end
|
||||
}
|
||||
|
||||
--[[ BENNY.Cameras["hall"] = {
|
||||
Type = "Fixed",
|
||||
Pos = Vector( 794, -40, 84 ),
|
||||
Ang = Angle( 29, 180, 0 ),
|
||||
Checks = {
|
||||
{
|
||||
Vector( 273, -111, 0 ),
|
||||
Vector( 751, 99, -130 ),
|
||||
},
|
||||
},
|
||||
v1 = Vector( 400, 0, -128 ),
|
||||
v2 = Vector( 630, 0, -128 ),
|
||||
FOV = 67,
|
||||
Special = function( self, ply )
|
||||
local pos = Vector()
|
||||
pos:Set( self.Pos )
|
||||
local ang = Angle()
|
||||
ang:Set( self.Ang )
|
||||
|
||||
debugoverlay.Cross( self.v1, 8, 0, color_white, true )
|
||||
debugoverlay.Cross( self.v2, 8, 0, color_white, true )
|
||||
|
||||
local amt = math.TimeFraction( self.v1.x, self.v2.x, ply:GetPos().x )
|
||||
amt = math.Clamp( amt, 0, 1 )
|
||||
ang.p = ang.p + ( 32 * amt )
|
||||
pos.x = pos.x - ( 50 * (1-amt) )
|
||||
return pos, ang, self.FOV
|
||||
end
|
||||
} ]]
|
||||
|
||||
--[[ BENNY.Cameras["racks"] = {
|
||||
Type = "Standard",
|
||||
Pos = Vector( 120, 0, 280 ),
|
||||
Ang = Angle( 60, 180, 0 ),
|
||||
Checks = {
|
||||
{
|
||||
Vector( 890, 135, 0 ),
|
||||
Vector( -253, 765, -130 )
|
||||
},
|
||||
},
|
||||
v1 = Vector( 870, 135, -130 ),
|
||||
v2 = Vector( 760, 135, -130 ),
|
||||
v3 = Vector( 890, 135, -130 ),
|
||||
v4 = Vector( -253, 135, -130 ),
|
||||
FOV = 75,
|
||||
Special = function( self, ply )
|
||||
local pos = Vector()
|
||||
pos:Set( ply:GetPos() )
|
||||
pos:Add( self.Pos )
|
||||
local ang = Angle()
|
||||
ang:Set( self.Ang )
|
||||
|
||||
debugoverlay.Cross( self.v1, 8, 0, color_white, true )
|
||||
debugoverlay.Cross( self.v2, 8, 0, color_white, true )
|
||||
|
||||
pos.x = math.Clamp( pos.x, -200, 890 )
|
||||
pos.y = math.Clamp( pos.y, 300, 600 )
|
||||
|
||||
do -- close to back wall
|
||||
local amt = math.TimeFraction( self.v1.x, self.v2.x, ply:GetPos().x )
|
||||
amt = math.Clamp( amt, 0, 1 )
|
||||
-- pos.x = pos.x - ( (150) * (1-amt) )
|
||||
ang.p = ang.p + ( 10 * (1-amt) )
|
||||
end
|
||||
|
||||
do -- stretch
|
||||
local amt = math.TimeFraction( self.v3.x, self.v4.x, ply:GetPos().x )
|
||||
amt = math.Clamp( amt, 0, 1 )
|
||||
-- pos.x = pos.x - ( (1143) * (amt) )
|
||||
end
|
||||
|
||||
|
||||
return pos, ang, self.FOV
|
||||
end
|
||||
} ]]
|
||||
|
||||
BENNY_ACTIVECAMERA = BENNY_ACTIVECAMERA or nil
|
||||
BENNY_ACTIVECAMERA = nil
|
||||
|
||||
local c_over = CreateConVar( "benny_cam_override", "" )
|
||||
local c_unlock = CreateConVar( "benny_cam_unlock", 0 )
|
||||
|
||||
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()
|
||||
local fov = self.FOV
|
||||
local ppos = ply:GetPos()
|
||||
local pang = ply:EyeAngles()
|
||||
|
||||
pos:Set( ppos )
|
||||
ang:Add( pang )
|
||||
|
||||
pos.z = pos.z + 68
|
||||
ctrace.start = pos
|
||||
ctrace.endpos = pos + ( ang:Forward() * -60 ) + ( ang:Right() * 20 )
|
||||
ctrace.filter = ply
|
||||
local tr = util.TraceHull( ctrace )
|
||||
|
||||
pos = tr.HitPos
|
||||
|
||||
return pos, ang, fov
|
||||
end
|
||||
}
|
||||
|
||||
local function decide_active()
|
||||
print( LocalPlayer():GetPos() )
|
||||
for name, camera in pairs( BENNY.Cameras ) do
|
||||
if camera.Checks then
|
||||
for i, v in ipairs(camera.Checks) do
|
||||
if LocalPlayer():GetPos():WithinAABox( v[1], v[2] ) then
|
||||
debugoverlay.Box( vector_origin, v[1], v[2], 0, debugcolor )
|
||||
return name
|
||||
-- print( LocalPlayer():GetPos() )
|
||||
-- BENNY_ACTIVECAMERA = tempcam
|
||||
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
|
||||
if LocalPlayer():GetPos():WithinAABox( v[1], v[2] ) then
|
||||
debugoverlay.Box( vector_origin, v[1], v[2], 0, debugcolor )
|
||||
BENNY_ACTIVECAMERA = camera
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
hook.Add( "CalcView", "MyCalcView", function( ply, pos, ang, fov )
|
||||
if c_unlock:GetBool() then return end
|
||||
if ply:GetMoveType() == MOVETYPE_NOCLIP then return end
|
||||
local da = decide_active()
|
||||
if da then
|
||||
BENNY_ACTIVECAMERA = da
|
||||
end
|
||||
local camera = BENNY.Cameras[BENNY_ACTIVECAMERA]
|
||||
decide_active()
|
||||
local camera = BENNY_ACTIVECAMERA
|
||||
if camera then
|
||||
local view = {
|
||||
origin = camera.Pos,
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
-- HUD
|
||||
|
||||
local hide = {
|
||||
["CHudHealth"] = true,
|
||||
["CHudBattery"] = true,
|
||||
["CHudAmmo"] = true,
|
||||
["CHudSecondaryAmmo"] = true,
|
||||
["CHudPoisonDamageIndicator"] = true,
|
||||
}
|
||||
|
||||
hook.Add( "HUDShouldDraw", "HideHUD", function( name )
|
||||
if ( hide[ name ] ) then return false end
|
||||
end )
|
||||
|
||||
function ss( scale )
|
||||
return scale * ( ScrH() / 480 )
|
||||
end
|
||||
|
||||
hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||
surface.SetDrawColor( 0, 0, 0, 0 )
|
||||
surface.DrawRect( 0, 0, 256, 256 )
|
||||
end )
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
function GM:PlayerSetModel( ply )
|
||||
ply:SetModel( "models/player/group01/male_07.mdl" )
|
||||
end
|
||||
|
||||
function GM:PlayerLoadout( ply )
|
||||
ply:Give( "benny" )
|
||||
end
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
-- Movement
|
||||
|
||||
local wa, wb = 0, 0
|
||||
|
||||
local blop = Angle()
|
||||
|
||||
hook.Add( "CreateMove", "CamFuck", function( cmd )
|
||||
if LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
|
||||
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
|
||||
wa, wb = x, y
|
||||
|
||||
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: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
|
||||
end)
|
||||
|
||||
function GM:PlayerNoClip()
|
||||
return true
|
||||
end
|
|
@ -1,100 +0,0 @@
|
|||
|
||||
local wa, wb = 0, 0
|
||||
|
||||
hook.Add( "CreateMove", "CamFuck", function( cmd )
|
||||
if LocalPlayer():GetMoveType() != MOVETYPE_NOCLIP then
|
||||
local x, y = cmd:GetForwardMove(), cmd:GetSideMove()
|
||||
wa, wb = x, y
|
||||
|
||||
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)
|
||||
|
||||
--print(ad.x, ad.y)
|
||||
|
||||
cmd:SetForwardMove( ad.x )
|
||||
cmd:SetSideMove( ad.y )
|
||||
end
|
||||
end)
|
||||
|
||||
function GM:PlayerNoClip()
|
||||
return true
|
||||
end
|
||||
|
||||
if CLIENT then
|
||||
local function ss( scale )
|
||||
return scale * ( ScrH() / 480 )
|
||||
end
|
||||
|
||||
local w25, w50, w75, w100 = Color( 255, 255, 255, 0.25*255 ), Color( 255, 255, 255, 0.50*255 ), Color( 255, 255, 255, 0.75*255 ), Color( 255, 255, 255, 1.00*255 )
|
||||
local g25, g50, g75, g100 = Color( 0, 0, 0, 0.25*255 ), Color( 0, 0, 0, 0.50*255 ), Color( 0, 0, 0, 0.75*255 ), Color( 0, 0, 0, 1.00*255 )
|
||||
|
||||
hook.Add( "HUDPaint", "HUDFuck", function()
|
||||
local bo = ss( 20 )
|
||||
local cr, cd = ss( 50 ), ss( 100 )
|
||||
|
||||
surface.SetDrawColor( g100 )
|
||||
surface.DrawRect( bo, ScrH() - bo + cr, cd, cd )
|
||||
|
||||
surface.SetDrawColor( w25 )
|
||||
surface.DrawLine( bo + cr, ScrH() - bo - cd, bo + cr, ScrH() - bo )
|
||||
surface.DrawLine( bo, ScrH() - bo - cr, bo + cd, ScrH() - bo - cr )
|
||||
|
||||
surface.SetDrawColor( w100 )
|
||||
surface.DrawCircle( bo + cr, ScrH() - bo - cr, cr )
|
||||
|
||||
local ox, oy = 0, 0
|
||||
local msp = 300
|
||||
|
||||
ox = wb/msp
|
||||
oy = -wa/msp
|
||||
|
||||
ox = math.Clamp( ox, -1, 1 ) * cr
|
||||
oy = math.Clamp( oy, -1, 1 ) * cr
|
||||
|
||||
surface.DrawCircle( bo + cr + ox, ScrH() - bo - cr + oy, ss( 2 ) )
|
||||
|
||||
-- local x, y, w, h = 0, 0, 360, 240
|
||||
-- local ow, oh = 512, 512
|
||||
|
||||
-- local camera = BENNY.Cameras[BENNY_ACTIVECAMERA]
|
||||
-- local view = {
|
||||
-- origin = camera.Pos,
|
||||
-- angles = camera.Ang,
|
||||
-- fov = camera.FOV or 60,
|
||||
-- drawviewer = true
|
||||
-- }
|
||||
-- if camera.Special then
|
||||
-- view.origin, view.angles, view.fov = camera.Special( camera, LocalPlayer() )
|
||||
-- end
|
||||
-- view.angles.p = 0
|
||||
-- view.angles.r = 0
|
||||
|
||||
-- local aratio = w/h
|
||||
|
||||
-- render.RenderView( {
|
||||
-- origin = view.origin + Vector( 0, 0, 64 ),
|
||||
-- angles = Angle( 90, view.angles.y, 0 ),
|
||||
-- aspect = 1,
|
||||
-- fov = 90,
|
||||
-- x = x, y = y,
|
||||
-- w = w, h = h,
|
||||
-- ortho = {
|
||||
-- left = -ow, right = ow,
|
||||
-- top = -oh / aratio, bottom = oh / aratio,
|
||||
-- },
|
||||
-- } )
|
||||
end)
|
||||
end
|
Loading…
Reference in New Issue