- Joined
- Jan 25, 2025
- Messages
- 47
- Reaction score
- 0
- Points
- 6
Quest for drop items alternative to mob_drop_info.
If the killed mob is at a maximum level difference of 15 from the player, there is a probability that it will drop one of the items set in questlib.
alternativdrop.quest :
We add in questlib :
Edit in questlib - Explanations :
chance = drop chance in percentages
vnum = item code
count = quantity
If the killed mob is at a maximum level difference of 15 from the player, there is a probability that it will drop one of the items set in questlib.
alternativdrop.quest :
Code:
quest alterdrop begin
state start begin
when kill with npc.get_level_dif() <= 15 begin
if not ALTERNATIVE_DROP then return end
for _,item in ipairs(ALTERNATIVE_DROP) do
if math.chance(item.chance) then
game.drop_item_with_ownership(item.vnum, item.count)
end
end
end
end
end
We add in questlib :
Code:
function math.chance(i)
return math.random() <= (i/100)
end
local NPC_INFO = {}
local NPC_QUERY_RESULT = mysql_query("SELECT vnum, level FROM player.mob_proto;")
if type(NPC_QUERY_RESULT) == "table" then
for i,mob in ipairs(NPC_QUERY_RESULT) do
NPC_INFO[tonumber(mob[1])] = {level = tonumber(mob[2])}
end
end
function npc.get_level()
local npcvnum = npc.get_race()
local npcinfo = NPC_INFO[npcvnum]
if not npcinfo then
return nil
end
return npcinfo.level
end
function npc.get_level_dif()
local pclevel = pc.get_level()
local npclevel = npc.get_level()
if not pclevel or not npclevel then
return nil
end
return math.max(pclevel, npclevel) - math.min(pclevel, npclevel)
end
ALTERNATIVE_DROP = {
{chance = 5, vnum = 50125, count = 1},
{chance = 5, vnum = 50011, count = 1},
{chance = 5, vnum = 50254, count = 1},
}
Edit in questlib - Explanations :
chance = drop chance in percentages
vnum = item code
count = quantity