Felipe93
Ghost Member
Hello
I'm trying to make monsters re-spawn if they are outside of their spawn range / spawn size
this is the main code made for tfs 0.4
i tried to adapt it few times but the code never worked at all and i did things like these
after of being thinking i saw the default code that comes inside the tfs 1.x that removes monster if they're outside of if spawn range and teleport them back
to it's spawn:
so i changed it to this
when the monster is out of it's spawn range, it's start to constantly pooffing the problem is that the new monster never appears
(note that i did not remove the poofing part of the cause in order to view if the code was partially working
please lend me a hand
I'm trying to make monsters re-spawn if they are outside of their spawn range / spawn size
this is the main code made for tfs 0.4
Lua:
void Monster::onThink(uint32_t interval)
{
Creature::onThink(interval);
if(despawn())
{
if(spawn)
{
spawn->removeMonster(this);
spawn->startEvent();
spawn = NULL;
masterRadius = -1;
}
}
updateIdleStatus();
if(isIdle)
return;
Code:
if (!isInSpawnRange(position)) {
spawn->removeMonster(this);
spawn->startSpawnCheck();
spawn->startup();
spawn = NULL;
despawnRadius = -1;
else if (!isInSpawnRange(position)) {
spawn->removeMonster(this);
spawn->startSpawnCheck();
spawn->startup();
spawn = NULL;
despawnRadius = -1;
g_game.placeCreature(this);
}
{
else if (!isInSpawnRange(position)) {
spawn->removeMonster(this);
spawn->startSpawnCheck();
spawn->startup();
spawn = NULL;
despawnRadius = -1;
g_game.placeCreature(this);
}
after of being thinking i saw the default code that comes inside the tfs 1.x that removes monster if they're outside of if spawn range and teleport them back
to it's spawn:
Code:
if (!isInSpawnRange(position)) {
g_game.addMagicEffect(this->getPosition(), CONST_ME_POFF);
if (g_config.getBoolean(ConfigManager::REMOVE_ON_DESPAWN)) {
g_game.removeCreature(this, false);
}
else {
g_game.internalTeleport(this, masterPos);
setIdle(true);
}
}
so i changed it to this
Code:
if (!isInSpawnRange(position)) {
g_game.addMagicEffect(this->getPosition(), CONST_ME_POFF);
if (g_config.getBoolean(ConfigManager::REMOVE_ON_DESPAWN)) {
//g_game.removeCreature(this, false);
}
else {
g_game.placeCreature(this, masterPos);
setIdle(true);
}
}
when the monster is out of it's spawn range, it's start to constantly pooffing the problem is that the new monster never appears
(note that i did not remove the poofing part of the cause in order to view if the code was partially working
please lend me a hand