TFS 0.X Imbuements System to 0.4 (8.60)

OP
runsicky

runsicky

Member
Joined
Apr 19, 2018
Messages
68
Best answers
0
Reaction score
11
There is a bug, if i relog with a enchanted boots, with more 500 speed
And remove the boots, the character speed just bug

How to fix it?

Make the same script on a creature script onlogin?
Or there is a best way?

---

Another thing about description...

There is a way to make it more friendly to the players?

Because the item description is a little strange to players, for example:

A boots that still have ibu works:
Code:
16:22 You see steel boots (Arm:5).
It can only be wielded properly by knights.
It weighs 29.00 oz.
swiftness,1565276961

A boots that ibu no work anymore:
Code:
16:26 You see steel boots (Arm:5).
It can only be wielded properly by knights.
It weighs 29.00 oz.
swiftness,1561206837
U guys know a way to make friendly to the players?

---

scripts for now:
movemments:
Code:
-- credits @Xikini / @StreamSide
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   print("player equip an item")
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid

    local itemString = getItemSpecialDescription(item.uid)
    local one, two = itemString:match("([^,]+),([^,]+)")
    print(one)
    print(two)

   -- bonus speed
   if one == "swiftness" and two + 0 > os.time() then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("ENCHANTED ITEM EQUIPED")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("ENCHANTED ITEM UNEQUIPED")
       end
   end
   return true
end

NPC:
Code:
--[[
        CONST_SLOT_FIRST = 1
        CONST_SLOT_HEAD = CONST_SLOT_FIRST
        CONST_SLOT_NECKLACE = 2
        CONST_SLOT_BACKPACK = 3
        CONST_SLOT_ARMOR = 4
        CONST_SLOT_RIGHT = 5
        CONST_SLOT_LEFT = 6
        CONST_SLOT_LEGS = 7
        CONST_SLOT_FEET = 8
        CONST_SLOT_RING = 9
        CONST_SLOT_AMMO = 10
        CONST_SLOT_LAST = CONST_SLOT_AMMO
]]

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic, Description = {}, {}

local thinkMsg = {
        "I can personalise your items, come to me!",
        "Want to upgrade your items temporarily? Come to me!"
}

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                      npcHandler:onThink() end

function greetCallback(cid)
        Topic[cid], Description[cid] = 1, nil
        return true
end

function creatureSayCallback(cid, type, msg)
        if not npcHandler:isFocused(cid) then
                return false
        elseif (Topic[cid] == 1) and (msgcontains(msg, 'yes') or msgcontains(msg, 'imbuement') or msgcontains(msg, 'imbuements')) then
                npcHandler:say('Choose the imbuements type: {swiftness}', cid)
                Topic[cid] = 2
       


        elseif Topic[cid] == 2 and msgcontains(msg, 'swiftness') then
                npcHandler:say('What kinda of weapon you want to upgrade? {boots}', cid)
                Topic[cid] = 17

        -- swiftness
        elseif Topic[cid] == 17 and msgcontains(msg, 'boots') then
                local ib_UID = getPlayerSlotItem(cid, CONST_SLOT_FEET).uid
                -- HOW TO CHECK IF PLAYER IS USING A BOOTS?
                local recipient_itemid = 11219 -- compasses
                local recipient_neededammount = 25
                if(getPlayerItemCount(cid, recipient_itemid) >= recipient_neededammount) then
                        doPlayerRemoveItem(cid,recipient_itemid,recipient_neededammount)
                        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_RED)
                        npcHandler:say('Here you are. May I help you with something else? ', cid)
                        local hours = 60 * 60
                        local time = 20 * hours
                        doSetItemSpecialDescription(ib_UID, "swiftness," .. (os.time() + time) .. "")
                        Topic[cid] = 1
                else
                        npcHandler:say('You do not have the recipients enoght to make the Imbuement! May I help you with something else?', cid)
                        Topic[cid] = 1
                end
        end
        return true
end

npcHandler:setMessage(MESSAGE_FAREWELL, 'I hope you made the right choice, have a wonderful day.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Okay well, I guess you don\'t care if someone steals your stuff... You will have no idea if it\'s yours...')
npcHandler:setMessage(MESSAGE_GREET, 'Hello, |PLAYERNAME|! I am a brander. I can personalize any of your items for a price, would you like to continue to the next step?')

npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
OP
runsicky

runsicky

Member
Joined
Apr 19, 2018
Messages
68
Best answers
0
Reaction score
11
Did u guys know how to convert that time 1565493648
Code:
04:20 You see steel boots (Arm:5). It can only be wielded properly by knights. It weighs 29.00 oz.
It can only be wielded properly by knights.
It weighs 29.00 oz.
swiftness,1565493648
To something like minutes, like softboots is
Code:
04:22 You see a pair of soft boots (Arm:1) that has energy for 239 minutes left.
For players understand what is that

---

I was thinking and there are so many places to check:
  • on enchant the item on npc
  • on login
  • on equip, on unequip
  • after sometime, if the enchant is over (idk how)

Would be better if delete this movemment and check all players items each 1 min?

With a script like:
Code:
-- credits @Xikini / @StreamSide
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemuid
local itemString = getItemSpecialDescription(ibID)


-- add imbu boots speed
if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
   if one == "swiftness" and two + 0 > os.time() then
    doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
    setPlayerStorageValue(cid, feet_IB_storage, 1)
   end
-- remove imbu boots speed
if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
    if one == "swiftness" and two + 0 <= os.time() then
           doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
           setPlayerStorageValue(cid, feet_IB_storage, 0)
    end
end
Idk how to make it work, but the logic is right?
 
Top