-- https://otland.net/members/xikini.102396/
-- https://otland.net/threads/xikinis-free-scripting-service.234306/page-2#post-2262314
local t = {
[{"rat", "cave rat"}] = { -- Monster names = Monsters you can kill in the quest. You can use as little or as many as you want.
started = 45001, -- started = Storage value Required to start the quest. (given by an npc for example)
storage = 45002, -- storage = Storage used for counting how many kills have been achieved.
kills = 30, -- kills = how many monsters must be killed to gain reward
raceName = "rats", -- raceName = Whatever you want it to show for the monsters race. "You have defeated 34 out of 50 rodents."
------------- It is recommended to keep raceName all lowercase letters for best effect.
weaponID = 6528, -- weaponID = The itemID of the weapon you wish the player to use for this quest.
newAttack = 100} -- newAttack = What the attack of the weapon will be after finished quest. old: Atk +67 | new: Atk +100
-------------- Only works for Melee and Distance weapons
}
function onKill(cid, target, damage, flags)
for v, k in pairs(t) do
local master = getCreatureMaster(target)
if(master and master ~= target) then return true end
if(bit.band(flags, 1) == 1 and isMonster(target) and isInArray(v, getCreatureName(target))) then
if(getCreatureStorage(cid, k.started) == 1) then
if(getCreatureStorage(cid, k.storage) < 0) then
doCreatureSetStorage(cid, k.storage, 0)
end
if getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == k.weaponID then
if getPlayerSlotItem(cid, CONST_SLOT_LEFT).actionid < 1 then
local type = getItemWeaponType(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid)
if type == 1 or type == 2 or type == 3 or type == 4 then
if isItemStackable(k.weaponID) ~= true then
if(getCreatureStorage(cid, k.storage) < k.kills - 1) then
doCreatureSetStorage(cid, k.storage, getCreatureStorage(cid, k.storage) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated " .. getCreatureStorage(cid, k.storage) .. " out of " .. k.kills .. " " .. k.raceName .. "!")
elseif getCreatureStorage(cid, k.storage) == k.kills - 1 then
doSetItemActionId(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid)
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, "attack", k.newAttack)
doItemSetAttribute(getPlayerSlotItem(cid, CONST_SLOT_LEFT).uid, "description", "This item has imbued with special properties for killing " .. k.kills .. " " .. k.raceName .. ". It")
doCreatureSetStorage(cid, k.storage, getCreatureStorage(cid, k.storage) + 1)
doCreatureSetStorage(cid, k.started, getCreatureStorage(cid, k.started) + 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have defeated enough " .. k.raceName .. "! Your weapon has been imbued with special properties. Well done.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error: Item being used in script is stackable. Contact Administration.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error: Incorrect item type being used in script. Contact Administration.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "This item has already been upgraded. Only non-upgraded " .. getItemNameById(k.weaponID) .. "'s can be used.")
end
end
end
end
end
return true
end