thebigsleepjoe / TTT-Bots-2

Player bots for Garry's Mod TTT
Creative Commons Attribution Share Alike 4.0 International
11 stars 4 forks source link

[BUG] witnesses and weapons cause mortal terror #31

Closed EntranceJew closed 11 months ago

EntranceJew commented 11 months ago

Game version/server type

Describe the bug

Some bots when there's no navmesh get really upset about the thing that killed something.

Stack trace/error

The error, if any. Example:

[TTT Bots 2.0] lua/tttbots2/components/sv_morality.lua:292: attempt to index field 'Roles' (a nil value)
  1. OnWitnessKill - lua/tttbots2/components/sv_morality.lua:292
   2. fn - lua/tttbots2/components/sv_morality.lua:344
    3. unknown - lua/ulib/shared/hook.lua:109
     4. FireBullets - [C]:-1
      5. ShootBullet - addons/ttt2/gamemodes/terrortown/entities/weapons/weapon_tttbase.lua:701
       6. PrimaryAttack - addons/ttt2/gamemodes/terrortown/entities/weapons/weapon_tttbase.lua:601
        7. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_sg550.lua:54
[...]
[TTT Bots 2.0] lua/tttbots2/components/sv_morality.lua:267: attempt to index field 'Roles' (a nil value)
  1. OnWitnessHurtIfAlly - lua/tttbots2/components/sv_morality.lua:267
   2. OnWitnessHurt - lua/tttbots2/components/sv_morality.lua:352
    3. fn - lua/tttbots2/components/sv_morality.lua:458
     4. unknown - lua/ulib/shared/hook.lua:109
      5. FireBullets - [C]:-1
       6. ShootBullet - addons/ttt2/gamemodes/terrortown/entities/weapons/weapon_tttbase.lua:701
        7. unknown - addons/ttt2/gamemodes/terrortown/entities/weapons/weapon_tttbase.lua:601

Reproducing the bug

Steps to reproduce the behavior:

  1. See a bot
  2. Kill a bot
  3. Have a bot see that also

Expected behavior

No errors

thebigsleepjoe commented 11 months ago

I believe this is caused by the mod intentionally not fully loading when there is no navmesh -- I'll probably have to fix by restricting bots to only spawn w/ one (which I thought already was supposed to happen lol)

Also, funny title.

thebigsleepjoe commented 11 months ago

This should be fixed as of v1.11-roles. I'll release it as a hotfix for the workshop ASAP as well.

"Fixed" by preventing bots from spawning anymore.