1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
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
end
--END... Newer versions of maps should use a brush entity instead.
end
|