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
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
the spell just summon 1 monster and send this error in console.
I heard that Utevo Res is a function in sources then I went search the function in my sources, I have found this
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.
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
the spell just summon 1 monster and send this error in console.
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: