spawn monster

Kjhgfd

Member
Joined
Dec 25, 2016
Messages
63
Reaction score
1
Hello guys i have source 0.4 8.60
need to edite it before monster spawn make effect {MAGIC_EFFECT_TELEPORT} for 5 second like rl tibia
 

tetra20

DD
Joined
Jan 17, 2009
Messages
1,304
Reaction score
285
Location
Egypt
Code:
spawnMonster(it->first, sb.mType, sb.pos, sb.direction, 4200);
Code:
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, int16_t t,
    bool startup /*= false*/)
{
    Monster* monster = Monster::createMonster(mType);
    if(!monster)
        return false;

    if(startup)
    {
        //No need to send out events to the surrounding since there is no one out there to listen!
        if(!g_game.internalPlaceCreature(monster, pos, false, true))
        {
            delete monster;
            return false;
        }
    }
    else if (t == 0)
    {
        if (!g_game.placeCreature(monster, pos, false, true))
        {
            delete monster;
            return false;
        }
    } 
    else {
        g_game.addMagicEffect(pos, MAGIC_EFFECT_TELEPORT);
        Scheduler::getInstance().addEvent(createSchedulerTask(
            1400, boost::bind(&Spawn::spawnMonster, this, spawnId, mType, pos, dir, t - 1400,false)));
        return true;
    }

        monster->setSpawn(this);
        monster->setMasterPosition(pos, radius);
        monster->setDirection(dir);

        monster->addRef();
        spawnedMap.insert(SpawnedPair(spawnId, monster));
        spawnMap[spawnId].lastSpawn = OTSYS_TIME();
   
    return true;
}
Code:
bool spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, int16_t t,bool startup = false);
And Remove the Player Checker
 
OP
K

Kjhgfd

Member
Joined
Dec 25, 2016
Messages
63
Reaction score
1
Code:
spawnMonster(it->first, sb.mType, sb.pos, sb.direction, 4200);
Code:
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, int16_t t,
    bool startup /*= false*/)
{
    Monster* monster = Monster::createMonster(mType);
    if(!monster)
        return false;

    if(startup)
    {
        //No need to send out events to the surrounding since there is no one out there to listen!
        if(!g_game.internalPlaceCreature(monster, pos, false, true))
        {
            delete monster;
            return false;
        }
    }
    else if (t == 0)
    {
        if (!g_game.placeCreature(monster, pos, false, true))
        {
            delete monster;
            return false;
        }
    }
    else {
        g_game.addMagicEffect(pos, MAGIC_EFFECT_TELEPORT);
        Scheduler::getInstance().addEvent(createSchedulerTask(
            1400, boost::bind(&Spawn::spawnMonster, this, spawnId, mType, pos, dir, t - 1400,false)));
        return true;
    }

        monster->setSpawn(this);
        monster->setMasterPosition(pos, radius);
        monster->setDirection(dir);

        monster->addRef();
        spawnedMap.insert(SpawnedPair(spawnId, monster));
        spawnMap[spawnId].lastSpawn = OTSYS_TIME();
  
    return true;
}
Code:
bool spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, int16_t t,bool startup = false);
And Remove the Player Checker
noway u are my love work 100% :D
 

Ron'sPepe

Member
Joined
Jul 11, 2014
Messages
32
Reaction score
4
Location
Chile
Code:
spawnMonster(it->first, sb.mType, sb.pos, sb.direction, 4200);
Code:
bool Spawn::spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, int16_t t,
    bool startup /*= false*/)
{
    Monster* monster = Monster::createMonster(mType);
    if(!monster)
        return false;

    if(startup)
    {
        //No need to send out events to the surrounding since there is no one out there to listen!
        if(!g_game.internalPlaceCreature(monster, pos, false, true))
        {
            delete monster;
            return false;
        }
    }
    else if (t == 0)
    {
        if (!g_game.placeCreature(monster, pos, false, true))
        {
            delete monster;
            return false;
        }
    }
    else {
        g_game.addMagicEffect(pos, MAGIC_EFFECT_TELEPORT);
        Scheduler::getInstance().addEvent(createSchedulerTask(
            1400, boost::bind(&Spawn::spawnMonster, this, spawnId, mType, pos, dir, t - 1400,false)));
        return true;
    }

        monster->setSpawn(this);
        monster->setMasterPosition(pos, radius);
        monster->setDirection(dir);

        monster->addRef();
        spawnedMap.insert(SpawnedPair(spawnId, monster));
        spawnMap[spawnId].lastSpawn = OTSYS_TIME();
  
    return true;
}
Code:
bool spawnMonster(uint32_t spawnId, MonsterType* mType, const Position& pos, Direction dir, int16_t t,bool startup = false);
And Remove the Player Checker


What are 1400, t-1400 and 4200 values?
 

tetra20

DD
Joined
Jan 17, 2009
Messages
1,304
Reaction score
285
Location
Egypt
Time in milliseconds,4200 = 4.2s
It takes 4.2s to summon the monster after first flash(a new flash appear each 1.4 second)..you can set it to whatever you want..

Code:
Scheduler::getInstance().addEvent(createSchedulerTask(
            x, boost::bind(&Spawn::spawnMonster, this, spawnId, mType, pos, dir, t - x,false)));
you first set t to anything,let's say 5000..then you find t divisors

which are (5,10,20,25,50,100,250,1000,1250 and so on)

then x has to be one of those numbers

So let's say X = 1250,then each 1250 ms,a flash will appear and after 5000/1250 = 4s, the monster will summon..
 

5lave Ots

Member
Joined
Oct 2, 2017
Messages
150
Reaction score
5
can you tell more details because when I made the compile, after killing one monster it makes a spam of teleport effect and no monster is respawned, and every 5 seconds the tp effect is getting faster and faster
 
Top