Dadido3 / D3bot

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

Survivors don't have weapons #91

Open thewsmred opened 1 year ago

thewsmred commented 1 year ago

It's there a way to make survivors spawn with weapons?

Dadido3 commented 1 year ago

Survivor bots will get a random loadout like any other player that does not choose a loadout. This is done by ZS itself, so you need to modify the gamemode in some way. The logic that gives default or random loadouts starts here:

https://github.com/JetBoom/zombiesurvival/blob/310793aff3e200dd9e8d31b1f9241f4bce416c84/gamemodes/zombiesurvival/gamemode/init.lua#L2447-L2464

You could modify it directly, or you could add a hook to this GM event, see facepunch.com/gmod/hook.Add.

I can't test it right now, but a hook for this could look like this:

hook.Add("GiveDefaultOrRandomEquipment", "GiveSurvivorBotLoadout", function(pl)
    if not pl:IsBot() then return end
    if GAMEMODE.CheckedOut[pl:UniqueID()] then return end
    GAMEMODE.CheckedOut[pl:UniqueID()] = true

    pl:Give("weapon_zs_peashooter")
    pl:GiveAmmo(50, "pistol")
end)

This should give any survivor bot a peashooter and 50 ammo at the start of the round.

Save this as ...\garrysmod\lua\autorun\server\custom_bot_loadout.lua or something similar. (Or even better: Put it into your own custom addon.)