mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 05:43:46 +03:00
97 lines
2.1 KiB
Lua
97 lines
2.1 KiB
Lua
--[[
|
|
| This file was obtained through the combined efforts
|
|
| of Madbluntz & Plymouth Antiquarian Society.
|
|
|
|
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
|
| Maloy, DrPepper10 @ RIP, Atle!
|
|
|
|
|
| Visit for more: https://plymouth.thetwilightzone.ru/
|
|
--]]
|
|
|
|
|
|
AddCSLuaFile()
|
|
DEFINE_BASECLASS( "base_gmodentity" )
|
|
|
|
ENT.PrintName = "Balloon"
|
|
ENT.Editable = true
|
|
|
|
function ENT:SetupDataTables()
|
|
|
|
self:NetworkVar( "Float", 0, "Force", { KeyName = "force", Edit = { type = "Float", order = 1, min = -2000, max = 2000, title = "#tool.balloon.force" } } )
|
|
|
|
if ( SERVER ) then
|
|
self:NetworkVarNotify( "Force", function() self:PhysWake() end )
|
|
end
|
|
|
|
end
|
|
|
|
function ENT:Initialize()
|
|
|
|
if ( CLIENT ) then return end
|
|
|
|
self:PhysicsInit( SOLID_VPHYSICS )
|
|
self:SetRenderMode( RENDERMODE_TRANSCOLOR )
|
|
|
|
-- Set up our physics object here
|
|
local phys = self:GetPhysicsObject()
|
|
if ( IsValid( phys ) ) then
|
|
phys:SetMass( 100 )
|
|
phys:Wake()
|
|
phys:EnableGravity( false )
|
|
end
|
|
|
|
self:SetForce( 1 )
|
|
self:StartMotionController()
|
|
|
|
end
|
|
|
|
function ENT:GetOverlayText()
|
|
|
|
local txt = "Force: " .. math.floor( self:GetForce() )
|
|
|
|
if ( txt == "" ) then return "" end
|
|
if ( game.SinglePlayer() ) then return txt end
|
|
|
|
return txt .. "\n(" .. self:GetPlayerName() .. ")"
|
|
|
|
end
|
|
|
|
function ENT:OnTakeDamage( dmginfo )
|
|
|
|
if ( self.Indestructible ) then return end
|
|
|
|
local c = self:GetColor()
|
|
|
|
local effectdata = EffectData()
|
|
effectdata:SetOrigin( self:GetPos() )
|
|
effectdata:SetStart( Vector( c.r, c.g, c.b ) )
|
|
util.Effect( "balloon_pop", effectdata )
|
|
|
|
if ( self.Explosive ) then
|
|
|
|
local ed_expl = EffectData()
|
|
ed_expl:SetOrigin( self:GetPos() )
|
|
ed_expl:SetScale( 1 )
|
|
ed_expl:SetMagnitude( 25 )
|
|
util.Effect( "Explosion", ed_expl, true, true )
|
|
|
|
end
|
|
|
|
local attacker = dmginfo:GetAttacker()
|
|
if ( IsValid( attacker ) && attacker:IsPlayer() ) then
|
|
attacker:SendLua( "achievements.BalloonPopped()" )
|
|
end
|
|
|
|
self:Remove()
|
|
|
|
end
|
|
|
|
function ENT:PhysicsSimulate( phys, deltatime )
|
|
|
|
local vLinear = Vector( 0, 0, self:GetForce() * 5000 ) * deltatime
|
|
local vAngular = vector_origin
|
|
|
|
return vAngular, vLinear, SIM_GLOBAL_FORCE
|
|
|
|
end
|