Forum

> > CS2D > Scripts > (Tibia)NPC Hp and name how?
Forums overviewCS2D overview Scripts overviewLog in to reply

English (Tibia)NPC Hp and name how?

2 replies
To the start Previous 1 Next To the start

old Little Help

Tudi20
User Off Offline

Quote
First notice where we want to edit. Default in the monsters.lua because in that file where all with the monsters.
Then searching something where yo can easily have some defaults.
If you found this:
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
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 weapon == 251 then
		wpnName = 'rune'
	elseif weapon == 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
	--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 .. ' 10 ' .. 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

So you maybe want the code here because when the player damage a monster this things happens.

Now you might have to bit cut it so:
1
2
3
self.health = self.health - dmg
	--print(player(id, 'name') .. ' deals ' .. dmg .. ' damage to ' .. self.name .. ' usng a ' .. wpnName .. '.')
	if self.health <= 0 then

So you see the "--print" ? So you maybe want to make something that like, but not with "print" and without "--".
You don't need that what player do the damage and with weapon.
So left only 2 values:
"dmg" and "self.name"
But we want the hp too and you can figure it out from the previous line it.
It's self.health.
self.health = self.health - dmg

So you want a code something like this to paste in:
1
2
msg2(id, 'Name: ' .. self.name)
msg2(id, ' HP: ' .. self.health)

So it in the chat write in first the monster name the second line their HP when the player damaged the mob.

So the cutted code:
1
2
3
4
5
self.health = self.health - dmg
	msg2(id, 'Name: ' .. self.name)
	msg2(id, ' HP: ' .. self.health)
	--print(player(id, 'name') .. ' deals ' .. dmg .. ' damage to ' .. self.name .. ' usng a ' .. wpnName .. '.')
	if self.health <= 0 then

And the hole section is:
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 weapon == 251 then
		wpnName = 'rune'
	elseif weapon == 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
	msg2(id, 'Name: ' .. self.name)
	msg2(id, ' HP: ' .. self.health)
	--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 .. ' 10 ' .. 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

From now you can color the text and more.
You can add what damage the player given to the monster:

msg2(id, 'Damage: ' .. dmg)


° Note: Sorry for the bad english.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview