alejandro762
Well-Known Member
- Joined
- Sep 6, 2021
- Messages
- 225
- Reaction score
- 63
Hello,
I am using this script, ( something very similar posted already on forum with "sucess" and "fail" method ) i cannot find right now the post
Here is the code,
Do not pay attention about 'fail', that's normal the script got 300+ id, i have deleted all Id's to cet a small script here,
The script is working like a charm,
I Want add a "ITEM_ATTRIBUTE_DESCRIPTION' with target:getDescription(), is working too but it show"s x2 Times the same Text i wish to know how to show It only one time, since i think im calling two times target, but i dont know why write there i tried upgradeId, itemEx, uid, item, keyConfig..
I added this line:
And i got , this: ( Some Description, is the <attribute key="description" value="Some Description" /> from items.xml )
I wish get The description from items.xml + the description who has upgraded the item.
I am using this script, ( something very similar posted already on forum with "sucess" and "fail" method ) i cannot find right now the post
Action - [TFS 0.4/1.2] Tier upgrading system
This is a simple script that is able to support multiple upgrader itemids without having to make a script for every single id. edit: updated for tfs 1.2 Basic layout for each upgrader id [UpgraderID] = {tier = x, upgraderType = 'str', chance = y, items = { [StartID] = NewID }...
otland.net
Here is the code,
Do not pay attention about 'fail', that's normal the script got 300+ id, i have deleted all Id's to cet a small script here,
The script is working like a charm,
I Want add a "ITEM_ATTRIBUTE_DESCRIPTION' with target:getDescription(), is working too but it show"s x2 Times the same Text i wish to know how to show It only one time, since i think im calling two times target, but i dont know why write there i tried upgradeId, itemEx, uid, item, keyConfig..
I added this line:
target:setAttribute( ITEM_ATTRIBUTE_DESCRIPTION, target:getDescription().."\nRefined by "..player:getName()..".")
And i got , this: ( Some Description, is the <attribute key="description" value="Some Description" /> from items.xml )
I wish get The description from items.xml + the description who has upgraded the item.
Code:
16:03 You see a Excalibur Wand +5 (damage reflect: 5% all elements, critical hit chance 8%, critical extra damage +8%, magic level +7, protection physical +8%, holy +8%, death +8%).
It can only be wielded properly by sorcerers and druids of level 300 or higher.
Imbuements: (Empty Slot, Empty Slot, Empty Slot).
It weighs 33.00 oz.
a Excalibur Wand +5 (damage reflect: 5% all elements, critical hit chance 8%, critical extra damage +8%, magic level +7, protection physical +8%, holy +8%, death +8%).
It can only be wielded properly by sorcerers and druids of level 300 or higher.
Imbuements: (Empty Slot, Empty Slot, Empty Slot).
It weighs 33.00 oz.
Some description.
Refined by GOD.
Code:
local action = Action()
local config = {
messages = {
success = {
text = 'Your item has been upgraded to the next Tier!',
talkType = TALKTYPE_MONSTER_SAY,
effect = CONST_ME_FIREWORK_RED
},
fail = {
text = 'Upgrade Failed.',
talkType = TALKTYPE_MONSTER_SAY,
effect = CONST_ME_POFF
}
},
gear = {
[7865] = {tier = 1, upgraderType = 'rune', chance = 30,
items = {
[42033] = 40804,
},
},
}
}
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
-- Using player's position if the target item is located in a container, otherwise use the item's position located on the map
local pos = target:getPosition().x == 65535 and player:getPosition() or target:getPosition()
-- Make sure the player is not attempting to target a creature
if not target:isItem() then
player:sendCancelMessage('You must select an item.')
pos:sendMagicEffect(CONST_ME_POFF)
return true
end
-- Attempt to get the config based on which key id the player is using
local keyConfig = config.gear[item:getId()]
-- Adding article to full item name if possible, ex: "a sword"
local name = (target:getArticle() ~= '') and string.format('%s %s', target:getArticle(), target:getName()) or target:getName()
if keyConfig then
-- Directly attempt to access the item id to upgrade to by indexing the item list with the target item's id
local upgradeId = keyConfig.items[target:getId()]
-- Prevent attempting to upgrade an item that isn't in config
if not upgradeId then
player:sendCancelMessage(string.format('You are unable to upgrade %s with a tier %d %s.', (name == '') and 'this' or name, keyConfig.tier, keyConfig.upgraderType))
pos:sendMagicEffect(CONST_ME_POFF)
return true
end
-- Prevent attempting to upgrade a stackable item that has more than 1 in it's stack
if target:getCount() > 1 then
player:sendCancelMessage('You may only upgrade this item one at a time.')
pos:sendMagicEffect(CONST_ME_POFF)
return true
end
-- Use the "success" table in config if the random value is less than or equal to the chance, otherwise use the "fail" table
local confKey = (math.random(100) <= keyConfig.chance and 'success' or 'fail')
local resultConfig = config.messages[confKey]
pos:sendMagicEffect(resultConfig.effect)
player:say(resultConfig.text, resultConfig.talkType)
if confKey == 'success' then
target:transform(upgradeId)
target:setAttribute( ITEM_ATTRIBUTE_DESCRIPTION, target:getDescription().."\nRefined by "..player:getName()..".")
end
if confKey == 'fail' and target.itemid == 40804 then
target:transform(42033)
end
item:remove(1)
end
return true
end
for keyId, _ in pairs(config.gear) do
action:id(keyId)
end
action:aid(7865, 7866, 7867) -- El item que hara upgrade
action:register()
Last edited: