slaw
Software Developer
Idea by: Cocoamonkey
Works only with TFS 0.3!
How it looks in game:
How it works.
Player must kill specified monsters. For every x kills with specified weapon, weapon gets additional extra attack points.
Max extra attack can be limited, so players wont get to much powerful weapons!
1. data/creaturescripts/scripts/monster_weapon_upgrade.lua
2. data/creaturescripts/creaturescripts.xml
3. Add this at bottom of your login.lua (before return TRUE)
Works only with TFS 0.3!
How it looks in game:
How it works.
Player must kill specified monsters. For every x kills with specified weapon, weapon gets additional extra attack points.
Max extra attack can be limited, so players wont get to much powerful weapons!
1. data/creaturescripts/scripts/monster_weapon_upgrade.lua
Code:
--[[
** Monster weapon upgrader by slawkens **
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
]]--
local monsters = {
["rat"] = {
[2395] = {
kills = 30,
extraAttack = 1,
extraAttackLimit = 3,
storage = 34000
}
},
["dragon"] = {
[2383] = {
kills = 500,
extraAttack = 1,
extraAttackLimit = 20,
storage = 34001
}
}
}
if(not getItemExtraAttack) then
if(not getItemAttribute) then
print("ERROR: (monster_weapon_upgrade.lua) your distribution is not supported!")
return false
end
function getItemExtraAttack(uid)
return getItemAttribute(uid, "extraattack")
end
function setItemExtraAttack(uid, extraAttack)
doItemSetAttribute(uid, "extraattack", extraAttack)
return true
end
end
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(not killedMonsters or 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 +" .. (currentExtraAttack + weapon.extraAttack) .. " points!")
end
setPlayerStorageValue(cid, weapon.storage, killedMonsters + 1)
return TRUE
end
2. data/creaturescripts/creaturescripts.xml
Code:
<event type="kill" name="MonstersWeaponUpgrade" event="script" value="monster_weapon_upgrade.lua"/>
3. Add this at bottom of your login.lua (before return TRUE)
Code:
registerCreatureEvent(cid, "MonstersWeaponUpgrade")
Last edited: