aboutsummaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/items/runeexplosive.lua
blob: 6d5414396d4ca06a766af375602ec4611aa8b740 (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
local ITEM = {}
ITEM.Name 			= "Explosive Rune"
ITEM.Class 			= "resource"
ITEM.Desc 			= "A highly volitile rune! Handle with care."
ITEM.Model 			= "models/props_junk/Rock001a.mdl"
ITEM.Icon 			= Material("wintersurvival2/hud/ws2_icons/icon_runeexplosive.png")

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

ITEM.Recipe		= {
	Resources = {
		["Energy Rune"] = 1,
		["Fire Rune"] = 1,
	},
	Tools = {},
}



ITEM.Damage 	= 1
ITEM.Range 		= 64
ITEM.CD 		= 1

function ITEM:OnPrimary(user)
	if user:HasItem("Explosive Rune",1) then
		self:OnUse(user)
	else
		if not user.UnEquipWeaponSlot then return end
		user:UnEquipWeaponSlot(user:GetSelectedWeapon())
		self:OnUse(user)
	end
end

function ITEM:OnUse(user)
	if not user:IsOnGround() then
		user:SetVelocity(Vector(0,0,500))
		if SERVER then
			user:TakeDamage(30)
		end
	else
		if SERVER then
			user:TakeDamage(40)
		end
	end
	if CLIENT then return end
	user:RemoveItem(self.Name,1)
	local exp = ents.Create("env_explosion")
	exp:SetPos(user:GetPos())
	exp:Fire("Explode","",0)
	exp:Spawn()
end
RegisterItem(ITEM)