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

CreatureEvent Killing in the name of...quest!!!

ryandometal

Guitarist!
Joined
Dec 18, 2008
Messages
143
Reaction score
0
Location
Brazil
Hello everyone, this is my first script that post here in the community, I am not very good at it, but after a while I got to make it work 100%.

-----------------------------------------
Description:
Killing in the Name of... Quest - TibiaWiki - Quests, Items, Spells, and more

Distro tested:
The Forgotten Server 0.2.2/0.2.3/0.2.4


First, let's do the NPC.
Go on a data/NPC and create a file .xml with the name of Raymond Striker. Copy this into the file and save:
PHP:
<?xml version="1.0"?>
<npc name="Raymond Striker" script="data/npc/scripts/killing_quest.lua" access="3" lookdir="2" walkinterval="2000">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="151" head="115" body="76" legs="35" feet="117" addons="1" corpse="6080"/>
 <parameters>
  <parameter key="message_greet" value="Hello, what do you do here? Want something? "/>
    </parameters>
</npc>

Now, on data/NPC/scripts, create a file called killing_quest.lua and copy this inside:
PHP:
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
function say(param)
            npcHandler:say(param.text,param.cid)
         end
	function delayedSay(text, delay, cid)
	if(not npcHandler:isFocused(cid)) then
      	      return FALSE
	 else
         local param = {cid = cid, text = text}
			local delay = delay or 0
			local cid = cid or 0
			local nid = getNpcCid()
			addEvent(say, delay, param)


		end
	end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
	return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local quest = 86669
local reward = 90000
local TALKDELAY_ONTHINK = 1
if msgcontains(msg, 'task') then
	delayedSay("The pirates on Nargor are becoming more and more of a threat to us each day. I wish someone could get rid of them once and for all, but unfortunately they just keep coming! ...", 100, cid) 
	delayedSay("Only a dead pirate is a good pirate. I think killing a large number of them would definitely help us to make Sabrehaven a safer place. ...", 12000, cid)
	delayedSay("It doesn't matter how long it takes, but... would you be willing to kill 1200 pirates for us?", 23000, cid)
	talkState[talkUser] = 2
elseif(getPlayerStorageValue(cid, quest) == 2) then
	delayedSay("Come back here when you finish your mission.", 10, cid)
	
	elseif(getPlayerStorageValue(cid, quest) == 3) then --pirates
	delayedSay("Hey, great. You've done well! As a small reward I give you some coins from our treasure box. Also, let me tell you an interesting piece of information. ...", 100, cid)
    delayedSay("One our of spies told us about a secret hideout somewhere on Nargor. Supposedly, one of the four pirate leaders can be found there sometimes. If you dare go there, you might be able to face him or her in one on one combat. ...", 12000, cid)
	delayedSay("Beware though - prepare yourself well and only flee if you must. This might be your only chance to get into there, so be careful and don't die!", 23000, cid)
        doPlayerAddExp(cid, 300000)
        setPlayerStorageValue(cid, quest, 4)
        setPlayerStorageValue(cid, 696969, 1) ---questdoor storage---	
	
elseif(getPlayerStorageValue(cid, quest) == 4) or (getPlayerStorageValue(cid, 696969) == 2) then
	delayedSay("Hm... you already helped me a lot, do not need more of you here, thanks! You expect more missions!", 100, cid)

elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
	delayedSay("Perfect. I know it sounds like a lot, but really, take your time. You won't do it for nothing, I promise, {ok}?.", 100, cid)
	talkState[talkUser]= 3
	elseif msgcontains(msg, 'ok') and talkState[talkUser] == 3 then
	delayedSay("Okay, now go and kill pirates. And after that go back and report!", 100, cid)
    setPlayerStorageValue(cid, quest, 2)

end
end

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

Change only what is in red, in the words of the NPC, and storagevalue of the quest.
You can also modify the reward of quest, rather than doPlayerAddExp (cid, amount), put doPlayerAddItem (cid, IDDOITEM, QUANTITY).

Now go to the folder data/creaturescripts/scripts and create a file with the name kill_counter.lua, then add this in it:
PHP:
local monsters = {
	--name = storage
	["pirate buccaneer"] = 45004,
	["pirate corsair"] = 45004,
	["pirate cutthroat"] = 45004,
	["pirate marauder"] = 45004,
	["pirate ghost"] = 45004
	}

function onKill(cid, target)
	if(isPlayer(target) ~= TRUE) then
		local name = getCreatureName(target)
		local monster = monsters[string.lower(name)]
		if(monster) then
			local killedMonsters = getPlayerStorageValue(cid, monster)
			if(killedMonsters == -1) then
				killedMonsters = 1
			end
			if(name == "pirate buccaneer" or name == "pirate corsair" or name == "pirate cutthroat" or name == "pirate marauder" or name == "pirate ghost") and getPlayerStorageValue(cid, 86669) == 2 then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed " .. killedMonsters .. " of 1200 pirate's.")
				setPlayerStorageValue(cid, monster, killedMonsters + 1)
				if getPlayerStorageValue(cid, 45004)>=1200 then 
					setPlayerStorageValue(cid, 86669, 3)
					
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed enought pirate's.")
				end

		end
	end
	return TRUE
end
end

You can change the names of the monsters to be faced, if you have a different quest. In this example we used pirates: P
Ahh, to change the amount of monsters that the player must kill, here where change is in red:
if getPlayerStorageValue (cid, 45004)> = 1200
1200 = number of monsters
If the quantity change, do not forget to change the messages highlighted in red for the correct number of monsters to be faced!

Also in the folder creaturescripts/scripts, open the file login.lua and add the following command under "onLogin function (cid)":
PHP:
registerCreatureEvent(cid, "KillingInTheNameOf")

Open the file Onkill.lua and add the same command:
PHP:
registerCreatureEvent(cid, "KillingInTheNameOf")

Now go on data/creaturescripts and open the file creaturescripts.xml, add the following tag:
PHP:
<event type="kill" name="KillingInTheNameOf" script="kill_counter.lua"/>

Finally, go to data/actions/scripts, create a file called piratedoor.lua and add this:
PHP:
local bossroom = {x=880, y=617, z=2} ---coordenadas da sala onde o jogador será teleportado ao clicar na porta
local spawn = {x=886, y=608, z=2} ---coordenadas de onde irá nascer o boss

function onUse(cid, item, pos, frompos, item2, topos)
local randommonsters = {"brutus bloodbeard", "deadeye devious", "lethal lissy", "ron the ripper"}
local randomboss = math.random(1,4)

        if getPlayerStorageValue(cid,696969) == 1 then
            doTeleportThing(cid, bossroom)
			doSendMagicEffect(bossroom,10)
			doSummonCreature(randommonsters[randomboss], spawn)
			setPlayerStorageValue(cid, 696969, 2)
   else
   
if item.uid == 8735 and item.itemid == 5290 then
if getPlayerStorageValue(cid,696969) <= 0 or getPlayerStorageValue(cid,696969) >= 2 then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,'The door seems to be sealed against unwanted intruders.')
end
end
end
end

Open the file actions.xml, and add the tag:
PHP:
<action uniqueid="8735" script="piratedoor.lua" />

Change only what is in red, reminding that in the end, 8735 is the UniqueID you put in the door on your map editor, 5290 is the id of the door, both can be changed!
Create an area similar to that of the screenshot, and do not forget to add the NPC on the map!
16150947.png


Thanks to Slawkens to create part of the script, Zakius and to Val(xtibia) for taking a course :p
If it helps you, give rep++ :)
Report bugs here, and have fun!

PS:Sorry for english, using translator :(
 
Last edited:
I think with this script you won't be able to do the quest again.
 
Wow, I was looking for this to work.
I tried to make my own and posted on Donators board for help, but NOOOOO...

But if you can make it possible to do more than once like real Tibia, you will be blessed.
 
Okay, how do I know how many I have killed?
 
Yes, I used your script but I did some changes, I forgot to put your credits, sorry!

Okay, how do I know how many I have killed?
Here:
PHP:
if(name == "pirate buccaneer" or name == "pirate corsair" or name == "pirate cutthroat" or name == "pirate marauder" or name == "pirate ghost") and getPlayerStorageValue(cid, 86669) == 2 then
                doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed " .. killedMonsters .. " of 1200 pirate's.")

When you kill a monster, a message will appear telling you how many killed
 
@Lostboy: I thought that I helped you with it.

@ryandometal o_O this script is very simmilar to this one posted by me in Lostboys request, even upper part of npc script is like this posted by me, I changed these functions to look like that to be able to correct autotab in luascripter.(link to topic: http://otland.net/f132/request-killing-name-quest-38555/)

It did work fine, but then when I tried to add more monsters, something just went poop.
You did help me, and I will thank you so much for it.
 
It did work fine, but then when I tried to add more monsters, something just went poop.
You did help me, and I will thank you so much for it.

Something happened to me too, try the following.
Open the file of the monster you want to add, and check the name tag it is so.
EX:
PHP:
<monster name = "pirate buccaneer"

The name of the monster you want to add the script should be exactly equal to its name of origin, as a precaution, put everything in lowercase.

PHP:
local monsters = {
    --name = storage
    ["pirate buccaneer"] = 45004,
    ["pirate corsair"] = 45004,
    ["pirate cutthroat"] = 45004,
    ["pirate marauder"] = 45004,
    ["pirate ghost"] = 45004
    }

Try it, if don't work, tell me :)
 
Set missions to kill 12 pirates, where it continues to kill does not work, simply "Raymond Striker: Come back here when you finish your mission." Maybe something wrong with my login.lua and onKill.lua?
TFS 0.3.4pl2

login.lua- I know that this is a big mess; s
PHP:
function onLogin(cid)
registerCreatureEvent(cid, "inquisitionPortals")
registerCreatureEvent(cid, "WarAttack")
registerCreatureEvent(cid, "WarKill")
registerCreatureEvent(cid, "KillingInTheNameOf")    

    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end
    -- if he did not make full arena 1 he must start from zero
    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 2 he must start from zero
    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 3 he must start from zero
    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena 

	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		for i = PLAYERLOSS_EXPERIENCE, PLAYERLOSS_ITEMS do
			doPlayerSetLossPercent(cid, i, loss)
		end
	end

	registerCreatureEvent(cid, "Mail")
	registerCreatureEvent(cid, "GuildMotd")
	registerCreatureEvent(cid, "PlayerDeath")
	registerCreatureEvent(cid, "PlayerKill")
	registerCreatureEvent(cid, "Pacccheck")  
	return TRUE
end

function onLogin(cid)
    if(InitHistory == 0) then
        local historyPage = addEvent(historyPage, 60000, {})
        InitHistory = historyPage
    end
    registerCreatureEvent(cid, "PlayerDeath")
    return TRUE
end

function historyPage(parameters)
    local historyPage = addEvent(historyPage, 60000, {})
    if (tonumber(os.date("%d")) ~= getGlobalStorageValue(23456)) then
        setGlobalStorageValue(23456, (tonumber(os.date("%d"))))
        db.executeQuery("UPDATE `players` SET `onlinetime7`=players.onlinetime6, `onlinetime6`=players.onlinetime5, `onlinetime5`=players.onlinetime4, `onlinetime4`=players.onlinetime3, `onlinetime3`=players.onlinetime2, `onlinetime2`=players.onlinetime1, `onlinetime1`=players.onlinetimetoday, `onlinetimetoday`=0;")
        db.executeQuery("UPDATE `players` SET `exphist7`=players.exphist6, `exphist6`=players.exphist5, `exphist5`=players.exphist4, `exphist4`=players.exphist3, `exphist3`=players.exphist2, `exphist2`=players.exphist1, `exphist1`=players.experience-players.exphist_lastexp, `exphist_lastexp`=players.experience;")
    end
    db.executeQuery("UPDATE `players` SET `onlinetimetoday`=players.onlinetimetoday+60, `onlinetimeall`=players.onlinetimeall+60 WHERE `online` = 1;")
end
onKill.lua
PHP:
function onKill(cid, target)
registerCreatureEvent(cid, "KillingInTheNameOf")  
return TRUE
end
Someone help me with this?

EDIT
Also You can add magic effect and "+ xxx EXP" at ending quest ;p
 
Last edited:
Can you add another monster group, like minotaurs or something, so we can get an idea of how to add more monsters on different missions.
 
Sure.
PHP:
local monsters = {
	--name = storage
	["minotaur"] = 646564,
	["minotaur archer"] = 646564,
	["minotaur guard"] = 646564,
	["minotaur mage"] = 646564
	}

function onKill(cid, target)
	if(isPlayer(target) ~= TRUE) then
		local name = getCreatureName(target)
		local monster = monsters[string.lower(name)]
		if(monster) then
			local killedMonsters = getPlayerStorageValue(cid, monster)
			if(killedMonsters == -1) then
				killedMonsters = 1
			end
			if(name == "minotaur" or name == "minotaur archer" or name == "minotaur guard" or name == "minotaur mage" and getPlayerStorageValue(cid, 86669) == 2 then
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed " .. killedMonsters .. " of 5000 minotaur's.")
				setPlayerStorageValue(cid, monster, killedMonsters + 1)
				if getPlayerStorageValue(cid, 646564)>=5000 then 
					setPlayerStorageValue(cid, 86669, 3)
					
					doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed enought minotaur's.")
				end

		end
	end
	return TRUE
end
end
 
Back
Top