add sborka

This commit is contained in:
2026-03-31 10:27:04 +03:00
commit f5e5f56c84
2345 changed files with 382127 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
TOOL.Category = "LVS"
TOOL.Name = "#AI Enabler"
TOOL.Command = nil
TOOL.ConfigName = ""
TOOL.ClientConVar[ "team" ] = "-1"
if CLIENT then
language.Add( "tool.lvsaienabler.name", "AI Enabler" )
language.Add( "tool.lvsaienabler.desc", "A tool used to enable/disable AI on LVS-Vehicles" )
language.Add( "tool.lvsaienabler.0", "Left click on a LVS-Vehicle to enable AI, Right click to disable." )
language.Add( "tool.lvsaienabler.1", "Left click on a LVS-Vehicle to enable AI, Right click to disable." )
end
function TOOL:LeftClick( trace )
local ent = trace.Entity
if not IsValid( ent ) then return false end
if not ent.LVS and not ent.LFS then return end
if isfunction( ent.SetAI ) then
ent:SetAI( true )
end
if SERVER then
local Team = self:GetClientNumber( "team" )
if Team ~= -1 then
ent:SetAITEAM( math.Clamp( Team, 0, 3 ) )
end
end
return true
end
function TOOL:RightClick( trace )
local ent = trace.Entity
if not IsValid( ent ) then return false end
if not ent.LVS and not ent.LFS then return end
if isfunction( ent.SetAI ) then
ent:SetAI( false )
end
return true
end
function TOOL:Reload( trace )
return false
end
function TOOL.BuildCPanel( CPanel )
CPanel:AddControl( "Header", { Text = "#tool.lvsaienabler.name", Description = "#tool.lvsaienabler.desc" } )
CPanel:AddControl( "Slider", { Label = "TeamOverride", Type = "Int", Min = -1, Max = 3, Command = "lvsaienabler_team" } )
end

View File

@@ -0,0 +1,98 @@
TOOL.Category = "LVS"
TOOL.Name = "#Engine Swap"
TOOL.Information = {
{ name = "left" },
{ name = "right" },
}
if CLIENT then
language.Add( "tool.lvscarengineswap.name", "Engine Swap" )
language.Add( "tool.lvscarengineswap.desc", "A tool used to swap engine sounds on [LVS] - Cars" )
language.Add( "tool.lvscarengineswap.left", "Apply Engine Sound" )
language.Add( "tool.lvscarengineswap.right", "Copy Engine Sound" )
end
local function SwapEngine( ent, data )
if not IsValid( ent ) or not istable( data ) then return end
local originalEngine = ent:GetEngine()
if not IsValid( originalEngine ) then return end
local Engine = ents.Create( "lvs_wheeldrive_engine_swapped" )
Engine:SetPos( originalEngine:GetPos() )
Engine:SetAngles( originalEngine:GetAngles() )
Engine:Spawn()
Engine:Activate()
Engine:SetParent( ent )
Engine:SetBase( ent )
Engine.EngineSounds = data
Engine:SetDoorHandler( originalEngine:GetDoorHandler() )
ent:SetEngine( Engine )
ent:DeleteOnRemove( Engine )
ent:TransferCPPI( Engine )
originalEngine:Remove()
if not duplicator or not duplicator.StoreEntityModifier then return end
duplicator.StoreEntityModifier( ent, "lvsCarSwapEngine", data )
end
local function DuplicatorSwapEngine( ply, ent, data )
timer.Simple(0.1, function()
if not IsValid( ent ) then return end
SwapEngine( ent, data )
end )
end
if duplicator and duplicator.RegisterEntityModifier then
duplicator.RegisterEntityModifier( "lvsCarSwapEngine", DuplicatorSwapEngine )
end
function TOOL:SwapEngine( ent )
if CLIENT then return end
SwapEngine( ent, self.EngineSounds )
end
function TOOL:IsValidTarget( ent )
if not IsValid( ent ) then return false end
if not ent.LVS or not ent.lvsAllowEngineTool then return false end
return true
end
function TOOL:LeftClick( trace )
if not self.EngineSounds then return false end
local ent = trace.Entity
if not self:IsValidTarget( ent ) then return false end
self:SwapEngine( ent )
return true
end
function TOOL:RightClick( trace )
local ent = trace.Entity
if not self:IsValidTarget( ent ) then return false end
self.EngineSounds = ent.EngineSounds
return true
end
function TOOL:Reload( trace )
return false
end

View File

@@ -0,0 +1,83 @@
TOOL.Category = "LVS"
TOOL.Name = "#Tuning Remover"
TOOL.Information = {
{ name = "left" },
{ name = "right" },
}
if CLIENT then
language.Add( "tool.lvscartuningremover.name", "Tuning Remover" )
language.Add( "tool.lvscartuningremover.desc", "A tool used to remove Turbo + Compressor on [LVS-Cars]" )
language.Add( "tool.lvscartuningremover.left", "Remove Turbo" )
language.Add( "tool.lvscartuningremover.right", "Remove Compressor" )
end
function TOOL:IsValidTarget( ent )
if not IsValid( ent ) then return false end
if not ent.LVS or not ent.GetCompressor or not ent.GetTurbo then return false end
return true
end
local function DoRemoveEntity( ent )
timer.Simple( 1, function() if ( IsValid( ent ) ) then ent:Remove() end end )
ent:SetNotSolid( true )
ent:SetMoveType( MOVETYPE_NONE )
ent:SetNoDraw( true )
local ed = EffectData()
ed:SetOrigin( ent:GetPos() )
ed:SetEntity( ent )
util.Effect( "entity_remove", ed, true, true )
end
function TOOL:LeftClick( trace )
local ent = trace.Entity
if not self:IsValidTarget( ent ) then return false end
local Turbo = ent:GetTurbo()
local Compressor = ent:GetCompressor()
local Removed = false
if IsValid( Turbo ) and not Turbo._RemoveRememberThis then
Turbo._RemoveRememberThis = true
if SERVER then DoRemoveEntity( Turbo ) end
Removed = true
end
return Removed
end
function TOOL:RightClick( trace )
local ent = trace.Entity
if not self:IsValidTarget( ent ) then return false end
local Turbo = ent:GetTurbo()
local Compressor = ent:GetCompressor()
local Removed = false
if IsValid( Compressor ) and not Compressor._RemoveRememberThis then
Compressor._RemoveRememberThis = true
if SERVER then DoRemoveEntity( Compressor ) end
Removed = true
end
return Removed
end
function TOOL:Reload( trace )
return false
end

View File

@@ -0,0 +1,578 @@
TOOL.Category = "LVS"
TOOL.Name = "#Wheel Editor"
TOOL.ClientConVar[ "model" ] = "models/props_vehicles/carparts_wheel01a.mdl"
TOOL.ClientConVar[ "camber" ] = 0
TOOL.ClientConVar[ "caster" ] = 0
TOOL.ClientConVar[ "toe" ] = 0
TOOL.ClientConVar[ "height" ] = 0
TOOL.ClientConVar[ "stiffness" ] = 0
TOOL.ClientConVar[ "skin" ] = 0
TOOL.ClientConVar[ "bodygroup0" ] = 0
TOOL.ClientConVar[ "bodygroup1" ] = 0
TOOL.ClientConVar[ "bodygroup2" ] = 0
TOOL.ClientConVar[ "bodygroup3" ] = 0
TOOL.ClientConVar[ "bodygroup4" ] = 0
TOOL.ClientConVar[ "bodygroup5" ] = 0
TOOL.ClientConVar[ "bodygroup6" ] = 0
TOOL.ClientConVar[ "bodygroup7" ] = 0
TOOL.ClientConVar[ "bodygroup8" ] = 0
TOOL.ClientConVar[ "bodygroup9" ] = 0
TOOL.ClientConVar[ "pp0" ] = 0
TOOL.ClientConVar[ "pp1" ] = 0
TOOL.ClientConVar[ "pp2" ] = 0
TOOL.ClientConVar[ "pp3" ] = 0
TOOL.ClientConVar[ "pp4" ] = 0
TOOL.ClientConVar[ "pp5" ] = 0
TOOL.ClientConVar[ "pp6" ] = 0
TOOL.ClientConVar[ "pp7" ] = 0
TOOL.ClientConVar[ "pp8" ] = 0
TOOL.ClientConVar[ "pp9" ] = 0
TOOL.ClientConVar[ "r" ] = 255
TOOL.ClientConVar[ "g" ] = 255
TOOL.ClientConVar[ "b" ] = 255
TOOL.ClientConVar[ "a" ] = 255
TOOL.Information = {
{ name = "left" },
{ name = "right" },
{ name = "reload" }
}
if CLIENT then
language.Add( "tool.lvscarwheelchanger.name", "Wheel Editor" )
language.Add( "tool.lvscarwheelchanger.desc", "A tool used to edit [LVS-Cars] Wheels" )
language.Add( "tool.lvscarwheelchanger.left", "Apply wheel. Click again to flip 180 degrees" )
language.Add( "tool.lvscarwheelchanger.right", "Copy wheel" )
language.Add( "tool.lvscarwheelchanger.reload", "Apply camber/caster/toe/height/stiffness. Click again to flip camber and toe" )
local ContextMenuPanel
local skins = 0
local bodygroups = {}
local poseparameters = {}
local ConVarsDefault = TOOL:BuildConVarList()
local function BuildContextMenu()
if not IsValid( ContextMenuPanel ) then return end
ContextMenuPanel:Clear()
if IsValid( ContextMenuPanel.modelpanel ) then
ContextMenuPanel.modelpanel:Remove()
end
ContextMenuPanel:AddControl( "Header", { Text = "#tool.lvscarwheelchanger.name", Description = "#tool.lvscarwheelchanger.desc" } )
ContextMenuPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "lvswheels", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
ContextMenuPanel:ColorPicker( "Wheel Color", "lvscarwheelchanger_r", "lvscarwheelchanger_g", "lvscarwheelchanger_b", "lvscarwheelchanger_a" )
if skins > 0 then
ContextMenuPanel:AddControl( "Label", { Text = "" } )
ContextMenuPanel:AddControl( "Label", { Text = "Skins" } )
ContextMenuPanel:AddControl("Slider", { Label = "Skin", Type = "int", Min = "0", Max = tostring( skins ), Command = "lvscarwheelchanger_skin" } )
end
local icon = vgui.Create( "DModelPanel", ContextMenuPanel )
icon:SetSize(200,200)
icon:SetFOV( 30 )
icon:SetAnimated( true )
icon:SetModel( GetConVar( "lvscarwheelchanger_model" ):GetString() )
icon:Dock( TOP )
icon:SetCamPos( Vector(80,0,0) )
icon:SetLookAt( vector_origin )
icon.Angles = angle_zero
function icon:DragMousePress()
self.PressX, self.PressY = gui.MousePos()
self.Pressed = true
end
function icon:DragMouseRelease()
self.Pressed = false
end
function icon:LayoutEntity( ent )
if self.Pressed then
local mx, my = gui.MousePos()
self.Angles:RotateAroundAxis( Vector(0,0,-1), ((self.PressX or mx) - mx) / 2 )
self.Angles:RotateAroundAxis( Vector(0,-1,0), ((self.PressY or my) - my) / 2 )
self.PressX, self.PressY = gui.MousePos()
end
ent:SetSkin( GetConVar( "lvscarwheelchanger_skin" ):GetInt() )
local R = GetConVar( "lvscarwheelchanger_r" ):GetInt()
local G = GetConVar( "lvscarwheelchanger_g" ):GetInt()
local B = GetConVar( "lvscarwheelchanger_b" ):GetInt()
local A = GetConVar( "lvscarwheelchanger_a" ):GetInt()
self:SetColor( Color(R,G,B,A) )
ent:SetAngles( self.Angles )
for id = 0, 9 do
ent:SetBodygroup( id, GetConVar( "lvscarwheelchanger_bodygroup"..id ):GetInt() )
end
for id, data in pairs( poseparameters ) do
if id > 9 then break end
if data.name == "#scale" then
local bonescale = math.Clamp( GetConVar( "lvscarwheelchanger_pp"..id ):GetFloat(), data.min, data.max )
local num = ent:GetBoneCount() - 1
for boneid = 0, num do
local bonename = ent:GetBoneName( boneid )
if not bonename or bonename == "__INVALIDBONE__" or not string.StartsWith( bonename, "#" ) then continue end
ent:ManipulateBoneScale( boneid, Vector(bonescale,bonescale,1) )
end
continue
end
ent:SetPoseParameter( data.name, GetConVar( "lvscarwheelchanger_pp"..id ):GetFloat() )
end
end
ContextMenuPanel.modelpanel = icon
if table.Count( poseparameters ) > 0 then
ContextMenuPanel:AddControl( "Label", { Text = "" } )
ContextMenuPanel:AddControl( "Label", { Text = "PoseParameters" } )
for id, data in pairs( poseparameters ) do
ContextMenuPanel:AddControl("Slider", { Label = data.name, Type = "float", Min = tostring( data.min ), Max = tostring( data.max ), Command = "lvscarwheelchanger_pp"..id } )
end
end
if #bodygroups > 0 then
ContextMenuPanel:AddControl( "Label", { Text = "" } )
ContextMenuPanel:AddControl( "Label", { Text = "BodyGroup" } )
for group, data in pairs( bodygroups ) do
local maxvalue = tostring( data.submodels )
if maxvalue == "0" then continue end
ContextMenuPanel:AddControl("Slider", { Label = data.name, Type = "int", Min = "0", Max = maxvalue, Command = "lvscarwheelchanger_bodygroup"..group } )
end
end
ContextMenuPanel:AddControl( "Label", { Text = "" } )
ContextMenuPanel:AddControl( "Label", { Text = "Alignment Specs" } )
ContextMenuPanel:AddControl( "Label", { Text = "- Wheel" } )
ContextMenuPanel:AddControl("Slider", { Label = "Camber", Type = "float", Min = "-15", Max = "15", Command = "lvscarwheelchanger_camber" } )
ContextMenuPanel:AddControl("Slider", { Label = "Caster", Type = "float", Min = "-15", Max = "15", Command = "lvscarwheelchanger_caster" } )
ContextMenuPanel:AddControl("Slider", { Label = "Toe", Type = "float", Min = "-30", Max = "30", Command = "lvscarwheelchanger_toe" } )
ContextMenuPanel:AddControl( "Label", { Text = "- Suspension" } )
ContextMenuPanel:AddControl("Slider", { Label = "Height", Type = "float", Min = "-1", Max = "1", Command = "lvscarwheelchanger_height" } )
ContextMenuPanel:AddControl("Slider", { Label = "Stiffness", Type = "float", Min = "-1", Max = "1", Command = "lvscarwheelchanger_stiffness" } )
-- purpose: avoid bullshit concommand system and avoid players abusing it
for mdl, _ in pairs( list.Get( "lvs_wheels" ) or {} ) do
list.Set( "lvs_wheels_selection", mdl, {} )
end
ContextMenuPanel:AddControl( "Label", { Text = "" } )
ContextMenuPanel:AddControl( "Label", { Text = "Wheel Models" } )
ContextMenuPanel:AddControl( "PropSelect", { Label = "", ConVar = "lvscarwheelchanger_model", Height = 0, Models = list.Get( "lvs_wheels_selection" ) } )
end
local function SetModel( name )
local ModelInfo = util.GetModelInfo( name )
if ModelInfo and ModelInfo.SkinCount then
skins = ModelInfo.SkinCount - 1
else
skins = 0
end
local bgroupmdl = ents.CreateClientProp()
bgroupmdl:SetModel( name )
bgroupmdl:Spawn()
table.Empty( bodygroups )
table.Empty( poseparameters )
for _, bgroup in pairs( bgroupmdl:GetBodyGroups() ) do
bodygroups[ bgroup.id ] = {
name = bgroup.name,
submodels = #bgroup.submodels,
}
end
local num = bgroupmdl:GetNumPoseParameters()
if num > 0 then
for i = 0, num - 1 do
local min, max = bgroupmdl:GetPoseParameterRange( i )
local name = bgroupmdl:GetPoseParameterName( i )
local pp_cvar = GetConVar( "lvscarwheelchanger_pp"..i )
if name == "#scale" and pp_cvar then
local val = pp_cvar:GetFloat()
if val > max or val < min then
pp_cvar:SetFloat( math.Clamp( 1, min, max ) )
end
end
poseparameters[ i ] = {
name = name,
min = min,
max = max,
}
end
end
bgroupmdl:Remove()
BuildContextMenu()
end
function TOOL.BuildCPanel( panel )
ContextMenuPanel = panel
BuildContextMenu()
end
cvars.AddChangeCallback( "lvscarwheelchanger_model", function( convar, oldValue, newValue )
SetModel( newValue )
end)
end
local function DuplicatorSaveCarWheels( ent )
if CLIENT then return end
local base = ent:GetBase()
if not IsValid( base ) then return end
local data = {}
for id, wheel in pairs( base:GetWheels() ) do
if not IsValid( wheel ) then continue end
local wheeldata = {}
wheeldata.ID = id
wheeldata.Model = wheel:GetModel()
wheeldata.ModelScale = wheel:GetModelScale()
wheeldata.Skin = wheel:GetSkin()
wheeldata.Camber = wheel:GetCamber()
wheeldata.Caster = wheel:GetCaster()
wheeldata.Toe = wheel:GetToe()
wheeldata.Height = wheel:GetSuspensionHeight()
wheeldata.Stiffness = wheel:GetSuspensionStiffness()
wheeldata.AlignmentAngle = wheel:GetAlignmentAngle()
wheeldata.Color = wheel:GetColor()
wheeldata.BodyGroups = {}
for id = 0, 9 do
wheeldata.BodyGroups[ id ] = wheel:GetBodygroup( id )
end
wheeldata.PoseParameters = {}
for id = 0, 9 do
wheeldata.PoseParameters[ id ] = wheel:GetPoseParameter( wheel:GetPoseParameterName( id ) )
end
table.insert( data, wheeldata )
end
if not duplicator or not duplicator.StoreEntityModifier then return end
duplicator.StoreEntityModifier( base, "lvsCarWheels", data )
end
local function DuplicatorApplyCarWheels( ply, ent, data )
if CLIENT then return end
timer.Simple(0.1, function()
if not IsValid( ent ) then return end
for id, wheel in pairs( ent:GetWheels() ) do
for _, wheeldata in pairs( data ) do
if not wheeldata or wheeldata.ID ~= id then continue end
if wheeldata.Model then wheel:SetModel( wheeldata.Model ) end
if wheeldata.ModelScale then wheel:SetModelScale( wheeldata.ModelScale ) end
if wheeldata.Skin then wheel:SetSkin( wheeldata.Skin ) end
if wheeldata.Camber then wheel:SetCamber( wheeldata.Camber ) end
if wheeldata.Caster then wheel:SetCaster( wheeldata.Caster ) end
if wheeldata.Toe then wheel:SetToe( wheeldata.Toe ) end
if wheeldata.AlignmentAngle then wheel:SetAlignmentAngle( wheeldata.AlignmentAngle ) end
if wheeldata.Color then wheel:SetColor( wheeldata.Color ) end
if wheeldata.Height then wheel:SetSuspensionHeight( wheeldata.Height ) end
if wheeldata.Stiffness then wheel:SetSuspensionStiffness( wheeldata.Stiffness ) end
timer.Simple(0, function()
if not IsValid( wheel ) then return end
if wheeldata.BodyGroups then
for group, subgroup in pairs( wheeldata.BodyGroups ) do
if subgroup == 0 then continue end
wheel:SetBodygroup( group, subgroup )
end
end
if wheeldata.PoseParameters and wheel:GetNumPoseParameters() > 0 then
for id, pose in pairs( wheeldata.PoseParameters ) do
local name = wheel:GetPoseParameterName( id )
wheel:StartThink()
wheel:SetPoseParameter( name, pose )
if name == "#scale" then
local min, max = wheel:GetPoseParameterRange( id )
local num = wheel:GetBoneCount() - 1
local bonescale = math.Clamp( pose, min, max )
for boneid = 0, num do
local bonename = wheel:GetBoneName( boneid )
if not bonename or bonename == "__INVALIDBONE__" or not string.StartsWith( bonename, "#" ) then continue end
wheel:ManipulateBoneScale( boneid, Vector(bonescale,bonescale,1) )
end
continue
end
end
end
end)
wheel:CheckAlignment()
wheel:PhysWake()
end
end
end)
end
if duplicator and duplicator.RegisterEntityModifier then
duplicator.RegisterEntityModifier( "lvsCarWheels", DuplicatorApplyCarWheels )
end
function TOOL:IsValidTarget( ent )
if not IsValid( ent ) then return false end
local class = ent:GetClass()
return class == "lvs_wheeldrive_wheel"
end
function TOOL:GetData( ent )
if CLIENT then return end
local ply = self:GetOwner()
if not IsValid( ply ) then return end
self.radius = ent:GetRadius() * (1 / ent:GetModelScale())
self.ang = ent:GetAlignmentAngle()
self.mdl = ent:GetModel()
ply:ConCommand( [[lvscarwheelchanger_model "]]..self.mdl..[["]] )
ply:ConCommand( "lvscarwheelchanger_skin "..ent:GetSkin() )
local clr = ent:GetColor()
ply:ConCommand( "lvscarwheelchanger_r " .. clr.r )
ply:ConCommand( "lvscarwheelchanger_g " .. clr.g )
ply:ConCommand( "lvscarwheelchanger_b " .. clr.b )
ply:ConCommand( "lvscarwheelchanger_a " .. clr.a )
for id = 0, 9 do
local group = ent:GetBodygroup( id ) or 0
ply:ConCommand( "lvscarwheelchanger_bodygroup"..id.." "..group )
end
for id = 0, 9 do
local pp = ent:GetPoseParameter( ent:GetPoseParameterName( id ) )
ply:ConCommand( "lvscarwheelchanger_pp"..id.." "..pp )
end
ply:ConCommand( "lvscarwheelchanger_camber "..ent:GetCamber() )
ply:ConCommand( "lvscarwheelchanger_caster "..ent:GetCaster() )
ply:ConCommand( "lvscarwheelchanger_toe "..ent:GetToe() )
ply:ConCommand( "lvscarwheelchanger_height "..ent:GetSuspensionHeight() )
ply:ConCommand( "lvscarwheelchanger_stiffness "..ent:GetSuspensionStiffness() )
end
function TOOL:SetData( ent )
if CLIENT then return end
local mdl = self:GetClientInfo("model")
if mdl ~= "" then
local data = list.Get( "lvs_wheels" )[ mdl ]
if data then
self.mdl = mdl
self.ang = data.angle
self.radius = data.radius
end
end
if not isstring( self.mdl ) or not isangle( self.ang ) or not isnumber( self.radius ) then return end
local r = self:GetClientNumber( "r", 0 )
local g = self:GetClientNumber( "g", 0 )
local b = self:GetClientNumber( "b", 0 )
local a = self:GetClientNumber( "a", 0 )
ent:SetColor( Color( r, g, b, a ) )
ent:SetSkin( self:GetClientNumber( "skin", 0 ) )
timer.Simple(0, function()
if not IsValid( ent ) then return end
for id = 0, 9 do
ent:SetBodygroup( id, self:GetClientNumber( "bodygroup"..id, 0 ) )
end
local num = ent:GetNumPoseParameters()
if num > 0 then
for id = 0, 9 do
if id > num - 1 then break end
local name = ent:GetPoseParameterName( id )
local pose = self:GetClientNumber( "pp"..id, 0 )
ent:StartThink()
ent:SetPoseParameter( name, pose )
if name == "#scale" then
local min, max = ent:GetPoseParameterRange( id )
local num = ent:GetBoneCount() - 1
local bonescale = math.Clamp( pose, min, max )
for boneid = 0, num do
local bonename = ent:GetBoneName( boneid )
if not bonename or bonename == "__INVALIDBONE__" or not string.StartsWith( bonename, "#" ) then continue end
ent:ManipulateBoneScale( boneid, Vector(bonescale,bonescale,1) )
end
continue
end
end
end
end)
if ent:GetModel() == self.mdl then
local Ang = ent:GetAlignmentAngle()
Ang:RotateAroundAxis( Vector(0,0,1), 180 )
ent:SetAlignmentAngle( Ang )
else
ent:SetModel( self.mdl )
ent:SetAlignmentAngle( self.ang )
timer.Simple(0.05, function()
if not IsValid( ent ) then return end
ent:SetModelScale( ent:GetRadius() / self.radius )
end)
end
timer.Simple(0.1, function()
if not IsValid( ent ) then return end
DuplicatorSaveCarWheels( ent )
end)
end
function TOOL:LeftClick( trace )
if not self:IsValidTarget( trace.Entity ) then return false end
self:SetData( trace.Entity )
if CLIENT then return true end
local ent = trace.Entity
timer.Simple(0, function()
if not IsValid( ent ) then return end
local effectdata = EffectData()
effectdata:SetOrigin( ent:GetPos() )
effectdata:SetEntity( ent )
util.Effect( "lvs_upgrade", effectdata )
end)
return true
end
function TOOL:RightClick( trace )
if not self:IsValidTarget( trace.Entity ) then return false end
self:GetData( trace.Entity )
if CLIENT then return true end
local ent = trace.Entity
timer.Simple(0, function()
if not IsValid( ent ) then return end
local effectdata = EffectData()
effectdata:SetOrigin( ent:GetPos() )
effectdata:SetEntity( ent )
util.Effect( "lvs_update", effectdata )
end)
return true
end
function TOOL:Reload( trace )
local ent = trace.Entity
if not self:IsValidTarget( ent ) then return false end
if CLIENT then return true end
timer.Simple(0, function()
if not IsValid( ent ) then return end
local effectdata = EffectData()
effectdata:SetOrigin( ent:GetPos() )
effectdata:SetEntity( ent )
util.Effect( "lvs_downgrade", effectdata )
end)
local camber = math.Round( self:GetClientNumber("camber",0) , 2 )
local caster = math.Round( self:GetClientNumber("caster",0) , 2 )
local toe = math.Round( self:GetClientNumber("toe",0) , 2 )
if math.Round( ent:GetCamber(), 2 ) == camber and math.Round( ent:GetToe(), 2 ) == toe and math.Round( ent:GetCaster(), 2 ) == caster then
ent:SetCamber( -camber )
ent:SetToe( -toe )
else
ent:SetCamber( camber )
ent:SetToe( toe )
end
ent:SetCaster( caster )
local NewTraction = math.min( math.Round( (ent:CheckAlignment() or 0) * 100, 0 ), 120 )
local ply = self:GetOwner()
if IsValid( ply ) and ply:IsPlayer() then
ply:ChatPrint( "Estimated Traction: "..NewTraction.."%" )
end
ent:SetSuspensionHeight( self:GetClientInfo("height") )
ent:SetSuspensionStiffness( self:GetClientInfo("stiffness") )
ent:PhysWake()
DuplicatorSaveCarWheels( ent )
return true
end
list.Set( "lvs_wheels", "models/props_vehicles/carparts_wheel01a.mdl", {angle = Angle(0,90,0), radius = 16} )

View File

@@ -0,0 +1,117 @@
TOOL.Category = "LVS"
TOOL.Name = "#tool.lvshealthshieldeditor.name"
TOOL.Command = nil
TOOL.ConfigName = ""
TOOL.ClientConVar[ "maxshield" ] = 0
TOOL.ClientConVar[ "maxhealth" ] = 5000
if CLIENT then
language.Add( "tool.lvshealthshieldeditor.name", "Max Health & Shield Editor" )
language.Add( "tool.lvshealthshieldeditor.desc", "A tool used to edit Max Health & Shield on LVS-Vehicles" )
language.Add( "tool.lvshealthshieldeditor.0", "Left click on a LVS-Vehicle to set Max Health, Right click to set Max Shield, Reload to reset." )
language.Add( "tool.lvshealthshieldeditor.1", "Left click on a LVS-Vehicle to set Max Health, Right click to set Max Shield, Reload to reset." )
language.Add( "tool.lvshealthshieldeditor.maxshield", "Max Shield" )
language.Add( "tool.lvshealthshieldeditor.maxhealth", "Max Health" )
end
function TOOL:LeftClick( trace )
local ent = trace.Entity
if not IsValid( ent ) then return false end
if not ent.LVS and not ent.LFS then return end
if not ent.OGMaxHealth then
ent.OGMaxHealth = ent.MaxHealth
end
ent.MaxHealth = self:GetClientNumber( "maxhealth" )
ent:SetHP( ent.MaxHealth )
return true
end
function TOOL:RightClick( trace )
local ent = trace.Entity
if not IsValid( ent ) then return false end
if not ent.LVS and not ent.LFS then return end
if not ent.OGMaxShield then
ent.OGMaxShield = ent.MaxShield
end
ent.MaxShield = self:GetClientNumber( "maxshield" )
ent:SetShield( ent.MaxShield )
return true
end
function TOOL:Reload( trace )
local ent = trace.Entity
if not IsValid( ent ) then return false end
if not ent.LVS and not ent.LFS then return end
if ent.OGMaxHealth then
ent.MaxHealth = ent.OGMaxHealth
end
if ent.OGMaxShield then
ent.MaxShield = ent.OGMaxShield
end
ent:SetHP( ent.MaxHealth )
ent:SetShield( ent.MaxShield )
return true
end
function TOOL:Think()
if SERVER then return end
local ply = LocalPlayer()
local tr = ply:GetEyeTrace()
local ent = tr.Entity
if not IsValid( ent ) then return end
if not ent.LVS and not ent.LFS then return end
local Text = "Health: "..tostring( math.Round( ent:GetHP(), 0 ) ).."/"..tostring( ent.MaxHealth )
if ent:GetShield() > 0 then
Text = Text.."\nShield: "..tostring( math.Round( ent:GetShield(), 0 ) ).."/"..tostring( ent.MaxShield )
end
AddWorldTip( ent:EntIndex(), Text, SysTime() + 0.05, ent:GetPos(), ent )
end
function TOOL.BuildCPanel( panel )
panel:AddControl( "Header", { Text = "#tool.lvshealthshieldeditor.name", Description = "#tool.lvshealthshieldeditor.desc" } )
panel:AddControl( "Slider",
{
Label = "#tool.lvshealthshieldeditor.maxhealth",
Type = "Int",
Min = "1",
Max = "50000",
Command = "lvshealthshieldeditor_maxhealth",
Help = false
})
panel:AddControl( "Slider",
{
Label = "#tool.lvshealthshieldeditor.maxshield",
Type = "Int",
Min = "0",
Max = "50000",
Command = "lvshealthshieldeditor_maxshield",
Help = false
})
panel:AddControl( "Label", { Text = "NOTE: Value in Edit-Properties menu will still be the same, because they can not be updated after the vehicle is spawned!" } )
end

View File

@@ -0,0 +1,45 @@
TOOL.Category = "LVS"
TOOL.Name = "#Transmission Editor"
TOOL.Command = nil
TOOL.ConfigName = ""
if CLIENT then
language.Add( "tool.lvstransmission.name", "Transmission Editor" )
language.Add( "tool.lvstransmission.desc", "A tool used to enable/disable Manual Transmission on LVS-Cars" )
language.Add( "tool.lvstransmission.0", "Left click on a LVS-Car to enable Manual Transmission. Right click to disable." )
language.Add( "tool.lvstransmission.1", "Left click on a LVS-Car to enable Manual Transmission. Right click to disable." )
end
function TOOL:LeftClick( trace )
local ent = trace.Entity
if not IsValid( ent ) then return false end
if not ent.LVS then return end
if isfunction( ent.SetNWGear ) and isfunction( ent.SetReverse ) then
ent:SetNWGear( 1 )
ent:SetReverse( false )
end
return true
end
function TOOL:RightClick( trace )
local ent = trace.Entity
if not IsValid( ent ) then return false end
if not ent.LVS then return end
if isfunction( ent.SetNWGear ) then
ent:SetNWGear( -1 )
end
return true
end
function TOOL:Reload( trace )
return false
end

View File

@@ -0,0 +1,144 @@
TOOL.Category = "LVS"
TOOL.Name = "#tool.lvsturret.name"
TOOL.Command = nil
TOOL.ConfigName = ""
cleanup.Register( "lvsturret" )
CreateConVar("sbox_maxlvsturret", 1, "FCVAR_NOTIFY")
TOOL.ClientConVar[ "delay" ] = "0.05"
TOOL.ClientConVar[ "damage" ] = "15"
TOOL.ClientConVar[ "speed" ] = "30000"
TOOL.ClientConVar[ "size" ] = "1"
TOOL.ClientConVar[ "spread" ] = "0"
TOOL.ClientConVar[ "penetration" ] = "10"
TOOL.ClientConVar[ "splashdamage" ] = "0"
TOOL.ClientConVar[ "splashradius" ] = "0"
TOOL.ClientConVar[ "tracer" ] = "lvs_tracer_orange"
TOOL.ClientConVar[ "splasheffect" ] = "lvs_bullet_impact"
if CLIENT then
language.Add( "tool.lvsturret.name", "Projectile Turret" )
language.Add( "tool.lvsturret.desc", "A Tool used to spawn Turrets" )
language.Add( "tool.lvsturret.0", "Left click to spawn or update a turret" )
language.Add( "tool.lvsturret.1", "Left click to spawn or update a turret" )
language.Add( "Cleanup_lvsturret", "[LVS] Projectile Turret" )
language.Add( "Cleaned_lvsturret", "Cleaned up all [LVS] Projectile Turrets" )
language.Add( "SBoxLimit_lvsturret", "You've reached the Projectile Turret limit!" )
end
function TOOL:LeftClick( trace )
if CLIENT then return true end
local ply = self:GetOwner()
if not istable( WireLib ) then
ply:PrintMessage( HUD_PRINTTALK, "[LVS]: WIREMOD REQUIRED" )
ply:SendLua( "gui.OpenURL( 'https://steamcommunity.com/sharedfiles/filedetails/?id=160250458' )")
end
if IsValid( trace.Entity ) and trace.Entity:GetClass():lower() == "lvs_turret" then
self:UpdateTurret( trace.Entity )
else
local turret = self:MakeTurret( ply, trace.HitPos + trace.HitNormal * 5 )
undo.Create("Turret")
undo.AddEntity( turret )
undo.SetPlayer( ply )
undo.Finish()
end
return true
end
function TOOL:RightClick( trace )
return false
end
if SERVER then
function TOOL:UpdateTurret( ent )
if not IsValid( ent ) then return end
ent:SetShootDelay( self:GetClientNumber( "delay" ) )
ent:SetDamage( math.Clamp( self:GetClientNumber( "damage" ), 0, 1000 ) )
ent:SetSpeed( math.Clamp( self:GetClientNumber( "speed" ), 10000, 100000 ) )
ent:SetSize( math.Clamp( self:GetClientNumber( "size" ), 0, 50 ) )
ent:SetSpread( math.Clamp( self:GetClientNumber( "spread" ), 0, 1 ) )
ent:SetPenetration( math.Clamp( self:GetClientNumber( "penetration" ), 0, 500 ) )
ent:SetSplashDamage( math.Clamp( self:GetClientNumber( "splashdamage" ), 0, 1000 ) )
ent:SetSplashDamageRadius( math.Clamp( self:GetClientNumber( "splashradius" ), 0, 750 ) )
ent:SetTracer( self:GetClientInfo( "tracer" ) )
ent:SetSplashDamageType( self:GetClientInfo( "splasheffect" ) )
end
function TOOL:MakeTurret( ply, Pos, Ang )
if not ply:CheckLimit( "lvsturret" ) then return NULL end
local turret = ents.Create( "lvs_turret" )
if not IsValid( turret ) then return NULL end
turret:SetPos( Pos )
turret:SetAngles( Angle(0,0,0) )
turret:Spawn()
turret.Attacker = ply
self:UpdateTurret( turret )
ply:AddCount( "lvsturret", turret )
ply:AddCleanup( "lvsturret", turret )
return turret
end
end
local ConVarsDefault = TOOL:BuildConVarList()
function TOOL.BuildCPanel( CPanel )
CPanel:AddControl( "ComboBox", { MenuButton = 1, Folder = "lvs_turrets", Options = { [ "#preset.default" ] = ConVarsDefault }, CVars = table.GetKeys( ConVarsDefault ) } )
CPanel:AddControl( "Header", { Text = "#tool.lvsturret.name", Description = "#tool.lvsturret.desc" } )
local TracerEffect = {Label = "Tracer Effect", MenuButton = 0, Options={}, CVars = {}}
local TracerOptions = {
["LaserBlue"] = "lvs_laser_blue",
["LaserRed"] = "lvs_laser_red",
["LaserGreen"] = "lvs_laser_green",
["TracerGreen"] = "lvs_tracer_green",
["TracerOrange"] = "lvs_tracer_orange",
["TracerWhite"] = "lvs_tracer_white",
["TracerYellow"] = "lvs_tracer_yellow",
["AutoCannon"] = "lvs_tracer_autocannon",
["Cannon"] = "lvs_tracer_cannon",
}
for id, name in pairs( TracerOptions ) do
if not file.Exists( "effects/"..name..".lua", "LUA" ) then continue end
TracerEffect["Options"][id] = { lvsturret_tracer = name }
end
CPanel:AddControl("ComboBox", TracerEffect )
CPanel:AddControl( "Slider", { Label = "Shoot Delay", Type = "Float", Min = 0, Max = 2.0, Command = "lvsturret_delay" } )
CPanel:AddControl( "Slider", { Label = "Damage", Type = "Float", Min = 0, Max = 1000, Command = "lvsturret_damage" } )
CPanel:AddControl( "Slider", { Label = "Bullet Speed", Type = "Float", Min = 10000, Max = 100000, Command = "lvsturret_speed" } )
CPanel:AddControl( "Slider", { Label = "Bullet Spread", Type = "Float", Min = 0, Max = 1, Command = "lvsturret_spread" } )
CPanel:AddControl( "Slider", { Label = "Hull Size", Type = "Float", Min = 0, Max = 50, Command = "lvsturret_size" } )
CPanel:AddControl( "Slider", { Label = "Armor Penetration (mm)", Type = "Float", Min = 0, Max = 500, Command = "lvsturret_penetration" } )
CPanel:AddControl( "Slider", { Label = "Splash Damage", Type = "Float", Min = 0, Max = 1000, Command = "lvsturret_splashdamage" } )
CPanel:AddControl( "Slider", { Label = "Splash Radius", Type = "Float", Min = 0, Max = 750, Command = "lvsturret_splashradius" } )
local SplashType = {Label = "Splash Type", MenuButton = 0, Options={}, CVars = {}}
SplashType["Options"][ "Shrapnel" ] = { lvsturret_splasheffect = "lvs_bullet_impact" }
SplashType["Options"][ "Explosive" ] = { lvsturret_splasheffect = "lvs_bullet_impact_explosive" }
CPanel:AddControl("ComboBox", SplashType )
end

View File

@@ -0,0 +1,198 @@
AddCSLuaFile()
SWEP.Category = "[LVS]"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.ViewModel = "models/weapons/c_scrubriglvs.mdl"
SWEP.WorldModel = "models/blu/lvsmine.mdl"
SWEP.UseHands = true
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 60
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = true
SWEP.HoldType = "slam"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 3
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "slam"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
cleanup.Register( "lvsmine" )
CreateConVar("sbox_maxlvsmine", 10, "FCVAR_NOTIFY")
if CLIENT then
SWEP.PrintName = "Mines"
SWEP.Slot = 4
SWEP.SlotPos = 1
SWEP.DrawWeaponInfoBox = false
SWEP.pViewModel = ClientsideModel("models/blu/lvsmine.mdl", RENDERGROUP_OPAQUE)
SWEP.pViewModel:SetNoDraw( true )
function SWEP:ViewModelDrawn()
local ply = self:GetOwner()
if not IsValid( ply ) then return end
local vm = ply:GetViewModel()
local bm = vm:GetBoneMatrix( 1 )
if not bm then return end
local pos = bm:GetTranslation()
local ang = bm:GetAngles()
pos = pos + ang:Up() * 25
pos = pos + ang:Right() * 1
pos = pos + ang:Forward() * -3
ang:RotateAroundAxis(ang:Forward(),60)
ang:RotateAroundAxis(ang:Right(),170)
ang:RotateAroundAxis(ang:Up(),65)
self.pViewModel:SetModelScale( 0.75 )
self.pViewModel:SetPos( pos )
self.pViewModel:SetAngles( ang )
self.pViewModel:DrawModel()
end
function SWEP:DrawWorldModel()
local ply = self:GetOwner()
if not IsValid( ply ) then self:DrawModel() return end
local id = ply:LookupAttachment("anim_attachment_rh")
local attachment = ply:GetAttachment( id )
if not attachment then return end
local pos = attachment.Pos + attachment.Ang:Forward() * 2
local ang = attachment.Ang
ang:RotateAroundAxis(attachment.Ang:Up(), 20)
ang:RotateAroundAxis(attachment.Ang:Right(), -30)
ang:RotateAroundAxis(attachment.Ang:Forward(), 0)
self:SetRenderOrigin( pos )
self:SetRenderAngles( ang )
self:DrawModel()
end
function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
draw.SimpleText( "z", "WeaponIcons", x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end
end
function SWEP:Initialize()
self:SetHoldType( self.HoldType )
end
function SWEP:OwnerChanged()
end
function SWEP:Think()
end
function SWEP:TakePrimaryAmmo( num )
local ply = self:GetOwner()
if self:Clip1() <= 0 then
if self:Ammo1() <= 0 then return end
ply:RemoveAmmo( num, self:GetPrimaryAmmoType() )
return
end
self:SetClip1( math.max(self:Clip1() - num,0) )
end
function SWEP:CanPrimaryAttack()
self.NextFire = self.NextFire or 0
return self.NextFire <= CurTime() and self:Ammo1() > 0
end
function SWEP:SetNextPrimaryFire( time )
self.NextFire = time
end
function SWEP:ThrowMine()
if CLIENT then return end
local ply = self:GetOwner()
if not ply:CheckLimit( "lvsmine" ) then return end
ply:EmitSound( "npc/zombie/claw_miss1.wav" )
local ent = ents.Create( "lvs_item_mine" )
if not IsValid( ent ) then return end
ent:SetPos( ply:GetShootPos() - Vector(0,0,10) )
ent:Spawn()
ent:Activate()
ent:SetAttacker( ply )
ply:AddCount( "lvsmine", ent )
ply:AddCleanup( "lvsmine", ent )
undo.Create("Mine")
undo.AddEntity( ent )
undo.SetPlayer( ply )
undo.Finish()
local PhysObj = ent:GetPhysicsObject()
if not IsValid( PhysObj ) then return end
PhysObj:SetVelocityInstantaneous( ply:GetAimVector() * 200 + Vector(0,0,150) )
PhysObj:AddAngleVelocity( VectorRand() * 20 )
end
function SWEP:PrimaryAttack()
if not self:CanPrimaryAttack() then return end
local ply = self:GetOwner()
ply:SetAnimation( PLAYER_ATTACK1 )
self:ThrowMine()
self:SetNextPrimaryFire( CurTime() + 1.5 )
self:TakePrimaryAmmo( 1 )
if SERVER then
if self:Ammo1() <= 0 then
ply:StripWeapon( "weapon_lvsmines" )
end
end
end
function SWEP:SecondaryAttack()
return false
end
function SWEP:Deploy()
self:SendWeaponAnim( ACT_SLAM_STICKWALL_DRAW )
return true
end
function SWEP:Holster()
return true
end

View File

@@ -0,0 +1,168 @@
AddCSLuaFile()
SWEP.Category = "[LVS]"
SWEP.Spawnable = true
SWEP.AdminSpawnable = false
SWEP.ViewModel = "models/weapons/c_scrubriglvs.mdl"
SWEP.WorldModel = "models/diggercars/shared/spikestrip_fold.mdl"
SWEP.UseHands = true
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 60
SWEP.AutoSwitchTo = true
SWEP.AutoSwitchFrom = true
SWEP.HoldType = "physgun"
SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
cleanup.Register( "lvsspikestrip" )
if CLIENT then
SWEP.PrintName = "Spike Strip"
SWEP.Slot = 4
SWEP.SlotPos = 2
SWEP.DrawWeaponInfoBox = false
SWEP.pViewModel = ClientsideModel("models/diggercars/shared/spikestrip_fold.mdl", RENDERGROUP_OPAQUE)
SWEP.pViewModel:SetNoDraw( true )
function SWEP:ViewModelDrawn()
local ply = self:GetOwner()
if not IsValid( ply ) then return end
local vm = ply:GetViewModel()
local bm = vm:GetBoneMatrix(0)
if not bm then return end
local pos = bm:GetTranslation()
local ang = bm:GetAngles()
pos = pos + ang:Up() * 28
pos = pos + ang:Right() * 8
pos = pos + ang:Forward() * -5
ang:RotateAroundAxis(ang:Forward(), -210)
ang:RotateAroundAxis(ang:Right(),-60)
ang:RotateAroundAxis(ang:Up(), 90)
self.pViewModel:SetPos( pos )
self.pViewModel:SetAngles( ang )
self.pViewModel:DrawModel()
self.pViewModel:SetModelScale( 0.5 )
end
function SWEP:DrawWorldModel()
local ply = self:GetOwner()
if not IsValid( ply ) then self:DrawModel() return end
local id = ply:LookupAttachment("anim_attachment_rh")
local attachment = ply:GetAttachment( id )
if not attachment then return end
local pos = attachment.Pos + attachment.Ang:Forward() * 3 - attachment.Ang:Up() * 30
local ang = attachment.Ang
ang:RotateAroundAxis(attachment.Ang:Up(), -40)
ang:RotateAroundAxis(attachment.Ang:Right(), -90)
ang:RotateAroundAxis(attachment.Ang:Forward(), 0)
self:SetRenderOrigin( pos )
self:SetRenderAngles( ang )
self:DrawModel()
end
function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
draw.SimpleText( "P", "WeaponIcons", x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end
end
function SWEP:Initialize()
self:SetHoldType( self.HoldType )
end
function SWEP:OwnerChanged()
end
function SWEP:Think()
end
if SERVER then
function SWEP:PlaceStrip()
local ply = self:GetOwner()
ply:EmitSound( "npc/zombie/claw_miss1.wav" )
local ent = ents.Create( "lvs_item_spikestrip_foldable" )
if not IsValid( ent ) then return end
ent:SetAngles( Angle(0,180 + ply:EyeAngles().y,0) )
ent:SetPos( ply:GetShootPos() - Vector(0,0,10) )
ent:Spawn()
ent:Activate()
ent:SetAttacker( ply )
ent:SetOwner( ply )
ply:AddCleanup( "lvsspikestrip", ent )
undo.Create("Spike Strip")
undo.AddEntity( ent )
undo.SetPlayer( ply )
undo.Finish()
local PhysObj = ent:GetPhysicsObject()
if not IsValid( PhysObj ) then return end
PhysObj:SetVelocityInstantaneous( ply:GetAimVector() * 200 + Vector(0,0,75) )
end
end
function SWEP:PrimaryAttack()
local ply = self:GetOwner()
self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
ply:SetAnimation( PLAYER_ATTACK1 )
self:SetNextPrimaryFire( CurTime() + 1.5 )
if SERVER then
self:PlaceStrip()
ply:StripWeapon( "weapon_lvsspikestrip" )
end
end
function SWEP:SecondaryAttack()
return false
end
function SWEP:Deploy()
self:SendWeaponAnim( ACT_VM_DRAW )
return true
end
function SWEP:Holster()
return true
end
function SWEP:OnRemove()
end

View File

@@ -0,0 +1,240 @@
hook.Add( "PopulateVehicles", "!!!add_lvs_to_vehicles", function( pnlContent, tree, node )
local CategoryNameTranslate = {}
local Categorised = {}
local SubCategorised = {}
local SpawnableEntities = table.Copy( list.Get( "SpawnableEntities" ) )
local Variants = {
[1] = "[LVS] - ",
[2] = "[LVS] -",
[3] = "[LVS]- ",
[4] = "[LVS]-",
[5] = "[LVS] ",
}
for _, v in pairs( scripted_ents.GetList() ) do
if not v.t or not v.t.ClassName or not v.t.VehicleCategory then continue end
if not isstring( v.t.ClassName ) or v.t.ClassName == "" or not SpawnableEntities[ v.t.ClassName ] then continue end
SpawnableEntities[ v.t.ClassName ].Category = "[LVS] - "..v.t.VehicleCategory
if not v.t.VehicleSubCategory then continue end
SpawnableEntities[ v.t.ClassName ].SubCategory = v.t.VehicleSubCategory
end
if SpawnableEntities then
for k, v in pairs( SpawnableEntities ) do
local Category = v.Category
if not isstring( Category ) then continue end
if not Category:StartWith( "[LVS]" ) and not v.LVS then continue end
v.SpawnName = k
for _, start in pairs( Variants ) do
if Category:StartWith( start ) then
local NewName = string.Replace(Category, start, "")
CategoryNameTranslate[ NewName ] = Category
Category = NewName
break
end
end
if v.SubCategory then
SubCategorised[ Category ] = SubCategorised[ Category ] or {}
SubCategorised[ Category ][ v.SubCategory ] = SubCategorised[ Category ][ v.SubCategory ] or {}
table.insert( SubCategorised[ Category ][ v.SubCategory ], v )
end
Categorised[ Category ] = Categorised[ Category ] or {}
table.insert( Categorised[ Category ], v )
end
end
local lvsNode = tree:AddNode( "[LVS]", "icon16/lvs.png" )
if Categorised["[LVS]"] then
local v = Categorised["[LVS]"]
lvsNode.DoPopulate = function( self )
if self.PropPanel then return end
self.PropPanel = vgui.Create( "ContentContainer", pnlContent )
self.PropPanel:SetVisible( false )
self.PropPanel:SetTriggerSpawnlistChange( false )
for k, ent in SortedPairsByMemberValue( v, "PrintName" ) do
spawnmenu.CreateContentIcon( ent.ScriptedEntityType or "entity", self.PropPanel, {
nicename = ent.PrintName or ent.ClassName,
spawnname = ent.SpawnName,
material = ent.IconOverride or "entities/" .. ent.SpawnName .. ".png",
admin = ent.AdminOnly
} )
end
end
lvsNode.DoClick = function( self )
self:DoPopulate()
pnlContent:SwitchPanel( self.PropPanel )
end
end
local IconList = list.Get( "ContentCategoryIcons" )
for CategoryName, v in SortedPairs( Categorised ) do
if CategoryName:StartWith( "[LVS]" ) then continue end
local Icon = "icon16/lvs_noicon.png"
if IconList and IconList[ CategoryNameTranslate[ CategoryName ] ] then
Icon = IconList[ CategoryNameTranslate[ CategoryName ] ]
end
local node = lvsNode:AddNode( CategoryName, Icon )
node.DoPopulate = function( self )
if self.PropPanel then return end
self.PropPanel = vgui.Create( "ContentContainer", pnlContent )
self.PropPanel:SetVisible( false )
self.PropPanel:SetTriggerSpawnlistChange( false )
for k, ent in SortedPairsByMemberValue( v, "PrintName" ) do
if ent.SubCategory then
continue
end
spawnmenu.CreateContentIcon( ent.ScriptedEntityType or "entity", self.PropPanel, {
nicename = ent.PrintName or ent.ClassName,
spawnname = ent.SpawnName,
material = ent.IconOverride or "entities/" .. ent.SpawnName .. ".png",
admin = ent.AdminOnly
} )
end
end
node.DoClick = function( self )
self:DoPopulate()
pnlContent:SwitchPanel( self.PropPanel )
end
local SubCat = SubCategorised[ CategoryName ]
if not SubCat then continue end
for SubName, data in SortedPairs( SubCat ) do
local SubIcon = "icon16/lvs_noicon.png"
if IconList then
if IconList[ "[LVS] - "..CategoryName.." - "..SubName ] then
SubIcon = IconList[ "[LVS] - "..CategoryName.." - "..SubName ]
else
if IconList[ "[LVS] - "..SubName ] then
SubIcon = IconList[ "[LVS] - "..SubName ]
end
end
end
local subnode = node:AddNode( SubName, SubIcon )
subnode.DoPopulate = function( self )
if self.PropPanel then return end
self.PropPanel = vgui.Create( "ContentContainer", pnlContent )
self.PropPanel:SetVisible( false )
self.PropPanel:SetTriggerSpawnlistChange( false )
for k, ent in SortedPairsByMemberValue( data, "PrintName" ) do
spawnmenu.CreateContentIcon( ent.ScriptedEntityType or "entity", self.PropPanel, {
nicename = ent.PrintName or ent.ClassName,
spawnname = ent.SpawnName,
material = ent.IconOverride or "entities/" .. ent.SpawnName .. ".png",
admin = ent.AdminOnly
} )
end
end
subnode.DoClick = function( self )
self:DoPopulate()
pnlContent:SwitchPanel( self.PropPanel )
end
end
end
-- User Stuff
hook.Run( "LVS.PopulateVehicles", lvsNode, pnlContent, tree )
-- CONTROLS
local node = lvsNode:AddNode( "Controls", "icon16/keyboard.png" )
node.DoClick = function( self )
LVS:OpenMenu()
LVS:OpenClientControls()
end
-- CLIENT SETTINGS
local node = lvsNode:AddNode( "Client Settings", "icon16/wrench.png" )
node.DoClick = function( self )
LVS:OpenMenu()
LVS:OpenClientSettings()
end
-- SERVER SETTINGS
local node = lvsNode:AddNode( "Server Settings", "icon16/wrench_orange.png" )
node.DoClick = function( self )
if LocalPlayer():IsSuperAdmin() then
LVS:OpenMenu()
LVS:OpenServerMenu()
else
surface.PlaySound( "buttons/button11.wav" )
end
end
end )
list.Set( "ContentCategoryIcons", "[LVS]", "icon16/lvs.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Artillery", "icon16/lvs_artillery.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Boats", "icon16/lvs_boats.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Boats - Civilian", "icon16/lvs_civilian.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Racers", "icon16/lvs_racers.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Cars", "icon16/lvs_cars.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Cars - Armored", "icon16/lvs_armor.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Cars - Civilian", "icon16/lvs_civilian.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Cars - Military", "icon16/lvs_military.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Cars - Pack", "icon16/lvs_cars_pack.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Trucks - Pack", "icon16/lvs_trucks.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Rig", "icon16/lvs_trucks.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Rig - Trucks", "icon16/lvs_trucks.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Rig - Trailers", "icon16/lvs_trucktrailers.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Helicopters", "icon16/lvs_helicopters.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Helicopters - Combine", "icon16/lvs_combine.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Helicopters - Resistance", "icon16/lvs_resistance.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Planes", "icon16/lvs_planes.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Planes - Bombers", "icon16/lvs_bomb.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Planes - Fighters", "icon16/lvs_fighter.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Planes - Civilian", "icon16/lvs_civilian.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Tanks", "icon16/lvs_tanks.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Tanks - Light", "icon16/lvs_light.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Tanks - Medium", "icon16/lvs_medium.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Tanks - Heavy", "icon16/lvs_heavy.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Tanks - RP", "icon16/lvs_rp.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Star Wars", "icon16/lvs_starwars.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Star Wars - Gunships", "icon16/lvs_sw_gunship.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Star Wars - Hover Tanks", "icon16/lvs_sw_hover.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Star Wars - Walkers", "icon16/lvs_sw_walker.png" )
list.Set( "ContentCategoryIcons", "[LVS] - Star Wars - Starfighters", "icon16/lvs_sw_starfighter.png" )

View File

@@ -0,0 +1,3 @@
if SERVER then
resource.AddWorkshop("2922255744") -- LVS Base
end

View File

@@ -0,0 +1,476 @@
LVS = istable( LVS ) and LVS or {}
LVS.VERSION = 348
LVS.VERSION_GITHUB = 0
LVS.VERSION_TYPE = ".WS"
LVS.VERSION_ADDONS_OUTDATED = false
LVS.KEYS_CATEGORIES = {}
LVS.KEYS_REGISTERED = {}
LVS.pSwitchKeys = {[KEY_1] = 1,[KEY_2] = 2,[KEY_3] = 3,[KEY_4] = 4,[KEY_5] = 5,[KEY_6] = 6,[KEY_7] = 7,[KEY_8] = 8,[KEY_9] = 9,[KEY_0] = 10}
LVS.pSwitchKeysInv = {[1] = KEY_1,[2] = KEY_2,[3] = KEY_3,[4] = KEY_4,[5] = KEY_5,[6] = KEY_6,[7] = KEY_7,[8] = KEY_8,[9] = KEY_9,[10] = KEY_0}
LVS.ThemeColor = Color(127,0,0,255)
LVS.WHEEL_BRAKE = 1
LVS.WHEEL_STEER_NONE = 2
LVS.WHEEL_STEER_FRONT = 3
LVS.WHEEL_STEER_REAR = 4
LVS.WHEEL_STEER_ACKERMANN = 5
LVS.WHEELTYPE_NONE = 0
LVS.WHEELTYPE_LEFT = 1
LVS.WHEELTYPE_RIGHT = -1
LVS.HITCHTYPE_NONE = -1
LVS.HITCHTYPE_MALE = 0
LVS.HITCHTYPE_FEMALE = 1
LVS.SOUNDTYPE_NONE = 0
LVS.SOUNDTYPE_IDLE_ONLY = 1
LVS.SOUNDTYPE_REV_UP = 2
LVS.SOUNDTYPE_REV_DOWN = 3
LVS.SOUNDTYPE_REV_DN = 3
LVS.SOUNDTYPE_ALL = 4
LVS.FUELTYPE_PETROL = 0
LVS.FUELTYPE_DIESEL = 1
LVS.FUELTYPE_ELECTRIC = 2
LVS.FUELTYPES = {
[LVS.FUELTYPE_PETROL] = {
name = "Petrol",
color = Vector(240,200,0),
},
[LVS.FUELTYPE_DIESEL] = {
name = "Diesel",
color = Vector(255,60,0),
},
[LVS.FUELTYPE_ELECTRIC] = {
name = "Electric",
color = Vector(0,127,255),
},
}
LVS.SPEEDUNITS = {
["u/s"] = {
name = "u/s",
value = 1,
},
["mph"] = {
name = "mph",
value = 0.0568182,
},
["km/h"] = {
name = "km/h",
value = 0.09144,
},
}
LVS.WEAPONS = {
["DEFAULT"] = {
Icon = Material("lvs/weapons/bullet.png"),
Ammo = 9999,
Delay = 0,
HeatRateUp = 0.2,
HeatRateDown = 0.25,
Attack = function( ent ) end,
StartAttack = function( ent ) end,
FinishAttack = function( ent ) end,
OnSelect = function( ent, old ) end,
OnDeselect = function( ent, new ) end,
OnThink = function( ent, active ) end,
OnOverheat = function( ent ) end,
OnRemove = function( ent ) end,
OnReload = function( ent ) end,
},
["LMG"] = {
Icon = Material("lvs/weapons/mg.png"),
Ammo = 1000,
Delay = 0.1,
Attack = function( ent )
ent.MirrorPrimary = not ent.MirrorPrimary
local Mirror = ent.MirrorPrimary and -1 or 1
local Pos = ent:LocalToWorld( ent.PosLMG and Vector(ent.PosLMG.x,ent.PosLMG.y * Mirror,ent.PosLMG.z) or Vector(0,0,0) )
local Dir = ent.DirLMG or 0
local effectdata = EffectData()
effectdata:SetOrigin( Pos )
effectdata:SetNormal( ent:GetForward() )
effectdata:SetEntity( ent )
util.Effect( "lvs_muzzle", effectdata )
local bullet = {}
bullet.Src = Pos
bullet.Dir = ent:LocalToWorldAngles( Angle(0,-Dir * Mirror,0) ):Forward()
bullet.Spread = Vector( 0.015, 0.015, 0.015 )
bullet.TracerName = "lvs_tracer_white"
bullet.Force = 1000
bullet.HullSize = 50
bullet.Damage = 35
bullet.Velocity = 30000
bullet.Attacker = ent:GetDriver()
bullet.Callback = function(att, tr, dmginfo) end
ent:LVSFireBullet( bullet )
ent:TakeAmmo()
end,
StartAttack = function( ent )
if not IsValid( ent.SoundEmitter1 ) then
ent.SoundEmitter1 = ent:AddSoundEmitter( Vector(109.29,0,92.85), "lvs/weapons/mg_loop.wav", "lvs/weapons/mg_loop_interior.wav" )
ent.SoundEmitter1:SetSoundLevel( 95 )
end
ent.SoundEmitter1:Play()
end,
FinishAttack = function( ent )
if IsValid( ent.SoundEmitter1 ) then
ent.SoundEmitter1:Stop()
ent.SoundEmitter1:EmitSound("lvs/weapons/mg_lastshot.wav")
end
end,
OnSelect = function( ent ) ent:EmitSound("physics/metal/weapon_impact_soft3.wav") end,
OnOverheat = function( ent ) ent:EmitSound("lvs/overheat.wav") end,
},
["TABLE_POINT_MG"] = {
Icon = Material("lvs/weapons/mc.png"),
Ammo = 2000,
Delay = 0.1,
Attack = function( ent )
if not ent.PosTPMG or not ent.DirTPMG then return end
for i = 1, 2 do
ent._NumTPMG = ent._NumTPMG and ent._NumTPMG + 1 or 1
if ent._NumTPMG > #ent.PosTPMG then ent._NumTPMG = 1 end
local Pos = ent:LocalToWorld( ent.PosTPMG[ ent._NumTPMG ] )
local Dir = ent.DirTPMG[ ent._NumTPMG ]
local effectdata = EffectData()
effectdata:SetOrigin( Pos )
effectdata:SetNormal( ent:GetForward() )
effectdata:SetEntity( ent )
util.Effect( "lvs_muzzle", effectdata )
local bullet = {}
bullet.Src = Pos
bullet.Dir = ent:LocalToWorldAngles( Angle(0,-Dir,0) ):Forward()
bullet.Spread = Vector( 0.035, 0.035, 0.035 )
bullet.TracerName = "lvs_tracer_yellow"
bullet.Force = 1000
bullet.HullSize = 25
bullet.Damage = 35
bullet.Velocity = 40000
bullet.Attacker = ent:GetDriver()
bullet.Callback = function(att, tr, dmginfo) end
ent:LVSFireBullet( bullet )
end
ent:TakeAmmo( 2 )
end,
StartAttack = function( ent )
if not IsValid( ent.SoundEmitter1 ) then
ent.SoundEmitter1 = ent:AddSoundEmitter( Vector(109.29,0,92.85), "lvs/weapons/mg_light_loop.wav", "lvs/weapons/mg_light_loop_interior.wav" )
ent.SoundEmitter1:SetSoundLevel( 95 )
end
ent.SoundEmitter1:Play()
end,
FinishAttack = function( ent )
if IsValid( ent.SoundEmitter1 ) then
ent.SoundEmitter1:Stop()
ent.SoundEmitter1:EmitSound("lvs/weapons/mg_light_lastshot.wav")
end
end,
OnSelect = function( ent ) ent:EmitSound("physics/metal/weapon_impact_soft3.wav") end,
OnOverheat = function( ent ) ent:EmitSound("lvs/overheat.wav") end,
},
["HMG"] = {
Icon = Material("lvs/weapons/hmg.png"),
Ammo = 300,
Delay = 0.14,
Attack = function( ent )
ent.MirrorSecondary = not ent.MirrorSecondary
local Mirror = ent.MirrorSecondary and -1 or 1
local Pos = ent:LocalToWorld( ent.PosHMG and Vector(ent.PosHMG.x,ent.PosHMG.y * Mirror,ent.PosHMG.z) or Vector(0,0,0) )
local Dir = ent.DirHMG or 0.5
local effectdata = EffectData()
effectdata:SetOrigin( Pos )
effectdata:SetNormal( ent:GetForward() )
effectdata:SetEntity( ent )
util.Effect( "lvs_muzzle", effectdata )
local bullet = {}
bullet.Src = Pos
bullet.Dir = ent:LocalToWorldAngles( Angle(0,-Dir * Mirror,0) ):Forward()
bullet.Spread = Vector( 0.02, 0.02, 0.02 )
bullet.TracerName = "lvs_tracer_orange"
bullet.Force = 4000
bullet.HullSize = 15
bullet.Damage = 45
bullet.SplashDamage = 75
bullet.SplashDamageRadius = 200
bullet.Velocity = 15000
bullet.Attacker = ent:GetDriver()
bullet.Callback = function(att, tr, dmginfo)
end
ent:LVSFireBullet( bullet )
ent:TakeAmmo()
end,
StartAttack = function( ent )
if not IsValid( ent.SoundEmitter2 ) then
ent.SoundEmitter2 = ent:AddSoundEmitter( Vector(109.29,0,92.85), "lvs/weapons/mc_loop.wav", "lvs/weapons/mc_loop_interior.wav" )
ent.SoundEmitter2:SetSoundLevel( 95 )
end
ent.SoundEmitter2:Play()
end,
FinishAttack = function( ent )
if IsValid( ent.SoundEmitter2 ) then
ent.SoundEmitter2:Stop()
ent.SoundEmitter2:EmitSound("lvs/weapons/mc_lastshot.wav")
end
end,
OnSelect = function( ent ) ent:EmitSound("physics/metal/weapon_impact_soft2.wav") end,
OnOverheat = function( ent ) ent:EmitSound("lvs/overheat.wav") end,
},
["TURBO"] = {
Icon = Material("lvs/weapons/nos.png"),
HeatRateUp = 0.1,
HeatRateDown = 0.1,
UseableByAI = false,
Attack = function( ent )
local PhysObj = ent:GetPhysicsObject()
if not IsValid( PhysObj ) then return end
local THR = ent:GetThrottle()
local FT = FrameTime()
local Vel = ent:GetVelocity():Length()
PhysObj:ApplyForceCenter( ent:GetForward() * math.Clamp(ent.MaxVelocity + 500 - Vel,0,1) * PhysObj:GetMass() * THR * FT * 150 ) -- increase speed
PhysObj:AddAngleVelocity( PhysObj:GetAngleVelocity() * FT * 0.5 * THR ) -- increase turn rate
end,
StartAttack = function( ent )
ent.TargetThrottle = 1.3
ent:EmitSound("lvs/vehicles/generic/boost.wav")
end,
FinishAttack = function( ent )
ent.TargetThrottle = 1
end,
OnSelect = function( ent )
ent:EmitSound("buttons/lever5.wav")
end,
OnThink = function( ent, active )
if not ent.TargetThrottle then return end
local Rate = FrameTime() * 0.5
ent:SetMaxThrottle( ent:GetMaxThrottle() + math.Clamp(ent.TargetThrottle - ent:GetMaxThrottle(),-Rate,Rate) )
local MaxThrottle = ent:GetMaxThrottle()
ent:SetThrottle( MaxThrottle )
if MaxThrottle == ent.TargetThrottle then
ent.TargetThrottle = nil
end
end,
OnOverheat = function( ent ) ent:EmitSound("lvs/overheat_boost.wav") end,
},
}
function LVS:GetVersion()
return LVS.VERSION
end
function LVS:AddKey(name, category, printname, cmd, default)
local data = {
printname = printname,
id = name,
category = category,
cmd = cmd,
}
if not LVS.KEYS_CATEGORIES[ category ] then
LVS.KEYS_CATEGORIES[ category ] = {}
end
if SERVER then
table.insert( LVS.KEYS_REGISTERED, data )
else
if default then
if isstring( default ) then
local Key = input.LookupBinding( default )
if Key then
default = input.GetKeyCode( Key )
else
default = 0
end
end
else
default = 0
end
data.default = default
table.insert( LVS.KEYS_REGISTERED, data )
CreateClientConVar( cmd, default, true, true )
end
end
function LVS:CheckUpdates()
http.Fetch("https://raw.githubusercontent.com/SpaxscE/lvs_base/main/lua/autorun/lvs_init.lua", function(contents,size)
local Entry = string.match( contents, "LVS.VERSION%s=%s%d+" )
if Entry then
LVS.VERSION_GITHUB = tonumber( string.match( Entry , "%d+" ) ) or 0
else
LVS.VERSION_GITHUB = 0
end
if LVS.VERSION_GITHUB == 0 then
print("[LVS] - Framework: latest version could not be detected, You have Version: "..LVS:GetVersion())
else
if LVS:GetVersion() >= LVS.VERSION_GITHUB then
print("[LVS] - Framework is up to date, Version: "..LVS:GetVersion())
else
print("[LVS] - Framework: a newer version is available! Version: "..LVS.VERSION_GITHUB..", You have Version: "..LVS:GetVersion())
if LVS.VERSION_TYPE == ".GIT" then
print("[LVS] - Framework: get the latest version at https://github.com/SpaxscE/lvs_base")
else
print("[LVS] - Framework: restart your game/server to get the latest version!")
end
if CLIENT then
timer.Simple(18, function()
chat.AddText( Color( 255, 0, 0 ), "[LVS] - Framework: a newer version is available!" )
end)
end
end
end
local Delay = 0
local addons = file.Find( "data_static/lvs/*", "GAME" )
for _, addonFile in pairs( addons ) do
local addonInfo = file.Read( "data_static/lvs/"..addonFile, "GAME" )
if not addonInfo then continue end
local data = string.Explode( "\n", addonInfo )
local wsid = string.Replace( addonFile, ".txt", "" )
local addon_name = wsid
local addon_url
local addon_version
for _, entry in pairs( data ) do
if string.StartsWith( entry, "url=" ) then
addon_url = string.Replace( entry, "url=", "" )
end
if string.StartsWith( entry, "version=" ) then
addon_version = string.Replace( entry, "version=", "" )
end
if string.StartsWith( entry, "name=" ) then
addon_name = string.Replace( entry, "name=", "" )
end
end
if not addon_url or not addon_version then continue end
addon_version = tonumber( addon_version )
Delay = Delay + 1.5
timer.Simple( Delay, function()
http.Fetch(addon_url, function(con,_)
local addon_entry = string.match( con, "version=%d+" )
local addon_version_git = 0
if addon_entry then
addon_version_git = tonumber( string.match( addon_entry, "%d+" ) ) or 0
end
local wsurl = "https://steamcommunity.com/sharedfiles/filedetails/?id="..wsid
if addon_version_git == 0 then
print("[LVS] latest version of "..addon_name.." ( "..wsurl.." ) could not be detected, You have Version: "..addon_version)
else
if addon_version_git > addon_version then
print("[LVS] - "..addon_name.." ( "..wsurl.." ) is out of date!")
if CLIENT then
timer.Simple(18, function()
chat.AddText( Color( 255, 0, 0 ),"[LVS] - "..addon_name.." is out of date!" )
end)
end
LVS.VERSION_ADDONS_OUTDATED = true
else
print("[LVS] - "..addon_name.." is up to date, Version: "..addon_version)
end
end
end)
end )
end
end)
end
function LVS:GetWeaponPreset( name )
if not LVS.WEAPONS[ name ] then return table.Copy( LVS.WEAPONS["DEFAULT"] ) end
return table.Copy( LVS.WEAPONS[ name ] )
end
function LVS:AddWeaponPreset( name, data )
if not isstring( name ) or not istable( data ) then return end
LVS.WEAPONS[ name ] = data
end
function LVS:GetVehicleTypes()
local VehicleTypes = {}
for s, v in pairs( scripted_ents.GetList() ) do
if not v.t or not isfunction( v.t.GetVehicleType ) then continue end
local vehicletype = v.t:GetVehicleType()
if not isstring( vehicletype ) or string.StartsWith( vehicletype, "LBase" ) or table.HasValue( VehicleTypes, vehicletype ) then continue end
table.insert( VehicleTypes, vehicletype )
end
return VehicleTypes
end
if CLIENT then
function LVS:GetUnitValue( number )
if not LVS.SPEEDUNITS[ LVS.SpeedUnit ] then return number end
return (number * LVS.SPEEDUNITS[ LVS.SpeedUnit ].value)
end
function LVS:GetUnitName()
if not LVS.SPEEDUNITS[ LVS.SpeedUnit ] then return "u/s" end
return LVS.SPEEDUNITS[ LVS.SpeedUnit ].name
end
end
AddCSLuaFile("lvs_framework/init.lua")
include("lvs_framework/init.lua")

View File

@@ -0,0 +1,179 @@
EFFECT.FireMat = Material( "effects/fire_cloud1" )
EFFECT.HeatMat = Material( "sprites/heatwave" )
EFFECT.Smoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
self.LifeTime = 0.4
self.DieTime = CurTime() + self.LifeTime
if not IsValid( Ent ) then return end
self.Ent = Ent
self.Pos = Ent:WorldToLocal( Pos + VectorRand() * 3 )
self.Seed = math.Rand( 0, 10000 )
self.Magnitude = data:GetMagnitude()
local emitter = Ent:GetParticleEmitter( self.Pos )
if not IsValid( emitter ) then return end
local VecCol = (render.GetLightColor( Pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
for i = 0, 20 do
local particle = emitter:Add( "sprites/rico1", Pos )
local vel = VectorRand() * 800
if particle then
particle:SetVelocity( Vector(0,0,500) + VectorRand() * 500 )
particle:SetDieTime( 0.25 * self.Magnitude )
particle:SetStartAlpha( 200 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 3 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-1,1) * math.pi )
particle:SetRollDelta( math.Rand(-1,1) * 3 )
particle:SetColor( 255, 255, 255 )
particle:SetAirResistance( 0 )
end
end
for i = 1, 8 do
local particle = emitter:Add( self.Smoke[ math.random(1, #self.Smoke ) ], Pos )
local Dir = Angle(0,math.Rand(-180,180),0):Forward()
Dir.z = -0.5
Dir:Normalize()
if particle then
particle:SetVelocity( Dir * 250 )
particle:SetDieTime( 0.5 + i * 0.01 )
particle:SetAirResistance( 125 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 20 )
particle:SetEndSize( 40 )
particle:SetRoll( math.Rand(-1,1) * math.pi )
particle:SetRollDelta( math.Rand(-1,1) * 3 )
particle:SetColor( 0, 0, 0 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( true )
particle:SetBounce( 0 )
end
end
for i = 0,22 do
local particle = emitter:Add( "particles/flamelet"..math.random(1,5), Pos )
local Dir = Angle(0,math.Rand(-180,180),0):Forward()
if particle then
particle:SetVelocity( Dir * math.Rand(600,900) * self.Magnitude )
particle:SetDieTime( math.Rand(0.2,0.3) * self.Magnitude )
particle:SetAirResistance( 400 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( math.Rand(20,25) )
particle:SetEndSize( math.Rand(5,10) )
particle:SetRoll( math.Rand(-1,1) * 180 )
particle:SetRollDelta( math.Rand(-1,1) * 3 )
particle:SetColor( 255, 200, 50 )
particle:SetGravity( Vector( 0, 0, 1000 ) )
particle:SetCollide( false )
end
end
for i = 1, 4 do
local particle = emitter:Add( self.Smoke[ math.random(1, #self.Smoke ) ], Pos )
local Dir = Angle(0,math.Rand(-180,180),0):Forward()
if particle then
particle:SetVelocity( Dir * 500 * self.Magnitude )
particle:SetDieTime( 0.5 + i * 0.01 )
particle:SetAirResistance( 125 )
particle:SetStartAlpha( 150 * self.Magnitude )
particle:SetStartSize( 40 * self.Magnitude )
particle:SetEndSize( 250 * self.Magnitude )
particle:SetRoll( math.Rand(-1,1) * math.pi )
particle:SetRollDelta( math.Rand(-1,1) * 3 )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( true )
particle:SetBounce( 0 )
end
end
end
function EFFECT:Think()
if not IsValid( self.Ent ) then return false end
if self.DieTime < CurTime() then return false end
self:SetPos( self.Ent:LocalToWorld( self.Pos ) )
return true
end
function EFFECT:Render()
if not IsValid( self.Ent ) or not self.Pos then return end
self:RenderFire()
end
function EFFECT:RenderFire()
local Scale = ((self.DieTime - CurTime()) / self.LifeTime) * (self.Magnitude or 0)
if Scale < 0 then return end
local Pos = self.Ent:LocalToWorld( self.Pos )
local scroll = -CurTime() * 10
local Up = Vector(0,0,0.92) + VectorRand() * 0.08
render.SetMaterial( self.FireMat )
render.StartBeam( 3 )
render.AddBeam( Pos, 64 * Scale, scroll, Color( 100, 100, 100, 100 ) )
render.AddBeam( Pos + Up * 120 * Scale, 64 * Scale, scroll + 1, Color( 255, 200, 50, 150 ) )
render.AddBeam( Pos + Up * 300 * Scale, 64 * Scale, scroll + 3, Color( 255, 191, 0, 0 ) )
render.EndBeam()
scroll = scroll * 0.5
render.UpdateRefractTexture()
render.SetMaterial( self.HeatMat )
render.StartBeam( 3 )
render.AddBeam( Pos, 64 * Scale, scroll, Color( 0, 0, 255, 200 ) )
render.AddBeam( Pos + Up * 64 * Scale, 64 * Scale, scroll + 2, color_white )
render.AddBeam( Pos + Up * 250 * Scale, 120 * Scale, scroll + 5, Color( 0, 0, 0, 0 ) )
render.EndBeam()
scroll = scroll * 1.3
render.SetMaterial( self.FireMat )
render.StartBeam( 3 )
render.AddBeam( Pos, 32 * Scale, scroll, Color( 100, 100, 100, 100 ) )
render.AddBeam( Pos + Up * 60 * Scale, 32 * Scale, scroll + 1, Color( 255, 200, 50, 150 ) )
render.AddBeam( Pos + Up * 300 * Scale, 32 * Scale, scroll + 3, Color( 255, 191, 0, 0 ) )
render.EndBeam()
end

View File

@@ -0,0 +1,110 @@
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
EFFECT.DustMat = {
"effects/lvs_base/particle_debris_01",
"effects/lvs_base/particle_debris_02",
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
local scale = data:GetMagnitude()
sound.Play( "physics/flesh/flesh_strider_impact_bullet"..math.random(1,3)..".wav", pos, 85, math.random(180,200) + 55 * math.max(1 - scale,0), 0.75 )
sound.Play( "ambient/materials/rock"..math.random(1,5)..".wav", pos, 75, 180, 1 )
local emitter = ParticleEmitter( pos, false )
local VecCol = (render.GetLightColor( pos + dir ) * 0.5 + Vector(0.2,0.18,0.15)) * 255
local DieTime = math.Rand(0.8,1.6)
if dir.z > 0.85 then
for i = 1, 10 do
for n = 0,6 do
local particle = emitter:Add( self.DustMat[ math.random(1,#self.DustMat) ] , pos )
if not particle then continue end
particle:SetVelocity( (dir * 50 * i + VectorRand() * 25) * scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * scale )
particle:SetEndSize( 20 * i * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-600) * scale )
particle:SetCollide( false )
end
end
for i = 1, 10 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , pos )
if not particle then continue end
particle:SetVelocity( (dir * 50 * i + VectorRand() * 40) * scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * scale )
particle:SetEndSize( 20 * i * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-600) * scale )
particle:SetCollide( false )
end
end
for i = 1,12 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , pos )
if particle then
local ang = i * 30
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
local Vel = Vector(X,Y,0) * math.Rand(200,1600) + Vector(0,0,50)
Vel:Rotate( dir:Angle() + Angle(90,0,0) )
particle:SetVelocity( Vel * scale )
particle:SetDieTime( DieTime )
particle:SetAirResistance( 500 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 40 * scale )
particle:SetEndSize( 200 * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,60) * scale )
particle:SetCollide( true )
end
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,229 @@
EFFECT.DustMat = {
"effects/lvs_base/particle_debris_01",
"effects/lvs_base/particle_debris_02",
}
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
EFFECT.SparkSurface = {
["chainlink"] = true,
["canister"] = true,
["metal_barrel"] = true,
["metalvehicle"] = true,
["metal"] = true,
["metalgrate"] = true,
["rubbertire"] = true,
}
EFFECT.DustSurface = {
["sand"] = true,
["dirt"] = true,
["grass"] = true,
["antlionsand"] = true,
}
EFFECT.SmokeSurface = {
["concrete"] = true,
["tile"] = true,
["plaster"] = true,
["boulder"] = true,
["plastic"] = true,
["default"] = true,
["glass"] = true,
["brick"] = true,
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local bullet_dir = data:GetStart()
local dir = data:GetNormal()
local magnitude = data:GetMagnitude()
local ent = data:GetEntity()
local surface = data:GetSurfaceProp()
local surfaceName = util.GetSurfacePropName( surface )
local emitter = ParticleEmitter( pos, false )
local VecCol = (render.GetLightColor( pos ) * 0.8 + Vector(0.17,0.15,0.1)) * 255
local DieTime = math.Rand(0.8,1.4)
for i = 1, 60 * magnitude do
local spark = emitter:Add("effects/spark", pos + dir * 8)
if not spark then continue end
spark:SetStartAlpha( 255 )
spark:SetEndAlpha( 0 )
spark:SetCollide( true )
spark:SetBounce( math.Rand(0,1) )
spark:SetColor( 255, 255, 255 )
spark:SetGravity( Vector(0,0,-600) )
spark:SetEndLength(0)
local size = math.Rand(4, 6) * magnitude
spark:SetEndSize( size )
spark:SetStartSize( size )
spark:SetStartLength( math.Rand(20,40) * magnitude )
spark:SetDieTime( math.Rand(0.4, 1.2) )
spark:SetVelocity( (dir * math.Rand(300, 600) + VectorRand() * 300) * magnitude )
end
local flash = emitter:Add( "effects/yellowflare",pos )
if flash then
flash:SetPos( pos + dir * 15 )
flash:SetStartAlpha( 200 )
flash:SetEndAlpha( 0 )
flash:SetColor( 255,255,255 )
flash:SetEndSize( 0 )
flash:SetDieTime( 0.075 )
flash:SetStartSize( 300 * magnitude ^ 2 )
end
if self.SparkSurface[ surfaceName ] then
if IsValid( ent ) and ent.LVS then
if (90 - math.deg( math.acos( math.Clamp( -dir:Dot( bullet_dir ) ,-1,1) ) )) > 10 then
local effectdata = EffectData()
effectdata:SetOrigin( pos )
util.Effect( "cball_explode", effectdata, true, true )
local Ax = math.acos( math.Clamp( dir:Dot( bullet_dir ) ,-1,1) )
local Fx = math.cos( Ax )
local effectdata = EffectData()
effectdata:SetOrigin( pos )
effectdata:SetNormal( (bullet_dir - dir * Fx * 2):GetNormalized() * 0.75 )
util.Effect( "manhacksparks", effectdata, true, true )
local effectdata = EffectData()
effectdata:SetOrigin( pos )
effectdata:SetNormal( -bullet_dir * 0.75 )
util.Effect( "manhacksparks", effectdata, true, true )
end
else
local effectdata = EffectData()
effectdata:SetOrigin( pos )
util.Effect( "cball_explode", effectdata, true, true )
local effectdata = EffectData()
effectdata:SetOrigin( pos )
effectdata:SetNormal( dir )
util.Effect( "manhacksparks", effectdata, true, true )
local effectdata = EffectData()
effectdata:SetOrigin( pos )
effectdata:SetNormal( -bullet_dir )
util.Effect( "manhacksparks", effectdata, true, true )
end
end
if self.SmokeSurface[ surfaceName ] then
for i = 1, 24 do
local particle = emitter:Add( self.SmokeMat[ math.random(1, #self.SmokeMat ) ], pos )
if not particle then continue end
particle:SetStartAlpha( math.Rand(33, 66) )
particle:SetEndAlpha( 0 )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-math.Rand(33, 66)) )
particle:SetRollDelta( math.random(0, 0.5 * math.pi) )
particle:SetAirResistance( 175 )
particle:SetStartSize( 15 )
particle:SetDieTime( math.Rand(0.5, 1) )
particle:SetEndSize( math.Rand(45, 90) )
particle:SetVelocity( dir * math.Rand(40, 200) + VectorRand() * 150)
end
for i = 1,15 do
local particle = emitter:Add("effects/fleck_cement" .. math.random(1, 2), pos + dir * 8)
if not particle then continue end
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetCollide( true )
particle:SetBounce( math.Rand(0,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity(Vector(0,0,-600))
particle:SetRollDelta( math.random(0, 0.5*math.pi) )
particle:SetEndSize( 2 )
particle:SetStartSize( 2 )
particle:SetDieTime( math.Rand(1, 2) )
particle:SetVelocity( dir * math.Rand(40, 200) + VectorRand() * 500 )
end
end
if not self.DustSurface[ surfaceName ] then return end
for i = 1, 10 do
for i = 1, 15 do
local particle = emitter:Add( self.SmokeMat[ math.random(1, #self.SmokeMat ) ], pos )
if not particle then continue end
particle:SetStartAlpha( math.Rand(40, 80) )
particle:SetEndAlpha(0)
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-math.Rand(75, 150)) )
particle:SetRollDelta( math.random(0, 0.5*math.pi) )
particle:SetAirResistance( 175 )
particle:SetStartSize( 5 )
particle:SetDieTime( math.Rand(0.5, 1) )
particle:SetEndSize( math.Rand(15, 30) )
particle:SetVelocity( (dir * math.Rand(80, 400) + VectorRand() * 100) * 1.5 )
end
for n = 0,6 do
local particle = emitter:Add( self.DustMat[ math.random(1,#self.DustMat) ] , pos )
if not particle then continue end
particle:SetVelocity( (dir * 50 * i + VectorRand() * 50) )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 5 )
particle:SetEndSize( 10 * i )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-600) )
particle:SetCollide( false )
end
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,277 @@
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
EFFECT.DustMat = {
"effects/lvs_base/particle_debris_01",
"effects/lvs_base/particle_debris_02",
}
EFFECT.DecalMat = Material( util.DecalMaterial( "Scorch" ) )
function EFFECT:Init( data )
self.Dir = data:GetNormal()
self.Pos = data:GetOrigin()
self.LifeTime = 0.35
self.DieTime = CurTime() + self.LifeTime
local scale = data:GetMagnitude() * 0.5
self.Scale = 3 * scale
local emitter = ParticleEmitter( self.Pos, false )
local VecCol = (render.GetLightColor( self.Pos + self.Dir ) * 0.5 + Vector(0.1,0.09,0.075)) * 255
local DieTime = math.Rand(0.8,1.6)
local traceSky = util.TraceLine( {
start = self.Pos,
endpos = self.Pos + Vector(0,0,50000),
filter = self,
} )
local traceWater = util.TraceLine( {
start = traceSky.HitPos,
endpos = self.Pos - Vector(0,0,100),
filter = self,
mask = MASK_WATER,
} )
if traceWater.Hit then
local effectdata = EffectData()
effectdata:SetOrigin( traceWater.HitPos )
effectdata:SetScale( 100 )
effectdata:SetFlags( 2 )
util.Effect( "WaterSplash", effectdata, true, true )
end
local Pos = self.Pos
local Dist = (traceWater.HitPos - Pos):Length()
local ply = LocalPlayer():GetViewEntity()
if not IsValid( ply ) then return end
local delay = (Pos - ply:GetPos()):Length() / 13503.9
if traceWater.Hit and Dist > 150 then
timer.Simple( delay, function()
local effectdata = EffectData()
effectdata:SetOrigin( Pos )
util.Effect( "WaterSurfaceExplosion", effectdata, true, true )
end )
if Dist > 300 then return end
else
timer.Simple( delay, function()
sound.Play( "LVS.BULLET_EXPLOSION", Pos )
sound.Play( "LVS.BULLET_EXPLOSION_DYNAMIC", Pos )
end )
local trace = util.TraceLine( {
start = self.Pos + Vector(0,0,100),
endpos = self.Pos - Vector(0,0,100),
mask = MASK_SOLID_BRUSHONLY,
} )
if trace.Hit and not trace.HitNonWorld then
util.DecalEx( self.DecalMat, trace.Entity, trace.HitPos + trace.HitNormal, trace.HitNormal, Color(255,255,255,255), self.Scale * 2.5, self.Scale * 2.5 )
end
end
if self.Dir.z > 0.8 then
for i = 1, 10 do
for n = 0,6 do
local particle = emitter:Add( self.DustMat[ math.random(1,#self.DustMat) ], self.Pos )
if not particle then continue end
particle:SetVelocity( (self.Dir * 50 * i + VectorRand() * 25) * self.Scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * self.Scale )
particle:SetEndSize( 20 * i * self.Scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-600) * self.Scale )
particle:SetCollide( false )
end
end
for i = 1, 10 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ], self.Pos )
if not particle then continue end
particle:SetVelocity( (self.Dir * 50 * i + VectorRand() * 40) * self.Scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * self.Scale )
particle:SetEndSize( 20 * i * self.Scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-600) * self.Scale )
particle:SetCollide( false )
end
end
for i = 1,24 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , self.Pos )
if not particle then continue end
local ang = i * 15
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
local Vel = Vector(X,Y,0) * math.Rand(800,1200)
Vel:Rotate( self.Dir:Angle() + Angle(90,0,0) )
particle:SetVelocity( Vel * self.Scale )
particle:SetDieTime( math.Rand(1,3) )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 40 * self.Scale )
particle:SetEndSize( 140 * self.Scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,60) * self.Scale )
particle:SetCollide( true )
end
for i = 0, 15 do
local particle = emitter:Add( self.SmokeMat[ math.random(1, #self.SmokeMat ) ], self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 1000 * scale )
particle:SetDieTime( math.Rand(2,3) )
particle:SetAirResistance( 200 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 200 * scale )
particle:SetEndSize( 600 * scale )
particle:SetRoll( math.Rand(-1,1) )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector( 0, 0, -600 ) * scale )
particle:SetCollide( false )
end
end
for i = 0, 20 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 800 * scale )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 120 * scale )
particle:SetEndSize( 20 * scale )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( self.Dir * 2500 )
particle:SetRollDelta( math.Rand(-5,5) )
particle:SetAirResistance( 300 )
end
for i = 0, 5 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Pos )
if not particle then continue end
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( Vector(0,0,0) )
local size = math.Rand(8, 24) * scale
particle:SetEndSize( size )
particle:SetStartSize( size )
particle:SetStartLength( 400 * scale )
particle:SetEndLength( size )
particle:SetDieTime( math.Rand(0.1,0.2) )
particle:SetVelocity( (self.Dir * 4000 + VectorRand() * 2000) * scale )
particle:SetAirResistance( 0 )
end
for i = 0, 40 do
local particle = emitter:Add( "effects/fire_embers"..math.random(1,2), self.Pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 800 * scale )
particle:SetDieTime( math.Rand(0.4,0.6) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 40 * scale )
particle:SetEndSize( 0 )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( Vector(0,0,600) )
particle:SetRollDelta( math.Rand(-8,8) )
particle:SetAirResistance( 300 )
end
emitter:Finish()
end
function EFFECT:Explosion( pos , scale )
local emitter = ParticleEmitter( pos, false )
if not IsValid( emitter ) then return end
for i = 0, 40 do
local particle = emitter:Add( "particles/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( VectorRand() * 1500 * scale )
particle:SetDieTime( 0.2 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 20 * scale )
particle:SetEndSize( math.Rand(180,240) * scale )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
end
emitter:Finish()
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
if not self.Scale then return end
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local R1 = 800 * self.Scale
render.SetMaterial( self.GlowMat )
render.DrawSprite( self.Pos, R1 * Scale, R1 * Scale, Color( 255, 200, 150, 255) )
end

View File

@@ -0,0 +1,57 @@
EFFECT.Smoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
if not IsValid( Ent ) then return end
local emitter = Ent:GetParticleEmitter( Ent:WorldToLocal( Pos ) )
if not IsValid( emitter ) then return end
local particle = emitter:Add( self.Smoke[ math.random(1, #self.Smoke ) ], Pos )
local rCol = math.random(30,60)
local Scale = math.Rand(1,8)
if not particle then return end
particle:SetVelocity( Vector(0,0,80) + VectorRand() * 80 )
particle:SetDieTime( Scale )
particle:SetAirResistance( 200 )
particle:SetStartAlpha( 100 / Scale )
particle:SetStartSize( 20 )
particle:SetEndSize( math.random(15,30) * Scale )
particle:SetRoll( math.pi / Scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( rCol, rCol, rCol )
particle:SetGravity( Vector( 0, 0, math.random(-40,80) ) )
particle:SetCollide( true )
particle:SetBounce( 0 )
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,130 @@
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
EFFECT.FireMat = {
[1] = Material( "effects/lvs_base/flamelet1" ),
[2] = Material( "effects/lvs_base/flamelet2" ),
[3] = Material( "effects/lvs_base/flamelet3" ),
[4] = Material( "effects/lvs_base/flamelet4" ),
[5] = Material( "effects/lvs_base/flamelet5" ),
[6] = Material( "effects/lvs_base/fire" ),
}
EFFECT.SmokeMat = {
[1] = Material( "particle/smokesprites_0001" ),
[2] = Material( "particle/smokesprites_0002" ),
[3] = Material( "particle/smokesprites_0003" ),
[4] = Material( "particle/smokesprites_0004" ),
[5] = Material( "particle/smokesprites_0005" ),
[6] = Material( "particle/smokesprites_0006" ),
[7] = Material( "particle/smokesprites_0007" ),
[8] = Material( "particle/smokesprites_0008" ),
[9] = Material( "particle/smokesprites_0009" ),
[10] = Material( "particle/smokesprites_0010" ),
[11] = Material( "particle/smokesprites_0011" ),
[12] = Material( "particle/smokesprites_0012" ),
[13] = Material( "particle/smokesprites_0013" ),
[14] = Material( "particle/smokesprites_0014" ),
[15] = Material( "particle/smokesprites_0015" ),
[16] = Material( "particle/smokesprites_0016" ),
}
EFFECT.Smoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
self.LifeTime = 1
self.DieTime = CurTime() + self.LifeTime
if not IsValid( Ent ) then return end
local randomPos = VectorRand() * 15
randomPos.z = 0
self.Ent = Ent
self.Pos = Ent:WorldToLocal( Pos + randomPos )
self.RandomSize = math.Rand( 0.8, 1.6 )
self.Vel = self.Ent:GetVelocity()
local emitter = Ent:GetParticleEmitter( self.Pos )
if not IsValid( emitter ) then return end
for i = 1, 8 do
local particle = emitter:Add( self.Smoke[ math.random(1, #self.Smoke ) ], Pos )
local Dir = Angle(0,math.Rand(-180,180),0):Forward()
Dir.z = -0.5
Dir:Normalize()
if particle then
particle:SetVelocity( Dir * 250 )
particle:SetDieTime( 0.5 + i * 0.01 )
particle:SetAirResistance( 125 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 20 )
particle:SetEndSize( 40 )
particle:SetRoll( math.Rand(-1,1) * math.pi )
particle:SetRollDelta( math.Rand(-1,1) * 3 )
particle:SetColor( 0, 0, 0 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( true )
particle:SetBounce( 0 )
end
end
end
function EFFECT:Think()
if not IsValid( self.Ent ) then return false end
if self.DieTime < CurTime() then return false end
self:SetPos( self.Ent:LocalToWorld( self.Pos ) )
return true
end
function EFFECT:Render()
if not IsValid( self.Ent ) or not self.Pos then return end
self:RenderFire()
end
function EFFECT:RenderFire()
local Scale = (self.DieTime - 0.4 - CurTime()) / 0.6
if Scale < 0 then return end
local Pos = self.Ent:LocalToWorld( self.Pos )
local InvScale = 1 - Scale
render.SetMaterial( self.GlowMat )
render.DrawSprite( Pos + Vector(0,0,InvScale ^ 2 * 10), 100 * InvScale, 100 * InvScale, Color( 255, 150, 75, 255) )
local Num = #self.FireMat - math.Clamp(math.ceil( Scale * #self.FireMat ) - 1,0, #self.FireMat - 1)
local Size = (5 + 20 * Scale) * self.RandomSize
local Offset = (self.Vel * InvScale ^ 2) * 0.025
render.SetMaterial( self.FireMat[ Num ] )
render.DrawSprite( Pos + Vector(0,0,InvScale ^ 2 * 30) - Offset, Size, Size, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,71 @@
EFFECT.SmokeMat = {
[1] = Material( "particle/smokesprites_0001" ),
[2] = Material( "particle/smokesprites_0002" ),
[3] = Material( "particle/smokesprites_0003" ),
[4] = Material( "particle/smokesprites_0004" ),
[5] = Material( "particle/smokesprites_0005" ),
[6] = Material( "particle/smokesprites_0006" ),
[7] = Material( "particle/smokesprites_0007" ),
[8] = Material( "particle/smokesprites_0008" ),
[9] = Material( "particle/smokesprites_0009" ),
[10] = Material( "particle/smokesprites_0010" ),
[11] = Material( "particle/smokesprites_0011" ),
[12] = Material( "particle/smokesprites_0012" ),
[13] = Material( "particle/smokesprites_0013" ),
[14] = Material( "particle/smokesprites_0014" ),
[15] = Material( "particle/smokesprites_0015" ),
[16] = Material( "particle/smokesprites_0016" ),
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
local Mag = data:GetMagnitude()
self.LifeTime = 0.5 + Mag * 0.5
self.DieTime = CurTime() + self.LifeTime
if not IsValid( Ent ) then return end
self.Mag = Mag
self.Ent = Ent
self.Pos = Ent:WorldToLocal( Pos + VectorRand() * 15 )
self.RandomSize = math.Rand( 0.8, 1.6 )
self.Vel = self.Ent:GetVelocity()
end
function EFFECT:Think()
if not IsValid( self.Ent ) then return false end
if self.DieTime < CurTime() then return false end
self:SetPos( self.Ent:LocalToWorld( self.Pos ) )
return true
end
function EFFECT:Render()
if not IsValid( self.Ent ) or not self.Pos then return end
self:RenderSmoke()
end
function EFFECT:RenderSmoke()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local Pos = self.Ent:LocalToWorld( self.Pos )
local InvScale = 1 - Scale
local Num = #self.SmokeMat - math.Clamp(math.ceil( Scale * #self.SmokeMat ) - 1,0, #self.SmokeMat - 1)
local A = (50 + 100 * (1 - self.Mag)) * Scale
local C = (20 + 30 * self.RandomSize * self.Mag)
local Size = (25 + 30 * InvScale) * self.RandomSize
local Offset = (self.Vel * InvScale ^ 2) * 0.15
render.SetMaterial( self.SmokeMat[ Num ] )
render.DrawSprite( Pos + Vector(0,0,InvScale ^ 2 * (20 + self.Vel:Length() / 25) * self.RandomSize) - Offset, Size, Size, Color( C, C, C, A ) )
end

View File

@@ -0,0 +1,127 @@
EFFECT.SmokeMat = {
[1] = Material( "particle/smokesprites_0001" ),
[2] = Material( "particle/smokesprites_0002" ),
[3] = Material( "particle/smokesprites_0003" ),
[4] = Material( "particle/smokesprites_0004" ),
[5] = Material( "particle/smokesprites_0005" ),
[6] = Material( "particle/smokesprites_0006" ),
[7] = Material( "particle/smokesprites_0007" ),
[8] = Material( "particle/smokesprites_0008" ),
[9] = Material( "particle/smokesprites_0009" ),
[10] = Material( "particle/smokesprites_0010" ),
[11] = Material( "particle/smokesprites_0011" ),
[12] = Material( "particle/smokesprites_0012" ),
[13] = Material( "particle/smokesprites_0013" ),
[14] = Material( "particle/smokesprites_0014" ),
[15] = Material( "particle/smokesprites_0015" ),
[16] = Material( "particle/smokesprites_0016" ),
}
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
EFFECT.FireMat = Material( "effects/muzzleflash2" )
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.Ang = data:GetAngles()
self.Ent = data:GetEntity()
self.LifeTime = 0.5
self.DieTime = CurTime() + self.LifeTime
if not IsValid( self.Ent ) then return end
self.Mat = self.SmokeMat[ math.random(1,#self.SmokeMat) ]
local Pos = self.Ent:LocalToWorld( self.Pos )
self:SetPos( Pos )
local dlight = DynamicLight( self.Ent:EntIndex() * math.random(1,4), true )
if dlight then
dlight.pos = Pos
dlight.r = 255
dlight.g = 180
dlight.b = 100
dlight.brightness = 1
dlight.Decay = 2000
dlight.Size = 300
dlight.DieTime = CurTime() + 0.2
end
sound.Play( "lvs/vehicles/generic/exhaust_backfire"..math.random(1,3)..".ogg", Pos, 75, 100, 1 )
local vel = self.Ent:GetVelocity()
local dir = self.Ent:LocalToWorldAngles( self.Ang ):Forward()
local emitter = ParticleEmitter( Pos, false )
if emitter then
for i = 0, 12 do
local particle = emitter:Add( "sprites/rico1", Pos )
if not particle then continue end
particle:SetVelocity( vel + dir * 100 + VectorRand() * 100 )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetStartAlpha( 0 )
particle:SetEndAlpha( 25 )
particle:SetStartSize( 1 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
particle:SetAirResistance( 0 )
particle:SetColor( 255, 225, 150 )
particle:SetGravity( Vector(0,0,-600) )
end
emitter:Finish()
end
end
function EFFECT:Think()
if not IsValid( self.Ent ) then return false end
if self.DieTime < CurTime() then return false end
self:SetPos( self.Ent:LocalToWorld( self.Pos ) )
return true
end
function EFFECT:Render()
if not IsValid( self.Ent ) or not self.Pos then return end
self:RenderSmoke()
end
function EFFECT:RenderSmoke()
if not self.Pos or not self.Ang then return end
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local InvScale = 1 - Scale
local Pos = self.Ent:LocalToWorld( self.Pos )
local Ang = self.Ent:LocalToWorldAngles( self.Ang )
local FlameSize = 40 * Scale ^ 2
render.SetMaterial( self.FireMat )
for i = 1, 4 do
render.DrawSprite( Pos + Ang:Forward() * InvScale * 5 + VectorRand() * 2, FlameSize, FlameSize, Color( 255, 255, 255, 255 * InvScale) )
end
local GlowSize = 80 * Scale ^ 2
render.SetMaterial( self.GlowMat )
render.DrawSprite( Pos + Ang:Forward() * InvScale * 10, GlowSize, GlowSize, Color(255* InvScale, 150* InvScale,75* InvScale,255* InvScale) )
if not self.Mat then return end
local C = 40
local Size = (20 + 50 * InvScale)
render.SetMaterial( self.Mat )
render.DrawSprite( Pos + Ang:Forward() * InvScale * 40, Size, Size, Color( C, C, C, 255 * Scale) )
end

View File

@@ -0,0 +1,105 @@
EFFECT.GlowMat = Material( "effects/yellowflare" )
EFFECT.FireMat = Material( "effects/muzzleflash2" )
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.Ang = data:GetAngles()
self.Ent = data:GetEntity()
local volume = math.Clamp( data:GetMagnitude(), 0, 1 )
local T = CurTime()
self.LifeTime = 0.25
self.LifeTimePop = 0.1
self.DieTime = T + self.LifeTime
self.DieTimePop = T + self.LifeTimePop
self.Scale = math.Rand( 0.25, 1 )
if not IsValid( self.Ent ) then return end
local Pos = self.Ent:LocalToWorld( self.Pos )
self:SetPos( Pos )
local ply = LocalPlayer()
if not IsValid( ply ) then return end
local veh = ply:lvsGetVehicle()
if IsValid( veh ) and veh == self.Ent then
local pod = ply:GetVehicle()
if IsValid( pod ) and not pod:GetThirdPersonMode() then
sound.Play( "lvs/vehicles/generic/exhaust_pop_interior"..math.random(1,12)..".ogg", Pos, 75, math.random(98,105), volume )
return
end
end
local dlight = DynamicLight( self.Ent:EntIndex() * math.random(1,4), true )
if dlight then
dlight.pos = Pos
dlight.r = 255
dlight.g = 180
dlight.b = 100
dlight.brightness = 1
dlight.Decay = 2000
dlight.Size = 400
dlight.DieTime = CurTime() + 0.2
end
sound.Play( "lvs/vehicles/generic/exhaust_pop"..math.random(1,16)..".ogg", Pos, 75, math.random(98,105), volume )
end
function EFFECT:Think()
if not IsValid( self.Ent ) then return false end
if self.DieTime < CurTime() then return false end
self:SetPos( self.Ent:LocalToWorld( self.Pos ) )
return true
end
function EFFECT:Render()
if not IsValid( self.Ent ) or not self.Pos then return end
self:RenderSmoke()
end
function EFFECT:RenderSmoke()
if not self.Pos or not self.Ang or not self.Scale then return end
local T = CurTime()
local ScalePop = math.Clamp( (self.DieTimePop - T) / self.LifeTimePop, 0, 1 )
local InvScalePop = 1 - ScalePop
local Scale = (self.DieTime - T) / self.LifeTime
local InvScale = 1 - Scale
local Pos = self.Ent:LocalToWorld( self.Pos )
local Ang = self.Ent:LocalToWorldAngles( self.Ang )
local FlameSize = 5 * Scale ^ 2
render.SetMaterial( self.FireMat )
for i = 1, 12 do
render.DrawSprite( Pos + Ang:Forward() * InvScale * 20 + VectorRand() * 2, FlameSize, FlameSize, color_white )
end
if InvScalePop <= 0 then return end
local GlowSize = 60 * InvScalePop * self.Scale
local A255 = 255 * ScalePop
render.SetMaterial( self.GlowMat )
render.DrawSprite( Pos, GlowSize, GlowSize, Color(A255,A255,A255,A255) )
end

View File

@@ -0,0 +1,145 @@
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
EFFECT.FireMat = {
[1] = Material( "effects/lvs_base/flamelet1" ),
[2] = Material( "effects/lvs_base/flamelet2" ),
[3] = Material( "effects/lvs_base/flamelet3" ),
[4] = Material( "effects/lvs_base/flamelet4" ),
[5] = Material( "effects/lvs_base/flamelet5" ),
[6] = Material( "effects/lvs_base/fire" ),
}
EFFECT.SmokeMat = {
[1] = Material( "particle/smokesprites_0001" ),
[2] = Material( "particle/smokesprites_0002" ),
[3] = Material( "particle/smokesprites_0003" ),
[4] = Material( "particle/smokesprites_0004" ),
[5] = Material( "particle/smokesprites_0005" ),
[6] = Material( "particle/smokesprites_0006" ),
[7] = Material( "particle/smokesprites_0007" ),
[8] = Material( "particle/smokesprites_0008" ),
[9] = Material( "particle/smokesprites_0009" ),
[10] = Material( "particle/smokesprites_0010" ),
[11] = Material( "particle/smokesprites_0011" ),
[12] = Material( "particle/smokesprites_0012" ),
[13] = Material( "particle/smokesprites_0013" ),
[14] = Material( "particle/smokesprites_0014" ),
[15] = Material( "particle/smokesprites_0015" ),
[16] = Material( "particle/smokesprites_0016" ),
}
EFFECT.Smoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
self.LifeTime = 1
self.DieTime = CurTime() + self.LifeTime
if not IsValid( Ent ) then return end
self.Ent = Ent
self.Pos = Ent:WorldToLocal( Pos + VectorRand() * 20 )
self.RandomSize = math.Rand( 1, 2 )
self.Vel = self.Ent:GetVelocity()
local emitter = Ent:GetParticleEmitter( self.Pos )
if not IsValid( emitter ) then return end
for i = 1, 8 do
local particle = emitter:Add( self.Smoke[ math.random(1, #self.Smoke ) ], Pos )
local Dir = Angle(0,math.Rand(-180,180),0):Forward()
Dir.z = -0.5
Dir:Normalize()
if particle then
particle:SetVelocity( Dir * 250 )
particle:SetDieTime( 0.5 + i * 0.01 )
particle:SetAirResistance( 125 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 20 )
particle:SetEndSize( 40 )
particle:SetRoll( math.Rand(-1,1) * math.pi )
particle:SetRollDelta( math.Rand(-1,1) * 3 )
particle:SetColor( 0, 0, 0 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( true )
particle:SetBounce( 0 )
end
end
end
function EFFECT:Think()
if not IsValid( self.Ent ) then return false end
if self.DieTime < CurTime() then return false end
self:SetPos( self.Ent:LocalToWorld( self.Pos ) )
return true
end
function EFFECT:Render()
if not IsValid( self.Ent ) or not self.Pos then return end
self:RenderSmoke()
self:RenderFire()
end
function EFFECT:RenderSmoke()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local Pos = self.Ent:LocalToWorld( self.Pos ) + Vector(0,0,25)
local InvScale = 1 - Scale
local Num = #self.SmokeMat - math.Clamp(math.ceil( Scale * #self.SmokeMat ) - 1,0, #self.SmokeMat - 1)
local C = 10 + 10 * self.RandomSize
local Size = (25 + 30 * InvScale) * self.RandomSize
local Offset = (self.Vel * InvScale ^ 2) * 0.5
render.SetMaterial( self.SmokeMat[ Num ] )
render.DrawSprite( Pos + Vector(0,0,InvScale ^ 2 * 80 * self.RandomSize) - Offset, Size, Size, Color( C, C, C, 200 * Scale) )
end
function EFFECT:RenderFire()
local Scale = (self.DieTime - 0.4 - CurTime()) / 0.6
if Scale < 0 then return end
local Pos = self.Ent:LocalToWorld( self.Pos )
local InvScale = 1 - Scale
render.SetMaterial( self.GlowMat )
render.DrawSprite( Pos + Vector(0,0,InvScale ^ 2 * 10), 100 * InvScale, 100 * InvScale, Color( 255, 150, 75, 255) )
local Num = #self.FireMat - math.Clamp(math.ceil( Scale * #self.FireMat ) - 1,0, #self.FireMat - 1)
local Size = (10 + 20 * Scale) * self.RandomSize
local Offset = (self.Vel * InvScale ^ 2) * 0.025
render.SetMaterial( self.FireMat[ Num ] )
render.DrawSprite( Pos + Vector(0,0,InvScale ^ 2 * 25) - Offset, Size, Size, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,119 @@
local GlowMat = Material( "sprites/light_glow02_add" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.LifeTime = 0.4
self.DieTime = CurTime() + self.LifeTime
local emitter = ParticleEmitter( self.Pos, false )
if not IsValid( emitter ) then return end
for i = 0,30 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 800 )
particle:SetDieTime( math.Rand(4,6) )
particle:SetAirResistance( math.Rand(200,600) )
particle:SetStartAlpha( 100 )
particle:SetStartSize( math.Rand(30,60) )
particle:SetEndSize( math.Rand(100,150) )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 50,50,50 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
end
for i = 0, 20 do
local particle = emitter:Add( "sprites/light_glow02_add", self.Pos )
local vel = VectorRand() * 400
if particle then
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.4,0.8) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(24,48) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( 255, 40, 100 )
particle:SetGravity( Vector(0,0,-600) )
particle:SetAirResistance( 0 )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
end
end
for i = 0, 40 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 500 )
particle:SetDieTime( 0.14 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 )
particle:SetEndSize( math.Rand(30,60) )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
end
emitter:Finish()
local Pos = self.Pos
local ply = LocalPlayer():GetViewEntity()
if IsValid( ply ) then
local delay = (Pos - ply:GetPos()):Length() / 13503.9
if delay <= 0.11 then
sound.Play( "ambient/explosions/explode_9.wav", Pos, 85, 100, 1 - delay * 8 )
end
timer.Simple( delay, function()
sound.Play( "LVS.MISSILE_EXPLOSION", Pos )
end )
else
sound.Play( "LVS.MISSILE_EXPLOSION", Pos )
end
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
render.SetMaterial( GlowMat )
render.DrawSprite( self.Pos, 400 * Scale, 400 * Scale, Color( 255, 40, 100, 255) )
render.DrawSprite( self.Pos, 100 * Scale, 100 * Scale, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,124 @@
EFFECT.Offset = Vector(-8,0,0)
local GlowMat = Material( "effects/select_ring" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if IsValid( self.Entity ) then
self.OldPos = self.Entity:LocalToWorld( self.Offset )
self.Emitter = ParticleEmitter( self.Entity:LocalToWorld( self.OldPos ), false )
end
end
function EFFECT:doFX( pos )
if not IsValid( self.Entity ) then return end
if IsValid( self.Emitter ) then
local emitter = self.Emitter
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if particle then
particle:SetGravity( Vector(0,0,100) + VectorRand() * 50 )
particle:SetVelocity( -self.Entity:GetForward() * 200 )
particle:SetAirResistance( 600 )
particle:SetDieTime( math.Rand(2,3) )
particle:SetStartAlpha( 100 )
particle:SetStartSize( math.Rand(5,6) )
particle:SetEndSize( math.Rand(12,30) )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 50,50,50 )
particle:SetCollide( false )
end
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( -self.Entity:GetForward() * math.Rand(250,800) + self.Entity:GetVelocity())
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( math.Rand(10,15) )
particle:SetEndSize( 5 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 150,50,100 )
particle:SetGravity( Vector( 0, 0, 0 ) )
particle:SetCollide( false )
end
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Entity:GetPos() )
if particle then
particle:SetVelocity( -self.Entity:GetForward() * 200 + VectorRand() * 50 )
particle:SetDieTime( 0.25 )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( math.Rand(6,10) )
particle:SetEndSize( math.Rand(2,3) )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 255,100,200 )
particle:SetGravity( Vector( 0, 0, 0 ) )
particle:SetCollide( false )
end
end
end
function EFFECT:Think()
if IsValid( self.Entity ) then
self.nextDFX = self.nextDFX or 0
if self.nextDFX < CurTime() then
self.nextDFX = CurTime() + 0.02
local oldpos = self.OldPos
local newpos = self.Entity:LocalToWorld( self.Offset )
self:SetPos( newpos )
local Sub = (newpos - oldpos)
local Dir = Sub:GetNormalized()
local Len = Sub:Length()
self.OldPos = newpos
for i = 0, Len, 45 do
local pos = oldpos + Dir * i
self:doFX( pos )
end
end
return true
end
if IsValid( self.Emitter ) then
self.Emitter:Finish()
end
return false
end
function EFFECT:Render()
local ent = self.Entity
local pos = ent:LocalToWorld( self.Offset )
render.SetMaterial( GlowMat )
render.DrawSprite( pos, 100, 100, Color( 255, 40, 100, 50 ) )
end

View File

@@ -0,0 +1,182 @@
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
EFFECT.DustMat = {
"effects/lvs_base/particle_debris_01",
"effects/lvs_base/particle_debris_02",
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
local scale = data:GetMagnitude()
self.LifeTime = 0.35
self.DieTime = CurTime() + self.LifeTime
self.Pos = pos
self.Scale = scale
sound.Play( "weapons/shotgun/shotgun_fire6.wav", pos, 75, 150, 1 )
local VecCol = (render.GetLightColor( pos + dir ) * 0.5 + Vector(0.2,0.18,0.15)) * 255
local emitter = ParticleEmitter( pos, false )
for i = 0,20 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 500 * scale )
particle:SetDieTime( math.Rand(0.4,0.6) )
particle:SetAirResistance( 500 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 40 * scale )
particle:SetEndSize( 200 * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,1200) )
particle:SetCollide( true )
end
for i = 1,12 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , pos )
if not particle then continue end
local ang = i * 30
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
local Vel = Vector(X,Y,0) * 1000
Vel:Rotate( dir:Angle() + Angle(90,0,0) )
particle:SetVelocity( Vel * scale )
particle:SetDieTime( math.Rand(0.6,0.8) )
particle:SetAirResistance( 500 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 30 * scale )
particle:SetEndSize( 60 * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,600) )
particle:SetCollide( true )
end
for i = 0, 15 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 400 * scale )
particle:SetDieTime( math.Rand(0.2,0.3) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 60 * scale )
particle:SetEndSize( 10 * scale )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( dir * 2500 )
particle:SetRollDelta( math.Rand(-5,5) )
particle:SetAirResistance( 300 )
end
for i = 0, 5 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos)
if not particle then continue end
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( Vector(0,0,0) )
local size = math.Rand(2, 12) * scale
particle:SetEndSize( size )
particle:SetStartSize( size )
particle:SetStartLength( 100 * scale )
particle:SetEndLength( size )
particle:SetDieTime( math.Rand(0.1,0.2) )
particle:SetVelocity( (dir * 2000 + VectorRand() * 1000) * scale )
particle:SetAirResistance( 0 )
end
for i = 0, 40 do
local particle = emitter:Add( "effects/fire_embers"..math.random(1,2), pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 400 * scale )
particle:SetDieTime( math.Rand(0.4,0.6) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 20 * scale )
particle:SetEndSize( 0 )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( Vector(0,0,600) )
particle:SetRollDelta( math.Rand(-8,8) )
particle:SetAirResistance( 300 )
end
if dir.z > 0.8 then
for i = 0,60 do
local particle = emitter:Add( "effects/fleck_cement"..math.random(1,2), pos )
local vel = dir * math.Rand(600,1000) + VectorRand() * 200
if not particle then continue end
particle:SetVelocity( vel * scale )
particle:SetDieTime( math.Rand(10,15) )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
local size = math.Rand(2, 4) * scale
particle:SetEndSize( size )
particle:SetStartSize( size )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( true )
particle:SetBounce( 0.3 )
end
end
emitter:Finish()
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
if not self.Scale then return end
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local R1 = 800 * self.Scale
render.SetMaterial( self.GlowMat )
render.DrawSprite( self.Pos, R1 * Scale, R1 * Scale, Color( 255, 200, 150, 255) )
end

View File

@@ -0,0 +1,56 @@
EFFECT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local emitter = ParticleEmitter( pos, false )
if not emitter then return end
local VecCol = (render.GetLightColor( pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
for i = 0,2 do
local particle = emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 200 )
particle:SetDieTime( math.Rand(4,6) )
particle:SetAirResistance( 250 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 0 )
particle:SetEndSize( 650 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( VectorRand() * 600 )
particle:SetCollide( true )
particle:SetBounce( 1 )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,43 @@
function EFFECT:Init( data )
self.Ent = data:GetEntity()
self.Pos = data:GetOrigin()
local T = CurTime()
self.LifeTime = 1
self.DieTime = T + self.LifeTime
if IsValid( self.Ent ) then
self.Model = ClientsideModel( self.Ent:GetModel(), RENDERMODE_TRANSCOLOR )
self.Model:SetMaterial("models/alyx/emptool_glow")
self.Model:SetColor( Color(255,0,0,255) )
self.Model:SetParent( self.Ent, 0 )
self.Model:SetMoveType( MOVETYPE_NONE )
self.Model:SetLocalPos( Vector( 0, 0, 0 ) )
self.Model:SetLocalAngles( Angle( 0, 0, 0 ) )
self.Model:AddEffects( EF_BONEMERGE )
self.Model:SetModelScale( self.Ent:GetModelScale() )
end
end
function EFFECT:Think()
if not IsValid( self.Ent ) then
if IsValid( self.Model ) then
self.Model:Remove()
end
end
if self.DieTime < CurTime() then
if IsValid( self.Model ) then
self.Model:Remove()
end
return false
end
return true
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,53 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin() + VectorRand() * 25
local Ent = data:GetEntity()
if not IsValid( Ent ) then return end
local emitter = Ent:GetParticleEmitter( Pos )
if not IsValid( emitter ) then return end
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], Pos )
if particle then
particle:SetVelocity( VectorRand() * 100 )
particle:SetDieTime( 2 )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 50 )
particle:SetStartSize( 60 )
particle:SetEndSize( 200 )
particle:SetRoll( math.Rand(-1,1) * math.pi )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( 60, 60, 60 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( false )
end
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,59 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Dir = data:GetNormal()
local Ent = data:GetEntity()
local Scale = data:GetMagnitude()
if not IsValid( Ent ) then return end
local Vel = Ent:GetVelocity()
local emitter = Ent:GetParticleEmitter( Pos )
if not IsValid( emitter ) then return end
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], Pos )
if not particle then return end
local Col = 100 - 60 * Scale
particle:SetVelocity( Vel + Dir * (100 + 50 * Scale) )
particle:SetDieTime( 0.4 - 0.3 * Scale )
particle:SetAirResistance( 400 )
particle:SetStartAlpha( 80 )
particle:SetStartSize( 2 )
particle:SetEndSize( 10 + 20 * Scale )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetRollDelta( math.Rand( -1, 1 ) * 2 )
particle:SetColor( Col, Col, Col )
particle:SetGravity( Vector( 0, 0, 10 ) )
particle:SetCollide( false )
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,52 @@
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Dir = data:GetNormal()
local Ent = data:GetEntity()
local Scale = data:GetMagnitude()
if not IsValid( Ent ) then return end
local emitter = Ent:GetParticleEmitter( Pos )
if not IsValid( emitter ) then return end
local particle = emitter:Add( "effects/lvs_base/fire", Pos )
if particle then
particle:SetVelocity( Dir * 70 )
particle:SetDieTime( 0.2 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 + 18 * Scale )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-1,1) * 180 )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
for i = 1, 3 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), Pos )
if particle then
particle:SetVelocity( Dir * 40 * i )
particle:SetDieTime( 0.2 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( (5 + 5 * Scale) - i )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-1,1) * 180 )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
end
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,178 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
EFFECT.DecalMat = Material( util.DecalMaterial( "Scorch" ) )
function EFFECT:Init( data )
local Pos = data:GetOrigin()
self.DieTime = CurTime() + 1
self:Explosion( Pos, 2 )
local ply = LocalPlayer():GetViewEntity()
if IsValid( ply ) then
local delay = (Pos - ply:GetPos()):Length() / 13503.9
timer.Simple( delay, function()
sound.Play( "LVS.DYNAMIC_EXPLOSION", Pos )
end )
else
sound.Play( "LVS.DYNAMIC_EXPLOSION", Pos )
end
for i = 1, 20 do
timer.Simple(math.Rand(0,0.01) * i, function()
if IsValid( self ) then
local p = Pos + VectorRand() * 10 * i
self:Explosion( p, math.Rand(0.5,0.8) )
end
end)
end
self:Debris( Pos )
local traceSky = util.TraceLine( {
start = Pos,
endpos = Pos + Vector(0,0,50000),
mask = MASK_SOLID_BRUSHONLY,
} )
local traceWater = util.TraceLine( {
start = traceSky.HitPos,
endpos = Pos - Vector(0,0,100),
mask = MASK_WATER,
} )
if traceWater.Hit then
local effectdata = EffectData()
effectdata:SetOrigin( traceWater.HitPos )
effectdata:SetScale( 100 )
effectdata:SetFlags( 2 )
util.Effect( "WaterSplash", effectdata, true, true )
else
local trace = util.TraceLine( {
start = Pos + Vector(0,0,100),
endpos = Pos - Vector(0,0,100),
mask = MASK_SOLID_BRUSHONLY,
} )
if trace.Hit and not trace.HitNonWorld then
for i = 1, 10 do
local StartPos = trace.HitPos + Vector(math.random(-25,25) * i,math.random(-25,25) * i,0)
local decalTrace = util.TraceLine( {
start = StartPos + Vector(0,0,100),
endpos = StartPos - Vector(0,0,100),
mask = MASK_SOLID_BRUSHONLY,
} )
util.DecalEx( self.DecalMat, trace.Entity, decalTrace.HitPos + decalTrace.HitNormal, decalTrace.HitNormal, Color(255,255,255,255), math.Rand(2,3), math.Rand(2,3) )
end
end
end
end
function EFFECT:Debris( pos )
local emitter = ParticleEmitter( pos, false )
if not IsValid( emitter ) then return end
for i = 0,60 do
local particle = emitter:Add( "effects/fleck_tile"..math.random(1,2), pos )
local vel = VectorRand() * math.Rand(200,600)
vel.z = math.Rand(200,600)
if particle then
particle:SetVelocity( vel )
particle:SetDieTime( math.Rand(10,15) )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 5 )
particle:SetEndSize( 5 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 0,0,0 )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( true )
particle:SetBounce( 0.3 )
end
end
emitter:Finish()
end
function EFFECT:Explosion( pos , scale )
local emitter = ParticleEmitter( pos, false )
if not IsValid( emitter ) then return end
for i = 0,10 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if particle then
particle:SetVelocity( VectorRand() * 1500 * scale )
particle:SetDieTime( math.Rand(0.75,1.5) * scale )
particle:SetAirResistance( math.Rand(200,600) )
particle:SetStartAlpha( 255 )
particle:SetStartSize( math.Rand(60,120) * scale )
particle:SetEndSize( math.Rand(220,320) * scale )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 40,40,40 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
end
for i = 0, 40 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( VectorRand() * 1500 * scale )
particle:SetDieTime( 0.2 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 20 * scale )
particle:SetEndSize( math.Rand(180,240) * scale )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
end
emitter:Finish()
local dlight = DynamicLight( math.random(0,9999) )
if dlight then
dlight.pos = pos
dlight.r = 255
dlight.g = 180
dlight.b = 100
dlight.brightness = 8
dlight.Decay = 2000
dlight.Size = 300
dlight.DieTime = CurTime() + 1
end
end
function EFFECT:Think()
if CurTime() < self.DieTime then return true end
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,297 @@
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
EFFECT.DustMat = {
"effects/lvs_base/particle_debris_01",
"effects/lvs_base/particle_debris_02",
}
EFFECT.DecalMat = Material( util.DecalMaterial( "Scorch" ) )
function EFFECT:Init( data )
self.Dir = Vector(0,0,1)
self.Pos = data:GetOrigin()
self.LifeTime = 0.35
self.DieTime = CurTime() + self.LifeTime
local scale = 3
local emitter = ParticleEmitter( self.Pos, false )
local VecCol = (render.GetLightColor( self.Pos + self.Dir ) * 0.5 + Vector(0.1,0.09,0.075)) * 255
local DieTime = math.Rand(0.8,1.6)
local traceSky = util.TraceLine( {
start = self.Pos,
endpos = self.Pos + Vector(0,0,50000),
filter = self,
} )
local traceWater = util.TraceLine( {
start = traceSky.HitPos,
endpos = self.Pos - Vector(0,0,100),
filter = self,
mask = MASK_WATER,
} )
if traceWater.Hit then
local effectdata = EffectData()
effectdata:SetOrigin( traceWater.HitPos )
effectdata:SetScale( 100 )
effectdata:SetFlags( 2 )
util.Effect( "WaterSplash", effectdata, true, true )
else
local trace = util.TraceLine( {
start = self.Pos + Vector(0,0,100),
endpos = self.Pos - Vector(0,0,100),
} )
if trace.Hit and not trace.HitNonWorld then
for i = 1, 3 do
local StartPos = trace.HitPos + Vector(math.random(-200,200),math.random(-200,200),0)
local decalTrace = util.TraceLine( {
start = StartPos + Vector(0,0,100),
endpos = StartPos - Vector(0,0,100),
} )
util.DecalEx( self.DecalMat, trace.Entity, decalTrace.HitPos + decalTrace.HitNormal, decalTrace.HitNormal, Color(255,255,255,255), math.Rand(3,6), math.Rand(3,6) )
end
end
end
local Pos = self.Pos
local Dist = (traceWater.HitPos - Pos):Length()
local ply = LocalPlayer():GetViewEntity()
if not IsValid( ply ) then return end
local delay = (Pos - ply:GetPos()):Length() / 13503.9
if traceWater.Hit and Dist > 150 then
timer.Simple( delay, function()
local effectdata = EffectData()
effectdata:SetOrigin( Pos )
util.Effect( "WaterSurfaceExplosion", effectdata, true, true )
end )
if Dist > 300 then return end
else
timer.Simple( delay, function()
sound.Play( "LVS.BOMB_EXPLOSION", Pos )
sound.Play( "LVS.BOMB_EXPLOSION_DYNAMIC", Pos )
end )
end
for i = 1, 10 do
for n = 0,6 do
local particle = emitter:Add( self.DustMat[ math.random(1,#self.DustMat) ], self.Pos )
if not particle then continue end
particle:SetVelocity( (self.Dir * 50 * i + VectorRand() * 25) * scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * scale )
particle:SetEndSize( 20 * i * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector(0,0,-600) * scale )
particle:SetCollide( false )
end
end
for i = 1, 10 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ], self.Pos )
if not particle then continue end
particle:SetVelocity( (self.Dir * 50 * i + VectorRand() * 40) * scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * scale )
particle:SetEndSize( 20 * i * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector(0,0,-600) * scale )
particle:SetCollide( false )
end
for i = 1,24 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , self.Pos )
if particle then
local ang = i * 15
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
local Vel = Vector(X,Y,0) * math.Rand(1500,2000)
particle:SetVelocity( Vel * scale )
particle:SetDieTime( math.Rand(1,3) )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 40 * scale )
particle:SetEndSize( 200 * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector(0,0,60) * scale )
particle:SetCollide( true )
end
end
for i = 0, 15 do
local particle = emitter:Add( self.SmokeMat[ math.random(1, #self.SmokeMat ) ], self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 1000 )
particle:SetDieTime( math.Rand(2,3) )
particle:SetAirResistance( 200 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 200 )
particle:SetEndSize( 600 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( false )
end
end
for i = 0, 15 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 500 )
particle:SetDieTime( math.Rand(0.15,0.3) )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 25 )
particle:SetEndSize( math.Rand(70,100) )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
end
for i = 0, 20 do
local particle = emitter:Add( "sprites/rico1", self.Pos )
local vel = VectorRand() * 800
if particle then
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(20,40) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( 0 )
particle:SetColor( 255, 255, 255 )
particle:SetAirResistance( 0 )
end
end
for i = 0,60 do
local particle = emitter:Add( "effects/fleck_tile"..math.random(1,2), self.Pos )
local vel = VectorRand() * math.Rand(800,1600)
vel.z = math.Rand(1000,4000)
if particle then
particle:SetVelocity( vel )
particle:SetDieTime( math.random(5,15) )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 5 )
particle:SetEndSize( 5 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 0,0,0 )
particle:SetGravity( Vector( 0, 0, -2000 ) )
particle:SetCollide( true )
particle:SetBounce( 0.3 )
end
end
emitter:Finish()
end
function EFFECT:Explosion( pos , scale )
local emitter = ParticleEmitter( pos, false )
if not IsValid( emitter ) then return end
for i = 0, 40 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( VectorRand() * 1500 * scale )
particle:SetDieTime( 0.2 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 20 * scale )
particle:SetEndSize( math.Rand(180,240) * scale )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
end
emitter:Finish()
local dlight = DynamicLight( math.random(0,9999) )
if dlight then
dlight.pos = pos
dlight.r = 255
dlight.g = 180
dlight.b = 100
dlight.brightness = 8
dlight.Decay = 2000
dlight.Size = 300
dlight.DieTime = CurTime() + 1
end
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
render.SetMaterial( self.GlowMat )
render.DrawSprite( self.Pos, 2000 * Scale, 2000 * Scale, Color( 255, 200, 150, 255) )
local Scale = (self.DieTime - self.LifeTime + 0.25 - CurTime()) / 0.25
local InvScale = 1 - Scale
if Scale > 0 then
render.SetColorMaterial()
render.DrawSphere( self.Pos, -450 * InvScale, 30,30, Color( 255, 200, 150, 150 * (Scale ^ 2) ) )
render.DrawSphere( self.Pos, -500 * InvScale, 30,30, Color( 255, 200, 150, 100 * (Scale ^ 2) ) )
render.DrawSphere( self.Pos, -550 * InvScale, 30,30, Color( 255, 200, 150, 25 * (Scale ^ 2) ) )
render.DrawSphere( self.Pos, 600 * InvScale, 30,30, Color( 255, 200, 150, 25 * (Scale ^ 2) ) )
end
end

View File

@@ -0,0 +1,92 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
self:Explosion( Pos, 2 )
local ply = LocalPlayer():GetViewEntity()
if IsValid( ply ) then
local delay = (Pos - ply:GetPos()):Length() / 13503.9
timer.Simple( delay, function()
sound.Play( "LVS.EXPLOSION", Pos )
end )
else
sound.Play( "LVS.EXPLOSION", Pos )
end
for i = 1, 20 do
timer.Simple(math.Rand(0,0.01) * i, function()
if not IsValid( self ) then return end
local p = Pos + VectorRand() * 10 * i
self:Explosion( p, math.Rand(0.5,0.8) )
end)
end
end
function EFFECT:Explosion( pos , scale )
local emitter = ParticleEmitter( pos, false )
if not IsValid( emitter ) then return end
for i = 0,10 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 1000 * scale )
particle:SetDieTime( math.Rand(0.75,1.5) * scale )
particle:SetAirResistance( math.Rand(200,600) )
particle:SetStartAlpha( 255 )
particle:SetStartSize( math.Rand(60,120) * scale )
particle:SetEndSize( math.Rand(160,280) * scale )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 40,40,40 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
for i = 0, 40 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 1000 * scale )
particle:SetDieTime( 0.14 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * scale )
particle:SetEndSize( math.Rand(60,120) * scale )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,112 @@
local GlowMat = Material( "sprites/light_glow02_add" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.LifeTime = 0.35
self.DieTime = CurTime() + self.LifeTime
local emitter = ParticleEmitter( self.Pos, false )
for i = 0, 15 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 1000 )
particle:SetDieTime( math.Rand(2,3) )
particle:SetAirResistance( math.Rand(200,600) )
particle:SetStartAlpha( 200 )
particle:SetStartSize( 120 )
particle:SetEndSize( 300 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( 50,50,50 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( false )
end
end
for i = 0, 15 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 500 )
particle:SetDieTime( math.Rand(0.15,0.3) )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 25 )
particle:SetEndSize( math.Rand(70,100) )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
end
for i = 0, 20 do
local particle = emitter:Add( "sprites/rico1", self.Pos )
local vel = VectorRand() * 800
if particle then
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(20,40) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( 0 )
particle:SetColor( 255, 255, 255 )
particle:SetAirResistance( 0 )
end
end
emitter:Finish()
local Pos = self.Pos
local ply = LocalPlayer():GetViewEntity()
if IsValid( ply ) then
local delay = (Pos - ply:GetPos()):Length() / 13503.9
if delay <= 0.11 then
sound.Play( "ambient/explosions/explode_9.wav", Pos, 85, 100, 1 - delay * 8 )
end
timer.Simple( delay, function()
sound.Play( "LVS.MISSILE_EXPLOSION", Pos )
end )
else
sound.Play( "LVS.MISSILE_EXPLOSION", Pos )
end
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
render.SetMaterial( GlowMat )
render.DrawSprite( self.Pos, 2000 * Scale, 2000 * Scale, Color( 255, 200, 150, 255) )
end

View File

@@ -0,0 +1,111 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Entity = data:GetEntity()
self.Scale = data:GetScale()
self.DieTime = CurTime() + data:GetMagnitude()
self.Pos = data:GetStart()
if not IsValid( self.Entity ) then return end
self.Emitter = ParticleEmitter( self.Entity:LocalToWorld( self.Pos ), false )
end
function EFFECT:Think()
if IsValid( self.Entity ) then
local Pos = self.Entity:LocalToWorld( self.Pos )
local T = CurTime()
if (self.nextDFX or 0) < T then
self.nextDFX = T + 0.05
if self.Emitter then
local particle = self.Emitter:Add( Materials[ math.random(1, #Materials ) ], Pos )
if particle then
particle:SetVelocity( VectorRand() * 100 * self.Scale )
particle:SetDieTime( 3 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 150 )
particle:SetStartSize( 150 * self.Scale )
particle:SetEndSize( math.Rand(200,300) * self.Scale )
particle:SetRoll( math.Rand(-1,1) * 100 )
particle:SetColor( 40,40,40 )
particle:SetGravity( Vector( 0, 0, 0 ) )
particle:SetCollide( false )
end
local particle = self.Emitter:Add( "effects/lvs_base/fire", Pos )
if particle then
particle:SetVelocity( VectorRand() * 100 * self.Scale )
particle:SetDieTime( math.random(40,80) / 100 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 130 * self.Scale )
particle:SetEndSize( math.Rand(50,100) * self.Scale )
particle:SetRoll( math.Rand(-1,1) * 180 )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 70 ) )
particle:SetCollide( false )
end
for i = 0,3 do
local particle = self.Emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), Pos + VectorRand() * 100 * self.Scale )
if particle then
particle:SetVelocity( VectorRand() * 100 * self.Scale )
particle:SetDieTime( math.random(30,60) / 100 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 70 * self.Scale )
particle:SetEndSize( math.Rand(25,80) * self.Scale )
particle:SetRoll( math.Rand(-1,1) * 180 )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 40 ) )
particle:SetCollide( false )
end
end
end
end
if self.DieTime < CurTime() then
if self.Emitter then
self.Emitter:Finish()
end
return false
end
return true
end
if self.Emitter then
self.Emitter:Finish()
end
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,415 @@
local GlowMat = Material( "sprites/light_glow02_add" )
local FireMat = Material( "effects/fire_cloud1" )
local HeatMat = Material( "sprites/heatwave" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if not IsValid( self.Entity ) then return end
local Pos = self:GetPos()
self._Particles = {}
self.Emitter = ParticleEmitter( Pos, false )
self.Emitter3D = ParticleEmitter( Pos, true )
self._LastParticlePos = vector_origin
end
function EFFECT:AddParticle( particle )
table.insert( self._Particles, particle )
for id, particle in pairs( self._Particles ) do
if not particle or particle:GetLifeTime() > particle:GetDieTime() then
self._Particles[ id ] = nil
end
end
end
function EFFECT:GetPosition()
local ent = self.Entity
if not IsValid( ent ) then return vector_origin, vector_origin end
local Pos = ent:GetPos()
local Dir = ent:GetForward()
local Target = ent:GetTarget()
local Attachment = ent:GetTargetAttachment()
if IsValid( Target ) and Attachment ~= "" then
local ID = Target:LookupAttachment( Attachment )
local Muzzle = Target:GetAttachment( ID )
if not Muzzle then return vector_origin, vector_origin end
Pos = Muzzle.Pos
Dir = Muzzle.Ang:Forward()
end
return Pos, Dir
end
function EFFECT:Think()
local ent = self.Entity
local emitter = self.Emitter
local emitter3D = self.Emitter3D
if not IsValid( emitter ) or not IsValid( emitter3D ) then return true end
local T = CurTime()
if IsValid( ent ) and not self._KillSwitch then
if not ent:GetActive() then
self._KillSwitch = true
self._KillSwitchTime = CurTime() + 2
end
if (self.nextDFX or 0) < T then
self.nextDFX = T + 0.01
local Pos, Dir = self:GetPosition()
self:MakeFlameStream( emitter, emitter3D, Pos, Dir )
self:MakeFlameMuzzle( emitter, emitter3D, Pos, Dir )
self:SetRenderBoundsWS( Pos, Pos + Dir * 50000 )
end
return true
end
if self._KillSwitch and IsValid( emitter ) and IsValid( emitter3D ) then
if self._KillSwitchTime > T then
return true
end
end
if emitter then
emitter:Finish()
end
if emitter3D then
emitter3D:Finish()
end
return false
end
function EFFECT:MakeFlameImpact( Pos, Dir, Size )
local emitter3D = self.Emitter3D
if not IsValid( emitter3D ) then return end
local hitparticle = emitter3D:Add( "effects/lvs_base/flamelet"..math.random(1,5), Pos + Dir )
if hitparticle then
hitparticle:SetStartSize( Size * 0.25 )
hitparticle:SetEndSize( Size )
hitparticle:SetDieTime( math.Rand(0.5,1) )
hitparticle:SetStartAlpha( 255 )
hitparticle:SetEndAlpha( 0 )
hitparticle:SetRollDelta( math.Rand(-2,2) )
hitparticle:SetAngles( Dir:Angle() )
end
end
function EFFECT:MakeFlameImpactWater( Pos, Dir, Size )
local emitter3D = self.Emitter3D
local emitter = self.Emitter
if not IsValid( emitter ) or not IsValid( emitter3D ) then return end
local sparticle = emitter:Add( Materials[ math.random(1, #Materials ) ], Pos )
if sparticle then
sparticle:SetVelocity( Vector(0,0,400) + VectorRand() * 100 )
sparticle:SetDieTime( Size * 0.01 )
sparticle:SetAirResistance( 500 )
sparticle:SetStartAlpha( 40 )
sparticle:SetStartSize( 0 )
sparticle:SetEndSize( Size * 4 )
sparticle:SetRoll( math.Rand(-3,3) )
sparticle:SetRollDelta( math.Rand(-1,1) )
sparticle:SetColor( 255, 255, 255 )
sparticle:SetGravity( Vector( 0, 0, 800 ) )
sparticle:SetCollide( false )
end
local hitparticle = emitter3D:Add( "effects/lvs_base/flamelet"..math.random(1,5), Pos + Dir )
if hitparticle then
hitparticle:SetStartSize( Size * 0.25 )
hitparticle:SetEndSize( Size )
hitparticle:SetDieTime( math.Rand(0.5,1) )
hitparticle:SetStartAlpha( 255 )
hitparticle:SetEndAlpha( 0 )
hitparticle:SetRollDelta( math.Rand(-2,2) )
hitparticle:SetAngles( Dir:Angle() )
end
end
function EFFECT:MakeFlameBurst( Pos, Vel, Size )
local emitter = self.Emitter
if not IsValid( emitter ) then return end
local fparticle = emitter:Add( "effects/lvs_base/fire", Pos )
if fparticle then
fparticle:SetVelocity( VectorRand() * 15 + Vector( 0, 0, 200 ) + Vel )
fparticle:SetDieTime( math.Rand(0.6,0.8) )
fparticle:SetAirResistance( 0 )
fparticle:SetStartAlpha( 255 )
fparticle:SetEndAlpha( 255 )
fparticle:SetStartSize( 40 )
fparticle:SetEndSize( 0 )
fparticle:SetRollDelta( math.Rand(-2,2) )
fparticle:SetColor( 255,255,255 )
fparticle:SetGravity( Vector( 0, 0, 0 ) )
fparticle:SetCollide( false )
self:AddParticle( fparticle )
end
local fparticle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), Pos )
if fparticle then
fparticle:SetVelocity( VectorRand() * 25 + Vel )
fparticle:SetDieTime( math.Rand(0.4,0.8) )
fparticle:SetStartAlpha( 150 )
fparticle:SetEndAlpha( 0 )
fparticle:SetStartSize( 0 )
fparticle:SetEndSize( math.Rand(60,120) )
fparticle:SetColor( 255, 255, 255 )
fparticle:SetGravity( Vector(0,0,100) )
fparticle:SetRollDelta( math.Rand(-2,2) )
fparticle:SetAirResistance( 0 )
end
for i = 0, 6 do
local eparticle = emitter:Add( "effects/fire_embers"..math.random(1,2), Pos )
if not eparticle then continue end
eparticle:SetVelocity( VectorRand() * 400 + Vel )
eparticle:SetDieTime( math.Rand(0.4,0.6) )
eparticle:SetStartAlpha( 255 )
eparticle:SetEndAlpha( 0 )
eparticle:SetStartSize( 20 )
eparticle:SetEndSize( 0 )
eparticle:SetColor( 255, 255, 255 )
eparticle:SetGravity( Vector(0,0,600) )
eparticle:SetRollDelta( math.Rand(-8,8) )
eparticle:SetAirResistance( 300 )
end
local Dist = (self._LastParticlePos - Pos):Length()
self._LastParticlePos = Pos
if Dist < 250 then
if math.random(1,8) ~= 1 then return end
end
local sparticle = emitter:Add( Materials[ math.random(1, #Materials ) ], Pos )
if sparticle then
sparticle:SetVelocity( Vector(0,0,400) + Vel )
sparticle:SetDieTime( math.Rand(2,4) * Size )
sparticle:SetAirResistance( 500 )
sparticle:SetStartAlpha( 125 )
sparticle:SetStartSize( 0 )
sparticle:SetEndSize( 200 * Size )
sparticle:SetRoll( math.Rand(-3,3) )
sparticle:SetRollDelta( math.Rand(-1,1) )
sparticle:SetColor( 0, 0, 0 )
sparticle:SetGravity( Vector( 0, 0, 800 ) )
sparticle:SetCollide( false )
end
end
function EFFECT:MakeFlameMuzzle( emitter, emitter3D, pos, dir )
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if not particle then return end
local ent = self.Entity
if not IsValid( ent ) then return end
local velDesired = ent:GetFlameVelocity()
local vel = dir * velDesired
local DieTime = 0.075
particle:SetVelocity( VectorRand() * 30 + vel )
particle:SetDieTime( DieTime )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetEndLength( velDesired * 0.1 )
particle:SetStartLength( velDesired * 0.04 )
particle:SetStartSize( 10 )
particle:SetEndSize( 0 )
particle:SetRollDelta( math.Rand(-5,5) )
particle:SetColor( 50, 50, 255 )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( true )
end
function EFFECT:MakeFlameStream( emitter, emitter3D, pos, dir )
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if not particle then return end
local ent = self.Entity
if not IsValid( ent ) then return end
local velDesired = ent:GetFlameVelocity()
local vel = dir * velDesired
local DieTime = math.Rand( ent:GetFlameLifeTime() * 0.5, ent:GetFlameLifeTime() )
particle:SetVelocity( VectorRand() * 30 + vel )
particle:SetDieTime( DieTime )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetEndLength( velDesired * 0.1 )
particle:SetStartLength( velDesired * 0.04 )
particle:SetStartSize( 2 )
particle:SetEndSize( ent:GetFlameSize() )
particle:SetRollDelta( math.Rand(-5,5) )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( true )
local Delay = math.Rand( DieTime * 0.5, DieTime )
local Size = (Delay / DieTime) ^ 2
timer.Simple( Delay, function()
if not IsValid( self ) or not particle or particle.NoSmokeSpawn then return end
local ParticlePos = particle:GetPos()
self:MakeFlameBurst( ParticlePos, vel * 0.2, Size )
end)
particle:SetNextThink( CurTime() )
particle:SetThinkFunction( function( p )
if not IsValid( self ) then return end
p:SetNextThink( CurTime() + 0.05 )
local pos = p:GetPos()
local vel = p:GetVelocity()
local dir = vel:GetNormalized()
local speed = vel:Length() * 0.06
local traceData = {
start = pos,
endpos = pos + dir * speed,
filter = self.Entity,
}
local trace = util.TraceLine( traceData )
traceData.mask = MASK_WATER
local traceWater = util.TraceLine( traceData )
if traceWater.Hit and not trace.Hit then
p:SetDieTime( 0 )
p.NoSmokeSpawn = true
local RandomSize = math.Rand(60,80)
self:MakeFlameImpactWater( traceWater.HitPos, traceWater.HitNormal, RandomSize )
end
if trace.HitWorld or not trace.Hit then return end
p:SetDieTime( 0 )
p.NoSmokeSpawn = true
local RandomSize = math.Rand(40,60)
self:MakeFlameImpact( trace.HitPos, trace.HitNormal, RandomSize )
self:MakeFlameBurst( trace.HitPos, vector_origin, RandomSize / 60 )
end )
particle:SetCollideCallback( function( p, hitpos, hitnormal )
if p.NoSmokeSpawn then return end
p:SetDieTime( 0 )
p.NoSmokeSpawn = true
if not IsValid( emitter3D ) then return end
local RandomSize = math.Rand(40,60)
self:MakeFlameImpact( hitpos, hitnormal, RandomSize )
self:MakeFlameBurst( hitpos + hitnormal, vector_origin, RandomSize / 60 )
end )
particle.NoFade = true
self:AddParticle( particle )
local particle = emitter:Add( "effects/lvs_base/fire", pos )
if particle then
particle:SetVelocity( VectorRand() * 4 + dir * math.Rand(velDesired * 0.8,velDesired * 1.6) )
particle:SetDieTime( math.Rand(0.75,1.5) )
particle:SetAirResistance( 40 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 4 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-3,3) )
particle:SetRollDelta( math.Rand(-6,6) )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( VectorRand() * 400 - Vector(0,0,600) )
particle:SetCollide( true )
end
end
function EFFECT:Render()
local ent = self.Entity
if not IsValid( ent ) then return end
if ent:GetActive() and not self._KillSwitch then
local Scale = 1
local Pos, Dir = self:GetPosition()
local scroll = -CurTime() * 5
local Up = Dir + VectorRand() * 0.08
render.UpdateRefractTexture()
render.SetMaterial( HeatMat )
render.StartBeam( 3 )
render.AddBeam( Pos, 8 * Scale, scroll, Color( 0, 0, 255, 200 ) )
render.AddBeam( Pos + Up * 32 * Scale, 32 * Scale, scroll + 2, color_white )
render.AddBeam( Pos + Up * 128 * Scale, 32 * Scale, scroll + 5, Color( 0, 0, 0, 0 ) )
render.EndBeam()
end
if not istable( self._Particles ) then return end
for id, particle in pairs( self._Particles ) do
if not particle then continue end
local S = particle:GetLifeTime() / particle:GetDieTime()
local A = ((1 - S) ^ 2) * 0.5
local Size = particle:GetStartSize() * A * 8
if particle.NoFade then
Size = particle:GetEndSize() * S * 8
end
render.SetMaterial( GlowMat )
render.DrawSprite( particle:GetPos(), Size, Size, Color( 255 * A, 150 * A, 75 * A, 255 * A) )
end
end

View File

@@ -0,0 +1,112 @@
local GlowMat = Material( "sprites/light_glow02_add" )
local FireMat = Material( "effects/fire_cloud1" )
local HeatMat = Material( "sprites/heatwave" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Entity = data:GetEntity()
self.LifeTime = data:GetMagnitude() * 4
self.DieTime = CurTime() + self.LifeTime
if not IsValid( self.Entity ) then return end
local Pos, Dir = self:GetPosition()
self.Emitter = ParticleEmitter( Pos, false )
self:SetRenderBoundsWS( Pos, Pos + Dir * 50000 )
end
function EFFECT:GetPosition()
local ent = self.Entity
if not IsValid( ent ) then return vector_origin, vector_origin end
local Pos = ent:GetPos()
local Dir = ent:GetForward()
local Target = ent:GetTarget()
local Attachment = ent:GetTargetAttachment()
if IsValid( Target ) and Attachment ~= "" then
local ID = Target:LookupAttachment( Attachment )
local Muzzle = Target:GetAttachment( ID )
if not Muzzle then return vector_origin, vector_origin end
Pos = Muzzle.Pos
Dir = Muzzle.Ang:Forward()
end
return Pos, Dir
end
function EFFECT:DoSmoke( emitter, pos, dir )
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if not particle then return end
particle:SetVelocity( dir * 20 )
particle:SetDieTime( math.Rand(0.8,1.2) )
particle:SetAirResistance( 400 )
particle:SetStartAlpha( 50 * Scale )
particle:SetStartSize( 2 )
particle:SetEndSize( 20 )
particle:SetRoll( math.Rand( -2, 2 ) )
particle:SetRollDelta( math.Rand( -2, 2 ) )
particle:SetColor( 0, 0, 0 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
function EFFECT:Think()
local ent = self.Entity
local emitter = self.Emitter
local T = CurTime()
if IsValid( ent ) and (self.DieTime or 0) > T then
if (self.nextDFX or 0) < T then
self.nextDFX = T + 0.01
local Pos, Dir = self:GetPosition()
if not ent:GetActive() and math.random(1,6) == 1 then
self:DoSmoke( emitter, Pos, Dir )
end
self:SetRenderBoundsWS( Pos, Pos + Dir * 50000 )
end
return true
end
if emitter then
emitter:Finish()
end
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,186 @@
local GlowMat = Material( "sprites/light_glow02_add" )
local FireMat = Material( "effects/fire_cloud1" )
local HeatMat = Material( "sprites/heatwave" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Entity = data:GetEntity()
self.LifeTime = data:GetMagnitude()
self.DieTime = CurTime() + self.LifeTime
if not IsValid( self.Entity ) then return end
local Pos, Dir = self:GetPosition()
self.Emitter = ParticleEmitter( Pos, false )
self:SetRenderBoundsWS( Pos, Pos + Dir * 50000 )
local Pos, Dir = self:GetPosition()
for i = 1,10 do
self:MakeFlameStream( self.Emitter, self.Entity, Pos, Dir )
end
end
function EFFECT:GetPosition()
local ent = self.Entity
if not IsValid( ent ) then return vector_origin, vector_origin end
local Pos = ent:GetPos()
local Dir = ent:GetForward()
local Target = ent:GetTarget()
local Attachment = ent:GetTargetAttachment()
if IsValid( Target ) and Attachment ~= "" then
local ID = Target:LookupAttachment( Attachment )
local Muzzle = Target:GetAttachment( ID )
if not Muzzle then return vector_origin, vector_origin end
Pos = Muzzle.Pos
Dir = Muzzle.Ang:Forward()
end
return Pos, Dir
end
function EFFECT:MakeFlameStream( emitter, ent, pos, dir )
local vel = ent:GetTargetVelocity()
local Alpha = 100 - vel:Length() / 2
if Alpha > 1 then
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if particle then
particle:SetVelocity( VectorRand() * 60 + dir * 200 )
particle:SetDieTime( math.Rand(0.8,1.2) )
particle:SetAirResistance( 400 )
particle:SetStartAlpha( Alpha )
particle:SetStartSize( 2 )
particle:SetEndSize( 20 )
particle:SetRoll( math.Rand( -2, 2 ) )
particle:SetRollDelta( math.Rand( -2, 2 ) )
particle:SetColor( 0, 0, 0 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
end
local particle = emitter:Add( "effects/lvs_base/fire", pos )
if particle then
particle:SetVelocity( VectorRand() * 60 + dir * math.Rand(100,200) + vel )
particle:SetDieTime( math.Rand(0.75,1.5) )
particle:SetAirResistance( 40 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 1 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-3,3) )
particle:SetRollDelta( math.Rand(-6,6) )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( Vector(0,0,-600) )
particle:SetCollide( true )
end
local particle = emitter:Add( "effects/lvs_base/fire", pos )
if particle then
particle:SetVelocity( dir * 70 + vel )
particle:SetDieTime( 0.2 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 5 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-1,1) * 180 )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( dir * 40 + vel )
particle:SetDieTime( 0.2 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 2 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-1,1) * 180 )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
end
function EFFECT:Think()
local ent = self.Entity
local emitter = self.Emitter
local T = CurTime()
if IsValid( ent ) and (self.DieTime or 0) > T then
if (self.nextDFX or 0) < T then
self.nextDFX = T + 0.01
local Pos, Dir = self:GetPosition()
self:SetRenderBoundsWS( Pos, Pos + Dir * 50000 )
end
return true
end
if emitter then
emitter:Finish()
end
return false
end
function EFFECT:Render()
local ent = self.Entity
if not IsValid( ent ) then return end
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local invScaleExp = (1 - Scale) ^ 2
local Pos, Dir = self:GetPosition()
local scroll = -CurTime() * 5
local Up = Dir + VectorRand() * 0.08
render.UpdateRefractTexture()
render.SetMaterial( HeatMat )
render.StartBeam( 3 )
render.AddBeam( Pos, 8 * invScaleExp, scroll, Color( 0, 0, 255, 200 ) )
render.AddBeam( Pos + Up * 32 * invScaleExp, 32 * invScaleExp, scroll + 2, color_white )
render.AddBeam( Pos + Up * 128 * invScaleExp, 32 * invScaleExp, scroll + 5, Color( 0, 0, 0, 0 ) )
render.EndBeam()
local A = Scale ^ 2
local Size = Scale * 64
render.SetMaterial( GlowMat )
render.DrawSprite( Pos, Size, Size, Color( 255 * A, 150 * A, 75 * A, 255 * A) )
end

View File

@@ -0,0 +1,123 @@
EFFECT.MatBeam = Material( "effects/lvs_base/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
EFFECT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Dir = data:GetNormal()
local Ent = data:GetEntity()
local Vel = Dir * 10
if IsValid( Ent ) then
Vel = Ent:GetVelocity()
end
local emitter = ParticleEmitter( Pos, false )
if not IsValid( emitter ) then return end
for i = 0, 12 do
local particle = emitter:Add( "effects/muzzleflash2", Pos + Dir * i * 0.7 * math.random(1,2) * 0.5 )
local Size = 1
if not particle then continue end
particle:SetVelocity( Dir * 800 + Vel )
particle:SetDieTime( 0.05 )
particle:SetStartAlpha( 255 * Size )
particle:SetStartSize( math.max( math.random(10,24) - i * 0.5,0.1 ) * Size )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 255, 255, 255 )
particle:SetCollide( false )
end
local VecCol = (render.GetLightColor( Pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
for i = 0,10 do
local particle = emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], Pos )
if not particle then continue end
particle:SetVelocity( Dir * 700 + VectorRand() * 200 )
particle:SetDieTime( math.Rand(2,3) )
particle:SetAirResistance( 250 )
particle:SetStartAlpha( 50 )
particle:SetStartSize( 5 )
particle:SetEndSize( 120 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,100) )
particle:SetCollide( false )
end
local trace = util.TraceLine( {
start = Pos,
endpos = Pos - Vector(0,0,500),
mask = MASK_SOLID_BRUSHONLY,
} )
if not trace.Hit then return end
local VecCol = (render.GetLightColor( trace.HitPos + trace.HitNormal ) * 0.8 + Vector(0.17,0.15,0.1)) * 255
for i = 1,24 do
local particle = emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], trace.HitPos )
if not particle then continue end
local ang = i * 15
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
particle:SetVelocity( Vector(X,Y,0) * 3000 )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( 500 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 50 )
particle:SetEndSize( 240 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,150) + Dir * 2000 )
particle:SetCollide( false )
end
emitter:Finish()
local ply = LocalPlayer()
if not IsValid( ply ) then return end
local ViewEnt = ply:GetViewEntity()
if not IsValid( ViewEnt ) then return end
local Intensity = 16
local Ratio = math.min( 250 / (ViewEnt:GetPos() - trace.HitPos):Length(), 1 )
if Ratio < 0 then return end
util.ScreenShake( trace.HitPos, Intensity * Ratio, 0.1, 0.5, 250 )
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,108 @@
local MatBeam = Material( "effects/lvs_base/spark" )
local GlowMat = Material( "sprites/light_glow02_add" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if IsValid( self.Entity ) then
self.OldPos = self.Entity:GetPos()
self.Emitter = ParticleEmitter( self.Entity:LocalToWorld( self.OldPos ), false )
end
end
function EFFECT:doFX( pos )
if not IsValid( self.Entity ) then return end
if IsValid( self.Emitter ) then
local emitter = self.Emitter
local VecCol = (render.GetLightColor( pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if particle then
particle:SetVelocity( -self.Entity:GetForward() * 1500 + VectorRand() * 10 )
particle:SetDieTime( math.Rand(0.05,1) )
particle:SetAirResistance( 250 )
particle:SetStartAlpha( 100 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 0 )
particle:SetEndSize( 30 )
particle:SetRollDelta( 1 )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetCollide( false )
end
end
end
function EFFECT:Think()
if IsValid( self.Entity ) then
self.nextDFX = self.nextDFX or 0
if self.nextDFX < CurTime() then
self.nextDFX = CurTime() + 0.02
local oldpos = self.OldPos
local newpos = self.Entity:GetPos()
self:SetPos( newpos )
local Sub = (newpos - oldpos)
local Dir = Sub:GetNormalized()
local Len = Sub:Length()
self.OldPos = newpos
for i = 0, Len, 45 do
local pos = oldpos + Dir * i
self:doFX( pos )
end
end
return true
end
if IsValid( self.Emitter ) then
self.Emitter:Finish()
end
return false
end
function EFFECT:Render()
local ent = self.Entity
if not IsValid( ent ) then return end
local pos = ent:GetPos()
local dir = ent:GetForward()
local len = 250
render.SetMaterial( MatBeam )
render.DrawBeam( pos - dir * len, pos + dir * len * 0.1, 32, 1, 0, Color( 100, 100, 100, 100 ) )
render.DrawBeam( pos - dir * len * 0.5, pos + dir * len * 0.1, 16, 1, 0, Color( 255, 255, 255, 255 ) )
render.SetMaterial( GlowMat )
render.DrawSprite( pos, 250, 250, Color( 100, 100, 100, 255 ) )
end

View File

@@ -0,0 +1,67 @@
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
self.Size = data:GetMagnitude()
if not IsValid( Ent ) then return end
self.LifeTime = math.Rand(1.5,3)
self.DieTime = CurTime() + self.LifeTime
local LightColor = render.GetLightColor( Pos )
local VecCol = Vector(1,1.2,1.4) * (0.06 + (0.2126 * LightColor.r) + (0.7152 * LightColor.g) + (0.0722 * LightColor.b)) * 1000
VecCol.x = math.min( VecCol.x, 255 )
VecCol.y = math.min( VecCol.y, 255 )
VecCol.z = math.min( VecCol.z, 255 )
self.Splash = {
Pos = Pos,
Mat = Material("effects/splashwake1"),
RandomAng = math.random(0,360),
Color = VecCol,
}
local emitter = Ent:GetParticleEmitter( Ent:GetPos() )
if emitter and emitter.Add then
local particle = emitter:Add( "effects/splash4", Pos )
if not particle then return end
local Vel = Ent:GetVelocity():Length()
particle:SetVelocity( Vector(0,0,math.Clamp(Vel / 2,100,250)) )
particle:SetDieTime( 0.25 + math.min(Vel / 200,0.35) )
particle:SetAirResistance( 60 )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( self.Size * 0.2 )
particle:SetEndSize( self.Size * 2 )
particle:SetRoll( math.Rand(-1,1) * 100 )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( false )
end
end
function EFFECT:Think()
if CurTime() > self.DieTime then
return false
end
return true
end
function EFFECT:Render()
if self.Splash and self.LifeTime then
local Scale = ((self.DieTime - self.LifeTime - CurTime()) / self.LifeTime)
local S = self.Size * 5 + (self.Size * 5) * Scale
local Alpha = 100 + 100 * Scale
cam.Start3D2D( self.Splash.Pos + Vector(0,0,1), Angle(0,0,0), 1 )
surface.SetMaterial( self.Splash.Mat )
surface.SetDrawColor( self.Splash.Color.r, self.Splash.Color.g, self.Splash.Color.b, Alpha )
surface.DrawTexturedRectRotated( 0, 0, S , S, self.Splash.RandomAng )
cam.End3D2D()
end
end

View File

@@ -0,0 +1,121 @@
EFFECT.Mat = Material( "effects/lvs/ballturret_projectorbeam" )
EFFECT.HitMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if IsValid( self.Entity ) then
self.ID = self.Entity:LookupAttachment( "muzzle_primary" )
if self.ID then
local Muzzle = self.Entity:GetAttachment( self.ID )
self:SetRenderBoundsWS( self.Entity:GetPos(), -Muzzle.Ang:Right() * 50000 )
end
end
self.SpawnTime = CurTime()
end
function EFFECT:Think()
if not IsValid( self.Entity ) or not self.ID or not self.Entity:GetProjectorBeam() then
return false
end
return true
end
function EFFECT:Render()
if not self.ID or not IsValid( self.Entity ) then return end
local T = CurTime()
local Mul = math.min( math.max( 1.5 - (T - self.SpawnTime), 0 ) ^ 2, 1 )
local Muzzle = self.Entity:GetAttachment( self.ID )
local Dir = -Muzzle.Ang:Right()
local StartPos = Muzzle.Pos
local Trace = util.TraceLine( { start = StartPos, endpos = StartPos + Dir * 50000, filter = self } )
local EndPos = Trace.HitPos
self:SetRenderBoundsWS( StartPos, EndPos )
render.SetMaterial( self.Mat )
render.DrawBeam( StartPos, EndPos, (16 + math.random(0,3)) * Mul, 1, 0, Color(255,0,0,255) )
render.DrawBeam( StartPos, EndPos, (4 + math.random(0,2)) * Mul, 1, 0, Color(255,255,255,255) )
render.SetMaterial( self.HitMat )
local A = 150 + math.random(0,20)
local B = 70 + math.random(0,20)
render.DrawSprite( StartPos, A * Mul, A * Mul, Color(255,0,0,255) )
render.DrawSprite( StartPos, B * Mul, B * Mul, Color(255,255,255,255) )
render.DrawSprite( EndPos, A, A, Color(255,0,0,255) )
render.DrawSprite( EndPos + VectorRand() * 10, B, B, Color(255,255,255,255) )
if (self._Next or 0) > T then return end
self._Next = T + 0.02
local emitter = ParticleEmitter( EndPos, false )
if not emitter or not IsValid( emitter ) then return end
local dir = (self.Entity:GetPos() - EndPos):GetNormalized()
for i = 0, 3 do
local particle = emitter:Add( "sprites/light_glow02_add", EndPos )
local vel = VectorRand() * 250 + Trace.HitNormal
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(12,24) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( 255, 0, 0 )
particle:SetGravity( Vector(0,0,-600) )
particle:SetAirResistance( 0 )
particle:SetCollide( true )
particle:SetBounce( 1 )
end
local Dist = (StartPos - EndPos):Length()
local invMul = (1 - Mul)
for i = 0, Dist, 25 do
local Pos = StartPos + Dir * i
local particle = emitter:Add( "sprites/rico1", Pos )
local vel = VectorRand() * 150
if not particle then continue end
particle:SetVelocity( vel + vel * invMul )
particle:SetDieTime( 0.1 + 0.15 * invMul )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand( 1, 5 ) + invMul * 2 )
particle:SetEndSize( 0 )
particle:SetColor( 50 + 205 * Mul, 0, 0 )
particle:SetAirResistance( 0 )
particle:SetRoll( math.Rand(-10,10) )
particle:SetRollDelta( math.Rand(-10,10) )
particle:SetGravity( Vector(0,0,-600 * invMul) )
particle:SetAirResistance( 0 )
end
emitter:Finish()
end

View File

@@ -0,0 +1,78 @@
EFFECT.Mat = Material( "effects/lvs/ballturret_projectorbeam" )
EFFECT.HitMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if IsValid( self.Entity ) then
self.ID = self.Entity:LookupAttachment( "muzzle_ballturret_left" )
if self.ID then
local Muzzle = self.Entity:GetAttachment( self.ID )
self:SetRenderBoundsWS( self.Entity:GetPos(), Muzzle.Ang:Up() * 50000 )
end
end
end
function EFFECT:Think()
if not IsValid( self.Entity ) or not self.ID or not self.Entity:GetBTLFire() then
return false
end
return true
end
function EFFECT:Render()
if not self.ID or not IsValid( self.Entity ) then return end
local Muzzle = self.Entity:GetAttachment( self.ID )
local Dir = Muzzle.Ang:Up()
local StartPos = Muzzle.Pos + Dir * 14
local Trace = util.TraceLine( { start = StartPos, endpos = StartPos + Dir * 50000, filter = self } )
local EndPos = Trace.HitPos
self:SetRenderBoundsWS( StartPos, EndPos )
render.SetMaterial( self.Mat )
render.DrawBeam( StartPos, EndPos, 14 + math.random(0,4), 1, 0, Color(0,255,0,255) )
render.DrawBeam( StartPos, EndPos, 3 + math.random(0,4), 1, 0, Color(255,255,255,255) )
render.SetMaterial( self.HitMat )
local A = 150 + math.random(0,20)
local B = 70 + math.random(0,20)
render.DrawSprite( StartPos, A, A, Color(0,255,0,255) )
render.DrawSprite( StartPos, B, B, Color(255,255,255,255) )
render.DrawSprite( EndPos, A, A, Color(0,255,0,255) )
render.DrawSprite( EndPos + VectorRand() * 10, B, B, Color(255,255,255,255) )
if math.random(0,5) == 1 then
local emitter = ParticleEmitter( EndPos, false )
local dir = (self.Entity:GetPos() - EndPos):GetNormalized()
for i = 0, 10 do
local particle = emitter:Add( "sprites/rico1", EndPos )
local vel = VectorRand() * 100 + dir * 40
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.1,0.3) * 0.5 )
particle:SetStartAlpha( math.Rand( 200, 255 ) )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(1,30) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetAirResistance( 0 )
end
emitter:Finish()
end
end

View File

@@ -0,0 +1,78 @@
EFFECT.Mat = Material( "effects/lvs/ballturret_projectorbeam" )
EFFECT.HitMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if IsValid( self.Entity ) then
self.ID = self.Entity:LookupAttachment( "muzzle_ballturret_right" )
if self.ID then
local Muzzle = self.Entity:GetAttachment( self.ID )
self:SetRenderBoundsWS( self.Entity:GetPos(), Muzzle.Ang:Up() * 50000 )
end
end
end
function EFFECT:Think()
if not IsValid( self.Entity ) or not self.ID or not self.Entity:GetBTRFire() then
return false
end
return true
end
function EFFECT:Render()
if not self.ID or not IsValid( self.Entity ) then return end
local Muzzle = self.Entity:GetAttachment( self.ID )
local Dir = Muzzle.Ang:Up()
local StartPos = Muzzle.Pos + Dir * 14
local Trace = util.TraceLine( { start = StartPos, endpos = StartPos + Dir * 50000, filter = self } )
local EndPos = Trace.HitPos
self:SetRenderBoundsWS( StartPos, EndPos )
render.SetMaterial( self.Mat )
render.DrawBeam( StartPos, EndPos, 14 + math.random(0,4), 1, 0, Color(0,255,0,255) )
render.DrawBeam( StartPos, EndPos, 3 + math.random(0,4), 1, 0, Color(255,255,255,255) )
render.SetMaterial( self.HitMat )
local A = 150 + math.random(0,20)
local B = 70 + math.random(0,20)
render.DrawSprite( StartPos, A, A, Color(0,255,0,255) )
render.DrawSprite( StartPos, B, B, Color(255,255,255,255) )
render.DrawSprite( EndPos, A, A, Color(0,255,0,255) )
render.DrawSprite( EndPos + VectorRand() * 10, B, B, Color(255,255,255,255) )
if math.random(0,5) == 1 then
local emitter = ParticleEmitter( EndPos, false )
local dir = (self.Entity:GetPos() - EndPos):GetNormalized()
for i = 0, 10 do
local particle = emitter:Add( "sprites/rico1", EndPos )
local vel = VectorRand() * 100 + dir * 40
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.1,0.3) * 0.5 )
particle:SetStartAlpha( math.Rand( 200, 255 ) )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(1,30) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetAirResistance( 0 )
end
emitter:Finish()
end
end

View File

@@ -0,0 +1,82 @@
EFFECT.Mat = Material( "effects/lvs/ballturret_projectorbeam" )
EFFECT.HitMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
self.Entity = data:GetEntity()
self.StartPos = Vector(-172.97,334.04,93.25)
self.EndPos = self.Entity:GetWingTurretTarget()
end
function EFFECT:Think()
if not IsValid( self.Entity ) or not self.Entity:GetWingTurretFire() then
return false
end
self.EndPosDesired = self.Entity:GetWingTurretTarget()
self:SetRenderBoundsWS( self.Entity:GetPos(), self.EndPosDesired )
return true
end
function EFFECT:Render()
if not self.EndPosDesired then return end
self.EndPos = self.EndPos + (self.EndPosDesired - self.EndPos) * FrameTime() * 10
for i = -1,1,2 do
local StartPos = self.Entity:LocalToWorld( self.StartPos * Vector(1,i,1) )
local Trace = util.TraceLine( { start = StartPos, endpos = self.EndPos} )
local EndPos = Trace.HitPos
if self.Entity:WorldToLocal( EndPos ).z < 0 then
self.StartPos = Vector(-172.97,334.04,93.25)
else
self.StartPos = Vector(-174.79,350.05,125.98)
end
if Trace.Entity == self.Entity then continue end
render.SetMaterial( self.Mat )
render.DrawBeam( StartPos, EndPos, 14 + math.random(0,4), 1, 0, Color(0,255,0,255) )
render.DrawBeam( StartPos, EndPos, 3 + math.random(0,4), 1, 0, Color(255,255,255,255) )
render.SetMaterial( self.HitMat )
local A = 150 + math.random(0,20)
local B = 70 + math.random(0,20)
render.DrawSprite( StartPos, A, A, Color(0,255,0,255) )
render.DrawSprite( StartPos, B, B, Color(255,255,255,255) )
render.DrawSprite( EndPos, A, A, Color(0,255,0,255) )
render.DrawSprite( EndPos + VectorRand() * 10, B, B, Color(255,255,255,255) )
if math.random(0,5) == 1 then
local emitter = ParticleEmitter( EndPos, false )
local dir = (self.Entity:GetPos() - EndPos):GetNormalized()
for i = 0, 10 do
local particle = emitter:Add( "sprites/rico1", EndPos )
local vel = VectorRand() * 100 + dir * 40
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.1,0.3) * 0.5 )
particle:SetStartAlpha( math.Rand( 200, 255 ) )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(1,30) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetAirResistance( 0 )
end
emitter:Finish()
end
end
end

View File

@@ -0,0 +1,34 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 1000 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 4, endpos + dir * len * 4, 200, 1, 0, Color( 0, 0, 255, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 45, 1, 0, Color( 0, 0, 255, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 15, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,75 @@
EFFECT.MatBeam = Material( "effects/lvs/ballturret_projectorbeam" )
-- variables
local LifeTime = 1.4
local StartSizeOuter = 16
local StartSizeInner = 6
local EndSizeOuter = 3
local EndSizeInner = 1
local DissipateExponentScale = 16
local DissipateExponentAlpha = 16
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.StartPos = pos
self.Dir = dir
self.ID = data:GetMaterialIndex()
self.LifeTime = LifeTime
self.DieTime = CurTime() + self.LifeTime
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
if bullet then
self.StartPos = bullet.Entity:LocalToWorld( bullet.SrcEntity )
self.EndPos = bullet:GetPos()
self.BulletAlive = true
self.BulletFilter = bullet.Filter
else
-- fix problem in lvs bullet code not updating the target destination
if self.BulletAlive and self.BulletFilter then
self.BulletAlive = nil
local trace = util.TraceLine( {
start = self.StartPos,
endpos = self.StartPos + self.Dir * 50000,
mask = MASK_SHOT_HULL,
filter = self.BulletFilter,
} )
self.EndPos = trace.HitPos
end
end
if not self.StartPos or not self.EndPos then return end
if bullet and bullet:GetLength() <= 0 then return end
-- math, dont change
local S = (self.DieTime - CurTime()) / self.LifeTime
local invS = 1 - S
local Alpha = 255 * (S ^ DissipateExponentAlpha)
local Scale = S ^ DissipateExponentScale
local invScale = invS ^ DissipateExponentScale
render.SetMaterial( self.MatBeam )
render.DrawBeam( self.StartPos, self.EndPos, StartSizeOuter * Scale + EndSizeOuter * invScale, 1, 0, Color( 0, 0, 255, Alpha ) )
render.DrawBeam( self.StartPos, self.EndPos, StartSizeInner * Scale + EndSizeInner * invScale, 1, 0, Color( 255, 255, 255, Alpha ) )
end

View File

@@ -0,0 +1,34 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 2500 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 2, endpos + dir * len * 2, 200, 1, 0, Color( 0, 0, 255, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 45, 1, 0, Color( 0, 0, 255, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 15, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,34 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 300 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 2, endpos + dir * len * 2, 200, 1, 0, Color( 0, 0, 255, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 45, 1, 0, Color( 0, 0, 255, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 15, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,103 @@
EFFECT.HeatWaveMat = Material( "particle/warp1_warp" )
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
self.Ent = data:GetEntity()
self.ID = data:GetAttachment()
if not IsValid( self.Ent ) then return end
local att = self.Ent:GetAttachment( self.ID )
if not att then return end
local Pos = att.Pos
self.LifeTime = 0.35
self.DieTime = CurTime() + self.LifeTime
self.Emitter = ParticleEmitter( Pos, false )
self.Particles = {}
end
function EFFECT:Think()
if (self.DieTime or 0) < CurTime() or not IsValid( self.Ent ) then
if IsValid( self.Emitter ) then
self.Emitter:Finish()
end
return false
end
self:DoSpark()
return true
end
function EFFECT:DoSpark()
local T = CurTime()
if (self._Next or 0) > T then return end
self._Next = T + 0.01
if not IsValid( self.Emitter ) then return end
if not IsValid( self.Ent ) or not self.ID then return end
local att = self.Ent:GetAttachment( self.ID )
if not att then return end
local Pos = att.Pos
local Dir = VectorRand() * 25
for id, particle in pairs( self.Particles ) do
if not particle then
self.Particles[ id ] = nil
continue
end
particle:SetGravity( (Pos - particle:GetPos()) * 50 )
end
local particle = self.Emitter:Add( "sprites/rico1", Pos + Dir )
if not particle then return end
particle:SetDieTime( 0.25 )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand( 1, 5 ) )
particle:SetEndSize( 0 )
particle:SetColor( 255, 0, 0 )
particle:SetAirResistance( 0 )
particle:SetRoll( math.Rand(-10,10) )
particle:SetRollDelta( math.Rand(-10,10) )
table.insert( self.Particles, particle )
end
function EFFECT:Render()
if not IsValid( self.Ent ) or not self.ID then return end
local att = self.Ent:GetAttachment( self.ID )
if not att then return end
local Scale = (self.DieTime - CurTime()) / self.LifeTime
if Scale <= 0 then return end
local rnd = VectorRand() * math.Rand(0,0.5)
render.SetMaterial( self.HeatWaveMat )
render.DrawSprite( att.Pos, 30 *(1 - Scale), 30 * (1 - Scale), Color( 255, 255, 255, 255) )
render.SetMaterial( self.GlowMat )
render.DrawSprite( att.Pos + rnd, 120 * (1 - Scale), 120 * (1 - Scale), Color(255,0,0,255) )
end

View File

@@ -0,0 +1,73 @@
local GlowMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.Col = data:GetStart() or Vector(255,100,0)
self.LifeTime = 0.4
self.DieTime = CurTime() + self.LifeTime
local emitter = ParticleEmitter( self.Pos, false )
if not IsValid( emitter ) then return end
for i = 0, 20 do
local particle = emitter:Add( "sprites/light_glow02_add", self.Pos )
local vel = VectorRand() * 400
if particle then
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.4,0.8) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(24,48) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( self.Col.x,self.Col.y,self.Col.z )
particle:SetGravity( Vector(0,0,-600) )
particle:SetAirResistance( 0 )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
end
end
for i = 0, 20 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 500 )
particle:SetDieTime( 0.15 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 )
particle:SetEndSize( 32 )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetRollDelta( math.Rand( -1, 1 ) * 100 )
particle:SetColor( self.Col.x,self.Col.y,self.Col.z )
particle:SetCollide( false )
end
end
emitter:Finish()
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
if not self.Col then return end
local Scale = (self.DieTime - CurTime()) / self.LifeTime
render.SetMaterial( GlowMat )
render.DrawSprite( self.Pos, 400 * Scale, 400 * Scale, Color( self.Col.x,self.Col.y,self.Col.z, 255) )
render.DrawSprite( self.Pos, 100 * Scale, 100 * Scale, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,121 @@
EFFECT.HeatWaveMat = Material( "particle/warp1_warp" )
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local Pos = data:GetOrigin()
self.Pos = Pos
self.LifeTime = 0.4
self.DieTime = CurTime() + self.LifeTime
self.DieTimeGlow = CurTime() + 0.2
sound.Play( "LVS.AAT.LASER_EXPLOSION", Pos )
self:Explosion( Pos )
end
function EFFECT:Explosion( pos )
local emitter = ParticleEmitter( pos, false )
if not emitter then return end
for i = 0, 15 do
local particle = emitter:Add( "sprites/light_glow02_add", pos )
local vel = VectorRand() * 450
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(1,1.6) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(12,15) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( 255,0,0 )
particle:SetGravity( Vector(0,0,-600) )
particle:SetAirResistance( 0 )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
end
for i = 0, 5 do
local particle = emitter:Add( "sprites/rico1", pos )
local vel = VectorRand() * 1000
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.5,0.8) )
particle:SetStartAlpha( math.Rand( 200, 255 ) )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(10,20) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( 255, 0, 0 )
particle:SetGravity( -vel:GetNormalized() * math.random(1250,1750) )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
particle:SetAirResistance( 200 )
end
for i = 0, 20 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if not particle then continue end
particle:SetVelocity( VectorRand(-1,1) * 500 )
particle:SetDieTime( 0.14 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 )
particle:SetEndSize( math.Rand(30,60) )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
emitter:Finish()
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
local Scale = math.max((self.DieTime - self.LifeTime + 0.3 - CurTime()) / 0.3,0)
render.SetMaterial( self.HeatWaveMat )
render.DrawSprite( self.Pos, 300 * Scale, 300 * Scale, Color( 255, 255, 255, 255) )
render.SetMaterial( self.GlowMat )
render.DrawSprite( self.Pos, 1000 * Scale, 1000 * Scale, Color( 255, 100, 50, 255) )
local Scale = (self.DieTimeGlow - CurTime()) / 0.2
if Scale > 0 then
render.SetMaterial( self.GlowMat )
render.DrawSprite( self.Pos, 100 * Scale, 100 * Scale, Color( 250, 0, 0, 255) )
render.DrawSprite( self.Pos, 25 * Scale, 25 * Scale, Color( 255, 255, 255, 255) )
end
local Scale = (self.DieTime - self.LifeTime + 0.25 - CurTime()) / 0.25
local InvScale = 1 - Scale
if Scale > 0 then
render.SetColorMaterial()
render.DrawSphere( self.Pos, -180 * InvScale, 30,30, Color( 255, 0, 0, 255 * (Scale ^ 2) ) )
render.DrawSphere( self.Pos, -190 * InvScale, 30,30, Color( 255, 0, 0, 150 * (Scale ^ 2) ) )
render.DrawSphere( self.Pos, -200 * InvScale, 30,30, Color( 255, 0, 0, 50 * (Scale ^ 2) ) )
render.DrawSphere( self.Pos, 210 * InvScale, 30,30, Color( 255, 0, 0, 50 * (Scale ^ 2) ) )
end
end

View File

@@ -0,0 +1,34 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 1000 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 4, endpos + dir * len * 4, 200, 1, 0, Color( 0, 255, 0, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 45, 1, 0, Color( 0, 255, 0, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 15, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,34 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 300 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 2, endpos + dir * len * 2, 100, 1, 0, Color( 0, 255, 0, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 60, 1, 0, Color( 0, 255, 0, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 15, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,78 @@
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.Dir = data:GetNormal()
self.Col = data:GetStart() or Vector(255,100,0)
self.LifeTime = 0.2
self.DieTime = CurTime() + self.LifeTime
local trace = util.TraceLine( {
start = self.Pos - self.Dir,
endpos = self.Pos + self.Dir,
mask = MASK_SOLID_BRUSHONLY,
} )
self.Flat = trace.Hit and not trace.HitSky
local Col = self.Col
local Pos = self.Pos
local emitter = ParticleEmitter( Pos, false )
for i = 0, 10 do
local particle = emitter:Add( "sprites/light_glow02_add", Pos )
local vel = VectorRand() * 200 + self.Dir * 80
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(12,24) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( Col.x,Col.y,Col.z )
particle:SetGravity( Vector(0,0,-600) )
particle:SetAirResistance( 0 )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
end
emitter:Finish()
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
local S1 = 200 * Scale
local S2 = 50 * Scale
if self.Flat then
cam.Start3D2D( self.Pos + self.Dir, self.Dir:Angle() + Angle(90,0,0), 1 )
surface.SetMaterial( self.GlowMat )
surface.SetDrawColor( self.Col.x, self.Col.y, self.Col.z, 255 )
surface.DrawTexturedRectRotated( 0, 0, S1 , S1 , 0 )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawTexturedRectRotated( 0, 0, S2 , S2 , 0 )
cam.End3D2D()
end
render.SetMaterial( self.GlowMat )
render.DrawSprite( self.Pos + self.Dir, S1, S1, Color( self.Col.x, self.Col.y, self.Col.z, 255 ) )
render.DrawSprite( self.Pos + self.Dir, S2, S2, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,34 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 1000 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 4, endpos + dir * len * 4, 200, 1, 0, Color( 255, 0, 0, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 45, 1, 0, Color( 255, 0, 0, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 15, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,103 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
EFFECT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
local emitter = ParticleEmitter( pos, false )
if not IsValid( emitter ) then return end
local trace = util.TraceLine( {
start = pos,
endpos = pos - Vector(0,0,500),
mask = MASK_SOLID_BRUSHONLY,
} )
if not trace.Hit then return end
local VecCol = (render.GetLightColor( trace.HitPos + trace.HitNormal ) * 0.8 + Vector(0.17,0.15,0.1)) * 255
for i = 1,24 do
local particle = emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], trace.HitPos )
if not particle then continue end
local ang = i * 15
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
particle:SetVelocity( Vector(X,Y,0) * 3000 )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( 500 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 50 )
particle:SetEndSize( 240 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,150) + dir * 2000 )
particle:SetCollide( false )
end
emitter:Finish()
local ply = LocalPlayer()
if not IsValid( ply ) then return end
local ViewEnt = ply:GetViewEntity()
if not IsValid( ViewEnt ) then return end
local Intensity = 8
local Ratio = math.min( 250 / (ViewEnt:GetPos() - trace.HitPos):Length(), 1 )
if Ratio < 0 then return end
util.ScreenShake( trace.HitPos, Intensity * Ratio, 0.1, 0.5, 250 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 100 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 8, endpos + dir * len * 8, 200, 1, 0, Color( 255, 0, 0, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 60, 1, 0, Color( 255, 0, 0, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 30, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,34 @@
EFFECT.MatBeam = Material( "effects/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then return false end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 300 * bullet:GetLength()
render.SetMaterial( self.MatSprite )
render.DrawBeam( endpos - dir * len * 2, endpos + dir * len * 2, 200, 1, 0, Color( 255, 0, 0, 255 ) )
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 45, 1, 0, Color( 255, 0, 0, 255 ) )
render.DrawBeam( endpos - dir * len, endpos + dir * len, 15, 1, 0, Color( 255, 255, 255, 255 ) )
end

View File

@@ -0,0 +1,127 @@
EFFECT.Offset = Vector(-8,0,0)
local GlowMat = Material( "sprites/light_glow02_add" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if IsValid( self.Entity ) then
self.OldPos = self.Entity:LocalToWorld( self.Offset )
self.Emitter = ParticleEmitter( self.Entity:LocalToWorld( self.OldPos ), false )
end
end
function EFFECT:doFX( pos )
if not IsValid( self.Entity ) then return end
if IsValid( self.Emitter ) then
local emitter = self.Emitter
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if particle then
particle:SetGravity( Vector(0,0,100) + VectorRand() * 50 )
particle:SetVelocity( -self.Entity:GetForward() * 200 )
particle:SetAirResistance( 600 )
particle:SetDieTime( math.Rand(1.5,2) )
particle:SetStartAlpha( 50 )
particle:SetStartSize( 20 )
particle:SetEndSize( 60 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetRollDelta( math.Rand( -1, 1 ) )
particle:SetColor(40,40,40)
particle:SetCollide( false )
end
local particle = emitter:Add( "particles/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( -self.Entity:GetForward() * math.Rand(250,800) + self.Entity:GetVelocity())
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 8 )
particle:SetEndSize( 1 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 0 ) )
particle:SetCollide( false )
end
local particle = emitter:Add( "particles/flamelet"..math.random(1,5), self.Entity:GetPos() )
if particle then
particle:SetVelocity( -self.Entity:GetForward() * 200 + VectorRand() * 50 )
particle:SetDieTime( 0.25 )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 6 )
particle:SetEndSize( 2 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 0 ) )
particle:SetCollide( false )
end
end
end
function EFFECT:Think()
if IsValid( self.Entity ) then
self.nextDFX = self.nextDFX or 0
if self.nextDFX < CurTime() then
self.nextDFX = CurTime() + 0.02
local oldpos = self.OldPos
local newpos = self.Entity:LocalToWorld( self.Offset )
self:SetPos( newpos )
local Sub = (newpos - oldpos)
local Dir = Sub:GetNormalized()
local Len = Sub:Length()
self.OldPos = newpos
for i = 0, Len, 45 do
local pos = oldpos + Dir * i
self:doFX( pos )
end
end
return true
end
if IsValid( self.Emitter ) then
self.Emitter:Finish()
end
return false
end
function EFFECT:Render()
local ent = self.Entity
if not IsValid( ent ) then return end
local pos = ent:LocalToWorld( self.Offset )
render.SetMaterial( GlowMat )
render.DrawSprite( pos, 100, 100, Color( 255, 200, 150, 255 ) )
end

View File

@@ -0,0 +1,40 @@
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Dir = data:GetNormal()
local Ent = data:GetEntity()
local Vel = Dir * 10
if IsValid( Ent ) then
Vel = Ent:GetVelocity()
end
local emitter = ParticleEmitter( Pos, false )
if not IsValid( emitter ) then return end
for i = 0, 12 do
local particle = emitter:Add( "effects/muzzleflash2", Pos + Dir * i * 0.7 * math.random(1,2) * 0.5 )
local Size = 1
if not particle then continue end
particle:SetVelocity( Dir * 800 + Vel )
particle:SetDieTime( 0.05 )
particle:SetStartAlpha( 255 * Size )
particle:SetStartSize( math.max( math.random(10,24) - i * 0.5,0.1 ) * Size )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 255, 255, 255 )
particle:SetCollide( false )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,41 @@
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Dir = data:GetNormal()
local Ent = data:GetEntity()
local Col = data:GetStart() or Vector(255,255,255)
local Vel = Dir * 10
if IsValid( Ent ) then
Vel = Ent:GetVelocity()
end
local emitter = ParticleEmitter( Pos, false )
if not IsValid( emitter ) then return end
for i = 0, 12 do
local particle = emitter:Add( "effects/muzzleflash2", Pos + Dir * i * 0.7 * math.random(1,2) * 0.5 )
local Size = 1
if not particle then continue end
particle:SetVelocity( Dir * 800 + Vel )
particle:SetDieTime( 0.05 )
particle:SetStartAlpha( 255 * Size )
particle:SetStartSize( math.max( math.random(10,24) - i * 0.5,0.1 ) * Size )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( Col.x, Col.y, Col.z )
particle:SetCollide( false )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,82 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
local MatDebris = {
"effects/lvs_base/particle_debris_01",
"effects/lvs_base/particle_debris_02",
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
if not IsValid( Ent ) then return end
local Dir = Ent:GetForward()
local emitter = Ent:GetParticleEmitter( Ent:GetPos() )
local VecCol = render.GetLightColor( Pos + Vector(0,0,10) ) * 0.5 + Vector(0.3,0.25,0.15)
if emitter and emitter.Add then
for i = 1, 3 do
local particle = emitter:Add( MatDebris[math.random(1,#MatDebris)], Pos + VectorRand(-10,10) )
if particle then
particle:SetVelocity( Vector(0,0,150) - Dir * 150 )
particle:SetDieTime( 0.2 )
particle:SetAirResistance( 60 )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 255 )
particle:SetStartSize( 15 )
particle:SetEndSize( 50 )
particle:SetRoll( math.Rand(-1,1) * 100 )
particle:SetColor( VecCol.x * 130,VecCol.y * 100,VecCol.z * 60 )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( false )
end
end
local Right = Ent:GetRight()
Right.z = 0
Right:Normalize()
for i = -1,1,2 do
local particle = emitter:Add( Materials[math.random(1,#Materials)], Pos + Vector(0,0,10) )
if particle then
particle:SetVelocity( -Dir * 400 + Right * 150 * i )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( 150 )
particle:SetStartAlpha( 50 )
particle:SetStartSize( -80 )
particle:SetEndSize( 400 )
particle:SetColor( VecCol.x * 255,VecCol.y * 255,VecCol.z * 255 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
end
end
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,89 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
if not LVS.ShowPhysicsEffects then return end
local dir = data:GetNormal()
local pos = data:GetOrigin() + dir
local emitter = ParticleEmitter( pos, false )
for i = 0, 10 do
local particle = emitter:Add( "effects/spark", pos )
local vel = VectorRand() * 75 + dir * 75 + Vector(0,0,100)
if not particle then continue end
particle:SetVelocity( vel )
particle:SetDieTime( math.Rand(2.5,5) )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartLength( 6 )
particle:SetEndLength(0)
particle:SetStartSize( 3 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-5,5) )
particle:SetColor( 255, 200, 50 )
particle:SetGravity( Vector(0,0,-600) )
particle:SetCollide( true )
end
local smoke = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
if smoke then
smoke:SetVelocity( dir * 30 + VectorRand() * 15 )
smoke:SetDieTime( math.Rand(1.5,3) )
smoke:SetAirResistance( 100 )
smoke:SetStartAlpha( 100 )
smoke:SetEndAlpha( 0 )
smoke:SetStartSize( 15 )
smoke:SetEndSize( 30 )
smoke:SetColor(30,30,30)
smoke:SetGravity(Vector(0,0,40))
smoke:SetCollide( false )
smoke:SetRollDelta( math.Rand(-1,1) )
end
local flash = emitter:Add( "effects/yellowflare",pos )
if flash then
flash:SetPos( pos )
flash:SetStartAlpha( 200 )
flash:SetEndAlpha( 0 )
flash:SetColor( 255, 200, 0 )
flash:SetEndSize( 100 )
flash:SetDieTime( 0.1 )
flash:SetStartSize( 0 )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,109 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
if not LVS.ShowPhysicsEffects then
self.LifeTime = 0
self.DieTime = 0
return
end
self.Pos = data:GetOrigin()
self.mat = Material( "sprites/light_glow02_add" )
self.LifeTime = 0.2
self.DieTime = CurTime() + self.LifeTime
local Col = self.Col
local Pos = self.Pos
local Dir = data:GetNormal()
local Strength = data:GetMagnitude()
local emitter = ParticleEmitter( Pos, false )
for i = 0,1 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], Pos )
local vel = VectorRand() * 100 + Dir * 40
if particle then
particle:SetVelocity( vel )
particle:SetDieTime( 1 )
particle:SetAirResistance( 1000 )
particle:SetStartAlpha( 10 )
particle:SetStartSize( 2 )
particle:SetEndSize( 12 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 40, 30, 20 )
particle:SetGravity( Dir * 50 )
particle:SetCollide( false )
end
end
for i = 0, 3 do
local particle = emitter:Add( "effects/spark", Pos )
local vel = VectorRand() * 25 * (1 - Strength) + (VectorRand() * 100 + Dir * 150) * Strength
if particle then
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( 2 )
particle:SetStartAlpha( math.Rand( 200, 255 ) )
particle:SetEndAlpha( 0 )
particle:SetStartLength( 4 )
particle:SetEndLength(0)
particle:SetStartSize( 2 )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
particle:SetAirResistance( 0 )
particle:SetColor( 255, 200, 50 )
particle:SetGravity( Vector(0,0,-600) )
end
end
emitter:Finish()
end
function EFFECT:Think()
if self.DieTime < CurTime() then
return false
end
return true
end
local mat = Material( "sprites/light_glow02_add" )
function EFFECT:Render()
if not LVS.ShowPhysicsEffects then return end
local Scale = (self.DieTime - CurTime()) / self.LifeTime
render.SetMaterial( mat )
render.DrawSprite( self.Pos, 32, 32, Color( 255 * Scale, 175 * Scale, 80 * Scale, 255) )
end

View File

@@ -0,0 +1,43 @@
EFFECT.DustMat = {
"effects/lvs/track_debris_01",
"effects/lvs/track_debris_02",
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local ent = data:GetEntity()
local size = data:GetMagnitude()
if not IsValid( ent ) then return end
local dir = data:GetNormal()
local emitter = ent:GetParticleEmitter( ent:GetPos() )
local VecCol = (render.GetLightColor( pos + dir ) * 0.5 + Vector(0.5,0.4,0.3)) * 255
local scale = math.Clamp( size / 23, 0.5, 1.25 )
local particle = emitter:Add( self.DustMat[ math.random(1,#self.DustMat) ] , pos + dir * 5 * scale + VectorRand() * 5 * scale )
if not particle then return end
particle:SetVelocity( (dir * 100 * scale + VectorRand() * 20 * scale) )
particle:SetDieTime( math.Rand(0.4,0.6) )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( math.random(100,255) )
particle:SetStartSize( 6 * scale )
particle:SetEndSize( math.random(20,25) * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,-600) )
particle:SetCollide( false )
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,48 @@
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
local emitter = ParticleEmitter( pos, false )
for i = 1, 360 do
if math.random(1,30) ~= 10 then continue end
local ang = i
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
local forward = Vector(X,Y,0)
forward:Rotate( dir:Angle() + Angle(90,0,0) )
local spark = emitter:Add("effects/spark", pos + VectorRand() * 10 )
if not spark then continue end
spark:SetStartAlpha( 255 )
spark:SetEndAlpha( 0 )
spark:SetCollide( true )
spark:SetBounce( math.Rand(0,1) )
spark:SetColor( 255, 255, 255 )
spark:SetGravity( Vector(0,0,-600) )
spark:SetEndLength(0)
local size = math.Rand(2, 4)
spark:SetEndSize( size )
spark:SetStartSize( size )
spark:SetStartLength( math.Rand(5,7) )
spark:SetDieTime( math.Rand(0.1, 0.3) )
spark:SetVelocity( forward * math.random(75,100) + VectorRand() * 50 )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,48 @@
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
local emitter = ParticleEmitter( pos, false )
for i = 1, 360 do
if math.random(1,30) ~= 15 then continue end
local ang = i
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
local forward = Vector(X,Y,0)
forward:Rotate( dir:Angle() + Angle(90,0,0) )
local spark = emitter:Add("effects/spark", pos + forward * 25 )
if not spark then continue end
spark:SetStartAlpha( 255 )
spark:SetEndAlpha( 0 )
spark:SetCollide( true )
spark:SetBounce( math.Rand(0,1) )
spark:SetColor( 255, 255, 255 )
spark:SetGravity( Vector(0,0,-600) )
spark:SetEndLength(0)
local size = math.Rand(4, 6)
spark:SetEndSize( size )
spark:SetStartSize( size )
spark:SetStartLength( math.Rand(10,20) )
spark:SetDieTime( math.Rand(0.01, 0.2) )
spark:SetVelocity( forward * math.random(250,400) + dir * 150 + VectorRand() * 50 )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,63 @@
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
if not IsValid( Ent ) then return end
self.LifeTime = math.Rand(1.5,3)
self.DieTime = CurTime() + self.LifeTime
local LightColor = render.GetLightColor( Pos )
self.VecCol = Vector(1,1.2,1.4) * (0.06 + (0.2126 * LightColor.r) + (0.7152 * LightColor.g) + (0.0722 * LightColor.b)) * 1000
self.VecCol.x = math.min( self.VecCol.x, 255 )
self.VecCol.y = math.min( self.VecCol.y, 255 )
self.VecCol.z = math.min( self.VecCol.z, 255 )
self.Splash = {
Pos = Pos,
Mat = Material("effects/splashwake1"),
RandomAng = math.random(0,360),
}
local emitter = Ent:GetParticleEmitter( Ent:GetPos() )
if emitter and emitter.Add then
local particle = emitter:Add( "effects/splash4", Pos + VectorRand(-10,10) - Vector(0,0,20) )
if particle then
particle:SetVelocity( Vector(0,0,250) )
particle:SetDieTime( 0.8 )
particle:SetAirResistance( 60 )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 50 )
particle:SetEndSize( 100 )
particle:SetRoll( math.Rand(-1,1) * 100 )
particle:SetColor(self.VecCol.r,self.VecCol.g,self.VecCol.b)
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( false )
end
end
end
function EFFECT:Think()
if CurTime() > self.DieTime then
return false
end
return true
end
function EFFECT:Render()
if self.Splash and self.LifeTime then
local Scale = (self.DieTime - self.LifeTime - CurTime()) / self.LifeTime
local S = 200 - Scale * 600
local Alpha = 100 + 100 * Scale
cam.Start3D2D( self.Splash.Pos + Vector(0,0,1), Angle(0,0,0), 1 )
surface.SetMaterial( self.Splash.Mat )
surface.SetDrawColor( self.VecCol.r, self.VecCol.g, self.VecCol.b, Alpha )
surface.DrawTexturedRectRotated( 0, 0, S , S, self.Splash.RandomAng )
cam.End3D2D()
end
end

View File

@@ -0,0 +1,175 @@
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Ent = data:GetEntity()
if not IsValid( Ent ) then return end
local emitter = Ent:GetParticleEmitter( Ent:GetPos() )
if not IsValid( emitter ) then return end
local Vel = Ent:GetVelocity()
Vel.z = 0
local Speed = Vel:Length()
if Speed < 50 then return end
local Steer = math.abs( Ent:GetSteer() )
local ShouldPlaySound = false
local T = CurTime()
local LightColor = render.GetLightColor( Pos )
local VecCol = Vector(1,1.2,1.4) * (0.06 + (0.2126 * LightColor.r) + (0.7152 * LightColor.g) + (0.0722 * LightColor.b)) * 1000
VecCol.x = math.min( VecCol.x, 255 )
VecCol.y = math.min( VecCol.y, 255 )
VecCol.z = math.min( VecCol.z, 255 )
local mul = math.min(Speed * 0.005,1)
local invmul = 1 - mul
local EntPos = Ent:GetPos()
local Len = Ent:BoundingRadius() * 1.5
local MoveDir = Vel:GetNormalized()
local MoveAng = MoveDir:Angle()
local Target = LocalPlayer()
if IsValid( Target ) then
ShouldPlaySound = Target:lvsGetVehicle() == Ent
local ViewEnt = Target:GetViewEntity()
if IsValid( ViewEnt ) then
Target = ViewEnt
end
end
local SwapSides = math.abs( Ent:GetSteer() ) > 0.9
local Res = math.max( math.Round( (Target:GetPos() - Pos):LengthSqr() / 2500000, 0 ), 5 )
for i = -135, 135, Res do
local Dir = Angle(0,MoveAng.y+i,0):Forward()
local StartPos = Pos + Dir * Len
local EndPos = Pos
local trace = util.TraceLine( {
start = StartPos,
endpos = EndPos,
filter = Ent,
ignoreworld = true,
whitelist = true,
} )
if not trace.Hit then continue end
local fxPos = Ent:WorldToLocal( trace.HitPos + trace.HitNormal * 2 )
if SwapSides then fxPos.y = -fxPos.y end
fxPos = Ent:LocalToWorld( fxPos )
local particle = emitter:Add( "effects/splash4", fxPos + Vector(0,0,math.Rand(-5,5) * mul) )
if not particle then continue end
local pfxVel = Ent:WorldToLocal( EntPos + Dir * Speed * 0.5 + trace.HitNormal * Speed * 0.25 )
if SwapSides then pfxVel.y = -pfxVel.y end
pfxVel = Ent:LocalToWorld( pfxVel ) - EntPos
local pfxMul = math.Clamp( pfxVel.z / 250, 1, 2 )
particle:SetVelocity( pfxVel )
particle:SetDieTime( (math.Rand(0.8,0.8) + math.Rand(0.2,0.4) * invmul) * pfxMul )
particle:SetAirResistance( 60 )
particle:SetStartAlpha( ((pfxMul / 2) ^ 2) * 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 5 + math.Rand(5,10) * mul )
particle:SetEndSize( 15 + math.Rand(10,20) * mul * pfxMul )
particle:SetRoll( math.Rand(-1,1) * math.Rand(50,150) )
particle:SetRollDelta( math.Rand(-1,1) * pfxMul * mul * 0.5 )
particle:SetColor(VecCol.r,VecCol.g,VecCol.b)
particle:SetGravity( Vector( 0, 0, -600 * math.Rand(1,1 + Steer * 3) ) - Vel * math.abs( i * 0.15 ) / 65 )
particle:SetCollide( false )
particle:SetNextThink( T )
particle:SetThinkFunction( function( p )
local fxpos = p:GetPos()
p:SetNextThink( CurTime() )
if fxpos.z > Pos.z then return end
p:SetDieTime( 0 )
if not IsValid( Ent ) or math.random(1,6) ~= 2 then return end
local startpos = Vector(fxpos.x,fxpos.y,Pos.z + 1)
local volume = math.min( math.abs( p:GetVelocity().z ) / 100, 1 )
if ShouldPlaySound and volume > 0.2 and p:GetStartSize() > 13 and math.random(1,10) == 1 then
local pitch = math.Rand(95,105) * math.Clamp( 1.5 - volume * 0.9,0.5,1)
if pitch < 58 then
sound.Play( "vehicles/airboat/pontoon_splash"..math.random(1,2)..".wav", startpos, 75, math.Rand(95,105), volume * 0.1, 0 )
else
if Speed < 600 then
sound.Play( "ambient/water/water_splash"..math.random(1,3)..".wav", startpos, 75, pitch, volume * 0.1, 0 )
end
end
end
if not ShouldPlaySound then return end
local emitter3D = Ent:GetParticleEmitter3D( Ent:GetPos() )
if not IsValid( emitter3D ) then return end
local particle = emitter3D:Add("effects/splashwake1", startpos )
if not particle then return end
local scale = math.Rand(0.5,2)
local size = p:GetEndSize()
local vsize = Vector(size,size,size)
particle:SetStartSize( size * scale * 0.5 )
particle:SetEndSize( size * scale )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetPos( startpos )
particle:SetAngles( Angle(-90,math.Rand(-180,180),0) )
particle:SetColor(VecCol.r,VecCol.g,VecCol.b)
particle:SetNextThink( CurTime() )
particle:SetThinkFunction( function( pfx )
local startpos = pfx:GetPos()
local endpos = startpos - Vector(0,0,100)
local trace = util.TraceHull( {
start = startpos,
endpos = endpos,
filter = Ent,
whitelist = true,
mins = -vsize,
maxs = vsize,
} )
if trace.Hit then pfx:SetDieTime( 0 ) return end
pfx:SetNextThink( CurTime() )
end )
end )
end
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,183 @@
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
EFFECT.DustMat = {
"effects/lvs_base/particle_debris_01",
"effects/lvs_base/particle_debris_02",
}
local SmokeMat = EFFECT.SmokeMat
local function MakeDustParticle( emitter, emitter3D, pos, vel, r, g, b )
local particle = emitter:Add( SmokeMat[ math.random(1,#SmokeMat) ], pos )
if not particle then return end
particle:SetVelocity( vel )
particle:SetDieTime( 0.4 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 20 )
particle:SetEndSize( 30 )
particle:SetRollDelta( math.Rand(-6,6) )
particle:SetColor( r, g, b )
particle:SetGravity( Vector(0,0,-600) )
particle:SetCollide( false )
particle:SetNextThink( CurTime() )
particle:SetThinkFunction( function( p )
if not IsValid( emitter3D ) then return end
p:SetNextThink( CurTime() + 0.05 )
local pos = p:GetPos()
local vel = p:GetVelocity()
local traceData = {
start = pos,
endpos = pos + Vector(0,0,vel.z) * 0.06,
mask = MASK_SOLID_BRUSHONLY,
}
local trace = util.TraceLine( traceData )
if not trace.Hit then return end
p:SetEndSize( 0 )
p:SetDieTime( 0 )
local pHit = emitter3D:Add( SmokeMat[ math.random(1,#SmokeMat) ], trace.HitPos + trace.HitNormal )
pHit:SetStartSize( 15 )
pHit:SetEndSize( 15 )
pHit:SetDieTime( math.Rand(5,6) )
pHit:SetStartAlpha( 50 )
pHit:SetEndAlpha( 0 )
pHit:SetColor( p:GetColor() )
local Ang = trace.HitNormal:Angle()
Ang:RotateAroundAxis( trace.HitNormal, math.Rand(-180,180) )
pHit:SetAngles( Ang )
end )
end
function EFFECT:Init( data )
local pos = data:GetOrigin()
local ent = data:GetEntity()
if not IsValid( ent ) then return end
local dir = data:GetNormal()
local scale = data:GetMagnitude()
local speed = ent:GetVelocity():LengthSqr()
local tooSlow = speed < 30000
local tooFast = speed > 400000
local underwater = data:GetFlags() == 1
local start = ent:GetPos()
local emitter = ent:GetParticleEmitter( start )
local emitter3D = ent:GetParticleEmitter3D( start )
local VecCol
local LightColor = render.GetLightColor( pos + dir )
if underwater then
VecCol = Vector(1,1.2,1.4) * (0.06 + (0.2126 * LightColor.r) + (0.7152 * LightColor.g) + (0.0722 * LightColor.b)) * 1000
else
VecCol = Vector(0.3,0.25,0.15) * (0.1 + (0.2126 * LightColor.r) + (0.7152 * LightColor.g) + (0.0722 * LightColor.b)) * 1000
end
VecCol.x = math.min( VecCol.x, 255 )
VecCol.y = math.min( VecCol.y, 255 )
VecCol.z = math.min( VecCol.z, 255 )
local DieTime = math.Rand(0.8,1.6)
if not tooSlow then
for i = 1, 5 do
local particle = emitter:Add( self.DustMat[ math.random(1,#self.DustMat) ] , pos )
if not particle then continue end
particle:SetVelocity( (dir * 50 * i + VectorRand() * 25) * scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 * scale )
particle:SetEndSize( 20 * i * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector(0,0,-600) * scale )
particle:SetCollide( false )
end
end
for i = 1, 5 do
local particle = emitter:Add( underwater and "effects/splash4" or self.SmokeMat[ math.random(1,#self.SmokeMat) ] , pos )
if not particle then continue end
particle:SetVelocity( (dir * 50 * i + VectorRand() * 40) * scale )
particle:SetDieTime( (i / 8) * DieTime )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( underwarter and 150 or 255 )
particle:SetStartSize( 10 * scale )
particle:SetEndSize( 20 * i * scale )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector(0,0,-600) * scale )
particle:SetCollide( false )
if underwater or tooFast then continue end
particle:SetNextThink( CurTime() )
particle:SetThinkFunction( function( p )
if not IsValid( ent ) or not IsValid( emitter ) or not IsValid( emitter3D ) then return end
p:SetNextThink( CurTime() + 0.05 )
local pos = p:GetPos()
local vel = p:GetVelocity()
local dir = vel:GetNormalized()
local speed = vel:Length()
local traceData = {
start = pos,
endpos = pos + dir * speed * 0.06,
whitelist = true,
filter = ent,
}
local trace = util.TraceLine( traceData )
if not trace.Hit then return end
if tooSlow then
p:SetEndSize( 0 )
p:SetDieTime( 0 )
end
MakeDustParticle( emitter, emitter3D, trace.HitPos - trace.HitNormal * 10, trace.HitNormal * 20 + VectorRand() * 40, p:GetColor() )
end )
end
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,56 @@
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local ent = data:GetEntity()
if not IsValid( ent ) then return end
local dir = data:GetNormal()
local emitter = ent:GetParticleEmitter( ent:GetPos() )
local VecCol = (render.GetLightColor( pos + dir ) * 0.5 + Vector(0.3,0.3,0.3)) * 255
for i = 1, 2 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 50 )
particle:SetDieTime( math.Rand(0.5,1.5) )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 50 )
particle:SetStartSize( 20 )
particle:SetEndSize( 60 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,5) )
particle:SetCollide( false )
end
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,80 @@
EFFECT.WaterWake = Material("effects/splashwake1")
function EFFECT:Init( data )
local Pos = data:GetOrigin() + Vector(0,0,1)
local Ent = data:GetEntity()
self.Size = data:GetMagnitude()
if not IsValid( Ent ) then return end
self.LifeTime = 1
self.DieTime = CurTime() + self.LifeTime
local RainFX = data:GetFlags() == 1
if RainFX then
self.Size = self.Size * 2
else
self.Splash = {
Pos = Pos,
Mat = self.WaterWake,
RandomAng = math.random(0,360),
}
end
local LightColor = render.GetLightColor( Pos )
self.VecCol = Vector(1,1.2,1.4) * (0.06 + (0.2126 * LightColor.r) + (0.7152 * LightColor.g) + (0.0722 * LightColor.b)) * 1000
self.VecCol.x = math.min( self.VecCol.x, 255 )
self.VecCol.y = math.min( self.VecCol.y, 255 )
self.VecCol.z = math.min( self.VecCol.z, 255 )
local emitter = Ent:GetParticleEmitter( Ent:GetPos() )
local Vel = Ent:GetVelocity():Length()
for i = 1, 3 do
if emitter and emitter.Add then
local particle = emitter:Add( "effects/splash4", Pos + VectorRand() * self.Size * 0.1 )
if not particle then continue end
particle:SetVelocity( Vector(0,0,math.Clamp(Vel / 100,100,250)) )
particle:SetDieTime( 0.25 + math.min(Vel / 500,0.2) )
particle:SetAirResistance( 60 )
particle:SetStartAlpha( RainFX and 5 or 150 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( self.Size * 0.2 )
particle:SetEndSize( self.Size )
particle:SetRollDelta( math.Rand(-1,1) * 5 )
particle:SetColor( math.min( self.VecCol.r, 255 ), math.min( self.VecCol.g, 255 ), math.min( self.VecCol.b, 255 ) )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( false )
end
end
end
function EFFECT:Think()
if CurTime() > self.DieTime then
return false
end
return true
end
function EFFECT:Render()
if not self.Splash or not self.LifeTime or not self.VecCol then return end
local Scale = 1 - (self.DieTime - CurTime()) / self.LifeTime
local Alpha = math.max( 100 - 150 * Scale ^ 2, 0 )
if Alpha <= 0 then return end
local Size = (self.Size + self.Size * Scale) * 1.5
cam.Start3D2D( self.Splash.Pos, Angle(0,0,0), 1 )
surface.SetMaterial( self.Splash.Mat )
surface.SetDrawColor( math.min( self.VecCol.r, 255 ), math.min( self.VecCol.g, 255 ), math.min( self.VecCol.b, 255 ), Alpha )
surface.DrawTexturedRectRotated( 0, 0, Size, Size, self.Splash.RandomAng )
cam.End3D2D()
end

View File

@@ -0,0 +1,119 @@
local GlowMat = Material( "sprites/light_glow02_add" )
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.LifeTime = 0.4
self.DieTime = CurTime() + self.LifeTime
local emitter = ParticleEmitter( self.Pos, false )
if not IsValid( emitter ) then return end
for i = 0,30 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 800 )
particle:SetDieTime( math.Rand(4,6) )
particle:SetAirResistance( math.Rand(200,600) )
particle:SetStartAlpha( 100 )
particle:SetStartSize( math.Rand(30,60) )
particle:SetEndSize( math.Rand(100,150) )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 50,50,50 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
end
for i = 0, 20 do
local particle = emitter:Add( "sprites/light_glow02_add", self.Pos )
local vel = VectorRand() * 400
if particle then
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.4,0.8) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(24,48) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( 0,127,255 )
particle:SetGravity( Vector(0,0,-600) )
particle:SetAirResistance( 0 )
particle:SetCollide( true )
particle:SetBounce( 0.5 )
end
end
for i = 0, 40 do
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Pos )
if particle then
particle:SetVelocity( VectorRand(-1,1) * 500 )
particle:SetDieTime( 0.14 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 10 )
particle:SetEndSize( math.Rand(30,60) )
particle:SetEndAlpha( 100 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 200,150,150 )
particle:SetCollide( false )
end
end
emitter:Finish()
local Pos = self.Pos
local ply = LocalPlayer():GetViewEntity()
if IsValid( ply ) then
local delay = (Pos - ply:GetPos()):Length() / 13503.9
if delay <= 0.11 then
sound.Play( "ambient/explosions/explode_9.wav", Pos, 85, 100, 1 - delay * 8 )
end
timer.Simple( delay, function()
sound.Play( "LVS.MISSILE_EXPLOSION", Pos )
end )
else
sound.Play( "LVS.MISSILE_EXPLOSION", Pos )
end
end
function EFFECT:Think()
if self.DieTime < CurTime() then return false end
return true
end
function EFFECT:Render()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
render.SetMaterial( GlowMat )
render.DrawSprite( self.Pos, 400 * Scale, 400 * Scale, Color( 0, 127, 255, 255) )
render.DrawSprite( self.Pos, 100 * Scale, 100 * Scale, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,92 @@
EFFECT.Offset = Vector(-8,0,0)
local GlowMat = Material( "effects/select_ring" )
function EFFECT:Init( data )
self.Entity = data:GetEntity()
if IsValid( self.Entity ) then
self.OldPos = self.Entity:LocalToWorld( self.Offset )
self.Emitter = ParticleEmitter( self.Entity:LocalToWorld( self.OldPos ), false )
end
end
function EFFECT:doFX( pos )
if not IsValid( self.Entity ) then return end
if IsValid( self.Emitter ) then
local emitter = self.Emitter
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( -self.Entity:GetForward() * math.Rand(250,800) + self.Entity:GetVelocity())
particle:SetDieTime( 1 )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 8 )
particle:SetEndSize( 1 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 0,0,255 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( false )
end
local particle = emitter:Add( "effects/lvs_base/flamelet"..math.random(1,5), self.Entity:GetPos() )
if particle then
particle:SetVelocity( -self.Entity:GetForward() * 200 + VectorRand() * 50 )
particle:SetDieTime( 1 )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 6 )
particle:SetEndSize( 2 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 0,0,255 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( false )
end
end
end
function EFFECT:Think()
if IsValid( self.Entity ) then
self.nextDFX = self.nextDFX or 0
if self.nextDFX < CurTime() then
self.nextDFX = CurTime() + 0.02
local oldpos = self.OldPos
local newpos = self.Entity:LocalToWorld( self.Offset )
self:SetPos( newpos )
local Sub = (newpos - oldpos)
local Dir = Sub:GetNormalized()
local Len = Sub:Length()
self.OldPos = newpos
for i = 0, Len, 45 do
local pos = oldpos + Dir * i
self:doFX( pos )
end
end
return true
end
if IsValid( self.Emitter ) then
self.Emitter:Finish()
end
return false
end
function EFFECT:Render()
local ent = self.Entity
local pos = ent:LocalToWorld( self.Offset )
render.SetMaterial( GlowMat )
render.DrawSprite( pos, 100, 100, Color( 0, 127, 255, 50 ) )
end

View File

@@ -0,0 +1,40 @@
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Dir = data:GetNormal()
local Ent = data:GetEntity()
local Vel = Dir * 10
if IsValid( Ent ) then
Vel = Ent:GetVelocity()
end
local emitter = ParticleEmitter( Pos, false )
if not IsValid( emitter ) then return end
for i = 0, 12 do
local particle = emitter:Add( "effects/gunshipmuzzle", Pos + Dir * i * 0.7 * math.random(1,2) * 0.5 )
local Size = 1
if not particle then continue end
particle:SetVelocity( Dir * 800 + Vel )
particle:SetDieTime( 0.05 )
particle:SetStartAlpha( 255 * Size )
particle:SetStartSize( math.max( math.random(10,24) - i * 0.5,0.1 ) * Size )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetColor( 255, 255, 255 )
particle:SetCollide( false )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

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

View File

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

View File

@@ -0,0 +1,141 @@
EFFECT.BeamMaterial = Material( "particle/smokesprites_0003" )
EFFECT.SmokeMaterials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
self.Pos = data:GetOrigin()
self.Radius = data:GetMagnitude()
self.SpawnTime = CurTime()
self:SetAngles( data:GetNormal():Angle() )
self:Debris()
self:Explosion()
end
function EFFECT:Debris()
local emitter = ParticleEmitter( self.Pos, false )
if not IsValid( emitter ) then return end
for i = 0,30 do
local particle = emitter:Add( "effects/fleck_tile"..math.random(1,2), self.Pos )
local vel = (self:GetRight() * math.Rand(-1,1) + self:GetForward() * math.Rand(-1,1) + self:GetUp() * math.Rand(-0.25,0.25)):GetNormalized() * self.Radius * 5
if particle then
particle:SetVelocity( vel )
particle:SetDieTime( 0.6 )
particle:SetAirResistance( 25 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 5 )
particle:SetEndSize( 5 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetRollDelta( math.Rand(-1,1) * 10 )
particle:SetColor( 0,0,0 )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( true )
particle:SetBounce( 0.3 )
end
end
emitter:Finish()
end
function EFFECT:Explosion()
local emitter = ParticleEmitter( self.Pos, false )
if not IsValid( emitter ) then return end
local scale = 0.1 + self.Radius / 1000
for i = 0,10 do
local particle = emitter:Add( self.SmokeMaterials[ math.random(1, #self.SmokeMaterials ) ], self.Pos )
if not particle then continue end
particle:SetVelocity( VectorRand() * 1500 * scale )
particle:SetDieTime( math.Rand(0.75,1.5) * scale )
particle:SetAirResistance( math.Rand(200,600) )
particle:SetStartAlpha( 255 )
particle:SetStartSize( math.Rand(60,120) * scale )
particle:SetEndSize( math.Rand(220,320) * scale )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 40,40,40 )
particle:SetGravity( Vector( 0, 0, 100 ) )
particle:SetCollide( false )
end
emitter:Finish()
end
function EFFECT:Think()
if (self.SpawnTime + 0.15) < CurTime() then return false end
return true
end
function EFFECT:Render()
if not self.SpawnTime then return end
local pos = self:GetPos()
render.SetMaterial( self.BeamMaterial )
local segmentdist = 360 / 30
local overlap = 10
local Mul = math.Clamp(self.SpawnTime + 0.15 - CurTime(),0,0.15) / 0.15
do
local Width = self.Radius / 2
local Alpha = Mul * 255
local radius = self.Radius * 0.5 * ((1 - Mul) ^ 5)
local AngOffset = Mul * 360
if Alpha > 0 then
for a = segmentdist, 360, segmentdist do
local Ang = a + AngOffset
local StartPos = self:LocalToWorld( Vector( math.cos( math.rad( -Ang - overlap ) ) * radius, -math.sin( math.rad( -Ang - overlap ) ) * radius, 0 ) )
local EndPos = self:LocalToWorld( Vector( math.cos( math.rad( -Ang + overlap + segmentdist ) ) * radius, -math.sin( math.rad( -Ang + overlap + segmentdist ) ) * radius, 0 ) )
render.DrawBeam( StartPos, EndPos, Width, 0, 1, Color( 255, 255, 255, Alpha ) )
end
end
end
do
local Width = self.Radius / 2
local Alpha = Mul * 255
local radius = self.Radius * ((1 - Mul) ^ 5)
local AngOffset = Mul * 360
if Alpha > 0 then
for a = segmentdist, 360, segmentdist do
local Ang = a + AngOffset
local StartPos = self:LocalToWorld( Vector( math.cos( math.rad( -Ang - overlap ) ) * radius, -math.sin( math.rad( -Ang - overlap ) ) * radius, 0 ) )
local EndPos = self:LocalToWorld( Vector( math.cos( math.rad( -Ang + overlap + segmentdist ) ) * radius, -math.sin( math.rad( -Ang + overlap + segmentdist ) ) * radius, 0 ) )
render.DrawBeam( StartPos, EndPos, Width, 0, 1, Color( 255, 255, 255, Alpha ) )
end
end
end
end

View File

@@ -0,0 +1,85 @@
local LastImpact = 0
function EFFECT:Init( data )
self.Ent = data:GetEntity()
self.Pos = data:GetOrigin()
self.mat = Material( "sprites/light_glow02_add" )
local T = CurTime()
self.LifeTime = 0.2
self.DieTime = T + self.LifeTime
local DontHurtEars = math.Clamp( T - LastImpact, 0.4, 1 ) ^ 2
LastImpact = T
sound.Play( "lvs/shield_deflect.ogg", self.Pos, 120, 100, DontHurtEars )
self:Spark( self.Pos )
if IsValid( self.Ent ) then
self.Model = ClientsideModel( self.Ent:GetModel(), RENDERMODE_TRANSCOLOR )
self.Model:SetMaterial("models/alyx/emptool_glow")
self.Model:SetColor( Color(200,220,255,255) )
self.Model:SetParent( self.Ent, 0 )
self.Model:SetMoveType( MOVETYPE_NONE )
self.Model:SetLocalPos( Vector( 0, 0, 0 ) )
self.Model:SetLocalAngles( Angle( 0, 0, 0 ) )
self.Model:AddEffects( EF_BONEMERGE )
end
end
function EFFECT:Spark( pos )
local emitter = ParticleEmitter( pos, false )
for i = 0, 20 do
local particle = emitter:Add( "sprites/rico1", pos )
local vel = VectorRand() * 500
if not particle then continue end
particle:SetVelocity( vel )
particle:SetAngles( vel:Angle() + Angle(0,90,0) )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetStartAlpha( math.Rand( 200, 255 ) )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(10,20) )
particle:SetEndSize( 0 )
particle:SetRoll( math.Rand(-100,100) )
particle:SetRollDelta( math.Rand(-100,100) )
particle:SetColor( 0, 127, 255 )
particle:SetAirResistance( 0 )
end
emitter:Finish()
end
function EFFECT:Think()
if not IsValid( self.Ent ) then
if IsValid( self.Model ) then
self.Model:Remove()
end
end
if self.DieTime < CurTime() then
if IsValid( self.Model ) then
self.Model:Remove()
end
return false
end
return true
end
function EFFECT:Render()
local Scale = (self.DieTime - CurTime()) / self.LifeTime
render.SetMaterial( self.mat )
render.DrawSprite( self.Pos, 800 * Scale, 800 * Scale, Color( 0, 127, 255, 255) )
render.DrawSprite( self.Pos, 200 * Scale, 200 * Scale, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,90 @@
EFFECT.SmokeMat = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Ent = data:GetEntity()
if not IsValid( Ent ) then return end
local Offset = Ent:GetPos()
local Low, High = Ent:WorldSpaceAABB()
local Vel = Ent:GetVelocity()
local Radius = Ent:BoundingRadius()
local NumParticles = Radius
NumParticles = NumParticles * 4
NumParticles = math.Clamp( NumParticles, 32, 256 )
local emitter = ParticleEmitter( Offset )
for i = 0, NumParticles do
local Pos = Vector( math.Rand( Low.x, High.x ), math.Rand( Low.y, High.y ), math.Rand( Low.z, High.z ) )
local particle = emitter:Add( "effects/fleck_tile"..math.random(1,2), Pos )
if not particle then continue end
particle:SetVelocity( ( Pos - Offset ) * 5 + Vel * 0.5 )
particle:SetLifeTime( 0 )
particle:SetDieTime( math.Rand( 0.5, 1 ) )
particle:SetStartAlpha( 255 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( math.Rand(3,6) * Radius * 0.025 )
particle:SetEndSize( 1 )
particle:SetRoll( math.Rand( 0, 360 ) )
particle:SetRollDelta( math.Rand(-10,10) )
particle:SetAirResistance( 25 )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( true )
particle:SetColor( 50, 50, 50 )
particle:SetBounce( 0.3 )
particle:SetLighting( true )
end
for i = 1, 2 do
local particle = emitter:Add( self.SmokeMat[ math.random(1,#self.SmokeMat) ] , Offset )
if not particle then continue end
particle:SetVelocity( VectorRand() * 100 * Radius + Vel * 0.5 )
particle:SetDieTime( math.Rand(0.2,0.6) )
particle:SetAirResistance( 200 * Radius )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 0.5 * Radius )
particle:SetEndSize( 2 * Radius )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( 255, 255, 255 )
particle:SetGravity( Vector(0,0,600) )
particle:SetCollide( false )
particle:SetLighting( true )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,202 @@
EFFECT.MatBeam = Material( "effects/lvs_base/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
EFFECT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
self.emitter = ParticleEmitter( pos, false )
self.OldPos = pos
self.Dir = dir
if not self.emitter then return end
local VecCol = (render.GetLightColor( pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
for i = 0, 2 do
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], pos )
if not particle then continue end
particle:SetVelocity( dir * 700 + VectorRand() * 200 )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( 250 )
particle:SetStartAlpha( 50 )
particle:SetStartSize( 5 )
particle:SetEndSize( 80 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,100) )
particle:SetCollide( false )
end
for i = 0, math.random(1,12) do
local particle = self.emitter:Add( "sprites/rico1", pos )
if not particle then continue end
particle:SetVelocity( dir * 2000 + VectorRand() * 50 )
particle:SetDieTime( math.Rand(0.1,0.2) )
particle:SetStartAlpha( 0 )
particle:SetEndAlpha( 5 )
particle:SetStartSize( math.Rand(0,0.5) )
particle:SetEndSize( math.Rand(0,0.5) )
particle:SetRollDelta( 100 )
particle:SetAirResistance( 0 )
particle:SetColor( 255, 200, 120 )
end
local trace = util.TraceLine( {
start = pos,
endpos = pos - Vector(0,0,500),
mask = MASK_SOLID_BRUSHONLY,
} )
if not trace or not trace.Hit then return end
local VecCol = (render.GetLightColor( trace.HitPos + trace.HitNormal ) * 0.8 + Vector(0.17,0.15,0.1)) * 255
for i = 1, 12 do
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], trace.HitPos )
if not particle then continue end
local ang = i * 30
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
particle:SetVelocity( Vector(X,Y,0) * 1000 )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( 500 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 25 )
particle:SetEndSize( 80 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,150) + self.Dir * 1000 )
particle:SetCollide( false )
end
local ply = LocalPlayer()
if not IsValid( ply ) then return end
local ViewEnt = ply:GetViewEntity()
if not IsValid( ViewEnt ) then return end
local Intensity = 2
local Ratio = math.min( 250 / (ViewEnt:GetPos() - trace.HitPos):Length(), 1 )
if Ratio < 0 then return end
util.ScreenShake( trace.HitPos, Intensity * Ratio, 0.1, 0.5, 250 )
end
function EFFECT:Think()
local bullet = LVS:GetBullet( self.ID )
if not bullet then
if self.emitter then
self.emitter:Finish()
end
local StartPos = self.OldPos
local EndPos = StartPos + self.Dir * 1000
local trace = util.TraceLine( {
start = StartPos,
endpos = EndPos,
} )
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetStart( self.Dir )
effectdata:SetEntity( trace.Entity )
effectdata:SetNormal( trace.HitNormal )
effectdata:SetSurfaceProp( trace.SurfaceProps )
effectdata:SetMagnitude( 0.5 )
util.Effect( "lvs_bullet_impact_ap", effectdata )
return false
end
if not self.emitter then return true end
local Pos = bullet:GetPos()
self.Dir = bullet:GetDir()
local Sub = self.OldPos - Pos
local Dist = Sub:Length()
local Dir = Sub:GetNormalized()
local Vel = bullet.Velocity / 10
for i = 0, Dist, 100 do
local cur_pos = self.OldPos + Dir * i
local VecCol = (render.GetLightColor( cur_pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], cur_pos )
if not particle then continue end
particle:SetVelocity( -Dir * Vel + VectorRand() * 10 )
particle:SetDieTime( math.Rand(0.05,1) )
particle:SetAirResistance( 250 )
particle:SetStartAlpha( 100 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 0 )
particle:SetEndSize( 15 )
particle:SetRollDelta( 1 )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetCollide( false )
end
self.OldPos = Pos
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 2000 * bullet:GetLength()
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len * 0.1, 10, 1, 0, Color( 100, 100, 100, 100 ) )
render.DrawBeam( endpos - dir * len * 0.5, endpos + dir * len * 0.1, 5, 1, 0, Color( 255, 255, 255, 255 ) )
render.SetMaterial( self.MatSprite )
render.DrawSprite( endpos, 400, 400, Color( 100, 100, 100, 255 ) )
end

View File

@@ -0,0 +1,187 @@
EFFECT.MatBeam = Material( "effects/lvs_base/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
EFFECT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
self.emitter = ParticleEmitter( pos, false )
self.OldPos = pos
self.Dir = dir
if not self.emitter then return end
local VecCol = (render.GetLightColor( pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
for i = 0,10 do
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], pos )
if not particle then continue end
particle:SetVelocity( dir * 700 + VectorRand() * 200 )
particle:SetDieTime( math.Rand(2,3) )
particle:SetAirResistance( 250 )
particle:SetStartAlpha( 50 )
particle:SetStartSize( 5 )
particle:SetEndSize( 120 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,100) )
particle:SetCollide( false )
end
local trace = util.TraceLine( {
start = pos,
endpos = pos - Vector(0,0,500),
mask = MASK_SOLID_BRUSHONLY,
} )
if not trace or not trace.Hit then return end
local VecCol = (render.GetLightColor( trace.HitPos + trace.HitNormal ) * 0.8 + Vector(0.17,0.15,0.1)) * 255
for i = 1,24 do
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], trace.HitPos )
if not particle then continue end
local ang = i * 15
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
particle:SetVelocity( Vector(X,Y,0) * 2000 )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( 500 )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 25 )
particle:SetEndSize( 120 )
particle:SetRollDelta( math.Rand(-1,1) )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetGravity( Vector(0,0,150) + self.Dir * 2000 )
particle:SetCollide( false )
end
local ply = LocalPlayer()
if not IsValid( ply ) then return end
local ViewEnt = ply:GetViewEntity()
if not IsValid( ViewEnt ) then return end
local Intensity = 8
local Ratio = math.min( 250 / (ViewEnt:GetPos() - trace.HitPos):Length(), 1 )
if Ratio < 0 then return end
util.ScreenShake( trace.HitPos, Intensity * Ratio, 0.1, 0.5, 250 )
end
function EFFECT:Think()
local bullet = LVS:GetBullet( self.ID )
if not bullet then
if self.emitter then
self.emitter:Finish()
end
local StartPos = self.OldPos
local EndPos = StartPos + self.Dir * 1000
local trace = util.TraceLine( {
start = StartPos,
endpos = EndPos,
} )
if not trace.Hit then return false end
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetStart( self.Dir )
effectdata:SetEntity( trace.Entity )
effectdata:SetNormal( trace.HitNormal )
effectdata:SetSurfaceProp( trace.SurfaceProps )
effectdata:SetMagnitude( 1 )
util.Effect( "lvs_bullet_impact_ap", effectdata )
return false
end
if not self.emitter then return true end
local Pos = bullet:GetPos()
self.Dir = bullet:GetDir()
local Sub = self.OldPos - Pos
local Dist = Sub:Length()
local Dir = Sub:GetNormalized()
local Vel = bullet.Velocity / 10
for i = 0, Dist, 25 do
local cur_pos = self.OldPos + Dir * i
local VecCol = (render.GetLightColor( cur_pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], cur_pos )
if not particle then continue end
particle:SetVelocity( -Dir * Vel + VectorRand() * 10 )
particle:SetDieTime( math.Rand(0.05,1) )
particle:SetAirResistance( 250 )
particle:SetStartAlpha( 100 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 0 )
particle:SetEndSize( 30 )
particle:SetRollDelta( 1 )
particle:SetColor( math.min( VecCol.r, 255 ), math.min( VecCol.g, 255 ), math.min( VecCol.b, 255 ) )
particle:SetCollide( false )
end
self.OldPos = Pos
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local endpos = bullet:GetPos()
local dir = bullet:GetDir()
local len = 3000 * bullet:GetLength()
render.SetMaterial( self.MatBeam )
render.DrawBeam( endpos - dir * len, endpos + dir * len * 0.1, 32, 1, 0, Color( 100, 100, 100, 100 ) )
render.DrawBeam( endpos - dir * len * 0.5, endpos + dir * len * 0.1, 16, 1, 0, Color( 255, 255, 255, 255 ) )
render.SetMaterial( self.MatSprite )
render.DrawSprite( endpos, 250, 250, Color( 100, 100, 100, 255 ) )
end

View File

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

View File

@@ -0,0 +1,128 @@
EFFECT.MatBeam = Material( "effects/lvs_base/spark" )
EFFECT.MatSprite = Material( "sprites/light_glow02_add" )
EFFECT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
self.emitter = ParticleEmitter( pos, false )
self.OldPos = pos
self.Dir = dir
end
function EFFECT:doFX( pos, curpos )
if not IsValid( self.emitter ) then return end
local particle = self.emitter:Add( self.MatSmoke[ math.random(1, #self.MatSmoke ) ], pos )
if particle then
particle:SetGravity( Vector(0,0,100) + VectorRand() * 50 )
particle:SetVelocity( -self.Dir * 200 )
particle:SetAirResistance( 600 )
particle:SetDieTime( math.Rand(1.5,2) )
particle:SetStartAlpha( 50 )
particle:SetStartSize( 20 )
particle:SetEndSize( 60 )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetRollDelta( math.Rand( -1, 1 ) )
particle:SetColor(40,40,40)
particle:SetCollide( false )
end
local particle = self.emitter:Add( "particles/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( -self.Dir * math.Rand(250,800) + self.Dir * 1500 )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 8 )
particle:SetEndSize( 1 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 0 ) )
particle:SetCollide( false )
end
local particle = self.emitter:Add( "particles/flamelet"..math.random(1,5), curpos )
if particle then
particle:SetVelocity( -self.Dir * 200 + VectorRand() * 50 )
particle:SetDieTime( 0.25 )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 6 )
particle:SetEndSize( 2 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 255,255,255 )
particle:SetGravity( Vector( 0, 0, 0 ) )
particle:SetCollide( false )
end
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then
if self.emitter then
self.emitter:Finish()
end
return false
end
if not self.emitter then return true end
local T = CurTime()
if (self.nextDFX or 0) <= T then
self.nextDFX = T + 0.02
local bullet = LVS:GetBullet( self.ID )
local Pos = bullet:GetPos()
local Sub = self.OldPos - Pos
local Dist = Sub:Length()
local Dir = Sub:GetNormalized()
for i = 0, Dist, 45 do
local cur_pos = self.OldPos + Dir * i
self:doFX( cur_pos, Pos )
end
self.OldPos = Pos
end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local pos = bullet:GetPos()
render.SetMaterial( self.MatSprite )
render.DrawSprite( pos, 100, 100, Color( 255, 200, 150, 255 ) )
end

View File

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

View File

@@ -0,0 +1,104 @@
EFFECT.GlowColor = Color( 0, 127, 255, 255 )
EFFECT.GlowMat = Material( "sprites/light_glow02_add" )
EFFECT.MatSprite = Material( "effects/select_ring" )
function EFFECT:Init( data )
local pos = data:GetOrigin()
local dir = data:GetNormal()
self.ID = data:GetMaterialIndex()
self:SetRenderBoundsWS( pos, pos + dir * 50000 )
self.emitter = ParticleEmitter( pos, false )
self.OldPos = pos
self.Dir = dir
end
function EFFECT:doFX( pos, curpos )
if not IsValid( self.emitter ) then return end
local particle = self.emitter:Add( "particles/flamelet"..math.random(1,5), pos )
if particle then
particle:SetVelocity( -self.Dir * math.Rand(250,800) + self.Dir * 5000 )
particle:SetDieTime( math.Rand(0.2,0.4) )
particle:SetAirResistance( 0 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 8 )
particle:SetEndSize( 1 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 0,0,255 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( false )
end
local particle = self.emitter:Add( "particles/flamelet"..math.random(1,5), curpos )
if particle then
particle:SetVelocity( self.Dir * 5000 + VectorRand() * 50 )
particle:SetDieTime( 1 )
particle:SetAirResistance( 600 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 6 )
particle:SetEndSize( 2 )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 0,0,255 )
particle:SetGravity( Vector( 0, 0, 600 ) )
particle:SetCollide( false )
end
end
function EFFECT:Think()
if not LVS:GetBullet( self.ID ) then
if self.emitter then
self.emitter:Finish()
end
return false
end
if not self.emitter then return true end
local T = CurTime()
if (self.nextDFX or 0) <= T then
self.nextDFX = T + 0.02
local bullet = LVS:GetBullet( self.ID )
local Pos = bullet:GetPos()
local Sub = self.OldPos - Pos
local Dist = Sub:Length()
local Dir = Sub:GetNormalized()
for i = 0, Dist, 45 do
local cur_pos = self.OldPos + Dir * i
self:doFX( cur_pos, Pos )
end
self.OldPos = Pos
end
return true
end
function EFFECT:Render()
local bullet = LVS:GetBullet( self.ID )
local pos = bullet:GetPos()
render.SetMaterial( self.MatSprite )
render.DrawSprite( pos, 100, 100, Color( 0, 127, 255, 50 ) )
render.SetMaterial( self.GlowMat )
for i = 0, 30 do
local Size = ((30 - i) / 30) ^ 2 * 128
render.DrawSprite( pos - self.Dir * i * 7, Size, Size, self.GlowColor )
end
end

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,81 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local effectdata = EffectData()
effectdata:SetOrigin( pos )
util.Effect( "cball_explode", effectdata, true, true )
local effectdata = EffectData()
effectdata:SetOrigin( pos )
effectdata:SetNormal( Vector(0,0,1) )
util.Effect( "manhacksparks", effectdata, true, true )
local emitter = ParticleEmitter( pos, false )
for i = 0,30 do
local particle = emitter:Add( "effects/fleck_tile"..math.random(1,2), pos )
local vel = VectorRand() * math.Rand(150,200)
vel.z = math.Rand(200,250)
if not particle then continue end
particle:SetVelocity( vel )
particle:SetDieTime( math.Rand(2,6) )
particle:SetAirResistance( 10 )
particle:SetStartAlpha( 255 )
particle:SetStartSize( 2 )
particle:SetEndSize( 2 )
particle:SetRoll( math.Rand(-1,1) * math.pi )
particle:SetColor( 0,0,0 )
particle:SetGravity( Vector( 0, 0, -600 ) )
particle:SetCollide( true )
particle:SetBounce( 0.3 )
end
for i = 0,4 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], pos )
local vel = VectorRand() * 200
if particle then
particle:SetVelocity( vel )
particle:SetDieTime( math.Rand(2.5,5) )
particle:SetAirResistance( 100 )
particle:SetStartAlpha( 200 )
particle:SetStartSize( 50 )
particle:SetEndSize( 200 )
particle:SetRoll( math.Rand(-5,5) )
particle:SetColor( 10,10,10 )
particle:SetGravity( Vector(0,0,20) )
particle:SetCollide( false )
end
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,84 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local Pos = data:GetOrigin()
local Dir = data:GetNormal()
local Ent = data:GetEntity()
if not IsValid( Ent ) or not isfunction( Ent.GetThrottle ) then return end
local Engine = Ent:GetEngine()
if not IsValid( Engine ) or not isfunction( Engine.GetRPM ) then return end
local Vel = Ent:GetVelocity()
local emitter = Ent:GetParticleEmitter( Pos )
if not IsValid( emitter ) then return end
local throttle = math.min( Ent:GetThrottle() / 0.5, 1 )
local clutch = Ent:GetQuickVar( "clutch" )
local hasClutch = Ent:HasQuickVar( "clutch" )
local ClutchActive = Engine:GetClutch()
if not clutch then
clutch = ClutchActive and 1 or 0
end
if ClutchActive then
throttle = math.max( throttle - clutch, 0 )
end
local Scale = math.min( (math.max( Engine:GetRPM() - Ent.EngineIdleRPM, 0 ) / (Ent.EngineMaxRPM - Ent.EngineIdleRPM)) * (throttle ^ 2), 1 )
local temp = 0
if Ent:HasQuickVar("temp") then
temp = math.Clamp( 1 - Ent:GetQuickVar( "temp" ) / 0.5, 0, 1 )
end
local Col = 50 + 205 * temp
Col = Col - (Scale * Col)
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ], Pos )
if not particle then return end
local invert = (1 - Dir.z) / 2
particle:SetVelocity( Vel + Dir * (100 + math.min( 800 * Scale, 300)) + VectorRand() * 50 * Scale + (Ent:GetVelocity() * 0.5 + Vector(0,0,Scale * 100)) * invert )
particle:SetDieTime( math.max((1.4 - temp) - Ent:GetVelocity():LengthSqr() * 0.0001,0.2) + Scale * math.Rand(0.8,1.2) )
particle:SetAirResistance( 400 )
particle:SetStartAlpha( 100 - 50 * temp + Scale * 150 )
particle:SetStartSize( 2 + (throttle + Scale) * 4 )
particle:SetEndSize( 10 + 35 * (throttle + Scale) )
particle:SetRoll( math.Rand( -1, 1 ) )
particle:SetRollDelta( math.Rand( -1, 1 ) * (2 - Scale * 1.75) )
particle:SetColor( Col, Col, Col )
particle:SetGravity( Vector( 0, 0, 10 + Scale * 300 ) + Ent:GetVelocity() * 4 )
particle:SetCollide( true )
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,43 @@
function EFFECT:Init( data )
self.Ent = data:GetEntity()
self.Pos = data:GetOrigin()
local T = CurTime()
self.LifeTime = 1
self.DieTime = T + self.LifeTime
if IsValid( self.Ent ) then
self.Model = ClientsideModel( self.Ent:GetModel(), RENDERMODE_TRANSCOLOR )
self.Model:SetMaterial("models/alyx/emptool_glow")
self.Model:SetColor( Color(0,127,255,255) )
self.Model:SetParent( self.Ent, 0 )
self.Model:SetMoveType( MOVETYPE_NONE )
self.Model:SetLocalPos( Vector( 0, 0, 0 ) )
self.Model:SetLocalAngles( Angle( 0, 0, 0 ) )
self.Model:AddEffects( EF_BONEMERGE )
self.Model:SetModelScale( self.Ent:GetModelScale() )
end
end
function EFFECT:Think()
if not IsValid( self.Ent ) then
if IsValid( self.Model ) then
self.Model:Remove()
end
end
if self.DieTime < CurTime() then
if IsValid( self.Model ) then
self.Model:Remove()
end
return false
end
return true
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,43 @@
function EFFECT:Init( data )
self.Ent = data:GetEntity()
self.Pos = data:GetOrigin()
local T = CurTime()
self.LifeTime = 1
self.DieTime = T + self.LifeTime
if IsValid( self.Ent ) then
self.Model = ClientsideModel( self.Ent:GetModel(), RENDERMODE_TRANSCOLOR )
self.Model:SetMaterial("models/alyx/emptool_glow")
self.Model:SetColor( Color(255,200,50,255) )
self.Model:SetParent( self.Ent, 0 )
self.Model:SetMoveType( MOVETYPE_NONE )
self.Model:SetLocalPos( Vector( 0, 0, 0 ) )
self.Model:SetLocalAngles( Angle( 0, 0, 0 ) )
self.Model:AddEffects( EF_BONEMERGE )
self.Model:SetModelScale( self.Ent:GetModelScale() )
end
end
function EFFECT:Think()
if not IsValid( self.Ent ) then
if IsValid( self.Model ) then
self.Model:Remove()
end
end
if self.DieTime < CurTime() then
if IsValid( self.Model ) then
self.Model:Remove()
end
return false
end
return true
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,54 @@
local Materials = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function EFFECT:Init( data )
local pos = data:GetOrigin()
local emitter = ParticleEmitter( pos, false )
for i = 1,12 do
local particle = emitter:Add( Materials[ math.random(1, #Materials ) ],pos )
if not particle then continue end
local ang = i * 30
local X = math.cos( math.rad(ang) )
local Y = math.sin( math.rad(ang) )
particle:SetVelocity( Vector(X,Y,0) * math.Rand(3000,4000) )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( math.Rand(3000,5000) )
particle:SetStartAlpha( 100 )
particle:SetStartSize( 20 )
particle:SetEndSize( math.Rand(30,40) )
particle:SetRoll( math.Rand(-1,1) )
particle:SetColor( 60,60,60 )
particle:SetGravity( VectorRand() * 200 + Vector(0,0,1000) )
particle:SetCollide( false )
end
emitter:Finish()
end
function EFFECT:Think()
return false
end
function EFFECT:Render()
end

View File

@@ -0,0 +1,63 @@
local MuzzleFX = Material("sprites/strider_blackball")
local BeamFX = Material("sprites/bluelaser1")
local WarpFX = Material("particle/warp5_warp")
function EFFECT:Init( data )
self.Ent = data:GetEntity()
if not IsValid( self.Ent ) then return end
self.LifeTime = 2
self.DieTime = CurTime() + self.LifeTime
self.Ent:EmitSound( "NPC_Strider.Charge" )
self:SetRenderBoundsWS( self.Ent:GetPos(), self.Ent:GetPos() - self.Ent:GetUp() * 50000 )
end
function EFFECT:Think()
if (self.DieTime or 0) < CurTime() then return false end
return true
end
function EFFECT:Render()
if not IsValid( self.Ent ) then return end
local Muzzle = self.Ent:GetAttachment( self.Ent:LookupAttachment( "bellygun" ) )
if not Muzzle then return end
local T = CurTime()
local Delta = ((T + self.LifeTime) - self.DieTime) / self.LifeTime
local trace = util.TraceLine( {
start = Muzzle.Pos,
endpos = Muzzle.Pos + self.Ent:GetAimVector() * 50000,
mask = MASK_SOLID_BRUSHONLY
} )
self:SetRenderBoundsWS( Muzzle.Pos, trace.HitPos )
render.SetMaterial( MuzzleFX )
render.DrawSprite( Muzzle.Pos, Delta * 32, Delta * 32, Color( 255, 255, 255, Delta * 255) )
render.SetMaterial( BeamFX )
render.DrawBeam( Muzzle.Pos, trace.HitPos, (Delta ^ 2) * 64, 0, 1, Color( 255, 255, 255 ) )
render.SetMaterial( WarpFX )
render.DrawSprite( Muzzle.Pos, (Delta ^ 2) * 256, (Delta ^ 2) * 256, Color( 255, 255, 255, 100) )
local dlight = DynamicLight( self:EntIndex() * 1337 )
if dlight then
dlight.pos = Muzzle.Pos
dlight.r = 0
dlight.g = 255
dlight.b = 255
dlight.brightness = Delta * 10
dlight.Decay = 100
dlight.Size = 128
dlight.DieTime = CurTime() + 0.2
end
end

View File

@@ -0,0 +1,76 @@
local MuzzleFX = Material("sprites/strider_blackball")
local BeamFX = Material("sprites/bluelaser1")
local WarpFX = Material("particle/warp5_warp")
function EFFECT:Init( data )
self.Ent = data:GetEntity()
if not IsValid( self.Ent ) then return end
self.LifeTime = 0.2
self.DieTime = CurTime() + self.LifeTime
self.Ent:EmitSound( "NPC_Strider.Shoot" )
self:SetRenderBoundsWS( self.Ent:GetPos(), self.Ent:GetPos() - self.Ent:GetUp() * 50000 )
end
function EFFECT:Think()
if (self.DieTime or 0) < CurTime() then
self:DoImpactEffect()
return false
end
return true
end
function EFFECT:DoImpactEffect()
if not IsValid( self.Ent ) then return end
local Muzzle = self.Ent:GetAttachment( self.Ent:LookupAttachment( "bellygun" ) )
if not Muzzle then return end
local trace = util.TraceLine( {
start = Muzzle.Pos,
endpos = Muzzle.Pos + self.Ent:GetAimVector() * 50000,
mask = MASK_SOLID_BRUSHONLY
} )
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos + trace.HitNormal )
effectdata:SetRadius( 256 )
effectdata:SetNormal( trace.HitNormal )
util.Effect( "AR2Explosion", effectdata, true, true )
end
function EFFECT:Render()
if not IsValid( self.Ent ) then return end
local Muzzle = self.Ent:GetAttachment( self.Ent:LookupAttachment( "bellygun" ) )
if not Muzzle then return end
local T = CurTime()
local Delta = ((T + self.LifeTime) - self.DieTime) / self.LifeTime
local trace = util.TraceLine( {
start = Muzzle.Pos,
endpos = Muzzle.Pos + self.Ent:GetAimVector() * 50000,
mask = MASK_SOLID_BRUSHONLY
} )
self:SetRenderBoundsWS( Muzzle.Pos, trace.HitPos )
render.SetMaterial( BeamFX )
render.DrawBeam( Muzzle.Pos, trace.HitPos, (Delta ^ 2) * 64, 0, 1, Color( 255, 255, 255 ) )
local Sub = trace.HitPos - Muzzle.Pos
local Dir = Sub:GetNormalized()
local Dist = Sub:Length()
local Scale = 512 - Delta * 512
render.SetMaterial( WarpFX )
render.DrawSprite( Muzzle.Pos + Dir * Dist * Delta, Scale, Scale, Color( 255, 255, 255, 255) )
end

View File

@@ -0,0 +1,258 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.DoNotDuplicate = true
ENT.RenderGroup = RENDERGROUP_BOTH
function ENT:SetupDataTables()
self:NetworkVar( "Entity",0, "Base" )
self:NetworkVar( "Float",0, "HP" )
self:NetworkVar( "Float",1, "MaxHP" )
self:NetworkVar( "Float",2, "IgnoreForce" )
self:NetworkVar( "Vector",0, "Mins" )
self:NetworkVar( "Vector",1, "Maxs" )
self:NetworkVar( "Bool",0, "Destroyed" )
self:NetworkVar( "String",0, "Label" )
if SERVER then
self:SetMaxHP( 100 )
self:SetHP( 100 )
self:SetLabel( "Armor Plate" )
end
end
if SERVER then
function ENT:Initialize()
self:SetMoveType( MOVETYPE_NONE )
self:SetSolid( SOLID_NONE )
self:DrawShadow( false )
end
function ENT:Think()
return false
end
function ENT:OnHealthChanged( dmginfo, old, new )
if old == new then return end
end
function ENT:OnRepaired()
end
function ENT:OnDestroyed( dmginfo )
end
function ENT:OnTakeDamage( dmginfo )
end
function ENT:TakeTransmittedDamage( dmginfo )
local Force = dmginfo:GetDamageForce()
local Damage = dmginfo:GetDamage()
local DamageForce = Force:Length()
local IsBlastDamage = dmginfo:IsDamageType( DMG_BLAST )
local CurHealth = self:GetHP()
local pos = dmginfo:GetDamagePosition()
local dir = Force:GetNormalized()
local base = self:GetBase()
-- translate force value to armor penetration value is Force * 0.1
-- mm to inch is * 0.0393701
-- so correct value is * 0.00393701
local pLength = DamageForce * 0.00393701
local TraceData = {
start = pos - dir * pLength,
endpos = pos + dir * pLength,
}
local trace = util.TraceLine( TraceData )
-- parent stays the same
local parent = trace.Entity
local parentPos = trace.HitPos
local parentDir = trace.HitNormal
-- only one extra iteration should be enough ...
if IsValid( trace.Entity ) and isfunction( trace.Entity.GetBase ) and trace.Entity:GetBase() == base then
TraceData.filter = trace.Entity
local FilteredTrace = util.TraceLine( TraceData )
if FilteredTrace.Hit then
trace = FilteredTrace
end
trace.Entity = base
end
local DotHitNormal = math.Clamp( trace.HitNormal:Dot( dir ) ,-1,1)
local Armor = self:GetIgnoreForce()
local ArmorEffective = Armor / math.abs( DotHitNormal )
if math.abs( DotHitNormal ) > 0.9 then
ArmorEffective = Armor
end
local DisableBounce = false
local Inflictor = dmginfo:GetInflictor()
if IsValid( Inflictor ) then
if Inflictor.DisableBallistics or Inflictor:IsNPC() or Inflictor:IsNextBot() then
DisableBounce = true
end
end
if DamageForce <= ArmorEffective and not IsBlastDamage then
local T = CurTime()
if trace.Entity ~= base then
self._NextBounce = T + 1
return false
end
local Ax = math.acos( DotHitNormal )
local HitAngle = 90 - (180 - math.deg( Ax ))
if HitAngle > 30 then
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetNormal( -dir )
util.Effect( "manhacksparks", effectdata, true, true )
self._NextBounce = T + 1
return false
end
local NewDir = dir - trace.HitNormal * math.cos( Ax ) * 2
if (self._NextBounce or 0) > T or DisableBounce then
local effectdata = EffectData()
effectdata:SetOrigin( trace.HitPos )
effectdata:SetNormal( NewDir:GetNormalized() * 0.25 )
util.Effect( "manhacksparks", effectdata, true, true )
return false
end
self._NextBounce = T + 1
local hit_decal = ents.Create( "lvs_armor_bounce" )
hit_decal:SetPos( trace.HitPos )
hit_decal:SetAngles( NewDir:Angle() )
hit_decal:Spawn()
hit_decal:Activate()
hit_decal:EmitSound("lvs/armor_rico"..math.random(1,6)..".wav", 95, 100, math.min( dmginfo:GetDamage() / 1000, 1 ) )
local PhysObj = hit_decal:GetPhysicsObject()
if not IsValid( PhysObj ) then return false end
PhysObj:EnableDrag( false )
PhysObj:SetVelocityInstantaneous( NewDir * 2000 + Vector(0,0,250) )
PhysObj:SetAngleVelocityInstantaneous( VectorRand() * 250 )
return false
end
local NewHealth = math.Clamp( CurHealth - Damage, 0, self:GetMaxHP() )
self:OnHealthChanged( dmginfo, CurHealth, NewHealth )
self:SetHP( NewHealth )
if NewHealth <= 0 and not self:GetDestroyed() then
self:SetDestroyed( true )
self:OnDestroyed( dmginfo )
end
local hit_decal = ents.Create( "lvs_armor_penetrate" )
hit_decal:SetPos( parentPos + parentDir * 0.2 )
hit_decal:SetAngles( parentDir:Angle() + Angle(90,0,0) )
hit_decal:Spawn()
hit_decal:Activate()
hit_decal:SetParent( parent )
return true
end
return
end
function ENT:Initialize()
end
function ENT:OnRemove()
end
function ENT:Think()
end
function ENT:Draw()
end
local function DrawText( pos, text, col )
cam.Start2D()
local data2D = pos:ToScreen()
if not data2D.visible then cam.End2D() return end
local font = "TargetIDSmall"
local x = data2D.x
local y = data2D.y
draw.DrawText( text, font, x + 1, y + 1, Color( 0, 0, 0, 120 ), TEXT_ALIGN_CENTER )
draw.DrawText( text, font, x + 2, y + 2, Color( 0, 0, 0, 50 ), TEXT_ALIGN_CENTER )
draw.DrawText( text, font, x, y, col or color_white, TEXT_ALIGN_CENTER )
cam.End2D()
end
local LVS = LVS
local BoxMat = Material("models/wireframe")
local ColorSelect = Color(0,127,255,150)
local ColorNormal = Color(50,50,50,150)
local ColorTransBlack = Color(0,0,0,150)
local OutlineThickness = Vector(0.5,0.5,0.5)
local ColorText = Color(255,0,0,255)
function ENT:DrawTranslucent()
if not LVS.DeveloperEnabled then return end
local ply = LocalPlayer()
if not IsValid( ply ) or ply:InVehicle() or not ply:KeyDown( IN_SPEED ) then return end
local boxOrigin = self:GetPos()
local boxAngles = self:GetAngles()
local boxMins = self:GetMins()
local boxMaxs = self:GetMaxs()
local HitPos, _, _ = util.IntersectRayWithOBB( ply:GetShootPos(), ply:GetAimVector() * 1000, boxOrigin, boxAngles, boxMins, boxMaxs )
local InRange = isvector( HitPos )
local Col = InRange and ColorSelect or ColorNormal
render.SetColorMaterial()
render.DrawBox( boxOrigin, boxAngles, boxMins, boxMaxs, Col )
render.DrawBox( boxOrigin, boxAngles, boxMaxs + OutlineThickness, boxMins - OutlineThickness, ColorTransBlack )
local boxCenter = (self:LocalToWorld( boxMins ) + self:LocalToWorld( boxMaxs )) * 0.5
if not InRange then return end
DrawText( boxCenter, "Armor: "..(self:GetIgnoreForce() / 100).."mm\nHealth:"..self:GetHP().."/"..self:GetMaxHP(), ColorText )
end

View File

@@ -0,0 +1,124 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.PrintName = "88mm Round"
ENT.Author = "Luna"
ENT.Information = "Luna's Vehicle Script"
ENT.Category = "[LVS] - Cars - Items"
ENT.Spawnable = false
ENT.AdminOnly = false
ENT.LifeTime = 10
if SERVER then
function ENT:Initialize()
self:SetModel( "models/misc/88mm_projectile.mdl" )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:PhysicsInit( SOLID_VPHYSICS)
self.DieTime = CurTime() + self.LifeTime
self:SetCollisionGroup( COLLISION_GROUP_WORLD )
end
function ENT:Think()
if self.MarkForRemove then self:Remove() return false end
self:NextThink( CurTime() + 0.1 )
if (self.DieTime or 0) > CurTime() then return true end
self:Remove()
return false
end
function ENT:PhysicsCollide( data, physobj )
self.MarkForRemove = true
local effectdata = EffectData()
effectdata:SetOrigin( data.HitPos )
effectdata:SetNormal( -data.HitNormal )
effectdata:SetMagnitude( 0.5 )
util.Effect( "lvs_bullet_impact", effectdata )
end
return
end
ENT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
function ENT:Initialize()
self.DieTime = CurTime() + self.LifeTime
self.emitter = ParticleEmitter( self:GetPos(), false )
end
function ENT:Smoke()
local T = CurTime()
if (self.DieTime or 0) < T then return end
if not IsValid( self.emitter ) then return end
if (self.NextFX or 0) < T then
self.NextFX = T + 0.02
local Timed = 1 - (self.DieTime - T) / self.LifeTime
local Scale = math.max(math.min(2 - Timed * 2,1),0)
local Pos = self:GetPos()
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], Pos )
local VecCol = (render.GetLightColor( Pos ) * 0.8 + Vector(0.2,0.2,0.2)) * 255
if particle then
particle:SetVelocity( VectorRand() * 10 )
particle:SetDieTime( math.Rand(0.5,1) )
particle:SetAirResistance( 100 )
particle:SetStartAlpha( 100 * Scale )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 10 )
particle:SetEndSize( 20 )
particle:SetRollDelta( 1 )
particle:SetColor( VecCol.r, VecCol.g, VecCol.b )
particle:SetGravity( Vector( 0, 0, 200 ) )
particle:SetCollide( false )
end
end
end
function ENT:Think()
self:Smoke()
end
function ENT:OnRemove()
if not self.emitter then return end
self.emitter:Finish()
end
function ENT:Draw()
self:DrawModel()
end

View File

@@ -0,0 +1,149 @@
AddCSLuaFile()
ENT.Type = "anim"
ENT.RenderGroup = RENDERGROUP_BOTH
ENT.LifeTime = 15
if SERVER then
local CountTotal = {}
function ENT:Initialize()
CountTotal[ self:EntIndex() ] = true
local Num = table.Count( CountTotal )
if (Num > 30 and math.random(1,2) == 1) or Num > 60 then
self:Remove()
return
end
self:SetMoveType( MOVETYPE_NONE )
self:SetSolid( SOLID_NONE )
self:DrawShadow( false )
self.DieTime = CurTime() + self.LifeTime
end
function ENT:OnRemove()
CountTotal[ self:EntIndex() ] = nil
end
function ENT:Think()
self:NextThink( CurTime() + 0.1 )
if not IsValid( self:GetParent() ) then self:Remove() return end
if (self.DieTime or 0) > CurTime() then return true end
self:Remove()
return false
end
return
end
ENT.GlowMat1 = Material( "particle/particle_ring_wave_8" )
ENT.GlowMat2 = Material( "sprites/light_glow02_add" )
ENT.DecalMat = Material( "particle/particle_noisesphere" )
ENT.MatSmoke = {
"particle/smokesprites_0001",
"particle/smokesprites_0002",
"particle/smokesprites_0003",
"particle/smokesprites_0004",
"particle/smokesprites_0005",
"particle/smokesprites_0006",
"particle/smokesprites_0007",
"particle/smokesprites_0008",
"particle/smokesprites_0009",
"particle/smokesprites_0010",
"particle/smokesprites_0011",
"particle/smokesprites_0012",
"particle/smokesprites_0013",
"particle/smokesprites_0014",
"particle/smokesprites_0015",
"particle/smokesprites_0016"
}
local CountTotal = {}
function ENT:Initialize()
CountTotal[ self:EntIndex() ] = true
self.RandomAng = math.random(0,360)
self.DieTime = CurTime() + self.LifeTime
local Pos = self:GetPos()
local Dir = self:GetUp()
self.emitter = ParticleEmitter( Pos, false )
self:EmitSound( "lvs/armor_pen_"..math.random(1,3)..".wav", 95 )
end
function ENT:Smoke()
local T = CurTime()
if (self.DieTime or 0) < T then return end
if not IsValid( self.emitter ) then return end
if (self.NextFX or 0) < T then
self.NextFX = T + 0.2 + table.Count( CountTotal ) / 50
local particle = self.emitter:Add( self.MatSmoke[math.random(1,#self.MatSmoke)], self:GetPos() )
if particle then
particle:SetVelocity( self:GetUp() * 60 + VectorRand() * 30 )
particle:SetDieTime( math.Rand(1.5,2) )
particle:SetAirResistance( 100 )
particle:SetStartAlpha( 30 )
particle:SetEndAlpha( 0 )
particle:SetStartSize( 0 )
particle:SetEndSize( 60 )
particle:SetRollDelta( math.Rand( -1, 1 ) )
particle:SetColor( 50,50,50 )
particle:SetGravity( Vector( 0, 0, 200 ) )
particle:SetCollide( false )
end
end
end
function ENT:Think()
self:Smoke()
end
function ENT:OnRemove()
CountTotal[ self:EntIndex() ] = nil
if not IsValid(self.emitter) then return end
self.emitter:Finish()
end
function ENT:Draw()
local Timed = 1 - (self.DieTime - CurTime()) / self.LifeTime
local Scale = math.max(math.min(2 - Timed * 2,1),0)
local Scale02 = math.max(Scale - 0.8,0) / 0.2
cam.Start3D2D( self:GetPos() + self:GetAngles():Up(), self:GetAngles(), 1 )
surface.SetDrawColor( 255 * Scale02, (93 + 50 * Scale) * Scale02, (50 * Scale) * Scale02, (200 * Scale) * Scale02 )
surface.SetMaterial( self.GlowMat1 )
surface.DrawTexturedRectRotated( 0, 0, 8 , 8 , self.RandomAng )
surface.SetMaterial( self.GlowMat2 )
surface.DrawTexturedRectRotated( 0, 0, 16 , 16 , self.RandomAng )
surface.SetDrawColor( 0, 0, 0, 255 )
surface.SetMaterial( self.DecalMat )
surface.DrawTexturedRectRotated( 0, 0, 16 , 16 , self.RandomAng )
cam.End3D2D()
end
function ENT:DrawTranslucent()
self:Draw()
end

View File

@@ -0,0 +1,30 @@
function ENT:CreateBonePoseParameter( name, bone, ang_min, ang_max, pos_min, pos_max )
if not istable( self._BonePoseParameters ) then self._BonePoseParameters = {} end
self._BonePoseParameters[ name ] = {
bone = (bone or -1),
ang_min = ang_min or angle_zero,
ang_max = ang_max or angle_zero,
pos_min = pos_min or vector_origin,
pos_max = pos_max or vector_origin,
}
end
function ENT:SetBonePoseParameter( name, value )
if name and string.StartsWith( name, "!" ) then
name = string.Replace( name, "!", "" )
end
local EntTable = self:GetTable()
if not istable( EntTable._BonePoseParameters ) or not EntTable._BonePoseParameters[ name ] then return end
local data = EntTable._BonePoseParameters[ name ]
local ang = LerpAngle( value, data.ang_min, data.ang_max )
local pos = LerpVector( value, data.pos_min, data.pos_max )
self:ManipulateBoneAngles( data.bone, ang )
self:ManipulateBonePosition( data.bone, pos )
end

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