• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • 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!

Passive monsters tfs 0.3x to x.4 no bugs With no bugs

MartK

Member
Joined
Dec 6, 2018
Messages
52
Best answers
1
Reaction score
15
1.- First Step in creature.cpp, Find:
Code:
bool Creature::setAttackedCreature(Creature* creature)
2.- find this fuction and edit for
Code:
 if(attackedCreature)
    {
        onAttackedCreature(attackedCreature);
        attackedCreature->onAttacked();
    }
Code:
 if(attackedCreature)
    {
        onAttackedCreature(attackedCreature);
        attackedCreature->onAttacked();
        attackedCreature->addDamagePoints(this, 0);
    }
3.- find this fuction & and change all for this :

Code:
void Creature::addDamagePoints(Creature* attacker, int32_t damagePoints)
Code:
void Creature::addDamagePoints(Creature* attacker, int32_t damagePoints)
{
    uint32_t attackerId = 0;
    if(attacker)
        attackerId = attacker->isPlayerSummon() ? attacker->getMaster()->getID() : attacker->getID();

    CountMap::iterator it = damageMap.find(attackerId);
    if(it != damageMap.end())
    {
        it->second.ticks = OTSYS_TIME();
        if(damagePoints > 0)
            it->second.total += damagePoints;
    }
    else
        damageMap[attackerId] = CountBlock_t(damagePoints);

    if(damagePoints > 0)
        lastHitCreature = attackerId;
}
4.- Go monster.cpp and find:
Code:
void Monster::onThink(uint32_t interval)
inside the fuction see
Code:
else if(!targetList.empty())
& change for :

Code:
 else if(!targetList.empty())
    {
        if(!followCreature || !hasFollowPath)
            searchTarget();
    }
5.- Find this fuction, remove and change all for this:
bool Monster::selectTarget(Creature* creature)

Code:
bool Monster::selectTarget(Creature* creature)
{
#ifdef __DEBUG__
    std::cout << "Selecting target... " << std::endl;
#endif
    if(!isTarget(creature))
        return false;

    uint32_t targetId = creature->isPlayerSummon() ? creature->getMaster()->getID() : creature->getID();
    if(!isHostile() && !hasBeenAttacked(targetId))
        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(setAttackedCreature(creature))
        Dispatcher::getInstance().addTask(createTask(boost::bind(&Game::checkCreatureAttack, &g_game, getID())));

    return setFollowCreature(creature, true);
}
& thats its all :*
 

Matheus Vieira

New Member
Joined
Apr 11, 2015
Messages
38
Best answers
0
Reaction score
0
A silly question, but after doing this changes, do i have to compile my server?
Im asking this because i can never compile the server. I think i downloaded a buged server, dont know
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,340
Best answers
528
Reaction score
3,083
A silly question, but after doing this changes, do i have to compile my server?
Im asking this because i can never compile the server. I think i downloaded a buged server, dont know
Any C++ edits require compilation.
 

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
320
Best answers
0
Reaction score
5
i did this change how i can make passive monster
what i have to add in monster.xml?
 
Top