RevScript Revscript SlotsSystem Attributes extras in items

Shuyin

Miembro
LV
23
 
Awards
17
Actualizado Attributes Extra 09/12/2023

--Colocar el Revscript dentro de data/scripts. Creais un archivo .lua y le poneis el nombre que querais y copiais todo lo que hay justo debajo.

-- Creditos: [Adm] SevuOT de tibiaface.com
-- Nota: este sistema fue creado con la intencion de regalarles algo en navidad! feliz navidad!
-- Version: 1.0
-- RECOMENDACIONES: > Si no sabe de lua o scripts, mejor no tocar mucho el script, es delicado a cambios brutos <

-- Objetos con el cual podras añadirle slots a otros objeos
-- Tambien puedes añadir esta funcionalidad a mas de un objeto, solo añadiendo una coma y seguido de la nueva ID
-- Ejemplo: local addSlotItems = { 2160, 2452 }


Código:
local addSlotItems = { 35181 }
local slotAction = Action()
local creatureEvent = CreatureEvent()

-- Libreria para la funcionalidad del sistema
Código:
local Attr = {}
Attr.__index = Attr
Attr.init = function(slot)
 local attr = {}
 setmetatable(attr, Attr)
 attr.name = slot.name
 attr.value = slot.value
 attr.percent = slot.percent
 return attr
end
setmetatable(Attr, {
 __call = function(_, ...) return Attr.init(...) end,
 __eq = function(a, b) return a.name == b.name and a.value == b.value and a.percent == b.percent end
})
local slotLib = {}
slotLib.maxSlots = 3 -- max 10, more get a errors
slotLib.baseSubids = 90
slotLib.cache = {}
slotLib.attributes = {
 { name = "Club", values = { 1, 2, 3 }, percent = false },
 { name = "Sword", values = { 1, 2, 3 }, percent = false },
 { name = "Axe", values = { 1, 2, 3 }, percent = false },
 { name = "Distance", values = { 1, 2 }, percent = false },
 { name = "Shield", values = { 1, 2, 3 }, percent = false },
 { name = "Fishing", values = { 1, 2, 3 }, percent = false },
 { name = "MagicLevel", values = { 1, 2, 3 }, percent = false },
 { name = "CriticalChance", values = { 3, 6, 9 }, percent = false },
 { name = "CriticalAmount", values = { 3, 6, 9 }, percent = false },
 { name = "LifeLeechChance", values = { 3, 6, 9 }, percent = false },
 { name = "LifeLeechAmount", values = { 3, 6, 9 }, percent = false },
 { name = "ManaLeechChance", values = { 3, 6, 9 }, percent = false },
 { name = "ManaLeechAmount", values = { 3, 6, 9 }, percent = false },
 { name = "Speed", values = { 10, 20, 30 }, percent = false },
 { name = "HealthGain", values = { 1, 2, 3 }, percent = false },
 { name = "ManaGain", values = { 1, 2,  3}, percent = false }
}
slotLib.conditions = {
 ["Club"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_CLUB },
 ["Sword"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_SWORD },
 ["Axe"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_AXE },
 ["Distance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_DISTANCE },
 ["Shield"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_SHIELD },
 ["Fishing"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_FISHING },
 ["MagicLevel"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_STAT_MAGICPOINTS },
 ["CriticalChance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_CRITICAL_HIT_CHANCE },
 ["CriticalAmount"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_CRITICAL_HIT_DAMAGE },
 ["LifeLeechChance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_LIFE_LEECH_CHANCE },
 ["LifeLeechAmount"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_LIFE_LEECH_AMOUNT },
 ["ManaLeechChance"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_MANA_LEECH_CHANCE },
 ["ManaLeechAmount"] = { Type = CONDITION_ATTRIBUTES, Attr = CONDITION_PARAM_SKILL_MANA_LEECH_AMOUNT },
 ["Speed"] = { Type = CONDITION_HASTE, Attr = CONDITION_PARAM_SPEED },
 ["HealthGain"] = { Type = CONDITION_REGENERATION, Attr = CONDITION_PARAM_HEALTHGAIN },
 ["ManaGain"] = { Type = CONDITION_REGENERATION, Attr = CONDITION_PARAM_MANAGAIN }
}
slotLib.addItemSlot = function(item)
 local slots = slotLib.getItemSlots(item)
 local replace = #slots >= slotLib.maxSlots
 local slot = slotLib.attributes[math.random(1, #slotLib.attributes)]
 if slot then
 local slotIndex = not replace and #slots + 1 or math.random(1, slotLib.maxSlots)
 local newvalue = slot.values[math.random(1, #slot.values)]
 local oldvalue = replace and slots[slotIndex].value or newvalue
 slots[slotIndex] = {
 name = slot.name,
 value = not slot.percent and newvalue,
 valuePercent = slot.percent and newvalue
 }
 slotLib.setItemSlots(item, slots)
 return newvalue >= oldvalue
 end
end
slotLib.getItemSlots = function(item)
 local slots = {}
 for slot in string.gmatch(Item.getDescription(item), "(%[.-%])") do
 local name = string.match(slot, "%[(%a+)%p")
     local value = tonumber(string.match(slot, "%p(%d+)%]"))
     local valuePercent = tonumber(string.match(slot, "%p(%d+)%%+%]"))
     slots[#slots + 1] = {
     name = name,
     value = value,
     valuePercent = valuePercent
     }
 end
 return slots
end
slotLib.setItemSlots = function(item, slots)
 local description = ItemType.getDescription(ItemType(Item.getId(item))) or ""
 for _, slot in pairs(slots) do
 description = string.format("%s[%s+%u%s]%s", description, slot.name, slot.value or slot.valuePercent, slot.valuePercent and "%" or "", _ == #slots and "" or "\n")
 end
 return Item.setAttribute(item, ITEM_ATTRIBUTE_DESCRIPTION, description)
end
slotLib.autoDetection = function(playerId)
 local player = Player(playerId)
 if player then
 if not slotLib.cache[playerId] then
 slotLib.cache[playerId] = {}
 end
 for slot = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
 local item = player:getSlotItem(slot)
 if item then
 local slots = slotLib.getItemSlots(item)
 slotLib.onSlotEquip(player, slots, slot)
 if #slots < slotLib.maxSlots then
 for index = #slots+1, slotLib.maxSlots do
 local subid = slotLib.baseSubids + slot + (CONST_SLOT_AMMO * index)
 player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, subid, true)
 player:removeCondition(CONDITION_HASTE, CONDITIONID_DEFAULT, subid, true)
 player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, subid, true)
 end
 end
 else
 for index = 1, slotLib.maxSlots do
 local subid = slotLib.baseSubids + slot + (CONST_SLOT_AMMO * index)
 player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, subid, true)
 player:removeCondition(CONDITION_HASTE, CONDITIONID_DEFAULT, subid, true)
 player:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, subid, true)
 end
 end
 end
 addEvent(slotLib.autoDetection, 100, playerId)
 else
 slotLib.cache[playerId] = nil
 end
end
slotLib.onSlotEquip = function(player, slots, slotIndex)
 for index, slot in pairs(slots) do
 local attr = Attr(slot)
 local subid = slotLib.baseSubids + slotIndex + (CONST_SLOT_AMMO * index)
 if not slotLib.cache[player.uid][subid] or slotLib.cache[player.uid][subid] ~= attr then
 if slotLib.cache[player.uid][subid] and slotLib.cache[player.uid][subid] ~= attr then
 player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, subid, true)
 player:removeCondition(CONDITION_HASTE, CONDITIONID_DEFAULT, subid, true)
 end
 local info = slotLib.conditions[attr.name]
 if info then
 local condition = Condition(info.Type, CONDITIONID_DEFAULT)
 if condition then
 condition:setParameter(info.Attr, attr.value)
 condition:setParameter(CONDITION_PARAM_TICKS, -1)
 condition:setParameter(CONDITION_PARAM_SUBID, subid)
 player:addCondition(condition)
 slotLib.cache[player.uid][subid] = attr
 end
 end
 end
 end
end
slotLib.isUpgradeable = function(item)
    local it = ItemType(item.itemid)
    return it:getWeaponType() ~= WEAPON_NONE or it:getSpeed() or it:getArmor() > 0 or it:getDefense() > 0 or it:getExtraDefense() > 0 or it:getAttack() > 0
   end
function slotAction.onUse(player, item, fromPos, target, toPos, isHotkey)
 if not target or not target:isItem() then
 return player:sendCancelMessage("Sorry not possible, only work on items.")
 end
 if not slotLib.isUpgradeable(target) then
 return player:sendCancelMessage("Sorry not possible, this item cannot update slots.")
 end
 local greatz = slotLib.addItemSlot(target)
 target:getPosition():sendMagicEffect(greatz and CONST_ME_FIREWORK_RED or CONST_ME_FIREWORK_BLUE)
 player:say(greatz and "Perfect!" or "Bad!")
 item:remove(1)
 return true
end
  
slotAction:id(addSlotItems[1])
slotAction:register()
function creatureEvent.onLogin(player)
 slotLib.autoDetection(player.uid)
 return true
end
creatureEvent:register()
 
Última edición:

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
¡Felicitaciones, su Tema ha sido aprobado!
Muchas gracias por tu contribución, nosotros en Open Games Community te agradecemos.
Tu contenido seguramente ayudará a muchos otros, has ganado +1 Like.
 

Evodrael

Miembro
LV
1
 
Awards
2
A lot of time has passed, but I would like to know if we have an updated version for the current Canary base?
 

Damian1234

Miembro
LV
14
 
Awards
15
Esta increible para Exodus TFS 1.4, todo funciona perfecto a expcecion de los atributos de:

CriticalChance
CriticalAmount
LifeLeechChance
LifeLeechAmount
ManaLeechChance
ManaLeechAmount

No se editan dentro del juego
 

Adjuntos

  • Captura de pantalla 2023-12-20 152830.png
    Captura de pantalla 2023-12-20 152830.png
    7 KB · Visitas: 9
  • Captura de pantalla 2023-12-20 152929.png
    Captura de pantalla 2023-12-20 152929.png
    179,1 KB · Visitas: 9

Damian1234

Miembro
LV
14
 
Awards
15
Esta increible para Exodus TFS 1.4, todo funciona perfecto a expcecion de los atributos de:

CriticalChance
CriticalAmount
LifeLeechChance
LifeLeechAmount
ManaLeechChance
ManaLeechAmount

No se editan dentro del juego

Actualizo, con TFS 1.4 Exodus hay que cambiar esos por: CONDITION_PARAM_SPECIALSKILL
 

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Actualizo, con TFS 1.4 Exodus hay que cambiar esos por: CONDITION_PARAM_SPECIALSKILL
Hola,

Exactamente, el revscript fué creado para canary, de base.
Entre TFS y Canary hay varios codigos y cosas script distintamente, todos esos skills son "Especiales" por lo cual se llaman CONDITION_PARAM_SPECIALSKILL en sources y asi se llaman.
 

misaki1124

Miembro
LV
7
 
Awards
5
Hola,

Exactamente, el revscript fué creado para canary, de base.
Entre TFS y Canary hay varios codigos y cosas script distintamente, todos esos skills son "Especiales" por lo cual se llaman CONDITION_PARAM_SPECIALSKILL en sources y asi se llaman.
para agregarle un condition_attribute ( como que los monsters dropen o te den mas exp con esos stats ) como se podria agregar ?
 

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
para agregarle un condition_attribute ( como que los monsters dropen o te den mas exp con esos stats ) como se podria agregar ?
Descarga Visual Studio Code ,
Busca algo en tu servidor que haga de exp , como el boost , mira como se llama para incrementar la exp , o bien por storages , descargas hellgrave v6 que es gratis y miras en visual studio el dragon cryptic egg , que da exp incrementado.
 

misaki1124

Miembro
LV
7
 
Awards
5
Descarga Visual Studio Code ,
Busca algo en tu servidor que haga de exp , como el boost , mira como se llama para incrementar la exp , o bien por storages , descargas hellgrave v6 que es gratis y miras en visual studio el dragon cryptic egg , que da exp incrementado.
No me aparecio el monster o archivo que mencionastes, tengo una duda para configurar ese script para que no se repitan los atributos (
20:51 You see a jester staff.
It can only be wielded properly by sorcerers and druids of level 1 or higher.
It weighs 7.25 oz.
[HealthGain+1]
[ManaGain+1]
[HealthGain+3]
 

bonas

Miembro
LV
16
 
Awards
8
Buenas noches, quería saber si este sistema es compatible con tfs 1.5 nekiro downgrade 8.60?
 

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Buenas noches, quería saber si este sistema es compatible con tfs 1.5 nekiro downgrade 8.60?
Hola ,

Debería de serlo , pero para Life/mana/crit hay que mirar si es correcto o es como tfs param skill special.
 
Arriba