• 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!

Whats wrong here?

vejsa

Banned User
Joined
Nov 3, 2007
Messages
434
Reaction score
0
As the title says.. whats wrong here.. im trying to make an npc that only will say:
Code:
Okey, lets start.. The roumor has it that if you go to a place containing demons, a whole lot of them you will find your first clue to proceed with the firewalker boots quest! say {ok} if you understand me.
When the player has said "OK" then the second thing that the npc will say has to come up. Wich in this case is:


Code:
Now return to the teleport room. Enter a Demon spawn teleport. I do not know wich you need to figure that out by ur self.. From there on you have to do everything by thinking!

Code:
local target = 0
local prevTarget = 0
local maxChaseDistance = 20
local origPos = 0
local lastAttack = 0
local followTimeout = 10

local function isSkulled(cid)
	if(getCreatureSkullType(cid) >= SKULL_WHITE and isPlayerPzLocked(cid)) then
		return true
	end

	return false
end

local function goToOrigPos()
	target = 0
	lastAttack  = 0
	selfFollow(0)
	doTeleportThing(getNpcCid(), origPos)
end

local function updateTarget()
	if(not isPlayer(target)) then
		goToOrigPos()
	elseif(not isSkulled(target)) then
	if(msgcontains(msg, 'firewalker boots') or msgcontains(msg, 'boots')) then
		selfSay("Okey, lets start.. The roumor has it that if you go to a place containing demons, a whole lot of them you will find your first clue to proceed with the firewalker boots quest! say {ok} if you understand me.")
		goToOrigPos()
				talkState[talkUser] = 1
	elseif(msgcontains(msg, 'ok') and talkState[talkUser] == 1) then
				selfSay('Now return to the teleport room. Enter a Demon spawn teleport. I do not know wich you need to figure that out by ur self.. From there on you have to do everything by thinking!', cid)
			else
	end

	if(target == 0) then
		local list = getSpectators(getNpcPos(), 9, 9, false)
		for i = 1, table.getn(list) do
			local _target = list[i]
			if(_target ~= 0) then
				if(isPlayer(_target) and isSkulled(_target)) then
					if(not getTilePzInfo(getCreaturePosition(_target))) then
						if(selfFollow(_target)) then
							target = _target
							if(target ~= prevTarget) then
								selfSay("We do not tolerate people like you here!")
							end

							prevTarget = target
							break
						end
					end
				end
			end
		end
	end
end

function onCreatureAppear(cid)
	if(cid == getNpcCid()) then
		origPos = getNpcPos()
	end
end

function onCreatureDisappear(cid)
	if(cid == target) then
		goToOrigPos()
	end
end

function onCreatureMove(creature, oldPos, newPos)
	--
end

function onThink()
	updateTarget()

	if(target == 0) then
		return
	end

	local playerPos = getCreaturePosition(target)
	local myPos = getNpcPos()

	if(myPos.z ~= playerPos.z) then
		goToOrigPos()
		return
	end

	if(math.abs(myPos.x - origPos.x) > maxChaseDistance or math.abs(myPos.y - origPos.y) > maxChaseDistance) then
		selfSay("I'll catch you next time.")
		goToOrigPos()
		return
	end

	if(lastAttack == 0) then
		lastAttack = os.clock()
	end

	if(os.clock() - lastAttack > followTimeout) then
		selfSay("You got me this time, but just wait.")
		goToOrigPos()
		return
	end

	if((math.abs(playerPos.x - myPos.x) <= 1) and (math.abs(playerPos.y - myPos.y) <= 1)) then
		doTargetCombatHealth(getNpcCid(), target, COMBAT_LIFEDRAIN, -200, -300, CONST_ME_BLOCKHIT)
		lastAttack = os.clock()
	end
end

Is it something wrong with the script or something like it?.. Cuz I cant make it work In-game when I try it out.. the npc wont even spawn. :confused:
 
Last edited:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}

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() end

function greetCallback(cid)
	Topic[cid] = 0
	return true
end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, 'boots') then
		npcHandler:say("Okay, let's start... The rumor has it that if you go to a place containing demons, a whole lot of them, you will find your first clue to proceed with the firewalker boots quest! Say {ok} if you understand me so far.", cid)
		Topic[cid] = 1
	elseif msgcontains(msg, 'ok') and Topic[cid] == 1 then
		npcHandler:say("Now return to the teleport room. Enter a Demon spawn teleport. I don't know which one, you need to figure that out yourself. From there on you have to do everything by thinking!", cid)
		Topic[cid] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I bet Cykotitan's version worked out pretty well, but you posted that to look smart and not as stupid as we thought after seeing what you tried to do with your guard script.
 
Back
Top