ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
- Joined
- Dec 17, 2011
- Messages
- 1,713
- Solutions
- 31
- Reaction score
- 965
- Location
- Santiago - Chile
- GitHub
- ralke23
- Twitch
- ralke23
Hi again! I use TFS 1.5 downgrades 8.6 (based on nekiro) and I need help modifying my enchanting script.
Request (modify the following script)
there should be some local variable that identifies the item onUse, taking it from table such as happens here:
in some point the script knows it is 8906, or 8907, 8909 or 8909 and then assigns the
so how could it be like
and call it on
If you want to access rainbow shields number for min, from that example, it would be exactly like this
but how could I automate the selection from the table, so it already knows which type of combat and item id is it? like replacing the 8905 and the combat_firedamage with a local function that recognize which item is going to be the outcome (I think the script already does it somewhere)
Thanks in advance
Regards!
Request (modify the following script)
LUA:
local items = {
equipment = {
[2147] = { -- small ruby
[COMBAT_FIREDAMAGE] = {id = 2343, targetId = 2147} -- helmet of the ancients (enchanted)
},
[2383] = { -- spike sword
[COMBAT_FIREDAMAGE] = {id = 7744}, [COMBAT_ICEDAMAGE] = {id = 7763},
[COMBAT_EARTHDAMAGE] = {id = 7854}, [COMBAT_ENERGYDAMAGE] = {id = 7869}
},
[2391] = { -- war hammer
[COMBAT_FIREDAMAGE] = {id = 7758}, [COMBAT_ICEDAMAGE] = {id = 7777},
[COMBAT_EARTHDAMAGE] = {id = 7868}, [COMBAT_ENERGYDAMAGE] = {id = 7883}
},
[2423] = { -- clerical mace
[COMBAT_FIREDAMAGE] = {id = 7754}, [COMBAT_ICEDAMAGE] = {id = 7773},
[COMBAT_EARTHDAMAGE] = {id = 7864}, [COMBAT_ENERGYDAMAGE] = {id = 7879}
},
[2429] = { -- barbarian axe
[COMBAT_FIREDAMAGE] = {id = 7749}, [COMBAT_ICEDAMAGE] = {id = 7768},
[COMBAT_EARTHDAMAGE] = {id = 7859}, [COMBAT_ENERGYDAMAGE] = {id = 7874}
},
[2430] = { -- knight axe
[COMBAT_FIREDAMAGE] = {id = 7750}, [COMBAT_ICEDAMAGE] = {id = 7769},
[COMBAT_EARTHDAMAGE] = {id = 7860}, [COMBAT_ENERGYDAMAGE] = {id = 7875}
},
[2445] = { -- crystal mace
[COMBAT_FIREDAMAGE] = {id = 7755}, [COMBAT_ICEDAMAGE] = {id = 7774},
[COMBAT_EARTHDAMAGE] = {id = 7865}, [COMBAT_ENERGYDAMAGE] = {id = 7880}
},
[2454] = { -- war axe
[COMBAT_FIREDAMAGE] = {id = 7753}, [COMBAT_ICEDAMAGE] = {id = 7772},
[COMBAT_EARTHDAMAGE] = {id = 7863}, [COMBAT_ENERGYDAMAGE] = {id = 7878}
},
[7380] = { -- headchopper
[COMBAT_FIREDAMAGE] = {id = 7752}, [COMBAT_ICEDAMAGE] = {id = 7771},
[COMBAT_EARTHDAMAGE] = {id = 7862}, [COMBAT_ENERGYDAMAGE] = {id = 7877}
},
[7383] = { -- relic sword
[COMBAT_FIREDAMAGE] = {id = 7745}, [COMBAT_ICEDAMAGE] = {id = 7764},
[COMBAT_EARTHDAMAGE] = {id = 7855}, [COMBAT_ENERGYDAMAGE] = {id = 7870}
},
[7384] = { -- mystic blade
[COMBAT_FIREDAMAGE] = {id = 7746}, [COMBAT_ICEDAMAGE] = {id = 7765},
[COMBAT_EARTHDAMAGE] = {id = 7856}, [COMBAT_ENERGYDAMAGE] = {id = 7871}
},
[7389] = { -- heroic axe
[COMBAT_FIREDAMAGE] = {id = 7751}, [COMBAT_ICEDAMAGE] = {id = 7770},
[COMBAT_EARTHDAMAGE] = {id = 7861}, [COMBAT_ENERGYDAMAGE] = {id = 7876}
},
[7392] = { -- orcish maul
[COMBAT_FIREDAMAGE] = {id = 7757}, [COMBAT_ICEDAMAGE] = {id = 7776},
[COMBAT_EARTHDAMAGE] = {id = 7867}, [COMBAT_ENERGYDAMAGE] = {id = 7882}
},
[7402] = { -- dragon slayer
[COMBAT_FIREDAMAGE] = {id = 7748}, [COMBAT_ICEDAMAGE] = {id = 7767},
[COMBAT_EARTHDAMAGE] = {id = 7858}, [COMBAT_ENERGYDAMAGE] = {id = 7873}
},
[7406] = { -- blacksteel sword
[COMBAT_FIREDAMAGE] = {id = 7747}, [COMBAT_ICEDAMAGE] = {id = 7766},
[COMBAT_EARTHDAMAGE] = {id = 7857}, [COMBAT_ENERGYDAMAGE] = {id = 7872}
},
[7415] = { -- cranial basher
[COMBAT_FIREDAMAGE] = {id = 7756}, [COMBAT_ICEDAMAGE] = {id = 7775},
[COMBAT_EARTHDAMAGE] = {id = 7866}, [COMBAT_ENERGYDAMAGE] = {id = 7881}
},
[8905] = { -- rainbow shield
[COMBAT_FIREDAMAGE] = {id = 8906}, [COMBAT_ICEDAMAGE] = {id = 8907},
[COMBAT_EARTHDAMAGE] = {id = 8909}, [COMBAT_ENERGYDAMAGE] = {id = 8908}
},
[9949] = { -- dracoyle statue
[COMBAT_EARTHDAMAGE] = {id = 9948} -- dracoyle statue (enchanted)
},
[9954] = { -- dracoyle statue
[COMBAT_EARTHDAMAGE] = {id = 9953} -- dracoyle statue (enchanted)
},
[10022] = { -- worn firewalker boots
[COMBAT_FIREDAMAGE] = {id = 9933, say = {text = "Quitate las botas antes de encantarlas."}},
slot = {type = CONST_SLOT_FEET, check = true}
},
[24718] = { -- werewolf helmet
[COMBAT_NONE] = {
id = {
[SKILL_CLUB] = {id = 24783},
[SKILL_SWORD] = {id = 24783},
[SKILL_AXE] = {id = 24783},
[SKILL_DISTANCE] = {id = 24783},
[SKILL_MAGLEVEL] = {id = 24783}
},
effects = {failure = CONST_ME_POFF, success = CONST_ME_THUNDER},
message = {text = "The helmet cannot be enchanted while worn."},
usesStorage = true
},
slot = {type = CONST_SLOT_HEAD, check = true}
},
charges = 1000, effect = CONST_ME_MAGIC_RED
},
valuables = {
[2146] = {id = 7759, shrine = {7508, 7509, 7510, 7511}}, -- small sapphire
[2147] = {id = 7760, shrine = {7504, 7505, 7506, 7507}}, -- small ruby
[2149] = {id = 7761, shrine = {7516, 7517, 7518, 7519}}, -- small emerald
[2150] = {id = 7762, shrine = {7512, 7513, 7514, 7515}}, -- small amethyst
soul = 2, mana = 300, effect = CONST_ME_HOLYDAMAGE
},
[2342] = {combatType = COMBAT_FIREDAMAGE, targetId = 2147}, -- helmet of the ancients
[7759] = {combatType = COMBAT_ICEDAMAGE}, -- small enchanted sapphire
[7760] = {combatType = COMBAT_FIREDAMAGE}, -- small enchanted ruby
[7761] = {combatType = COMBAT_EARTHDAMAGE}, -- small enchanted emerald
[7762] = {combatType = COMBAT_ENERGYDAMAGE}, -- small enchanted amethyst
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:isItem() then
return false
end
local itemId, targetId = item:getId(), target:getId()
local targetType = items.valuables[itemId] or items.equipment[items[itemId].targetId or targetId]
if not targetType then
return false
end
if targetType.shrine then
if not table.contains(targetType.shrine, targetId) then
player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
return true
end
if player:getMana() < items.valuables.mana then
player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
return true
end
if player:getSoul() < items.valuables.soul then
player:sendCancelMessage(RETURNVALUE_NOTENOUGHSOUL)
return true
end
player:addSoul(-items.valuables.soul)
player:addMana(-items.valuables.mana)
player:addManaSpent(items.valuables.mana)
player:addItem(targetType.id)
player:getPosition():sendMagicEffect(items.valuables.effect)
--player:sendSupplyUsed(item)
item:remove(1)
else
local targetItem = targetType[items[itemId].combatType]
if not targetItem or targetItem.targetId and targetItem.targetId ~= targetId then
return false
end
local isInSlot = targetType.slot and targetType.slot.check and target:getType():usesSlot(targetType.slot.type) and Player(target:getParent())
if isInSlot then
if targetItem.say then
player:say(targetItem.say.text, TALKTYPE_MONSTER_SAY)
return true
elseif targetItem.message then
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, targetItem.message.text)
else
return false
end
else
if targetItem.targetId then
item:transform(targetItem.id)
item:decay()
--player:sendSupplyUsed(target)
target:remove(1)
else
if targetItem.usesStorage then
local vocationId = player:getVocation():getDemotion():getId()
local storage = storages[itemId] and storages[itemId][targetId] and storages[itemId][targetId][vocationId]
if not storage then
return false
end
local storageValue = player:getStorageValue(storage.key)
if not storageValue then
return false
end
local transform = targetItem.id and targetItem.id[storageValue]
if not transform then
return false
end
target:transform(transform.id)
-- Local level
local minLevel = 55
local maxLevel = 75
local randomLevel = math.random(minLevel, maxLevel)
-- ItemLevel
target:setItemLevel(randomLevel, false)
target:setRarity(COMMON)
-- Roll
local itemType = ItemType(transform.id)
local weaponType = itemType:getWeaponType()
target:rollAttribute(player, itemType, weaponType, true)
--target:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
else
target:transform(targetItem.id)
-- Local level
local minLevel = 55
local maxLevel = 75
local randomLevel = math.random(minLevel, maxLevel)
-- ItemLevel
target:setItemLevel(randomLevel, false)
target:setRarity(COMMON)
-- Roll
local itemType = ItemType(targetItem.id)
local weaponType = itemType:getWeaponType()
target:rollAttribute(player, itemType, weaponType, true)
--target:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
end
if target:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
target:decay()
end
if target:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
target:setAttribute(ITEM_ATTRIBUTE_CHARGES, items.equipment.charges)
end
--player:sendSupplyUsed(item)
item:remove(1)
end
end
player:getPosition():sendMagicEffect(targetItem.effects and (isInSlot and targetItem.effects.failure or targetItem.effects.success) or items.equipment.effect)
end
return true
end
there should be some local variable that identifies the item onUse, taking it from table such as happens here:
LUA:
[8905] = { -- rainbow shield
[COMBAT_FIREDAMAGE] = {id = 8906}, [COMBAT_ICEDAMAGE] = {id = 8907},
[COMBAT_EARTHDAMAGE] = {id = 8909}, [COMBAT_ENERGYDAMAGE] = {id = 8908}
},
LUA:
target:setItemLevel(randomLevel, false)
target:setRarity(COMMON)
so how could it be like
LUA:
[8905] = { -- rainbow shield
[COMBAT_FIREDAMAGE] = {id = 8906, min = 50, max = 100}, [COMBAT_ICEDAMAGE] = {id = 8907, min = 50, max = 100},
[COMBAT_EARTHDAMAGE] = {id = 8909, min = 50, max = 100}, [COMBAT_ENERGYDAMAGE] = {id = 8908, min = 50, max = 100}
},
and call it on
LUA:
local minLevel = 55 --- use min from table instead
local maxLevel = 75 --- use max from table instead
local randomLevel = math.random(minLevel, maxLevel)
If you want to access rainbow shields number for min, from that example, it would be exactly like this
LUA:
items.equipment[8905][COMBAT_FIREDAMAGE].min
Thanks in advance
Regards!
Last edited: