summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/common_plantable.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-06 20:20:56 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-06 20:20:56 -0400
commit5322c9c6534054c0e2da6441e477d0b2166fbe97 (patch)
treec10bba96ddcbb82b000f5cc569cdfff5e5522d08 /gamemode/itemsystem/common_plantable.lua
parent76e9c919b926f35f51e147e042eadc992f06018e (diff)
downloadgmstranded-5322c9c6534054c0e2da6441e477d0b2166fbe97.tar.gz
gmstranded-5322c9c6534054c0e2da6441e477d0b2166fbe97.tar.bz2
gmstranded-5322c9c6534054c0e2da6441e477d0b2166fbe97.zip
Did some refactoring
Diffstat (limited to 'gamemode/itemsystem/common_plantable.lua')
-rw-r--r--gamemode/itemsystem/common_plantable.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/gamemode/itemsystem/common_plantable.lua b/gamemode/itemsystem/common_plantable.lua
index 5e3ad55..2728b9a 100644
--- a/gamemode/itemsystem/common_plantable.lua
+++ b/gamemode/itemsystem/common_plantable.lua
@@ -82,3 +82,30 @@ function GAMEMODE.MakeGenericPlantChild( ply, pos, mdl, parent )
return ent
end
+
+function GAMEMODE.MakeGenericPlant( ply, pos, mdl, isTree )
+ local ent = ents.Create( "prop_dynamic" )
+ ent:SetAngles( Angle( 0, math.random( 0, 360 ), 0 ) )
+ ent:SetSolid( SOLID_VPHYSICS )
+ ent:SetModel( mdl )
+ ent:SetPos( pos )
+ ent:Spawn()
+ ent.IsPlant = true
+ ent:SetName( "gms_plant" .. ent:EntIndex() )
+
+ ent:Fadein()
+ ent:RiseFromGround( 1, 50 )
+
+ if ( !isTree && IsValid( ply ) ) then
+ ent:SetNWEntity( "plantowner", ply )
+ SPropProtection.PlayerMakePropOwner( ply, ent )
+ else
+ ent:SetNWString( "Owner", "World" )
+ end
+
+ local phys = ent:GetPhysicsObject()
+ if ( IsValid( phys ) ) then phys:EnableMotion( false ) end
+ ent.PhysgunDisabled = true
+
+ return ent
+end