This commit is contained in:
lifestorm
2024-08-04 23:54:45 +03:00
parent 8064ba84d8
commit 6a58f406b1
7522 changed files with 4011896 additions and 15 deletions

View File

@@ -0,0 +1,661 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
CreateConVar( "sv_simfphys_enabledamage", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE},"1 = enabled, 0 = disabled" )
CreateConVar( "sv_simfphys_gib_lifetime", "30", {FCVAR_REPLICATED , FCVAR_ARCHIVE},"How many seconds before removing the gibs (0 = never remove)" )
CreateConVar( "sv_simfphys_playerdamage", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE},"should players take damage from collisions in vehicles?" )
CreateConVar( "sv_simfphys_damagemultiplicator", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE},"vehicle damage multiplicator" )
CreateConVar( "sv_simfphys_fuel", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE},"enable fuel? 1 = enabled, 0 = disabled" )
CreateConVar( "sv_simfphys_fuelscale", "0.1", {FCVAR_REPLICATED , FCVAR_ARCHIVE},"fuel tank size multiplier. 1 = Realistic fuel tank size (about 2-3 hours of fullthrottle driving, Lol, have fun)" )
simfphys.DamageEnabled = false
simfphys.DamageMul = 1
simfphys.pDamageEnabled = false
simfphys.Fuel = true
simfphys.FuelMul = 0.1
cvars.AddChangeCallback( "sv_simfphys_enabledamage", function( convar, oldValue, newValue ) simfphys.DamageEnabled = ( tonumber( newValue )~=0 ) end)
cvars.AddChangeCallback( "sv_simfphys_damagemultiplicator", function( convar, oldValue, newValue ) simfphys.DamageMul = tonumber( newValue ) end)
cvars.AddChangeCallback( "sv_simfphys_playerdamage", function( convar, oldValue, newValue ) simfphys.pDamageEnabled = ( tonumber( newValue )~=0 ) end)
cvars.AddChangeCallback( "sv_simfphys_fuel", function( convar, oldValue, newValue ) simfphys.Fuel = ( tonumber( newValue )~=0 ) end)
cvars.AddChangeCallback( "sv_simfphys_fuelscale", function( convar, oldValue, newValue ) simfphys.FuelMul = tonumber( newValue ) end)
simfphys.DamageEnabled = GetConVar( "sv_simfphys_enabledamage" ):GetBool()
simfphys.DamageMul = GetConVar( "sv_simfphys_damagemultiplicator" ):GetFloat()
simfphys.pDamageEnabled = GetConVar( "sv_simfphys_playerdamage" ):GetBool()
simfphys.Fuel = GetConVar( "sv_simfphys_fuel" ):GetBool()
simfphys.FuelMul = GetConVar( "sv_simfphys_fuelscale" ):GetFloat()
simfphys.ice = CreateConVar( "sv_simfphys_traction_ice", "0.35", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.gmod_ice = CreateConVar( "sv_simfphys_traction_gmod_ice", "0.1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.snow = CreateConVar( "sv_simfphys_traction_snow", "0.7", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.slipperyslime = CreateConVar( "sv_simfphys_traction_slipperyslime", "0.2", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.grass = CreateConVar( "sv_simfphys_traction_grass", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.sand = CreateConVar( "sv_simfphys_traction_sand", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.dirt = CreateConVar( "sv_simfphys_traction_dirt", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.concrete = CreateConVar( "sv_simfphys_traction_concrete", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.metal = CreateConVar( "sv_simfphys_traction_metal", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.glass = CreateConVar( "sv_simfphys_traction_glass", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.gravel = CreateConVar( "sv_simfphys_traction_gravel", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.rock = CreateConVar( "sv_simfphys_traction_rock", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
simfphys.wood = CreateConVar( "sv_simfphys_traction_wood", "1", {FCVAR_REPLICATED , FCVAR_ARCHIVE})
function simfphys.IsCar( ent )
if not IsValid( ent ) then return false end
return ent.LVSsimfphys == true
end
local meta = FindMetaTable( "Player" )
function meta:IsDrivingSimfphys()
local Car = self:GetSimfphys()
local Pod = self:GetVehicle()
if not IsValid( Car ) then return false end
return Pod == Car:GetDriverSeat()
end
function meta:GetSimfphys()
local Pod = self:GetVehicle()
if not IsValid( Pod ) then return NULL end
if Pod.SPHYSchecked == true then
return Pod.SPHYSBaseEnt
else
local Parent = Pod:GetParent()
if not IsValid( Parent ) then return NULL end
if not Parent.LVSsimfphys then
Pod.SPHYSchecked = LVS.MapDoneLoading
Pod.SPHYSBaseEnt = NULL
Pod.vehiclebase = NULL
return NULL
end
Pod.SPHYSchecked = true
Pod.SPHYSBaseEnt = Parent
Pod.vehiclebase = Parent -- compatibility for old addons
return Parent
end
end
if SERVER then
util.AddNetworkString( "simfphys_settings" )
util.AddNetworkString( "simfphys_turnsignal" )
util.AddNetworkString( "simfphys_spritedamage" )
util.AddNetworkString( "simfphys_lightsfixall" )
util.AddNetworkString( "simfphys_backfire" )
util.AddNetworkString( "simfphys_plyrequestinfo" )
net.Receive( "simfphys_plyrequestinfo", function( length, ply )
if not IsValid( ply ) then return end
ply.simeditor_nextrequest = isnumber( ply.simeditor_nextrequest ) and ply.simeditor_nextrequest or 0
if ply.simeditor_nextrequest > CurTime() then return end
ply.simeditor_nextrequest = CurTime() + 0.5
local ent = ply:GetEyeTrace().Entity
if not simfphys.IsCar( ent ) then return end
local ent = net.ReadEntity()
local data = simfphys.BuildVehicleInfo( ent )
if not data then return end
net.Start( "simfphys_plyrequestinfo" )
net.WriteEntity( ent )
net.WriteFloat( data["torque"] )
net.WriteFloat( data["horsepower"] )
net.WriteFloat( data["maxspeed"] )
net.WriteFloat( data["weight"] )
net.Send( ply )
end )
net.Receive( "simfphys_turnsignal", function( length, ply )
if not ply:IsDrivingSimfphys() then return end
local ent = net.ReadEntity()
local mode = net.ReadInt( 32 )
if not IsValid( ent ) or ply:GetSimfphys() ~= ent then return end
ent:SetTSInternal( mode )
net.Start( "simfphys_turnsignal" )
net.WriteEntity( ent )
net.WriteInt( mode, 32 )
net.Broadcast()
end )
net.Receive( "simfphys_settings", function( length, ply )
if not IsValid( ply ) or not ply:IsSuperAdmin() then return end
local dmgEnabled = tostring(net.ReadBool() and 1 or 0)
local giblifetime = tostring(net.ReadFloat())
local dmgMul = tostring(net.ReadFloat())
local pdmgEnabled = tostring(net.ReadBool() and 1 or 0)
local fuel = tostring(net.ReadBool() and 1 or 0)
local fuelscale = tostring(net.ReadFloat())
local newtraction = net.ReadTable()
RunConsoleCommand("sv_simfphys_enabledamage", dmgEnabled )
RunConsoleCommand("sv_simfphys_gib_lifetime", giblifetime )
RunConsoleCommand("sv_simfphys_damagemultiplicator", dmgMul )
RunConsoleCommand("sv_simfphys_playerdamage", pdmgEnabled )
RunConsoleCommand("sv_simfphys_fuel", fuel )
RunConsoleCommand("sv_simfphys_fuelscale", fuelscale )
for k, v in pairs( newtraction ) do
RunConsoleCommand("sv_simfphys_traction_"..k, v)
end
simfphys.UpdateFrictionData()
end)
function simfphys.BuildVehicleInfo( ent )
if not simfphys.IsCar( ent ) then return false end
local WheelRad = ent.RearWheelRadius
if ent.FrontWheelPowered and ent.RearWheelRadius then
WheelRad = math.max( ent.FrontWheelRadius, ent.RearWheelRadius )
elseif ent.FrontWheelPowered then
WheelRad = ent.FrontWheelRadius
end
local Mass = 0
for _, Entity in pairs( constraint.GetAllConstrainedEntities( ent ) ) do
local EPOBJ = Entity:GetPhysicsObject()
if IsValid( EPOBJ ) then
Mass = Mass + EPOBJ:GetMass()
end
end
local data = {}
data["torque"] = ent:GetMaxTorque() * (WheelRad / 10) * ent:GetEfficiency() * (1 + (ent:GetTurboCharged() and 0.3 or 0) + (ent:GetSuperCharged() and 0.48 or 0))
data["horsepower"] = (data["torque"] * ent:GetLimitRPM() / 9548.8) * 1.34
data["maxspeed"] = ((ent:GetLimitRPM() * ent.Gears[ table.Count( ent.Gears ) ] * ent:GetDifferentialGear()) * 3.14 * WheelRad * 2) / 52
data["weight"] = Mass
return data
end
function simfphys.SpawnVehicleSimple( spawnname, pos, ang )
if not isstring( spawnname ) then print("invalid spawnname") return NULL end
if not isvector( pos ) then print("invalid spawn position") return NULL end
if not isangle( ang ) then print("invalid spawn angle") return NULL end
local vehicle = list.Get( "simfphys_vehicles" )[ spawnname ]
if not vehicle then print("vehicle \""..spawnname.."\" does not exist!") return NULL end
local Ent = simfphys.SpawnVehicle( nil, pos, ang, vehicle.Model, vehicle.Class, spawnname, vehicle, true )
return Ent
end
function simfphys.SpawnVehicle( Player, Pos, Ang, Model, Class, VName, VTable, bNoOwner )
if not bNoOwner then
if not gamemode.Call( "PlayerSpawnVehicle", Player, Model, VName, VTable ) then return end
end
if not file.Exists( Model, "GAME" ) then
Player:PrintMessage( HUD_PRINTTALK, "ERROR: \""..Model.."\" does not exist! (Class: "..VName..")")
return
end
local Ent = ents.Create( "gmod_sent_vehicle_fphysics_base" )
if not Ent then return NULL end
Ent:SetModel( Model )
Ent:SetAngles( Ang )
Ent:SetPos( Pos )
Ent:Spawn()
Ent:Activate()
Ent.VehicleName = VName
Ent.VehicleTable = VTable
Ent.EntityOwner = Player
Ent:SetSpawn_List( VName )
if VTable.Members then
table.Merge( Ent, VTable.Members )
if Ent.ModelInfo then
if Ent.ModelInfo.Bodygroups then
for i = 1, table.Count( Ent.ModelInfo.Bodygroups ) do
Ent:SetBodygroup(i, Ent.ModelInfo.Bodygroups[i] )
end
end
if Ent.ModelInfo.Skin then
Ent:SetSkin( Ent.ModelInfo.Skin )
end
if Ent.ModelInfo.Color then
Ent:SetColor( Ent.ModelInfo.Color )
local Color = Ent.ModelInfo.Color
local dot = Color.r * Color.g * Color.b * Color.a
Ent.OldColor = dot
local data = {
Color = Color,
RenderMode = 0,
RenderFX = 0
}
duplicator.StoreEntityModifier( Ent, "colour", data )
end
end
Ent:SetTireSmokeColor(Vector(180,180,180) / 255)
Ent.Turbocharged = Ent.Turbocharged or false
Ent.Supercharged = Ent.Supercharged or false
Ent:SetEngineSoundPreset( Ent.EngineSoundPreset )
Ent:SetMaxTorque( Ent.PeakTorque )
Ent:SetDifferentialGear( Ent.DifferentialGear )
Ent:SetSteerSpeed( Ent.TurnSpeed )
Ent:SetFastSteerConeFadeSpeed( Ent.SteeringFadeFastSpeed )
Ent:SetFastSteerAngle( Ent.FastSteeringAngle )
Ent:SetEfficiency( Ent.Efficiency )
Ent:SetMaxTraction( Ent.MaxGrip )
Ent:SetTractionBias( Ent.GripOffset / Ent.MaxGrip )
Ent:SetPowerDistribution( Ent.PowerBias )
Ent:SetBackFire( Ent.Backfire or false )
Ent:SetDoNotStall( Ent.DoNotStall or false )
Ent:SetIdleRPM( Ent.IdleRPM )
Ent:SetLimitRPM( Ent.LimitRPM )
Ent:SetRevlimiter( Ent.Revlimiter or false )
Ent:SetPowerBandEnd( Ent.PowerbandEnd )
Ent:SetPowerBandStart( Ent.PowerbandStart )
Ent:SetTurboCharged( Ent.Turbocharged )
Ent:SetSuperCharged( Ent.Supercharged )
Ent:SetBrakePower( Ent.BrakePower )
Ent:SetLights_List( Ent.LightsTable or "no_lights" )
Ent:SetBulletProofTires( Ent.BulletProofTires or false )
Ent:SetBackfireSound( Ent.snd_backfire or "" )
if not simfphys.WeaponSystemRegister then
if simfphys.ManagedVehicles then
print("[SIMFPHYS ARMED] IS OUT OF DATE")
end
else
timer.Simple( 0.2, function()
simfphys.WeaponSystemRegister( Ent )
end )
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
duplicator.StoreEntityModifier( Ent, "VehicleMemDupe", VTable.Members )
end
if IsValid( Player ) then
gamemode.Call( "PlayerSpawnedVehicle", Player, Ent )
return Ent
end
return Ent
end
function simfphys.SetOwner( ply, entity )
if not IsValid( entity ) or not IsValid( ply ) then return end
if CPPI then
if not IsEntity( ply ) then return end
if IsValid( ply ) then
entity:CPPISetOwner( ply )
end
end
end
end
if CLIENT then
net.Receive( "simfphys_plyrequestinfo", function( length )
local ent = net.ReadEntity()
if not simfphys.IsCar( ent ) then return end
ent.VehicleInfo = {}
ent.VehicleInfo["torque"] = net.ReadFloat()
ent.VehicleInfo["horsepower"] = net.ReadFloat()
ent.VehicleInfo["maxspeed"] = net.ReadFloat()
ent.VehicleInfo["weight"] = net.ReadFloat()
end )
end
function simfphys.UpdateFrictionData()
simfphys.TractionData = {}
timer.Simple( 0.1,function()
simfphys.TractionData["ice"] = simfphys.ice:GetFloat()
simfphys.TractionData["gmod_ice"] = simfphys.gmod_ice:GetFloat()
simfphys.TractionData["snow"] = simfphys.snow:GetFloat()
simfphys.TractionData["slipperyslime"] = simfphys.slipperyslime:GetFloat()
simfphys.TractionData["grass"] = simfphys.grass:GetFloat()
simfphys.TractionData["sand"] = simfphys.sand:GetFloat()
simfphys.TractionData["dirt"] = simfphys.dirt:GetFloat()
simfphys.TractionData["concrete"] = simfphys.concrete:GetFloat()
simfphys.TractionData["metal"] = simfphys.metal:GetFloat()
simfphys.TractionData["glass"] = simfphys.glass:GetFloat()
simfphys.TractionData["gravel"] = simfphys.gravel:GetFloat()
simfphys.TractionData["rock"] = simfphys.rock:GetFloat()
simfphys.TractionData["wood"] = simfphys.wood:GetFloat()
end)
end
simfphys.UpdateFrictionData()
simfphys.SoundPresets = {
{
"simulated_vehicles/gta5_dukes/dukes_idle.wav",
"simulated_vehicles/gta5_dukes/dukes_low.wav",
"simulated_vehicles/gta5_dukes/dukes_mid.wav",
"simulated_vehicles/gta5_dukes/dukes_revdown.wav",
"simulated_vehicles/gta5_dukes/dukes_second.wav",
"simulated_vehicles/gta5_dukes/dukes_second.wav",
0.8,
1,
0.8
},
{
"simulated_vehicles/master_chris_charger69/charger_idle.wav",
"simulated_vehicles/master_chris_charger69/charger_low.wav",
"simulated_vehicles/master_chris_charger69/charger_mid.wav",
"simulated_vehicles/master_chris_charger69/charger_revdown.wav",
"simulated_vehicles/master_chris_charger69/charger_second.wav",
"simulated_vehicles/master_chris_charger69/charger_shiftdown.wav",
0.75,
0.9,
0.95
},
{
"simulated_vehicles/shelby/shelby_idle.wav",
"simulated_vehicles/shelby/shelby_low.wav",
"simulated_vehicles/shelby/shelby_mid.wav",
"simulated_vehicles/shelby/shelby_revdown.wav",
"simulated_vehicles/shelby/shelby_second.wav",
"simulated_vehicles/shelby/shelby_shiftdown.wav",
0.8,
1,
0.85
},
{
"simulated_vehicles/jeep/jeep_idle.wav",
"simulated_vehicles/jeep/jeep_low.wav",
"simulated_vehicles/jeep/jeep_mid.wav",
"simulated_vehicles/jeep/jeep_revdown.wav",
"simulated_vehicles/jeep/jeep_second.wav",
"simulated_vehicles/jeep/jeep_second.wav",
0.9,
1,
1
},
{
"simulated_vehicles/v8elite/v8elite_idle.wav",
"simulated_vehicles/v8elite/v8elite_low.wav",
"simulated_vehicles/v8elite/v8elite_mid.wav",
"simulated_vehicles/v8elite/v8elite_revdown.wav",
"simulated_vehicles/v8elite/v8elite_second.wav",
"simulated_vehicles/v8elite/v8elite_second.wav",
0.8,
1,
1
},
{
"simulated_vehicles/4banger/4banger_idle.wav",
"simulated_vehicles/4banger/4banger_low.wav",
"simulated_vehicles/4banger/4banger_mid.wav",
"simulated_vehicles/4banger/4banger_low.wav",
"simulated_vehicles/4banger/4banger_second.wav",
"simulated_vehicles/4banger/4banger_second.wav",
0.8,
0.9,
1
},
{
"simulated_vehicles/jalopy/jalopy_idle.wav",
"simulated_vehicles/jalopy/jalopy_low.wav",
"simulated_vehicles/jalopy/jalopy_mid.wav",
"simulated_vehicles/jalopy/jalopy_revdown.wav",
"simulated_vehicles/jalopy/jalopy_second.wav",
"simulated_vehicles/jalopy/jalopy_shiftdown.wav",
0.95,
1.1,
0.9
},
{
"simulated_vehicles/alfaromeo/alfaromeo_idle.wav",
"simulated_vehicles/alfaromeo/alfaromeo_low.wav",
"simulated_vehicles/alfaromeo/alfaromeo_mid.wav",
"simulated_vehicles/alfaromeo/alfaromeo_low.wav",
"simulated_vehicles/alfaromeo/alfaromeo_second.wav",
"simulated_vehicles/alfaromeo/alfaromeo_second.wav",
0.65,
0.8,
1
},
{
"simulated_vehicles/generic1/generic1_idle.wav",
"simulated_vehicles/generic1/generic1_low.wav",
"simulated_vehicles/generic1/generic1_mid.wav",
"simulated_vehicles/generic1/generic1_revdown.wav",
"simulated_vehicles/generic1/generic1_second.wav",
"simulated_vehicles/generic1/generic1_second.wav",
0.8,
1.1,
1
},
{
"simulated_vehicles/generic2/generic2_idle.wav",
"simulated_vehicles/generic2/generic2_low.wav",
"simulated_vehicles/generic2/generic2_mid.wav",
"simulated_vehicles/generic2/generic2_revdown.wav",
"simulated_vehicles/generic2/generic2_second.wav",
"simulated_vehicles/generic2/generic2_second.wav",
1,
1.1,
1
},
{
"simulated_vehicles/generic3/generic3_idle.wav",
"simulated_vehicles/generic3/generic3_low.wav",
"simulated_vehicles/generic3/generic3_mid.wav",
"simulated_vehicles/generic3/generic3_revdown.wav",
"simulated_vehicles/generic3/generic3_second.wav",
"simulated_vehicles/generic3/generic3_second.wav",
0.9,
0.9,
1
},
{
"simulated_vehicles/generic4/generic4_idle.wav",
"simulated_vehicles/generic4/generic4_low.wav",
"simulated_vehicles/generic4/generic4_mid.wav",
"simulated_vehicles/generic4/generic4_revdown.wav",
"simulated_vehicles/generic4/generic4_gear.wav",
"simulated_vehicles/generic4/generic4_shiftdown.wav",
1,
1.1,
1
},
{
"simulated_vehicles/generic5/generic5_idle.wav",
"simulated_vehicles/generic5/generic5_low.wav",
"simulated_vehicles/generic5/generic5_mid.wav",
"simulated_vehicles/generic5/generic5_revdown.wav",
"simulated_vehicles/generic5/generic5_gear.wav",
"simulated_vehicles/generic5/generic5_gear.wav",
0.7,
0.7,
1
},
{
"simulated_vehicles/gta5_gauntlet/gauntlet_idle.wav",
"simulated_vehicles/gta5_gauntlet/gauntlet_low.wav",
"simulated_vehicles/gta5_gauntlet/gauntlet_mid.wav",
"simulated_vehicles/gta5_gauntlet/gauntlet_revdown.wav",
"simulated_vehicles/gta5_gauntlet/gauntlet_gear.wav",
"simulated_vehicles/gta5_gauntlet/gauntlet_gear.wav",
0.95,
1.1,
1
},
{
"vehicles/tdmcars/mitsuevox/mitsuevox_idle.wav",
"vehicles/tdmcars/mitsuevox/mitsuevox_low.wav",
"vehicles/tdmcars/mitsuevox/mitsuevox_mid.wav",
"vehicles/tdmcars/mitsuevox/mitsuevox_revdown.wav",
"vehicles/tdmcars/mitsuevox/mitsuevox_gear.wav",
"vehicles/tdmcars/mitsuevox/mitsuevox_gear.wav",
0.9,
0.95,
1,
},
{
"vehicles/tdmcars/for_taurus_13/for_taurus_13_idle.wav",
"vehicles/tdmcars/for_taurus_13/for_taurus_13_low.wav",
"vehicles/tdmcars/for_taurus_13/for_taurus_13_mid.wav",
"vehicles/tdmcars/for_taurus_13/for_taurus_13_revdown.wav",
"vehicles/tdmcars/for_taurus_13/for_taurus_13_gear.wav",
"vehicles/tdmcars/for_taurus_13/for_taurus_13_gear.wav",
1,
0.9,
1,
},
{
"vehicles/tdmcars/focussvt/focussvt_idle.wav",
"vehicles/tdmcars/focussvt/focussvt_low.wav",
"vehicles/tdmcars/focussvt/focussvt_mid.wav",
"vehicles/tdmcars/focussvt/focussvt_revdown.wav",
"vehicles/tdmcars/focussvt/focussvt_gear.wav",
"vehicles/tdmcars/focussvt/focussvt_gear.wav",
0.95,
1.05,
1,
},
{
"vehicles/tdmcars/mere63/mere63_idle.wav",
"vehicles/tdmcars/mere63/mere63_low.wav",
"vehicles/tdmcars/mere63/mere63_mid.wav",
"vehicles/tdmcars/mere63/mere63_revdown.wav",
"vehicles/tdmcars/mere63/mere63_gear.wav",
"vehicles/tdmcars/mere63/mere63_gear.wav",
1.2,
1.1,
1,
},
{
"vehicles/tdmcars/supra/supra_idle.wav",
"vehicles/tdmcars/supra/supra_low.wav",
"vehicles/tdmcars/supra/supra_mid.wav",
"vehicles/tdmcars/supra/supra_revdown.wav",
"vehicles/tdmcars/supra/supra_gear.wav",
"vehicles/tdmcars/supra/supra_gear.wav",
1,
1.2,
0.85,
},
{
"vehicles/tdmcars/f350/f350_idle.wav",
"vehicles/tdmcars/f350/f350_low.wav",
"vehicles/tdmcars/f350/f350_mid.wav",
"vehicles/tdmcars/f350/f350_revdown.wav",
"vehicles/tdmcars/f350/f350_gear.wav",
"vehicles/tdmcars/f350/f350_gear.wav",
1,
1.2,
1,
},
{
"vehicles/tdmcars/mr2gt/mr2gt_idle.wav",
"vehicles/tdmcars/mr2gt/mr2gt_low.wav",
"vehicles/tdmcars/mr2gt/mr2gt_mid.wav",
"vehicles/tdmcars/mr2gt/mr2gt_revdown.wav",
"vehicles/tdmcars/mr2gt/mr2gt_gear.wav",
"vehicles/tdmcars/mr2gt/mr2gt_gear.wav",
0.9,
1,
1,
},
{
"vehicles/tdmcars/rav4/rav4_idle.wav",
"vehicles/tdmcars/rav4/rav4_low.wav",
"vehicles/tdmcars/rav4/rav4_mid.wav",
"vehicles/tdmcars/rav4/rav4_revdown.wav",
"vehicles/tdmcars/rav4/rav4_gear.wav",
"vehicles/tdmcars/rav4/rav4_gear.wav",
1.1,
1.1,
1,
},
{
"vehicles/tdmcars/toyfj/toyfj_idle.wav",
"vehicles/tdmcars/toyfj/toyfj_low.wav",
"vehicles/tdmcars/toyfj/toyfj_mid.wav",
"vehicles/tdmcars/toyfj/toyfj_revdown.wav",
"vehicles/tdmcars/toyfj/toyfj_gear.wav",
"vehicles/tdmcars/toyfj/toyfj_shiftdown.wav",
0.85,
1.15,
1,
},
}

View File

@@ -0,0 +1,168 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
-- 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()
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 = Base: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 )

View File

@@ -0,0 +1,207 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
-- 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)

View File

@@ -0,0 +1,568 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
CreateClientConVar( "cl_simfphys_crosshair", "1", true, false )
local ShowHud = false
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)
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 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 )
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( color_white )
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
vehicle:PaintCrosshairCenter( scr )
vehicle:PaintCrosshairOuter( scr )
surface.SetDrawColor( color_white )
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( "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( "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 )
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 )
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 )
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( 255, 255, 255, 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( 255, 255, 255, 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)
surface.SetDrawColor( 255, 255, 255, 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( 255, 255, 255, 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)
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_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( "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( "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 )
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( 255, 255, 255, 180 )
else
surface.SetDrawColor( 255, 255, 255, 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( 255, 255, 255, 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
vehicle:PaintCrosshairCenter( scr )
vehicle:PaintCrosshairOuter( scr )
surface.SetDrawColor( color_white )
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_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( "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( "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 )
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 )
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 )
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()
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" ) )
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 )

View File

@@ -0,0 +1,16 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local function damagedbackfire( length )
local veh = net.ReadEntity()
if not IsValid( veh ) then return end
veh:Backfire( true )
end
net.Receive("simfphys_backfire", damagedbackfire)

View File

@@ -0,0 +1,136 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
surface.CreateFont( "simfphysworldtip", {font="coolvetica", size=24, weight=500, antialias=true, additive=false} )
surface.CreateFont( "simfphysfont", {
font = "Verdana",
extended = false,
size = ScrH() >= 900 and (ScrH() >= 1080 and 20 or 18) or 12,
weight = 600,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = true,
additive = false,
outline = false,
} )
surface.CreateFont( "simfphysfont2", {font = "Verdana",
extended = false,
size = (ScrH() >= 900 and (ScrH() >= 1080 and 20 or 18) or 12) * 2.8,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = true,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
surface.CreateFont( "simfphysfont3", {
font = "Verdana",
extended = false,
size = (ScrH() >= 900 and (ScrH() >= 1080 and 20 or 18) or 12) * 1.3,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = true,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
surface.CreateFont( "simfphysfont4", {
font = "Verdana",
extended = false,
size = (ScrH() >= 900 and (ScrH() >= 1080 and 20 or 18) or 12) * 6,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = true,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
surface.CreateFont( "DSimfphysFont", {
font = "Arial",
extended = false,
size = 22,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
surface.CreateFont( "DSimfphysFont_hint", {
font = "Arial",
extended = false,
size = 21,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = true,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = false,
} )
surface.CreateFont( "SimfphysFont_seatswitcher", {
font = "Verdana",
extended = false,
size = 16,
weight = 2000,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = true,
additive = false,
outline = false,
} )

556
lua/simfphys/client/hud.lua Normal file
View File

@@ -0,0 +1,556 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
if not file.Exists( "includes/circles/circles.lua", "LUA" ) then return end
local circles = include("includes/circles/circles.lua")
local CircleMain
local CircleMainRed
local CircleRedLine
local screenw = ScrW()
local screenh = ScrH()
local Widescreen = (screenw / screenh) > (4 / 3)
local sizex = screenw * (Widescreen and 1 or 1.32)
local sizey = screenh
local xpos = sizex * 0.02
local ypos = sizey * 0.8
local x = xpos * (Widescreen and 43.5 or 32)
local y = ypos * 1.015
local radius = 0.085 * sizex
local startang = 105
local lights_on = Material( "simfphys/hud/low_beam_on" )
local lights_on2 = Material( "simfphys/hud/high_beam_on" )
local lights_off = Material( "simfphys/hud/low_beam_off" )
local fog_on = Material( "simfphys/hud/fog_light_on" )
local fog_off = Material( "simfphys/hud/fog_light_off" )
local cruise_on = Material( "simfphys/hud/cc_on" )
local cruise_off = Material( "simfphys/hud/cc_off" )
local hbrake_on = Material( "simfphys/hud/handbrake_on" )
local hbrake_off = Material( "simfphys/hud/handbrake_off" )
local HUD_1 = Material( "simfphys/hud/hud" )
local HUD_2 = Material( "simfphys/hud/hud_center" )
local HUD_3 = Material( "simfphys/hud/hud_center_red" )
local ForceSimpleHud = not file.Exists( "materials/simfphys/hud/hud.vmt", "GAME" ) -- lets check if the background material exists, if not we will force the old hud to prevent fps drop
local smHider = 0
local ShowHud = false
local ShowHud_ms = false
local AltHud = false
local Hudmph = false
local Hudmpg = false
local Hudreal = false
local hasCounterSteerEnabled = false
local slushbox = false
local hudoffset_x = 0
local hudoffset_y = 0
local turnmenu = KEY_COMMA
cvars.AddChangeCallback( "cl_simfphys_hud", function( convar, oldValue, newValue ) ShowHud = tonumber( newValue )~=0 end)
cvars.AddChangeCallback( "cl_simfphys_hud_offset_x", function( convar, oldValue, newValue ) hudoffset_x = newValue end)
cvars.AddChangeCallback( "cl_simfphys_hud_offset_y", function( convar, oldValue, newValue ) hudoffset_y = newValue end)
cvars.AddChangeCallback( "cl_simfphys_althud", function( convar, oldValue, newValue ) AltHud = tonumber( newValue )~=0 end)
cvars.AddChangeCallback( "cl_simfphys_hudmph", function( convar, oldValue, newValue ) Hudmph = tonumber( newValue )~=0 end)
cvars.AddChangeCallback( "cl_simfphys_hudmpg", function( convar, oldValue, newValue ) Hudmpg = tonumber( newValue )~=0 end)
cvars.AddChangeCallback( "cl_simfphys_hudrealspeed", function( convar, oldValue, newValue ) Hudreal = tonumber( newValue )~=0 end)
cvars.AddChangeCallback( "cl_simfphys_ctenable", function( convar, oldValue, newValue ) hasCounterSteerEnabled = tonumber( newValue )~=0 end)
cvars.AddChangeCallback( "cl_simfphys_auto", function( convar, oldValue, newValue ) slushbox = tonumber( newValue )~=0 end)
cvars.AddChangeCallback( "cl_simfphys_key_turnmenu", function( convar, oldValue, newValue ) turnmenu = tonumber( newValue ) end)
ShowHud = GetConVar( "cl_simfphys_hud" ):GetBool()
hudoffset_x = GetConVar( "cl_simfphys_hud_offset_x" ):GetFloat()
hudoffset_y = GetConVar( "cl_simfphys_hud_offset_y" ):GetFloat()
AltHud = GetConVar( "cl_simfphys_althud" ):GetBool()
Hudmph = GetConVar( "cl_simfphys_hudmph" ):GetBool()
Hudmpg = GetConVar( "cl_simfphys_hudmpg" ):GetBool()
Hudreal = GetConVar( "cl_simfphys_hudrealspeed" ):GetBool()
hasCounterSteerEnabled = GetConVar( "cl_simfphys_ctenable" ):GetBool()
slushbox = GetConVar( "cl_simfphys_auto" ):GetBool()
turnmenu = GetConVar( "cl_simfphys_key_turnmenu" ):GetInt()
local function DrawCircle( X, Y, radius )
local segmentdist = 360 / ( 2 * math.pi * radius / 2 )
for a = 0, 360 - segmentdist, 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 )
end
end
local sm_throttle = 0
local s_smoothrpm = 0
local function drawsimfphysHUD(vehicle)
if not ShowHud then return end
if vehicle:GetNWBool( "simfphys_NoHud", false ) then return end
local maxrpm = vehicle:GetLimitRPM()
local rpm = vehicle:GetRPM()
local throttle = math.Round(vehicle:GetThrottle() * 100,0)
local revlimiter = vehicle:GetRevlimiter() and (maxrpm > 2500) and (throttle > 0)
local SimpleHudIsForced = vehicle:GetNWBool( "simfphys_NoRacingHud", false )
local powerbandend = math.min(vehicle:GetPowerBandEnd(), maxrpm - 1)
local redline = math.max(rpm - powerbandend,0) / (maxrpm - powerbandend)
local Active = vehicle:GetActive() and "" or "!"
local speed = vehicle:GetVelocity():Length()
local mph = math.Round(speed * 0.0568182,0)
local kmh = math.Round(speed * 0.09144,0)
local wiremph = math.Round(speed * 0.0568182 * 0.75,0)
local wirekmh = math.Round(speed * 0.09144 * 0.75,0)
local cruisecontrol = vehicle:GetIsCruiseModeOn()
local gear = vehicle:GetGear()
local DrawGear = not slushbox and (gear == 1 and "R" or gear == 2 and "N" or (gear - 2)) or (gear == 1 and "R" or gear == 2 and "N" or "(".. (gear - 2)..")")
local o_x = hudoffset_x * screenw
local o_y = hudoffset_y * screenh
local fuel = vehicle:GetFuel() / vehicle:GetMaxFuel()
local fueltype = vehicle:GetFuelType()
local fueltype_color = color_white
if fueltype == FUELTYPE_ELECTRIC then
fueltype_color = Color(0,127,255,150)
elseif fueltype == FUELTYPE_PETROL then
fueltype_color = Color(240,200,0,150)
elseif fueltype == FUELTYPE_DIESEL then
fueltype_color = Color(255,60,0,150)
end
if AltHud and not ForceSimpleHud and not SimpleHudIsForced then
local LightsOn = vehicle:GetLightsEnabled()
local LampsOn = vehicle:GetLampsEnabled()
local FogLightsOn = vehicle:GetFogLightsEnabled()
local HandBrakeOn = vehicle:GetHandBrakeEnabled()
s_smoothrpm = s_smoothrpm or 0
s_smoothrpm = math.Clamp(s_smoothrpm + (rpm - s_smoothrpm) * 0.3,0,maxrpm)
local endang = startang + math.Round( (s_smoothrpm/maxrpm) * 255, 0)
local c_ang = math.cos( math.rad(endang) )
local s_ang = math.sin( math.rad(endang) )
local ang_pend = startang + math.Round( (powerbandend / maxrpm) * 255, 0)
local r_rpm = math.floor(maxrpm / 1000) * 1000
local in_red = s_smoothrpm < powerbandend
surface.SetDrawColor( 255, 255, 255, 255 )
local mat = LightsOn and (LampsOn and lights_on2 or lights_on) or lights_off
surface.SetMaterial( mat )
surface.DrawTexturedRect( x + radius * 1.15 + o_x, y - radius * 0.1 + o_y, sizex * 0.014, sizex * 0.014 )
local mat = FogLightsOn and fog_on or fog_off
surface.SetMaterial( mat )
surface.DrawTexturedRect( x + radius * 1.12 + o_x, y - radius * 0.43 + o_y, sizex * 0.018, sizex * 0.018 )
local mat = cruisecontrol and cruise_on or cruise_off
surface.SetMaterial( mat )
surface.DrawTexturedRect( x + radius * 1.11 + o_x, y - radius * 0.75 + o_y, sizex * 0.02, sizex * 0.02 )
local mat = HandBrakeOn and hbrake_on or hbrake_off
surface.SetMaterial( mat )
surface.DrawTexturedRect( x + radius * 1.13 + o_x, y - radius * 1 + o_y, sizex * 0.018, sizex * 0.018 )
surface.SetMaterial( HUD_1 )
surface.DrawTexturedRect( x - radius + o_x, y - radius + 1 + o_y, radius * 2, radius * 2)
surface.SetMaterial( in_red and HUD_2 or HUD_3 )
surface.DrawTexturedRect( x - radius + o_x, y - radius + 1 + o_y, radius * 2, radius * 2)
draw.NoTexture()
if not CircleMain then
CircleMain = circles.New(CIRCLE_OUTLINED, radius, 0, 0, radius / 6.66)
CircleMain:SetColor( Color(255,255,255,150) )
end
CircleMain:SetX( x + o_x )
CircleMain:SetY( y + o_y )
CircleMain:SetStartAngle( startang )
CircleMain:SetEndAngle( math.min(endang,ang_pend) )
CircleMain()
if not CircleRedLine then
CircleRedLine = circles.New(CIRCLE_OUTLINED, radius, 0, 0, radius / 6.66)
CircleRedLine:SetColor( Color(120,0,0,230) )
end
CircleRedLine:SetX( x + o_x )
CircleRedLine:SetY( y + o_y )
CircleRedLine:SetStartAngle( ang_pend )
CircleRedLine:SetEndAngle( 360 )
CircleRedLine()
if not CircleMainRed then
CircleMainRed = circles.New(CIRCLE_OUTLINED, radius, 0, 0, radius / 6.66)
CircleMainRed:SetColor( Color(255,0,0,140) )
end
CircleMainRed:SetX( x + o_x )
CircleMainRed:SetY( y + o_y )
CircleMainRed:SetStartAngle( math.Round(ang_pend - 1,0) )
CircleMainRed:SetEndAngle( startang + (s_smoothrpm / maxrpm) * 255 )
CircleMainRed()
--draw.Arc(x + o_x,y + o_y,radius,radius / 6.66,startang,math.min(endang,ang_pend),1,Color(255,255,255,150),true)
--draw.Arc(x + o_x,y + o_y,radius,radius / 6.66,ang_pend,360,1,Color(120,0,0,230),true)
--draw.Arc(x + o_x,y + o_y,radius,radius / 6.66,math.Round(ang_pend - 1,0),startang + (s_smoothrpm / maxrpm) * 255,1,Color(255,0,0,140),true)
--draw.Arc(x + o_x,y + o_y,radius / 3.5,radius / 66,startang,360,15,Color(255,255,255,50),true)
--draw.Arc(x + o_x,y + o_y,radius,radius / 6.66,startang,ang_pend,1,Color(150,150,150,50),true)
--draw.Arc(x + o_x,y + o_y,radius / 5,radius / 70,0,360,15,center_ncol,true)
local step = 0
for i = 0,maxrpm,250 do
step = step + 1
local anglestep = (255 / maxrpm) * i
local n_col_on
local n_col_off
if (i < powerbandend) then
n_col_off = Color(150, 150, 150, 150)
n_col_on = Color(255, 255, 255, 255)
else
n_col_off = Color( 150, 0, 0, 150)
n_col_on = Color( 255, 0, 0, 255 )
end
local u_col = (s_smoothrpm > i) and n_col_on or n_col_off
surface.SetDrawColor( u_col )
local cos_a = math.cos( math.rad(startang + anglestep) )
local sin_a = math.sin( math.rad(startang + anglestep) )
if step > 4 then
step = 1
surface.DrawLine( x + cos_a * radius / 1.3 + o_x, y + sin_a * radius / 1.3 + o_y, x + cos_a * radius + o_x, y + sin_a * radius + o_y)
local printnumber = tostring(i / 1000)
draw.SimpleText(printnumber, "simfphysfont3", x + cos_a * radius / 1.5 + o_x, y + sin_a * radius / 1.5 + o_y,u_col, 1, 1 )
else
surface.DrawLine( x + cos_a * radius / 1.05 + o_x, y + sin_a * radius / 1.05 + o_y, x + cos_a * radius + o_x, y + sin_a * radius + o_y)
end
end
local center_ncol = in_red and Color(0,254,235,200) or Color( 255, 0, 0, 255 )
surface.SetDrawColor( in_red and Color(255,255,255,255) or Color( 255, 0, 0, 255 ) )
surface.DrawLine( x + c_ang * radius / 3.5 + o_x, y + s_ang * radius / 3.5 + o_y, x + c_ang * radius + o_x, y + s_ang * radius + o_y)
surface.SetDrawColor( 255, 255, 255, 255 )
draw.SimpleText( (gear == 1 and "R" or gear == 2 and "N" or (gear - 2)), "simfphysfont2", x * 0.999 + o_x, y * 0.996 + o_y, center_ncol, 1, 1 )
local print_text = Hudmph and "MPH" or "KM/H"
draw.SimpleText( print_text, "simfphysfont3", x + radius * 0.82 + o_x, y + radius * 0.16 + o_y, Color(255,255,255,50), 1, 1 )
local printspeed = Hudmph and (Hudreal and mph or wiremph) or (Hudreal and kmh or wirekmh)
local digit_1 = printspeed % 10
local digit_2 = (printspeed - digit_1) % 100
local digit_3 = (printspeed - digit_1 - digit_2) % 1000
local col_on = Color(150,150,150,50)
local col_off = Color(255,255,255,150)
local col1 = (printspeed > 0) and col_off or col_on
local col2 = (printspeed >= 10) and col_off or col_on
local col3 = (printspeed >= 100) and col_off or col_on
draw.SimpleText( digit_1, "simfphysfont4", x + radius * 0.84 + o_x, y + radius * 0.65 + o_y, col1, 1, 1 )
draw.SimpleText( digit_2/ 10, "simfphysfont4", x + radius * 0.48 + o_x, y + radius * 0.65 + o_y, col2, 1, 1 )
draw.SimpleText( digit_3 / 100, "simfphysfont4", x + radius * 0.12 + o_x, y + radius * 0.65 + o_y, col3, 1, 1 )
sm_throttle = sm_throttle + (throttle - sm_throttle) * 0.1
local t_size = (sizey * 0.1)
surface.SetDrawColor( Color(150,150,150,50) )
surface.DrawRect( x + radius * 1.22 + o_x, y + radius * 0.36 + o_y, radius * 0.08, sizey * 0.1 )
surface.SetDrawColor( Color(255,255,255,150) )
surface.DrawRect( x + radius * 1.22 + o_x, y + radius * 0.36 + t_size - t_size * math.min(sm_throttle / 100,1) + o_y, radius * 0.08, t_size * math.min(sm_throttle / 100,1) )
local fueluse = vehicle:GetFuelUse()
if fueluse == -1 then return end
local r = math.Round( radius, 0)
surface.SetDrawColor( Color(150,150,150,50) )
surface.DrawRect( x + o_x + r * fuel, y + o_y + r, r * (1 - fuel), r * 0.04 )
surface.DrawLine( x + o_x - r * 0.85, y + o_y + r * 1.04 - 2, x + o_x, y + o_y + r * 1.04 - 2)
surface.SetDrawColor( fueltype_color )
surface.DrawRect( x + o_x, y + o_y + r, r * fuel, r * 0.04 )
if fueltype ~= FUELTYPE_PETROL and fueltype ~= FUELTYPE_DIESEL then return end
local ecospeed = (Hudreal and kmh or wirekmh)
local calc_fueluse = (100 / ecospeed) * fueluse * 60
if Hudmpg then
calc_fueluse = 235.214 / calc_fueluse
end
local print_fueluse = (ecospeed > 0 and vehicle:GetFuel() > 0) and tostring( math.Round( calc_fueluse,0) ) or "N/A"
--draw.SimpleText( tostring( math.Round( fueluse,2) ).." L/min", "simfphysfont3", x + o_x + radius, y + o_y + radius * 1.04, Color(150,150,150,150), TEXT_ALIGN_RIGHT, TEXT_ALIGN_TOP )
draw.SimpleText( print_fueluse, "simfphysfont3", x + o_x - radius * 0.85, y + o_y + radius * 0.85, Color(150,150,150,150), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
draw.SimpleText( Hudmpg and "MPG" or "L/100KM", "simfphysfont3", x + o_x - radius * 0.85, y + o_y + radius * 1.02, Color(150,150,150,150), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP )
return
end
local s_xpos = xpos
local s_ypos = ypos
local Col = color_white
if SimpleHudIsForced then
o_x = 0
o_y = 0
s_xpos = screenw * 0.5 - sizex * 0.115 - sizex * 0.032
s_ypos = screenh - sizey * 0.092 - sizey * 0.02
end
if cruisecontrol then
draw.SimpleText( "cruise", "simfphysfont", s_xpos + sizex * 0.115 + o_x, s_ypos + sizey * 0.035 + o_y, Color( 255, 127, 0, 255 ), 2, 1 )
end
draw.SimpleText( "Throttle: "..throttle.." %", "simfphysfont", s_xpos + o_x, s_ypos + sizey * 0.035 + o_y, Col, 0, 1)
local ColRPM = Color( 255, 255 * (1 - redline), 255 * (1 - redline), 255 )
draw.SimpleText( "RPM: "..math.Round(rpm,0)..Active, "simfphysfont", s_xpos + o_x, s_ypos + sizey * 0.012 + o_y, ColRPM, 0, 1 )
draw.SimpleText( "GEAR:", "simfphysfont", s_xpos + sizex * 0.062 + o_x, s_ypos + sizey * 0.012 + o_y, Col, 0, 1 )
draw.SimpleText( DrawGear, "simfphysfont", s_xpos + sizex * 0.11 + o_x, s_ypos + sizey * 0.012 + o_y, Col, 2, 1 )
draw.SimpleText( (Hudreal and mph or wiremph).." mph", "simfphysfont", s_xpos + o_x, s_ypos + sizey * 0.062 + o_y, Col, 0, 1 )
draw.SimpleText( (Hudreal and kmh or wirekmh).." kmh", "simfphysfont", s_xpos + sizex * 0.11 + o_x, s_ypos + sizey * 0.062 + o_y, Col, 2, 1 )
local fueluse = vehicle:GetFuelUse()
if fueluse == -1 then return end
local r = math.Round(sizey * 0.075,0)
surface.SetDrawColor( Color(0,0,0,80) )
surface.DrawRect( s_xpos + o_x - sizex * 0.007, s_ypos + o_y, sizex * 0.0025, r * (1 - fuel) )
surface.SetDrawColor( fueltype_color )
surface.DrawRect( s_xpos + o_x - sizex * 0.007, s_ypos + o_y + r * (1 - fuel), sizex * 0.0025, r * fuel )
end
local turnmode = 0
local turnmenu_wasopen = false
local function drawTurnMenu( vehicle )
if input.IsKeyDown( GetConVar( "cl_simfphys_keyforward" ):GetInt() ) or input.IsKeyDown( GetConVar( "cl_simfphys_key_air_forward" ):GetInt() ) then
turnmode = 0
end
if input.IsKeyDown( GetConVar( "cl_simfphys_keyleft" ):GetInt() ) or input.IsKeyDown( GetConVar( "cl_simfphys_key_air_left" ):GetInt() ) then
turnmode = 2
end
if input.IsKeyDown( GetConVar( "cl_simfphys_keyright" ):GetInt() ) or input.IsKeyDown( GetConVar( "cl_simfphys_key_air_right" ):GetInt() ) then
turnmode = 3
end
if input.IsKeyDown( GetConVar( "cl_simfphys_keyreverse" ):GetInt() ) or input.IsKeyDown( GetConVar( "cl_simfphys_key_air_reverse" ):GetInt() ) then
turnmode = 1
end
local cX = ScrW() / 2
local cY = ScrH() / 2
local sx = sizex * 0.065
local sy = sizex * 0.065
local selectorX = (turnmode == 2 and (-sx - 1) or 0) + (turnmode == 3 and (sx + 1) or 0)
local selectorY = (turnmode == 0 and (-sy - 1) or 0)
draw.RoundedBox( 8, cX - sx * 0.5 - 1 + selectorX, cY - sy * 0.5 - 1 + selectorY, sx + 2, sy + 2, Color( 240, 200, 0, 255 ) )
draw.RoundedBox( 8, cX - sx * 0.5 + selectorX, cY - sy * 0.5 + selectorY, sx, sy, Color( 50, 50, 50, 255 ) )
draw.RoundedBox( 8, cX - sx * 0.5, cY - sy * 0.5, sx, sy, Color( 0, 0, 0, 100 ) )
draw.RoundedBox( 8, cX - sx * 0.5, cY - sy * 1.5 - 1, sx, sy, Color( 0, 0, 0, 100 ) )
draw.RoundedBox( 8, cX - sx * 1.5 - 1, cY - sy * 0.5, sx, sy, Color( 0, 0, 0, 100 ) )
draw.RoundedBox( 8, cX + sx * 0.5 + 1, cY - sy * 0.5, sx, sy, Color( 0, 0, 0, 100 ) )
surface.SetDrawColor( 240, 200, 0, 100 )
--X
if turnmode == 0 then
surface.SetDrawColor( 240, 200, 0, 255 )
end
surface.DrawLine( cX - sx * 0.3, cY - sy - sy * 0.3, cX + sx * 0.3, cY - sy + sy * 0.3 )
surface.DrawLine( cX + sx * 0.3, cY - sy - sy * 0.3, cX - sx * 0.3, cY - sy + sy * 0.3 )
surface.SetDrawColor( 240, 200, 0, 100 )
-- <=
if turnmode == 2 then
surface.SetDrawColor( 240, 200, 0, 255 )
end
surface.DrawLine( cX - sx + sx * 0.3, cY - sy * 0.15, cX - sx + sx * 0.3, cY + sy * 0.15 )
surface.DrawLine( cX - sx + sx * 0.3, cY + sy * 0.15, cX - sx, cY + sy * 0.15 )
surface.DrawLine( cX - sx + sx * 0.3, cY - sy * 0.15, cX - sx, cY - sy * 0.15 )
surface.DrawLine( cX - sx, cY - sy * 0.3, cX - sx, cY - sy * 0.15 )
surface.DrawLine( cX - sx, cY + sy * 0.3, cX - sx, cY + sy * 0.15 )
surface.DrawLine( cX - sx, cY + sy * 0.3, cX - sx - sx * 0.3, cY )
surface.DrawLine( cX - sx, cY - sy * 0.3, cX - sx - sx * 0.3, cY )
surface.SetDrawColor( 240, 200, 0, 100 )
-- =>
if turnmode == 3 then
surface.SetDrawColor( 240, 200, 0, 255 )
end
surface.DrawLine( cX + sx - sx * 0.3, cY - sy * 0.15, cX + sx - sx * 0.3, cY + sy * 0.15 )
surface.DrawLine( cX + sx - sx * 0.3, cY + sy * 0.15, cX + sx, cY + sy * 0.15 )
surface.DrawLine( cX + sx - sx * 0.3, cY - sy * 0.15, cX + sx, cY - sy * 0.15 )
surface.DrawLine( cX + sx, cY - sy * 0.3, cX + sx, cY - sy * 0.15 )
surface.DrawLine( cX + sx, cY + sy * 0.3, cX + sx, cY + sy * 0.15 )
surface.DrawLine( cX + sx, cY + sy * 0.3, cX + sx + sx * 0.3, cY )
surface.DrawLine( cX + sx, cY - sy * 0.3, cX + sx + sx * 0.3, cY )
surface.SetDrawColor( 240, 200, 0, 100 )
-- ^
if turnmode == 1 then
surface.SetDrawColor( 240, 200, 0, 255 )
end
surface.DrawLine( cX, cY - sy * 0.4, cX + sx * 0.4, cY + sy * 0.3 )
surface.DrawLine( cX, cY - sy * 0.4, cX - sx * 0.4, cY + sy * 0.3 )
surface.DrawLine( cX + sx * 0.4, cY + sy * 0.3, cX - sx * 0.4, cY + sy * 0.3 )
surface.DrawLine( cX, cY - sy * 0.26, cX + sx * 0.3, cY + sy * 0.24 )
surface.DrawLine( cX, cY - sy * 0.26, cX - sx * 0.3, cY + sy * 0.24 )
surface.DrawLine( cX + sx * 0.3, cY + sy * 0.24, cX - sx * 0.3, cY + sy * 0.24 )
surface.SetDrawColor( 255, 255, 255, 255 )
end
hook.Add( "HUDPaint", "simfphys_HUD", function()
local ply = LocalPlayer()
local turnmenu_isopen = false
if not IsValid( ply ) or not ply:Alive() then turnmenu_wasopen = false return end
local vehicle = ply:GetVehicle()
local vehiclebase = ply:GetSimfphys()
if not IsValid( vehicle ) or not IsValid( vehiclebase ) then
ply.oldPassengersmf = {}
turnmenu_wasopen = false
smHider = 0
return
end
if not ply:IsDrivingSimfphys() then turnmenu_wasopen = false return end
drawsimfphysHUD( vehiclebase )
if vehiclebase.HasTurnSignals and input.IsKeyDown( turnmenu ) then
turnmenu_isopen = true
drawTurnMenu( vehiclebase )
end
if turnmenu_isopen ~= turnmenu_wasopen then
turnmenu_wasopen = turnmenu_isopen
if turnmenu_isopen then
turnmode = 0
else
net.Start( "simfphys_turnsignal" )
net.WriteEntity( vehiclebase )
net.WriteInt( turnmode, 32 )
net.SendToServer()
if turnmode == 1 or turnmode == 2 or turnmode == 3 then
vehiclebase:EmitSound( "simulated_vehicles/sfx/turnsignal_start.ogg" )
else
vehiclebase:EmitSound( "simulated_vehicles/sfx/turnsignal_end.ogg" )
end
end
end
end)
local bgcol = Color(120,120,120,255)
local framecol = Color(0,0,0,255)
local textcol = Color(210,210,210,255)
hook.Add("HUDPaint", "simfphys_vehicleditorinfo", function()
local ply = LocalPlayer()
if ply:InVehicle() then return end
local wep = ply:GetActiveWeapon()
if not IsValid( wep ) or wep:GetClass() ~= "gmod_tool" or ply:GetInfo("gmod_toolmode") ~= "simfphyseditor" then return end
local trace = ply:GetEyeTrace()
local Ent = trace.Entity
if not simfphys.IsCar( Ent ) then return end
local vInfo = Ent:GetVehicleInfo()
if not istable( vInfo ) or not vInfo["maxspeed"] or not vInfo["horsepower"] or not vInfo["weight"] or not vInfo["torque"] then return end
local SpeedMul = Hudmph and (Hudreal and 0.0568182 or 0.0568182 * 0.75) or (Hudreal and 0.09144 or 0.09144 * 0.75)
local SpeedSuffix = Hudmph and "mph" or "km/h"
local toSize = Hudreal and (1/0.75) or 1
local nameSize = Hudreal and "\n\nNote: values are based on playersize" or ""
local TopSpeed = math.Round( vInfo["maxspeed"] * SpeedMul )
local HP = math.Round( vInfo["horsepower"] * toSize )
local Weight = math.Round( vInfo["weight"] )
local PowerToWeight = math.Round(Weight / HP,1)
local PeakTorque = math.Round( vInfo["torque"] * toSize )
local text = "Peak Power: "..HP.." HP".."\nPeak Torque: "..PeakTorque.." Nm\nTop Speed: "..tostring( TopSpeed )..SpeedSuffix.." (theoretical max)".."\nWeight: "..Weight.." kg ("..PowerToWeight.." kg / HP)"..nameSize
local pos = Ent:LocalToWorld( Ent:OBBCenter() ):ToScreen()
local x = 0
local y = 0
local padding = 10
local offset = 50
surface.SetFont( "simfphysworldtip" )
local w, h = surface.GetTextSize( text )
x = pos.x - w
y = pos.y - h
x = x - offset
y = y - offset
draw.RoundedBox( 8, x-padding-2, y-padding-2, w+padding*2+4, h+padding*2+4, framecol )
local verts = {}
verts[1] = { x=x+w/1.5-2, y=y+h+2 }
verts[2] = { x=x+w+2, y=y+h/2-1 }
verts[3] = { x=pos.x-offset/2+2, y=pos.y-offset/2+2 }
draw.NoTexture()
surface.SetDrawColor( framecol )
surface.DrawPoly( verts )
draw.RoundedBox( 8, x-padding, y-padding, w+padding*2, h+padding*2, bgcol )
local verts = {}
verts[1] = { x=x+w/1.5, y=y+h }
verts[2] = { x=x+w, y=y+h/2 }
verts[3] = { x=pos.x-offset/2, y=pos.y-offset/2 }
draw.NoTexture()
surface.SetDrawColor( bgcol )
surface.DrawPoly( verts )
draw.DrawText( text, "simfphysworldtip", x + w/2, y, textcol, TEXT_ALIGN_CENTER )
end)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,69 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local function receiveppdata( length )
local ent = net.ReadEntity()
if IsValid( ent ) then
ent.CustomWheels = net.ReadBool()
if not ent.CustomWheels then
local wheelFL = net.ReadEntity()
local posFL = net.ReadFloat()
local travelFL = net.ReadFloat()
local wheelFR = net.ReadEntity()
local posFR = net.ReadFloat()
local travelFR = net.ReadFloat()
local wheelRL = net.ReadEntity()
local posRL = net.ReadFloat()
local travelRL = net.ReadFloat()
local wheelRR = net.ReadEntity()
local posRR = net.ReadFloat()
local travelRR = net.ReadFloat()
if not IsValid( wheelFL ) or not IsValid( wheelFR ) or not IsValid( wheelRL ) or not IsValid( wheelRR ) then return end
ent.pp_data = {
[1] = {
name = "vehicle_wheel_fl_height",
entity = wheelFL,
pos = posFL,
travel = travelFL,
dradius = (wheelFL:BoundingRadius() * 0.28),
},
[2] = {
name = "vehicle_wheel_fr_height",
entity = wheelFR,
pos = posFR,
travel = travelFR,
dradius = (wheelFR:BoundingRadius() * 0.28),
},
[3] = {
name = "vehicle_wheel_rl_height",
entity = wheelRL,
pos = posRL,
travel = travelRL,
dradius = (wheelRL:BoundingRadius() * 0.28),
},
[4] = {
name = "vehicle_wheel_rr_height",
entity = wheelRR,
pos = posRR,
travel = travelRR,
dradius = (wheelRR:BoundingRadius() * 0.28),
},
}
end
end
end
net.Receive("simfphys_send_ppdata", receiveppdata)

View File

@@ -0,0 +1,81 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local function TableMerge( ent, class )
local vehiclelist = list.Get( "simfphys_vehicles" )[ class ]
if not vehiclelist then return end
local data = vehiclelist.Members
if not data then return end
ent.customview = data.FirstPersonViewPos or Vector(0,-9,5)
ent.EnginePos = data.EnginePos
ent.ExhaustPositions = data.ExhaustPositions
ent.snd_idle = data.snd_idle
ent.snd_low = data.snd_low
ent.snd_mid = data.snd_mid
ent.snd_low_revdown = data.snd_low_revdown
ent.snd_mid_gearup = data.snd_mid_gearup
ent.snd_mid_geardown = data.snd_mid_geardown
ent.snd_low_pitch = data.snd_low_pitch
ent.snd_mid_pitch = data.snd_mid_pitch
ent.snd_pitch = data.snd_pitch
ent.Sound_Idle = data.Sound_Idle
ent.Sound_IdlePitch = data.Sound_IdlePitch
ent.Sound_Mid = data.Sound_Mid
ent.Sound_MidPitch = data.Sound_MidPitch
ent.Sound_MidVolume = data.Sound_MidVolume
ent.Sound_MidFadeOutRPMpercent = data.Sound_MidFadeOutRPMpercent
ent.Sound_MidFadeOutRate = data.Sound_MidFadeOutRate
ent.Sound_High = data.Sound_High
ent.Sound_HighPitch = data.Sound_HighPitch
ent.Sound_HighVolume = data.Sound_HighVolume
ent.Sound_HighFadeInRPMpercent = data.Sound_HighFadeInRPMpercent
ent.Sound_HighFadeInRate = data.Sound_HighFadeInRate
ent.Sound_Throttle = data.Sound_Throttle
ent.Sound_ThrottlePitch = data.Sound_ThrottlePitch
ent.Sound_ThrottleVolume = data.Sound_ThrottleVolume
end
local function Loop( ent, delay )
delay = delay or 0
if not IsValid( ent ) then return end
timer.Simple( delay , function()
if not IsValid( ent ) then return end
if ent.GetSpawn_List then
TableMerge( ent, ent:GetSpawn_List() )
else
Loop( ent, 0.1 )
end
end)
end
hook.Add( "OnEntityCreated", "!!!!lvs_just_in_time_table_merge", function( ent )
if not IsValid( ent ) then return end
if ent:GetClass() ~= "gmod_sent_vehicle_fphysics_base" then return end
Loop( ent )
end )

616
lua/simfphys/client/tab.lua Normal file
View File

@@ -0,0 +1,616 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local auto = CreateClientConVar( "cl_simfphys_auto", 1 , true, true )
local sport = CreateClientConVar( "cl_simfphys_sport", 0 , true, true )
local sanic = CreateClientConVar( "cl_simfphys_sanic", 0 , true, true )
local ctenable = CreateClientConVar( "cl_simfphys_ctenable", 1 , true, true )
local ctmul = CreateClientConVar( "cl_simfphys_ctmul", 0.7 , true, true )
local ctang = CreateClientConVar( "cl_simfphys_ctang", 15 , true, true )
local hud = CreateClientConVar( "cl_simfphys_hud", "1", true, false )
local alt_hud = CreateClientConVar( "cl_simfphys_althud", "1", true, false )
local hud_x = CreateClientConVar( "cl_simfphys_hud_offset_x", "0", true, false )
local hud_y = CreateClientConVar( "cl_simfphys_hud_offset_y", "0", true, false )
local hud_mph = CreateClientConVar( "cl_simfphys_hudmph", "0", true, false )
local hud_mpg = CreateClientConVar( "cl_simfphys_hudmpg", "0", true, false )
local hud_realspeed = CreateClientConVar( "cl_simfphys_hudrealspeed", "0", true, false )
local autostart = CreateClientConVar( "cl_simfphys_autostart", "1", true, true )
local overwrite = CreateClientConVar( "cl_simfphys_overwrite", 0, true, true )
local smoothsteer = CreateClientConVar( "cl_simfphys_smoothsteer", 0, true, true )
local steerspeed = CreateClientConVar( "cl_simfphys_steerspeed", 8, true, true )
local faststeerang = CreateClientConVar( "cl_simfphys_steerangfast", 10, true, true )
local fadespeed = CreateClientConVar( "cl_simfphys_fadespeed", 535, true, true )
CreateClientConVar( "cl_simfphys_hidesprites", "0", true, false )
CreateClientConVar( "cl_simfphys_frontlamps", "1", true, false )
CreateClientConVar( "cl_simfphys_rearlamps", "1", true, false )
CreateClientConVar( "cl_simfphys_shadows", "0", true, false )
local function simplebinder( x, y, tbl, num, parent)
local sizex = 500
local sizey = 40
local kentry = tbl[num]
local key = kentry[1]
local setdefault = key:GetInt()
local Shape = vgui.Create( "DShape", parent)
Shape:SetType( "Rect" )
Shape:SetPos( x, y )
Shape:SetSize( 175, sizey )
Shape:SetColor( Color( 0, 0, 0, 255 ) )
local Shape = vgui.Create( "DShape", parent)
Shape:SetType( "Rect" )
Shape:SetPos( x + 1, y + 1 )
Shape:SetSize( 173 - 2, sizey - 2 )
Shape:SetColor( Color( 241, 241, 241, 255 ) )
local binder = vgui.Create( "DBinder", parent)
binder:SetPos( 175 + x, y )
binder:SetSize( 500 - 175, sizey )
binder:SetValue( setdefault )
function binder:SetSelectedNumber( num )
self.m_iSelectedNumber = num
self:ConVarChanged( num )
self:UpdateText()
self:OnChange( num )
key:SetInt( num )
end
local TextLabel = vgui.Create( "DPanel", parent)
TextLabel:SetPos( x, y )
TextLabel:SetSize( 175, sizey )
TextLabel.Paint = function()
draw.SimpleText( kentry[3], "DSimfphysFont", 175 * 0.5, sizey * 0.5, Color( 100, 100, 100, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
return binder
end
local function simplebinder_old( x, y, tbl, num, parent, sizex, sizey)
local kentry = tbl[num]
local key = kentry[1]
local setdefault = key:GetInt()
local sizex = sizex or 400
local sizey = sizey or 40
local Shape = vgui.Create( "DShape", parent)
Shape:SetType( "Rect" )
Shape:SetPos( x, y )
Shape:SetSize( sizex, sizey )
Shape:SetColor( Color( 0, 0, 0, 255 ) )
local Shape = vgui.Create( "DShape", parent)
Shape:SetType( "Rect" )
Shape:SetPos( x + 1, y + 1 )
Shape:SetSize( sizex - 2, sizey - 2 )
Shape:SetColor( Color( 241, 241, 241, 255 ) )
local binder = vgui.Create( "DBinder", parent)
binder:SetPos( sizex * 0.5 + x, y )
binder:SetSize( sizex * 0.5, sizey )
binder:SetValue( setdefault )
function binder:SetSelectedNumber( num )
self.m_iSelectedNumber = num
self:ConVarChanged( num )
self:UpdateText()
self:OnChange( num )
key:SetInt( num )
end
local TextLabel = vgui.Create( "DPanel", parent)
TextLabel:SetPos( x, y )
TextLabel:SetSize( sizex * 0.5, sizey )
TextLabel.Paint = function()
draw.SimpleText( kentry[3], "DSimfphysFont", sizex * 0.25, 20, Color( 100, 100, 100, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
end
return binder
end
local function createcheckbox(x, y, label, command, parent, default)
local boxy = vgui.Create( "DCheckBoxLabel", parent)
boxy:SetParent( parent )
boxy:SetPos( x, y )
boxy:SetText( label )
boxy:SetConVar( command )
boxy:SetValue( default )
boxy:SizeToContents()
return boxy
end
local function createslider(x, y, sizex, sizey, label, command, parent,min,max,default)
local slider = vgui.Create( "DNumSlider", parent)
slider:SetPos( x, y )
slider:SetSize( sizex, sizey )
slider:SetText( label )
slider:SetMin( min )
slider:SetMax( max )
slider:SetDecimals( 2 )
slider:SetConVar( command )
slider:SetValue( default )
return slider
end
local function buildclientsettingsmenu( self )
local Shape = vgui.Create( "DShape", self.PropPanel)
Shape:SetType( "Rect" )
Shape:SetPos( 20, 20 )
Shape:SetSize( 350, 180 )
Shape:SetColor( Color( 0, 0, 0, 200 ) )
createcheckbox(25,25,"Show Hud","cl_simfphys_hud",self.PropPanel,hud:GetInt())
createcheckbox(210,25,"Racing Hud","cl_simfphys_althud",self.PropPanel,alt_hud:GetInt())
createcheckbox(25,45,"MPH instead of KMH","cl_simfphys_hudmph",self.PropPanel,hud_mph:GetInt())
createcheckbox(25,65,"Speed relative to \nplayersize instead \nworldsize","cl_simfphys_hudrealspeed",self.PropPanel,hud_realspeed:GetInt())
createcheckbox(25,110,"Fuel consumption \nin MPG instead \nof L/100KM","cl_simfphys_hudmpg",self.PropPanel,hud_mpg:GetInt())
createslider(30,155,345,20,"Hud offset X","cl_simfphys_hud_offset_x",self.PropPanel,-1,1,hud_x:GetFloat())
createslider(30,175,345,20,"Hud offset Y","cl_simfphys_hud_offset_y",self.PropPanel,-1,1,hud_y:GetFloat())
local Shape = vgui.Create( "DShape", self.PropPanel)
Shape:SetType( "Rect" )
Shape:SetPos( 20, 210 )
Shape:SetSize( 350, 85 )
Shape:SetColor( Color( 0, 0, 0, 200 ) )
createcheckbox(25,215,"Hide Sprites","cl_simfphys_hidesprites",self.PropPanel,0)
createcheckbox(25,235,"Front Projected Textures","cl_simfphys_frontlamps",self.PropPanel,0)
createcheckbox(25,255,"Rear Projected Textures","cl_simfphys_rearlamps",self.PropPanel,0)
createcheckbox(25,275,"Enable Shadows","cl_simfphys_shadows",self.PropPanel,0)
local Shape = vgui.Create( "DShape", self.PropPanel)
Shape:SetType( "Rect" )
Shape:SetPos( 20, 305 )
Shape:SetSize( 350, 85 )
Shape:SetColor( Color( 0, 0, 0, 200 ) )
createcheckbox(25,310,"Always Fullthrottle","cl_simfphys_sanic",self.PropPanel,sanic:GetInt())
createcheckbox(25,330,"Engine Auto Start/Stop","cl_simfphys_autostart",self.PropPanel,autostart:GetInt())
createcheckbox(25,350,"Automatic Transmission","cl_simfphys_auto",self.PropPanel,auto:GetInt())
createcheckbox(25,370,"Automatic Sportmode (late up and downshifts)","cl_simfphys_sport",self.PropPanel,sport:GetInt())
local Shape = vgui.Create( "DShape", self.PropPanel)
Shape:SetType( "Rect" )
Shape:SetPos( 20, 400 )
Shape:SetSize( 350, 115 )
Shape:SetColor( Color( 0, 0, 0, 200 ) )
local ctitem_1 = createcheckbox(25,405,"Enable Countersteer","cl_simfphys_ctenable",self.PropPanel,ctenable:GetInt())
local ctitem_2 = createslider(30,425,345,40,"Countersteer Mul","cl_simfphys_ctmul",self.PropPanel,0.1,2,ctmul:GetFloat())
local ctitem_3 = createslider(30,445,345,40,"Countersteer MaxAng","cl_simfphys_ctang",self.PropPanel,1,90,ctang:GetFloat())
local Reset = vgui.Create( "DButton" )
Reset:SetParent( self.PropPanel )
Reset:SetText( "Reset" )
Reset:SetPos( 25, 485 )
Reset:SetSize( 340, 25 )
Reset.DoClick = function()
ctitem_1:SetValue( 1 )
ctitem_2:SetValue( 0.7 )
ctitem_3:SetValue( 15 )
ctenable:SetInt( 1 )
ctmul:SetFloat( 0.7 )
ctang:SetFloat( 15 )
end
local Shape = vgui.Create( "DShape", self.PropPanel)
Shape:SetType( "Rect" )
Shape:SetPos( 20, 525 )
Shape:SetSize( 350, 165 )
Shape:SetColor( Color( 0, 0, 0, 200 ) )
local st_item_1 = createcheckbox(25,530,"Use these settings\n(you need to re-enter the vehicle)","cl_simfphys_overwrite",self.PropPanel,overwrite:GetInt())
local st_item_2 = createslider(30,550,345,40,"steer speed","cl_simfphys_steerspeed",self.PropPanel,1,16,steerspeed:GetFloat())
local st_item_3 = createslider(30,570,345,40,"fast speed steer angle","cl_simfphys_steerangfast",self.PropPanel,0,90,faststeerang:GetFloat())
local st_item_4 = createslider(30,595,345,40,"fade speed(units/seconds)\nfor fast speed steer angle","cl_simfphys_fadespeed",self.PropPanel,1,5000,fadespeed:GetFloat())
local st_item_5 = createcheckbox(25,635,"extra smooth steering","cl_simfphys_smoothsteer",self.PropPanel,smoothsteer:GetInt())
local Reset = vgui.Create( "DButton" )
Reset:SetParent( self.PropPanel )
Reset:SetText( "Reset" )
Reset:SetPos( 25, 660 )
Reset:SetSize( 340, 25 )
Reset.DoClick = function()
st_item_1:SetValue( 0 )
st_item_2:SetValue( 8 )
st_item_3:SetValue( 10 )
st_item_4:SetValue( 535 )
st_item_5:SetValue( 0 )
overwrite:SetInt( 0 )
steerspeed:SetFloat( 8 )
faststeerang:SetFloat( 10 )
fadespeed:SetFloat( 535 )
smoothsteer:SetInt( 0 )
end
end
local function buildserversettingsmenu( self )
local Background = vgui.Create( "DShape", self.PropPanel)
Background:SetType( "Rect" )
Background:SetPos( 20, 20 )
Background:SetColor( Color( 0, 0, 0, 200 ) )
local y = 0
if LocalPlayer():IsSuperAdmin() then
y = y + 25
local CheckBoxDamage = vgui.Create( "DCheckBoxLabel", self.PropPanel)
CheckBoxDamage:SetPos( 25, y )
CheckBoxDamage:SetText( "Enable Damage" )
CheckBoxDamage:SetValue( GetConVar( "sv_simfphys_enabledamage" ) :GetInt() )
CheckBoxDamage:SizeToContents()
y = y + 18
local DamageMul = vgui.Create( "DNumSlider", self.PropPanel)
DamageMul:SetPos( 30, y )
DamageMul:SetSize( 345, 30 )
DamageMul:SetText( "Damage Multiplicator" )
DamageMul:SetMin( 0 )
DamageMul:SetMax( 10 )
DamageMul:SetDecimals( 3 )
DamageMul:SetValue( GetConVar( "sv_simfphys_damagemultiplicator" ):GetFloat() )
y = y + 32
local CheckBoxpDamage = vgui.Create( "DCheckBoxLabel", self.PropPanel)
CheckBoxpDamage:SetPos( 25, y )
CheckBoxpDamage:SetText( "Enable Player Damage (On Collision)" )
CheckBoxpDamage:SetValue( GetConVar( "sv_simfphys_playerdamage" ) :GetInt() )
CheckBoxpDamage:SizeToContents()
y = y + 25
local GibRemoveTimer = vgui.Create( "DNumSlider", self.PropPanel)
GibRemoveTimer:SetPos( 30, y )
GibRemoveTimer:SetSize( 345, 30 )
GibRemoveTimer:SetText( "Gib Lifetime\n(0 = never remove)" )
GibRemoveTimer:SetMin( 0 )
GibRemoveTimer:SetMax( 3600 )
GibRemoveTimer:SetDecimals( 0 )
GibRemoveTimer:SetValue( GetConVar( "sv_simfphys_gib_lifetime" ):GetInt() )
y = y + 45
local CheckBoxFuel = vgui.Create( "DCheckBoxLabel", self.PropPanel)
CheckBoxFuel:SetPos( 25, y )
CheckBoxFuel:SetText( "Enable Fuelsystem" )
CheckBoxFuel:SetValue( GetConVar( "sv_simfphys_fuel" ) :GetInt() )
CheckBoxFuel:SizeToContents()
y = y + 18
local ScaleFuel = vgui.Create( "DNumSlider", self.PropPanel)
ScaleFuel:SetPos( 30, y )
ScaleFuel:SetSize( 345, 30 )
ScaleFuel:SetText( "Fuel tank size multiplier" )
ScaleFuel:SetMin( 0 )
ScaleFuel:SetMax( 1 )
ScaleFuel:SetDecimals( 2 )
ScaleFuel:SetValue( GetConVar( "sv_simfphys_fuelscale" ):GetFloat() )
y = y + 45
local tractionLabel = vgui.Create( "DLabel", self.PropPanel )
tractionLabel:SetPos( 25, y )
tractionLabel:SetText( "Traction Multiplicator for:" )
tractionLabel:SizeToContents()
local NewTractionData = {}
local DemSliders = {}
y = y + 15
for k, v in pairs( simfphys.TractionData ) do
DemSliders[k] = vgui.Create( "DNumSlider", self.PropPanel)
DemSliders[k]:SetPos( 30, y )
DemSliders[k]:SetSize( 345, 30 )
DemSliders[k]:SetText( k )
DemSliders[k]:SetMin( 0 )
DemSliders[k]:SetMax( 2 )
DemSliders[k]:SetDecimals( 2 )
DemSliders[k]:SetValue( simfphys[k]:GetFloat() )
DemSliders[k].OnValueChanged = function( item, value )
NewTractionData[ k ] = value
end
y = y + 25
end
y = y + 30
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( self.PropPanel )
DermaButton:SetText( "Apply" )
DermaButton:SetPos( 25, y - 10 )
DermaButton:SetSize( 340, 25 )
DermaButton.DoClick = function()
net.Start("simfphys_settings")
net.WriteBool( CheckBoxDamage:GetChecked() )
net.WriteFloat( GibRemoveTimer:GetValue() )
net.WriteFloat( DamageMul:GetValue() )
net.WriteBool( CheckBoxpDamage:GetChecked() )
net.WriteBool( CheckBoxFuel:GetChecked() )
net.WriteFloat( ScaleFuel:GetValue() )
net.WriteTable( NewTractionData )
net.SendToServer()
end
y = y + 30
local DermaButton = vgui.Create( "DButton" )
DermaButton:SetParent( self.PropPanel )
DermaButton:SetText( "Reset" )
DermaButton:SetPos( 25, y - 10 )
DermaButton:SetSize( 340, 25 )
DermaButton.DoClick = function()
NewTractionData["ice"] = 0.35
NewTractionData["gmod_ice"] = 0.1
NewTractionData["slipperyslime"] = 0.2
NewTractionData["snow"] = 0.7
NewTractionData["grass"] = 1
NewTractionData["sand"] = 1
NewTractionData["dirt"] = 1
NewTractionData["concrete"] = 1
NewTractionData["metal"] = 1
NewTractionData["glass"] = 1
NewTractionData["gravel"] = 1
NewTractionData["rock"] = 1
NewTractionData["wood"] = 1
for k, v in pairs( NewTractionData ) do
DemSliders[k]:SetValue( v )
end
CheckBoxDamage:SetValue( 1 )
GibRemoveTimer:SetValue( 120 )
DamageMul:SetValue( 1 )
CheckBoxpDamage:SetValue( 1 )
CheckBoxFuel:SetValue( 1 )
ScaleFuel:SetValue( 0.1 )
net.Start("simfphys_settings")
net.WriteBool( true )
net.WriteFloat( 120 )
net.WriteFloat( 1 )
net.WriteBool( true )
net.WriteBool( true )
net.WriteFloat( 0.1 )
net.WriteTable( NewTractionData )
net.SendToServer()
end
else
y = y + 25
local Label = vgui.Create( "DLabel", self.PropPanel )
Label:SetPos( 30, y )
Label:SetText( "Damage is "..((GetConVar( "sv_simfphys_enabledamage" ):GetInt() > 0) and "enabled" or "disabled") )
Label:SizeToContents()
y = y + 25
local Label = vgui.Create( "DLabel", self.PropPanel )
Label:SetPos( 30, y )
Label:SetText( "Damage Multiplicator is: "..GetConVar( "sv_simfphys_damagemultiplicator" ):GetFloat() )
Label:SizeToContents()
y = y + 25
local yes = "Players can take damage from collisions"
local no = "Players can't take damage from collisions"
local Label = vgui.Create( "DLabel", self.PropPanel )
Label:SetPos( 30, y )
Label:SetText( GetConVar( "sv_simfphys_playerdamage" ):GetBool() and yes or no )
Label:SizeToContents()
y = y + 25
local Label = vgui.Create( "DLabel", self.PropPanel )
local lifetime = GetConVar( "sv_simfphys_gib_lifetime" ):GetInt()
Label:SetPos( 30, y )
Label:SetText( (lifetime > 0) and ("Gib Lifetime = "..lifetime.." seconds") or "Gibs never despawn" )
Label:SizeToContents()
y = y + 25
local Label = vgui.Create( "DLabel", self.PropPanel )
Label:SetPos( 30, y )
Label:SetText( "Vehicles "..(GetConVar( "sv_simfphys_fuel" ):GetBool() and "are running on fuel" or "don't use fuel") )
Label:SizeToContents()
y = y + 25
local Label = vgui.Create( "DLabel", self.PropPanel )
local fuelscale = math.Round( GetConVar( "sv_simfphys_fuelscale" ):GetFloat() , 3 )
Label:SetPos( 30, y )
Label:SetText( "Fuel tank size multiplier is: "..fuelscale )
Label:SizeToContents()
if GetConVar( "sv_simfphys_teampassenger" ):GetBool() then
y = y + 25
local Label = vgui.Create( "DLabel", self.PropPanel )
Label:SetPos( 30, y )
Label:SetText( "Only players of the same team can enter the same vehicle" )
Label:SizeToContents()
end
y = y + 40
local Label = vgui.Create( "DLabel", self.PropPanel )
Label:SetPos( 30, y )
Label:SetText( "Traction multiplier for..." )
Label:SizeToContents()
y = y + 15
for k, v in pairs( simfphys.TractionData ) do
local tractionLabel = vgui.Create( "DLabel", self.PropPanel )
tractionLabel:SetPos( 105, y )
tractionLabel:SetText( k )
tractionLabel:SizeToContents()
local tractionLabel = vgui.Create( "DLabel", self.PropPanel )
tractionLabel:SetPos( 170, y )
tractionLabel:SetText( "=" )
tractionLabel:SizeToContents()
local tractionLabel = vgui.Create( "DLabel", self.PropPanel )
tractionLabel:SetPos( 185, y )
tractionLabel:SetText( math.Round(v,2) )
tractionLabel:SizeToContents()
y = y + 25
end
y = y - 25
end
Background:SetSize( 350, y )
end
hook.Add( "LVS.PopulateVehicles", "!!!add_simfphys_vehicles", function( node, pnlContent, _ )
local tree = node:AddNode( "simfphys", "icon16/simfphys.png" )
local Categorised = {}
-- Add this list into the tormoil
local Vehicles = list.Get( "simfphys_vehicles" )
if Vehicles then
for k, v in pairs( Vehicles ) do
v.Category = v.Category or "Other"
Categorised[ v.Category ] = Categorised[ v.Category ] or {}
v.ClassName = k
v.PrintName = v.Name
table.insert( Categorised[ v.Category ], v )
end
end
--
-- Add a tree node for each category
--
local IconList = list.Get( "ContentCategoryIcons" )
for CategoryName, v in SortedPairs( Categorised ) do
local node
if CategoryName == "Base" then
node = tree
else
local Icon = "icon16/simfphys_noicon.png"
if IconList and IconList[ "[simfphys] - "..CategoryName ] then
Icon = IconList[ "[simfphys] - "..CategoryName ]
end
-- Add a node to the tree
node = tree:AddNode( CategoryName, Icon )
end
-- When we click on the node - populate it using this function
node.DoPopulate = function( self )
-- If we've already populated it - forget it.
if self.PropPanel then return end
-- Create the container panel
self.PropPanel = vgui.Create( "ContentContainer", pnlContent )
self.PropPanel:SetVisible( false )
self.PropPanel:SetTriggerSpawnlistChange( false )
for k, ent in SortedPairsByMemberValue( v, "PrintName" ) do
spawnmenu.CreateContentIcon( "simfphys_vehicles", self.PropPanel, {
nicename = ent.PrintName or ent.ClassName,
spawnname = ent.ClassName,
material = "entities/"..ent.ClassName..".png",
admin = ent.AdminOnly
} )
end
end
-- If we click on the node populate it and switch to it.
node.DoClick = function( self )
self:DoPopulate()
pnlContent:SwitchPanel( self.PropPanel )
end
end
-- JOYSTICK
if istable( jcon ) and file.Exists("lua/bin/gmcl_joystick_win32.dll", "GAME") then
local node = tree:AddNode( "Joystick Configuration", "icon16/joystick.png" )
node.DoClick = function( self )
RunConsoleCommand("joyconfig")
end
end
-- CLIENT SETTINGS
local node = tree:AddNode( "Preferences", "icon16/ruby.png" )
node.DoPopulate = function( self )
if self.PropPanel then return end
self.PropPanel = vgui.Create( "ContentContainer", pnlContent )
self.PropPanel:SetVisible( false )
self.PropPanel:SetTriggerSpawnlistChange( false )
buildclientsettingsmenu( self )
end
node.DoClick = function( self )
self:DoPopulate()
pnlContent:SwitchPanel( self.PropPanel )
end
-- SERVER SETTINGS
local node = tree:AddNode( "Settings", "icon16/shield.png" )
node.DoPopulate = function( self )
self.PropPanel = vgui.Create( "ContentContainer", pnlContent )
self.PropPanel:SetVisible( false )
self.PropPanel:SetTriggerSpawnlistChange( false )
buildserversettingsmenu( self )
end
node.DoClick = function( self )
self:DoPopulate()
pnlContent:SwitchPanel( self.PropPanel )
end
-- call original hook
hook.Run( "SimfphysPopulateVehicles", pnlContent, tree, node )
end )
spawnmenu.AddContentType( "simfphys_vehicles", function( container, obj )
if not obj.material then return end
if not obj.nicename then return end
if not obj.spawnname then return end
local icon = vgui.Create( "ContentIcon", container )
icon:SetContentType( "simfphys_vehicles" )
icon:SetSpawnName( obj.spawnname )
icon:SetName( obj.nicename )
icon:SetMaterial( obj.material )
icon:SetAdminOnly( obj.admin )
icon:SetColor( Color( 0, 0, 0, 255 ) )
icon.DoClick = function()
RunConsoleCommand( "simfphys_spawnvehicle", obj.spawnname )
surface.PlaySound( "ui/buttonclickrelease.wav" )
end
icon.OpenMenu = function( icon )
local menu = DermaMenu()
menu:AddOption( "Copy to Clipboard", function() SetClipboardText( obj.spawnname ) end )
--menu:AddSpacer()
--menu:AddOption( "Delete", function() icon:Remove() hook.Run( "SpawnlistContentChanged", icon ) end )
menu:Open()
end
if IsValid( container ) then
container:Add( icon )
end
return icon
end )
list.Set( "ContentCategoryIcons", "simfphys", "icon16/simfphys.png" )
list.Set( "ContentCategoryIcons", "[simfphys]", "icon16/simfphys.png" )
list.Set( "ContentCategoryIcons", "[simfphys] - Half Life 2 - Prewar", "icon16/simfphys_prewar.png" )
list.Set( "ContentCategoryIcons", "[simfphys] - Half Life 2 / Synergy", "icon16/simfphys_hl2.png" )
list.Set( "ContentCategoryIcons", "[simfphys] - Armed Vehicles", "icon16/simfphys_armed.png" )

View File

@@ -0,0 +1,218 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
simfphys.jcon = {}
hook.Add("JoystickInitialize", "simfphys_joystick", function()
simfphys.jcon.steer_left = jcon.register{
uid = "joystick_steer_left",
type = "analog",
description = "Steer Left",
category = "Simfphys",
}
simfphys.jcon.steer_right = jcon.register{
uid = "joystick_steer_right",
type = "analog",
description = "Steer Right",
category = "Simfphys",
}
simfphys.jcon.throttle = jcon.register{
uid = "joystick_throttle",
type = "analog",
description = "Throttle",
category = "Simfphys",
}
simfphys.jcon.brake = jcon.register{
uid = "joystick_brake",
type = "analog",
description = "Brake",
category = "Simfphys",
}
simfphys.jcon.gearup = jcon.register{
uid = "joystick_gearup",
type = "digital",
description = "Gear Up",
category = "Simfphys",
}
simfphys.jcon.geardown = jcon.register{
uid = "joystick_geardown",
type = "digital",
description = "Gear Down",
category = "Simfphys",
}
simfphys.jcon.handbrake = jcon.register{
uid = "joystick_handbrake",
type = "digital",
description = "Handbrake",
category = "Simfphys",
}
simfphys.jcon.clutch = jcon.register{
uid = "joystick_clutch",
type = "analog",
description = "Clutch",
category = "Simfphys",
}
simfphys.jcon.air_forward = jcon.register{
uid = "joystick_air_w",
type = "analog",
description = "Air (forward)",
category = "Simfphys",
}
simfphys.jcon.air_reverse = jcon.register{
uid = "joystick_air_s",
type = "analog",
description = "Air (backward)",
category = "Simfphys",
}
simfphys.jcon.air_left = jcon.register{
uid = "joystick_air_a",
type = "analog",
description = "Air (left)",
category = "Simfphys",
}
simfphys.jcon.air_right = jcon.register{
uid = "joystick_air_d",
type = "analog",
description = "Air (right)",
category = "Simfphys",
}
simfphys.jcon.gear_n = jcon.register{
uid = "joystick_gear_n",
type = "digital",
description = "Gear Neutral",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_1 = jcon.register{
uid = "joystick_gear_1",
type = "digital",
description = "Gear 1",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_2 = jcon.register{
uid = "joystick_gear_2",
type = "digital",
description = "Gear 2",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_3 = jcon.register{
uid = "joystick_gear_3",
type = "digital",
description = "Gear 3",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_4 = jcon.register{
uid = "joystick_gear_4",
type = "digital",
description = "Gear 4",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_5 = jcon.register{
uid = "joystick_gear_5",
type = "digital",
description = "Gear 5",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_6 = jcon.register{
uid = "joystick_gear_6",
type = "digital",
description = "Gear 6",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_7 = jcon.register{
uid = "joystick_gear_7",
type = "digital",
description = "Gear 7",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_8 = jcon.register{
uid = "joystick_gear_8",
type = "digital",
description = "Gear 8",
category = "Simfphys (Gears)",
}
simfphys.jcon.gear_r = jcon.register{
uid = "joystick_gear_r",
type = "digital",
description = "Gear Reverse",
category = "Simfphys (Gears)",
}
hook.Add("Think","simfphys_joystickhandler",function()
for i,ply in pairs( player.GetAll() ) do
if ply:IsConnected() then
local vehicle = ply:GetVehicle()
if not IsValid( vehicle ) then return end
if not vehicle.fphysSeat then return end
if vehicle.base:GetDriverSeat() ~= vehicle then return end
for k,v in pairs( simfphys.jcon ) do
if istable(v) and v.IsJoystickReg then
local val = joystick.Get( ply, v.uid )
if v.type == "analog" then
vehicle.base.PressedKeys[v.uid] = val and val / 255 or 0
else
if string.StartWith( v.uid, "joystick_gear_" ) then
if v.uid == "joystick_gear_r" then
if val then
vehicle.base:ForceGear( 1 )
end
elseif v.uid == "joystick_gear_n" then
if val then
vehicle.base:ForceGear( 2 )
end
else
for i = 1, 8 do
if v.uid == ("joystick_gear_"..i) then
if val then
vehicle.base:ForceGear( i + 2 )
end
break
end
end
end
else
vehicle.base.PressedKeys[v.uid] = val and 1 or 0
end
end
end
end
end
end
end)
end)

View File

@@ -0,0 +1,43 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
util.AddNetworkString( "simfphys_request_ppdata" )
util.AddNetworkString( "simfphys_send_ppdata" )
local function sendppdata( length, ply )
local ent = net.ReadEntity()
if not IsValid( ent ) then return end
if ent.IsInitialized and not ent:IsInitialized() then return end
if not istable( ent.Wheels ) then return end
net.Start( "simfphys_send_ppdata", true )
net.WriteEntity( ent )
net.WriteBool( ent.CustomWheels )
net.WriteEntity( ent.Wheels[1] )
net.WriteFloat( ent.posepositions.PoseL_Pos_FL.z )
net.WriteFloat( ent.VehicleData.suspensiontravel_fl )
net.WriteEntity( ent.Wheels[2] )
net.WriteFloat( ent.posepositions.PoseL_Pos_FR.z )
net.WriteFloat( ent.VehicleData.suspensiontravel_fr )
net.WriteEntity( ent.Wheels[3] )
net.WriteFloat( ent.posepositions.PoseL_Pos_RL.z )
net.WriteFloat( ent.VehicleData.suspensiontravel_rl )
net.WriteEntity( ent.Wheels[4] )
net.WriteFloat( ent.posepositions.PoseL_Pos_RR.z )
net.WriteFloat( ent.VehicleData.suspensiontravel_rr )
net.Send( ply )
end
net.Receive("simfphys_request_ppdata", sendppdata)

View File

@@ -0,0 +1,61 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
function SpawnSimfphysVehicle( Player, vname, tr )
if not vname then return end
local Tickrate = 1 / engine.TickInterval()
if ( Tickrate <= 25 ) and not Player.IsInformedAboutTheServersLowTickrate then
Player:PrintMessage( HUD_PRINTTALK, "(SIMFPHYS) WARNING! Server tickrate is "..Tickrate.." we recommend 33 or greater for this addon to work properly!")
Player:PrintMessage( HUD_PRINTTALK, "Known problems caused by a too low tickrate:")
Player:PrintMessage( HUD_PRINTTALK, "- Wobbly suspension")
Player:PrintMessage( HUD_PRINTTALK, "- Wheelspazz or shaking after an crash on bumps or while drifting")
Player:PrintMessage( HUD_PRINTTALK, "- Moondrive (wheels turning slower than they should)")
Player:PrintMessage( HUD_PRINTTALK, "- Worse vehicle performance (less grip, slower accelerating)")
Player.IsInformedAboutTheServersLowTickrate = true
end
local VehicleList = list.Get( "simfphys_vehicles" )
local vehicle = VehicleList[ vname ]
if not vehicle then return end
if not tr then
tr = Player:GetEyeTraceNoCursor()
end
local Angles = Player:GetAngles()
Angles.pitch = 0
Angles.roll = 0
Angles.yaw = Angles.yaw + 180 + (vehicle.SpawnAngleOffset and vehicle.SpawnAngleOffset or 0)
local pos = tr.HitPos + Vector(0,0,25) + (vehicle.SpawnOffset or Vector(0,0,0))
local Ent = simfphys.SpawnVehicle( Player, pos, Angles, vehicle.Model, vehicle.Class, vname, vehicle )
if not IsValid( Ent ) then return end
undo.Create( "Vehicle" )
undo.SetPlayer( Player )
undo.AddEntity( Ent )
undo.SetCustomUndoText( "Undone " .. vehicle.Name )
undo.Finish( "Vehicle (" .. tostring( vehicle.Name ) .. ")" )
Player:AddCleanup( "vehicles", Ent )
end
concommand.Add( "simfphys_spawnvehicle", function( ply, cmd, args ) SpawnSimfphysVehicle( ply, args[1] ) end )
local function VehicleMemDupe( Player, Entity, Data )
table.Merge( Entity, Data )
end
duplicator.RegisterEntityModifier( "VehicleMemDupe", VehicleMemDupe )

View File

@@ -0,0 +1,413 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
-- 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
simfphys = istable( simfphys ) and simfphys or {}
simfphys.ManagedVehicles = istable( simfphys.ManagedVehicles ) and simfphys.ManagedVehicles or {}
simfphys.Weapons = {}
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",
"physics/metal/metal_sheet_impact_hard6.wav",
}
sound.Add( {
name = "apc_fire",
channel = CHAN_WEAPON,
volume = 1.0,
level = 110,
pitch = { 90, 110 },
sound = "^simulated_vehicles/weapons/apc_fire.wav"
} )
sound.Add( {
name = "tiger_fire",
channel = CHAN_ITEM,
volume = 1.0,
level = 140,
pitch = { 90, 110 },
sound = "^simulated_vehicles/weapons/tiger_cannon.wav"
} )
sound.Add( {
name = "leopard_fire",
channel = CHAN_ITEM,
volume = 1.0,
level = 140,
pitch = { 90, 110 },
sound = "^simulated_vehicles/weapons/leopard_cannon.wav"
} )
sound.Add( {
name = "leopard_fire_mg",
channel = CHAN_WEAPON,
volume = 1.0,
level = 110,
pitch = { 90, 100 },
sound = {"^simulated_vehicles/weapons/leopard_mg1.wav","^simulated_vehicles/weapons/leopard_mg2.wav","^simulated_vehicles/weapons/leopard_mg3.wav"}
} )
sound.Add( {
name = "t90ms_fire",
channel = CHAN_ITEM,
volume = 1.0,
level = 140,
pitch = { 90, 110 },
sound = "^simulated_vehicles/weapons/t90ms_cannon.wav"
} )
sound.Add( {
name = "tiger_fire_mg",
channel = CHAN_WEAPON,
volume = 1.0,
level = 110,
pitch = { 90, 110 },
sound = "^simulated_vehicles/weapons/tiger_mg.wav"
} )
sound.Add( {
name = "tiger_fire_mg_new",
channel = CHAN_WEAPON,
volume = 1.0,
level = 110,
pitch = { 90, 110 },
sound = {"^simulated_vehicles/weapons/tiger_mg1.wav","^simulated_vehicles/weapons/tiger_mg2.wav","^simulated_vehicles/weapons/tiger_mg3.wav"}
} )
sound.Add( {
name = "tiger_reload",
channel = CHAN_STREAM,
volume = 1.0,
level = 70,
pitch = { 90, 110 },
sound = "simulated_vehicles/weapons/tiger_reload.wav"
} )
sound.Add( {
name = "sherman_fire",
channel = CHAN_ITEM,
volume = 1.0,
level = 140,
pitch = { 90, 110 },
sound = "^simulated_vehicles/weapons/sherman_cannon.wav"
} )
sound.Add( {
name = "sherman_fire_mg",
channel = CHAN_WEAPON,
volume = 1.0,
level = 110,
pitch = { 90, 110 },
sound = "^simulated_vehicles/weapons/sherman_mg.wav"
} )
sound.Add( {
name = "sherman_reload",
channel = CHAN_STREAM,
volume = 1.0,
level = 70,
pitch = { 90, 110 },
sound = "simulated_vehicles/weapons/sherman_reload.wav"
} )
sound.Add( {
name = "t90ms_reload",
channel = CHAN_STREAM,
volume = 1.0,
level = 70,
pitch = { 90, 110 },
sound = "simulated_vehicles/weapons/t90ms_reload.wav"
} )
sound.Add( {
name = "taucannon_fire",
channel = CHAN_WEAPON,
volume = 1.0,
level = 80,
pitch = { 95, 105 },
sound = "weapons/gauss/fire1.wav"
} )
-- seriously guys, you are not supposed to copy this script. I had to create this workaround because people keep stealing the entire code.
function simfphys.FireHitScan( data )
simfphys.FireBullet( data )
end
function simfphys.FirePhysProjectile( data )
simfphys.FirePhysBullet( data )
end
function simfphys.RegisterCrosshair( ent, data )
simfphys.xhairRegister( ent, data )
end
function simfphys.RegisterCamera( ent, offset_firstperson, offset_thirdperson, bLocalAng, attachment )
simfphys.CameraRegister( ent, offset_firstperson, offset_thirdperson, bLocalAng, attachment )
end
function simfphys.armedAutoRegister( vehicle )
simfphys.WeaponSystemRegister( vehicle )
return true
end
function simfphys.CameraRegister( ent, offset_firstperson, offset_thirdperson, bLocalAng, attachment )
if not IsValid( ent ) then return end
offset_firstperson = isvector( offset_firstperson ) and offset_firstperson or Vector(0,0,0)
offset_thirdperson = isvector( offset_thirdperson ) and offset_thirdperson or Vector(0,0,0)
ent:SetNWBool( "simfphys_SpecialCam", true )
ent:SetNWBool( "SpecialCam_LocalAngles", bLocalAng or false )
ent:SetNWVector( "SpecialCam_Firstperson", offset_firstperson )
ent:SetNWVector( "SpecialCam_Thirdperson", offset_thirdperson )
if isstring( attachment ) then
ent:SetNWString( "SpecialCam_Attachment", attachment )
end
end
function simfphys.FirePhysBullet( data )
if not data then return end
if not istable( data.filter ) then return end
if not isvector( data.shootOrigin ) then return end
if not isvector( data.shootDirection ) then return end
if not IsValid( data.attacker ) then return end
if not IsValid( data.attackingent ) then return end
if not isnumber( data.DeflectAng ) then data.DeflectAng = 25 end
local projectile = ents.Create( "simfphys_tankprojectile" )
projectile:SetPos( data.shootOrigin )
projectile:SetAngles( data.shootDirection:Angle() )
projectile:SetOwner( data.attackingent )
projectile.Attacker = data.attacker
projectile.DeflectAng = data.DeflectAng
projectile.AttackingEnt = data.attackingent
projectile.Force = data.Force and data.Force or 100
projectile.Damage = data.Damage and data.Damage or 100
projectile.BlastRadius = data.BlastRadius and data.BlastRadius or 200
projectile.BlastDamage = data.BlastDamage and data.BlastDamage or 50
projectile:SetBlastEffect( isstring( data.BlastEffect ) and data.BlastEffect or "simfphys_tankweapon_explosion" )
projectile:SetSize( data.Size and data.Size or 1 )
projectile.Filter = table.Copy( data.filter )
projectile:Spawn()
projectile:Activate()
end
function simfphys.FireBullet( data )
if not data then return end
if not istable( data.filter ) then return end
if not isvector( data.shootOrigin ) then return end
if not isvector( data.shootDirection ) then return end
if not IsValid( data.attacker ) then return end
if not IsValid( data.attackingent ) then return end
local bullet = {}
bullet.Num = 1
bullet.Src = data.shootOrigin
bullet.Dir = data.shootDirection
bullet.Spread = data.Spread
bullet.TracerName = "lvs_tracer_white"
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.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 )
end
LVS:FireBullet( bullet )
end
function simfphys.xhairRegister( ent, data )
if not IsValid( ent ) then return end
local data = istable( data ) and data or {}
local Base = data.Attachment or "muzzle"
local Dir = data.Direction or Vector(1,0,0)
local Type = data.Type and data.Type or 0
ent:SetNWInt( "CrosshairType", Type )
ent:SetNWBool( "HasCrosshair", true )
ent:SetNWString( "Attachment", Base )
ent:SetNWVector( "Direction", Dir )
if data.Attach_Start_Left and data.Attach_Start_Right then
ent:SetNWBool( "CalcCenterPos", true )
ent:SetNWString( "Start_Left", data.Attach_Start_Left )
ent:SetNWString( "Start_Right", data.Attach_Start_Right )
end
end
function simfphys.WeaponSystemRegister( vehicle )
if not IsValid( vehicle ) then return end
simfphys.Weapons = istable( simfphys.Weapons ) and table.Empty( simfphys.Weapons ) or {}
for k,v in pairs( file.Find("simfphys_weapons/*.lua", "LUA") ) do
local name = string.Explode( ".", v )[1]
table.Empty( simfphys.weapon )
include("simfphys_weapons/"..v)
simfphys.Weapons[ name ] = table.Copy( simfphys.weapon )
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
local data = {}
data.entity = vehicle
data.func = tbldata
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
end
local DMG_PROPEXPLOSION = 134217792 -- should use CTakeDamageInfo:IsDamageType( number dmgType ) at some point
local DMG_LUABULLET = 8194
local DMGTypeException = {
[DMG_LUABULLET] = true,
[DMG_BULLET] = true,
}
local IsValidDMGType = {
[DMG_PROPEXPLOSION] = true,
[DMG_BLAST] = true,
[DMG_BLAST_SURFACE] = true,
[DMG_ENERGYBEAM] = true,
[DMG_SHOCK] = true,
[DMG_CRUSH] = true,
[DMG_GENERIC] = true,
[DMG_DIRECT] = true,
[DMG_SLOWBURN] = true,
[DMG_BURN] = true,
[DMG_NEVERGIB] = true,
[DMG_ALWAYSGIB] = true,
[DMG_SNIPER] = true,
[DMG_CLUB] = true,
[DMG_MISSILEDEFENSE] = true,
}
function simfphys.TankApplyDamage(ent, Damage, Type)
if not IsValid( ent ) or not isnumber( Damage ) or not isnumber( Type ) then return end
if Type == DMG_PROPEXPLOSION then Damage = Damage * 10 end
if IsValidDMGType[ Type ] or (DMGTypeException[ Type ] and Damage > 100) then
if DMGTypeException[ Type ] then
Damage = Damage - 100
end
local MaxHealth = ent:GetMaxHealth()
local CurHealth = ent:GetCurHealth()
local NewHealth = math.max( math.Round(CurHealth - Damage,0) , 0 )
if NewHealth <= (MaxHealth * 0.6) then
if NewHealth <= (MaxHealth * 0.3) then
ent:SetOnFire( true )
ent:SetOnSmoke( false )
else
ent:SetOnSmoke( true )
end
end
if MaxHealth > 30 and NewHealth <= 31 then
if ent:EngineActive() then
ent:DamagedStall()
end
end
if NewHealth <= 0 then
if (Type ~= DMG_GENERIC and Type ~= DMG_CRUSH) or Damage > MaxHealth then
ent:ExplodeVehicle()
return
end
if ent:EngineActive() then
ent:DamagedStall()
end
ent:SetCurHealth( 0 )
return
end
ent:SetCurHealth( NewHealth )
end
end
hook.Add("Think", "simfphys_weaponhandler", function()
if simfphys.ManagedVehicles then
for k, v in pairs( simfphys.ManagedVehicles ) do
if IsValid( v.entity ) then
if v.func then
v.func.Think( v.func,v.entity )
end
else
simfphys.ManagedVehicles[k] = nil
end
end
end
end)