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

Solved Remove Creature Spell

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
745
Solutions
9
Reaction score
125
Hello! I've been trying to make a spell that unsummons my summoned creatures. But It's not working at all.. I lag maany skills in programing, so that might be the cause for not working haha.

So, If someone could help me, that would be amazing! Thanks in advance!

Code:
    local maxSummons = 3
    local summonName = "Rotten Flesher"

    function onCastSpell(player, var)
        local summonCount, playerPosition = #player:getSummons(), player:getPosition()
        if summonCount >= maxSummons then
            local summonedCreature = Game.removeMonster(summonName, playerPosition)
            player:sendMessage('You called back your creatures.')
            playerPosition:sendMagicEffect(CONST_ME_POFF)
            return false
        end
        return true
    end
 
I assume this code only removes summons who names are Rotten Flesher and are located under player.

Instead just run trough the userdatas you get from getSummons() and remove them..
 
Im really thanks for taking your time to answer me, but i didnt get anything about what you just said haha! Could you explain me a little more what should i do? I dont know whats the userdatas xD
 
im assuming this function returns table of userdata's
player:getSummons()
and it will look something like that:
{userdata,userdata,userdata,userdata}

userdata is metatable which holds specific parameters to that.
Summon is a creature. So it holds all the information creatures should have. (their position, health, mana, speed, etc)

You can use all these functions on a creature userdata:
Code:
registerMethod("Creature", "registerEvent", LuaScriptInterface::luaCreatureRegisterEvent);
    registerMethod("Creature", "unregisterEvent", LuaScriptInterface::luaCreatureUnregisterEvent);

    registerMethod("Creature", "isRemoved", LuaScriptInterface::luaCreatureIsRemoved);
    registerMethod("Creature", "isCreature", LuaScriptInterface::luaCreatureIsCreature);
    registerMethod("Creature", "isInGhostMode", LuaScriptInterface::luaCreatureIsInGhostMode);
    registerMethod("Creature", "isHealthHidden", LuaScriptInterface::luaCreatureIsHealthHidden);

    registerMethod("Creature", "canSee", LuaScriptInterface::luaCreatureCanSee);
    registerMethod("Creature", "canSeeCreature", LuaScriptInterface::luaCreatureCanSeeCreature);

    registerMethod("Creature", "getParent", LuaScriptInterface::luaCreatureGetParent);

    registerMethod("Creature", "getId", LuaScriptInterface::luaCreatureGetId);
    registerMethod("Creature", "getName", LuaScriptInterface::luaCreatureGetName);

    registerMethod("Creature", "getTarget", LuaScriptInterface::luaCreatureGetTarget);
    registerMethod("Creature", "setTarget", LuaScriptInterface::luaCreatureSetTarget);

    registerMethod("Creature", "getFollowCreature", LuaScriptInterface::luaCreatureGetFollowCreature);
    registerMethod("Creature", "setFollowCreature", LuaScriptInterface::luaCreatureSetFollowCreature);

    registerMethod("Creature", "getMaster", LuaScriptInterface::luaCreatureGetMaster);
    registerMethod("Creature", "setMaster", LuaScriptInterface::luaCreatureSetMaster);

    registerMethod("Creature", "getLight", LuaScriptInterface::luaCreatureGetLight);
    registerMethod("Creature", "setLight", LuaScriptInterface::luaCreatureSetLight);

    registerMethod("Creature", "getSpeed", LuaScriptInterface::luaCreatureGetSpeed);
    registerMethod("Creature", "getBaseSpeed", LuaScriptInterface::luaCreatureGetBaseSpeed);
    registerMethod("Creature", "changeSpeed", LuaScriptInterface::luaCreatureChangeSpeed);

    registerMethod("Creature", "setDropLoot", LuaScriptInterface::luaCreatureSetDropLoot);

    registerMethod("Creature", "getPosition", LuaScriptInterface::luaCreatureGetPosition);
    registerMethod("Creature", "getTile", LuaScriptInterface::luaCreatureGetTile);
    registerMethod("Creature", "getDirection", LuaScriptInterface::luaCreatureGetDirection);
    registerMethod("Creature", "setDirection", LuaScriptInterface::luaCreatureSetDirection);

    registerMethod("Creature", "getHealth", LuaScriptInterface::luaCreatureGetHealth);
    registerMethod("Creature", "addHealth", LuaScriptInterface::luaCreatureAddHealth);
    registerMethod("Creature", "getMaxHealth", LuaScriptInterface::luaCreatureGetMaxHealth);
    registerMethod("Creature", "setMaxHealth", LuaScriptInterface::luaCreatureSetMaxHealth);
    registerMethod("Creature", "setHiddenHealth", LuaScriptInterface::luaCreatureSetHiddenHealth);

    registerMethod("Creature", "getMana", LuaScriptInterface::luaCreatureGetMana);
    registerMethod("Creature", "addMana", LuaScriptInterface::luaCreatureAddMana);
    registerMethod("Creature", "getMaxMana", LuaScriptInterface::luaCreatureGetMaxMana);

    registerMethod("Creature", "getSkull", LuaScriptInterface::luaCreatureGetSkull);
    registerMethod("Creature", "setSkull", LuaScriptInterface::luaCreatureSetSkull);

    registerMethod("Creature", "getOutfit", LuaScriptInterface::luaCreatureGetOutfit);
    registerMethod("Creature", "setOutfit", LuaScriptInterface::luaCreatureSetOutfit);

    registerMethod("Creature", "getCondition", LuaScriptInterface::luaCreatureGetCondition);
    registerMethod("Creature", "addCondition", LuaScriptInterface::luaCreatureAddCondition);
    registerMethod("Creature", "removeCondition", LuaScriptInterface::luaCreatureRemoveCondition);

    registerMethod("Creature", "remove", LuaScriptInterface::luaCreatureRemove);
    registerMethod("Creature", "teleportTo", LuaScriptInterface::luaCreatureTeleportTo);
    registerMethod("Creature", "say", LuaScriptInterface::luaCreatureSay);

    registerMethod("Creature", "getDamageMap", LuaScriptInterface::luaCreatureGetDamageMap);

    registerMethod("Creature", "getSummons", LuaScriptInterface::luaCreatureGetSummons);

    registerMethod("Creature", "getDescription", LuaScriptInterface::luaCreatureGetDescription);

    registerMethod("Creature", "getPathTo", LuaScriptInterface::luaCreatureGetPathTo);
In addition, summons are monsters. So you can use monster function on that userdata too.
 
Okey! I get it now! But how should i use this on the code? I didnt write the code i posted, just modified a bit one i had. Not really sure how to go further ahead!

Btw, really thanks for your time and answers!

I've been trying diferent ways to handle this, but i really have no clue, nothing seems to work! If someone could lend me an extra hand, that would be awesome! Thanks!
 
Last edited by a moderator:
Hello! I've been trying to make a spell that unsummons my summoned creatures. But It's not working at all.. I lag maany skills in programing, so that might be the cause for not working haha.

So, If someone could help me, that would be amazing! Thanks in advance!

Code:
    local maxSummons = 3
    local summonName = "Rotten Flesher"

    function onCastSpell(player, var)
        local summonCount, playerPosition = #player:getSummons(), player:getPosition()
        if summonCount >= maxSummons then
            local summonedCreature = Game.removeMonster(summonName, playerPosition)
            player:sendMessage('You called back your creatures.')
            playerPosition:sendMagicEffect(CONST_ME_POFF)
            return false
        end
        return true
    end
This looks like my code
 
It is! You changed it for me a while ago from 0.3 to 1.2! :) Really thanks! Just improving things up!
 
This is working in TFS 1.2:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
  function onCastSpell(player, var)
    local summons = player:getSummons()
        for _, summon in pairs(summons) do
        summon:remove()
        return doCombat(cid, combat, var)
        end
        return true
    end
I copied your posted script and made this working as a spell. It works for any kind of summon.
 
This post is pretty old and i already have a working unsummon spell.. pretty good one actually! but thanks anyway! Maybe it helps someone!
 

Similar threads

V
  • Question Question
Replies
3
Views
186
Back
Top