aboutsummaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/items/bow.lua
blob: 4a7f2032641717ac677d45acc1e27c531e20c0ca (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
ITEM.Name 			= "Bow"
ITEM.Class 			= "weapon"
ITEM.Desc 			= "A primitive bow made from vine, sap, and wood."
ITEM.Model 			= "models/props_debris/wood_board02a.mdl"
ITEM.Icon 			= Material("wintersurvival2/hud/ws1_icons/icon_bow")
ITEM.HoldType		= "smg"

ITEM.Structure = {
	{
		Bone = "ValveBiped.Bip01_L_Hand",
		Model = "models/props_debris/wood_board02a.mdl",
		Size = Vector(.5,.5,.35),
		Pos = Vector(-1,-6,9),
		Ang = Angle(-30,-65,180),
	},
	{
		Bone = "ValveBiped.Bip01_L_Hand",
		Model = "models/props_debris/wood_board02a.mdl",
		Size = Vector(.5,.5,.35),
		Pos = Vector(-1,-6,-9),
		Ang = Angle(30,-65,180),
	},
	{
		Bone = "ValveBiped.Bip01_L_Hand",
		Model = "models/props_debris/wood_board02a.mdl",
		Size = Vector(.05,.05,.51),
		Pos = Vector(-3.3,-9.5,0),
		Ang = Angle(0,-65,180),
	},
}

ITEM.Recipe		= {
	Resources = {
		["Plank"] = 2,
		["Rope"] = 1,
		["Sap"] = 1,
	},
	Tools = {},
}

ITEM.CD = 1

local arrow = {}
arrow["model"] = "models/mixerman3d/other/arrow.mdl"
arrow["speed"] = 1300
arrow["drop"] = 50
arrow["init"] = function(fb) end
arrow["onhit"] = function (self,data,phys)
	--print("Arrow hit ")
	PrintTable(data.HitEntity)
	if(data.Entity and data.Entity.TakeDamage) then
		data.HitEntity:TakeDamage(25)
	end

	if(not data.HitNonWorld) then
		SpawnWSItem("Arrow",data.HitPos)
	end
	self:Remove()
end

function ITEM:OnPrimary(pl,tr)
	if (CLIENT) then return end
	if (!pl:HasItem("Arrow",1)) then return end

	local aim = pl:GetAimVector()

	local D = ents.Create("ws_projectile")
	if(arrow.speed) then D.speed = arrow.speed end
	if(arrow.model) then D.model = arrow.model end
	if(arrow.drop) then D.drop = arrow.drop end
	if(arrow.init) then D.init = arrow.init end
	if(arrow.onhit) then D.onhit = arrow.onhit end

	D:SetPos(pl:GetShootPos()+aim*50)
	D:SetOwner(pl)
	D:SetAngles(aim:Angle())
	D:Spawn()
	pl:EmitSound(Sound("physics/flesh/flesh_impact_hard.wav"),100,math.random(90,110))

	pl:RemoveItem("Arrow",1)
end