• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua TFS 1.3 use animal cure on a cat can reward player with mount

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hi guys,

I would like a script that when the player uses the "animal cure" (flask) on a cat, 4 things can happen:
  • 91% Nothing
  • 5% chance Player receive batcat mount
  • 3% chance Player receive Venompaw mount
  • 1% chance Player receive Flitterkatzen mount
 
Solution
X
Yeah, it's similar, but the other one you used the item and gain a mount, on this one you need to use the item on a monster.
It works, but can you teach me how to put more creatures? For example in the script the player need to use the item on a cat, but what if I would like to use the item on a deer and have a chance to be rewarded with a antilope or Shadow Hart?
Try this
LUA:
local mountItems = {
    [1111] = {targetCreature = "cat", rewardMounts = {
        [{1, 1}] = {rewardMount = 111}, -- between numbers 1 - 1 (aka, 1%) (1)
        [{2, 4}] = {rewardMount = 111}, -- between numbers 2 - 4 (aka, 3%) (2, 3, 4)
        [{5, 9}] = {rewardMount = 111}  -- between numbers 5 - 9 (aka, 5%) (5, 6, 7, 8, 9)...
Oh, this was so similar to the other request I thought it was a duplicate. xD

try this
LUA:
local mountItemId = 11111
local mountChance = {
    [{1, 1}] = {rewardMount = 111}, -- between numbers 1 - 1 (aka, 1%) (1)
    [{2, 4}] = {rewardMount = 111}, -- between numbers 2 - 4 (aka, 3%) (2, 3, 4)
    [{5, 9}] = {rewardMount = 111}  -- between numbers 5 - 9 (aka, 5%) (5, 6, 7, 8, 9)
                                    -- between numbers 10 - 100 (aka, 91%) (do nothing, cuz not in table.)
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isMonster() then
        return true
    end
    if not target:getName():lower() == "cat" then
        return true
    end
    local rand = math.random(100)
    for v, k in pairs(mountChance) do
        if v[1] <= rand and v[2] >= rand then
            if player:hasMount(k.rewardMount) then
                return true
            end
            player:addMount(k.rewardMount)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have received a mount.")
            target:remove()
            return true
        end
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Failed to capture?")
    return true
end

action:id(mountItemId)
action:register()
 
Oh, this was so similar to the other request I thought it was a duplicate. xD

try this
LUA:
local mountItemId = 11111
local mountChance = {
    [{1, 1}] = {rewardMount = 111}, -- between numbers 1 - 1 (aka, 1%) (1)
    [{2, 4}] = {rewardMount = 111}, -- between numbers 2 - 4 (aka, 3%) (2, 3, 4)
    [{5, 9}] = {rewardMount = 111}  -- between numbers 5 - 9 (aka, 5%) (5, 6, 7, 8, 9)
                                    -- between numbers 10 - 100 (aka, 91%) (do nothing, cuz not in table.)
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isMonster() then
        return true
    end
    if not target:getName():lower() == "cat" then
        return true
    end
    local rand = math.random(100)
    for v, k in pairs(mountChance) do
        if v[1] <= rand and v[2] >= rand then
            if player:hasMount(k.rewardMount) then
                return true
            end
            player:addMount(k.rewardMount)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have received a mount.")
            target:remove()
            return true
        end
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Failed to capture?")
    return true
end

action:id(mountItemId)
action:register()
Yeah, it's similar, but the other one you used the item and gain a mount, on this one you need to use the item on a monster.
It works, but can you teach me how to put more creatures? For example in the script the player need to use the item on a cat, but what if I would like to use the item on a deer and have a chance to be rewarded with a antilope or Shadow Hart?
 
Yeah, it's similar, but the other one you used the item and gain a mount, on this one you need to use the item on a monster.
It works, but can you teach me how to put more creatures? For example in the script the player need to use the item on a cat, but what if I would like to use the item on a deer and have a chance to be rewarded with a antilope or Shadow Hart?
Try this
LUA:
local mountItems = {
    [1111] = {targetCreature = "cat", rewardMounts = {
        [{1, 1}] = {rewardMount = 111}, -- between numbers 1 - 1 (aka, 1%) (1)
        [{2, 4}] = {rewardMount = 111}, -- between numbers 2 - 4 (aka, 3%) (2, 3, 4)
        [{5, 9}] = {rewardMount = 111}  -- between numbers 5 - 9 (aka, 5%) (5, 6, 7, 8, 9)
                                        -- between numbers 10 - 100 (aka, 91%) (do nothing, cuz not in table.)
        }
    },
    [2222] = {targetCreature = "deer", rewardMounts = {
        [{1, 1}] = {rewardMount = 111}, -- between numbers 1 - 1 (aka, 1%) (1)
        [{2, 4}] = {rewardMount = 111}, -- between numbers 2 - 4 (aka, 3%) (2, 3, 4)
        [{5, 9}] = {rewardMount = 111}  -- between numbers 5 - 9 (aka, 5%) (5, 6, 7, 8, 9)
                                        -- between numbers 10 - 100 (aka, 91%) (do nothing, cuz not in table.)
        }
    }
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not target:isMonster() then
        return true
    end
    local index = mountItems[item:getId()]
    if not target:getName():lower() == index.targetCreature then
        return true
    end
    local rand = math.random(100)
    for v, k in pairs(index.rewardMounts) do
        if v[1] <= rand and v[2] >= rand then
            if player:hasMount(k.rewardMount) then
                return true
            end
            player:addMount(k.rewardMount)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have received a mount.")
            target:remove()
            return true
        end
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Failed to capture?")
    return true
end

for v, k in pairs(mountItems) do
    action:id(v)
end
action:register()
 
Solution
local mountItems = { [1111] = {targetCreature = "cat", rewardMounts = { [{1, 1}] = {rewardMount = 111}, -- between numbers 1 - 1 (aka, 1%) (1) [{2, 4}] = {rewardMount = 111}, -- between numbers 2 - 4 (aka, 3%) (2, 3, 4) [{5, 9}] = {rewardMount = 111} -- between numbers 5 - 9 (aka, 5%) (5, 6, 7, 8, 9) -- between numbers 10 - 100 (aka, 91%) (do nothing, cuz not in table.) } }, [2222] = {targetCreature = "deer", rewardMounts = { [{1, 1}] = {rewardMount = 111}, -- between numbers 1 - 1 (aka, 1%) (1) [{2, 4}] = {rewardMount = 111}, -- between numbers 2 - 4 (aka, 3%) (2, 3, 4) [{5, 9}] = {rewardMount = 111} -- between numbers 5 - 9 (aka, 5%) (5, 6, 7, 8, 9) -- between numbers 10 - 100 (aka, 91%) (do nothing, cuz not in table.) } } } local action = Action() function action.onUse(player, item, fromPosition, target, toPosition, isHotkey) if not target:isMonster() then return true end local index = mountItems[item:getId()] if not target:getName():lower() == index.targetCreature then return true end local rand = math.random(100) for v, k in pairs(index.rewardMounts) do if v[1] <= rand and v[2] >= rand then if player:hasMount(k.rewardMount) then return true end player:addMount(k.rewardMount) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have received a mount.") target:remove() return true end end player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Failed to capture?") return true end for v, k in pairs(mountItems) do action:id(v) end action:register()
Thank you
 

Similar threads

Replies
0
Views
152
Back
Top