mirror of
https://github.com/SpaxscE/simfphys_armed.git
synced 2025-03-04 03:13:26 -05:00
fixed capslock folder
This commit is contained in:
parent
ff7c1943f2
commit
57386d2ad9
158
lua/autorun/client/armedvehicles_specialcam.lua
Normal file
158
lua/autorun/client/armedvehicles_specialcam.lua
Normal file
@ -0,0 +1,158 @@
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
|
||||
local HintPlayerAboutHisFuckingIncompetence = true
|
||||
|
||||
hook.Add( "CalcView", "zz_simfphys_gunner_view", function( ply, pos, ang )
|
||||
HintPlayerAboutHisFuckingIncompetence = false
|
||||
|
||||
if not IsValid( ply ) or not ply:Alive() or not ply:InVehicle() or ply:GetViewEntity() ~= ply then return end
|
||||
|
||||
local Vehicle = ply:GetVehicle()
|
||||
|
||||
if not IsValid( Vehicle ) then return end
|
||||
|
||||
local Base = ply.GetSimfphys and ply:GetSimfphys() or Vehicle.vehiclebase
|
||||
|
||||
if not IsValid( Base ) then return end
|
||||
|
||||
if not Vehicle:GetNWBool( "simfphys_SpecialCam" ) then return end
|
||||
|
||||
local view = {
|
||||
origin = pos,
|
||||
drawviewer = false,
|
||||
}
|
||||
|
||||
if Vehicle:GetNWBool( "SpecialCam_LocalAngles" ) then
|
||||
view.angles = ply:EyeAngles()
|
||||
else
|
||||
view.angles = Vehicle:LocalToWorldAngles( ply:EyeAngles() )
|
||||
end
|
||||
|
||||
if Vehicle.GetThirdPersonMode == nil or ply:GetViewEntity() ~= ply then
|
||||
return
|
||||
end
|
||||
|
||||
ply.simfphys_smooth_out = 0
|
||||
|
||||
local offset = Vehicle:GetNWVector( "SpecialCam_Thirdperson" )
|
||||
|
||||
if not Vehicle:GetThirdPersonMode() then
|
||||
local offset = Vehicle:GetNWVector( "SpecialCam_Firstperson" )
|
||||
local ID = Base:LookupAttachment( Vehicle:GetNWString( "SpecialCam_Attachment" ) )
|
||||
|
||||
if ID == 0 then
|
||||
view.origin = view.origin + Vehicle:GetForward() * offset.x + Vehicle:GetRight() * offset.y + Vehicle:GetUp() * offset.z
|
||||
else
|
||||
local attachment = Base:GetAttachment( ID )
|
||||
|
||||
view.origin = attachment.Pos + attachment.Ang:Forward() * offset.x + attachment.Ang:Right() * offset.y + attachment.Ang:Up() * offset.z
|
||||
end
|
||||
|
||||
return view
|
||||
end
|
||||
|
||||
view.origin = view.origin + Vehicle:GetForward() * offset.x + Vehicle:GetRight() * offset.y + Vehicle:GetUp() * offset.z
|
||||
|
||||
local mn, mx = Vehicle:GetRenderBounds()
|
||||
local radius = ( mn - mx ):Length()
|
||||
local radius = radius + radius * Vehicle:GetCameraDistance()
|
||||
|
||||
local TargetOrigin = view.origin + ( view.angles:Forward() * -radius )
|
||||
local WallOffset = 4
|
||||
|
||||
local tr = util.TraceHull( {
|
||||
start = view.origin,
|
||||
endpos = TargetOrigin,
|
||||
filter = function( e )
|
||||
local c = e:GetClass()
|
||||
local collide = not c:StartWith( "prop_physics" ) and not c:StartWith( "prop_dynamic" ) and not c:StartWith( "prop_ragdoll" ) and not e:IsVehicle() and not c:StartWith( "gmod_" ) and not c:StartWith( "player" )
|
||||
return collide
|
||||
end,
|
||||
mins = Vector( -WallOffset, -WallOffset, -WallOffset ),
|
||||
maxs = Vector( WallOffset, WallOffset, WallOffset ),
|
||||
} )
|
||||
|
||||
view.origin = tr.HitPos
|
||||
view.drawviewer = true
|
||||
|
||||
if tr.Hit and not tr.StartSolid then
|
||||
view.origin = view.origin + tr.HitNormal * WallOffset
|
||||
end
|
||||
|
||||
return view
|
||||
end )
|
||||
|
||||
surface.CreateFont( "SCRUBNOTE_FONT", {
|
||||
font = "Verdana",
|
||||
extended = false,
|
||||
size = 20,
|
||||
weight = 2000,
|
||||
blursize = 0,
|
||||
scanlines = 0,
|
||||
antialias = true,
|
||||
underline = false,
|
||||
italic = false,
|
||||
strikeout = false,
|
||||
symbol = false,
|
||||
rotary = false,
|
||||
shadow = true,
|
||||
additive = false,
|
||||
outline = false,
|
||||
} )
|
||||
|
||||
hook.Add( "HUDPaint", "zz_simfphys_brokencam_hint", function()
|
||||
if not HintPlayerAboutHisFuckingIncompetence then return end
|
||||
|
||||
local ply = LocalPlayer()
|
||||
|
||||
if not ply:InVehicle() then return end
|
||||
if ply:GetViewEntity() ~= ply then return end
|
||||
|
||||
local Pod = ply:GetVehicle()
|
||||
|
||||
if not IsValid( Pod ) then return end
|
||||
|
||||
local Base = ply.GetSimfphys and ply:GetSimfphys() or Pod.vehiclebase
|
||||
|
||||
if not IsValid( Base ) then return end
|
||||
if not Pod:GetNWBool( "simfphys_SpecialCam" ) then return end
|
||||
|
||||
if not Base.ERRORSOUND then
|
||||
surface.PlaySound( "error.wav" )
|
||||
Base.ERRORSOUND = true
|
||||
end
|
||||
|
||||
local X = ScrW()
|
||||
local Y = ScrH()
|
||||
local HintCol = Color(255,0,0, 255 )
|
||||
|
||||
surface.SetDrawColor( 0, 0, 0, 250 )
|
||||
surface.DrawRect( 0, 0, X, Y )
|
||||
surface.SetDrawColor( 255, 255, 255, 255 )
|
||||
|
||||
draw.SimpleText( "OOPS! SOMETHING WENT WRONG :( ", "SCRUBNOTE_FONT", X * 0.5, Y * 0.5 - 40, HintCol, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
draw.SimpleText( "ONE OF YOUR ADDONS IS BREAKING THE CALCVIEW HOOK. TANK TURRET WILL NOT BE USEABLE", "SCRUBNOTE_FONT", X * 0.5, Y * 0.5 - 20, HintCol, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
draw.SimpleText( "HOW TO FIX?", "SCRUBNOTE_FONT", X * 0.5, Y * 0.5 + 20, HintCol, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
draw.SimpleText( "DISABLE ALL ADDONS THAT COULD POSSIBLY MESS WITH THE CAMERA-VIEW", "SCRUBNOTE_FONT", X * 0.5, Y * 0.5 + 40, HintCol, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
draw.SimpleText( "(THIRDPERSON ADDONS OR SIMILAR)", "SCRUBNOTE_FONT", X * 0.5, Y * 0.5 + 60, HintCol, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
|
||||
draw.SimpleText( ">>PRESS YOUR USE-KEY TO LEAVE THE VEHICLE & HIDE THIS MESSAGE<<", "SCRUBNOTE_FONT", X * 0.5, Y * 0.5 + 120, Color(255,0,0, math.abs( math.cos( CurTime() ) * 255) ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
|
||||
end )
|
580
lua/autorun/client/simfphys_armed_xhair.lua
Normal file
580
lua/autorun/client/simfphys_armed_xhair.lua
Normal file
@ -0,0 +1,580 @@
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
|
||||
CreateClientConVar( "cl_simfphys_crosshair", "1", true, false )
|
||||
|
||||
local ShowHud = false
|
||||
cvars.AddChangeCallback( "cl_simfphys_hud", function( convar, oldValue, newValue ) ShowHud = tonumber( newValue )~=0 end)
|
||||
ShowHud = GetConVar( "cl_simfphys_hud" ):GetBool()
|
||||
|
||||
local show_crosshair = false
|
||||
local Hudmph = false
|
||||
local Hudreal = false
|
||||
|
||||
cvars.AddChangeCallback( "cl_simfphys_crosshair", function( convar, oldValue, newValue ) show_crosshair = tonumber( newValue )~=0 end)
|
||||
cvars.AddChangeCallback( "cl_simfphys_hudmph", function( convar, oldValue, newValue ) Hudmph = tonumber( newValue )~=0 end)
|
||||
cvars.AddChangeCallback( "cl_simfphys_hudrealspeed", function( convar, oldValue, newValue ) Hudreal = tonumber( newValue )~=0 end)
|
||||
|
||||
Hudmph = GetConVar( "cl_simfphys_hudmph" ):GetBool()
|
||||
Hudreal = GetConVar( "cl_simfphys_hudrealspeed" ):GetBool()
|
||||
show_crosshair = GetConVar( "cl_simfphys_crosshair" ):GetBool()
|
||||
|
||||
local xhair = Material( "sprites/hud/v_crosshair1" )
|
||||
local zoom_mat = Material( "vgui/zoom" )
|
||||
|
||||
local function DrawCircle( X, Y, radius )
|
||||
local segmentdist = 360 / ( 2 * math.pi * radius / 2 )
|
||||
|
||||
for a = 0, 360, segmentdist do
|
||||
surface.DrawLine( X + math.cos( math.rad( a ) ) * radius, Y - math.sin( math.rad( a ) ) * radius, X + math.cos( math.rad( a + segmentdist ) ) * radius, Y - math.sin( math.rad( a + segmentdist ) ) * radius )
|
||||
|
||||
surface.DrawLine( X + math.cos( math.rad( a ) ) * radius, Y - math.sin( math.rad( a ) ) * radius, X + math.cos( math.rad( a + segmentdist ) ) * radius, Y - math.sin( math.rad( a + segmentdist ) ) * radius )
|
||||
end
|
||||
end
|
||||
|
||||
surface.CreateFont( "SIMFPHYS_ARMED_HUDFONT", {
|
||||
font = "Verdana",
|
||||
extended = false,
|
||||
size = 20,
|
||||
weight = 2000,
|
||||
blursize = 0,
|
||||
scanlines = 0,
|
||||
antialias = true,
|
||||
underline = false,
|
||||
italic = false,
|
||||
strikeout = false,
|
||||
symbol = false,
|
||||
rotary = false,
|
||||
shadow = true,
|
||||
additive = false,
|
||||
outline = false,
|
||||
} )
|
||||
|
||||
hook.Add( "HUDShouldDraw", "simfphys_armed_xhair", function( name )
|
||||
|
||||
if name ~= "CHudZoom" then return end
|
||||
|
||||
local ply = LocalPlayer()
|
||||
|
||||
if not ply.GetSimfphys then return end
|
||||
|
||||
local Ent = ply:GetSimfphys()
|
||||
|
||||
if not IsValid( Ent ) then return end
|
||||
|
||||
local veh = ply:GetVehicle()
|
||||
|
||||
if not IsValid( veh ) then return end
|
||||
|
||||
if not veh:GetNWBool( "HasCrosshair", false ) then return end
|
||||
|
||||
return false
|
||||
end )
|
||||
|
||||
local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
|
||||
local trace = util.TraceLine( {
|
||||
start = startpos,
|
||||
endpos = endpos,
|
||||
filter = function( e )
|
||||
local class = not e:GetClass():StartWith( "gmod_sent_vehicle_fphysics_wheel" )
|
||||
local collide = class and e ~= vehicle
|
||||
|
||||
return collide
|
||||
end
|
||||
} )
|
||||
|
||||
local hitpos = trace.HitPos
|
||||
|
||||
local scr = hitpos:ToScreen()
|
||||
|
||||
local Type = pod:GetNWInt( "CrosshairType", 0 )
|
||||
|
||||
surface.SetDrawColor( 240, 200, 0, 255 )
|
||||
|
||||
local velocity = vehicle:GetVelocity():Length()
|
||||
local mph = Hudreal and math.Round(velocity * 0.0568182,0) or math.Round(velocity * 0.0568182 * 0.75,0)
|
||||
local kmh = Hudreal and math.Round(velocity * 0.09144,0) or math.Round(velocity * 0.09144 * 0.75,0)
|
||||
local printspeed = Hudmph and tostring(mph).."mph" or tostring(kmh).."km/h"
|
||||
|
||||
if Type == 0 then
|
||||
surface.SetMaterial( xhair )
|
||||
surface.DrawTexturedRect( scr.x - 17,scr.y - 17, 34, 34)
|
||||
|
||||
if vehicle:GetNWBool( "simfphys_NoRacingHud", false ) and ShowHud then
|
||||
local fuel = vehicle:GetFuel() / vehicle:GetMaxFuel()
|
||||
local Cruise = vehicle:GetIsCruiseModeOn() and " (cruise)" or ""
|
||||
draw.SimpleText( "THR", "SIMFPHYS_ARMED_HUDFONT", 10, 10, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetThrottle() * 100).."%"..Cruise , "SIMFPHYS_ARMED_HUDFONT", 120, 10, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "SPD", "SIMFPHYS_ARMED_HUDFONT", 10, 35, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( printspeed, "SIMFPHYS_ARMED_HUDFONT", 120, 35, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "FUEL", "SIMFPHYS_ARMED_HUDFONT", 10, 60, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetFuel()).."/"..vehicle:GetMaxFuel().."L", "SIMFPHYS_ARMED_HUDFONT", 120, 60, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
local Mode = vehicle:GetNWString( "WeaponMode", "-nowpn" )
|
||||
if Mode ~= "-nowpn" then
|
||||
draw.SimpleText( "WPN", "SIMFPHYS_ARMED_HUDFONT", 10, 85, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( Mode, "SIMFPHYS_ARMED_HUDFONT", 120, 85, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
local Ammo = vehicle:GetNWInt( "CurWPNAmmo", -1 )
|
||||
|
||||
if Ammo >= 0 then
|
||||
draw.SimpleText( "AMMO", "SIMFPHYS_ARMED_HUDFONT", 10, 110, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( Ammo, "SIMFPHYS_ARMED_HUDFONT", 120, 110, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif Type == 1 then
|
||||
local X = scr.x
|
||||
local Y = scr.y
|
||||
|
||||
local Scale = 0.75
|
||||
|
||||
local scrW = ScrW() / 2
|
||||
local scrH = ScrH() / 2
|
||||
local Z = scrW * Scale
|
||||
|
||||
local rOuter = scrW * 0.03 * Scale
|
||||
|
||||
DrawCircle( X, Y, rOuter )
|
||||
|
||||
surface.SetDrawColor( 240, 200, 0, 50 )
|
||||
|
||||
local Yaw = vehicle:GetPoseParameter( "turret_yaw" ) * 360 - 90
|
||||
|
||||
local dX = math.cos( math.rad( -Yaw ) )
|
||||
local dY = math.sin( math.rad( -Yaw ) )
|
||||
local len = scrH * 0.04
|
||||
|
||||
DrawCircle( scrW, scrH * 1.85, len )
|
||||
surface.DrawLine( scrW + dX * len, scrH * 1.85 + dY * len, scrW + dX * len * 3, scrH * 1.85 + dY * len * 3 )
|
||||
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW - len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW + len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 - len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 + len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
|
||||
elseif Type == 2 then
|
||||
local X = scr.x
|
||||
local Y = scr.y
|
||||
|
||||
local Scale = 0.75
|
||||
|
||||
local scrW = ScrW() / 2
|
||||
local scrH = ScrH() / 2
|
||||
local Z = scrW * Scale
|
||||
|
||||
local safemode = vehicle:GetNWBool( "TurretSafeMode", true )
|
||||
|
||||
if not safemode then
|
||||
surface.SetDrawColor( 240, 200, 0, 180 )
|
||||
else
|
||||
local alpha = math.abs( math.cos( CurTime() * 3 ) )
|
||||
|
||||
local Key = input.LookupBinding( "+walk" )
|
||||
if not isstring( Key ) then Key = "[+walk is not bound to a key]" end
|
||||
|
||||
draw.SimpleText( "press "..Key.." to activate turret!", "simfphysfont", scrW, ScrH() - scrH * 0.04, Color( 255, 235, 0, 255 * alpha ), 1, 1)
|
||||
|
||||
surface.SetDrawColor( 240, 200, 0, 50 )
|
||||
end
|
||||
|
||||
local rOuter = scrW * 0.03 * Scale
|
||||
local rInner = scrW * 0.005 * Scale
|
||||
|
||||
if vehicle:GetNWBool( "SpecialCam_Loader", false ) then
|
||||
surface.DrawLine( X, Y + rInner, X, Y + Z * 0.15)
|
||||
|
||||
surface.DrawLine( X, Y + Z * 0.025, X - Z * 0.01, Y + Z * 0.025)
|
||||
|
||||
surface.DrawLine( X, Y + Z * 0.05, X - Z * 0.015, Y + Z * 0.05)
|
||||
draw.SimpleText( "1", "simfphysfont", X - Z * 0.02, Y + Z * 0.05 , Color( 240, 200, 0, 180 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
|
||||
surface.DrawLine( X, Y + Z * 0.075, X - Z * 0.01, Y + Z * 0.075)
|
||||
|
||||
surface.DrawLine( X, Y + Z * 0.1, X - Z * 0.015, Y + Z * 0.1)
|
||||
draw.SimpleText( "2", "simfphysfont", X - Z * 0.02, Y + Z * 0.1 , Color( 240, 200, 0, 180 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
|
||||
surface.DrawLine( X, Y + Z * 0.125, X - Z * 0.01, Y + Z * 0.125)
|
||||
|
||||
surface.DrawLine( X + rInner, Y - rInner, X + rOuter, Y - rOuter )
|
||||
surface.DrawLine( X - rInner, Y - rInner, X - rOuter, Y - rOuter )
|
||||
|
||||
local LoaderTime = vehicle:GetNWFloat( "SpecialCam_LoaderTime", 0 )
|
||||
local FireNext = math.max(vehicle:GetNWFloat( "SpecialCam_LoaderNext", 0 ) - CurTime(),0)
|
||||
|
||||
local CProgress = ((LoaderTime - FireNext) / LoaderTime)
|
||||
|
||||
local pL1 = scrH * 0.25
|
||||
local pL2 = scrH * 0.23
|
||||
local pL3 = scrH * 0.24
|
||||
|
||||
for i = 0, 355, 5 do
|
||||
local angCos = math.cos( math.rad( i ) )
|
||||
local angSin = math.sin( math.rad( i ) )
|
||||
|
||||
if i > (CProgress * 360) then
|
||||
pL2 = pL3
|
||||
surface.SetDrawColor( 255, 0, 0, 255 )
|
||||
end
|
||||
|
||||
local pX1 = angCos * pL1
|
||||
local pY1 = angSin * pL1
|
||||
|
||||
local pX2 = angCos * pL2
|
||||
local pY2 = angSin * pL2
|
||||
|
||||
surface.DrawLine( X + pX1, Y + pY1, X + pX2, Y + pY2 )
|
||||
surface.DrawLine( X + pX1, Y + pY1, X + pX2, Y + pY2 )
|
||||
end
|
||||
|
||||
if vehicle:GetNWBool( "simfphys_NoHud", false ) and ShowHud then
|
||||
local fuel = vehicle:GetFuel() / vehicle:GetMaxFuel()
|
||||
local Cruise = vehicle:GetIsCruiseModeOn() and " (cruise)" or ""
|
||||
draw.SimpleText( "THR", "SIMFPHYS_ARMED_HUDFONT", 10, 10, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetThrottle() * 100).."%"..Cruise , "SIMFPHYS_ARMED_HUDFONT", 120, 10, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "SPD", "SIMFPHYS_ARMED_HUDFONT", 10, 35, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( printspeed, "SIMFPHYS_ARMED_HUDFONT", 120, 35, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "FUEL", "SIMFPHYS_ARMED_HUDFONT", 10, 60, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetFuel()).."/"..vehicle:GetMaxFuel().."L", "SIMFPHYS_ARMED_HUDFONT", 120, 60, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
end
|
||||
else
|
||||
DrawCircle( X, Y, rOuter )
|
||||
DrawCircle( X, Y, rInner )
|
||||
|
||||
surface.DrawLine( X + rOuter, Y, X + rOuter * 2, Y )
|
||||
surface.DrawLine( X - rOuter, Y, X - rOuter * 2, Y )
|
||||
surface.DrawLine( X, Y + rOuter, X, Y + rOuter * 2 )
|
||||
surface.DrawLine( X, Y - rOuter, X, Y - rOuter * 2)
|
||||
|
||||
surface.DrawLine( X + Z * 0.3, Y - Z * 0.35, X + Z * 0.6, Y - Z * 0.35 )
|
||||
surface.DrawLine( X + Z * 0.6, Y - Z * 0.35, X + Z * 0.7, Y - Z * 0.25 )
|
||||
surface.DrawLine( X - Z * 0.3, Y - Z * 0.35, X - Z * 0.6, Y - Z * 0.35 )
|
||||
surface.DrawLine( X - Z * 0.6, Y - Z * 0.35, X - Z * 0.7, Y - Z * 0.25 )
|
||||
|
||||
surface.DrawLine( X + Z * 0.3, Y + Z * 0.35, X + Z * 0.6, Y + Z * 0.35 )
|
||||
surface.DrawLine( X + Z * 0.6, Y + Z * 0.35, X + Z * 0.7, Y + Z * 0.25 )
|
||||
surface.DrawLine( X - Z * 0.3, Y + Z * 0.35, X - Z * 0.6, Y + Z * 0.35 )
|
||||
surface.DrawLine( X - Z * 0.6, Y + Z * 0.35, X - Z * 0.7, Y + Z * 0.25 )
|
||||
end
|
||||
|
||||
if not safemode then
|
||||
surface.SetDrawColor( 240, 200, 0, 180 )
|
||||
else
|
||||
surface.SetDrawColor( 240, 200, 0, 50 )
|
||||
end
|
||||
|
||||
local Yaw = vehicle:GetPoseParameter( "turret_yaw" ) * 360 - 90
|
||||
|
||||
local dX = math.cos( math.rad( -Yaw ) )
|
||||
local dY = math.sin( math.rad( -Yaw ) )
|
||||
local len = scrH * 0.04
|
||||
|
||||
DrawCircle( scrW, scrH * 1.85, len )
|
||||
surface.DrawLine( scrW + dX * len, scrH * 1.85 + dY * len, scrW + dX * len * 3, scrH * 1.85 + dY * len * 3 )
|
||||
|
||||
surface.SetDrawColor( 240, 200, 0, 180 )
|
||||
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW - len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW + len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 - len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 + len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
|
||||
elseif Type == 3 then
|
||||
surface.SetMaterial( xhair )
|
||||
surface.DrawTexturedRect( scr.x - 17,scr.y - 17, 34, 34)
|
||||
|
||||
local scrW = ScrW() / 2
|
||||
local scrH = ScrH() / 2
|
||||
|
||||
local Yaw = vehicle:GetPoseParameter( "turret_yaw" ) * 360 - 90
|
||||
|
||||
local dX = math.cos( math.rad( -Yaw ) )
|
||||
local dY = math.sin( math.rad( -Yaw ) )
|
||||
local len = scrH * 0.04
|
||||
|
||||
DrawCircle( scrW, scrH * 1.85, len )
|
||||
surface.DrawLine( scrW + dX * len, scrH * 1.85 + dY * len, scrW + dX * len * 3, scrH * 1.85 + dY * len * 3 )
|
||||
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW - len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW + len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 - len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 + len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
|
||||
if vehicle:GetNWBool( "simfphys_NoRacingHud", false ) and ShowHud then
|
||||
local fuel = vehicle:GetFuel() / vehicle:GetMaxFuel()
|
||||
local Cruise = vehicle:GetIsCruiseModeOn() and " (cruise)" or ""
|
||||
draw.SimpleText( "THR", "SIMFPHYS_ARMED_HUDFONT", 10, 10, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetThrottle() * 100).."%"..Cruise , "SIMFPHYS_ARMED_HUDFONT", 120, 10, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "SPD", "SIMFPHYS_ARMED_HUDFONT", 10, 35, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( printspeed, "SIMFPHYS_ARMED_HUDFONT", 120, 35, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "FUEL", "SIMFPHYS_ARMED_HUDFONT", 10, 60, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetFuel()).."/"..vehicle:GetMaxFuel().."L", "SIMFPHYS_ARMED_HUDFONT", 120, 60, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
local Mode = vehicle:GetNWString( "WeaponMode", "-nowpn" )
|
||||
if Mode ~= "-nowpn" then
|
||||
draw.SimpleText( "WPN", "SIMFPHYS_ARMED_HUDFONT", 10, 85, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( Mode, "SIMFPHYS_ARMED_HUDFONT", 120, 85, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
local Ammo = vehicle:GetNWInt( "CurWPNAmmo", -1 )
|
||||
|
||||
if Ammo >= 0 then
|
||||
draw.SimpleText( "AMMO", "SIMFPHYS_ARMED_HUDFONT", 10, 110, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( Ammo, "SIMFPHYS_ARMED_HUDFONT", 120, 110, Color( 255, 235, 0, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif Type == 4 then
|
||||
local X = scr.x
|
||||
local Y = scr.y
|
||||
|
||||
local Scale = 0.75
|
||||
|
||||
local scrW = ScrW() / 2
|
||||
local scrH = ScrH() / 2
|
||||
local Z = scrW * Scale
|
||||
|
||||
local safemode = vehicle:GetNWBool( "TurretSafeMode", true )
|
||||
|
||||
if not safemode then
|
||||
surface.SetDrawColor( 20, 255, 20, 180 )
|
||||
else
|
||||
local alpha = math.abs( math.cos( CurTime() * 3 ) )
|
||||
|
||||
local Key = input.LookupBinding( "+walk" )
|
||||
if not isstring( Key ) then Key = "[+walk is not bound to a key]" end
|
||||
|
||||
draw.SimpleText( "press "..Key.." to activate turret!", "simfphysfont", scrW, ScrH() - scrH * 0.04, Color( 20, 255, 20, 255 * alpha ), 1, 1)
|
||||
|
||||
surface.SetDrawColor( 20, 255, 20, 50 )
|
||||
end
|
||||
|
||||
local rOuter = scrW * 0.03 * Scale
|
||||
local rInner = scrW * 0.005 * Scale
|
||||
|
||||
if vehicle:GetNWBool( "SpecialCam_Loader", false ) then
|
||||
surface.DrawLine( X, Y + rInner, X, Y + Z * 0.15)
|
||||
|
||||
surface.DrawLine( X, Y + Z * 0.025, X - Z * 0.01, Y + Z * 0.025)
|
||||
|
||||
surface.DrawLine( X, Y + Z * 0.05, X - Z * 0.015, Y + Z * 0.05)
|
||||
draw.SimpleText( "1", "simfphysfont", X - Z * 0.02, Y + Z * 0.05 , Color( 20, 255, 20, 180 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
|
||||
surface.DrawLine( X, Y + Z * 0.075, X - Z * 0.01, Y + Z * 0.075)
|
||||
|
||||
surface.DrawLine( X, Y + Z * 0.1, X - Z * 0.015, Y + Z * 0.1)
|
||||
draw.SimpleText( "2", "simfphysfont", X - Z * 0.02, Y + Z * 0.1 , Color( 20, 255, 20, 180 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
|
||||
surface.DrawLine( X, Y + Z * 0.125, X - Z * 0.01, Y + Z * 0.125)
|
||||
|
||||
surface.DrawLine( X + rInner, Y - rInner, X + rOuter, Y - rOuter )
|
||||
surface.DrawLine( X - rInner, Y - rInner, X - rOuter, Y - rOuter )
|
||||
|
||||
local LoaderTime = vehicle:GetNWFloat( "SpecialCam_LoaderTime", 0 )
|
||||
local FireNext = math.max(vehicle:GetNWFloat( "SpecialCam_LoaderNext", 0 ) - CurTime(),0)
|
||||
|
||||
local CProgress = ((LoaderTime - FireNext) / LoaderTime)
|
||||
|
||||
local pL1 = scrH * 0.25
|
||||
local pL2 = scrH * 0.23
|
||||
local pL3 = scrH * 0.24
|
||||
|
||||
for i = 0, 355, 5 do
|
||||
local angCos = math.cos( math.rad( i ) )
|
||||
local angSin = math.sin( math.rad( i ) )
|
||||
|
||||
if i > (CProgress * 360) then
|
||||
pL2 = pL3
|
||||
surface.SetDrawColor( 255, 0, 0, 255 )
|
||||
end
|
||||
|
||||
local pX1 = angCos * pL1
|
||||
local pY1 = angSin * pL1
|
||||
|
||||
local pX2 = angCos * pL2
|
||||
local pY2 = angSin * pL2
|
||||
|
||||
surface.DrawLine( X + pX1, Y + pY1, X + pX2, Y + pY2 )
|
||||
surface.DrawLine( X + pX1, Y + pY1, X + pX2, Y + pY2 )
|
||||
end
|
||||
|
||||
if vehicle:GetNWBool( "simfphys_NoHud", false ) and ShowHud then
|
||||
local fuel = vehicle:GetFuel() / vehicle:GetMaxFuel()
|
||||
local Cruise = vehicle:GetIsCruiseModeOn() and " (cruise)" or ""
|
||||
draw.SimpleText( "THR", "SIMFPHYS_ARMED_HUDFONT", 10, 10, Color( 20, 255, 20, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetThrottle() * 100).."%"..Cruise , "SIMFPHYS_ARMED_HUDFONT", 120, 10, Color( 20, 255, 20, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "SPD", "SIMFPHYS_ARMED_HUDFONT", 10, 35, Color( 20, 255, 20, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( printspeed, "SIMFPHYS_ARMED_HUDFONT", 120, 35, Color( 20, 255, 20, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
|
||||
draw.SimpleText( "FUEL", "SIMFPHYS_ARMED_HUDFONT", 10, 60, Color( 20, 255, 20, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
draw.SimpleText( math.Round(vehicle:GetFuel()).."/"..vehicle:GetMaxFuel().."L", "SIMFPHYS_ARMED_HUDFONT", 120, 60, Color( 20, 255, 20, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
|
||||
end
|
||||
else
|
||||
DrawCircle( X, Y, rOuter )
|
||||
DrawCircle( X, Y, rInner )
|
||||
|
||||
surface.DrawLine( X + rOuter, Y, X + rOuter * 2, Y )
|
||||
surface.DrawLine( X - rOuter, Y, X - rOuter * 2, Y )
|
||||
surface.DrawLine( X, Y + rOuter, X, Y + rOuter * 2 )
|
||||
surface.DrawLine( X, Y - rOuter, X, Y - rOuter * 2)
|
||||
|
||||
surface.DrawLine( X + Z * 0.3, Y - Z * 0.35, X + Z * 0.6, Y - Z * 0.35 )
|
||||
surface.DrawLine( X + Z * 0.6, Y - Z * 0.35, X + Z * 0.7, Y - Z * 0.25 )
|
||||
surface.DrawLine( X - Z * 0.3, Y - Z * 0.35, X - Z * 0.6, Y - Z * 0.35 )
|
||||
surface.DrawLine( X - Z * 0.6, Y - Z * 0.35, X - Z * 0.7, Y - Z * 0.25 )
|
||||
|
||||
surface.DrawLine( X + Z * 0.3, Y + Z * 0.35, X + Z * 0.6, Y + Z * 0.35 )
|
||||
surface.DrawLine( X + Z * 0.6, Y + Z * 0.35, X + Z * 0.7, Y + Z * 0.25 )
|
||||
surface.DrawLine( X - Z * 0.3, Y + Z * 0.35, X - Z * 0.6, Y + Z * 0.35 )
|
||||
surface.DrawLine( X - Z * 0.6, Y + Z * 0.35, X - Z * 0.7, Y + Z * 0.25 )
|
||||
end
|
||||
|
||||
if not safemode then
|
||||
surface.SetDrawColor( 20, 255, 20, 180 )
|
||||
else
|
||||
surface.SetDrawColor( 20, 255, 20, 50 )
|
||||
end
|
||||
|
||||
local Yaw = vehicle:GetPoseParameter( "cannon_aim_yaw" ) * 360 - 90
|
||||
|
||||
local dX = math.cos( math.rad( -Yaw ) )
|
||||
local dY = math.sin( math.rad( -Yaw ) )
|
||||
local len = scrH * 0.04
|
||||
|
||||
DrawCircle( scrW, scrH * 1.85, len )
|
||||
surface.DrawLine( scrW + dX * len, scrH * 1.85 + dY * len, scrW + dX * len * 3, scrH * 1.85 + dY * len * 3 )
|
||||
|
||||
surface.SetDrawColor( 20, 255, 20, 180 )
|
||||
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW - len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW + len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 - len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 + len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
|
||||
elseif Type == 5 then
|
||||
local X = scr.x
|
||||
local Y = scr.y
|
||||
|
||||
local Scale = 0.75
|
||||
|
||||
local scrW = ScrW() / 2
|
||||
local scrH = ScrH() / 2
|
||||
local Z = scrW * Scale
|
||||
|
||||
local rOuter = scrW * 0.03 * Scale
|
||||
local rInner = scrW * 0.005 * Scale
|
||||
|
||||
surface.SetDrawColor( 20, 255, 20, 255 )
|
||||
|
||||
DrawCircle( X, Y, rOuter )
|
||||
|
||||
surface.SetDrawColor( 20, 255, 20, 50 )
|
||||
|
||||
local Yaw = vehicle:GetPoseParameter( "cannon_aim_yaw" ) * 360 - 90
|
||||
|
||||
local dX = math.cos( math.rad( -Yaw ) )
|
||||
local dY = math.sin( math.rad( -Yaw ) )
|
||||
local len = scrH * 0.04
|
||||
|
||||
DrawCircle( scrW, scrH * 1.85, len )
|
||||
surface.DrawLine( scrW + dX * len, scrH * 1.85 + dY * len, scrW + dX * len * 3, scrH * 1.85 + dY * len * 3 )
|
||||
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW - len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW + len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 - len * 2, scrW + len * 1.25, scrH * 1.85 - len * 2 )
|
||||
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 + len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
|
||||
end
|
||||
|
||||
surface.SetDrawColor( 255, 255, 255, 255 )
|
||||
draw.NoTexture()
|
||||
end
|
||||
|
||||
local function MixDirection( ang, direction )
|
||||
|
||||
local Dir = ang:Forward()
|
||||
|
||||
-- placeholder code
|
||||
if direction.x == -1 then
|
||||
Dir = -ang:Forward()
|
||||
|
||||
elseif direction.y == 1 then
|
||||
Dir = ang:Right()
|
||||
|
||||
elseif direction.y == -1 then
|
||||
Dir = -ang:Right()
|
||||
|
||||
elseif direction.z == 1 then
|
||||
Dir = ang:Up()
|
||||
|
||||
elseif direction.z == -1 then
|
||||
Dir = -ang:Up()
|
||||
end
|
||||
|
||||
return Dir
|
||||
end
|
||||
|
||||
hook.Add( "HUDPaint", "simfphys_crosshair", function()
|
||||
|
||||
if not show_crosshair then return end
|
||||
|
||||
local ply = LocalPlayer()
|
||||
local veh = ply:GetVehicle()
|
||||
|
||||
if not IsValid( veh ) then return end
|
||||
|
||||
local HasCrosshair = veh:GetNWBool( "HasCrosshair" )
|
||||
|
||||
if not HasCrosshair then return end
|
||||
|
||||
local vehicle = ply.GetSimfphys and ply:GetSimfphys() or veh.vehiclebase
|
||||
|
||||
if not IsValid( vehicle ) then return end
|
||||
|
||||
if ply:GetViewEntity() ~= ply then return end
|
||||
|
||||
local ID = vehicle:LookupAttachment( veh:GetNWString( "Attachment" ) )
|
||||
if ID == 0 then return end
|
||||
|
||||
local Attachment = vehicle:GetAttachment( ID )
|
||||
|
||||
local startpos = Attachment.Pos
|
||||
local endpos = startpos + MixDirection( Attachment.Ang, veh:GetNWVector( "Direction" ) ) * 999999
|
||||
|
||||
if veh:GetNWBool( "CalcCenterPos" ) then
|
||||
local attach_l = vehicle:LookupAttachment( veh:GetNWString( "Start_Left" ) )
|
||||
local attach_r = vehicle:LookupAttachment( veh:GetNWString( "Start_Right" ) )
|
||||
|
||||
if attach_l > 0 and attach_r > 0 then
|
||||
local pos1 = vehicle:GetAttachment( attach_l ).Pos
|
||||
local pos2 = vehicle:GetAttachment( attach_r ).Pos
|
||||
|
||||
startpos = (pos1 + pos2) / 2
|
||||
|
||||
traceAndDrawCrosshair( startpos, endpos, vehicle, veh )
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
traceAndDrawCrosshair( startpos, endpos, vehicle, veh )
|
||||
end )
|
197
lua/autorun/client/simfphys_tank_extras.lua
Normal file
197
lua/autorun/client/simfphys_tank_extras.lua
Normal file
@ -0,0 +1,197 @@
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
-- DO NOT EDIT OR REUPLOAD THIS SCRIPT
|
||||
|
||||
local function GetTrackPos( ent, div, smoother )
|
||||
local FT = FrameTime()
|
||||
local spin_left = ent.trackspin_l and (-ent.trackspin_l / div) or 0
|
||||
local spin_right = ent.trackspin_r and (-ent.trackspin_r / div) or 0
|
||||
|
||||
ent.sm_TrackDelta_L = ent.sm_TrackDelta_L and (ent.sm_TrackDelta_L + (spin_left - ent.sm_TrackDelta_L) * smoother) or 0
|
||||
ent.sm_TrackDelta_R = ent.sm_TrackDelta_R and (ent.sm_TrackDelta_R + (spin_right- ent.sm_TrackDelta_R) * smoother) or 0
|
||||
|
||||
return {Left = ent.sm_TrackDelta_L,Right = ent.sm_TrackDelta_R}
|
||||
end
|
||||
|
||||
local function UpdateTigerScrollTexture( ent )
|
||||
local id = ent:EntIndex()
|
||||
|
||||
if not ent.wheel_left_mat then
|
||||
ent.wheel_left_mat = CreateMaterial("trackmat_"..id.."_left", "VertexLitGeneric", { ["$basetexture"] = "models/blu/track", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
if not ent.wheel_right_mat then
|
||||
ent.wheel_right_mat = CreateMaterial("trackmat_"..id.."_right", "VertexLitGeneric", { ["$basetexture"] = "models/blu/track", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
local TrackPos = GetTrackPos( ent, 100, 0.5 )
|
||||
|
||||
ent.wheel_left_mat:SetVector("$translate", Vector(0,TrackPos.Left,0) )
|
||||
ent.wheel_right_mat:SetVector("$translate", Vector(0,TrackPos.Right,0) )
|
||||
|
||||
ent:SetSubMaterial( 1, "!trackmat_"..id.."_left" )
|
||||
ent:SetSubMaterial( 2, "!trackmat_"..id.."_right" )
|
||||
end
|
||||
|
||||
local function UpdateShermanScrollTexture( ent )
|
||||
local id = ent:EntIndex()
|
||||
|
||||
if not ent.wheel_left_mat then
|
||||
ent.wheel_left_mat = CreateMaterial("s_trackmat_"..id.."_left", "VertexLitGeneric", { ["$basetexture"] = "models/blu/track_sherman", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
if not ent.wheel_right_mat then
|
||||
ent.wheel_right_mat = CreateMaterial("s_trackmat_"..id.."_right", "VertexLitGeneric", { ["$basetexture"] = "models/blu/track_sherman", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
local TrackPos = GetTrackPos( ent, 350, 0.25 )
|
||||
|
||||
ent.wheel_left_mat:SetVector("$translate", Vector(0,TrackPos.Left,0) )
|
||||
ent.wheel_right_mat:SetVector("$translate", Vector(0,TrackPos.Right,0) )
|
||||
|
||||
ent:SetSubMaterial( 1, "!s_trackmat_"..id.."_left" )
|
||||
ent:SetSubMaterial( 2, "!s_trackmat_"..id.."_right" )
|
||||
end
|
||||
|
||||
local function UpdateLeopardScrollTexture( ent )
|
||||
local id = ent:EntIndex()
|
||||
|
||||
if not ent.wheel_left_mat then
|
||||
ent.wheel_left_mat = CreateMaterial("l_trackmat_"..id.."_left", "VertexLitGeneric", { ["$basetexture"] = "models/blu/track_leopard", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
if not ent.wheel_right_mat then
|
||||
ent.wheel_right_mat = CreateMaterial("l_trackmat_"..id.."_right", "VertexLitGeneric", { ["$basetexture"] = "models/blu/track_leopard", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
local TrackPos = GetTrackPos( ent, 90, 0.25 )
|
||||
ent.wheel_left_mat:SetVector("$translate", Vector(0,TrackPos.Left,0) )
|
||||
ent.wheel_right_mat:SetVector("$translate", Vector(0,TrackPos.Right,0) )
|
||||
|
||||
ent:SetSubMaterial( 4, "!l_trackmat_"..id.."_left" )
|
||||
ent:SetSubMaterial( 3, "!l_trackmat_"..id.."_right" )
|
||||
end
|
||||
|
||||
local function UpdateT90ScrollTexture( ent )
|
||||
local id = ent:EntIndex()
|
||||
|
||||
if not ent.wheel_left_mat then
|
||||
ent.wheel_left_mat = CreateMaterial("t90_trackmat_"..id.."_left", "VertexLitGeneric", { ["$basetexture"] = "models/blu/t90ms/t90ms_track_a_c", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
if not ent.wheel_right_mat then
|
||||
ent.wheel_right_mat = CreateMaterial("t90_trackmat_"..id.."_right", "VertexLitGeneric", { ["$basetexture"] = "models/blu/t90ms/t90ms_track_a_c", ["$alphatest"] = "1", ["$translate"] = "[0.0 0.0 0.0]", ["Proxies"] = { ["TextureTransform"] = { ["translateVar"] = "$translate", ["centerVar"] = "$center",["resultVar"] = "$basetexturetransform", } } } )
|
||||
end
|
||||
|
||||
local TrackPos = GetTrackPos( ent, 80, 0.25 )
|
||||
ent.wheel_left_mat:SetVector("$translate", Vector(0,TrackPos.Left,0) )
|
||||
ent.wheel_right_mat:SetVector("$translate", Vector(0,TrackPos.Right,0) )
|
||||
|
||||
ent:SetSubMaterial( 2, "!t90_trackmat_"..id.."_left" )
|
||||
ent:SetSubMaterial( 1, "!t90_trackmat_"..id.."_right" )
|
||||
end
|
||||
|
||||
local TrackData = {
|
||||
sim_fphys_tank = function( ent ) UpdateTigerScrollTexture( ent ) end,
|
||||
sim_fphys_tank2 = function( ent ) UpdateShermanScrollTexture( ent ) end,
|
||||
sim_fphys_tank3 = function( ent ) UpdateLeopardScrollTexture( ent ) end,
|
||||
sim_fphys_tank4 = function( ent ) UpdateT90ScrollTexture( ent ) end,
|
||||
}
|
||||
|
||||
local next_think = 0
|
||||
local next_find = 0
|
||||
local tanks = {}
|
||||
|
||||
hook.Add( "Think", "simfphys_armed_trackupdater", function()
|
||||
local curtime = CurTime()
|
||||
|
||||
if curtime > next_find then
|
||||
next_find = curtime + 2
|
||||
|
||||
table.Empty( tanks )
|
||||
|
||||
for _, ent in pairs( ents.FindByClass( "gmod_sent_vehicle_fphysics_base" ) ) do
|
||||
local class = ent:GetSpawn_List()
|
||||
|
||||
if isfunction( TrackData[class] ) then
|
||||
local Data = {}
|
||||
Data.Entity = ent
|
||||
Data.Func = TrackData[class]
|
||||
|
||||
table.insert( tanks, Data )
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if curtime > next_think then
|
||||
next_think = curtime + 0.02
|
||||
|
||||
if tanks then
|
||||
for index, data in pairs( tanks ) do
|
||||
if IsValid( data.Entity ) then
|
||||
data.Func( data.Entity )
|
||||
else
|
||||
tanks[index] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end )
|
||||
|
||||
net.Receive( "simfphys_update_tracks", function( length )
|
||||
local tank = net.ReadEntity()
|
||||
if not IsValid( tank ) then return end
|
||||
|
||||
tank.trackspin_r = net.ReadFloat()
|
||||
tank.trackspin_l = net.ReadFloat()
|
||||
end)
|
||||
|
||||
net.Receive( "simfphys_tank_do_effect", function( length ) -- we need to keep this for backwards compatibility
|
||||
local tank = net.ReadEntity()
|
||||
if not IsValid( tank ) then return end
|
||||
|
||||
local effect = net.ReadString()
|
||||
|
||||
if effect == "Muzzle" then
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetEntity( tank )
|
||||
util.Effect( "simfphys_tiger_muzzle", effectdata )
|
||||
|
||||
elseif effect == "Muzzle2" then
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetEntity( tank )
|
||||
util.Effect( "simfphys_sherman_muzzle", effectdata )
|
||||
|
||||
elseif effect == "Muzzle3" then
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetEntity( tank )
|
||||
util.Effect( "simfphys_leopard_muzzle", effectdata )
|
||||
|
||||
elseif effect == "Explosion" then
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( net.ReadVector() )
|
||||
util.Effect( "simfphys_tankweapon_explosion", effectdata )
|
||||
|
||||
elseif effect == "Explosion_small" then
|
||||
local effectdata = EffectData()
|
||||
effectdata:SetOrigin( net.ReadVector() )
|
||||
util.Effect( "simfphys_tankweapon_explosion_small", effectdata )
|
||||
end
|
||||
end)
|
Loading…
Reference in New Issue
Block a user