Jump to content

Boss Library


Recommended Posts

  • Premium

Hello.


Example of a bad quest:

Spoiler
-----------------------------------------------------
----  Scris cu diacritice de Donici Cãtãlin  ----
-----------------------------------------------------
quest mob_kill_notice begin
   state start begin
      when 691.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 300 )
         chat ("Gradul tãu a crescut cu 300 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe ªeful Orc din Valea Orcilor!" )
      end
      when 692.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 900 )
         chat ("Gradul tãu a crescut cu 900 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe ªeful Orc de elita din Valea Orcilor!" )
      end
      when 693.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1500 )
         chat ("Gradul tãu a crescut cu 1500 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe ªeful Orc ucigator din Valea Orcilor!" )
      end
      when 791.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 500 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 500 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Stãpânul Esotericilor din Templul Întunecat!" )
      end
      when 792.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 900 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 900 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Stãpânul Esotericilor Demonizat din Templul Întunecat!" )
      end
      when 793.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 900 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 900 de puncte!")
         notice_all ( pc.getname() , "l-a omorât pe Stãpânul Esotericilor Demonizat din Templul Întunecat!" )
      end
      when 794.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1500 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 1500 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Stãpânul Esotericilor din Templul Întunecat!" )
      end
      when 795.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Stãpânul Esotercilor Demonizat EXTRA" )
      end
      when 1306.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1500 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 2 pietre spirit ºi gradul tãu a crescut cu 1500 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Fantoma Tigrului Galben !" )
      end
      when 1307.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Fantoma Tigrului Galben EXTRA !" )
      end
      when 1091.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 600 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 600 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Regele Demon!" )
      end
      when 1092.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 800 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 800 de puncte!")
         notice_all ( pc.getname() , "l-a omorât pe Regele Demon Mândru!" )
      end
      when 1093.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 3 pietre spirit ºi gradul tãu a crescut cu 1000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Îngerul cu Coasa!" )
      end
      when 1094.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 3 pietre spirit ºi gradul tãu a crescut cu 1000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Regele Demon Mândru EXTRA!" )
      end
      when 1095.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Îngerul cu Coasa EXTRA!" )
      end
      when 993.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1500 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 1500 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Regele gazda al ciumei!" )
      end
      when 1901.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1500 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 2 pietre spirit ºi gradul tãu a crescut cu 1500 de puncte!")
         notice_all ( pc.getname() , " a omorât-o pe Vulpea cu 9 cozi!" )
      end
      when 1902.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 2000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 2 pietre spirit ºi gradul tãu a crescut cu 2000 de puncte!")
         notice_all ( pc.getname() , " a omorât-o pe Vulpea cu 9 cozi 2!" )
      end
      when 1903.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 3000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 3 pietre spirit ºi gradul tãu a crescut cu 3000 de puncte!!")
         notice_all ( pc.getname() , " a omorât-o pe Vulpea cu 9 cozi EXTRA!" )
      end
      when 2091.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1500 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 2 pietre spirit ºi gradul tãu a crescut cu 1500 de puncte!")
         notice_all ( pc.getname() , " a omorât-o pe Regina P?ianjen!" )
      end
      when 2092.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 3000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 3 pietre spirit ºi gradul tãu a crescut cu 3000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Regele P?ianjen!" )
      end
      when 2093.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " a omorât-o pe Regina Pianjen EXTRA!" )
      end
      when 2191.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 2000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 2 pietre spirit ºi gradul tãu a crescut cu 2000 de puncte!")
         notice_all ( pc.getname() , " a omorât-o pe ?estoasa Uria?? de De?ert!" )
      end
      when 2192.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " a omorât-o pre ?estoasa Uria?? de De?ert EXTRA!" )
      end
      when 2491.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Liderul Seatou Levhiatan!" )
      end
      when 2492.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Liderul Seatou Levhiatan 2 !" )
      end
      when 2493.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 10000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 10000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Beran-Setaou!" )
      end
      when 5002.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 2000 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 2000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Hae-Tae!" )
      end
      when 2206.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 1500 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 1 pietre spirit ºi gradul tãu a crescut cu 1500 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Regele de Foc!" )
      end
      when 2207.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Regele de Foc 2!" )
      end
      when 2291.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Dragonul Ro?u!" )
      end
      when 2306.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 3000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 3 pietre spirit ºi gradul tãu a crescut cu 3000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Copacul Gigant!" )
      end
      when 2307.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 8000 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         pc . give_item2 ( 50513 )
         chat ("Ai primit 5 pietre spirit ºi gradul tãu a crescut cu 8000 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Copacul B?trân!" )
      end
      when 1403.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 300 )
         pc . give_item2 ( 50034 )
         chat ("Ai primit 1 ladã misterioasa ºi gradul tãu a crescut cu 300 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Gigantul Milenar!" )
      end
   end
end

 

That is absolutely obnoxious in my opinion, totally obnoxious.
I'm here today to show you the simplest, cleanest and shortest way to deal with something like this: A quest which communicates with a simple library in order to get global notice and eventual drop from a boss/monster or metin kill, the quest is coded to work with bosses, but it's fully ampliable and 100% customizable to your likings.
I release this in hope to see less quests like the one i put into a spoiler (no one should see that, it could spread terminal cancer).

As always, the library is fully customizable.
Each function contains a clear explanation of its structure and what it does.

Have fun!

Function Library File (.lua):

This is the hidden content, please


Quest File:

This is the hidden content, please

Download (To avoid IPS invisible characters) -> 

This is the hidden content, please


How do i use the library file?
Make it load by dofile() in your questlib.lua or simply add what's inside it to the questlib.lua as it is.

Why should i use it?
First of all, as I said, it's fully customizable: you can just add new monsters to the main data array and the quest will handle them.
Secondly, the library file contains the full boss and data arrays + documentation and yet it still is only 120 lines of code, the quest contains the checks and the notice/drop functions, nothing else, since the whole is completely managed by the library, small, yet full of functionalities.

Edited by Syreldar
7/11/2022 - Edit: Added alignment award and code cleanup.
  • Metin2 Dev 91
  • kekw 1
  • Eyes 1
  • Dislove 1
  • Good 21
  • Love 6
  • Love 46

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium
7 minutes ago, Galet said:

Great ! First I was like "Uh, Is Syreldar really sharing a dirty coded Romanian quest ?" but then I saw the rest of the post. Sure it is the cleaner and the more advanced one I saw. Better than my own quest using tables and arrays.

 

Well done !

I would never do that, i'd prefer to kill myself, the spoilers just bugged out XD

Thanks <3

  • Scream 1
  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • 2 months later...
On 2017. 05. 29. at 11:33 AM, Syreldar said:

Hi, metin2devs and metin2users.
Many times i've seen a server use a quest like this one, to notice the kill of the bosses or to trigger special drops/events:

  Hide contents


-----------------------------------------------------
----  Scris cu diacritice de Donici Cãtãlin  ----
-----------------------------------------------------
quest mob_kill_notice begin
   state start begin
      when 691.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 300 )
         chat ("Gradul tãu a crescut cu 300 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe ªeful Orc din Valea Orcilor!" )
      end
     
      
      when 1403.kill begin
         if pc.is_gm() then
         return
         end
         pc . change_alignment ( 300 )
         pc . give_item2 ( 50034 )
         chat ("Ai primit 1 ladã misterioasa ºi gradul tãu a crescut cu 300 de puncte!")
         notice_all ( pc.getname() , " l-a omorât pe Gigantul Milenar!" )
      end
   end
end

 

That is absolutely obnoxious in my opinion, totally obnoxious.
I'm here today to show you the simplest, cleanest and shortest way to deal with something like this: A quest which communicates with a simple library in order to get global notice and eventual drop from a boss/monster or metin kill, the quest is coded to work with bosses, but it's fully ampliable and 100% customizable to your likings.
I release this in hope to see less quests like the one i put into a spoiler (no one should see that, it could spread terminal cancer).

As always, the library is fully customizable.
Each function contains a clear explanation of its structure and what it does.

Have fun!

Function Library File (.lua):

  Hide contents


--[[
	Initializes:
		The 'Boss' class.
]]
Boss = {}

--[[
	Returns:
		The 'data' array.

	Structure:
		[vnum] = {["type"] = The boss' type (Normal = 1, Dungeon = 2, Event = 3), ["drop"] = {["vnum"] = The vnum of the drop (0 if none), ["quant"] = The quantity of the item to drop}, ["notice"] = true if the kill should be globally announced, else false}

]]
Boss.GetData = function()
	local data = {
		--** Normals
		[591]  = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Bestial Captain
		[691]  = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Chief Orc
		[792]  = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Dark-Ghost Leader
		[1304] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Yellow Tiger Ghost
		[1901] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Nine Tails
		[2091] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Queen Spider
		[2191] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Giant Tortoise
		[2206] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Flame King
		[2306] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Giant Ghost Tree
		[5161] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Rock Ape
		[5162] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Walking Ape
		[5163] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Ape Lord

		--** Demon Tower
		[1091] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Demon King
		[1092] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Proud Demon King
		[1093] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Death Reaper
		
		--** Spiders Cave
		[2092] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Spider Baroness
		
		--** Grotto of Exile 1st Floor
		[1192] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Mighty Ice Witch

		--** Grotto of Exile 2nd Floor
		[2492] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** General Yonghan
		[2495] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** General Huashin
		
		--** Grotto of Exile's Dragon Lair
		[2493] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Beran-Setaou

		--** Devil's Catacomb
		[2591] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Tartaros
		[2597] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Charon
		[2598] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Azrael
		
		--** The Dark Dragons
		[3090] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Gnoll Lord
		[3091] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Supreme Gnoll Guard
		[3190] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Arges
		[3191] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Polyphemos
		[3290] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Rakshasa
		[3291] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Martyaxwar
		[3390] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Lemures Prince
		[3391] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Lemures Bodyguard
		[3490] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** General Kappa
		[3491] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Triton
		[3590] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Bone Face
		[3591] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Red Chief
		[3595] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Brutal Bone Face
		[3596] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Brutal Red Chief
		[3690] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** General Lobster
		[3691] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** King Crab
		[3790] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Gargoyle
		[3791] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** King Wubba
		[3890] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Captain Shruk
		[3891] = {["type"] = 1, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** The Great Ogre

		--** Blazing Purgatory
		[6051] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Ignator
		[6091] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Razador

		--** Nemere's Watchtower
		[6151] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Szel
		[6191] = {["type"] = 2, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Nemere

		--** Event Bosses
		[692]  = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Elite Chief Orc
		[693]  = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Reborn Chief Orc
		[794]  = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** ??
		[795]  = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** ??
		[993]  = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** ??
		[1094] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** ??
		[1095] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Blue Death
		[1191] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Ice Witch
		[1334] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Gr. Yellow Tiger Spirit
		[1902] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Elite Nice Tails
		[1903] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Elite Nine Tails (Black)
		[2093] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Dark Spider Queen
		[2192] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Dark Giant Tortoise
		[2207] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Dark Flame King
		[2291] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}, --** Red Dragon
		[2307] = {["type"] = 3, ["drop"] = {["vnum"] = 0, ["quant"] = 0}, ["notice"] = true}  --** Phantom Tree Lord
	};

	return data;
end -- function

--[[
	Returns:
		true if the vnum of the monster inserted in the 'vnum' argument matches a boss' vnum
		else, false.
]]
Boss.IsBoss = function(vnum)
	return table_contains_keyword(Boss.GetData(), vnum);
end -- function

--[[
	Returns:
		The boss' type if the vnum inserted in the argument 'vnum' matches a boss' vnum,
		else, nil.
]]
Boss.GetType = function(vnum)
	if (Boss.IsBoss(vnum)) then
		return Boss.GetData()[vnum]["type"];
	end -- if
	
	return nil;
end -- function

 


Quest File:

  Hide contents


quest boss begin
	state start begin
		when kill with not npc.is_pc() and Boss.IsBoss(npc.get_race()) begin
			local race = npc.get_race();
			local data = Boss.GetData()[race];
			local drop = data["drop"];

			if (not pc.is_gm() and data["notice"]) then
				notice_all(string.format("[Boss-Kill Notice]: %s has slain %s on channel %d.", pc.get_name(), mob_name(race), pc.get_channel_id()));
			end -- if
			
			if (drop["vnum"] ~= 0) then
				game.drop_item_with_ownership(drop["vnum"], drop["quant"]);
			end -- if
		end -- when
	end -- state
end -- quest

 


How do i use the library file?
Make it load by dofile() in your questlib.lua or simply add what's inside it to the questlib.lua as it is, even if it's not exactly the cleanest way to do it.

Why should i use it?
First of all as i said, it's fully customizable, you can just add new monsters to the main data array and the lib will handle them by itself.
Second, the library file contains the full boss and data arrays + documentation and yet it still is only 120 lines of code, the quest contains the checks and the notice/drop functions, nothing else, since the whole is fully managed by the library, so it's less than 20 lines of code. No script i've seen till now is more lightweight and as customizable as this one.


Hello,
Nice thank for sharing.
 

787292068_Nvtelen.png.6faa7b0bbb3398fd29

Link to comment
Share on other sites

  • 5 years later...

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.