summaryrefslogtreecommitdiff
path: root/entities/effects/player_gib/init.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-30 14:42:09 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-30 14:42:09 -0400
commit2736f498f30220b858fc6fac23e7ddc4a597df6d (patch)
tree374ceadedb654b00e09dac321620a8320830f734 /entities/effects/player_gib/init.lua
downloadredead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.gz
redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.tar.bz2
redead-2736f498f30220b858fc6fac23e7ddc4a597df6d.zip
Inital commit
Diffstat (limited to 'entities/effects/player_gib/init.lua')
-rw-r--r--entities/effects/player_gib/init.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/entities/effects/player_gib/init.lua b/entities/effects/player_gib/init.lua
new file mode 100644
index 0000000..2afcae0
--- /dev/null
+++ b/entities/effects/player_gib/init.lua
@@ -0,0 +1,58 @@
+
+function EFFECT:Init( data )
+
+ local scale = data:GetScale()
+
+ if scale < 2 then
+ self.Entity:SetModel( table.Random( GAMEMODE.SmallGibs ) )
+ else
+ self.Entity:SetModel( table.Random( GAMEMODE.BigGibs ) )
+ end
+
+ self.Entity:PhysicsInit( SOLID_VPHYSICS )
+ self.Entity:SetMaterial( "models/flesh" )
+
+ self.Entity:SetCollisionGroup( COLLISION_GROUP_DEBRIS )
+ self.Entity:SetCollisionBounds( Vector( -128 -128, -128 ), Vector( 128, 128, 128 ) )
+ self.Entity:SetAngles( Angle( math.Rand(0,360), math.Rand(0,360), math.Rand(0,360) ) )
+
+ local phys = self.Entity:GetPhysicsObject()
+
+ if IsValid( phys ) then
+
+ local vec = VectorRand()
+ vec.z = math.Clamp( vec.z, -0.4, 0.8 )
+
+ phys:Wake()
+ phys:SetMass( 100 )
+ phys:AddAngleVelocity( VectorRand() * 500 )
+ phys:SetMaterial( "gmod_silent" )
+
+ if scale < 2 then
+
+ phys:SetVelocity( vec * math.Rand( 100, 200 ) )
+
+ else
+
+ phys:SetVelocity( vec * math.Rand( 300, 600 ) )
+
+ end
+
+ end
+
+ self.LifeTime = CurTime() + 15
+
+end
+
+function EFFECT:Think( )
+
+ return self.LifeTime > CurTime()
+
+end
+
+function EFFECT:Render()
+
+ self.Entity:DrawModel()
+
+end
+