Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add monsters walking back to spawn #3604

Merged
merged 1 commit into from
Aug 28, 2021

Conversation

marmichalski
Copy link
Contributor

Pull Request Prelude

Changes Proposed

Monsters will now walk back to their spawn position when lured away and no targets are around. See the attached videos for more details. When the path gets blocked, monster will just stop.

spawnwalk.mp4 - monster does not walk back when in allowed range, and walk backs when goes outside of it.
spawnwalk_block.mp4 - monster cancels walk to spawn when target appears | stop when walking back and path gets blocked.

spawnwalk.mp4
spawnwalk_block.mp4

Issues addressed: Part of #922, #3600

src/game.cpp Outdated
bool result = g_config.reload();

Monster::despawnRange = g_config.getNumber(ConfigManager::DEFAULT_DESPAWNRANGE);
Monster::despawnRadius = g_config.getNumber(ConfigManager::DEFAULT_DESPAWNRADIUS);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny fix as a bonus 💩

@@ -725,14 +738,13 @@ void Monster::onThink(uint32_t interval)
}

if (!isInSpawnRange(position)) {
g_game.addMagicEffect(this->getPosition(), CONST_ME_POFF);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Effect has been displayed at the new position (after teleport) 🙄

src/game.cpp Outdated
case RELOAD_TYPE_CONFIG: {
bool result = g_config.reload();

Monster::despawnRange = g_config.getNumber(ConfigManager::DEFAULT_DESPAWNRANGE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part looks weird, a reload by overwriting variables directly in the reload event
I do not like it!

But the idea of ​​the monsters returning to their position is nice, although no one is going to see the monsters return, so they would be something unnecessary, for that grace, let's make them immediately return to their respawn position.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10000 monsters doing a ghost walk that no one will ever see, use of unnecessary processor, it seems useless to me, I hope you can have a better idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. If you do not want features, maintain your issues.
  2. There is already a despawn teleport.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just hope you don't bother, they are just my opinions.
the fact that you are actively contributing to the repository is great.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you dont want to accidentally run into walking monsters, just disable the feature - its possible with 0 as value.

@ghost ghost added the feature New feature or functionality label Aug 27, 2021
@ghost ghost requested review from DSpeichert, nekiro, ranisalt and yamaken93 August 27, 2021 21:03
@Bipbop69
Copy link

home/testeserver/src/monster.cpp: In member function ‘void Monster::onCreatureLeave(Creature*)’: /home/testeserver/src/monster.cpp:536:55: error: no matching function for call to ‘Monster::getPathTo(Position&, std::vector<Direction>&, int, int, bool, bool)’ if (getPathTo(masterPos, dirList, 0, 0, true, true)) { ^ In file included from /home/testeserver/src/monsters.h:23:0, from /home/testeserver/src/monster.h:24, from /home/testeserver/src/monster.cpp:24: /home/testeserver/src/creature.h:503:8: note: candidate: bool Creature::getPathTo(const Position&, std::forward_list<Direction>&, const FindPathParams&) const bool getPathTo(const Position& targetPos, std::forward_list<Direction>& dirList, const FindPathParams& fpp) const; ^~~~~~~~~ /home/testeserver/src/creature.h:503:8: note: candidate expects 3 arguments, 6 provided /home/testeserver/src/creature.h:504:8: note: candidate: bool Creature::getPathTo(const Position&, std::forward_list<Direction>&, int32_t, int32_t, bool, bool, int32_t) const bool getPathTo(const Position& targetPos, std::forward_list<Direction>& dirList, int32_t minTargetDist, int32_t maxTargetDist, bool fullPathSearch = true, bool clearSight = true, int32_t maxSearchDist = 0) const; ^~~~~~~~~ /home/testeserver/src/creature.h:504:8: note: no known conversion for argument 2 from ‘std::vector<Direction>’ to ‘std::forward_list<Direction>&’ /home/testeserver/src/monster.cpp:537:27: error: no matching function for call to ‘Monster::startAutoWalk(std::vector<Direction>&)’ startAutoWalk(dirList); ^ In file included from /home/testeserver/src/monsters.h:23:0, from /home/testeserver/src/monster.h:24, from /home/testeserver/src/monster.cpp:24: /home/testeserver/src/creature.h:289:8: note: candidate: void Creature::startAutoWalk(const std::forward_list<Direction>&) void startAutoWalk(const std::forward_list<Direction>& listDir); ^~~~~~~~~~~~~

@@ -258,8 +259,9 @@ bool ConfigManager::load()

integer[MAX_PLAYERS] = getGlobalNumber(L, "maxPlayers");
integer[PZ_LOCKED] = getGlobalNumber(L, "pzLocked", 60000);
integer[DEFAULT_DESPAWNRANGE] = getGlobalNumber(L, "deSpawnRange", 2);
integer[DEFAULT_DESPAWNRADIUS] = getGlobalNumber(L, "deSpawnRadius", 50);
integer[DEFAULT_DESPAWNRANGE] = Monster::despawnRange = getGlobalNumber(L, "deSpawnRange", 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it looks much better ;), now I like it.

I heard that this feature is from Tibia RL, so after all, I will be happy to see this change, I have no more things to say, I hope others can try and give their opinions.

I still have some doubts about what would happen if someone tried to make them walk very long distances? any definite behavior or just monsters walking crazy all over the place?

@ghost
Copy link

ghost commented Aug 28, 2021

home/testeserver/src/monster.cpp: In member function ‘void Monster::onCreatureLeave(Creature*)’: /home/testeserver/src/monster.cpp:536:55: error: no matching function for call to ‘Monster::getPathTo(Position&, std::vector<Direction>&, int, int, bool, bool)’ if (getPathTo(masterPos, dirList, 0, 0, true, true)) { ^ In file included from /home/testeserver/src/monsters.h:23:0, from /home/testeserver/src/monster.h:24, from /home/testeserver/src/monster.cpp:24: /home/testeserver/src/creature.h:503:8: note: candidate: bool Creature::getPathTo(const Position&, std::forward_list<Direction>&, const FindPathParams&) const bool getPathTo(const Position& targetPos, std::forward_list<Direction>& dirList, const FindPathParams& fpp) const; ^~~~~~~~~ /home/testeserver/src/creature.h:503:8: note: candidate expects 3 arguments, 6 provided /home/testeserver/src/creature.h:504:8: note: candidate: bool Creature::getPathTo(const Position&, std::forward_list<Direction>&, int32_t, int32_t, bool, bool, int32_t) const bool getPathTo(const Position& targetPos, std::forward_list<Direction>& dirList, int32_t minTargetDist, int32_t maxTargetDist, bool fullPathSearch = true, bool clearSight = true, int32_t maxSearchDist = 0) const; ^~~~~~~~~ /home/testeserver/src/creature.h:504:8: note: no known conversion for argument 2 from ‘std::vector<Direction>’ to ‘std::forward_list<Direction>&’ /home/testeserver/src/monster.cpp:537:27: error: no matching function for call to ‘Monster::startAutoWalk(std::vector<Direction>&)’ startAutoWalk(dirList); ^ In file included from /home/testeserver/src/monsters.h:23:0, from /home/testeserver/src/monster.h:24, from /home/testeserver/src/monster.cpp:24: /home/testeserver/src/creature.h:289:8: note: candidate: void Creature::startAutoWalk(const std::forward_list<Direction>&) void startAutoWalk(const std::forward_list<Direction>& listDir); ^~~~~~~~~~~~~

the code compiled just fine here, you either did something wrong or you are not using tfs-master but other engine

@DSpeichert DSpeichert merged commit 5a4558d into otland:master Aug 28, 2021
nekiro added a commit that referenced this pull request Aug 28, 2021
@MillhioreBT
Copy link
Contributor

The PR does not work at all well, only movements of 6 or 7 SQM maximum are allowed due to the getPathTo function So the PR itself is useless and does not work in 99% of cases

Please change the mechanism to the onThink event and have the monster update getPathTo until it reaches its destination
I hope you have a nice day @marmichalski ;)

@marmichalski marmichalski deleted the monster-spawn-walk branch August 28, 2021 20:38
@ghost ghost mentioned this pull request Aug 29, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants