From 5c4ebc932d8c02522802c842d43d863d89aca162 Mon Sep 17 00:00:00 2001 From: Apickx Date: Mon, 28 Dec 2015 19:10:44 -0500 Subject: Initial commit --- gamemode/server/world.lua | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 gamemode/server/world.lua (limited to 'gamemode/server/world.lua') diff --git a/gamemode/server/world.lua b/gamemode/server/world.lua new file mode 100644 index 0000000..9d23c7b --- /dev/null +++ b/gamemode/server/world.lua @@ -0,0 +1,60 @@ + +local random = math.random +local traceline = util.TraceLine +local contents = util.PointContents +local Up = Vector(0,0,1) + +function GM:GeneratePropRain() + local Items = { + GetItemByName("Wood"), + GetItemByName("Rock"), + GetItemByName("Crystal"), + } + + --THIS PIECE OF CODE IS FOR OLDER VERSIONS OF WS MAPS! ITS CRAP BUT WE HAVE TO... For WS players! + local areas = {} + + for i,area in pairs(ents.FindByClass("info_target")) do + if (area:GetName() == "survival_spawn") then + local parent = area:GetParent() + if (IsValid(parent)) then + areas[area] = parent + end + end + end + + for pAe,pBe in pairs(areas) do + local pA,pB = pAe:GetPos(),pBe:GetPos() + local Dis = pA:Distance(pB) + + for i = 1,40+math.ceil(Dis/70) do + local V = Vector(random(pB.x,pA.x),random(pB.y,pA.y),random(pB.z,pA.z)) + local Tr = traceline({start=V,endpos=V-Up*40000}) + local Pos = Tr.HitPos+Up*20 + local C = contents(Pos) + + if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then + local drop = ents.Create("ws_item") + drop.Item = Items[random(1,3)] + drop:SetModel(drop.Item.Model) + drop:SetPos(Pos) + drop:Spawn() + drop:GetPhysicsObject():Sleep() + end + end + + --Shop spawn + local V = Vector(random(pB.x,pA.x),random(pB.y,pA.y),random(pB.z,pA.z)) + local Tr = traceline({start=V,endpos=V-Up*40000}) + local Pos = Tr.HitPos+Up*20 + local C = contents(Pos) + + if (C != CONTENTS_WATER and C != CONTENTS_WATER+CONTENTS_TRANSLUCENT) then + local drop = ents.Create("ws_shop") + drop:SetPos(Pos) + drop:Spawn() + drop:Activate() + end + end + --END... Newer versions of maps should use a brush entity instead. +end -- cgit v1.2.3-70-g09d2