--[[
** Monster weapon upgrader by slawkens **
** Extra Defense added by Cocoamonkey **
kills - how much monsters must be killed
extraAttack - how much extraAttack points will this weapon get
extraAttackLimit - you can set limit of extraAttack points added
extraDefense - how much extraDefense points will this weapon get
extraDefenseLimit - you can set limit of extraDefense points added
]]--
local monsters = {
["demon"] = {
[7382] = {
kills = 1,
extraAttack = 50,
extraAttackLimit = 800,
extraDefense = 50,
extraDefenseLimit = 800,
storage = 34000
},
[2400] = {
kills = 30,
extraAttack = 1,
extraAttackLimit = 25,
extraDefense = 50,
extraDefenseLimit = 800,
storage = 34001
}
},
["dragon"] = {
[7407] = {
kills = 2,
extraAttack = 2,
extraAttackLimit = 20,
extraDefense = 2,
extraDefenseLimit = 30,
storage = 34003
}
}
}
function onKill(cid, target)
if(isPlayer(target) == TRUE) then
return TRUE
end
local monster = monsters[string.lower(getCreatureName(target))]
if(not monster) then
return TRUE
end
local playerWeapon = getPlayerWeapon(cid, TRUE)
if(playerWeapon.itemid == 0) then
return TRUE
end
local weapon = monster[playerWeapon.itemid]
if(not weapon) then
return TRUE
end
local killedMonsters = getPlayerStorageValue(cid, weapon.storage)
if(killedMonsters == -1) then
killedMonsters = 1
end
local currentExtraAttack = getItemExtraAttack(playerWeapon.uid)
if(killedMonsters % weapon.kills == 0 and currentExtraAttack < weapon.extraAttackLimit) then
setItemExtraAttack(playerWeapon.uid, currentExtraAttack + weapon.extraAttack)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.extraAttack .. " attack points and now have total extra damage of +" .. getItemExtraAttack(playerWeapon.uid) .. " points!")
end
local currentExtraDefense = getItemExtraDefense(playerWeapon.uid)
if(killedMonsters % weapon.kills == 0 and currentExtraDefense < weapon.extraDefenseLimit) then
setItemExtraDefense(playerWeapon.uid, currentExtraDefense + weapon.extraDefense)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations! Your weapon received +" .. weapon.extraDefense .. " defense points and now have total extra defense of +" .. getItemExtraDefense(playerWeapon.uid) .. " points!")
end
setPlayerStorageValue(cid, weapon.storage, killedMonsters + 1)
return TRUE
end