diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-04-16 12:22:52 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-04-16 12:22:52 -0400 |
| commit | 95bf646ef4610252f0899948d5999bc4988732b3 (patch) | |
| tree | 3ea1a0fe4f2c618f85cf2dc8818295273b399c35 /gamemode/server | |
| parent | b24ba036889a644bb9505f61e3feeda370299c98 (diff) | |
| download | gmstranded-95bf646ef4610252f0899948d5999bc4988732b3.tar.gz gmstranded-95bf646ef4610252f0899948d5999bc4988732b3.tar.bz2 gmstranded-95bf646ef4610252f0899948d5999bc4988732b3.zip | |
Moved ReproduceTrees() back into init.lua
Diffstat (limited to 'gamemode/server')
| -rw-r--r-- | gamemode/server/entity_functions.lua | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/gamemode/server/entity_functions.lua b/gamemode/server/entity_functions.lua index 89fced9..3f9d6a4 100644 --- a/gamemode/server/entity_functions.lua +++ b/gamemode/server/entity_functions.lua @@ -51,111 +51,6 @@ function EntityMeta:DropToGround() self:SetPos( tr.HitPos ) end -function GM.ReproduceTrees() - local GM = GAMEMODE - if ( GetConVarNumber( "gms_ReproduceTrees" ) == 1 ) then - local trees = {} - for k, v in pairs( ents.GetAll() ) do - if ( v:IsTreeModel() ) then - table.insert( trees, v ) - end - end - - if ( #trees < GetConVarNumber( "gms_MaxReproducedTrees" ) ) then - for k, ent in pairs( trees ) do - local num = math.random( 1, 3 ) - - if ( num == 1 ) then - local nearby = {} - for k, v in pairs( ents.FindInSphere( ent:GetPos(), 50 ) ) do - if ( v:GetClass() == "gms_seed" or v:IsProp() ) then - table.insert( nearby, v ) - end - end - - if ( #nearby < 3 ) then - local pos = ent:GetPos() + Vector( math.random( -500, 500 ), math.random( -500, 500 ), 0 ) - local retries = 50 - - while ( ( pos:Distance( ent:GetPos() ) < 200 or GMS.ClassIsNearby( pos, "prop_physics", 100 ) ) and retries > 0 ) do - pos = ent:GetPos() + Vector( math.random( -300, 300 ),math.random( -300, 300 ), 0 ) - retries = retries - 1 - end - - local pos = pos + Vector( 0, 0, 500 ) - - local seed = ents.Create( "gms_seed" ) - seed:SetPos( pos ) - seed:DropToGround() - seed:Setup( "tree", 180 ) - seed:SetNetworkedString( "Owner", "World" ) - seed:Spawn() - end - end - end - end - if ( #trees == 0 ) then - local info = {} - for i = 1, 20 do - info.pos = Vector( math.random( -10000, 10000 ), math.random( -10000, 10000 ), 1000 ) - info.Retries = 50 - - --Find pos in world - while ( util.IsInWorld( info.pos ) == false and info.Retries > 0 ) do - info.pos = Vector( math.random( -10000, 10000 ),math.random( -10000, 10000 ), 1000 ) - info.Retries = info.Retries - 1 - end - - --Find ground - local trace = {} - trace.start = info.pos - trace.endpos = trace.start + Vector( 0, 0, -100000 ) - trace.mask = MASK_SOLID_BRUSHONLY - - local groundtrace = util.TraceLine( trace ) - - --Assure space - local nearby = ents.FindInSphere( groundtrace.HitPos, 200 ) - info.HasSpace = true - - for k, v in pairs( nearby ) do - if ( v:IsProp() ) then - info.HasSpace = false - end - end - - --Find sky - local trace = {} - trace.start = groundtrace.HitPos - trace.endpos = trace.start + Vector( 0, 0, 100000 ) - - local skytrace = util.TraceLine( trace ) - - --Find water? - local trace = {} - trace.start = groundtrace.HitPos - trace.endpos = trace.start + Vector( 0, 0, 1 ) - trace.mask = MASK_WATER - - local watertrace = util.TraceLine( trace ) - - --All a go, make entity - if ( info.HasSpace and skytrace.HitSky and !watertrace.Hit and ( groundtrace.MatType == MAT_DIRT or groundtrace.MatType == MAT_GRASS or groundtrace.MatType == MAT_SAND ) ) then - local seed = ents.Create( "gms_seed" ) - seed:SetPos( groundtrace.HitPos ) - seed:DropToGround() - seed:Setup( "tree", 180 + math.random( -20, 20 ) ) - seed:SetNetworkedString( "Owner", "World" ) - seed:Spawn() - end - end - end - end - - timer.Simple( math.random( 1, 3 ) * 60, function() GM.ReproduceTrees() end ) -end -timer.Simple( 60, function() GAMEMODE.ReproduceTrees() end ) - GMS.LootableNPCs = { "npc_antlion", "npc_antlionguard", "npc_crow", "npc_seagull", "npc_pigeon", "npc_zombie" } function EntityMeta:IsLootableNPC() |
