Hello,
i looking for a script:
-When player DONT have stroage id 8000, 15 monster with name "rat" cant attack him
-When dont have this stroage, cant attack this monster too...
I have this code but it does not work on 8.54 (0.3.6pl1)
and
Is there anyone who knows C + + and know how to fix it?
i looking for a script:
-When player DONT have stroage id 8000, 15 monster with name "rat" cant attack him
-When dont have this stroage, cant attack this monster too...
I have this code but it does not work on 8.54 (0.3.6pl1)
Code:
Player* player = attackedCreature->getPlayer();
std::string value;
std::string check = "15";
if (getName() == "Rat" && player && ( !(player->getStorage("8000",value)) || check != value ) )
{
setFollowCreature(NULL);
setAttackedCreature(NULL);
searchTarget(TARGETSEARCH_NEAREST);
}
Code:
bool Monster::selectTarget(Creature* creature)
{
#ifdef __DEBUG__
std::cout << "Selecting target... " << std::endl;
#endif
if(!isTarget(creature))
return false;
CreatureList::iterator it = std::find(targetList.begin(), targetList.end(), creature);
if(it == targetList.end())
{
//Target not found in our target list.
#ifdef __DEBUG__
std::cout << "Target not found in targetList." << std::endl;
#endif
return false;
}
Player* player = creature->getPlayer();
std::string value;
std::string check = "15";
if (getName() == "Rat" && player && ( !(player->getStorage("8000",value)) || check != value ) )
return false;
if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())
Dispatcher::getInstance().addTask(createTask(
boost::bind(&Game::checkCreatureAttack, &g_game, getID())));
return setFollowCreature(creature, true);
}