aboutsummaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/items/researchtable.lua
blob: 8c5c9e58cf0b0c2bd4d329cfe2e45eb276d914ea (plain)
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
48
49
50
51
52
53
54
55
ITEM.Name 		= "Research Table"
ITEM.Class 		= "structure"
ITEM.Desc 		= "A table that gives hints every 30 seconds to nearby players"
ITEM.Model 		= "models/props_junk/wood_crate001a.mdl"
ITEM.Icon 		=  Material("wintersurvival2/hud/ws2_icons/icon_recipe.png")
ITEM.Recipe		= {
	Resources = {
		["Wood"] = 10,
		["Sap"] = 5,
	},
	Tools = {},
}

ITEM.Structure = {
	{
		Bone = "ValveBiped.Bip01_R_Hand",
		Model = "models/props_junk/wood_crate001a.mdl",
		Size = Vector(0.5,0.5,0.5),
		Pos = Vector(4,-3,-1),
		Ang = Angle(0,0,0),
	},
}

ITEM.Ghost = {
	{
		Model = "models/props_junk/wood_crate001a.mdl",
		Size = Vector(1,1,1),
		Pos = Vector(0,0,0),
		Ang = Angle(0,0,0),
	},
}

ITEM.Range 		= 200
ITEM.CD 		= 0.5

function ITEM:OnPrimary(pl,tr)
	if (CLIENT) then return end

	if (!pl:CanPlaceStructure(tr)) then pl:GhostStructure(self.Name) return end

	if (tr.Hit) then
		local drop = ents.Create("ws_researchtable")
		drop:SetAngles(Angle(0,pl:GetAimVector():Angle().y+90,0))
		drop:SetPos(tr.HitPos)
		drop:Spawn()
		drop:Activate()

		if (pl:HasItem(self.Name)) then pl:RemoveItem(self.Name,1)
		else pl:UnEquipWeaponSlot(pl.Select,true) end

		pl:GhostRemove()
	else
		pl:EmitSound(Sound("weapons/iceaxe/iceaxe_swing1.wav"),100,math.random(90,110))
	end
end