• 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!

doCreatureCastSpell() tfs 1.3revscript

RigBy

Member
Joined
Jun 9, 2015
Messages
44
Solutions
1
Reaction score
6
is there any version of "doCreatureCastSpell()" for tfs 1.3 revscript? if not, can you give me an idea of how to make an item when on.use, use a spell
 
Solution
If you only need it for a minimum number of spells, you can embed a global function in the file of the spell you want to execute and then call this function
example
1627611008027.png

and then you call this function to execute the power, for example:
You can pass as a variant, a position or a creature ID
Lua:
doExoriFrigo(player, player:getPosition() + Position(-2, 0, 0))
doExoriFrigo(player, Creature("Monk"):getId())
GIF 29-07-2021 10-15-11 p. m..gif


But if you are looking to execute many spells this is not the most organized and perfect way to do it, you will have to modify the sources, but I give you this option to get out of a problem quickly
If you only need it for a minimum number of spells, you can embed a global function in the file of the spell you want to execute and then call this function
example
1627611008027.png

and then you call this function to execute the power, for example:
You can pass as a variant, a position or a creature ID
Lua:
doExoriFrigo(player, player:getPosition() + Position(-2, 0, 0))
doExoriFrigo(player, Creature("Monk"):getId())
GIF 29-07-2021 10-15-11 p. m..gif


But if you are looking to execute many spells this is not the most organized and perfect way to do it, you will have to modify the sources, but I give you this option to get out of a problem quickly
 
Solution
If you only need it for a minimum number of spells, you can embed a global function in the file of the spell you want to execute and then call this function
example
View attachment 60729

and then you call this function to execute the power, for example:
You can pass as a variant, a position or a creature ID
Lua:
doExoriFrigo(player, player:getPosition() + Position(-2, 0, 0))
doExoriFrigo(player, Creature("Monk"):getId())
View attachment 60730


But if you are looking to execute many spells this is not the most organized and perfect way to do it, you will have to modify the sources, but I give you this option to get out of a problem quickly



I did it that way here, I don't know if it's the most viable way :/. Can you tell me if using storage nowadays to keep track of things is still viable or in this situation I should use something else? if you can, look at the script and talk about where you could improve, what would you do.
thanks

Lua:
local wandOfDragonbreath = Action()

local combat = {}

arr = {
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 2, 0, 0, 0},
    {0, 0, 0, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
},
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 1, 0, 0, 0, 0, 0},
    {0, 1, 1, 2, 0, 0, 0},
    {0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
},
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 0, 0, 0},
    {0, 0, 0, 2, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
},
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0},
    {0, 0, 0, 2, 1, 1, 0},
    {0, 0, 0, 0, 0, 1, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
}}

for i = 1, #arr do
    combat[i] = Combat()
    combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combat[i]:setParameter(COMBAT_PARAM_EFFECT, 16)
    combat[i]:setFormula(COMBAT_FORMULA_SKILL, 1, 1, 1, 1)
    combat[i]:setArea(createCombatArea(arr[i]))
end

local config = {
    time = 4,
    storage = 2000001,
}


function wandOfDragonbreath.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local slot = 6
    local getslot =  Item(getPlayerSlotItem(player, slot).uid)
    
    if  player:getStorageValue(config.storage) - os.time() > 0 then
        return player:sendCancelMessage("você só pode usar o item depois de "..(player:getStorageValue(config.storage) - os.time()).." segundos.")
    end
    
    if getslot ~= nil then
        if getslot:getId() == 2191 then
            for i = 1, 4 do
                if player:getDirection() == (i - 1) then
                    combat[i]:execute(player, Variant(player:getPosition()))
                    player:setStorageValue(config.storage, os.time() + config.time)
                end
            end
        end   
    else
        player:sendCancelMessage("Item precisa está equipado para usar.")
    end
    return true
end



wandOfDragonbreath:id(2191)
wandOfDragonbreath:register()
 
Try to become familiar with the metamethods and not use compatibility functions if you want to improve in scripting.

Here a little shorter the script, to serve as an example:
Lua:
local wandOfDragonbreath = Action()
local combats = {}
local arr = {
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 2, 0, 0, 0},
    {0, 0, 0, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
},
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 1, 0, 0, 0, 0, 0},
    {0, 1, 1, 2, 0, 0, 0},
    {0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
},
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 0, 0, 0},
    {0, 0, 0, 2, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
},
{
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0},
    {0, 0, 0, 2, 1, 1, 0},
    {0, 0, 0, 0, 0, 1, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0}
}}

for i = 1, #arr do
    combats[i] = Combat()
    combats[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
    combats[i]:setParameter(COMBAT_PARAM_EFFECT, 16)
    combats[i]:setFormula(COMBAT_FORMULA_SKILL, 1, 1, 1, 1)
    combats[i]:setArea(createCombatArea(arr[i]))
end

local config = {
    time = 4,
    storage = 2000001,
}

function wandOfDragonbreath.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if  player:getStorageValue(config.storage) - os.time() > 0 then
        return player:sendCancelMessage("você só pode usar o item depois de "..(player:getStorageValue(config.storage) - os.time()).." segundos.")
    end
    
    local slotItem = player:getSlotItem(CONST_SLOT_LEFT)
    if slotItem and item == slotItem then
        combats[player:getDirection() +1]:execute(player, Variant(player:getPosition()))
        player:setStorageValue(config.storage, os.time() + config.time)
    else
        player:sendCancelMessage("Item precisa está equipado para usar.")
    end
    return true
end

wandOfDragonbreath:id(2191)
wandOfDragonbreath:register()

You did a good job anyway ;), keep it up
 
Back
Top