Hello.
I've been working on an arena like script. The npc summons 4 mobs and waits for you to kill them. If you fail, he should then remove all the remaining monsters and summon 4 new ones if you want to try again.
Everything worked fine except the "doRemoveCreature" line. It was simply summoning new mobs and not removing the old ones.
So I got rid of that line and put the mobs in the mapeditor instead so the quest works for now, but not as I want.
So if anyone here is good at lua and can help me make the npc remove the creatures he spawns that would be splendid.
I use TFS 0.2.15
Here's my script in it's current form:
Thanks for taking the time to read this.
I've been working on an arena like script. The npc summons 4 mobs and waits for you to kill them. If you fail, he should then remove all the remaining monsters and summon 4 new ones if you want to try again.
Everything worked fine except the "doRemoveCreature" line. It was simply summoning new mobs and not removing the old ones.
So I got rid of that line and put the mobs in the mapeditor instead so the quest works for now, but not as I want.
So if anyone here is good at lua and can help me make the npc remove the creatures he spawns that would be splendid.
I use TFS 0.2.15
Here's my script in it's current form:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
npcHandler:addModule(FocusModule:new())
local storage = 50014
local platform = {fromX = 281, fromY = 44545, fromZ = 6, toX = 306, toY = 44577, toZ = 6}
local mob1pos = {x = 302, y = 44569, z = 6}
local mob2pos = {x = 302, y = 44547, z = 6}
local mob3pos = {x = 285, y = 44547, z = 6}
local mob4pos = {x = 285, y = 44575, z = 6}
local tppos = {x = 302, y = 44576, z = 6}
local mob1 = "Lonely Tree"
local mob2 = "Aggressive Puddle"
local mob3 = "Death"
local mob4 = "Ab'Xeath"
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'trial') then
if getPlayerStorageValue(cid,storage) == -1 and getPlayerLevel(cid) >= 100 then
if getPlayerVocation(cid) == 7 or getPlayerVocation(cid) == 8 then
npcHandler:say('So you want to challenge yourself in my trial?', cid)
talkState[talkUser] = 1
end
elseif getPlayerStorageValue(cid,storage) == 1 then
npcHandler:say('You\'re back already?', cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid,storage) == -1 and getPlayerVocation(cid) ~= 7 or getPlayerVocation(cid) ~= 8 or getPlayerLevel(cid) <= 100 then
npcHandler:say('Hah, you\'re far too weak to pass my trial.', cid)
talkState[talkUser] = 0
else npcHandler:say('Great job passing the trial, unfortunately I don\'t have a harder trial for you.', cid)
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid,storage) == -1 then
local monster_room = false
local monsters = {}
for x = platform.fromX, platform.toX do
for y = platform.fromY, platform.toY do
for z = platform.fromZ, platform.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if isPlayer(thing.uid) then
npcHandler:say('There is already someone doing the trial.', cid)
talkState[talkUser] = 0
return true
end end end end
npcHandler:say('Good luck. You\'re going to need it.', cid)
setPlayerStorageValue(cid,storage,1)
--[[doSummonCreature(mob1,mob1pos)
doSummonCreature(mob2,mob2pos)
doSummonCreature(mob3,mob3pos)
doSummonCreature(mob4,mob4pos)--]]
doTeleportThing(cid, tppos)
else
if(doPlayerRemoveItem(cid, 14321, 1)) and doPlayerRemoveItem(cid, 14322, 1) and doPlayerRemoveItem(cid, 14324, 1) and doPlayerRemoveItem(cid, 6550, 1) then
npcHandler:say('Impressive, here\'s your reward.', cid)
setPlayerStorageValue(cid,storage,2)
doPlayerAddItem(cid,2469,1)
doPlayerAddItem(cid,2506,1)
doPlayerAddExp(cid,250000)
else
npcHandler:say('You did not kill all the bosses though. Do you want to try again?', cid)
talkState[talkUser] = 2
end
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
if getPlayerStorageValue(cid,storage) == 1 then
doPlayerRemoveItem(cid, 14321, 1)
doPlayerRemoveItem(cid, 14322, 1)
doPlayerRemoveItem(cid, 14324, 1)
doPlayerRemoveItem(cid, 6550, 1)
local monsters = {}
for x = platform.fromX, platform.toX do
for y = platform.fromY, platform.toY do
for z = platform.fromZ, platform.toZ do
local pos = {x=x, y=y, z=z,stackpos = 253}
local thing = getThingfromPos(pos)
if isPlayer(thing.uid) then
npcHandler:say('There is already someone doing the trial.', cid)
talkState[talkUser] = 0
return true
end end end end
npcHandler:say('Good luck. You\'re going to need it.', cid)
setPlayerStorageValue(cid,storage,1)
--[[doSummonCreature(mob1,mob1pos)
doSummonCreature(mob2,mob2pos)
doSummonCreature(mob3,mob3pos)
doSummonCreature(mob4,mob4pos)--]]
doTeleportThing(cid, tppos)
end
elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 or talkState[talkUser] == 2 then
npcHandler:say('It\'s probably for the best. The trial is pretty scary.', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Thanks for taking the time to read this.