summaryrefslogtreecommitdiff
path: root/entities
diff options
context:
space:
mode:
Diffstat (limited to 'entities')
-rw-r--r--entities/entities/gms_food.lua4
-rw-r--r--entities/entities/gms_generic_plantable.lua122
2 files changed, 124 insertions, 2 deletions
diff --git a/entities/entities/gms_food.lua b/entities/entities/gms_food.lua
index 2ad1297..174a46c 100644
--- a/entities/entities/gms_food.lua
+++ b/entities/entities/gms_food.lua
@@ -56,7 +56,7 @@ function ENT:Draw()
self:DrawModel()
local food = self.Food or "Loading..."
- local tex = self.FoodIcons[ string.gsub( food, " ", "_" ) ] or texLogo
+ local tex = self.FoodIcons[food] or texLogo
cam.Start3D2D( self:GetPos() + Vector( 0, 0, 20 ), self.AddAngle, 0.01 )
surface.SetDrawColor( Color( 255, 255, 255, 255 ) )
@@ -93,7 +93,7 @@ function ENT:StartTouch( ent )
if ( ent:GetClass() == "gms_resourcedrop" ) then
big_gms_combineresourcepack( self, ent )
end
- if ( ent:GetClass() == "gms_buildsite" ) then
+ if ( ent:GetClass() == "gms_buildsite" ) then
gms_addbuildsiteresourcePack( self, ent )
end
end
diff --git a/entities/entities/gms_generic_plantable.lua b/entities/entities/gms_generic_plantable.lua
new file mode 100644
index 0000000..81f31b1
--- /dev/null
+++ b/entities/entities/gms_generic_plantable.lua
@@ -0,0 +1,122 @@
+--[[
+ Things you need to set when createing a generic plantable:
+ GrowTime (number),
+ Owner (player),
+ OnGrow (function),
+]]--
+AddCSLuaFile()
+
+ENT.Type = "anim"
+ENT.Base = "gms_base_entity"
+ENT.PrintName = "Seed"
+
+ENT.Model = "models/weapons/w_bugbait.mdl"
+ENT.Color = Color( 0, 255, 0, 255 )
+
+if ( CLIENT ) then return end
+
+function ENT:OnInitialize()
+ print("Initalizeing seed")
+ timer.Simple(self.GrowTime,function()
+ print("Grow's owner is:")
+ print(self:GetOwner())
+ self:OnGrow(self,self:GetOwner())
+ self:Remove()
+ end)
+end
+
+function ENT:Grow()
+ local ply = self:GetOwner()
+ local pos = self:GetPos()
+
+ local num = 1
+ if ( IsValid( ply ) && ply:HasUnlock( "Adept_Farmer" ) ) then num = num + math.random( 0, 1 ) end
+ if ( IsValid( ply ) && ply:HasUnlock( "Expert_Farmer" ) ) then num = num + math.random( 0, 2 ) end
+
+ if ( self.Type == "tree" ) then
+ GAMEMODE.MakeTree( pos )
+ elseif ( self.Type == "melon" ) then
+ GAMEMODE.MakeMelon( pos, num, ply )
+ elseif ( self.Type == "banana" ) then
+ GAMEMODE.MakeBanana( pos, num, ply )
+ elseif ( self.Type == "orange" ) then
+ GAMEMODE.MakeOrange( pos, num, ply )
+ elseif ( self.Type == "grain" ) then
+ GAMEMODE.MakeGrain( pos, ply )
+ elseif ( self.Type == "berry" ) then
+ GAMEMODE.MakeBush( pos, ply )
+ end
+
+ self.Grown = true
+ self:Fadeout()
+end
+
+function ENT:OnRemove()
+ if ( !self.Grown && self.Type != "tree" && IsValid( self:GetOwner() ) ) then
+ self:GetOwner():SetNWInt( "plants", self:GetOwner():GetNWInt( "plants" ) - 1 )
+ end
+ timer.Destroy( "GMS_SeedTimers_" .. self:EntIndex() )
+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
+
+function GAMEMODE.MakeTree( pos )
+ //GAMEMODE.MakeGenericPlant( ply, pos, GMS.TreeModels[ math.random( 1, #GMS.TreeModels ) ], true )
+ local ent = ents.Create( "gms_tree" )
+ ent:SetPos( pos )
+ ent:Spawn()
+ ent.GMSAutoSpawned = true
+ ent:SetNetworkedString( "Owner", "World" )
+end
+
+
+function GAMEMODE.MakeBush( pos, ply )
+ GAMEMODE.MakeGenericPlant( ply, pos + Vector( math.random( -10, 10 ), math.random( -10, 10 ), 16 ), "models/props/pi_shrub.mdl" )
+end
+
+function GAMEMODE.MakeMelon( pos, num, ply )
+ local plant = GAMEMODE.MakeGenericPlant( ply, pos + Vector( 0, 0, 13 ), "models/props/CS_militia/fern01.mdl" )
+ plant.Children = 0
+
+ for i = 1, num do
+ GAMEMODE.MakeGenericPlantChild( ply, pos + Vector( math.random( -25, 25 ), math.random( -25, 25 ), math.random( 5, 7 ) ), "models/props_junk/watermelon01.mdl", plant )
+ end
+end
+
+function GAMEMODE.MakeOrange( pos, num, ply )
+ local plant = GAMEMODE.MakeGenericPlant( ply, pos + Vector( 0, 0, -12 ), "models/props/cs_office/plant01_p1.mdl" )
+ plant.Children = 0
+
+ plant:SetCollisionGroup( 0 )
+ plant:SetSolid( SOLID_NONE )
+ plant.Children = 0
+
+ for i = 1, num do
+ GAMEMODE.MakeGenericPlantChild( ply, pos + Vector( math.random( -5, 5 ), math.random( -5, 5 ), math.random( 13, 30 ) ), "models/props/cs_italy/orange.mdl", plant )
+ end
+end