restore to non lvs

This commit is contained in:
Luna 2024-09-09 15:48:12 +02:00
parent 454ba5eb7e
commit a403c8a064
165 changed files with 2030 additions and 516 deletions

View File

@ -1,3 +0,0 @@
name=simfphys armed
version=167
url=https://raw.githubusercontent.com/SpaxscE/simfphys_armed/master/data_static/lvs/831680603.txt

View File

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

View File

@ -29,7 +29,7 @@ hook.Add( "CalcView", "zz_simfphys_gunner_view", function( ply, pos, ang )
if not IsValid( Vehicle ) then return end
local Base = ply:GetSimfphys()
local Base = ply.GetSimfphys and ply:GetSimfphys() or Vehicle.vehiclebase
if not IsValid( Base ) then return end
@ -65,13 +65,13 @@ hook.Add( "CalcView", "zz_simfphys_gunner_view", function( ply, pos, ang )
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 = Base:GetRenderBounds()
local mn, mx = Vehicle:GetRenderBounds()
local radius = ( mn - mx ):Length()
local radius = radius + radius * Vehicle:GetCameraDistance()

View File

@ -1,11 +1,33 @@
-- 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_hud", function( convar, oldValue, newValue ) ShowHud = tonumber( newValue )~=0 end)
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)
@ -13,13 +35,17 @@ cvars.AddChangeCallback( "cl_simfphys_hudrealspeed", function( convar, oldValue,
Hudmph = GetConVar( "cl_simfphys_hudmph" ):GetBool()
Hudreal = GetConVar( "cl_simfphys_hudrealspeed" ):GetBool()
show_crosshair = GetConVar( "cl_simfphys_crosshair" ):GetBool()
ShowHud = GetConVar( "cl_simfphys_hud" ):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
@ -80,7 +106,7 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
local Type = pod:GetNWInt( "CrosshairType", 0 )
surface.SetDrawColor( color_white )
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)
@ -88,32 +114,31 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
local printspeed = Hudmph and tostring(mph).."mph" or tostring(kmh).."km/h"
if Type == 0 then
vehicle:PaintCrosshairCenter( scr )
vehicle:PaintCrosshairOuter( scr )
surface.SetDrawColor( color_white )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( math.Round(vehicle:GetThrottle() * 100).."%"..Cruise , "SIMFPHYS_ARMED_HUDFONT", 120, 10, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( printspeed, "SIMFPHYS_ARMED_HUDFONT", 120, 35, color_white, 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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( math.Round(vehicle:GetFuel()).."/"..vehicle:GetMaxFuel().."L", "SIMFPHYS_ARMED_HUDFONT", 120, 60, color_white, 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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( Mode, "SIMFPHYS_ARMED_HUDFONT", 120, 85, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( Ammo, "SIMFPHYS_ARMED_HUDFONT", 120, 110, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
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
@ -121,28 +146,28 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
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( 255, 255, 255, 50 )
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 )
@ -161,16 +186,16 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
local safemode = vehicle:GetNWBool( "TurretSafeMode", true )
if not safemode then
surface.SetDrawColor( 255, 255, 255, 180 )
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, 255, 255, 255 * alpha ), 1, 1)
draw.SimpleText( "press "..Key.." to activate turret!", "simfphysfont", scrW, ScrH() - scrH * 0.04, Color( 255, 235, 0, 255 * alpha ), 1, 1)
surface.SetDrawColor( 255, 255, 255, 50 )
surface.SetDrawColor( 240, 200, 0, 50 )
end
local rOuter = scrW * 0.03 * Scale
@ -182,11 +207,11 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
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( 255, 255, 255, 180 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
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( 255, 255, 255, 180 ), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
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 )
@ -223,14 +248,14 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( math.Round(vehicle:GetThrottle() * 100).."%"..Cruise , "SIMFPHYS_ARMED_HUDFONT", 120, 10, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( printspeed, "SIMFPHYS_ARMED_HUDFONT", 120, 35, color_white, 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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( math.Round(vehicle:GetFuel()).."/"..vehicle:GetMaxFuel().."L", "SIMFPHYS_ARMED_HUDFONT", 120, 60, color_white, 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 )
@ -253,9 +278,9 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
end
if not safemode then
surface.SetDrawColor( 255, 255, 255, 180 )
surface.SetDrawColor( 240, 200, 0, 180 )
else
surface.SetDrawColor( 255, 255, 255, 50 )
surface.SetDrawColor( 240, 200, 0, 50 )
end
local Yaw = vehicle:GetPoseParameter( "turret_yaw" ) * 360 - 90
@ -267,7 +292,7 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
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( 255, 255, 255, 180 )
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 )
@ -275,9 +300,8 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
surface.DrawLine( scrW - len * 1.25, scrH * 1.85 + len * 2, scrW + len * 1.25, scrH * 1.85 + len * 2 )
elseif Type == 3 then
vehicle:PaintCrosshairCenter( scr )
vehicle:PaintCrosshairOuter( scr )
surface.SetDrawColor( color_white )
surface.SetMaterial( xhair )
surface.DrawTexturedRect( scr.x - 17,scr.y - 17, 34, 34)
local scrW = ScrW() / 2
local scrH = ScrH() / 2
@ -299,25 +323,25 @@ local function traceAndDrawCrosshair( startpos, endpos, vehicle, pod )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( math.Round(vehicle:GetThrottle() * 100).."%"..Cruise , "SIMFPHYS_ARMED_HUDFONT", 120, 10, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( printspeed, "SIMFPHYS_ARMED_HUDFONT", 120, 35, color_white, 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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( math.Round(vehicle:GetFuel()).."/"..vehicle:GetMaxFuel().."L", "SIMFPHYS_ARMED_HUDFONT", 120, 60, color_white, 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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( Mode, "SIMFPHYS_ARMED_HUDFONT", 120, 85, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
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_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( Ammo, "SIMFPHYS_ARMED_HUDFONT", 120, 110, color_white, TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
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
@ -511,34 +535,32 @@ local function MixDirection( ang, direction )
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()
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 )
if not Attachment then return end
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" ) )
@ -553,6 +575,6 @@ hook.Add( "HUDPaint", "simfphys_crosshair", function()
end
return
end
traceAndDrawCrosshair( startpos, endpos, vehicle, veh )
end )

View File

@ -5,18 +5,8 @@
-- 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
resource.AddWorkshop("831680603")
simfphys = istable( simfphys ) and simfphys or {}
@ -27,12 +17,6 @@ simfphys.weapon = {}
util.AddNetworkString( "simfphys_tank_do_effect" ) -- some people still use this so we have to keep it
util.AddNetworkString( "simfphys_update_tracks" )
--resource.AddSingleFile( "materials/effects/simfphys_armed/gauss_beam.vmt" )
--resource.AddSingleFile( "materials/effects/simfphys_armed/gauss_beam.vtf" )
--resource.AddSingleFile( "materials/effects/simfphys_armed/spark.vmt" )
--resource.AddSingleFile( "materials/effects/simfphys_armed/spark.vtf" )
--resource.AddSingleFile( "materials/effects/simfphys_armed/spark_brightness.vtf" )
local ImpactSounds = {
"physics/metal/metal_sheet_impact_bullet2.wav",
"physics/metal/metal_sheet_impact_hard2.wav",
@ -229,25 +213,51 @@ function simfphys.FireBullet( data )
if not isvector( data.shootDirection ) then return end
if not IsValid( data.attacker ) then return end
if not IsValid( data.attackingent ) then return end
data.Spread = data.Spread or Vector(0,0,0)
data.Tracer = data.Tracer or 0
data.HullSize = data.HullSize or 1
local trace = util.TraceHull( {
start = data.shootOrigin,
endpos = data.shootOrigin + (data.shootDirection + Vector(math.Rand(-data.Spread.x,data.Spread.x),math.Rand(-data.Spread.y,data.Spread.y),math.Rand(-data.Spread.x,data.Spread.x)) )* 50000,
filter = data.filter,
maxs = data.HullSize,
mins = -data.HullSize
} )
local bullet = {}
bullet.Num = 1
bullet.Src = data.shootOrigin
bullet.Src = trace.HitPos - data.shootDirection * 5
bullet.Dir = data.shootDirection
bullet.Spread = data.Spread
bullet.TracerName = "lvs_tracer_white"
bullet.Spread = Vector(0,0,0)
bullet.TracerName = "simfphys_tracer_hit"
bullet.Tracer = 1
bullet.Force = (data.Force and data.Force or 1)
bullet.Damage = (data.Damage and data.Damage or 1)
bullet.HullSize = data.HullSize or 1
bullet.HullSize = data.HullSize
bullet.Attacker = data.attacker
bullet.Entity = data.attackingent
bullet.Velocity = 30000
bullet.SrcEntity = data.attackingent:WorldToLocal( data.shootOrigin )
bullet.Callback = function(att, tr, dmginfo)
dmginfo:SetDamageType( DMG_BULLET )
if tr.Entity ~= Entity(0) then
if simfphys.IsCar( tr.Entity ) then
sound.Play( Sound( ImpactSounds[ math.random(1,table.Count( ImpactSounds )) ] ), tr.HitPos, SNDLVL_90dB)
end
end
end
data.attackingent:FireBullets( bullet )
data.attackingent.hScanTracer = data.attackingent.hScanTracer and (data.attackingent.hScanTracer + 1) or 0
if data.Tracer > 0 then
if data.attackingent.hScanTracer >= data.Tracer then
data.attackingent.hScanTracer = 0
local effectdata = EffectData()
effectdata:SetStart( data.shootOrigin )
effectdata:SetOrigin( trace.HitPos )
util.Effect( "simfphys_tracer", effectdata )
end
end
LVS:FireBullet( bullet )
end
function simfphys.xhairRegister( ent, data )
@ -287,7 +297,7 @@ function simfphys.WeaponSystemRegister( vehicle )
end
local class = vehicle:GetSpawn_List()
for wpnname,tbldata in pairs( simfphys.Weapons ) do
for _,v in pairs( tbldata.ValidClasses() ) do
if class == v then
@ -298,14 +308,6 @@ function simfphys.WeaponSystemRegister( vehicle )
table.insert(simfphys.ManagedVehicles, data)
tbldata.Initialize( tbldata, vehicle )
timer.Simple(0.3, function()
if not IsValid( vehicle ) then return end
if vehicle:GetAITEAM() == 0 then
vehicle:SetAITEAM( 3 )
end
end)
end
end
end
@ -401,3 +403,35 @@ hook.Add("Think", "simfphys_weaponhandler", function()
end
end
end)
timer.Simple(18, function()
if simfphys.VERSION < 1.2 then
print( "[SIMFPHYS ARMED]: SIMFPHYS BASE IS OUT OF DATE!" )
if (simfphys.armedAutoRegister and not simfphys.armedAutoRegister()) or simfphys.RegisterEquipment then
print("[SIMFPHYS ARMED]: ONE OF YOUR ADDITIONAL SIMFPHYS-ARMED PACKS IS CAUSING CONFLICTS!!!")
print("[SIMFPHYS ARMED]: PRECAUTIONARY RESTORING FUNCTION:")
print("[SIMFPHYS ARMED]: simfphys.FireHitScan")
print("[SIMFPHYS ARMED]: simfphys.FirePhysProjectile")
print("[SIMFPHYS ARMED]: simfphys.RegisterCrosshair")
print("[SIMFPHYS ARMED]: simfphys.RegisterCamera")
print("[SIMFPHYS ARMED]: simfphys.armedAutoRegister")
print("[SIMFPHYS ARMED]: REMOVING FUNCTION:")
print("[SIMFPHYS ARMED]: simfphys.RegisterEquipment")
print("[SIMFPHYS ARMED]: CLEARING OUTDATED ''RegisterEquipment'' HOOK")
print("[SIMFPHYS ARMED]: !!!FUNCTIONALITY IS NOT GUARANTEED!!!")
simfphys.FireHitScan = function( data ) simfphys.FireBullet( data ) end
simfphys.FirePhysProjectile = function( data ) simfphys.FirePhysBullet( data ) end
simfphys.RegisterCrosshair = function( ent, data ) simfphys.xhairRegister( ent, data ) end
simfphys.RegisterCamera =
function( ent, offset_firstperson, offset_thirdperson, bLocalAng, attachment )
simfphys.CameraRegister( ent, offset_firstperson, offset_thirdperson, bLocalAng, attachment )
end
hook.Remove( "PlayerSpawnedVehicle","simfphys_armedvehicles" )
simfphys.RegisterEquipment = nil
simfphys.armedAutoRegister = function( vehicle ) simfphys.WeaponSystemRegister( vehicle ) return true end
end
end
end)

View File

@ -1,15 +0,0 @@
hook.Add( "LVS:ARMED:Initialize", "[LVS] - Armed [Fake Physics]", function()
if SERVER then
AddCSLuaFile("simfphys/cl_armedvehicles_specialcam.lua")
AddCSLuaFile("simfphys/cl_armedvehicles_tankextras.lua")
AddCSLuaFile("simfphys/cl_armedvehicles_xhair.lua")
include("simfphys/sv_armedvehicles_handler.lua")
return
end
include("simfphys/cl_armedvehicles_specialcam.lua")
include("simfphys/cl_armedvehicles_tankextras.lua")
include("simfphys/cl_armedvehicles_xhair.lua")
end)

View File

@ -61,8 +61,6 @@ local V = {
Category = "Armed Vehicles",
Members = {
AITEAM = 1,
Mass = 3500,
MaxHealth = 6000,
@ -176,8 +174,6 @@ local V = {
Category = "Armed Vehicles",
Members = {
AITEAM = 2,
Mass = 1700,
LightsTable = "jeep",
@ -251,8 +247,6 @@ local V = {
Category = "Armed Vehicles",
Members = {
AITEAM = 2,
Mass = 1700,
LightsTable = "jeep",
@ -326,8 +320,6 @@ local V = {
Category = "Armed Vehicles",
Members = {
AITEAM = 2,
Mass = 1700,
LightsTable = "elitejeep",
@ -425,8 +417,6 @@ local V = {
Category = "Armed Vehicles",
Members = {
AITEAM = 2,
Mass = 1700,
LightsTable = "elitejeep",
@ -525,8 +515,6 @@ local V = {
SpawnOffset = Vector(0,0,50),
Members = {
AITEAM = 2,
Mass = 4800,
MaxHealth = 4500,
@ -785,8 +773,6 @@ local V = {
SpawnOffset = Vector(0,0,25),
Members = {
AITEAM = 3,
Mass = 4800,
FrontWheelMass = 225,
RearWheelMass = 225,
@ -925,8 +911,6 @@ local V = {
SpawnOffset = Vector(0,0,30),
Members = {
AITEAM = 3,
Mass = 4800,
FrontWheelMass = 225,
RearWheelMass = 225,
@ -1064,8 +1048,6 @@ local V = {
SpawnOffset = Vector(0,0,25),
Members = {
AITEAM = 3,
Mass = 4800,
FrontWheelMass = 225,
RearWheelMass = 225,
@ -1195,6 +1177,352 @@ local V = {
list.Set( "simfphys_vehicles", "sim_fphys_hedgehog", V )
local V = {
Name = "DOD:S Tiger Tank",
Model = "models/blu/tanks/tiger.mdl",
Class = "gmod_sent_vehicle_fphysics_base",
Category = "Armed Vehicles",
SpawnOffset = Vector(0,0,60),
SpawnAngleOffset = 90,
Members = {
Mass = 10000,
AirFriction = 5,
Inertia = Vector(10000,80000,100000),
OnSpawn =
function(ent)
ent:SetNWBool( "simfphys_NoRacingHud", true )
ent:SetNWBool( "simfphys_NoHud", true )
end,
ApplyDamage = function( ent, damage, type )
simfphys.TankApplyDamage(ent, damage, type)
end,
GibModels = {
"models/blu/tanks/tiger_gib_1.mdl",
"models/blu/tanks/tiger_gib_2.mdl",
"models/blu/tanks/tiger_gib_3.mdl",
"models/blu/tanks/tiger_gib_4.mdl",
},
MaxHealth = 8000,
IsArmored = true,
NoWheelGibs = true,
FirstPersonViewPos = Vector(0,-50,15),
FrontWheelRadius = 45,
RearWheelRadius = 45,
EnginePos = Vector(-79.66,0,72.21),
CustomWheels = true,
CustomSuspensionTravel = 10,
CustomWheelModel = "models/props_c17/canisterchunk01g.mdl",
CustomWheelPosFL = Vector(110,45,45),
CustomWheelPosFR = Vector(110,-45,45),
CustomWheelPosML = Vector(5,45,40),
CustomWheelPosMR = Vector(5,-45,40),
CustomWheelPosRL = Vector(-100,45,45),
CustomWheelPosRR = Vector(-100,-45,45),
CustomWheelAngleOffset = Angle(0,0,90),
CustomMassCenter = Vector(0,0,5),
CustomSteerAngle = 60,
SeatOffset = Vector(70,0,55),
SeatPitch = 0,
SeatYaw = 90,
ModelInfo = {
WheelColor = Color(0,0,0,0),
},
ExhaustPositions = {
{
pos = Vector(-118,-16.62,72.6),
ang = Angle(115,0,0)
},
{
pos = Vector(-118,-16.62,72.6),
ang = Angle(115,60,0)
},
{
pos = Vector(-118,-16.62,72.6),
ang = Angle(115,-60,0)
},
{
pos = Vector(-118,16.62,72.6),
ang = Angle(115,0,0)
},
{
pos = Vector(-118,16.62,72.6),
ang = Angle(115,60,0)
},
{
pos = Vector(-118,16.62,72.6),
ang = Angle(115,-60,0)
},
},
PassengerSeats = {
{
pos = Vector(0,0,50),
ang = Angle(0,-90,0)
},
{
pos = Vector(0,0,50),
ang = Angle(0,-90,0)
},
{
pos = Vector(0,0,50),
ang = Angle(0,-90,0)
}
},
FrontHeight = 23,
FrontConstant = 50000,
FrontDamping = 6000,
FrontRelativeDamping = 6000,
RearHeight = 23,
RearConstant = 50000,
RearDamping = 6000,
RearRelativeDamping = 6000,
FastSteeringAngle = 14,
SteeringFadeFastSpeed = 400,
TurnSpeed = 6,
MaxGrip = 800,
Efficiency = 0.7,
GripOffset = -300,
BrakePower = 150,
BulletProofTires = true,
IdleRPM = 600,
LimitRPM = 4500,
PeakTorque = 280,
PowerbandStart = 600,
PowerbandEnd = 3500,
Turbocharged = false,
Supercharged = false,
DoNotStall = true,
FuelFillPos = Vector(-111.88,-0.14,59.15),
FuelType = FUELTYPE_PETROL,
FuelTankSize = 160,
PowerBias = -0.5,
EngineSoundPreset = 0,
Sound_Idle = "simulated_vehicles/misc/nanjing_loop.wav",
Sound_IdlePitch = 1,
Sound_Mid = "simulated_vehicles/misc/m50.wav",
Sound_MidPitch = 1,
Sound_MidVolume = 1,
Sound_MidFadeOutRPMpercent = 58,
Sound_MidFadeOutRate = 0.476,
Sound_High = "simulated_vehicles/tiger/tiger_high.wav",
Sound_HighPitch = 0.75,
Sound_HighVolume = 0.75,
Sound_HighFadeInRPMpercent = 40,
Sound_HighFadeInRate = 0.19,
Sound_Throttle = "",
Sound_ThrottlePitch = 0,
Sound_ThrottleVolume = 0,
snd_horn = "common/null.wav",
ForceTransmission = 1,
DifferentialGear = 0.21,
Gears = {-0.1,0,0.05,0.07,0.09,0.11,0.13}
}
}
list.Set( "simfphys_vehicles", "sim_fphys_tank", V )
local V = {
Name = "DOD:S Sherman Tank",
Model = "models/blu/tanks/sherman.mdl",
Class = "gmod_sent_vehicle_fphysics_base",
Category = "Armed Vehicles",
SpawnOffset = Vector(0,0,60),
SpawnAngleOffset = 90,
Members = {
Mass = 8000,
AirFriction = 7,
Inertia = Vector(10000,80000,100000),
OnSpawn =
function(ent)
ent:SetNWBool( "simfphys_NoRacingHud", true )
ent:SetNWBool( "simfphys_NoHud", true )
end,
ApplyDamage = function( ent, damage, type )
simfphys.TankApplyDamage(ent, damage, type)
end,
GibModels = {
"models/blu/tanks/sherman_gib_1.mdl",
"models/blu/tanks/sherman_gib_2.mdl",
"models/blu/tanks/sherman_gib_3.mdl",
"models/blu/tanks/sherman_gib_4.mdl",
"models/blu/tanks/sherman_gib_6.mdl",
"models/blu/tanks/sherman_gib_7.mdl",
},
MaxHealth = 6000,
IsArmored = true,
NoWheelGibs = true,
FirstPersonViewPos = Vector(0,-50,15),
FrontWheelRadius = 40,
RearWheelRadius = 40,
EnginePos = Vector(-79.66,0,72.21),
CustomWheels = true,
CustomSuspensionTravel = 10,
CustomWheelModel = "models/props_c17/canisterchunk01g.mdl",
CustomWheelPosFL = Vector(100,35,50),
CustomWheelPosFR = Vector(100,-35,50),
CustomWheelPosML = Vector(-5,35,50),
CustomWheelPosMR = Vector(-5,-35,50),
CustomWheelPosRL = Vector(-110,35,50),
CustomWheelPosRR = Vector(-110,-35,50),
CustomWheelAngleOffset = Angle(0,0,90),
CustomMassCenter = Vector(0,0,3),
CustomSteerAngle = 60,
SeatOffset = Vector(60,-15,55),
SeatPitch = 0,
SeatYaw = 90,
ModelInfo = {
WheelColor = Color(0,0,0,0),
},
ExhaustPositions = {
{
pos = Vector(-90.47,17.01,52.77),
ang = Angle(180,0,0)
},
{
pos = Vector(-90.47,-17.01,52.77),
ang = Angle(180,0,0)
},
},
PassengerSeats = {
{
pos = Vector(50,-15,30),
ang = Angle(0,-90,0)
},
{
pos = Vector(0,0,30),
ang = Angle(0,-90,0)
},
{
pos = Vector(0,0,30),
ang = Angle(0,-90,0)
}
},
FrontHeight = 22,
FrontConstant = 50000,
FrontDamping = 5000,
FrontRelativeDamping = 5000,
RearHeight = 22,
RearConstant = 50000,
RearDamping = 5000,
RearRelativeDamping = 5000,
FastSteeringAngle = 14,
SteeringFadeFastSpeed = 400,
TurnSpeed = 6,
MaxGrip = 800,
Efficiency = 0.85,
GripOffset = -300,
BrakePower = 100,
BulletProofTires = true,
IdleRPM = 600,
LimitRPM = 4500,
PeakTorque = 250,
PowerbandStart = 600,
PowerbandEnd = 3500,
Turbocharged = false,
Supercharged = false,
DoNotStall = true,
FuelFillPos = Vector(-46.03,-34.64,75.23),
FuelType = FUELTYPE_PETROL,
FuelTankSize = 160,
PowerBias = -0.5,
EngineSoundPreset = 0,
Sound_Idle = "simulated_vehicles/sherman/idle.wav",
Sound_IdlePitch = 1,
Sound_Mid = "simulated_vehicles/sherman/low.wav",
Sound_MidPitch = 1.3,
Sound_MidVolume = 0.75,
Sound_MidFadeOutRPMpercent = 50,
Sound_MidFadeOutRate = 0.85,
Sound_High = "simulated_vehicles/sherman/high.wav",
Sound_HighPitch = 1,
Sound_HighVolume = 1,
Sound_HighFadeInRPMpercent = 20,
Sound_HighFadeInRate = 0.2,
Sound_Throttle = "",
Sound_ThrottlePitch = 0,
Sound_ThrottleVolume = 0,
snd_horn = "common/null.wav",
ForceTransmission = 1,
DifferentialGear = 0.3,
Gears = {-0.1,0,0.05,0.08,0.11,0.12}
}
}
list.Set( "simfphys_vehicles", "sim_fphys_tank2", V )
local light_table = {
L_HeadLampPos = Vector(-122.5,-33.02,25.81),
L_HeadLampAng = Angle(15,180,0),
@ -1269,8 +1597,6 @@ local V = {
SpawnAngleOffset = 90,
Members = {
AITEAM = 2,
Mass = 20000,
AirFriction = 7,
--Inertia = Vector(14017.5,46543,47984.5),
@ -1448,8 +1774,6 @@ local V = {
SpawnAngleOffset = 90,
Members = {
AITEAM = 1,
Mass = 20000,
AirFriction = 0,
--Inertia = Vector(14017.5,46543,47984.5),

View File

@ -1,29 +0,0 @@
EFFECT.MatBeam = Material( "effects/gunshiptracer" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 500 * bullet:GetLength()
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos + dir * len, endpos - dir * len, 10, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@ -46,6 +46,12 @@ function ENT:Initialize()
self.Vel = self:GetForward() * 200
end
local CanDeflectOn = {
["gmod_sent_vehicle_fphysics_base"] = true,
["gmod_sent_vehicle_fphysics_wheel"] = true,
["prop_physics"] = true,
}
function ENT:Think()
local curtime = CurTime()
self:NextThink( curtime )
@ -72,7 +78,7 @@ function ENT:Think()
self.DeflectAng = self.DeflectAng or 25
if hitangle < self.DeflectAng and not self.Bounced and (trace.Entity:GetClass() == "prop_physics" or trace.Entity.LVS) then
if hitangle < self.DeflectAng and not self.Bounced and CanDeflectOn[ trace.Entity:GetClass() ] then
local thVel = self.Vel:Length()
@ -119,14 +125,14 @@ function ENT:Think()
else
dmginfo:SetDamageType(DMG_DIRECT)
end
local attackingEnt = IsValid( self.AttackingEnt ) and self.AttackingEnt or self
local attacker = IsValid( self.Attacker ) and self.Attacker or self
util.BlastDamage( attackingEnt, attacker, tr.HitPos,self.BlastRadius,self.BlastDamage)
util.Decal("scorch", tr.HitPos - tr.HitNormal, tr.HitPos + tr.HitNormal)
if tr.Entity ~= Entity(0) then
if simfphys.IsCar( tr.Entity ) then
local effectdata = EffectData()

View File

@ -1,23 +1,28 @@
local function AirboatFire(ply,vehicle,shootOrigin,Attachment,damage)
local bullet = {}
bullet.Src = shootOrigin
bullet.Dir = Attachment.Ang:Forward()
bullet.Spread = Vector(0.04,0.04,0.04)
bullet.TracerName = "lvs_ar2_tracer"
bullet.Force = damage
bullet.HullSize = 1
bullet.Damage = damage
bullet.Velocity = 12000
bullet.Attacker = ply
bullet.Callback = function(att, tr, dmginfo)
local effectdata = EffectData()
effectdata:SetOrigin( tr.HitPos + tr.HitNormal )
effectdata:SetNormal( tr.HitNormal * 2 )
effectdata:SetRadius( 10 )
util.Effect( "cball_bounce", effectdata, true, true )
end
vehicle:LVSFireBullet( bullet )
bullet.Num = 1
bullet.Src = shootOrigin
bullet.Dir = Attachment.Ang:Forward()
bullet.Spread = Vector(0.04,0.04,0)
bullet.Tracer = 1
bullet.TracerName = (damage > 10 and "AirboatGunHeavyTracer" or "AirboatGunTracer")
bullet.Force = damage
bullet.Damage = damage
bullet.HullSize = 1
bullet.DisableOverride = true
bullet.Callback = function(att, tr, dmginfo)
dmginfo:SetDamageType(DMG_AIRBOAT)
local effectdata = EffectData()
effectdata:SetOrigin( tr.HitPos + tr.HitNormal )
effectdata:SetNormal( tr.HitNormal )
effectdata:SetRadius( (damage > 1) and 8 or 3 )
util.Effect( "cball_bounce", effectdata, true, true )
end
bullet.Attacker = ply
vehicle:FireBullets( bullet )
end
function simfphys.weapon:ValidClasses()
@ -56,23 +61,8 @@ function simfphys.weapon:AimWeapon( ply, vehicle, pod )
local Aimang = ply:EyeAngles()
local AimRate = 250
local Angles = angle_zero
if ply:lvsMouseAim() then
local ang = vehicle:GetAngles()
ang.y = pod:GetAngles().y + 90
local Forward = ang:Right()
local View = pod:WorldToLocalAngles( Aimang )
local Pitch = (vehicle:AngleBetweenNormal( View:Up(), ang:Forward() ) - 90)
local Yaw = (vehicle:AngleBetweenNormal( View:Forward(), ang:Right() ) - 90)
Angles = Angle(-Pitch,Yaw,0)
else
Angles = vehicle:WorldToLocalAngles( Aimang ) - Angle(0,90,0)
Angles:Normalize()
end
local Angles = vehicle:WorldToLocalAngles( Aimang ) - Angle(0,90,0)
vehicle.sm_pp_yaw = vehicle.sm_pp_yaw and math.ApproachAngle( vehicle.sm_pp_yaw, Angles.y, AimRate * FrameTime() ) or 0
vehicle.sm_pp_pitch = vehicle.sm_pp_pitch and math.ApproachAngle( vehicle.sm_pp_pitch, Angles.p, AimRate * FrameTime() ) or 0

View File

@ -8,23 +8,33 @@ local function cAPCFire(ply,vehicle,shootOrigin,Attachment,damage,ID)
util.Effect( "AirboatMuzzleFlash", effectdata, true, true )
local bullet = {}
bullet.Src = shootOrigin
bullet.Dir = Attachment.Ang:Forward()
bullet.Spread = Vector(0.015,0.015,0.015)
bullet.TracerName = "lvs_ar2_tracer"
bullet.Force = damage
bullet.HullSize = 6
bullet.Damage = damage
bullet.Velocity = 12000
bullet.Attacker = ply
bullet.Callback = function(att, tr, dmginfo)
local effectdata = EffectData()
effectdata:SetOrigin( tr.HitPos + tr.HitNormal )
effectdata:SetNormal( tr.HitNormal * 2 )
effectdata:SetRadius( 10 )
util.Effect( "cball_bounce", effectdata, true, true )
end
vehicle:LVSFireBullet( bullet )
bullet.Num = 1
bullet.Src = shootOrigin
bullet.Dir = Attachment.Ang:Forward()
bullet.Spread = Vector(0.015,0.015,0)
bullet.Tracer = 0
bullet.TracerName = "none"
bullet.Force = damage
bullet.Damage = damage
bullet.HullSize = 1
bullet.DisableOverride = true
bullet.Callback = function(att, tr, dmginfo)
local effectdata = EffectData()
effectdata:SetEntity( vehicle )
effectdata:SetAttachment( ID )
effectdata:SetStart( shootOrigin )
effectdata:SetOrigin( tr.HitPos )
effectdata:SetScale( 6000 )
util.Effect("AR2Tracer", effectdata )
local effectdata = EffectData()
effectdata:SetOrigin( tr.HitPos + tr.HitNormal )
effectdata:SetNormal( tr.HitNormal )
util.Effect( "AR2Impact", effectdata, true, true )
end
bullet.Attacker = ply
vehicle:FireBullets( bullet )
end
function simfphys.weapon:ValidClasses()

View File

@ -85,29 +85,12 @@ function simfphys.weapon:Think( vehicle )
local ID = vehicle:LookupAttachment( "machinegun_ref" )
local Attachment = vehicle:GetAttachment( ID )
local Angles = angle_zero
if ply:lvsMouseAim() then
local TargetAngle = ply:EyeAngles()
local ang = vehicle:GetAngles()
ang.y = DriverSeat:GetAngles().y + 90
local Forward = ang:Right()
local View = DriverSeat:WorldToLocalAngles( TargetAngle )
local Pitch = (vehicle:AngleBetweenNormal( View:Up(), ang:Forward() ) - 90)
local Yaw = (vehicle:AngleBetweenNormal( View:Forward(), ang:Right() ) - 90)
Angles = Angle(-Pitch,Yaw,0)
else
Angles = vehicle:WorldToLocalAngles( ply:EyeAngles() )
Angles:Normalize()
end
local Angles = vehicle:WorldToLocalAngles( ply:EyeAngles() )
Angles:Normalize()
vehicle.sm_pp_yaw = vehicle.sm_pp_yaw and (vehicle.sm_pp_yaw + (Angles.y - vehicle.sm_pp_yaw) * 0.2) or 0
vehicle.sm_pp_pitch = vehicle.sm_pp_pitch and (vehicle.sm_pp_pitch + (Angles.p - vehicle.sm_pp_pitch) * 0.2) or 0
vehicle:SetPoseParameter("vehicle_weapon_yaw", vehicle.sm_pp_yaw )
vehicle:SetPoseParameter("vehicle_weapon_pitch", -vehicle.sm_pp_pitch )

View File

@ -0,0 +1,471 @@
local sherman_susdata = {}
for i = 1,6 do
sherman_susdata[i] = {
attachment = "vehicle_suspension_l_"..i,
poseparameter = "suspension_left_"..i,
}
local ir = i + 6
sherman_susdata[ir] = {
attachment = "vehicle_suspension_r_"..i,
poseparameter = "suspension_right_"..i,
}
end
local function hmg_fire(ply,vehicle,shootOrigin,shootDirection)
vehicle:EmitSound("tiger_fire_mg")
local projectile = {}
projectile.filter = vehicle.VehicleData["filter"]
projectile.shootOrigin = shootOrigin
projectile.shootDirection = shootDirection
projectile.attacker = ply
projectile.Tracer = 1
projectile.Spread = Vector(0.01,0.01,0.01)
projectile.HullSize = 5
projectile.attackingent = vehicle
projectile.Damage = 20
projectile.Force = 12
simfphys.FireHitScan( projectile )
end
local function mg_fire(ply,vehicle,shootOrigin,shootDirection)
vehicle:EmitSound("tiger_fire_mg_new")
local projectile = {}
projectile.filter = vehicle.VehicleData["filter"]
projectile.shootOrigin = shootOrigin
projectile.shootDirection = shootDirection
projectile.attacker = ply
projectile.Tracer = 1
projectile.Spread = Vector(0.015,0.015,0.015)
projectile.HullSize = 5
projectile.attackingent = vehicle
projectile.Damage = 15
projectile.Force = 12
simfphys.FireHitScan( projectile )
end
local function cannon_fire(ply,vehicle,shootOrigin,shootDirection)
vehicle:EmitSound("sherman_fire")
vehicle:EmitSound("sherman_reload")
local effectdata = EffectData()
effectdata:SetEntity( vehicle )
util.Effect( "simfphys_sherman_muzzle", effectdata )
vehicle:GetPhysicsObject():ApplyForceOffset( -shootDirection * 300000, shootOrigin )
local projectile = {}
projectile.filter = vehicle.VehicleData["filter"]
projectile.shootOrigin = shootOrigin
projectile.shootDirection = shootDirection
projectile.attacker = ply
projectile.attackingent = vehicle
projectile.Damage = 1500
projectile.Force = 6000
projectile.Size = 10
projectile.DeflectAng = 40
projectile.BlastRadius = 150
projectile.BlastDamage = 500
projectile.BlastEffect = "simfphys_tankweapon_explosion_small"
simfphys.FirePhysProjectile( projectile )
end
function simfphys.weapon:ValidClasses()
local classes = {
"sim_fphys_tank2"
}
return classes
end
function simfphys.weapon:Initialize( vehicle )
vehicle:SetNWBool( "SpecialCam_Loader", true )
vehicle:SetNWFloat( "SpecialCam_LoaderTime", 3.5 )
simfphys.RegisterCrosshair( vehicle:GetDriverSeat(), { Direction = Vector(0,0,1),Attachment = "turret_cannon", Type = 2 } )
simfphys.RegisterCamera( vehicle:GetDriverSeat(), Vector(-30,0,0), Vector(20,60,65), true,"turret_machinegun" )
if not istable( vehicle.PassengerSeats ) or not istable( vehicle.pSeat ) then return end
simfphys.RegisterCrosshair( vehicle.pSeat[1] , { Attachment = "machinegun", Type = 1 } )
simfphys.RegisterCamera( vehicle.pSeat[1], Vector(0,-40,5), Vector(0,-40,50), true )
simfphys.RegisterCamera( vehicle.pSeat[2], Vector(0,0,25), Vector(0,0,25), false )
simfphys.RegisterCamera( vehicle.pSeat[3], Vector(0,0,55), Vector(0,0,55), true )
timer.Simple( 1, function()
if not IsValid( vehicle ) then return end
if not vehicle.VehicleData["filter"] then print("[simfphys Armed Vehicle Pack] ERROR:TRACE FILTER IS INVALID. PLEASE UPDATE SIMFPHYS BASE") return end
vehicle.WheelOnGround = function( ent )
ent.FrontWheelPowered = ent:GetPowerDistribution() ~= 1
ent.RearWheelPowered = ent:GetPowerDistribution() ~= -1
for i = 1, table.Count( ent.Wheels ) do
local Wheel = ent.Wheels[i]
if IsValid( Wheel ) then
local dmgMul = Wheel:GetDamaged() and 0.5 or 1
local surfacemul = simfphys.TractionData[Wheel:GetSurfaceMaterial():lower()]
ent.VehicleData[ "SurfaceMul_" .. i ] = (surfacemul and math.max(surfacemul,0.001) or 1) * dmgMul
local WheelPos = ent:LogicWheelPos( i )
local WheelRadius = WheelPos.IsFrontWheel and ent.FrontWheelRadius or ent.RearWheelRadius
local startpos = Wheel:GetPos()
local dir = -ent.Up
local len = WheelRadius + math.Clamp(-ent.Vel.z / 50,2.5,6)
local HullSize = Vector(WheelRadius,WheelRadius,0)
local tr = util.TraceHull( {
start = startpos,
endpos = startpos + dir * len,
maxs = HullSize,
mins = -HullSize,
filter = ent.VehicleData["filter"]
} )
local onground = self:IsOnGround( vehicle ) and 1 or 0
Wheel:SetOnGround( onground )
ent.VehicleData[ "onGround_" .. i ] = onground
if tr.Hit then
Wheel:SetSpeed( Wheel.FX )
Wheel:SetSkidSound( Wheel.skid )
Wheel:SetSurfaceMaterial( util.GetSurfacePropName( tr.SurfaceProps ) )
end
end
end
local FrontOnGround = math.max(ent.VehicleData[ "onGround_1" ],ent.VehicleData[ "onGround_2" ])
local RearOnGround = math.max(ent.VehicleData[ "onGround_3" ],ent.VehicleData[ "onGround_4" ])
ent.DriveWheelsOnGround = math.max(ent.FrontWheelPowered and FrontOnGround or 0,ent.RearWheelPowered and RearOnGround or 0)
end
end)
end
function simfphys.weapon:ControlPassengerSeats( vehicle )
if not vehicle.pSeat then return end
vehicle.sm_pp_yaw = vehicle.sm_pp_yaw and vehicle.sm_pp_yaw or 0
vehicle.sm_pp_pitch = vehicle.sm_pp_pitch and vehicle.sm_pp_pitch or 0
local Commander = vehicle.pSeat[2]
if IsValid( Commander ) then
local ply = Commander:GetDriver()
local Toggle = false
if IsValid( ply ) then
Toggle = ply:KeyDown( IN_JUMP )
end
if Toggle ~= vehicle.OldToggleC then
vehicle.OldToggleC = Toggle
if Toggle then
vehicle.tg_c_z = not vehicle.tg_c_z
if vehicle.tg_c_z then
vehicle:EmitSound( "vehicles/atv_ammo_open.wav" )
simfphys.RegisterCamera( Commander, Vector(0,0,0), Vector(0,0,0), false )
else
vehicle:EmitSound( "vehicles/atv_ammo_close.wav" )
simfphys.RegisterCamera( Commander, Vector(0,0,25), Vector(0,0,25), false )
end
end
end
local X = math.sin( math.rad( -vehicle.sm_pp_yaw - 130 ) ) * 16
local Y = math.cos( math.rad( -vehicle.sm_pp_yaw - 130 ) ) * 16
Commander:SetLocalPos( Vector(X + 2.8,Y,65 + (vehicle.tg_c_z and 25 or 0)) )
Commander:SetLocalAngles( Angle(0,vehicle.sm_pp_yaw - 90,0) )
end
end
function simfphys.weapon:Think( vehicle )
if not IsValid( vehicle ) or not vehicle:IsInitialized() then return end
vehicle.wOldPos = vehicle.wOldPos or Vector(0,0,0)
local deltapos = vehicle:GetPos() - vehicle.wOldPos
vehicle.wOldPos = vehicle:GetPos()
local handbrake = vehicle:GetHandBrakeEnabled()
self:UpdateSuspension( vehicle )
self:DoWheelSpin( vehicle )
self:ControlTurret( vehicle, deltapos )
self:ControlMachinegun( vehicle, deltapos )
self:ControlTrackSounds( vehicle, handbrake )
self:ControlPassengerSeats( vehicle )
self:ModPhysics( vehicle, handbrake )
end
function simfphys.weapon:AimMachinegun( ply, vehicle, pod )
if not IsValid( pod ) then return end
local Aimang = pod:WorldToLocalAngles( ply:EyeAngles() )
local Angles = vehicle:WorldToLocalAngles( Aimang )
Angles:Normalize()
local TargetPitch = Angles.p
local TargetYaw = Angles.y
vehicle:SetPoseParameter("machinegun_yaw", TargetYaw )
vehicle:SetPoseParameter("machinegun_pitch", TargetPitch )
end
function simfphys.weapon:ControlMachinegun( vehicle, deltapos )
if not istable( vehicle.PassengerSeats ) or not istable( vehicle.pSeat ) then return end
local pod = vehicle.pSeat[1]
if not IsValid( pod ) then return end
local ply = pod:GetDriver()
if not IsValid( ply ) then return end
self:AimMachinegun( ply, vehicle, pod )
local ID = vehicle:LookupAttachment( "machinegun" )
local Attachment = vehicle:GetAttachment( ID )
local shootOrigin = Attachment.Pos + deltapos * engine.TickInterval()
local fire = ply:KeyDown( IN_ATTACK )
local Rate = FrameTime() / 8
vehicle.smTmpMG = vehicle.smTmpMG and vehicle.smTmpMG + math.Clamp((fire and 1 or 0) - vehicle.smTmpMG,-Rate * 4,Rate) or 0
if fire then
self:Attack( vehicle, ply, shootOrigin, Attachment, ID )
end
end
function simfphys.weapon:ControlTurret( vehicle, deltapos )
local pod = vehicle:GetDriverSeat()
if not IsValid( pod ) then return end
local ply = pod:GetDriver()
if not IsValid( ply ) then return end
local safemode = ply:KeyDown( IN_WALK )
if vehicle.ButtonSafeMode ~= safemode then
vehicle.ButtonSafeMode = safemode
if safemode then
vehicle:SetNWBool( "TurretSafeMode", not vehicle:GetNWBool( "TurretSafeMode", true ) )
end
end
if vehicle:GetNWBool( "TurretSafeMode", true ) then return end
local ID = vehicle:LookupAttachment( "turret_cannon" )
local Attachment = vehicle:GetAttachment( ID )
self:AimCannon( ply, vehicle, pod, Attachment )
local shootOrigin = Attachment.Pos + deltapos * engine.TickInterval()
local fire = ply:KeyDown( IN_ATTACK )
local fire2 = ply:KeyDown( IN_ATTACK2 )
local Rate = FrameTime() / 8
vehicle.smTmpHMG = vehicle.smTmpHMG and vehicle.smTmpHMG + math.Clamp((fire2 and 1 or 0) - vehicle.smTmpHMG,-Rate * 4,Rate) or 0
if fire then
self:PrimaryAttack( vehicle, ply, shootOrigin, Attachment )
end
if fire2 then
self:SecondaryAttack( vehicle, ply, shootOrigin )
end
end
function simfphys.weapon:PrimaryAttack( vehicle, ply, shootOrigin, Attachment )
if not self:CanPrimaryAttack( vehicle ) then return end
local shootDirection = Attachment.Ang:Up()
cannon_fire( ply, vehicle, shootOrigin + shootDirection * 80, shootDirection )
self:SetNextPrimaryFire( vehicle, CurTime() + 3.5 )
end
function simfphys.weapon:Attack( vehicle, ply, shootOrigin, Attachment, ID )
if not self:CanAttack( vehicle ) then return end
local shootDirection = Attachment.Ang:Forward()
mg_fire( ply, vehicle, shootOrigin, shootDirection )
self:SetNextFire( vehicle, CurTime() + 0.07 + (vehicle.smTmpMG ^ 5) * 0.08 )
end
function simfphys.weapon:CanAttack( vehicle )
vehicle.NextShoot3 = vehicle.NextShoot3 or 0
return vehicle.NextShoot3 < CurTime()
end
function simfphys.weapon:SetNextFire( vehicle, time )
vehicle.NextShoot3 = time
end
function simfphys.weapon:AimCannon( ply, vehicle, pod, Attachment )
if not IsValid( pod ) then return end
local Aimang = pod:WorldToLocalAngles( ply:EyeAngles() )
local AimRate = 50
local Angles = vehicle:WorldToLocalAngles( Aimang )
vehicle.sm_pp_yaw = vehicle.sm_pp_yaw and math.ApproachAngle( vehicle.sm_pp_yaw, Angles.y, AimRate * FrameTime() ) or 0
vehicle.sm_pp_pitch = vehicle.sm_pp_pitch and math.ApproachAngle( vehicle.sm_pp_pitch, Angles.p, AimRate * FrameTime() ) or 0
local TargetAng = Angle(vehicle.sm_pp_pitch,vehicle.sm_pp_yaw,0)
TargetAng:Normalize()
vehicle:SetPoseParameter("turret_yaw", TargetAng.y )
vehicle:SetPoseParameter("turret_pitch", TargetAng.p )
end
function simfphys.weapon:CanPrimaryAttack( vehicle )
vehicle.NextShoot = vehicle.NextShoot or 0
return vehicle.NextShoot < CurTime()
end
function simfphys.weapon:SetNextPrimaryFire( vehicle, time )
vehicle.NextShoot = time
vehicle:SetNWFloat( "SpecialCam_LoaderNext", time )
end
function simfphys.weapon:SecondaryAttack( vehicle, ply, shootOrigin )
if not self:CanSecondaryAttack( vehicle ) then return end
local ID = vehicle:LookupAttachment( "turret_machinegun" )
local Attachment = vehicle:GetAttachment( ID )
hmg_fire( ply, vehicle, Attachment.Pos, (Attachment.Ang - Angle(0,0.5,0)):Up() )
self:SetNextSecondaryFire( vehicle, CurTime() + 0.07 + (vehicle.smTmpHMG ^ 5) * 0.08 )
end
function simfphys.weapon:CanSecondaryAttack( vehicle )
vehicle.NextShoot2 = vehicle.NextShoot2 or 0
return vehicle.NextShoot2 < CurTime()
end
function simfphys.weapon:SetNextSecondaryFire( vehicle, time )
vehicle.NextShoot2 = time
end
function simfphys.weapon:ControlTrackSounds( vehicle, wheelslocked )
local speed = math.abs( self:GetForwardSpeed( vehicle ) )
local fastenuf = speed > 20 and not wheelslocked and self:IsOnGround( vehicle )
if fastenuf ~= vehicle.fastenuf then
vehicle.fastenuf = fastenuf
if fastenuf then
vehicle.track_snd = CreateSound( vehicle, "simulated_vehicles/sherman/tracks.wav" )
vehicle.track_snd:PlayEx(0,0)
vehicle:CallOnRemove( "stopmesounds", function( vehicle )
if vehicle.track_snd then
vehicle.track_snd:Stop()
end
end)
else
if vehicle.track_snd then
vehicle.track_snd:Stop()
vehicle.track_snd = nil
end
end
end
if vehicle.track_snd then
vehicle.track_snd:ChangePitch( math.Clamp(60 + speed / 70,0,150) )
vehicle.track_snd:ChangeVolume( math.min( math.max(speed - 20,0) / 600,1) )
end
end
function simfphys.weapon:GetForwardSpeed( vehicle )
return vehicle.ForwardSpeed
end
function simfphys.weapon:IsOnGround( vehicle )
return (vehicle.susOnGround == true)
end
function simfphys.weapon:ModPhysics( vehicle, wheelslocked )
if wheelslocked and self:IsOnGround( vehicle ) then
local phys = vehicle:GetPhysicsObject()
phys:ApplyForceCenter( -vehicle:GetVelocity() * phys:GetMass() * 0.04 )
end
end
function simfphys.weapon:UpdateSuspension( vehicle )
if not vehicle.filterEntities then
vehicle.filterEntities = player.GetAll()
table.insert(vehicle.filterEntities, vehicle)
for i, wheel in pairs( ents.FindByClass( "gmod_sent_vehicle_fphysics_wheel" ) ) do
table.insert(vehicle.filterEntities, wheel)
end
end
vehicle.oldDist = istable( vehicle.oldDist ) and vehicle.oldDist or {}
vehicle.susOnGround = false
for i, v in pairs( sherman_susdata ) do
local pos = vehicle:GetAttachment( vehicle:LookupAttachment( sherman_susdata[i].attachment ) ).Pos
local trace = util.TraceHull( {
start = pos,
endpos = pos + vehicle:GetUp() * - 100,
maxs = Vector(15,15,0),
mins = -Vector(15,15,0),
filter = vehicle.filterEntities,
} )
local Dist = (pos - trace.HitPos):Length() - 30
if trace.Hit then
vehicle.susOnGround = true
end
vehicle.oldDist[i] = vehicle.oldDist[i] and (vehicle.oldDist[i] + math.Clamp(Dist - vehicle.oldDist[i],-5,1)) or 0
vehicle:SetPoseParameter(sherman_susdata[i].poseparameter, 12 - vehicle.oldDist[i] )
end
end
function simfphys.weapon:DoWheelSpin( vehicle )
local spin_r = (vehicle.VehicleData[ "spin_4" ] + vehicle.VehicleData[ "spin_6" ]) * 1.2
local spin_l = (vehicle.VehicleData[ "spin_3" ] + vehicle.VehicleData[ "spin_5" ]) * 1.2
vehicle:SetPoseParameter("spin_wheels_right", spin_r)
vehicle:SetPoseParameter("spin_wheels_left", spin_l )
net.Start( "simfphys_update_tracks", true )
net.WriteEntity( vehicle )
net.WriteFloat( spin_r )
net.WriteFloat( spin_l )
net.Broadcast()
end

View File

@ -0,0 +1,470 @@
local tiger_susdata = {}
for i = 1,8 do
tiger_susdata[i] = {
attachment = "vehicle_suspension_l_"..i,
poseparameter = "suspension_left_"..i,
}
local ir = i + 8
tiger_susdata[ir] = {
attachment = "vehicle_suspension_r_"..i,
poseparameter = "suspension_right_"..i,
}
end
local function mg_fire(ply,vehicle,shootOrigin,shootDirection)
vehicle:EmitSound("tiger_fire_mg_new")
local projectile = {}
projectile.filter = vehicle.VehicleData["filter"]
projectile.shootOrigin = shootOrigin
projectile.shootDirection = shootDirection
projectile.attacker = ply
projectile.Tracer = 1
projectile.Spread = Vector(0.015,0.015,0.015)
projectile.HullSize = 5
projectile.attackingent = vehicle
projectile.Damage = 20
projectile.Force = 12
simfphys.FireHitScan( projectile )
end
local function cannon_fire(ply,vehicle,shootOrigin,shootDirection)
vehicle:EmitSound("tiger_fire")
vehicle:EmitSound("tiger_reload")
local effectdata = EffectData()
effectdata:SetEntity( vehicle )
util.Effect( "simfphys_tiger_muzzle", effectdata )
vehicle:GetPhysicsObject():ApplyForceOffset( -shootDirection * 400000, shootOrigin )
local projectile = {}
projectile.filter = vehicle.VehicleData["filter"]
projectile.shootOrigin = shootOrigin
projectile.shootDirection = shootDirection
projectile.attacker = ply
projectile.attackingent = vehicle
projectile.Damage = 3000
projectile.Force = 6000
projectile.Size = 20
projectile.DeflectAng = 20
projectile.BlastRadius = 300
projectile.BlastDamage = 500
projectile.BlastEffect = "simfphys_tankweapon_explosion"
simfphys.FirePhysProjectile( projectile )
end
function simfphys.weapon:ValidClasses()
local classes = {
"sim_fphys_tank"
}
return classes
end
function simfphys.weapon:Initialize( vehicle )
vehicle:SetNWBool( "SpecialCam_Loader", true )
vehicle:SetNWFloat( "SpecialCam_LoaderTime", 5 )
simfphys.RegisterCrosshair( vehicle:GetDriverSeat(), { Direction = Vector(0,0,1), Type = 2 } )
simfphys.RegisterCamera( vehicle:GetDriverSeat(), Vector(20,0,-130), Vector(0,60,75), true, "muzzle" )
if not istable( vehicle.PassengerSeats ) or not istable( vehicle.pSeat ) then return end
simfphys.RegisterCrosshair( vehicle.pSeat[1] , { Attachment = "muzzle_machinegun", Type = 1 } )
simfphys.RegisterCamera( vehicle.pSeat[1], Vector(35,-105,-15), Vector(35,-105,25), true )
simfphys.RegisterCamera( vehicle.pSeat[2], Vector(0,0,25), Vector(0,0,25), false )
simfphys.RegisterCamera( vehicle.pSeat[3], Vector(0,0,25), Vector(0,0,25), false )
timer.Simple( 1, function()
if not IsValid( vehicle ) then return end
if not vehicle.VehicleData["filter"] then print("[simfphys Armed Vehicle Pack] ERROR:TRACE FILTER IS INVALID. PLEASE UPDATE SIMFPHYS BASE") return end
vehicle.WheelOnGround = function( ent )
ent.FrontWheelPowered = ent:GetPowerDistribution() ~= 1
ent.RearWheelPowered = ent:GetPowerDistribution() ~= -1
for i = 1, table.Count( ent.Wheels ) do
local Wheel = ent.Wheels[i]
if IsValid( Wheel ) then
local dmgMul = Wheel:GetDamaged() and 0.5 or 1
local surfacemul = simfphys.TractionData[Wheel:GetSurfaceMaterial():lower()]
ent.VehicleData[ "SurfaceMul_" .. i ] = (surfacemul and math.max(surfacemul,0.001) or 1) * dmgMul
local WheelPos = ent:LogicWheelPos( i )
local WheelRadius = WheelPos.IsFrontWheel and ent.FrontWheelRadius or ent.RearWheelRadius
local startpos = Wheel:GetPos()
local dir = -ent.Up
local len = WheelRadius + math.Clamp(-ent.Vel.z / 50,2.5,6)
local HullSize = Vector(WheelRadius,WheelRadius,0)
local tr = util.TraceHull( {
start = startpos,
endpos = startpos + dir * len,
maxs = HullSize,
mins = -HullSize,
filter = ent.VehicleData["filter"]
} )
local onground = self:IsOnGround( vehicle ) and 1 or 0
Wheel:SetOnGround( onground )
ent.VehicleData[ "onGround_" .. i ] = onground
if tr.Hit then
Wheel:SetSpeed( Wheel.FX )
Wheel:SetSkidSound( Wheel.skid )
Wheel:SetSurfaceMaterial( util.GetSurfacePropName( tr.SurfaceProps ) )
end
end
end
local FrontOnGround = math.max(ent.VehicleData[ "onGround_1" ],ent.VehicleData[ "onGround_2" ])
local RearOnGround = math.max(ent.VehicleData[ "onGround_3" ],ent.VehicleData[ "onGround_4" ])
ent.DriveWheelsOnGround = math.max(ent.FrontWheelPowered and FrontOnGround or 0,ent.RearWheelPowered and RearOnGround or 0)
end
end)
end
function simfphys.weapon:ControlTurret( vehicle, deltapos )
local pod = vehicle:GetDriverSeat()
if not IsValid( pod ) then return end
local ply = pod:GetDriver()
if not IsValid( ply ) then return end
local safemode = ply:KeyDown( IN_WALK )
if vehicle.ButtonSafeMode ~= safemode then
vehicle.ButtonSafeMode = safemode
if safemode then
vehicle:SetNWBool( "TurretSafeMode", not vehicle:GetNWBool( "TurretSafeMode", true ) )
end
end
if vehicle:GetNWBool( "TurretSafeMode", true ) then return end
local ID = vehicle:LookupAttachment( "muzzle" )
local Attachment = vehicle:GetAttachment( ID )
self:AimCannon( ply, vehicle, pod, Attachment )
local shootOrigin = Attachment.Pos + deltapos * engine.TickInterval()
local fire = ply:KeyDown( IN_ATTACK )
local fire2 = ply:KeyDown( IN_ATTACK2 )
if fire then
self:PrimaryAttack( vehicle, ply, shootOrigin, Attachment )
end
local Rate = FrameTime() / 8
vehicle.smTmpHMG = vehicle.smTmpHMG and vehicle.smTmpHMG + math.Clamp((fire2 and 1 or 0) - vehicle.smTmpHMG,-Rate * 4,Rate) or 0
if fire2 then
self:SecondaryAttack( vehicle, ply, shootOrigin - Attachment.Ang:Up() * 155 - Attachment.Ang:Forward() * 20, Attachment.Ang )
end
end
function simfphys.weapon:ControlMachinegun( vehicle, deltapos )
if not istable( vehicle.PassengerSeats ) or not istable( vehicle.pSeat ) then return end
local pod = vehicle.pSeat[1]
if not IsValid( pod ) then return end
local ply = pod:GetDriver()
if not IsValid( ply ) then return end
self:AimMachinegun( ply, vehicle, pod )
local ID = vehicle:LookupAttachment( "muzzle_machinegun" )
local Attachment = vehicle:GetAttachment( ID )
local shootOrigin = Attachment.Pos + deltapos * engine.TickInterval()
local fire = ply:KeyDown( IN_ATTACK )
local Rate = FrameTime() / 8
vehicle.smTmpMG = vehicle.smTmpMG and vehicle.smTmpMG + math.Clamp((fire and 1 or 0) - vehicle.smTmpMG,-Rate * 4,Rate) or 0
if fire then
self:TertiaryAttack( vehicle, ply, shootOrigin, Attachment, ID )
end
end
function simfphys.weapon:GetForwardSpeed( vehicle )
return vehicle.ForwardSpeed
end
function simfphys.weapon:IsOnGround( vehicle )
return (vehicle.susOnGround == true)
end
function simfphys.weapon:ModPhysics( vehicle, wheelslocked )
if wheelslocked and self:IsOnGround( vehicle ) then
local phys = vehicle:GetPhysicsObject()
phys:ApplyForceCenter( -vehicle:GetVelocity() * phys:GetMass() * 0.04 )
end
end
function simfphys.weapon:ControlTrackSounds( vehicle, wheelslocked )
local speed = math.abs( self:GetForwardSpeed( vehicle ) )
local fastenuf = speed > 20 and not wheelslocked and self:IsOnGround( vehicle )
if fastenuf ~= vehicle.fastenuf then
vehicle.fastenuf = fastenuf
if fastenuf then
vehicle.track_snd = CreateSound( vehicle, "simulated_vehicles/tiger/tiger_tracks.wav" )
vehicle.track_snd:PlayEx(0,0)
vehicle:CallOnRemove( "stopmesounds", function( vehicle )
if vehicle.track_snd then
vehicle.track_snd:Stop()
end
end)
else
if vehicle.track_snd then
vehicle.track_snd:Stop()
vehicle.track_snd = nil
end
end
end
if vehicle.track_snd then
vehicle.track_snd:ChangePitch( math.Clamp(60 + speed / 80,0,150) )
vehicle.track_snd:ChangeVolume( math.min( math.max(speed - 20,0) / 600,1) )
end
end
function simfphys.weapon:ControlPassengerSeats( vehicle )
if not vehicle.pSeat then return end
vehicle.sm_pp_yaw = vehicle.sm_pp_yaw and vehicle.sm_pp_yaw or 0
vehicle.sm_pp_pitch = vehicle.sm_pp_pitch and vehicle.sm_pp_pitch or 0
local Commander = vehicle.pSeat[2]
if IsValid( Commander ) then
local ply = Commander:GetDriver()
local Toggle = false
if IsValid( ply ) then
Toggle = ply:KeyDown( IN_JUMP )
end
if Toggle ~= vehicle.OldToggleC then
vehicle.OldToggleC = Toggle
if Toggle then
vehicle.tg_c_z = not vehicle.tg_c_z
if vehicle.tg_c_z then
vehicle:EmitSound( "vehicles/atv_ammo_open.wav" )
simfphys.RegisterCamera( Commander, Vector(0,0,0), Vector(0,0,0), false )
else
vehicle:EmitSound( "vehicles/atv_ammo_close.wav" )
simfphys.RegisterCamera( Commander, Vector(0,0,25), Vector(0,0,25), false )
end
end
end
local X = math.sin( math.rad( -vehicle.sm_pp_yaw - 50 ) ) * 30
local Y = math.cos( math.rad( -vehicle.sm_pp_yaw - 50 ) ) * 30
Commander:SetLocalPos( Vector(X,Y,65 + (vehicle.tg_c_z and 25 or 0)) )
Commander:SetLocalAngles( Angle(0,vehicle.sm_pp_yaw - 90,0) )
end
local Loader = vehicle.pSeat[3]
if IsValid( Loader ) then
local ply = Loader:GetDriver()
local Toggle = false
if IsValid( ply ) then
Toggle = ply:KeyDown( IN_JUMP )
end
if Toggle ~= vehicle.OldToggleL then
vehicle.OldToggleL = Toggle
if Toggle then
vehicle.tg_l_z = not vehicle.tg_l_z
if vehicle.tg_l_z then
vehicle:EmitSound( "vehicles/atv_ammo_open.wav" )
simfphys.RegisterCamera( Loader, Vector(0,0,0), Vector(0,0,0), false )
else
vehicle:EmitSound( "vehicles/atv_ammo_close.wav" )
simfphys.RegisterCamera( Loader, Vector(0,0,25), Vector(0,0,25), false )
end
end
end
local X = math.sin( math.rad( -vehicle.sm_pp_yaw - 170 ) ) * 28
local Y = math.cos( math.rad( -vehicle.sm_pp_yaw - 170 ) ) * 28
Loader:SetLocalPos( Vector(X,Y,60 + (vehicle.tg_l_z and 25 or 0)) )
Loader:SetLocalAngles( Angle(0,vehicle.sm_pp_yaw - 90,0) )
end
end
function simfphys.weapon:Think( vehicle )
if not IsValid( vehicle ) or not vehicle:IsInitialized() then return end
vehicle.wOldPos = vehicle.wOldPos or Vector(0,0,0)
local deltapos = vehicle:GetPos() - vehicle.wOldPos
vehicle.wOldPos = vehicle:GetPos()
local handbrake = vehicle:GetHandBrakeEnabled()
self:UpdateSuspension( vehicle )
self:DoWheelSpin( vehicle )
self:ControlTurret( vehicle, deltapos )
self:ControlMachinegun( vehicle, deltapos )
self:ControlTrackSounds( vehicle, handbrake )
self:ControlPassengerSeats( vehicle )
self:ModPhysics( vehicle, handbrake )
end
function simfphys.weapon:PrimaryAttack( vehicle, ply, shootOrigin, Attachment )
if not self:CanPrimaryAttack( vehicle ) then return end
cannon_fire( ply, vehicle, shootOrigin, Attachment.Ang:Up() )
self:SetNextPrimaryFire( vehicle, CurTime() + 5 )
end
function simfphys.weapon:SecondaryAttack( vehicle, ply, shootOrigin, shootDir )
if not self:CanSecondaryAttack( vehicle ) then return end
mg_fire( ply, vehicle, shootOrigin, (shootDir + Angle(0,0.5,0)):Up() )
self:SetNextSecondaryFire( vehicle, CurTime() + 0.07 + (vehicle.smTmpHMG ^ 5) * 0.08 )
end
function simfphys.weapon:TertiaryAttack( vehicle, ply, shootOrigin, Attachment, ID )
if not self:CanTertiaryAttack( vehicle ) then return end
mg_fire( ply, vehicle, shootOrigin, Attachment.Ang:Forward() )
self:SetNextTertiaryFire( vehicle, CurTime() + 0.07 + (vehicle.smTmpMG ^ 5) * 0.08 )
end
function simfphys.weapon:AimMachinegun( ply, vehicle, pod )
if not IsValid( pod ) then return end
local Aimang = pod:WorldToLocalAngles( ply:EyeAngles() )
local Angles = vehicle:WorldToLocalAngles( Aimang )
Angles:Normalize()
local TargetPitch = Angles.p
local TargetYaw = Angles.y
vehicle:SetPoseParameter("machinegun_yaw", -TargetYaw )
vehicle:SetPoseParameter("machinegun_pitch", TargetPitch )
end
function simfphys.weapon:AimCannon( ply, vehicle, pod, Attachment )
if not IsValid( pod ) then return end
local Aimang = pod:WorldToLocalAngles( ply:EyeAngles() )
local AimRate = 35
local Angles = vehicle:WorldToLocalAngles( Aimang )
vehicle.sm_pp_yaw = vehicle.sm_pp_yaw and math.ApproachAngle( vehicle.sm_pp_yaw, Angles.y, AimRate * FrameTime() ) or 0
vehicle.sm_pp_pitch = vehicle.sm_pp_pitch and math.ApproachAngle( vehicle.sm_pp_pitch, Angles.p, AimRate * FrameTime() ) or 0
local TargetAng = Angle(vehicle.sm_pp_pitch,vehicle.sm_pp_yaw,0)
TargetAng:Normalize()
vehicle:SetPoseParameter("turret_yaw", TargetAng.y )
vehicle:SetPoseParameter("turret_pitch", TargetAng.p )
end
function simfphys.weapon:CanPrimaryAttack( vehicle )
vehicle.NextShoot = vehicle.NextShoot or 0
return vehicle.NextShoot < CurTime()
end
function simfphys.weapon:CanSecondaryAttack( vehicle )
vehicle.NextShoot2 = vehicle.NextShoot2 or 0
return vehicle.NextShoot2 < CurTime()
end
function simfphys.weapon:CanTertiaryAttack( vehicle )
vehicle.NextShoot3 = vehicle.NextShoot3 or 0
return vehicle.NextShoot3 < CurTime()
end
function simfphys.weapon:SetNextPrimaryFire( vehicle, time )
vehicle.NextShoot = time
vehicle:SetNWFloat( "SpecialCam_LoaderNext", time )
end
function simfphys.weapon:SetNextSecondaryFire( vehicle, time )
vehicle.NextShoot2 = time
end
function simfphys.weapon:SetNextTertiaryFire( vehicle, time )
vehicle.NextShoot3 = time
end
function simfphys.weapon:UpdateSuspension( vehicle )
if not vehicle.filterEntities then
vehicle.filterEntities = player.GetAll()
table.insert(vehicle.filterEntities, vehicle)
for i, wheel in pairs( ents.FindByClass( "gmod_sent_vehicle_fphysics_wheel" ) ) do
table.insert(vehicle.filterEntities, wheel)
end
end
vehicle.oldDist = istable( vehicle.oldDist ) and vehicle.oldDist or {}
vehicle.susOnGround = false
for i, v in pairs( tiger_susdata ) do
local pos = vehicle:GetAttachment( vehicle:LookupAttachment( tiger_susdata[i].attachment ) ).Pos
local trace = util.TraceHull( {
start = pos,
endpos = pos + vehicle:GetUp() * - 100,
maxs = Vector(15,15,0),
mins = -Vector(15,15,0),
filter = vehicle.filterEntities,
} )
local Dist = (pos - trace.HitPos):Length() - 41
if trace.Hit then
vehicle.susOnGround = true
end
vehicle.oldDist[i] = vehicle.oldDist[i] and (vehicle.oldDist[i] + math.Clamp(Dist - vehicle.oldDist[i],-5,1)) or 0
vehicle:SetPoseParameter(tiger_susdata[i].poseparameter, vehicle.oldDist[i] )
end
end
function simfphys.weapon:DoWheelSpin( vehicle )
local spin_r = vehicle.VehicleData[ "spin_4" ] + vehicle.VehicleData[ "spin_6" ]
local spin_l = vehicle.VehicleData[ "spin_3" ] + vehicle.VehicleData[ "spin_5" ]
vehicle:SetPoseParameter("spin_wheels_right", spin_r)
vehicle:SetPoseParameter("spin_wheels_left", spin_l )
net.Start( "simfphys_update_tracks", true )
net.WriteEntity( vehicle )
net.WriteFloat( spin_r )
net.WriteFloat( spin_l )
net.Broadcast()
end

View File

@ -56,24 +56,8 @@ function simfphys.weapon:AimWeapon( ply, vehicle, pod )
local Aimang = ply:EyeAngles()
local AimRate = 250
local Angles = angle_zero
if ply:lvsMouseAim() then
local ang = vehicle:GetAngles()
ang.y = pod:GetAngles().y + 90
local Forward = ang:Right()
local View = pod:WorldToLocalAngles( Aimang )
local Pitch = (vehicle:AngleBetweenNormal( View:Up(), ang:Forward() ) - 90)
local Yaw = (vehicle:AngleBetweenNormal( View:Forward(), ang:Right() ) - 90)
Angles = Angle(-Pitch,Yaw,0)
else
Angles = vehicle:WorldToLocalAngles( Aimang ) - Angle(0,90,0)
Angles:Normalize()
end
local Angles = vehicle:WorldToLocalAngles( Aimang ) - Angle(0,90,0)
vehicle.sm_pp_yaw = vehicle.sm_pp_yaw and math.ApproachAngle( vehicle.sm_pp_yaw, Angles.y, AimRate * FrameTime() ) or 0
vehicle.sm_pp_pitch = vehicle.sm_pp_pitch and math.ApproachAngle( vehicle.sm_pp_pitch, Angles.p, AimRate * FrameTime() ) or 0

View File

@ -0,0 +1,133 @@
-- this script is called SEVERSIDE ONLY.
function simfphys.weapon:ValidClasses()
local classes = {
--"sim_fphys_jeep",
"sim_fphys_testvehicle", -- all classes listed in this table will be using this weapon
"my_vehicle", -- you can add as many vehicles you want
}
return classes
end
function simfphys.weapon:Initialize( vehicle ) -- "vehicle" is the "gmod_sent_vehicle_fphysics_base" entity.
-- this function is called once the weapon is initialized
end
function simfphys.weapon:Think( vehicle )
-- this function is called on tick
local ply = vehicle:GetDriver()
if not IsValid( ply ) then return end
local fire = ply:KeyDown( IN_ATTACK )
local fire2 = ply:KeyDown( IN_ATTACK2 )
if fire then
self:PrimaryAttack( vehicle, ply )
end
if fire2 then
self:SecondaryAttack( vehicle, ply )
end
end
function simfphys.weapon:PrimaryAttack( vehicle, ply )
if not self:CanPrimaryAttack( vehicle ) then return end
--primary attack code here
print("primary fire")
vehicle:EmitSound("Weapon_SMG1.NPC_Single")
self:SetNextPrimaryFire( vehicle, CurTime() + 0.1 )
end
function simfphys.weapon:SecondaryAttack( vehicle, ply )
if not self:CanSecondaryAttack( vehicle ) then return end
--secondary attack code here
print("secondary fire")
vehicle:EmitSound("Weapon_Mortar.Single")
self:SetNextSecondaryFire( vehicle, CurTime() + 0.3 )
end
function simfphys.weapon:CanPrimaryAttack( vehicle )
vehicle.NextShoot = vehicle.NextShoot or 0
return vehicle.NextShoot < CurTime()
end
function simfphys.weapon:SetNextPrimaryFire( vehicle, time )
vehicle.NextShoot = time
end
function simfphys.weapon:CanSecondaryAttack( vehicle )
vehicle.NextShoot2 = vehicle.NextShoot2 or 0
return vehicle.NextShoot2 < CurTime()
end
function simfphys.weapon:SetNextSecondaryFire( vehicle, time )
vehicle.NextShoot2 = time
end
--[[
-----------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------
some handy variables and functions:
vehicle:IsInitialized() -- checks if the vehicle is fully spawned
------------------------------------------
-- driver / driverseat
local pod = vehicle:GetDriverSeat() -- gets the driver seat
local ply = pod:GetDriver() -- gets the driver
------------------------------------------
------------------------------------------
-- passenger / passengerseat
local pod = vehicle.pSeat[1] -- gets the first passenger seat
local ply = pod:GetDriver() -- gets the driver of the passenger seat
-- but make sure the vehicle you call it on actually has passenger seats or it will throw an error. Add an safety check that prevents this:
if not istable( vehicle.pSeat ) then return end -- will bail out of the script incase there are no passenger seats
local pod = vehicle.pSeat[1]
local ply = pod:GetDriver()
------------------------------------------
------------------------------------------
-- crosshair
simfphys.RegisterCrosshair( <pod_entity> , { Attachment = <string name attachment>, Direction = <vector direction> } ) -- registers an crosshair to the pod_entity.
alternative (if you have two barrels and need the center of them):
local data = {}
data.Attachment = "minigun_barell_left" -- used for the direction
data.Direction = Vector(1,0,0)
data.Attach_Start_Left = "minigun_barell_right" -- used as postion 1
data.Attach_Start_Right = "minigun_barell_left" -- used as postion 2
simfphys.RegisterCrosshair( vehicle:GetDriverSeat(), data )
------------------------------------------
------------------------------------------
-- camera
simfphys.RegisterCamera( <pod_entity>, <vector position firstperson>, <vector position thirdperson> )
------------------------------------------
there are more lua functions wich can be found on simfphys.com
]]

View File

@ -0,0 +1,113 @@
-- this script is called SEVERSIDE ONLY.
function simfphys.weapon:ValidClasses()
local classes = {
--"sim_fphys_dukes", -- uncomment this to add weapons to the dukes
}
return classes
end
function simfphys.weapon:Initialize( vehicle )
vehicle.ForceTransmission = 1 -- Force automatic transmission
end
function simfphys.weapon:Think( vehicle )
local ply = vehicle:GetDriver()
if not IsValid( ply ) then return end
local fire = ply:KeyDown( IN_ATTACK )
local fire2 = ply:KeyDown( IN_ATTACK2 )
local AimDirToForwardDir = math.deg( math.acos( math.Clamp( vehicle.Forward:Dot( ply:EyeAngles():Forward() ) ,-1,1) ) )
if AimDirToForwardDir > 30 then return end -- if we are aiming sideways or back (angle greater than 30° relative to forward direction of the car) dont allow weapons
if fire then
self:PrimaryAttack( vehicle, ply )
end
if fire2 then
self:SecondaryAttack( vehicle, ply )
end
end
function simfphys.weapon:FireBullet( ply, vehicle, shootDirection, shootOrigin )
local bullet = {}
bullet.Num = 1
bullet.Src = shootOrigin
bullet.Dir = shootDirection
bullet.Spread = Vector(0.06,0.06,0)
bullet.Tracer = 1
bullet.TracerName = "simfphys_tracer"
bullet.Force = 4
bullet.Damage = 25
bullet.HullSize = 10
bullet.Attacker = ply
vehicle:FireBullets( bullet )
vehicle:EmitSound("Weapon_SMG1.NPC_Single")
end
function simfphys.weapon:FireMortar( ply, vehicle, shootDirection, shootOrigin )
vehicle:EmitSound("Weapon_Mortar.Single")
local projectile = {}
projectile.filter = vehicle.VehicleData["filter"]
projectile.shootOrigin = shootOrigin
projectile.shootDirection = shootDirection
projectile.attacker = ply
projectile.attackingent = vehicle
projectile.Damage = 1000
projectile.Force = 6000
projectile.Size = 10
projectile.BlastRadius = 200
projectile.BlastDamage = 50
projectile.BlastEffect = "simfphys_tankweapon_explosion_small"
simfphys.FirePhysProjectile( projectile )
end
function simfphys.weapon:PrimaryAttack( vehicle, ply )
if not self:CanPrimaryAttack( vehicle ) then return end
local shootDirection = ply:EyeAngles():Forward()
self:FireBullet( ply, vehicle, shootDirection, vehicle:LocalToWorld( Vector(108.53,-25.34,-2.48) ) )
self:FireBullet( ply, vehicle, shootDirection, vehicle:LocalToWorld( Vector(108.53,25.34,-2.48) ) )
self:SetNextPrimaryFire( vehicle, CurTime() + 0.1 )
end
function simfphys.weapon:SecondaryAttack( vehicle, ply )
if not self:CanSecondaryAttack( vehicle ) then return end
local shootDirection = ply:EyeAngles():Forward()
self:FireMortar( ply, vehicle, shootDirection, vehicle:LocalToWorld( Vector(108.53,0,-2.48) ) )
self:SetNextSecondaryFire( vehicle, CurTime() + 1 )
end
function simfphys.weapon:CanPrimaryAttack( vehicle )
vehicle.NextShoot = vehicle.NextShoot or 0
return vehicle.NextShoot < CurTime()
end
function simfphys.weapon:SetNextPrimaryFire( vehicle, time )
vehicle.NextShoot = time
end
function simfphys.weapon:CanSecondaryAttack( vehicle )
vehicle.NextShoot2 = vehicle.NextShoot2 or 0
return vehicle.NextShoot2 < CurTime()
end
function simfphys.weapon:SetNextSecondaryFire( vehicle, time )
vehicle.NextShoot2 = time
end

View File

@ -0,0 +1,208 @@
AddCSLuaFile()
CreateConVar( "sv_simfphys_maxmines", "3", {FCVAR_REPLICATED , FCVAR_ARCHIVE},"max mines" )
SWEP.Category = "simfphys"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.ViewModel = "models/weapons/v_slam.mdl"
SWEP.WorldModel = "models/blu/mine.mdl"
SWEP.UseHands = false
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 10
SWEP.Weight = 42
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = true
SWEP.HoldType = "slam"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "slam"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
function SWEP:SetupDataTables()
end
if CLIENT then
SWEP.PrintName = "Mines"
SWEP.Slot = 4
SWEP.SlotPos = 11
SWEP.IconLetter = "k"
--SWEP.WepSelectIcon = surface.GetTextureID( "weapons/s_repair" )
SWEP.DrawWeaponInfoBox = false
SWEP.pViewModel = ClientsideModel("models/blu/mine.mdl", RENDERGROUP_OPAQUE)
SWEP.pViewModel:SetNoDraw( true )
function SWEP:ViewModelDrawn()
if IsValid( self.Owner ) then
local vm = self.Owner:GetViewModel()
local bm = vm:GetBoneMatrix(0)
local pos = bm:GetTranslation()
local ang = bm:GetAngles()
pos = pos + ang:Up() * 220
pos = pos + ang:Right() * 2
pos = pos + ang:Forward() * -12
ang:RotateAroundAxis(ang:Forward(), 45)
ang:RotateAroundAxis(ang:Right(),120)
ang:RotateAroundAxis(ang:Up(), 0)
self.pViewModel:SetPos(pos)
self.pViewModel:SetAngles(ang)
self.pViewModel:DrawModel()
end
end
function SWEP:DrawWorldModel()
if not IsValid( self.Owner ) then self:DrawModel() return end
local id = self.Owner:LookupAttachment("anim_attachment_rh")
local attachment = self.Owner:GetAttachment( id )
if not attachment then return end
local pos = attachment.Pos + attachment.Ang:Forward() * 2
local ang = attachment.Ang
ang:RotateAroundAxis(attachment.Ang:Up(), 20)
ang:RotateAroundAxis(attachment.Ang:Right(), -30)
ang:RotateAroundAxis(attachment.Ang:Forward(), 0)
self:SetRenderOrigin( pos )
self:SetRenderAngles( ang )
self:DrawModel()
end
function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
draw.SimpleText( "z", "WeaponIcons", x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end
end
function SWEP:Initialize()
self.Weapon:SetHoldType( self.HoldType )
end
function SWEP:OwnerChanged()
end
function SWEP:Think()
end
function SWEP:TakePrimaryAmmo( num )
if self.Weapon:Clip1() <= 0 then
if self:Ammo1() <= 0 then return end
self.Owner:RemoveAmmo( num, self.Weapon:GetPrimaryAmmoType() )
return
end
self.Weapon:SetClip1( math.max(self.Weapon:Clip1() - num,0) )
end
function SWEP:CanPrimaryAttack()
self.NextFire = self.NextFire or 0
return self.NextFire <= CurTime() and self:Ammo1() > 0
end
function SWEP:SetNextPrimaryFire( time )
self.NextFire = time
end
function SWEP:ThrowMine()
if CLIENT then return end
local ent = ents.Create( "simfphys_antitankmine" )
local ply = self.Owner
ply:EmitSound( "npc/zombie/claw_miss1.wav" )
local Num = 0
local TimeOldest = 99999999999999
local Oldest = NULL
for _,v in ipairs( ents.FindByClass("simfphys_antitankmine" ) ) do
if v.CreatedBy ~= ply then continue end
Num = Num + 1
if TimeOldest > v.CreateTime then
TimeOldest = v.CreateTime
Oldest = v
end
end
if Num >= GetConVar("sv_simfphys_maxmines"):GetInt() then
if IsValid( Oldest ) then
Oldest:Remove()
end
end
if IsValid( ent ) then
local EyeAng = ply:EyeAngles()
ent:SetPos( ply:GetShootPos() - Vector(0,0,10) )
ent:SetAngles( Angle(0,EyeAng.y,0) )
ent.Thrown = true
ent.CreateTime = CurTime()
ent.CreatedBy = ply
ent:Spawn()
ent:Activate()
ent:SetAttacker( ply )
if CPPI then
ent:CPPISetOwner( ply )
end
local PhysObj = ent:GetPhysicsObject()
if IsValid( PhysObj ) then
PhysObj:SetVelocityInstantaneous( EyeAng:Forward() * 200 + Vector(0,0,150) )
PhysObj:AddAngleVelocity( VectorRand() * 20 )
end
end
end
function SWEP:PrimaryAttack()
if not self:CanPrimaryAttack() then return end
self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self:ThrowMine()
self:SetNextPrimaryFire( CurTime() + 1.5 )
self:TakePrimaryAmmo( 1 )
if SERVER then
if self:Ammo1() <= 0 then
self.Owner:StripWeapon( "weapon_simmines" )
end
end
end
function SWEP:SecondaryAttack()
return false
end
function SWEP:Deploy()
self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
return true
end
function SWEP:Holster()
return true
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -0,0 +1,5 @@
"VertexLitGeneric"
{
"$baseTexture" "models/blu/sherman/sherman_tank"
"$bumpmap" "models/blu/sherman/sherman_tank_normal"
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,5 @@
"VertexLitGeneric"
{
"$baseTexture" "models/blu/sherman/sherman_tank_snow"
"$bumpmap" "models/blu/sherman/sherman_tank_normal"
}

Binary file not shown.

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models/blu/track_sherman"
}

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models/blu/track_sherman"
}

View File

@ -1,19 +0,0 @@
"vertexlitgeneric"
{
"$basetexture" "models/chaos126p/chaos126p_blue"
"$bumpmap" "models/chaos126p/chaos126p_red_skin_normal"
"$selfillum" "1"
"$selfillumtint" "[3 3 3]"
"$selfillummask" "models/chaos126p/chaos126p_blue_ilumination"
"$phong" "1"
"$phongexponent" "5"
"$phongboost" ".7"
"$lightwarptexture" "models/chaos126p/chaos126p_blue_lightwarp"
"$phongfresnelranges" "[.05 3 1]"
"$halflambert" "1"
}

View File

@ -1,20 +0,0 @@
"vertexlitgeneric"
{
"$basetexture" "models/chaos126p/chaos126p_red"
"$bumpmap" "models/chaos126p/chaos126p_red_skin_normal"
"$selfillum" "1"
"$selfillumtint" "[3 3 3]"
"$selfillummask" "models/chaos126p/chaos126p_red_ilumination"
"$phong" "1"
"$phongexponent" "5"
"$phongboost" ".7"
"$lightwarptexture" "models/chaos126p/chaos126p_red_lightwarp"
"$phongfresnelranges" "[.05 3 1]"
"$halflambert" "1"
}

View File

@ -1,42 +0,0 @@
"vertexlitgeneric"
{
"$baseTexture" "models/Hedgehog/Hedgehog_blue"
"$bumpmap" "models/Hedgehog/Hedgehog_normal"
//"$surfaceprop" "solidmetal"
//"$envmap" "env_cubemap"
//"$envmap" "Environment Maps/rg"
//"$envmapcontrast" 1
//"$envmapsaturation" 1
//"$envmaptint" "[ 0.2 0.2 0.2 ]"
//"$normalmapalphaenvmapmask" "1"
//"$halflambert" "1"
//"$nodecal" "1"
//"$model" "1"
//"$phong" "1"
//"$phongexponent" "10"
//"$phongexponenttexture" "models/Hedgehog/Hedgehog_exponent"
//"$phongboost" "5"
//"$phongfresnelranges" "[0 0.5 1]"
"$selfillum" "1"
"$selfillumtint" "[3 3 3]"
"$selfillummask" "models/Hedgehog/Hedgehog_blue_ilumination"
"$phong" "1"
"$phongexponent" "20"
//"$phongexponenttexture" "models/Hedgehog/Hedgehog_exponent"
"$phongboost" "2.5"
"$lightwarptexture" "models/Hedgehog/Hedgehog_blue_lightwarp"
//"$phongwarptexture" "models/Hedgehog/Hedgehog_phongwarp"
//"$phongalbedotint" "1"
"$phongfresnelranges" "[.05 3 1]"
"$halflambert" "1"
//Rim lighting parameters
//"$rimlight" "1" // To enable rim lighting (requires phong)
//"$rimlightexponent" "75" // Exponent for phong component of rim lighting
//"$rimlightboost" "8" // Boost for ambient cube component of rim lighting
}

View File

@ -1,17 +0,0 @@
"vertexlitgeneric"
{
"$baseTexture" "models/Hedgehog/Hedgehog_destroyed"
"$bumpmap" "models/Hedgehog/Hedgehog_normal"
"$surfaceprop" "solidmetal"
//"$envmap" "env_cubemap"
//"$envmap" "Environment Maps/rg"
//"$envmap" "models/Chaos126p/rg"
//"$envmapmask" "models/WarBuggy/WarBuggy_mask"
//"$envmapcontrast" 1
//"$envmapsaturation" 1
//"$envmaptint" "[ 0.5 0.5 0.5 ]"
//"$normalmapalphaenvmapmask" "1"
}

View File

@ -1,42 +0,0 @@
"vertexlitgeneric"
{
"$baseTexture" "models/Hedgehog/Hedgehog_red"
"$bumpmap" "models/Hedgehog/Hedgehog_normal"
//"$surfaceprop" "solidmetal"
//"$envmap" "env_cubemap"
//"$envmap" "Environment Maps/rg"
//"$envmapcontrast" 1
//"$envmapsaturation" 1
//"$envmaptint" "[ 0.2 0.2 0.2 ]"
//"$normalmapalphaenvmapmask" "1"
//"$halflambert" "1"
//"$nodecal" "1"
//"$model" "1"
//"$phong" "1"
//"$phongexponent" "10"
//"$phongexponenttexture" "models/Hedgehog/Hedgehog_exponent"
//"$phongboost" "5"
//"$phongfresnelranges" "[0 0.5 1]"
"$selfillum" "1"
"$selfillumtint" "[3 3 3]"
"$selfillummask" "models/Hedgehog/Hedgehog_red_ilumination"
"$phong" "1"
"$phongexponent" "20"
//"$phongexponenttexture" "models/Hedgehog/Hedgehog_exponent"
"$phongboost" "2.5"
"$lightwarptexture" "models/Hedgehog/Hedgehog_red_lightwarp"
//"$phongwarptexture" "models/Hedgehog/Hedgehog_phongwarp"
//"$phongalbedotint" "1"
"$phongfresnelranges" "[.05 3 1]"
"$halflambert" "1"
//Rim lighting parameters
//"$rimlight" "1" // To enable rim lighting (requires phong)
//"$rimlightexponent" "75" // Exponent for phong component of rim lighting
//"$rimlightboost" "8" // Boost for ambient cube component of rim lighting
}

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models\props_vehicles/tiger_tank"
}

Binary file not shown.

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models\props_vehicles/tiger_tank_navyb"
}

Binary file not shown.

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models\props_vehicles/tiger_tank_snow"
}

Binary file not shown.

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models\props_vehicles/tiger_tank_tan"
}

Binary file not shown.

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models/blu/track"
}

View File

@ -0,0 +1,4 @@
"VertexLitGeneric"
{
"$baseTexture" "models/blu/track"
}

View File

@ -1,42 +0,0 @@
"vertexlitgeneric"
{
"$basetexture" "models/Ratmobile/Ratmobile_blue"
"$bumpmap" "models/Ratmobile/Ratmobile_normal"
//"$envmapmask" "models/Ratmobile/Ratmobile_DISP"
//"$envmap" "Environment Maps/rg"
//"$envmapcontrast" 1
//"$envmapsaturation" 1
//"$envmaptint" "[ 0.3 0.3 0.3 ]"
//"$normalmapalphaenvmapmask" "1"
//"$halflambert" "1"
//"$nodecal" "1"
//"$model" "1"
//"$phong" "1"
//"$phongexponent" "10"
//"$phongexponenttexture" "models/Ratmobile/Ratmobile_exponent"
//"$phongboost" "5"
//"$lightwarptexture" "models/Ratmobile/Ratmobile_lightwarp"
//"$phongfresnelranges" "[0.3 1 3]"
"$selfillum" "1"
"$selfillumtint" "[3 3 3]"
"$selfillummask" "models/Ratmobile/Ratmobile_blue_ilumination"
"$phong" "1"
"$phongexponent" "10"
//"$phongexponenttexture" "models/Ratmobile/Ratmobile_exponent"
"$phongboost" "3.5"
"$lightwarptexture" "models/Ratmobile/Ratmobile_lightwarp"
//"$phongwarptexture" "models/Ratmobile/Ratmobile_phongwarp"
//"$phongalbedotint" "1"
"$phongfresnelranges" "[.05 3 1]"
"$halflambert" "1"
//Rim lighting parameters
//"$rimlight" "1" // To enable rim lighting (requires phong)
//"$rimlightexponent" "75" // Exponent for phong component of rim lighting
//"$rimlightboost" "8" // Boost for ambient cube component of rim lighting
}

View File

@ -1,17 +0,0 @@
"vertexlitgeneric"
{
"$baseTexture" "models/Ratmobile/Ratmobile_destroyed"
"$bumpmap" "models/Ratmobile/Ratmobile_normal"
"$surfaceprop" "solidmetal"
//"$envmap" "env_cubemap"
//"$envmap" "Environment Maps/rg"
//"$envmap" "models/Chaos126p/rg"
//"$envmapmask" "models/WarBuggy/WarBuggy_mask"
//"$envmapcontrast" 1
//"$envmapsaturation" 1
//"$envmaptint" "[ 0.5 0.5 0.5 ]"
//"$normalmapalphaenvmapmask" "1"
}

View File

@ -1,42 +0,0 @@
"vertexlitgeneric"
{
"$basetexture" "models/Ratmobile/Ratmobile_red"
"$bumpmap" "models/Ratmobile/Ratmobile_normal"
//"$envmapmask" "models/Ratmobile/Ratmobile_DISP"
//"$envmap" "Environment Maps/rg"
//"$envmapcontrast" 1
//"$envmapsaturation" 1
//"$envmaptint" "[ 0.3 0.3 0.3 ]"
//"$normalmapalphaenvmapmask" "1"
//"$halflambert" "1"
//"$nodecal" "1"
//"$model" "1"
//"$phong" "1"
//"$phongexponent" "10"
//"$phongexponenttexture" "models/Ratmobile/Ratmobile_exponent"
//"$phongboost" "5"
//"$lightwarptexture" "models/Ratmobile/Ratmobile_lightwarp"
//"$phongfresnelranges" "[0.3 1 3]"
"$selfillum" "1"
"$selfillumtint" "[3 3 3]"
"$selfillummask" "models/Ratmobile/Ratmobile_red_ilumination"
"$phong" "1"
"$phongexponent" "10"
//"$phongexponenttexture" "models/Ratmobile/Ratmobile_exponent"
"$phongboost" "3.5"
"$lightwarptexture" "models/Ratmobile/Ratmobile_lightwarp"
//"$phongwarptexture" "models/Ratmobile/Ratmobile_phongwarp"
//"$phongalbedotint" "1"
"$phongfresnelranges" "[.05 3 1]"
"$halflambert" "1"
//Rim lighting parameters
//"$rimlight" "1" // To enable rim lighting (requires phong)
//"$rimlightexponent" "75" // Exponent for phong component of rim lighting
//"$rimlightboost" "8" // Boost for ambient cube component of rim lighting
}

View File

@ -0,0 +1,6 @@
"VertexlitGeneric"
{
"$basetexture" "models/salza/tankmine/mine"
"$bumpmap" "models/salza/tankmine/mine_nm"
"$halflambert" "1"
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
"VertexlitGeneric"
{
"$basetexture" "models/salza/tankmine/mine_text"
"$bumpmap" "models/salza/tankmine/mine_nm"
"$halflambert" "1"
}

Binary file not shown.

Binary file not shown.

BIN
models/blu/mine.dx80.vtx Normal file

Binary file not shown.

BIN
models/blu/mine.dx90.vtx Normal file

Binary file not shown.

BIN
models/blu/mine.mdl Normal file

Binary file not shown.

BIN
models/blu/mine.phy Normal file

Binary file not shown.

BIN
models/blu/mine.sw.vtx Normal file

Binary file not shown.

BIN
models/blu/mine.vvd Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More