Raised This Month: $ Target: $400
 0% 

[L4D & L4D2] Left 4 DHooks Direct (1.147) [30-Apr-2024]


Post New Thread Reply   
 
Thread Tools Display Modes
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 09-07-2021 , 03:32   Re: [L4D & L4D2] Left 4 DHooks Direct (1.52) [31-Aug-2021]
Reply With Quote #441

The first should be fine then, from testing it works and triggers the forward constantly if someones outside. So blocking the forward probably works as is with this patch. Thanks again for the method. Will release the update with a new forward and some natives for L4D1 soon after HarryPotter finishes testing them.
__________________
Silvers is offline
Forgetest
Member
Join Date: Aug 2020
Old 09-07-2021 , 10:38   Re: [L4D & L4D2] Left 4 DHooks Direct (1.52) [31-Aug-2021]
Reply With Quote #442

By the way, I noticed a director variable that tends to be m_iTankCount in L4D1 binary, when I was investigating something else. It seems you didn't make it into the L4D1 gamedata, so I might paste it here.

Code:
Found in "Director::UpdateVersusBossSpawning"
Linux: 524
Windows: 528
And probably the m_iWitchCount is next to it. Maybe I can confirm it later.

Edit: Well there's none. Only found this:
PHP Code:
Director *__cdecl Director::OnWitchAdded(Director *this)
{
  
Director *result// eax

  
result this;
  *((
_BYTE *)this 792) = 1;
  return 
result;


Last edited by Forgetest; 09-07-2021 at 12:19.
Forgetest is offline
Shadow Mirror
Junior Member
Join Date: Mar 2016
Old 09-07-2021 , 11:48   Re: [L4D & L4D2] Left 4 DHooks Direct (1.52) [31-Aug-2021]
Reply With Quote #443

Quote:
Originally Posted by Marttt View Post
Just redownload the plugin and overwrite/replace the current install.
Hello again, thanks for the answers, my problem just solved, it was my sourcemod build was outdated like 2 or 3 old versions, DHooks now works ok
Shadow Mirror is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 09-09-2021 , 03:09   Re: [L4D & L4D2] Left 4 DHooks Direct (1.53) [09-Sep-2021]
Reply With Quote #444

Code:
1.53 (09-Sep-2021)
    - Update for L4D1:

    - Added forward "L4D_OnRecalculateVersusScore" from "raziEiL"'s port of "L4D Direct".
    - Added natives "L4DDirect_GetSurvivorHealthBonus", "L4DDirect_SetSurvivorHealthBonus" and "L4DDirect_RecomputeTeamScores" from "raziEiL"'s port of "L4D Direct".
    - Changed native "L4D2_GetTankCount" to use the directors variable instead of counting entities. Thanks to "Forgetest" for the offsets.
    - Unblocked native "L4D_GetTeamScore" for usage in L4D1. Accepts logical_team params 1-6.
    - Fixed forward "L4D_OnFirstSurvivorLeftSafeArea" not blocking correctly. Thanks to "Forgetest" for the solution.
    - Various fixes and additions thanks to "HarryPotter" for requesting and testing.

    - L4D1 GameData file, include file and plugins updated.
__________________
Silvers is offline
HarryPotter
Veteran Member
Join Date: Sep 2017
Location: Taiwan, Asia
Old 09-09-2021 , 09:02   Re: [L4D & L4D2] Left 4 DHooks Direct (1.53) [09-Sep-2021]
Reply With Quote #445

Quote:
Originally Posted by Silvers View Post
Code:
1.53 (09-Sep-2021)
Thanks, silvers.
Almost there, I can finish my l4d1 roto rework.

PHP Code:
// L4D2 only. Get a reference to the CDirector natural mob spawn CountdownTimer
native CountdownTimer L4D2Direct_GetMobSpawnTimer(); 
Code:
left4dhooks.l4d1.txt
			// "MobTimer"
			// {
				// "windows"	"652"
				// "linux"		"648"
			// }
this function can be called in l4d1, I have already tried and it outputs the expected outcome.
__________________

Last edited by HarryPotter; 09-09-2021 at 09:04.
HarryPotter is offline
Forgetest
Member
Join Date: Aug 2020
Old 09-09-2021 , 10:36   Re: [L4D & L4D2] Left 4 DHooks Direct (1.52) [31-Aug-2021]
Reply With Quote #446

Quote:
Originally Posted by HarryPotter View Post
PHP Code:
// Is used for displaying the "X gets Tank" window and transferring Tank control
forward Action L4D_OnTryOfferingTankBot(int tank_indexbool &enterStasis); 
this function is not working first time director tank spawns in l4d1 linux.

PHP Code:
// Called when a Witch spawns
forward Action L4D_OnSpawnWitch(const float vecPos[3], const float vecAng[3]); 
this function is not working in l4d1 linux.
I believe the L4D_OnSpawnWitch has two overloaded functions, and one of them should be a wrapper of the other. But it seems not the case on L4D1 Linux, where the two are standalone. Is it more reasonable to make another detour, as long as ZombieManager::FindValidSpawnPosition is reachable?

Code:
ZombieManager::SpawnWitch(TerrorNavArea const*,QAngle const&)
ZombieManager::SpawnWitch(Vector const&,QAngle const&)
PHP Code:
// pseudocode of "ZombieManager::SpawnWitch(TerrorNavArea const*,QAngle const&)"

CBaseEntity *__cdecl ZombieManager::SpawnWitch(int a1int a2int a3)
{
  
CBaseEntity *v3// eax
  
CBaseEntity *v4// edi
  
CBaseEntity *result// eax
  
char v6[24]; // [esp+14h] [ebp-18h] BYREF

  
if ( (unsigned __int8)ZombieManager::FindValidSpawnPosition(v6) )
  {
    
v3 = (CBaseEntity *)CreateEntityByName("witch", -11);
    
v4 v3;
    if ( 
v3 )
    {
      
CBaseEntity::SetAbsOrigin(v3, (const Vector *)v6);
      
CBaseEntity::SetAbsAngles(v4a3);
      
DispatchSpawn(v4);
      
CL4DGameStats::Event_SpawnZombie(&CL4D_GameStats41);
    }
    
result v4;
  }
  else
  {
    
Warning("Failed to find a witch spawn position in area %d\n", *(_DWORD *)(a2 136));
    
result 0;
  }
  return 
result;

As for L4D_OnTryOfferingTankBot, I noticed something similar to the above, but seems I was not getting right there, crashing all the time.

Code:
Director::TryOfferingTankBot(CBaseEntity *,bool) [clone]
Director::TryOfferingTankBot(CBaseEntity *,bool)
PHP Code:
// pseudocode of "Director::TryOfferingTankBot(CBaseEntity *,bool)"

Director *__cdecl Director::TryOfferingTankBot(Director *thisCBaseEntity *a2bool a3)
{
  
Director *result// eax

  
result this;
  if ( 
a2
    
&& *((float *)this 146) <= 0.0
    
&& *((float *)this 449) <= 0.0
    
&& (!*(_BYTE *)(TheDirector 358) || *(_DWORD *)(TheDirector 408) != 3) )
  {
    
result = (Director *)Director::TryOfferingTankBot((int)thisa20.0, (Director *)a3); // the [clone]
  
}
  return 
result;

PHP Code:
// partial pseudocode of "Director::UpdateVersusBossSpawning"

          
result ZombieManager::SpawnTank(TheZombieManagerv17v41);
          if ( 
result )
          {
            
v34 = (Vector *)result;
            
SearchSurroundingAreas<RemoveWanderersScan>(
              (
CNavArea *)v17,
              (
Vector *)(v17 11),
              (int)
v43,
              *(
float *)(dword_C8B17C 44),
              
0,
              -
1);
            
result = (int)v34;
            if ( *((
float *)this 146) <= 0.0
              
&& *((float *)this 449) <= 0.0
              
&& (!*(_BYTE *)(TheDirector 358) || *(_DWORD *)(TheDirector 408) != 3) )
            {
              
result Director::TryOfferingTankBot((Director *)((char *)&dword_0 1)); // the [clone]
            
}
            *((
_BYTE *)this v3 1876) = 0;
            return 
result;
          } 
The clone one is used instead in Director::UpdateVersusBossSpawning, so I'd suggest it's the cause. But I might fail in setup the dhook, being actual newbie to this.

Code:
The type of [clone] function in IDA

IDA View -
; int __cdecl Director::TryOfferingTankBot(Director *)
_ZN8Director18TryOfferingTankBotEP11CBaseEntityb_part_203

Pseudocode View -
int __usercall Director::TryOfferingTankBot@<eax>(int a1@<eax>, const void *a2@<edx>, long double a3@<st0>, Director *a4)
Forgetest is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 09-09-2021 , 11:15   Re: [L4D & L4D2] Left 4 DHooks Direct (1.53) [09-Sep-2021]
Reply With Quote #447

You should be able to hook the clone the same as "TryOfferingTankBot" with the same detour functions.

Just noticed Windows seems to hook the clone, and Linux the original. Have to sort that out. Think both need hooking still? It should be possible to hook them both for the same forward, just changed the signature string is all.
__________________

Last edited by Silvers; 09-09-2021 at 11:23.
Silvers is offline
Forgetest
Member
Join Date: Aug 2020
Old 09-09-2021 , 12:44   Re: [L4D & L4D2] Left 4 DHooks Direct (1.53) [09-Sep-2021]
Reply With Quote #448

Quote:
Originally Posted by Silvers View Post
You should be able to hook the clone the same as "TryOfferingTankBot" with the same detour functions.

Just noticed Windows seems to hook the clone, and Linux the original. Have to sort that out. Think both need hooking still? It should be possible to hook them both for the same forward, just changed the signature string is all.
I tried it first and ended up with crashes. No further attempt for I decided to share the information before the end of day.

I think there's possibility that the call conversion is to blame there, or not, when I noticed it's a "jmp" instruction, other than a "call".
Forgetest is offline
Forgetest
Member
Join Date: Aug 2020
Old 09-10-2021 , 00:55   Re: [L4D & L4D2] Left 4 DHooks Direct (1.53) [09-Sep-2021]
Reply With Quote #449

Code:
"Games"
{
	"left4dead"
	{
		"Functions"
		{
			"TryOfferingTankBot_clone"
			{
				"signature"		"TryOfferingTankBot_clone"
				"callconv"		"cdecl"
				"return"		"int"
				"this"			"ignore"
				"arguments"
				{
					"a1"
					{
						"type"	"objectptr"
						"register"	"eax"
					}
					"a2"
					{
						"type"	"cbaseentity"
						"register"	"edx"
					}
					"a3"
					{
						"type"	"bool"
					}
				}
			}
		}
		
		"Signatures"
		{
			/*
			 * CDirector::TryOfferingTankBot(void) [clone]
			 * unique string "Tank offer: Starting the lottery\n"
			 */
			"TryOfferingTankBot_clone"
			{
				"library"	"server"
				"linux"		"\x55\x57\x56\x53\x83\xEC\x3C\xE8\x2A\x2A\x2A\x2A\x81\xC3\xC8\x0C\x57\x00"
				/**
				 *	Signature for _ZN8Director18TryOfferingTankBotEP11CBaseEntityb_part_203:
				 *	55 57 56 53 83 EC 3C E8 ? ? ? ? 81 C3 C8 0C 57 00
				 */
			}
		}
	}
}
Seems to be it, params and blocking were performing correctly.
The signature wasn't wildcarded manually, I used makesig.idc.

Probably we don't need to hook both functions, as the non-clone one is indeed a wrapper to this, unless this one bugs out.

Last edited by Forgetest; 09-10-2021 at 01:00.
Forgetest is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 09-12-2021 , 08:28   Re: [L4D & L4D2] Left 4 DHooks Direct (1.54) [12-Sep-2021]
Reply With Quote #450

Code:
1.54 (12-Sep-2021)
    - Big thanks to "Forgetest" and "HarryPotter" for helping fix and test this release.

    - Added forward "L4D_OnGameModeChange" to notify plugins when the mode has changed to Coop, Versus, Survival and Scavenge (L4D2).
    - Added native "L4D_GetGameModeType" to return if the current game mode is Coop, Versus, Survival or Scavenge (L4D2).

    - Update for L4D1:

    - Fixed on Linux forward "L4D_OnSpawnWitch" from not triggering for some Witch spawns. Thanks to "Forgetest" for fixing.
    - Fixed on Linux forward "L4D_OnTryOfferingTankBot" from not triggering on the first tank. Thanks to "Forgetest" for fixing.
    - Unlocked native "L4D2Direct_GetMobSpawnTimer" for usage in L4D1. Thanks to "HarryPotter" for reporting functionality.
    - Unlocked native "L4D2Direct_GetTankCount" for usage in L4D1. Missed this from the last update.

    - L4D1 GameData file, include file and plugins updated.
Code:
1.55 (12-Sep-2021)
    - Fixed native "L4D2Direct_TryOfferingTankBot" not working for L4D1 Linux due to the last update. Thanks to "Forgetest" for reporting.
    - L4D1 gamedata file updated only.
__________________

Last edited by Silvers; 09-12-2021 at 16:06.
Silvers 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 23:45.


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