diff options
| author | Apickx <Apickx@cogarr.org> | 2015-12-28 19:10:44 -0500 |
|---|---|---|
| committer | Apickx <Apickx@cogarr.org> | 2015-12-28 19:10:44 -0500 |
| commit | 5c4ebc932d8c02522802c842d43d863d89aca162 (patch) | |
| tree | 6be7ad664bdf060127e6df6baa72beaf508aa149 /gamemode/server/world.lua | |
| download | wintersurvival2-5c4ebc932d8c02522802c842d43d863d89aca162.tar.gz wintersurvival2-5c4ebc932d8c02522802c842d43d863d89aca162.tar.bz2 wintersurvival2-5c4ebc932d8c02522802c842d43d863d89aca162.zip | |
Initial commit
Diffstat (limited to 'gamemode/server/world.lua')
| -rw-r--r-- | gamemode/server/world.lua | 60 |
1 files changed, 60 insertions, 0 deletions
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
|
