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

"Bring the head" - script based on World of Warcraft

Alegres

You break it you buy it
Joined
Jun 27, 2009
Messages
325
Reaction score
14
Location
Wroclaw,Poland
Hello everyone. Could someone please tell me how to write or write for me script which would look like this?

SCRIPT:

1.) NPC tells you to bring him head of UBERSTRONGMONSTER.

2.) You accept the mission.

3.) You kill UBERSTRONGMONSTER and you loot his head (you can loot his head only if you're on that quest)

4.) You go to your quest giver and your turn in your missions (able only when you have head of UBERSTRONGMONSTER in your backpack)

5.) All with quest log.

And that's all. Thanks for everyone that are willing to help me =)
 
@up
easy? So why the fuck u dont do it and just leave spam...

Its something like that:

NPC:
Lua:
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 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, 'quest') or msgcontains(msg, 'mission')) then

		if getPlayerStorageValue(cid,5432) < 1 then
		selfSay('Ahh, i have problems with the UBERSTRONGMONSTER. Can u help me?', cid)
		talkState[talkUser] = 1


		elseif getPlayerStorageValue(cid,5432) == 1 then
		selfSay('Did you bring me his head?', cid)
		setPlayerStorageValue(cid,8000,58)
		talkState[talkUser] = 2

		else
		selfSay('I already have his head, thanks for help again.', cid)
		talkState[talkUser] = 0
		end
	end

	if(msgcontains(msg, 'yes')) then
		if talkState[talkUser] == 1 then
			selfSay('So go find that UBERFCKELOMELOMONSTER and bring me his head.', cid)
			setPlayerStorageValue(cid,5432,1)
			talkState[talkUser] = 0
		elseif talkState[talkUser] == 2 then
			if getPlayerItemCount(cid,XXXX) >= 1 then
				selfSay('Oh thank you!', cid)
				setPlayerStorageValue(cid,5432,2)
				doPlayerRemoveItem(cid,XXXX,1)
				talkState[talkUser] = 0
			else
				selfSay('You dont have his head in your backpack', cid)
				talkState[talkUser] = 0
			end
		end
	end
	
	if(msgcontains(msg, 'no')) then
		if talkState[talkUser] == 1 then
			selfSay('Okey, back soon.', cid)
			talkState[talkUser] = 0
		elseif talkState[talkUser] == 2 then
			selfSay('Aff, so go and find that bloody monster...', cid)
			talkState[talkUser] = 0
		end
	
	end



	return true

end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())


creaturescripts:
Lua:
function onKill(cid, target)
	if isMonster(target) then
	if getCreatureName(target):lower() == 'uberpromonster' then
	if getPlayerStorageValue(cid,5432) == 1 then
		doPlayerAddItem(cid, XXXX, 1)
	end
	end
	end
return true
end

When u kill monster, u immediately get the item with ID 'XXXX' to your backpack.
That all what i can do ^^, i cannot do it with Quests.xml :S

Erexo :)
 
Thanks you! It's very useful. I wonder if there is any possibility to let the head drop from monster as a quest item which is binded to player instead of putting it immediately into his backpack?

Also is it possible to not let players throw away some specific items and not let them trade it with other players? Something like Soulbound in World of Warcraft. Could someone explain me how can I do it?

VERY IMPORTANT

How can I do something like this:

Player kills monsters during a Task Quest and when he kill 50/100 of required enemies, on position x y z automatically spawns boss?
 
Last edited:
Thanks you! It's very useful. I wonder if there is any possibility to let the head drop from monster as a quest item which is binded to player instead of putting it immediately into his backpack?

Its kinda clever stuff however I can try it sec and Ill post it ^^ btw other stuff might I help too.
 
Eh, that was hard took me like hour of testings. I made it in the best way you dont need to register your monsters and so on just register it to login.lua

creaturescripts.xml

Code:
<event type="kill" name="bubu" script="bubu.lua"/>

bubu.lua

Lua:
local monsters = {
["demon"] = {item = 2160, count = 2, chance = 70},
["rat"] = {item = 2160, count = 2, chance = 80}
}	
				
function onKill(cid, target, lastHit)

local v = getMonsterInfo(getCreatureName(target)).lookCorpse
local chance = math.random(1, 100)
	for k, a in pairs(monsters) do
		if (isMonster(target) and ((string.lower(getCreatureName(target))) == k)) then
			if a.chance >= chance then
				local function dropLoot(pos, v, cid)
					local corpse = getTileItemById(pos, v).uid
					doAddContainerItem(corpse, a.item, math.random(1, a.count))
				end			
				addEvent(dropLoot, 0, getThingPos(target), v,cid)
			end
		end
	end
return true
end
 
oh Sorry I just now noticed that you using 0.2. version

so change to this code.

Lua:
local monsters = {
["demon"] = {item = 2160, cant = 2, chance = 70},
["rat"] = {item = 2160, cant = 2, chance = 100}
}

local storage = 7474

function onDeath(cid, corpse)
local chance = math.random(1, 100)
if getPlayerStorageValue(getPlayerByName(getPlayerName(getCreatureTarget(cid))), storage) == 1 then
	for k, v in pairs(monsters) do
		if (isMonster(cid) and ((string.lower(getCreatureName(cid))) == k)) then
			if v.chance >= chance then
				doAddContainerItem(corpse.uid, v.item, math.random(1, v.cant))
			end
		end
	end
end
return true
end

and add this to every monster you want to drop special item. before <loot>

Code:
<script>
	<event name="bubu"/>
    </script>

Btw I will release it to resources section it is very cool thing. Many would appreciate it
 

Similar threads

Back
Top