Dadido3 / D3bot

A very primitive AI for GMod bots designed to work with Jetboom's Zombie Survival gamemode.
38 stars 27 forks source link

Allow bots to become bosses #31

Open arthurgeron opened 4 years ago

arthurgeron commented 4 years ago

I've set my zombiesurvival to select bots as possible bosses when there are no playerbosses available, on gamemode/init.lua:1226 I've added the following lines:

    if #zombies == 0 then
        for _, ent in pairs(D3bot.GetBots()) do
            if ent:Team() == TEAM_UNDEAD and not ent:GetZombieClassTable().Boss then
                table.insert(zombies, ent)
            end
        end
    end

But I think somehow D3BOT is forcing zombies to not spawn as bosses, even if the gamemode has set them to be, what could I possibily change or did I do something wrong?

Thank you for your time :)

Dadido3 commented 4 years ago

I can't find anything meaningful at line 1226 in my version of ZS, but i assume you added that to function GM:CalculateNextBoss(). If so, then it should be ok.

D3bot isn't blocking bots from becoming bosses, but with too few players bosses may be disabled. And depending on the version of ZS you are using, bots don't add to the total player count.

I assume you just need to tweak the GM.BossZombiePlayersRequired value in gamemode/sh_globals.lua (or gamemode/shared/sh_globals.lua).

Dadido3 commented 4 years ago

Just tested it here. It works fine when i add your snippet to GM:CalculateNextBoss():

function GM:CalculateNextBoss()
    local livingbosses = 0
    local zombies = {}
    for _, ent in pairs(team.GetPlayers(TEAM_UNDEAD)) do
        if ent:GetZombieClassTable().Boss and ent:Alive() then
            livingbosses = livingbosses + 1
            if livingbosses >= 3 then return end
        else
            if ent:GetInfo("zs_nobosspick") == "0" then
                table.insert(zombies, ent)
            end
        end
    end
    if #zombies == 0 then
        for _, ent in pairs(D3bot.GetBots()) do
            if ent:Team() == TEAM_UNDEAD and not ent:GetZombieClassTable().Boss then
                table.insert(zombies, ent)
            end
        end
    end
    table.sort(zombies, BossZombieSort)
    local newboss = zombies[1]
    local newbossclass = ""

    if newboss and newboss:IsValid() then newbossclass = GAMEMODE.ZombieClasses[newboss:GetBossZombieIndex()].Name end
    net.Start("zs_nextboss")
    net.WriteEntity(newboss)
    net.WriteString(newbossclass)
    net.Broadcast()

    return newboss
end

So it must be something in your gamemode.