This is a script which after talkin with Npc you have to go through diff parts to kill boss and get a reward! Note that I'm still a noob at LUA, this is my first released script in OTland!
You say fight to Npc and he will teleport you behind a door (which you can only open after talking with that Npc), after you go through the door you'll go to a teleport that tps you to boss room, and the tp to leave, that gives you a storageID so you go back with Npc and say report and he will give you exp or reward[configurable], so Let's get started:
data/npc/Josh.xml
Josh.xml
data/npc/scripts/josh.lua
data/movements/movements.xml add:
data/movements/scripts/tp.lua
data/movements/scripts/tp back.lua
data/actions/actions.xml add:
data/actions/scripts/quest door.lua
And that's it! this pic so its easy for setup !
http://img508.imageshack.us/img508/9553/fightd.png
Tested and worked in TFS 0.3.6
PS: I need someone who can please make the last teleport appear after killing the required monster! If someone can do that It would be awesome!
Credits for Doggynub for fixing the Npc
You say fight to Npc and he will teleport you behind a door (which you can only open after talking with that Npc), after you go through the door you'll go to a teleport that tps you to boss room, and the tp to leave, that gives you a storageID so you go back with Npc and say report and he will give you exp or reward[configurable], so Let's get started:
data/npc/Josh.xml
Josh.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Josh" script="data/npc/scripts/josh.lua" walkinterval="5000" floorchange="0">
<health now="100" max="100"/>
<look type="130" head="0" body="0" legs="0" feet="0" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. Say {fight} if you'd like to have a fight!."/>
</parameters>
</npc>
data/npc/scripts/josh.lua
Lua:
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
local place = {x=95,y=125,z=7} ---- Edit this to your POSITIONS
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
if msgcontains(msg, 'fight') then
npcHandler:say('Would you like to have a fight?!', cid)
Topic[cid] = 1
elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then
npcHandler:say('Are you ready?', cid)
Topic[cid] = 2
elseif msgcontains(msg, 'no') and Topic[cid] == 1 then
npcHandler:say('Maybe later then.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
Topic[cid] = 0
setPlayerStorageValue(cid,35000,1)
selfSay('Here you are.', cid)
addEvent(doTeleportThing,50,cid,place)
addEvent(doSendMagicEffect,100,place,10)
elseif msgcontains(msg, 'report') and getPlayerStorageValue(cid,35000) == 3 then
doPlayerAddExp(cid,500) ---- Put exp in nrs (the exp you want to be rewarded) IF you do not want exp rewarded then remove the line
doPlayerAddItem(cid,2409) ---- Put itemID you want.
setPlayerStorageValue(cid,35000,4)
npcHandler:say('Congratulations, take these as a reward', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'report') and getPlayerStorageValue(cid,35000) == 4 then
npcHandler:say('I have already rewarded you!', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
data/movements/movements.xml add:
XML:
<movevent type="StepIn" uniqueid="29333" event="script" value="tp.lua"/>
<movevent type="StepIn" uniqueid="29334" event="script" value="tp back.lua"/>
Lua:
local storage = 35000
local position = {x=93,y=114,z=7} ---- Put the positions where the monster will be summoned
local newPos = {x=95,y=114,z=7} ---- The positions were the tp will lead
function onStepIn(cid, item, pos)
ppos = getPlayerPosition(cid)
if getPlayerStorageValue(cid,storage) == 1 then
doSendAnimatedText(ppos,"In!",math.random(1,60))
doSummonCreature("demon", position) ----EDIT TO THE MONSTER U WANT
doTeleportThing(cid, newPos)
else
doPlayerSendCancel(cid, "You have already done this fight!")
end
return true
end
data/movements/scripts/tp back.lua
Lua:
local storage = 35000
local newPos = {x=95,y=114,z=7} ---- The positions were the tp will lead
function onStepIn(cid, item, pos)
ppos = getPlayerPosition(cid)
setPlayerStorageValue(cid,storage,3)
doSendAnimatedText(ppos,"Out!",math.random(1,60))
doTeleportThing(cid, newPos)
return true
end
data/actions/actions.xml add:
XML:
<action uniqueid="5114" event="script" value="quest door.lua"/>
data/actions/scripts/quest door.lua
Lua:
local storage = 35000
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerStorageValue(cid,storage) == 1 then
doTransformItem(item.uid,5106)
else
doPlayerSendCancel(cid, "You have already done this boss")
end
return true
end
And that's it! this pic so its easy for setup !
http://img508.imageshack.us/img508/9553/fightd.png
Tested and worked in TFS 0.3.6
PS: I need someone who can please make the last teleport appear after killing the required monster! If someone can do that It would be awesome!
Credits for Doggynub for fixing the Npc