Issue solved differently, just by checking storage value of player in spells.cpp summonCreature spell.
thx to Migxxx
------
Hello!
So, I am total newbie in C++ and I would like to add a player storage check for summon creature spell. I tried it myself but I am getting compilation error. It's probably because, to do storage check in spell.cpp file, you need to include something or add some extra parameters for the spell function. As I understand, storage in C++ is being checked like this:
Here is the summonCreature code from spells.cpp.
Code:
[code] std::string stor;
player->getStorage(9000, stor);
if(stor == "1")
{
player->sendCancel("You are not allowed to use summon spells at the moment.");
g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
return false;
}
thx to Migxxx
------
Hello!
So, I am total newbie in C++ and I would like to add a player storage check for summon creature spell. I tried it myself but I am getting compilation error. It's probably because, to do storage check in spell.cpp file, you need to include something or add some extra parameters for the spell function. As I understand, storage in C++ is being checked like this:
Code:
player->getStorage(storage, id)
Here is the summonCreature code from spells.cpp.
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))
{
// I tired it this way, but I am getting compilation error S: if(player->getStorage(323323, 1)) return false;
if(player->getSkull() == SKULL_BLACK)
{
player->sendCancelMessage(RET_NOTPOSSIBLE);
g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
return false;
}
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;
}
Last edited: