Yatsu
I'm nobody.
- Joined
- Feb 12, 2016
- Messages
- 27
- Reaction score
- 2
Hello I'm trying to do something like "saga system(when you have storage for ex. 8000,1 monster dosen't attack you and you can't attack him, but if you have storage 8000,2 you can attack this monster same like he does attack you)" :
monster.cpp
and also
My problem is that just 50% of this script is working. Monster is ignoring the player, but player still can attack the monster..
I have no idea what is bad here, could someone help?
TFS 0.3.6
monster.cpp
Code:
void Monster::doAttacking(uint32_t interval)
{
if(!attackedCreature || (isSummon() && attackedCreature == this))
return;
Player* player = attackedCreature->getPlayer();
std::string value;
std::string check = "15";
if (getName() == "Demon Lord" && 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() == "Demon Lord" && 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);
}
I have no idea what is bad here, could someone help?
TFS 0.3.6
Last edited: