smilz0 / Left4Bots

Improvements for the L4D2 survivor bots
https://steamcommunity.com/sharedfiles/filedetails/?id=3022416274
34 stars 4 forks source link

Bots run back to human after unpause lead order #91

Closed 4512369781 closed 3 months ago

4512369781 commented 4 months ago

When "MovePos" exists, always refresh it. If not do this, in "BotFinalizeCurrentOrder()" func, 'nextPos' may be equal to 'CurrentOrder.DestPos', and bots will not refresh the move command. In testing, bots often ran back to human, after a few secends they start lead order again.

::Left4Bots.AIFuncs.BotOnResume <- function ()
{
    L4B.Logger.Debug("[AI]" + self.GetPlayerName() + " [->]");
    if (L4B.Settings.pause_debug)
        Say(self, "[->]", false);

    if (MovePos)
        NeedMove = 2; // Refresh previous MOVE

    if (MoveType == AI_MOVE_TYPE.Order && CurrentOrder.OrderType == "lead")
    {
        if (CurrentOrder.DestPos)
        {
            // If we are executing a "lead" order and, during the pause, we moved ahead of the next position, the last MOVE will take us backwards. Better finalize the order to re-calc the next position from here
            BotFinalizeCurrentOrder();
        }

        if ((CurTime - L4B.LastLeadStartVocalize) >= L4B.Settings.lead_vocalize_interval)
        {
            L4B.SpeakRandomVocalize(self, L4B.VocalizerLeadStart, RandomFloat(0.4, 0.9));
            L4B.LastLeadStartVocalize = CurTime;
        }
    }
}
smilz0 commented 3 months ago

Thx