• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[Npc] Guard

Kardaum

Member
Joined
Sep 4, 2007
Messages
35
Reaction score
13
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local fire = createConditionObject(CONDITION_FIRE)
[COLOR="Red"]addDamageCondition(fire, 4, 6000, -20)
addDamageCondition(fire, 4, 6000, -10)[/COLOR]

function onCreatureAppear(cid)		npcHandler:onCreatureAppear(cid)		end
function onCreatureDisappear(cid)	npcHandler:onCreatureDisappear(cid)		end
function onCreatureSay(cid, type, msg)	npcHandler:onCreatureSay(cid, type, msg)	end

function onThink()
	npcHandler:onThink()
	talk = math.random(1,40)
	if talk == 1 then
		selfSay("Long life to the king!")
	end
end

function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return FALSE
	end
	if msgcontains(msg, 'job') then
		selfSay("My duty is to protect this town from wild monsters.")
	elseif msgcontains(msg, 'king') then
		selfSay("I would protect the king with my own like if necessary!")
	elseif msgcontains(msg, 'ass') or msgcontains(msg, 'craw') or msgcontains(msg, 'fuck') then
		selfSay("Take this!")
		doCreatureSay(cid, "Ouch!", TALKTYPE_ORANGE_1)
		doTargetCombatCondition(0, cid, fire, CONST_ME_NONE)
	elseif msgcontains(msg, 'heal') and getCreatureHealth(cid) < 65 then
		selfSay("You're hurt, let me heal you.")
		heal = 65 - getCreatureHealth(cid)
		doCreatureAddHealth(cid, heal)
		doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
	elseif msgcontains(msg, 'heal') and getCreatureHealth(cid) >= 65 then
		selfSay("You don't need to be healed.")
	end
		
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

This is for fun guard npc. He has the hability to set any player on fire if he say bad words, and also to heal him to a maximum of 65 hitpoints. :D

Fire configuration:
addDamageCondition(fire, 4, 6000, -10)

Orange-> How many times you are hit.
Green-> The hit's delay.
Yellow-> The hit's damage.
 
Last edited:
Very nice job dude!
I use at my ots!
Thanks!

This NPC kill monster in city etc. ?

EDIT:
@DOWN:

Ok thanks
 
Last edited:
He dont kill monsters, he is only a "fake guard" npc, like the real tibia ones :p
 
U know this npc might crash the server??? because if it kills youthe server will get confused because it isen't an player you should make it it stops the fire or it wont shoot if you have 10hp or less


anywais Good job!
 
I don't know how to force the fire to stop so you don't get killed. Could you tell me how? :p
 
@original poster

if what moker says is true you can't fix it w/o going to source code and looking for the function itself and adding a condition proofer =D like if getPlayerHealth > 20 etc.
 
I don't know how to force the fire to stop so you don't get killed. Could you tell me how? :p

You can make an hp check if the guard attacks you, you will lose 40 Hp right? well make an hp check =)

if getPlayerHealth <=40 then
BLABLABLA =)

else
selfSay{`Go away on dont want your blood on my hands, i need to protect the city!`'|


Or somting like it :p
 
I've tested and there's no problem if someone gets killed. The fire is added to the player directly, it's not the npc that attacks him, so there is no problem like npc getting exp.
 
I updated him, now he has the ability to heal players to a maximum of 65 ;D
 
He's able to kill players, but there's no problem, since the server does not crash(I've tested)
 
Code:
heal = 65 - getCreatureHealth(cid)

If a player have 65 or less of life, the player will not get hurt, and if < 65, the player will get healed.
 
Code:
heal = 65 - getCreatureHealth(cid)
If a player have 65 or less of life, the player will not get hurt, and if < 65, the player will get healed.

I don't understand why he can't be hurt...
There's no condition to get hurt by the npc, you can even get yourself killed.
The npc was tested in forgotten and I had no errors.
 
I don't understand why he can't be hurt...
There's no condition to get hurt by the npc, you can even get yourself killed.
The npc was tested in forgotten and I had no errors.


Well sometimes if u get killed dont u like to check the website by what u get kileld? it mostly donset sai the npc name
 
Back
Top