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.
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: