D3bot icon indicating copy to clipboard operation
D3bot copied to clipboard

Survivors don't have weapons

Open thewsmred opened this issue 2 years ago • 1 comments

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

thewsmred avatar Jan 11 '23 00:01 thewsmred

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.)

Dadido3 avatar Jan 11 '23 10:01 Dadido3