Closed MutinCholer closed 7 months ago
Thanks, i will check this. Anyway, the idea for the future is to store the common infected entities in a table for faster retrieval like already did with the specials. This should also improve the FindBotNearestEnemy performance.
I checked your changes and maybe there is a problem with the FindBotNearestEnemy one. I might be wrong but the way you search for the special infected target makes the bots ignore a visible infected if an invisible one is closer. For example: if a special infected is 2 meters away from the bot but he is behind a wall and another one is 3 meters away and he is visible and ready to attack the bot, the bot will ignore the first one (correctly) because not visible but will also ignore the second one because he is not the closest one. The original code would select the second infected as target.
I'm sure that the function can be optimized but i wouldn't bother too much with that part because most of the times the trace check is not performed on all the infected.
If you look at this line of code:
if (dist <= radius && dist < minDist && botFacing.Dot(toEnt) >= minDot && !ent.IsGhost() && Left4Utils.CanTraceTo(bot, ent, tracemask_others))
the if has other conditions before the CanTraceTo, if those conditions are not met, che CanTrace isn't executed.
However you are right about m_hasVisibleThreats, it causes the bots to ignore the infected that are between the m_hasVisibleThreats fov and the manual_attack_mindot one when the latter is larger, so that change is needed. Thanks.
I implemented the second change. Thanks again.
Currently, the method for aiming at targets relies on using
m_hasVisibleThreats
in theLeft4Bots.AIFuncs.BotManualAttack
function to determine whether to call theLeft4Bots.FindBotNearestEnemy
function. Once a target is within a SurvivorBot's FOV, it attempts to call theLeft4Utils.CanTraceTo
function for each entity to determine whether to consider it a new target.Two problems arise with your current method:
m_hasVisibleThreats
requires the target to be within the SurvivorBot's FOV. This means that even if themanual_attack_mindot
option is lower than0.6
, the SurvivorBots will ignore any target they can't see.foreach
statements would have to call theLeft4Utils.CanTraceTo
function for each target from their tables. Assuming a horde is currently active, the SurvivorBots would be performing numerous raycasts to every common infected within the specified radius which could negatively impact performance while in combat.My proposed solution would be to remove the
m_hasVisibleThreats
and instead only callLeft4Utils.CanTraceTo
once for each of the nearest targets. This not only allows themanual_attack_mindot
to work as intended, but it also optimizes performance since theLeft4Bots.FindBotNearestEnemy
function won't have to perform raycasts as often.Here is the
left4bots_afterload.nut
file if you would like to test it out:Manual Attack Adjustments.zip