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

[L4D/L4D2] Precise ThirdPerson Aim (Listen only)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Toranks
Senior Member
Join Date: Dec 2021
Location: Spain
Plugin ID:
8069
Plugin Version:
1.0
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
Servers with this Plugin:
 
Plugin Description:
Bullets hit where the crosshair points, with total accuracy, as in first person
Old 05-29-2022 , 04:49   [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #1

LISTEN SERVER ONLY
(SourceMod doesn't support Listen Servers)


Explanation:
In third person, crosshair aiming is controlled by an unprotected cvar but is locked by Valve when playing online, so it can only be entered on console typing yourself.

The only two possible ways to change this cvar automatically so far is with Vslib and now this plugin on sourcemod. And both only work for the client that hosts the game on a listen server. It is impossible to recreate this functionality for the other players of the listen server, or on a dedicated server, AFAIK.

It is very useful for those who like to play in third person, and at least one of the players can enjoy this functionality.
I haven't tested in L4D1 but it's simple code and should work fine.

Requirement:
It only activates when you are in third person, so requires this plugin:
[L4D/L4D2]ThirdPersonShoulder_Detect(1.5.3 - 08/06/2020)


Notes:
- With a low timer you will notice a rattle of the screen when you walk looking to irregular surfaces. You can adjust the speed at which the aim changes with l4d_autoaim_rate CVAR (cfg file autogenerated too) to the value with which you feel most comfortable. Default value is 0.5 sec, but you can use numbers as low as 0.01 with no appreciable FPS drops.
- On third person, melee weapons, certain items, some survivor custom models, some attached models, etc can interfere with the flashlight causing very annoying shadows. (See images section below). With a specific CVAR l4d_autoaim_hide_shadows, you can choose whether to disable these shadows and restore them when you return to first person fully automatically so you don't lose shadow effects in unobtrusive situations.
- With Vslib a too fast timer produced FPS drops. Also using Vslib can cause Engine Error ED_Alloc: no free edicts error on some maps with many entities. With this plugin it is much more efficient and is impossible to cause this kind of crashes.

CVARS:
Code:
// Sef if you want to turn off dynamic flashlight shadows to avoid your own body shadows obstructing the vision only while on thirdperson.
// -
// Default: "1"
l4d_autoaim_hide_shadows "1"

// Time between each aim adjustment.
// -
// Default: "0.5"
l4d_autoaim_rate "0.5"
Changes
Code:
1.1 (31-May-2022)
    - Better client index detection. (Thanks to Marttt)
    - Better coding and performance. (Thanks to Silvers)
    - Added CVAR to disable dynamic shadows while on third person.

1.0 (29-May-2022)
    - Initial Release.
Useful links:
Survivor Thirdperson (Silvers), works on versus or infecteds
Workshop Vslib third person Auto-aim:
Workshop Vslib third person Auto-aim + shotgun sound fix (only for client)
Shotgun sound fix with sourcemod Windows version (for all clients)
Shotgun sound fix with sourcemod Linux version (for all clients)

Images:
Example
Example 2
Example 3
Example 4
Flashlight shadows on third person
Shadow fixed with l4d_autoaim_hide_shadows "1"
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_AutoaimOnThird.sp - 713 views - 5.8 KB)

Last edited by Toranks; 05-30-2022 at 18:53.
Toranks is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 05-29-2022 , 10:12   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #2

You left out the actual error message, which is the "Exception reported" line.
__________________
Psyk0tik is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 05-29-2022 , 10:29   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #3

According to the line error seems that the client index parameter is fixed as 1.
Gonna say that is not safe cause the "host" can become another client index besides 1.
Probably is throwing a "Client 1 is not in-game" exception.
__________________

Last edited by Marttt; 05-29-2022 at 10:30.
Marttt is offline
Toranks
Senior Member
Join Date: Dec 2021
Location: Spain
Old 05-29-2022 , 11:13   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #4

It should only work for the host player. Isn't it always supposed to be client 1?
Toranks is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 05-29-2022 , 11:54   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #5

No, it can change.
If you want to get the host client index check my plugin: https://forums.alliedmods.net/showthread.php?t=332763
__________________
Marttt is offline
Maur0
Senior Member
Join Date: Aug 2020
Old 05-29-2022 , 14:44   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #6

At last! Just what she needed! Thank you very much!
Maur0 is offline
Toranks
Senior Member
Join Date: Dec 2021
Location: Spain
Old 05-30-2022 , 19:00   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #7

While playing, I saw a message similar to the one reported above, but that didn't break the plugin at all. It just continued to function normally. And errors don't happen all the time, just sometimes and for a few seconds.
I used the same method as Martt to detect the client index now. And I have not seen that message again. I hope it works better this way.

Plus I've added the ability to turn off that annoying shadows automatically only in third person. Many people use a permanently disabled cvar for this, but then they can't see shadows in first person either.
In the future, I'll learn how to improve the behavior of this feature so that it only triggers on melee and objects that create those shadows (because the focus of light is on the chest or head), but not on firearms, which don't have that problem (because the light source is at the tip of the gun).

Code:
1.1 (31-May-2022)
    - Better client index detection. (Thanks to Marttt)
    - Better coding and performance. (Thanks to Silvers)
    - Added CVAR to disable dynamic shadows while on third person.
Toranks is offline
Beatles
Senior Member
Join Date: Feb 2014
Old 08-29-2022 , 02:41   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #8

Quote:
Originally Posted by Toranks View Post
I haven't tested in L4D1 but it's simple code and should work fine.
Hello, I love your plugin, but unfortunately I found an error when using it in L4D1, I attach here the corrected file, now it really works in L4D1.
Attached Files
File Type: sp Get Plugin or Get Source (l4d2_AutoaimOnThird.sp - 254 views - 5.8 KB)
File Type: smx l4d2_AutoaimOnThird.smx (6.2 KB, 195 views)
Beatles is offline
Hajitek Majitek
Junior Member
Join Date: Oct 2021
Old 09-17-2022 , 10:59   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #9

Hello Toranks! Thank you so much for making this wonderful plugin! My only issue is that the auto aim moves the screen every time you move, which is annoying, so I'd like to propose a different method of auto aiming that doesn't use a timer and instead detects when you press the left mouse button (shooting button) and begins fixing your aiming there. Do you think it's possible?
Hajitek Majitek is offline
Hajitek Majitek
Junior Member
Join Date: Oct 2021
Old 11-10-2022 , 05:54   Re: [L4D/L4D2] Precise ThirdPerson Aim (Listen only)
Reply With Quote #10

I'm getting this error.
Quote:
L 11/08/2022 - 18:24:57: SourceMod error session started
L 11/08/2022 - 18:24:57: Info (map "castle_massacre_v_2_1_2") (file "D:\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\logs\errors_202 21108.log")
L 11/08/2022 - 18:24:57: [SM] Exception reported: Client 1 is not connected
L 11/08/2022 - 18:24:57: [SM] Blaming: l4d2_AutoaimOnThird.smx
L 11/08/2022 - 18:24:57: [SM] Call stack trace:
L 11/08/2022 - 18:24:57: [SM] [0] ClientCommand
L 11/08/2022 - 18:24:57: [SM] [1] Line 185, D:\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\l4d2_ AutoaimOnThird.sp::TP_OnThirdPersonChanged
L 11/08/2022 - 18:24:57: [SM] [3] Call_Finish
L 11/08/2022 - 18:24:57: [SM] [4] Line 141, D:\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\Third PersonShoulder_Detect.sp::TP_PushForwardToPlu gins
L 11/08/2022 - 18:24:57: [SM] [5] Line 126, D:\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\scripting\Third PersonShoulder_Detect.sp::QueryClientConVarCa llback
L 11/08/2022 - 18:24:59: Error log file session closed.
L 11/08/2022 - 18:28:14: SourceMod error session started
L 11/08/2022 - 18:28:14: Info (map "turielspass") (file "D:\Steam\steamapps\common\Left 4 Dead 2\left4dead2\addons\sourcemod\logs\errors_202 21108.log")
L 11/08/2022 - 18:28:14: [CRASH] Accelerator uploaded crash dump: Crash ID: GMOK-BNUZ-LKFV

Last edited by Hajitek Majitek; 11-10-2022 at 05:55.
Hajitek Majitek 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 07:27.


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