• 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!

[C++/Creaturescripts] When player no stroage id, monster dont attack

Erexo

Kage
Premium User
Joined
Mar 27, 2010
Messages
741
Solutions
5
Reaction score
193
Location
Pr0land
GitHub
Erexo
Hello,
i looking for a script:
-When player DONT have stroage id 8000,15 monster with name "demon lord" cant attack him (like a gm :p).
-When dont have this stroage, cant attack this monster too...


Someone can? please :(
 
failure.... Like that You have to bugs:

1- Monster will target the player(means he will follow the creature) any way
2- if player or monster made a spell the attacked would be damaged.
 
I want that script too (without buts what Doggynub said).

Ex.
Monster dont move if creature dont have required storage (and change target to other player if there are 5 players) -> Checking if next have storage , if dont he dont move, check next, next. If anyone got storage he moves to player and attack him. But he dont attack other players with spells (ignore it).
 
\
I want that script too (without buts what Doggynub said).

Ex.
Monster dont move if creature dont have required storage (and change target to other player if there are 5 players) -> Checking if next have storage , if dont he dont move, check next, next. If anyone got storage he moves to player and attack him. But he dont attack other players with spells (ignore it).

This works jsut fine to me on 0.4
check
 
Hello , during the compilation of such errors. You know how to fix it?
c76f90f0266475df.png

and
29417524e5b8489a.png
 
Last edited:
Fixed version, update every hit check if storage changed

goto monster.xml
search for
PHP:
void Monster::doAttacking(uint32_t interval)
{
    if(!attackedCreature || (isSummon() && attackedCreature == this))
        return;

under it paste
PHP:
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);
       
    }

now replace this function
PHP:
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;
    }
    if((isHostile() || isSummon()) && setAttackedCreature(creature) && !isSummon())
        Dispatcher::getInstance().addTask(createTask(
            boost::bind(&Game::checkCreatureAttack, &g_game, getID())));

    return setFollowCreature(creature, true);
}

With this
PHP:
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);
}

it works!
but.. if player change storage when are in battle, the server crash! do u know how to solve it? tfs 0.3.6
 
hey if I work for 0.3.6 that I need to compile and I need a service that brings source 0.3.6 or I can put one to mine that does not have (source 0.3.6)
 
Back
Top