Raised This Month: $ Target: $400
 0% 

[L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Plugin ID:
8140
Plugin Version:
1.0
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Set the health value bots require before using First Aid, Pain Pills or Adrenaline.
    Unapprover:
    Reason for Unapproving:
    Plugin crashes server
    Old 08-01-2022 , 17:34   [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #1

    About:
    • After several different methods and attempts over the years, finally here is one that works, might possibly break on game updates.
    • Provides 2 cvars to control the health at which bots should attempt to heal.



    Thanks:
    • Psyk0tik - Looking through the code.
    • Dragokas - Testing on L4D1 linux.
    • Toranks - Asking for the plugin.



    CVars:

    Saved to l4d_bot_healing.cfg in your servers \cfg\sourcemod\ folder.

    PHP Code:
    // Allow bots to use First Aid when their health is below this value.
    l4d_bot_healing_first "30.0"

    // Allow bots to use Pills or Adrenaline when their health is below this value.
    l4d_bot_healing_pills "50.0"

    // Bot Healing Values plugin version.
    l4d_bot_healing_version 


    Changes:
    Code:
    1.0 (01-Aug-2022)
        - Initial release.


    Installation:
    • This plugin requires SourceMod version 1.11. Currently "Get Plugin" does not seem to be working, manually compile for now.
    • Click "Get Plugin" and put the .smx file into your servers \addons\sourcemod\plugins\ folder.
    • Download the "l4d_bot_healing.txt" gamedata file and put into your servers \addons\sourcemod\gamedata\ folder.
    Attached Files
    File Type: txt l4d_bot_healing.txt (3.2 KB, 24 views)
    File Type: sp Get Plugin or Get Source (l4d_bot_healing.sp - 30 views - 5.7 KB)
    __________________

    Last edited by Silvers; 08-01-2022 at 17:40.
    Silvers is offline
    HarryPotter
    Veteran Member
    Join Date: Sep 2017
    Location: Taiwan, Taipei
    Old 08-01-2022 , 23:33   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #2

    l4d2 windows server,
    launch server -> join server -> crash

    Accelerator uploaded crash dump: Crash ID: IDYH-4XRE-YPYZ

    Code:
    EXCEPTION_ACCESS_VIOLATION_WRITE accessing 0x7944f590
    
    Thread 0 (crashed):
       0: sourcemod.logic.dll!StoreToAddress [ smn_core.cpp:899 + 0x0 ]
          https://github.com/alliedmodders/sourcemod/blob/5e3a189642c496170b9705f327a91e77d0c0e5f9/core/logic/smn_core.cpp#L899
          eip: 0x79d85437  esp: 0x00efd400  ebp: 0x00efd408  ebx: 0x41f00000
          esi: 0x7944f590  edi: 0x00004edc  eax: 0x00000000  ecx: 0x21471200
          edx: 0x00000002  efl: 0x00210246  
    
          79d8542b  50                 push eax
          79d8542c  6a 40              push 0x40
          79d8542e  6a 04              push 0x4
          79d85430  56                 push esi
          79d85431  ff 15 24 f0 de 79  call dword [0x79def024]
      >   79d85437  89 1e              mov [esi], ebx
          79d85439  33 c0              xor eax, eax
          79d8543b  5b                 pop ebx
          79d8543c  5e                 pop esi
          79d8543d  5d                 pop ebp
          79d8543e  c3                 ret
    
          00efd400  00 13 47 21 10 c4 46 21  38 d4 ef 00 37 7f e5 31  ..G!..F!8...7..1
    
          Found via instruction pointer in context
    
    
       1: jit_code_836763648_1048576 + 0x57f37 [ l4d_bot_healing.smx::.5420.DetourUseHealingPre ]
          eip: 0x31e57f37  esp: 0x00efd410  ebp: 0x00efd438  
    
          00efd410  38 7c 20 21 ec 12 47 21  a4 0d 00 00 00 00 16 01  8| !..G!........
          00efd420  88 00 00 00 03 00 00 00  38 d4 ef 00 37 7f e5 31  ........8...7..1
          00efd430  2c 15 00 00 02 00 00 00  60 d4 ef 00 d7 00 de 1f  ,.......`.......
    
          Found via call frame info
    
    
       2: jit_code_534642688_1048576 + 0xd7
          eip: 0x1fde00d7  esp: 0x00efd440  ebp: 0x00efd460  
    
          00efd440  64 d4 ef 00 27 69 e7 79  39 69 e7 79 e4 d4 ef 00  d...'i.y9i.y....
          00efd450  38 7c 20 21 08 bb c2 0f  00 00 00 00 01 00 00 00  8| !............
          00efd460  ac d4 ef 00 ae 1a e7 79                           .......y        
    
          Found via previous frame's frame pointer
    
    
       3: sourcepawn.jit.x86.dll!sp::Environment::Invoke(sp::PluginContext *,ke::RefPtr<sp::MethodInfo> const &,int *) [ environment.cpp:346 + 0x18 ]
          https://github.com/alliedmodders/sourcepawn/blob/208001a01baaf98d4601e31fda0ab9c849fa700d/vm/environment.cpp#L346
          eip: 0x79e71aae  esp: 0x00efd468  ebp: 0x00efd4ac  
    
          00efd468  38 7c 20 21 90 7e e5 31  60 da ef 00 41 dc 51 72  8| !.~.1`...A.Qr
          00efd478  03 00 00 00 38 7c 20 21  00 3e 00 27 80 fb ee 79  ....8| !.>.'...y
          00efd488  00 00 00 00 38 7c 20 21  00 00 00 00 00 00 00 00  ....8| !........
          00efd498  a0 b6 c2 0f 08 bb c2 0f  ec d4 ef 00 80 b3 ee 79  ...............y
          00efd4a8  00 00 00 00 f8 d4 ef 00  22 74 e8 79              ........"t.y    
    
          Found via previous frame's frame pointer
    
    
       4: sourcepawn.jit.x86.dll!sp::PluginContext::Invoke(unsigned int,int const *,unsigned int,int *) [ plugin-context.cpp:461 + 0x10 ]
          https://github.com/alliedmodders/sourcepawn/blob/208001a01baaf98d4601e31fda0ab9c849fa700d/vm/plugin-context.cpp#L461
          eip: 0x79e87422  esp: 0x00efd4b4  ebp: 0x00efd4f8  
    
          00efd4b4  38 7c 20 21 18 d2 cb 2f  60 da ef 00 15 dc 51 72  8| !.../`.....Qr
          00efd4c4  03 00 00 00 01 00 00 00  c8 3e 00 27 00 00 80 41  .........>.'...A
          00efd4d4  ff ff ff ff 08 4f 00 00  38 7c 20 21 a4 0d 00 00  .....O..8| !....
          00efd4e4  c0 cf cb 2f 0b 00 00 00  10 da ef 00 17 c6 ee 79  .../...........y
          00efd4f4  02 00 00 00 e8 d9 ef 00  25 39 e8 79              ........%9.y    
    
          Found via call frame info
    
    
       5: sourcepawn.jit.x86.dll!sp::ScriptedInvoker::Invoke(int *) [ scripted-invoker.cpp:290 + 0x21 ]
          https://github.com/alliedmodders/sourcepawn/blob/208001a01baaf98d4601e31fda0ab9c849fa700d/vm/scripted-invoker.cpp#L290
          eip: 0x79e83925  esp: 0x00efd500  ebp: 0x00efd9e8  
    
          00efd500  05 00 00 00 64 d9 ef 00  60 da ef 00 08 4f 00 00  ....d...`....O..
          00efd510  00 6c 34 64 5f 62 6f 74  5f 68 65 61 6c 69 6e 67  .l4d_bot_healing
          00efd520  2e 73 6d 78 3a 3a 2e 35  34 32 30 2e 44 65 74 6f  .smx::.5420.Deto
          00efd530  75 72 55 73 65 48 65 61  6c 69 6e 67 50 72 65 00  urUseHealingPre.
          00efd540  a0 b6 c2 0f c8 3e 00 27  c8 3e 00 27 60 da ef 00  .....>.'.>.'`...
          00efd550  e0 3e 00 27 10 d5 ef 00  03 00 00 00 e8 84 ec 26  .>.'...........&
          00efd560  00 3e f2 2f 00 00 00 00  00 00 00 00 00 00 00 00  .>./............
          00efd570  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
          00efd580  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
          00efd590  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
          00efd5a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
          00efd5b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
          00efd5c0  00 00 00 00 e8 d5 ef 00  d4 d5 ef 00 14 06 cf 26  ...............&
          00efd5d0  24 d6 ef 00 14 06 cf 26  10 00 00 00 68 3d 30 1a  $......&....h=0.
          00efd5e0  00 d6 ef 00 c3 ec d6 79  68 3d 30 1a 00 00 00 00  .......yh=0.....
          00efd5f0  00 00 00 00 f4 6e 00 00  1c d6 ef 00 74 65 cf 26  .....n......te.&
          00efd600  20 d6 ef 00 ad d2 ca 79  a1 06 80 6d 30 00 00 00   ......y...m0...
          00efd610  20 60 2e 1a 1c d6 ef 00  a1 06 80 6d 28 ea 15 27   `.........m(..'
          00efd620  38 d6 ef 00 0b aa cc 79  a1 06 80 6d 44 d6 ef 00  8......y...mD...
          00efd630  00 00 00 00 70 f6 ce 26  68 d6 ef 00 f0 31 e3 31  ....p..&h....1.1
          00efd640  70 cb b5 26 28 f8 11 27  90 17 00 00 00 00 00 00  p..&(..'........
          00efd650  50 00 00 00 03 00 00 00  68 d6 ef 00 f0 31 e3 31  P.......h....1.1
          00efd660  90 16 00 00 02 00 00 00  90 d6 ef 00 d7 00 de 1f  ................
          00efd670  94 d6 ef 00 27 69 e7 79  39 69 e7 79 9c d6 ef 00  ....'i.y9i.y....
          00efd680  98 69 e7 79 b1 69 e7 79  71 de 51 72 08 bb c2 0f  .i.y.i.yq.Qr....
          00efd690  d0 d6 ef 00 65 b9 ee 79  00 00 00 00 dc d6 ef 00  ....e..y........
          00efd6a0  c3 1a e7 79 31 de 51 72  03 00 00 00 70 cb b5 26  ...y1.Qr....p..&
          00efd6b0  00 ac 20 27 70 fb ee 79  00 00 00 00 70 cb b5 26  .. 'p..y....p..&
          00efd6c0  00 00 00 00 00 00 00 00  a0 b6 c2 0f 08 bb c2 0f  ................
          00efd6d0  1c d7 ef 00 80 b3 ee 79  00 00 00 00 28 d7 ef 00  .......y....(...
          00efd6e0  22 74 e8 79 70 cb b5 26  d0 39 d7 2f 98 dc ef 00  "t.yp..&.9./....
          00efd6f0  c5 df 51 72 03 00 00 00  01 00 00 00 d0 ac 20 27  ..Qr.......... '
          00efd700  90 17 00 00 ff ff ff ff  1c 6f 00 00 70 cb b5 26  .........o..p..&
          00efd710  90 17 00 00 08 39 d7 2f  20 dc ef 00 48 dc ef 00  .....9./ ...H...
          00efd720  17 c6 ee 79 04 00 00 00  20 dc ef 00 25 39 e8 79  ...y.... ...%9.y
          00efd730  27 00 00 00 9c db ef 00  98 dc ef 00 bc 39 e8 79  '............9.y
          00efd740  20 5b 4c 34 44 32 5d 20  53 75 72 76 69 76 6f 72   [L4D2] Survivor
          00efd750  20 41 6e 69 6d 61 74 69  6f 6e 20 46 69 78 20 70   Animation Fix p
          00efd760  61 63 6b 2e 73 6d 78 3a  3a 4f 6e 53 65 71 75 65  ack.smx::OnSeque
          00efd770  6e 63 65 53 65 74 00 79  a0 b6 c2 0f d0 ac 20 27  nceSet.y...... '
          00efd780  d8 39 e8 79 98 dc ef 00  e8 ac 20 27 40 d7 ef 00  .9.y...... '@...
          00efd790  03 00 00 00 10 c8 14 27  41 df 51 01 30 26 b4 ae  .......'A.Q.0&..
          00efd7a0  00 40 00 00 5c 56 00 00  07 00 00 00 06 00 00 00  [email protected]\V..........
          00efd7b0  dc 00 00 00 05 00 00 00  25 00 00 00 f4 b6 c2 0f  ........%.......
          00efd7c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................
          00efd7d0  30 98 6b 8c bf a4 d8 01  6f 92 93 02 30 26 b4 ae  0.k.....o...0&..
          00efd7e0  00 40 00 00 6c 46 00 00  07 00 00 00 06 00 00 00  [email protected]
          00efd7f0  fb 00 00 00 05 00 00 00  25 00 00 00 a8 dd ef 00  ........%.......
          00efd800  d5 d0 51 72 02 00 00 00  01 00 00 00 f0 54 24 27  ..Qr.........T$'
          00efd810  1c d8 ef 00 ff ff ff ff  6c 5d 01 00 00 1d 9b 79  ........l].....y
          00efd820  48 2c 55 08 48 d8 ef 00  f4 b8 92 79 60 9c 50 79  H,U.H......y`.Py
          00efd830  40 04 96 0a 60 9c 50 79  60 9c 50 79 40 26 08 05  @...`.Py`[email protected]&..
          00efd840  60 9c 50 79 40 26 08 05  70 d9 ef 00 03 64 37 79  `[email protected]&..p....d7y
          00efd850  00 a0 fe 7f 08 03 00 00  5f be f1 76 f8 d8 ef 00  ........_..v....
          00efd860  fc d8 ef 00 e8 12 95 03  ff ff ff ff 00 73 74 54  .............stT
          00efd870  68 69 6e 6b 50 6f 73 74  00 38 e8 79 a0 b6 c2 0f  hinkPost.8.y....
          00efd880  f0 54 24 27 d8 39 e8 79  16 35 21 23 00 d9 ef 00  .T$'.9.y.5!#....
          00efd890  ec bc f1 76 ff ff ff ff  f8 d8 ef 00 9b bd f1 76  ...v...........v
          00efd8a0  ae 5e d1 2b 00 00 00 00  48 03 fe 7f 00 00 00 00  .^.+....H.......
          00efd8b0  00 00 00 00 00 00 00 00  00 00 00 00 0d 92 08 1f  ................
          00efd8c0  1d 03 00 00 21 61 7d d9  57 6a 03 00 91 10 9f ba  ....!a}.Wj......
          00efd8d0  08 03 00 00 01 00 00 00  48 61 6c 54 00 a0 fe 7f  ........HalT....
          00efd8e0  00 00 00 00 00 00 00 00  fd d7 00 00 f4 47 c6 00  .............G..
          00efd8f0  dd 63 e9 00 36 69 3d 3f  4c 01 2c c2 40 d9 ef 00  .c..6i=?L.,[email protected]
          00efd900  cb bb f1 76 ae 5e d1 2b  04 bc f1 76 9c d9 ef 00  ...v.^.+...v....
          00efd910  90 7a eb 74 a8 39 e2 79  9e a2 a7 d9 25 06 00 00  .z.t.9.y....%...
          00efd920  20 a6 d8 01 0d 8e 91 2c  25 06 00 00 00 00 00 00   ......,%.......
          00efd930  00 00 00 80 00 00 00 00  18 0c 00 00 5c d9 ef 01  ............\...
          00efd940  48 d9 ef 00 9b 7a eb 74  78 d9 ef 00 8c d9 ef 00  H....z.tx.......
          00efd950  9c d9 ef 00 c5 8c ce 79  25 1a 53 57 41 f4 3a 00  .......y%.SWA.:.
          00efd960  80 96 98 00 30 36 ae 31  bd 06 00 15 d2 06 10 15  ....06.1........
          00efd970  25 9a 91 2c 00 00 00 00  9c d9 ef 00 07 8d ce 79  %..,...........y
          00efd980  8c d9 ef 00 01 00 00 00  d0 9a f5 20 44 9a e8 62  ........... D..b
          00efd990  00 00 00 00 74 8e d4 19  00 00 00 00 ac d9 ef 00  ....t...........
          00efd9a0  4b 5e cc 79 00 00 00 00  30 4b 30 1a c8 d9 ef 00  K^.y....0K0.....
          00efd9b0  e7 99 cd 79 00 00 00 00  dd f9 d6 79 38 7c 20 21  ...y.......y8| !
          00efd9c0  90 1b cf 2f 88 7e df 79  e8 d9 ef 00 f9 ed d6 79  .../.~.y.......y
          00efd9d0  d2 06 10 15 d0 3d f2 2f  30 4b 30 1a 40 da ef 00  .....=./[email protected]
          00efd9e0  00 00 00 00 05 d1 51 72  1c da ef 00 15 36 e8 79  ......Qr.....6.y
    __________________
    HarryPotter is offline
    Toranks
    Senior Member
    Join Date: Dec 2021
    Location: Spain
    Old 08-02-2022 , 00:05   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #3

    Quote:
    Originally Posted by HarryPotter View Post
    l4d2 windows server,
    launch server -> join server -> crash

    Accelerator uploaded crash dump: Crash ID: IDYH-4XRE-YPYZ
    Exactly the same here, I think Silver has been confused the file or version, because I have a different one that has been working perfectly for days
    Toranks is offline
    Forgetest
    Member
    Join Date: Aug 2020
    Old 08-02-2022 , 03:03   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #4

    I think detour isn't needed as for changing constant values. Here maybe is a good one utilizing Source Scramble.
    Forgetest is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 08-02-2022 , 04:20   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #5

    Quote:
    Originally Posted by Forgetest View Post
    I think detour isn't needed as for changing constant values. Here maybe is a good one utilizing Source Scramble.
    The reason for this method is no extra dependencies, only dhooks which is part of SM now. Also on Linux L4D1 and previous to recent L4D2 updates the dword address was read differently using LEA or so something and I wouldn't know how to change that to read a new address.

    Will upload fix for windows soon.

    Edit: Linux L4D2 crashing also, no idea why, was working before.
    __________________

    Last edited by Silvers; 08-02-2022 at 05:03.
    Silvers is offline
    Forgetest
    Member
    Join Date: Aug 2020
    Old 08-02-2022 , 05:36   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #6

    Quote:
    Originally Posted by Silvers View Post
    The reason for this method is no extra dependencies, only dhooks which is part of SM now. Also on Linux L4D1 and previous to recent L4D2 updates the dword address was read differently using LEA or so something and I wouldn't know how to change that to read a new address.
    I can tell L4D1 Linux mostly addresses constants relatively, and I would then change the opcode to an absolute addressing one.
    Though you're right as now DHooks becomes a part of SM, I think Source Scramble is kinda widely used at least on my end xD.

    P.S.
    Suggestion that it might help to add the following ConVars about how bots decide on healing others.
    Code:
    sb_temp_health_consider_factor           : 0.5      : , "sv", "launcher" : Temporary health is multiplied by this when SurvivorBots consider who needs healing
    sb_toughness_buffer                      : 15       : , "sv", "launcher" : How much more SurvivorBots must be hurt to conider themselves equally valid as a healing target
    Quote:
    Originally Posted by Silvers View Post
    Edit: Linux L4D2 crashing also, no idea why, was working before
    Perhaps it has something to do with the read-only protection.
    Forgetest is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 08-02-2022 , 05:48   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #7

    Setting StoreToAddress updateMemAccess to true or false both produce the same crash. So I guess this method is dead too.
    __________________
    Silvers is offline
    Forgetest
    Member
    Join Date: Aug 2020
    Old 08-02-2022 , 06:45   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #8

    I would say setup is all fine, the most possible reason should be the value being edited on is read-only protected by OS:

    Quote:
    Originally Posted by HarryPotter View Post
    Code:
    EXCEPTION_ACCESS_VIOLATION_WRITE accessing 0x7944f590
    
    Thread 0 (crashed):
       0: sourcemod.logic.dll!StoreToAddress [ smn_core.cpp:899 + 0x0 ]
    Edit:
    I also tried the patching way I prefer to, no more crashing on Linux L4D2 at least. I'm not sure how to test properly, but setting "l4d_bot_healing_first" to 10.0 made bots heal me when below 10HP.

    For Linux L4D1, let's say:
    Code:
    D9 83 58 2B D8 FF        fld     ds:(flt_92E7E8 - 0BABC90h)[ebx]
    "D9 83" indicates reading a value from "[ebx] + FFD82B58", relative addressing.
    However, you can change the "83" to "05" so the assemble becomes:
    Code:
    D9 05 58 2B D8 FF        fld     dword ptr ds:0xFFD82B58
    And now it will straight loads a value from "0xFFD82B58" which can be later changed to our own one.

    If you decide to move on Source Scramble, above things should be helpful.

    Last edited by Forgetest; 08-02-2022 at 07:04.
    Forgetest is offline
    Sev
    Veteran Member
    Join Date: May 2010
    Old 08-02-2022 , 13:58   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #9

    Here I was excited this would lead to something like only allowing the bots to heal themselves or others with medkits on the final strike.

    Oh well.
    Sev is offline
    Toranks
    Senior Member
    Join Date: Dec 2021
    Location: Spain
    Old 08-02-2022 , 20:42   Re: [L4D & L4D2] Bot Healing Values (1.0) [01-Aug-2022]
    Reply With Quote #10

    Quote:
    Originally Posted by Sev View Post
    Here I was excited this would lead to something like only allowing the bots to heal themselves or others with medkits on the final strike.

    Oh well.
    That specific function already exists, with Actions. But it would be great if it was incorporated into this plugin, since this is just an extension:

    https://forums.alliedmods.net/showpo...20&postcount=1
    Toranks is offline
    Reply


    Thread Tools
    Display Modes

    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 19:19.


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