ike3 / mangosbot

This is a modification of MaNGOS (Zero, One, R2, Trinity) server which brings a number of bots online and available for any player. Also allows you to use your account/guild characters as bots.
http://ike3.github.io/mangosbot-docs/
GNU General Public License v2.0
185 stars 79 forks source link

RandomBots falling through ground #15

Closed Codex2000 closed 10 years ago

Codex2000 commented 10 years ago

RandomBots falling through ground. I have vmaps and mmaps enabled in trinity but they are still falling through ground most likely happend when they start to fight. Also i noticed when RandomBot is fighting and a secound mob attack him he will not fight back and completly ignore him until he die's, that's because i think you coded them to wait until hp/mana get's back to full and then fight next mob.

ike3 commented 10 years ago

I thinks this is some issue with TC MovementGenerators. Comparing to R2 I can see that movement is different: sometimes bots cannot follow master, sometimes they fall though ground. I noticed same problem with some regular mobs as well, so bots inherit this issue

Kittnz commented 10 years ago

however this does not happen a lot. most of the bots are indeed just underground. can't be seen.

ike3 commented 10 years ago

The actual spawning logic is located in RandomPlayerbotMgr::RandomTeleport. Locations are calculated based on creature and game_tele locations in the DB. The method just picks a random one from the list and uses the following code to teleport:

    if (!map->IsOutdoors(x, y, z) ||
            map->IsInWater(x, y, z))
        continue;

    float height = map->GetWaterOrGroundLevel(x, y, 0.05f + z);
    if (height == INVALID_HEIGHT)
        continue;

    z = 0.05f + height;

    bot->GetMotionMaster()->Clear();
    bot->TeleportTo(loc.GetMapId(), x, y, z, 0);

I suppose GetWaterOrGroundLevel returns correct z-coord and by adding 0.05f it is assured that the position is on the ground. Seems this check is not enough and something else needs to be added. Any ideas?

Kittnz commented 10 years ago

Check out:

void Creature::UpdateMovementFlags()
{
    // Do not update movement flags if creature is controlled by a player (charm/vehicle)
    if (m_movedPlayer)
       return;

// Set the movement flags if the creature is in that mode. (Only fly if actually in air, only swim if in water, etc)
float ground = GetMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZMinusOffset());

bool isInAir = (G3D::fuzzyGt(GetPositionZMinusOffset(), ground + 0.05f) || G3D::fuzzyLt(GetPositionZMinusOffset(), ground - 0.05f)); // Can be underground too, prevent the falling

if (GetCreatureTemplate()->InhabitType & INHABIT_AIR && isInAir && !IsFalling())
{
    if (GetCreatureTemplate()->InhabitType & INHABIT_GROUND)
        SetCanFly(true);
    else
        SetDisableGravity(true);
}
else
{
    SetCanFly(false);
    SetDisableGravity(false);
}

if (!isInAir)
    RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING);

SetSwim(GetCreatureTemplate()->InhabitType & INHABIT_WATER && IsInWater());
}
ike3 commented 10 years ago

Thanks! Changed it to

    float ground = map->GetHeight(x, y, z + 0.05f);
    if (ground <= INVALID_HEIGHT)
        continue;

Seems a bit better as there are no z = -19999.0 anymore but just have seen a bot under the ground in Astranaar.

ike3 commented 10 years ago

Seems 0.05f just not enough to prevent them from falling. Changed to 0.5f and the issue seems to be fixed.

Codex2000 commented 10 years ago

ike3 first of all you doing a good job on the bot's i was lokking forward to see them in trinity but the last couple of changes you make did not fix the problem, i was useing your latest update but still found bot's underground not sure why but it is true hope you can find i way to fix that. And Everytime i close worldserver.exe wth ctrl+c it crash with e8cfa740-4d13-11e4-9f2d-6cdc204608f7

Codex2000 commented 10 years ago

and here are some logs there are so many errors

TrinityCore rev. 3009a75ce862 2014-10-06 07:25:09 +0400 (trinity-wotlk-ai branch) (Win64, Release) (worldserver-daemon)

to stop. ``` Character: Apoupne (GUID: 66 Race: 10 Class: 8) has skill 46 not allowed for his race/class combination Character: Apoupne (GUID: 66 Race: 10 Class: 8) has skill 54 not allowed for his race/class combination ... Unit 416 is in controlled list of 0 when removed from world ``` *Useless long log removed
Kittnz commented 10 years ago

That's just some skills that were added too the char that are incorrect. There seem to be a little issue with giving correct skills to a character.

ike3 commented 10 years ago

There are no more bots under ground