summaryrefslogtreecommitdiff
path: root/gamemode/items/supplies.lua
blob: bc74a861ed6c9851716ca525eb20b206d5a827ff (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// This is the ID given to any item that is an essential supply for every faction
ITEM_SUPPLY = 2

function FUNC_ENERGY( ply, id, client, icon )

	if icon then return "icon16/cup.png" end
	if client then return "Drink" end

	ply:RemoveFromInventory( id )
	ply:EmitSound( table.Random{ "npc/barnacle/barnacle_gulp1.wav", "npc/barnacle/barnacle_gulp2.wav" }, 100, math.random( 90, 110 ) )
	ply:AddStamina( 50 )
	ply:Notice( "+50 Stamina", GAMEMODE.Colors.Green )

end

function FUNC_HEAL( ply, id, client, icon )

	if icon then return "icon16/heart.png" end
	if client then return "Use" end

	ply:RemoveFromInventory( id )
	ply:EmitSound( "HealthVial.Touch" )
	ply:AddHealth( 75 )
	ply:Notice( "+75 Health", GAMEMODE.Colors.Green )

end

function FUNC_SUPERHEAL( ply, id, client, icon )

	if icon then return "icon16/heart.png" end
	if client then return "Use" end

	ply:RemoveFromInventory( id )
	ply:EmitSound( "HealthVial.Touch" )
	ply:AddHealth( 150 )
	ply:Notice( "+150 Health", GAMEMODE.Colors.Green )

end

function FUNC_BANDAGE( ply, id, client, icon )

	if icon then return "icon16/heart.png" end
	if client then return "Use" end

	ply:RemoveFromInventory( id )
	ply:EmitSound( "Cardboard.Strain" )
	ply:SetBleeding( false )
	ply:AddHealth( 20 )
	ply:Notice( "+20 Health", GAMEMODE.Colors.Green )
	ply:Notice( "Stopped bleeding", GAMEMODE.Colors.Green )

end

function FUNC_MUTAGEN( ply, id, client, icon )

	if icon then return "icon16/pill.png" end
	if client then return "Inject" end

	ply:RemoveFromInventory( id )
	ply:EmitSound( "Weapon_SMG1.Special1" )

	if ply:IsInfected() then

		ply:Notice( "Your infection has been cured", GAMEMODE.Colors.Green, 5, 0 )
		ply:SetInfected( false )

	end

	local tbl = {}
	local inc = 0

	for i=1,math.random(1,3) do

		local rand = math.random(1,5)

		while table.HasValue( tbl, rand ) do

			rand = math.random(1,5)

		end

		table.insert( tbl, rand )

		if rand == 1 then

			ply:Notice( "You feel extremely nauseous", GAMEMODE.Colors.Red, 5, inc * 2 )

			umsg.Start( "Drunk", ply )
			umsg.Short( math.random( 10, 20 ) )
			umsg.End()

		elseif rand == 2 then

			local rad = math.random(2,5)

			if math.random(1,2) == 1 and ply:GetRadiation() < 1 then

				ply:Notice( "+" .. rad .. " Radiation", GAMEMODE.Colors.Red, 5, inc * 2 )
				ply:AddRadiation( rad )

			else

				ply:Notice( "-" .. rad .. " Radiation", GAMEMODE.Colors.Green, 5, inc * 2 )
				ply:AddRadiation( -rad )

			end

		elseif rand == 3 then

			ply:Notice( "Your whole body aches", GAMEMODE.Colors.Red, 5, inc * 2 )

			local dmg = math.random(2,5)

			ply:AddHealth( dmg * -10 )

		elseif rand == 4 then

			if math.random(1,2) == 1 then

				ply:Notice( "You feel exhausted", GAMEMODE.Colors.Red, 5, inc * 2 )
				ply:AddStamina( -50 )

			else

				ply:Notice( "+20 Stamina", GAMEMODE.Colors.Green, 5, inc * 2 )
				ply:AddStamina( 20 )

			end

		elseif rand == 5 then

			ply:Notice( "Your legs begin to feel weak", GAMEMODE.Colors.Red, 5, inc * 2 )
			ply:SetWalkSpeed( GAMEMODE.WalkSpeed - 80 )
			ply:SetRunSpeed( GAMEMODE.RunSpeed - 80 )

			local legtime = math.random( 20, 40 )

			timer.Simple( legtime - 5, function() if IsValid( ply ) and ply:Team() == TEAM_ARMY then ply:Notice( "Your legs start to feel better", GAMEMODE.Colors.Green, 5 ) end end )
			timer.Simple( legtime, function() if IsValid( ply ) and ply:Team() == TEAM_ARMY then ply:SetWalkSpeed( GAMEMODE.WalkSpeed ) ply:SetRunSpeed( GAMEMODE.RunSpeed ) end end )

		end

		inc = inc + 1

	end

end

item.Register( {
	Name = "Energy Drink",
	Description = "Restores 50 stamina.",
	Stackable = true,
	Type = ITEM_SUPPLY,
	Weight = 0.25,
	Price = 5,
	Rarity = 0.25,
	Model = "models/props_junk/popcan01a.mdl",
	Functions = { FUNC_ENERGY },
	CamPos = Vector(10,10,0),
	CamOrigin = Vector(0,0,0)
} )

item.Register( {
	Name = "Basic Medikit",
	Description = "Restores 50% of your health.",
	Stackable = true,
	Type = ITEM_SUPPLY,
	Weight = 1.25,
	Price = 10,
	Rarity = 0.65,
	Model = "models/radbox/healthpack.mdl",
	Functions = { FUNC_HEAL },
	CamPos = Vector(23,8,3),
	CamOrigin = Vector(0,0,-1)
} )

item.Register( {
	Name = "Advanced Medikit",
	Description = "Restores 100% of your health.",
	Stackable = true,
	Type = ITEM_SUPPLY,
	Weight = 1.25,
	Price = 20,
	Rarity = 0.85,
	Model = "models/radbox/healthpack2.mdl",
	Functions = { FUNC_SUPERHEAL },
	CamPos = Vector(23,8,3),
	CamOrigin = Vector(0,0,-1)
} )

item.Register( {
	Name = "Alpha Mutagen",
	Description = "Prototype drug which cures the infection.",
	Stackable = true,
	Type = ITEM_SUPPLY,
	Weight = 1.25,
	Price = 50,
	Rarity = 0.95,
	Model = "models/items/healthkit.mdl",
	Functions = { FUNC_MUTAGEN },
	CamPos = Vector(0,0,35),
	CamOrigin = Vector(4,0,0)
} )

item.Register( {
	Name = "Bandage",
	Description = "Stops all bleeding.",
	Stackable = true,
	Type = ITEM_SUPPLY,
	Weight = 0.35,
	Price = 5,
	Rarity = 0.50,
	Model = "models/radbox/bandage.mdl",
	Functions = { FUNC_BANDAGE },
	CamPos = Vector(18,10,5),
	CamOrigin = Vector(0,0,0)
} )