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

summon creature in target position

xoiox

New Member
Joined
Aug 20, 2009
Messages
46
Reaction score
2
Hi, I've made a script which changes a one creature to other. And problem is the creature appears next to target. I want to do that new monster appears in place of disappearing target.
My event looks like this:
Code:
function change(cid, var)
doSummonCreature("Boar", getCreaturePosition(cid))
doRemoveCreature(cid)
end

This code is for target, not a player. So script first creates "Boar" next to target and in this moment target disappears. How to save target position and put there "Boar"? Help :(

PS. I use TFS 1.2
 
Last edited:
Yes, it's a spell:
Code:
function onCastSpell(cid, var, position)
chance = math.random(0, 100)
     if(chance > 60) then
addEvent(czary, 1, getCreatureTarget(cid))
doSendMagicEffect(getCreatureTarget(cid),11)
doSendMagicEffect(getCreaturePosition(cid),13)
else
doPlayerSendCancel(cid, "You have failed change this creature.")
doSendMagicEffect(getCreaturePosition(cid),3)
doSendMagicEffect(getCreatureTarget(cid),3)
return true
end
return true
end

function czary(cid, var)
doSummonCreature("Boar", getCreaturePosition(cid))
doRemoveCreature(cid)
end
 
Code:
local function revert(target)
    Game.createMonster("Boar", target:getPosition())
    target:remove()
end

function onCastSpell(creature, variant, isHotkey)
    local randomValue = math.random(0, 100)
    if(randomValue > 60) then
        local target = creature:getTarget()
        if(not target) then
            return false
        end

        addEvent(revert, 1, target)
        target:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    else
        creature:sendCancelMessage("You have failed change this creature.")
        target:getPosition():sendMagicEffect(CONST_ME_POFF)
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
@WibbenZ, it doesn't work for me :(
ou9le8.jpg
 
Sorry fail by me
Code:
local function revert(targetId)
    local target = Creature(targetId)
    if(target ~= nil) then
        Game.createMonster("Boar", target:getPosition())
        target:remove()
    end
end

function onCastSpell(creature, variant, isHotkey)
    local target = creature:getTarget()
    if(not target) then
        return false
    end

    local randomValue = math.random(0, 100)
    if(randomValue > 60) then
        addEvent(revert, 1, target:getId())
        target:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    else
        creature:sendCancelMessage("You have failed change this creature.")
        target:getPosition():sendMagicEffect(CONST_ME_POFF)
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
This script works, but still boar appears in place next to, when monster disappears. It won't be big problem, but in case if obstacles are around of the monter, and when use this spell, monster just disappears and boar don't appears nowhere.
 
Code:
function onCastSpell(creature, variant, isHotkey)
    local target = creature:getTarget()
    if not target then
        return false
    end

    if math.random(100) < 60 then
        creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You have failed to change this creature.")
        creature:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    local monster = Game.createMonster("Boar", target:getPosition(), false, true)
    if not monster then
        return false
    end

    creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
    target:remove()
    return true
end
 
Back
Top