• 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 Clone spells?

norrow

Member
Joined
Dec 16, 2012
Messages
129
Reaction score
7
Location
Poland
Hello, can you make a code on the latest version of the engine so that the player can make his own clone? in the sense that such a monster would have the same name and the same outfit?
 
Lua:
local function isWalkable(pos)
    if getTileThingByPos(pos).itemid == 0 then
        return false
    end
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, 2) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end

function onCastSpell(cid, var)
    local anyPos, pos = {x = 0, y = 0, z = 0}, getCreaturePosition(cid)
    local toPos = {
        {x = pos.x + 0, y = pos.y, z = pos.z},
        {x = pos.x - 1, y = pos.y, z = pos.z},
        {x = pos.x, y = pos.y + 1, z = pos.z},
        {x = pos.x, y = pos.y - 1, z = pos.z}
    }

    local maxSummons = 1
    if maxSummons - #getCreatureSummons(cid) > 0 then
        for i = 1, maxSummons - #getCreatureSummons(cid) do
            if not isWalkable(toPos[i]) then
                toPos[i] = pos
            end
            doCombatAreaHealth(0, 0, anyPos, 0, 0, 0, 255)
            doCreateItem(460, 1, anyPos)
            local bunshin = doCreateMonster("Clone", anyPos)
            doConvinceCreature(cid, bunshin)
            ---setCreatureMaxHealth(bunshin, getCreatureMaxHealth(cid))
            ---doCreatureAddHealth(bunshin, getCreatureHealth(cid))
            doSetCreatureOutfit(bunshin, getCreatureOutfit(cid), -1)
            setCreatureName(bunshin, getCreatureName(cid), "a " .. getCreatureName(cid))
            doTeleportThing(bunshin, toPos[i])
            doSendMagicEffect(toPos[i], 3)
           
        end
    else
        return false
    end
    return true
end

In this line
Code:
local bunshin = doCreateMonster("Clone", anyPos)
Clone, is the name of the Monster, you should create a monster with that name.
Also if you happen to get an error, you should add the function
Code:
setCreatureName
in the sources.
 
This is for tfs 1.5?
I posted it for 1.5 and edited it, thinking you wanted it for a low version, here's the one I use.
Lua:
local function isWalkable(pos)
    if getTileThingByPos(pos).itemid == 0 then
        return false
    end
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, 2) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end

function onCastSpell(cid, var)
local creature = Creature(cid)
local cid = creature:getId()
    local anyPos, pos = {x = 0, y = 0, z = 0}, getCreaturePosition(cid)
    local toPos = {
        {x = pos.x + 0, y = pos.y, z = pos.z},
        {x = pos.x - 1, y = pos.y, z = pos.z},
        {x = pos.x, y = pos.y + 1, z = pos.z},
        {x = pos.x, y = pos.y - 1, z = pos.z}
    }
   

    local maxSummons = 1
    if maxSummons - #getCreatureSummons(cid) > 0 then
        for i = 1, maxSummons - #getCreatureSummons(cid) do
            if not isWalkable(toPos[i]) then
                toPos[i] = pos
            end
            doCombatAreaHealth(0, 0, anyPos, 0, 0, 0, 255)
            doCreateItem(460, 1, anyPos)
            local bunshin = doCreateMonster("Bunshin no jutsu", anyPos)
            doConvinceCreature(cid, bunshin)
            --setCreatureMaxHealth(bunshin, getCreatureMaxHealth(cid))
            --doCreatureAddHealth(bunshin, getCreatureHealth(cid))
            doSetCreatureOutfit(bunshin, getCreatureOutfit(cid), -1)
            setCreatureName(bunshin, getCreatureName(cid), "a " .. getCreatureName(cid))
            doTeleportThing(bunshin, toPos[i])
            doSendMagicEffect(toPos[i], 1109)
           
        end
    else
    creature:sendCancelMessage("You already have the maximum of clones, use [Kai no Jutsu] to undo.")
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You already have the maximum of clones, use [Kai no Jutsu] to undo.")
    creature:getPosition():sendMagicEffect(3)
        return false
    end
    return true
end
 
Back
Top