• 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 Double Summon Spell

Way20

Well-Known Member
Joined
Sep 29, 2014
Messages
205
Solutions
3
Reaction score
79
Hi guys, I need a spell that work like Utevo Res but summon 2 monsters (configured in script). I found this
Code:
function onCastSpell(cid, var)
     if #getCreatureSummons(cid) < 1 then
         for x = 1, 2 do
             m = doSummonCreature("Rat", getThingPos(cid))
             doConvinceCreature(cid, m)
         end
         doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
     else
         doPlayerSendCancel(cid, "You cannot summon more creatures")
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
         return false
     end
     return true
end
but don't work like Utevo Res, the problem is the script don't search for all space to summon. When I have a situation like this

rC6quV0.png


the spell just summon 1 monster and send this error in console.

Tl9APFh.png


I heard that Utevo Res is a function in sources then I went search the function in my sources, I have found this
Code:
bool InstantSpell::SummonMonster(const InstantSpell* spell, Creature* creature, const std::string& param)
{
    Player* player = creature->getPlayer();
    if(!player)
        return false;

    MonsterType* mType = g_monsters.getMonsterType(param);
    if(!mType)
    {
        player->sendCancelMessage(RET_NOTPOSSIBLE);
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

    int32_t manaCost = (int32_t)(mType->manaCost * g_config.getDouble(ConfigManager::RATE_MONSTER_MANA));
    if(!player->hasFlag(PlayerFlag_CanSummonAll))
    {


        if(!mType->isSummonable)
        {
            player->sendCancelMessage(RET_NOTPOSSIBLE);
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }

        if(player->getMana() < manaCost)
        {
            player->sendCancelMessage(RET_NOTENOUGHMANA);
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }

        if((int32_t)player->getSummonCount() >= g_config.getNumber(ConfigManager::MAX_PLAYER_SUMMONS))
        {
            player->sendCancel("You cannot summon more creatures.");
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }
    }

    ReturnValue ret = g_game.placeSummon(creature, param);
    if(ret == RET_NOERROR)
    {
        spell->postSpell(player, (uint32_t)manaCost, (uint32_t)spell->getSoulCost());
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_WRAPS_BLUE);
        return true;
    }

    player->sendCancelMessage(ret);
    g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
    return false;
}

but i don't know anything about C++. Can someone do the script work like Utevo Res (searching all posibilites to summon)?


Sorry for my English.
 
Last edited:
You want to add ANOTHER spell like that? Because you could just add an extra summon line in the SummonMonster function.
But anyway, I'm guessing the problem is the lack of params on the doSummonCreature function.

Try using:
Code:
//doSummonCreature(name, pos, <optional> extendedPosition, <optional: default: false> forceSpawn)
Also, you could change it to doPlayerSummonCreature (with same params as above) and get rid off doConvinceCreature
 
Code:
ReturnValue ret = g_game.placeSummon(creature, param);
ReturnValue ret2 = g_game.placeSummon(creature, param);
if(ret == RET_NOERROR && ret2 ==RET_NOERROR)
{
spell->postSpell(player, (uint32_t)manaCost, (uint32_t)spell->getSoulCost());
g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_WRAPS_BLUE);
return true;
}
 
Code:
ReturnValue ret = g_game.placeSummon(creature, param);
ReturnValue ret2 = g_game.placeSummon(creature, param);
if(ret == RET_NOERROR && ret2 ==RET_NOERROR)
{
spell->postSpell(player, (uint32_t)manaCost, (uint32_t)spell->getSoulCost());
g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_WRAPS_BLUE);
return true;
}
What I need change for the script check place before summon?
 
You want to add ANOTHER spell like that? Because you could just add an extra summon line in the SummonMonster function.
But anyway, I'm guessing the problem is the lack of params on the doSummonCreature function.

Try using:
Code:
//doSummonCreature(name, pos, <optional> extendedPosition, <optional: default: false> forceSpawn)
Also, you could change it to doPlayerSummonCreature (with same params as above) and get rid off doConvinceCreature

Don't work and send me this error in console.

id62Tz7.png
 
That's because your server doesn't have that function, in that case just stick to your old function (doSummonCreature) and add the extra params.
Samco already told you how to do it by editing sources btw...
 
Code:
function onTargetTile(cid, position)
position.stackpos = 255
local corpse = getThingFromPos(position)
    if corpse.uid == 0 or not isCorpse(corpse.uid) or not isMoveable(corpse.uid) then
        return false
    end
    if #getCreatureSummons(cid) < 2 then
        doRemoveItem(corpse.uid)
        doConvinceCreature(cid, doCreateMonster("Rat", position, false))
        doSendMagicEffect(position, CONST_ME_MAGIC_BLUE)
    end
    return true
end

local area, combat = createCombatArea(AREA_SQUARE1X1), createCombatObject()
setCombatArea(combat, area)

setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Code:
ReturnValue ret = g_game.placeSummon(creature, param);
ReturnValue ret2 = g_game.placeSummon(creature, param);
if(ret == RET_NOERROR && ret2 ==RET_NOERROR)
{
spell->postSpell(player, (uint32_t)manaCost, (uint32_t)spell->getSoulCost());
g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_WRAPS_BLUE);
return true;
}

I've compiled with that code and It worked 50% man, when I say Utevo Res "Monster, summon 2 monsters (checking all places) but I need that no need parameters to summon, my spell will be to summon only one monster so the monster need to be configured in code for when i say "Spell Name", summon two monster configured in script code. Can you edit for me? Thanks in advance!
 
Last edited:
LOL I've compiled with that code and It worked 50% man, when I say Utevo Res "Monster, summon 2 monsters (checking all places) but I need that no need parameters to summon, my spell will be to summon only one monster so the monster need to be configured in code for when i say "Spell Name", summon two monster configured in script code. Can you edit for me? Thanks in advance!
Or you could use the working script that I gave you.
 
Or you could use the working script that I gave you.

Sorry for don't reply before man, your script just work like a "exevo mas mort" with a small area, I need a spell that summon two monster configured in script and before summon check all places possible to summon.
 
Sorry for don't reply before man, your script just work like a "exevo mas mort" with a small area, I need a spell that summon two monster configured in script and before summon check all places possible to summon.
Exevo mas mort huh? I must be delusional to see that the script summons 2 monsters.
 
change param on
MonsterType* mType = g_monsters.getMonsterType(param);
ReturnValue ret = g_game.placeSummon(creature, param);


to your monster name.

you can also make a list of possible monsters, then do a rand to get 2 random monsters eg
 
Nope, the string containing the monster name must replace the param word.
E.G:
Code:
array = {"Rat", "Cave Rat", "Demon", "Rat"}
param = array[rand(0,array.length()];
MonsterType* mType = g_monsters.getMonsterType(param);

Thats a quick example, wont work as it, but will give you an idea
 
Back
Top