Raised This Month: $51 Target: $400
 12% 

[L4D(2)] Dynamic Witch Avoidance (v1.3.1a, 18-Sep-2022)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Omixsat
Member
Join Date: Jul 2022
Plugin ID:
8184
Plugin Version:
1.3.1a
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Survivor bots will avoid any enraged witch within a specified range
    Old 09-13-2022 , 08:18   [L4D(2)] Dynamic Witch Avoidance (v1.3.1a, 18-Sep-2022)
    Reply With Quote #1

    Another plugin inspired by the 200 IQ Bots of ConnerRia.

    Prerequisites
    - SM 1.10+

    Summary
    An alternate version of ConnerRia's Don't F*ck With her, Man plugin. Instead of focusing on the latest witch spawn, an algorithm records all spawned & enraged living witches in an array and compare it to each Survivor bot position.

    Versions
    Type A - An L4D2 exclusive
    Code:
    Makes use of vscript commands exclusive to only L4D2
    Type B - Applicable to both L4D1/2
    Code:
    To be announced as it might be possible to implement
    ConVars
    Saved to l4d_dynamicwitchavoidance.cfg in your servers ..\cfg\sourcemod\ folder.
    Code:
    //Print [L4D] Dynamic Witch Avoidance Version
    l4d_dynawitchavoid_version
    
    //The range the survivor bots must keep a distance from any enraged witch.
    //Default is 300
    l4d_dynawitchavoidancerange
    Recommended Settings
    Code:
    //A range between 150 to 300 hammer units is recommended for multi-witch maps such as Hard Rain
    
    Default is 300
    
    My personal setting is 200 for any map
    Changelog - Date format is MM/DD/YYY
    Code:
     Version 1.3.1a - 09/18/2022 
            - Several optimizations implemented per advice from Silvers
    
     Version 1.3.0a - 09/17/2022 ~ 10 views
            - Refactored/Optimized witch detection.
    
     Version 1.2.1a - 09/16/2022 ~ 17 views
            - Optimized detection and avoidance algorithm.
    
     Version 1.1a - 09/13/2022 @ 9:42 PM (PST) ~ 44 views 
            - Fixed a bug where killed witches stop the avoidance algorithm
    
     Version 1.0a - 09/13/2022 ~ 4 views 
            - An L4D2-exclusive plugin (Type A)
            - Initial release
    Credits
    Code:
    Timocop(indirectly) ~ for the L4D2 stock
    Bacardi ~ For his help to implement this diabetic plugin
    ConnerRia ~ For the original implementation where I figured out what to improve on.
    Impact123 - Advice on the PrintToChat function.
    Silvers - Optimizations and advice on some functions.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d_dynawitchavoid_a.sp - 1143 views - 6.2 KB)
    __________________
    My Plug-Ins
    Plug-in lookup
    My Forks
    [1] [2]

    Last edited by Omixsat; 09-17-2022 at 22:52. Reason: Updated
    Omixsat is offline
    thewintersoldier97
    Senior Member
    Join Date: Aug 2021
    Location: Vietnam
    Old 09-13-2022 , 13:50   Re: [L4D] Dynamic Witch Avoidance (v1.1, 13-Sep-2022)
    Reply With Quote #2

    Very cool and useful plugin! Thanks Omixsat

    I recommend you update your thread title to also include L4D2.
    __________________

    Looking for some fun!

    Last edited by thewintersoldier97; 09-13-2022 at 13:51.
    thewintersoldier97 is offline
    Omixsat
    Member
    Join Date: Jul 2022
    Old 09-16-2022 , 15:38   Re: [L4D] Dynamic Witch Avoidance (v1.1, 13-Sep-2022)
    Reply With Quote #3

    Quote:
    Originally Posted by thewintersoldier97 View Post
    Very cool and useful plugin! Thanks Omixsat

    I recommend you update your thread title to also include L4D2.
    Glad you like it .
    Post title/desc/plugin has been updated. Do let me know if you experience any issues.
    __________________
    My Plug-Ins
    Plug-in lookup
    My Forks
    [1] [2]
    Omixsat is offline
    Iizuka07
    Senior Member
    Join Date: Aug 2018
    Location: Underground
    Old 09-16-2022 , 20:52   Re: [L4D(2)] Dynamic Witch Avoidance (v1.2.1a, 16-Sep-2022)
    Reply With Quote #4

    Found an error

    L 09/17/2022 - 08:121: Info (map "c12m1_hilltop") (file "E:\SteamLibrary\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\logs\errors_202 20917.log")
    L 09/17/2022 - 08:121: [SM] Exception reported: Invalid entity index -2044176383
    L 09/17/2022 - 08:121: [SM] Blaming: [L4D2] Dynamic Witch Avoidance.smx
    L 09/17/2022 - 08:121: [SM] Call stack trace:
    L 09/17/2022 - 08:121: [SM] [0] EntIndexToEntRef
    L 09/17/2022 - 08:121: [SM] [1] Line 75, /home/forums/content/files/3/2/7/3/7/7/196901.attach::OnEntityCreated
    __________________
    死が待っている
    Iizuka07 is offline
    Omixsat
    Member
    Join Date: Jul 2022
    Old 09-17-2022 , 04:14   Re: [L4D(2)] Dynamic Witch Avoidance (v1.2.1a, 16-Sep-2022)
    Reply With Quote #5

    Quote:
    Originally Posted by Iizuka07 View Post
    Found an error

    L 09/17/2022 - 08:121: Info (map "c12m1_hilltop") (file "E:\SteamLibrary\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\logs\errors_202 20917.log")
    L 09/17/2022 - 08:121: [SM] Exception reported: Invalid entity index -2044176383
    L 09/17/2022 - 08:121: [SM] Blaming: [L4D2] Dynamic Witch Avoidance.smx
    L 09/17/2022 - 08:121: [SM] Call stack trace:
    L 09/17/2022 - 08:121: [SM] [0] EntIndexToEntRef
    L 09/17/2022 - 08:121: [SM] [1] Line 75, /home/forums/content/files/3/2/7/3/7/7/196901.attach::OnEntityCreated
    Fixed. Refactored/optimized witch detection in version 1.3.0a
    __________________
    My Plug-Ins
    Plug-in lookup
    My Forks
    [1] [2]
    Omixsat is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 09-17-2022 , 04:47   Re: [L4D(2)] Dynamic Witch Avoidance (v1.3.0a, 17-Sep-2022)
    Reply With Quote #6

    - You can remove "OnPluginEnd" stuff, unloading a plugin already does all of that.

    - You can replace the call to "IsSurvivor" with "GetClientTeam(client) == 2" since the rest of the stock is just repeating what's already being checked in the for loop.

    - As a trivial slight optimization you can do
    PHP Code:
                int WitchList ListOWitches.Length;
                for(
    int w 0WitchListw++) 
    instead of using "ListOWitches.Length" within the for loop declaration. You have this in 1 place but not others.

    - Another slight optimzation would be changing the two "char classname[8];" to "static char classname[8];" so the char is not constantly re-created and zeroed, since these are called often for almost every entity being create/deleted. I would do the same with "char sBuffer[512];" to "static char sBuffer[512];"

    - You could change
    PHP Code:
        int entref = -1;
        if(
    entity 0)
            
    entref EntIndexToEntRef(entity);
        else
            return; 
    to

    PHP Code:
        if(entity 1) return;
        
    int entref EntIndexToEntRef(entity); 
    and from the same function move "WitchInfo witch;" inside the "if(IsValidWitch(entity))" check, since it's never used outside of that.

    - You can remove "public" from any callbacks that you name yourself, for example you have done this with the timer but not "public void witchevents".
    __________________

    Last edited by Silvers; 09-17-2022 at 04:50.
    Silvers is offline
    Omixsat
    Member
    Join Date: Jul 2022
    Old 09-17-2022 , 20:15   Re: [L4D(2)] Dynamic Witch Avoidance (v1.3.0a, 17-Sep-2022)
    Reply With Quote #7

    Thank you, Silvers . I've implemented what you've advised including a few more tweaks.
    __________________
    My Plug-Ins
    Plug-in lookup
    My Forks
    [1] [2]
    Omixsat is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 13:55.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode