• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Quest to kill monsters. NPC included!

calveron

Bravemansworld
Joined
Feb 5, 2008
Messages
165
Reaction score
13
Location
Sweden
Well, since I couldn't find any working quest where a npc gives you a mission to kill x ammount of monsters, I decided to make one myself, with a little help and support.
Since I got help, I decided to help others and share this :)


This quest requires you to kill 200 dragons or dragon lords.
Creaturescript

CREATE /creaturescripts/scripts/monsterkilldragon.lua
Code:
local monsters = {
	--name = storage
	["dragon"] = 55004,
	["dragon lord"] = 55004
}

function onKill(cid, target)
	local monster = monsters[getCreatureName(target):lower()]
	if(isPlayer(target) == FALSE and monster and getPlayerStorageValue(cid, 76669) == 2) then
		if getPlayerStorageValue(cid, monster) < 200 then 
			local killedMonsters = getPlayerStorageValue(cid, monster)
            if(killedMonsters == -1) then
                killedMonsters = 1
			end
			setPlayerStorageValue(cid, monster, killedMonsters + 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed " .. killedMonsters .. " of 200 dragons.")
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed enough dragons.")
			setPlayerStorageValue(cid, 76669, 3)
		end
	end
	return TRUE
end


IN /creaturescripts/scripts/login.lua
ADD:
Code:
registerCreatureEvent(cid, "monsterkill")


IN /creaturescripts/creaturescripts.xml
ADD:
Code:
<event type="kill" name="monsterkill" script="monsterkill.lua"/>


NPC

CREATE npc/Martin.xml
Code:
<?xml version="1.0"?>
<npc name="Martin" script="data/npc/scripts/dragon quest.lua" access="3" lookdir="2" walkinterval="2000">
    <mana now="800" max="800"/>
    <health now="132" max="200"/>
<look type="151" head="115" body="76" legs="35" feet="117" addons="1" corpse="6080"/>
 <parameters>
  <parameter key="message_greet" value="Hi, can you help me? ask me for a {mission}. "/>
    </parameters>
</npc>

CREATE npc/scripts/dragon quest.lua
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local talkState = {}
local quest = 76669
local reward = 70000
	
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 creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(not npcHandler:isFocused(cid)) then
		return false
	elseif msgcontains(msg, "yes") and talkState[talkUser] == 1 then
		npcHandler:say("Great! I'll reward you greatly {ok}?.", cid)
		talkState[talkUser] = 2
	elseif msgcontains(msg, "ok") and talkState[talkUser] == 2 then
		npcHandler:say("Okay, Hurry up!", cid)
		setPlayerStorageValue(cid, quest, 2)
		talkState[talkUser] = 0
	elseif msgcontains(msg, "mission") then
		local str = getPlayerStorageValue(cid, quest)
		if(str < 2) then
			npcHandler:say("Great, an adventurer. I need you to slay 200 dragons for me. And then, we might be able to take out those dragon lords. Well, can you slay 200 dragons for me?", cid) 
			talkState[talkUser] = 1
			return true
		elseif(str == 2) then
			npcHandler:say("Please come back for a reward.", cid)
		elseif(str == 3) then
			npcHandler:say("200 dragons, already? You're a true dragon slayer! As I promised, here's your reward.", cid)
			doPlayerAddItem(cid, 2160, 30)
			doPlayerAddExp(cid, 1000000)
			doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and 142 or 134, 2)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have been rewarded with the warrior addon!")
			setPlayerStorageValue(cid, quest, 4)
		elseif(str == 4) then
			npcHandler:say("You have done enough for me, I will soon plan our attack!", cid)
		end
		talkState[talkUser] = 0
	end
	return TRUE
end

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

This npc will give you an outfit addon, 1mil exp and 300k. Just change it to whatever you want :p
 
Last edited:
Code:
<event type="kill" name="monsterkill" script="monsterkill.lua"/>
Only this line changes for 0.2 and 0.3 series.
This one is for 0.2 I think, but I'm not sure
And btw, you forgot about credits.
I'll edit and paste link with old topic
EDIT:
http://otland.net/f82/killing-name-quest-39581/
and even older post, from requests, where I made this script ; o
http://otland.net/f132/request-killing-name-quest-38555/#post391476
EDIT:
And your script isn't perfect, just like older ones, cause it will count summons
 
Last edited:
well, since you can't summon dragons, so I suppose it doesnt matter.
Thanks for the links btw, forgot to add. :)

works with 0.3.5
 
It matters even for demons, cause Orsh summons demons ;d
Code:
if(isPlayer(target) == FALSE and monster and getPlayerStorageValue(cid, 76669) == 2) then
should be
Code:
if(isPlayer(target) == FALSE and monster and getPlayerStorageValue(cid, 76669) == 2 and isSummon(target) == FALSE) then
But will work only if in function.lua is
Code:
function isSummon(cid)
        return (isMonster(cid)) and (getCreatureMaster(cid)~=cid)
end
 
How do i make the script work for several different monsters? Like, first you kill 100 dragons. When you come back to NPC he give you reward.

After he gives you a reward, it starts over. he ask you for a mission and then it's 200 rotworms and etc etc.

How do you add several monsters? Several rewards?

Teach me and i'll fix it myself! :)
 
How do i make the script work for several different monsters? Like, first you kill 100 dragons. When you come back to NPC he give you reward.

After he gives you a reward, it starts over. he ask you for a mission and then it's 200 rotworms and etc etc.

How do you add several monsters? Several rewards?

Teach me and i'll fix it myself! :)

Yup, I need this too. Thanks very much for the script!
 
EDIT2: Made it work now. But I want to understand what is for each storage.

What's one I have to change when making another quest like thie one.

I think I had understand all storage values, except local reward = 70000.
What this one make?

EDIT: when changing to another monters, I have to change this too:

--name = storage
["dragon"] = 55004,

and this:


local reward = 70000
(I actualy didnt understood what this last one make, once it has another storage value for quest, I dont understand to what this one is for)

????

or only change storage value of the quest is enough?

waiting any help
 
Last edited:
(BUMP) I also need help with this ^ is like he said is this another quest storage value that executes another script?
 
Back
Top