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

Feature [TFS 1.2] Monster:onSpawn(position, startup, artificial)

Game.createMonster("Valkyrie", self:getPosition()) right before return false
 
you can't directly change the actual monster spawn
you can, some time ago Mkalo help me with something like that, the respawn of a monster can be "changed" to another monster that is in the same "spawn" (that violet fire) I couldn't find another way to say it sorry
 
you can, some time ago Mkalo help me with something like that, the respawn of a monster can be "changed" to another monster that is in the same "spawn" (that violet fire) I couldn't find another way to say it sorry
ofc you can do whatever you want by changing sources, i'm saying the way it's made right now in my code you can't do that.
 
using these changes on latest tfs is making monsters no longer drop loot, or am I the only one with this issue? 🤔
 
No.


True if it was spawned by artificial means, i.e. /m or Game.createMonster, false if it was created from their original spawn.
true: the monster is spawned from a spawn on the map
false: the monster is spawned artificially via Game.createMonster(name, pos)

that's what i understood from your explanation

also why's the loot not dropping of tfs 1.3
 
true: the monster is spawned from a spawn on the map
false: the monster is spawned artificially via Game.createMonster(name, pos)

that's what i understood from your explanation

also why's the loot not dropping of tfs 1.3
In the explanation I put it backwards for true/false, but the loot has nothing to do with this system.
 
I see now, the Monster event class didn't exist before onDropLoot was added, so now there's an if statement at the end of the chain which is never executed, meaning onDropLoot will never execute from data/events/monster.lua.
Instead of adding the if (className == "Monster") portion to the top of the else/if chain, you need to place it under the current existing one that has dropLoot under it, and just check for the method name
C++:
        } else if (className == "Monster") {
            if (methodName == "onDropLoot") {
                info.monsterOnDropLoot = event;
            } else {
                std::cout << "[Warning - Events::load] Unknown monster method: " << methodName << std::endl;
            }
to:
C++:
        } else if (className == "Monster") {
            if (methodName == "onDropLoot") {
                info.monsterOnDropLoot = event;
            } else if (methodName == "onSpawn") {
                info.monsterOnSpawn = event;
            } else {
                std::cout << "[Warning - Events::load] Unknown monster method: " << methodName << std::endl;
            }
 
I see now, the Monster event class didn't exist before onDropLoot was added, so now there's an if statement at the end of the chain which is never executed, meaning onDropLoot will never execute from data/events/monster.lua.
Instead of adding the if (className == "Monster") portion to the top of the else/if chain, you need to place it under the current existing one that has dropLoot under it, and just check for the method name
C++:
        } else if (className == "Monster") {
            if (methodName == "onDropLoot") {
                info.monsterOnDropLoot = event;
            } else {
                std::cout << "[Warning - Events::load] Unknown monster method: " << methodName << std::endl;
            }
to:
C++:
        } else if (className == "Monster") {
            if (methodName == "onDropLoot") {
                info.monsterOnDropLoot = event;
            } else if (methodName == "onSpawn") {
                info.monsterOnSpawn = event;
            } else {
                std::cout << "[Warning - Events::load] Unknown monster method: " << methodName << std::endl;
            }
also there another one search for if (className == "Monster") you'll find it else it won't work without i just tested it
 
also there another one search for if (className == "Monster") you'll find it else it won't work without i just tested it
That's literally what I wrote.
I said instead of adding it to the top, you need to check methodname under the currently existing one in 1.3, which is at the bottom of the else/if chain, I even wrote an example of what I meant.
 
That's literally what I wrote.
I said instead of adding it to the top, you need to check methodname under the currently existing one in 1.3, which is at the bottom of the else/if chain, I even wrote an example of what I meant.
Ahh my bad
 
This generates a crash on the server:
Lua:
monster:remove()
1576707808514.png

The solution:
Add what is surrounded in light green.

game.cpp
1576708002558.png
map.cpp
1576708131379.png

This was one of the solutions I found at the first, but if there is a better solution, I would like to see it!

The blocking is caused by the function
Code:
map.getSpectators(list, >> tile->getPosition() <<, true)
this try to get the position of a tile that does not exist yet. this is in game.cpp in the function
Code:
bool Game::removeCreature(Creature* creature, bool isLogout/* = true*/)
 
There is absolutely zero reason to use monster:remove() in the first place, the return value of the function blocks the spawn if it's set to false. All this "fix" is, is a workaround for something that can already be handled with the original source.
 
I am creating a system in which it is necessary to use such a function, in the same way I would have liked to see another solution to the problem, there should be no things that block the server in any way.
 
Back
Top