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

spawn monster

Status
Not open for further replies.

Kjhgfd

New 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
 
Solution
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;
        }...
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
 
Solution
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
 
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?
 
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..
 
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
 
Hello tetra20 ,
You can help me please?

spawnMonster(it->first, sb.mType, sb.pos, sb.direction, 4200);

This phrase and script is added in what archive? spawn.cpp?
 
Hello tetra20 ,
You can help me please?

spawnMonster(it->first, sb.mType, sb.pos, sb.direction, 4200);

This phrase and script is added in what archive? spawn.cpp?
Please create your own thread about receiving help, in Support board.
Locking this thread since it's solved already.
 
Status
Not open for further replies.
Back
Top