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
function Monster:damage(id, dmg, wpntype)
	if not PLAYERS[id].Tutorial.damagem then
		message(id, "You have attacked a monster! Good job! Keep on attacking it until it dies.", "255128000")
		PLAYERS[id].Tutorial.damagem = true
	end
	local wpnName
	if wpntype == 251 then
		wpnName = 'rune'
	elseif wpntype == 46 then
		wpnName = 'firewave'
		dmg = dmg/5
	else
		wpnName = PLAYERS[id].Equipment[3] and ITEMS[PLAYERS[id].Equipment[3]].name or 'dagger'
	end
	self.health = self.health - dmg
	hudtxt2(id,41, 'Dealt '..dmg..' damage, '..self.health..' health left.', '255255255', 200,250,0)
	hudtxtalphafade(id,41,5000,0)
	print(player(id, 'name') .. ' deals ' .. dmg .. ' damage to ' .. self.name .. ' usng a ' .. wpnName .. '.')
	if self.health <= 0 then
		if not PLAYERS[id].Tutorial.killm then
			message(id, "Congratulation! You have killed your first monster. You can proceed to pick up the loot by using the drop weapon button (default G)", "255128000")
			PLAYERS[id].Tutorial.killm = true
		end
		addexp(id, math.floor(self.exp*CONFIG.EXPRATE))
		self:die()
	else
		parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 0 ' .. self.scaley .. ' ' .. (self.r and (self.r .. ' ' .. self.g .. ' ' .. self.b) or '192 0 0'))
	end
	radiussound("weapons/machete_hit.wav", self.x, self.y)
	return true
end