trickerer / Trinity-Bots

NPCBots for TrinityCore and AzerothCore 3.3.5
https://github.com/trickerer/TrinityCore-3.3.5-with-NPCBots/
472 stars 157 forks source link

[AC] [Question/Feature] Command to auto-populate unused bots #846

Closed maskreet closed 3 months ago

maskreet commented 4 months ago

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

Description

Was wondering if it's possible at the moment? I didn't see it in the manual, but I could've missed it.

I had to write a Python script to be able to bump up the amount of bots on the server, since the default isn't that many. No worries about that, since they were probably entered manually. My script can add as many as I want from the command line with a switch. Currently at 4,000 but I might go higher later.

I reserved about 400 for hirable bots, and that's where I'm running into an issue. There doesn't seem to be a way to have a command run in the AC world server terminal, only in the game client, which can take a while if you've got a bunch you want available for hire. Even something in game that can spawn all free bots to your location, or something with a set number to spawn.

TrinityCore or AzerothCore

AzerothCore

Core rev. hash/commit

No response

Operating system

WIndows 10

trickerer commented 4 months ago

There are two problems with mass-spawning bots. Number one is the location which is why you can't spawn bots using terminal. The seconds problem is mirror image packet spam due to too many bots in one location, causing players to be kicked.

You don't need to type in every bot entry you want to spawn, just use a macro: https://github.com/trickerer/Trinity-Bots/issues/279#issuecomment-1340923970 And to solve the second problem there is a worldserver.conf param NpcBot.InfoPacketsLimit, you can also move spawned bots to whatever location you want (even to a different map) using .npcbots move. The default mirror image packet limit is 100 IIRC

maskreet commented 4 months ago

The macro works, kind of. My script didn't create bots in any order by class, so it's lopsided with the spawns, and I get a lot of "doesn't exist!" messages. The reason I was hoping for a script-centric solution was because I could've returned a list of each class, then spawned them by their IDs, controlling how many of each class I wanted to spawn. The only way to do that now would be manually, which again takes a while if you've got a bunch to spawn.

And yeah, I realized about the spawn location with the terminal instead of the game client, but I also figured there'd be a way to enter the zone ID and coords for the spawned bot if used in the terminal. Maybe as a feature request?

Bogir commented 4 months ago

Screenshot_1 I created 250 bots of each class and placed them in unused (inaccessible to players) areas. Server diff increased from 5-10 ms to 250-300

When I added another 750 of each class - the diff became 30000-35000 ms. The server is simply drowning.

maskreet commented 4 months ago

Screenshot_1 I created 250 bots of each class and placed them in unused (inaccessible to players) areas. Server diff increased from 5-10 ms to 250-300

When I added another 750 of each class - the diff became 30000-35000 ms. The server is simply drowning.

I noticed there was a pretty big slowdown when I had a few hundred spawn in one spot as well on GM Island, but only in that area, and likely because of the GPU workload. As far as ping and system resources, it's negligible on my machine with the 4,000 wandering bots running around doing their thing. I get an increase of about 2GB RAM, CPU barely increases, ping stays the same.

I've got four cores and 16GB RAM dedicated to AzerothCore, so maybe it's just a resource issue with yours?

Bogir commented 4 months ago

I've got four cores and 16GB RAM dedicated to AzerothCore, so maybe it's just a resource issue with yours?

32GB RAM and 8 cores. Server used about ~10-16 Gb

trickerer commented 4 months ago

Bots check their surrounding periodically and although for free bots this delay is greater if you pack them like that the CPU usage will grow exponentially. Optimal spawn distance for bots is 50+ yds away from one another so no spell or aura reaches it

Bogir commented 4 months ago

Bots check their surrounding periodically and although for free bots this delay is greater if you pack them like that the CPU usage will grow exponentially. Optimal spawn distance for bots is 50+ yds away from one another so no spell or aura reaches it

Then maybe the bot spawn should be transferred to the hiring procedure? The bots are configured, the data is entered into all tables in advance, except creature. Then player hires a bot, at this moment the bot spawns near the player and script does all actions like .npcbot spawn command does.

This eliminates the need to spawn bots all over the world at a distance of 50 yards and reduces the load on the server. 10,000 bots is not that much, only 1000 for each class.

This is for a server with about 30-50 online players who have several accounts and several characters on each account. What if there are 50-100 players? The administrator will not be able to physically spawn 20,000 bots, and the server will not be able to handle that many. Although the server can withstand ordinary NPCs of about 140,000 without straining.

How do you think?

Bogir commented 4 months ago

Or, as an option, set the free bots to “sleep” mode, so that they do nothing at all and stand still until a player hires them

maskreet commented 4 months ago

Bots check their surrounding periodically and although for free bots this delay is greater if you pack them like that the CPU usage will grow exponentially. Optimal spawn distance for bots is 50+ yds away from one another so no spell or aura reaches it

Then maybe the bot spawn should be transferred to the hiring procedure? The bots are configured, the data is entered into all tables in advance, except creature. Then player hires a bot, at this moment the bot spawns near the player and script does all actions like .npcbot spawn command does.

This eliminates the need to spawn bots all over the world at a distance of 50 yards and reduces the load on the server. 10,000 bots is not that much, only 1000 for each class.

This is for a server with about 30-50 online players who have several accounts and several characters on each account. What if there are 50-100 players? The administrator will not be able to physically spawn 20,000 bots, and the server will not be able to handle that many. Although the server can withstand ordinary NPCs of about 140,000 without straining.

How do you think?

I thought this would have been what happened initially when I installed the mod. BTW, love the mod, and love this suggestion.

trickerer commented 4 months ago

Or, as an option, set the free bots to “sleep” mode, so that they do nothing at all and stand still until a player hires them

For now there is only one option: NpcBot.HideSpawns which essentially puts all spawned bots into sleep mode unless approached by a GM, then bot appears in world temporarily.

moncat2005 commented 4 months ago

It is not a good idea to generate the location of spawn NPCBOTs based on player needs. This will make the native world environment look messy. My approach is to select some remote locations in the world map to preset spawn points. In order to reduce CPU usage, it is required that each npcbots spawn point be spaced 50+yds apart. This type of site is not easy to choose, but fortunately, it can now be configured to be invisible by default to alleviate this difficulty. Can you recommend several coordinate locations with such broad conditions as the spawn point?

Regarding the issue of invisible functions:

  1. Invisible means that the interaction AI between NPCBots no longer exists, but is the release buff behavior of NPCBots still effective for themselves?
  2. Previously, there was feedback that after players teleported through the main city, the map showed several NPCBots nearby, but they couldn't see them. The server had to be restarted to restore normal operation. Could it be that these NPCBOTS are stuck in an invisible control script?
trickerer commented 4 months ago

Can you recommend several coordinate locations with such broad conditions as the spawn point?

No, because it depends on the number of bots you want to spawn. Also, problems with bots spawned too close to each other start when there are like 15+ bots in one spot, so this isn't that big a deal until you want to spawn hundreds of them

Regarding the issue of invisible functions:

1. Invisible means that the interaction AI between NPCBots no longer exists, but is the release buff behavior of NPCBots still effective for themselves?

2. Previously, there was feedback that after players teleported through the main city, the map showed several NPCBots nearby, but they couldn't see them. The server had to be restarted to restore normal operation. Could it be that these NPCBOTS are stuck in an invisible control script?
  1. If bot manages to cast anything on itself before teleporting out of world the buff stays on, but it doesn't matter - when hired all buffs are cleared anyway. As for Enrage buff, it doesn't get applied if 'hide spawns' option is enabled, the reasons are: 1) players can't talk to the bot anyway, 2) auras don't get updated so the buff will never expire
  2. This isn't related to the 'hide spawns' option, any kind of tracking won't stop on teleported creature until that creature's position update gets sent to player(s). This happens when any tracked creature teleports, it's just that only bots really do that. Can't tell for sure but it seems like client doesn't accept this kind of updates for creatures, only for players
moncat2005 commented 4 months ago

I have already spawn 400 or even more NPCBots in the world. So I am very concerned about the cost of CPU usage caused by spawning so many NPCBots in the same area, even if there is already a hidden spawn feature. So the hidden spawns feature can significantly reduce the CPU usage overhead, which is very important to me.

After the team teleportation, some NPCbots followed normally and some NPCbots disappeared. At this time, judging from the team object logos displayed on the map, all of them have been transferred to their locations normally, but they are actually invisible. At present, there is no good way to find patterns to reproduce this problem.

moncat2005 commented 4 months ago

I created 250 bots of each class and placed them in unused (inaccessible to players) areas. Server diff increased from 5-10 ms to 250-300 When I added another 750 of each class - the diff became 30000-35000 ms. The server is simply drowning.

Oh my god, this is so crazy. I only spawned less than 50 npcbots for each class. Where can there be so much space to carry so many npcbots you spawned? @Bogir Please give me the coordinates of this venue, thank you!

Bogir commented 4 months ago

I created 250 bots of each class and placed them in unused (inaccessible to players) areas. Server diff increased from 5-10 ms to 250-300 When I added another 750 of each class - the diff became 30000-35000 ms. The server is simply drowning.

Oh my god, this is so crazy. I only spawned less than 50 npcbots for each class. Where can there be so much space to carry so many npcbots you spawned? @Bogir Please give me the coordinates of this venue, thank you!

Addon "TrinityAdmin" has a lot of points to teleport in to "Unused areas" One of them : 3153 -5864 135 0 (x y z map)

Screenshot_0

Bogir commented 4 months ago

For now there is only one option: NpcBot.HideSpawns which essentially puts all spawned bots into sleep mode unless approached by a GM, then bot appears in world temporarily.

And what, if we add "sleep" to the end of bool Creature::LoadBotCreatureFromDB ?

m_corpseDelay = 0;
    m_respawnDelay = 0;
    setActive(true);
    GetBotAI()->SetBotCommandState(BOT_COMMAND_NO_CAST);        // <<<  THIS
    if (addToMap && !GetMap()->AddToMap(this))
        return false;
trickerer commented 4 months ago

For now there is only one option: NpcBot.HideSpawns which essentially puts all spawned bots into sleep mode unless approached by a GM, then bot appears in world temporarily.

And what, if we add "sleep" to the end of bool Creature::LoadBotCreatureFromDB ?

m_corpseDelay = 0;
    m_respawnDelay = 0;
    setActive(true);
    GetBotAI()->SetBotCommandState(BOT_COMMAND_NO_CAST);        // <<<  THIS
    if (addToMap && !GetMap()->AddToMap(this))
        return false;

No, that's a half-measure and doesn't prevent bots from checking the surroundings (ex. for attack target). Also this doesn't forbid passive AoE friendly auras

Bogir commented 4 months ago

No, that's a half-measure and doesn't prevent bots from checking the surroundings (ex. for attack target). Also this doesn't forbid passive AoE friendly auras

So, we need BOT_COMMAND_NO_CAST_ВООБЩЕ

Or, bots must to spawn only then called (hired) by player

trickerer commented 4 months ago

Or, bots must to spawn only then called (hired) by player

This is about exactly what NpcBot.HideSpawns option does except it keeps spawned bots out of map when owner isn't online

Bogir commented 4 months ago

Or, bots must to spawn only then called (hired) by player

This is about exactly what NpcBot.HideSpawns option does except it keeps spawned bots out of map when owner isn't online

I'm talking about free bots. About Thousands of free bots

Bogir commented 4 months ago

I turned off all buffs and summon pets by bots using condition IAmFree(). Nothing changed. CPU usage isn't redused.

Loading of ~900-950 free bots takes about 110-120 sec at server startup. Characters can't enter at this time.

trickerer commented 3 months ago

Cutting the off-topic here.

This mod was made to support small servers, that's why there aren't many 'stock' bots. If you create thousands of new bots and want to spawn them all (or most of them), then you're on your own here. My stance on this is: if you have enough players to hire thousands of bots (default max bots is 1 mind you) then you have enough players to do raids so you don't need any bots at all. I don't intend on making any additional elaborate bot spawning tools