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

[L4D] Boss Rush


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Beatles
Senior Member
Join Date: Feb 2014
Old 07-27-2021 , 02:23   [L4D] Boss Rush
Reply With Quote #1

This plugin was written for L4D2, and although I have tried to do this same function in L4D1, I have not been successful, I would like to know if someone can help me with the equivalents of these 2 values in L4D1:

L4D_GetVersusMaxCompletionScore
L4D_SetVersusMaxCompletionScore

Or some way to be able to do this same function in L4D1.

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <left4dhooks>

new iDistance;
new 
witchIndex;

new 
bool:bTankPointsFrozen;
new 
bool:bWitchPointsFrozen;

public 
Plugin:myinfo 
{
    
name "L4D2 No Boss Rush",
    
author "Visor; originally by Jahze, vintik",
    
version "2.1",
    
description "Stops distance points accumulating whilst the Tank or Witch are alive",
    
url "https://github.com/Attano/Equilibrium"
};

public 
OnPluginStart()
{
    
HookEvent("round_start"EventHook:OnRoundStartEventHookMode_PostNoCopy);
    
HookEvent("tank_spawn"EventHook:OnTankSpawnEventHookMode_PostNoCopy);
    
HookEvent("player_death"OnPlayerDeath);
    
HookEvent("witch_spawn"OnWitchSpawn);
    
HookEvent("witch_killed"EventHook:OnWitchKilledEventHookMode_PostNoCopy);
}

public 
OnRoundStart()
{
    if (
InSecondHalfOfRound())
    {
        
UnFreezePoints();
    }
}

/* Tank */

public OnTankSpawn()
{
    if (!
bTankPointsFrozen && !bWitchPointsFrozen)
    {
        
PrintToChatAll("\x01[\x04NoBossRush\x01] Tank spawned. Freezing distance points!");
        
bTankPointsFrozen true;
        
FreezePoints();
    }
}

public 
Action:OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
IsTank(client))
    {
        
CreateTimer(0.1CheckForTanksDelayTIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
OnClientDisconnect(client
{
    if (
IsTank(client))
    {
        
CreateTimer(0.1CheckForTanksDelayTIMER_FLAG_NO_MAPCHANGE);
    }
}

public 
Action:CheckForTanksDelay(Handle:timer
{
    if (
FindTank() == -1)
    {
        if (
bTankPointsFrozen
        {
            
PrintToChatAll("\x01[\x04NoBossRush\x01] Tank is dead. Unfreezing distance points!");
            
bTankPointsFrozen false;
            
UnFreezePoints();
        }
    }
}

/* Witch */

public Action:OnWitchSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (!
bTankPointsFrozen && !bWitchPointsFrozen)
    {
        
witchIndex GetEventInt(event"witchid");
        
PrintToChatAll("\x01[\x04NoBossRush\x01] Witch spawned. Freezing distance points!");
        
bWitchPointsFrozen true;
        
FreezePoints();
    }
}

public 
OnWitchKilled()
{
    if (
bWitchPointsFrozen)
    {
        
PrintToChatAll("\x01[\x04NoBossRush\x01] Witch is dead. Unfreezing distance points!");
        
bWitchPointsFrozen false;
        
UnFreezePoints();
        
witchIndex = -1;
    }
}

public 
OnEntityDestroyed(entity)
{
    if (
entity == witchIndex)
    {
        
OnWitchKilled();
    }
}

/* Shared */

FreezePoints() 
{
    
iDistance L4D_GetVersusMaxCompletionScore();
    
L4D_SetVersusMaxCompletionScore(0);
}

UnFreezePoints() 
{
    
L4D_SetVersusMaxCompletionScore(iDistance);
}

FindTank() 
{
    for (new 
1<= MaxClientsi++) 
    {
        if (
IsTank(i) && IsPlayerAlive(i)) 
        {
            return 
i;
        }
    }
    return -
1;
}

bool:IsTank(client)
{
    if (
client <= || !IsClientInGame(client) || GetClientTeam(client) != 3)
        return 
false;

    if (
GetEntProp(clientProp_Send"m_zombieClass") != 8)
        return 
false;

    return 
true;
}

InSecondHalfOfRound()
{
    return 
GameRules_GetProp("m_bInSecondHalfOfRound");


Last edited by Beatles; 07-27-2021 at 02:30.
Beatles is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-27-2021 , 13:49   Re: [L4D] Boss Rush
Reply With Quote #2

Need to find the "VersusMaxCompletionScore" offset in L4D1 binary, if it exists. Probably should have posted this in Left4DHooks thread.

Edit: Might be "944" on Linux. Left4DHooks would have to be modified to allow this native to be used. If you verify that's the correct offset then I'll update the plugin.

Found in "CTerrorGameRules::GetVersusMapMaxScore" which I'm guessing is the right place.
__________________

Last edited by Silvers; 07-27-2021 at 13:54.
Silvers is offline
Beatles
Senior Member
Join Date: Feb 2014
Old 07-28-2021 , 01:13   Re: [L4D] Boss Rush
Reply With Quote #3

Quote:
Originally Posted by Silvers View Post
Need to find the "VersusMaxCompletionScore" offset in L4D1 binary, if it exists. Probably should have posted this in Left4DHooks thread.

Edit: Might be "944" on Linux. Left4DHooks would have to be modified to allow this native to be used. If you verify that's the correct offset then I'll update the plugin.

Found in "CTerrorGameRules::GetVersusMapMaxScore" which I'm guessing is the right place.
It did not occur to me to post in the Left4DHooks thread, but I will take it into account next time, even so I have already tried, that is why I ask for help, since I have not found anything that works, and here are the most experts in these topics.
Beatles is offline
Beatles
Senior Member
Join Date: Feb 2014
Old 08-01-2021 , 11:30   [L4D] VersusMaxCompletionScore
Reply With Quote #4

I need to find the "VersusMaxCompletionScore" offset in L4D1 binary

Can someone help me with this ?, I remember seeing someone say that they knew all the binaries of L4D1, but I can not find it anywhere.

To better understand what I'm looking for, go through this thread:
https://forums.alliedmods.net/showth...76#post2753776
Beatles is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 08-01-2021 , 12:03   Re: [L4D] Boss Rush
Reply With Quote #5

It's hard to find "CTerrorGameRules::GetVersusMapMaxScore" on Windows since it's not used by the game at all and there's nothing in the function to reference.

Quote:
Originally Posted by Silvers View Post
Edit: Might be "944" on Linux. Left4DHooks would have to be modified to allow this native to be used. If you verify that's the correct offset then I'll update the plugin.

Found in "CTerrorGameRules::GetVersusMapMaxScore" which I'm guessing is the right place.
How did you get that value?
PHP Code:
int __cdecl CTerrorGameRules::GetVersusMapMaxScore(CTerrorGameRules *thisint a2)
{
  
int result// eax

  
result 0;
  if ( (
unsigned int)(a2 1) <= )
    
result = *((_DWORD *)this a2 235);
  return 
result;

Is "a2" supposed to equal "1"? How would one know?
4 * (1 + 235) = 944 ?
or
(4 * 235) + 4 = 944 ?
__________________
Psyk0tik is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 08-01-2021 , 16:01   Re: [L4D] Boss Rush
Reply With Quote #6

Quote:
Originally Posted by Beatles View Post
I need to find the "VersusMaxCompletionScore" offset in L4D1 binary

Can someone help me with this ?, I remember seeing someone say that they knew all the binaries of L4D1, but I can not find it anywhere.

To better understand what I'm looking for, go through this thread:
https://forums.alliedmods.net/showth...76#post2753776
Please don't create multiple threads to ask the same question. I have merged these 2.



Quote:
Originally Posted by Psyk0tik View Post
(4 * 235) + 4 = 944 ?
This is what I do. But on Linux it had the 944 byte in hex before viewing the pseudocode so I copied it from that without doing the math.

I think windows offset will be +4. Have to test. Let me know and I'll add into Left4DHooks next update. I don't have time right now to test it out. But windows could be the same or, +8, +16, +20 etc. Would have to test with them all to find the right one, or using L4D1 structs to find the offset which Diswar1 converted/created for L4D1. Not sure if this variable is covered since I did look at the structs to retrieve a bunch of offsets when creating Left4DHooks.
__________________
Silvers is offline
BHaType
Great Tester of Whatever
Join Date: Jun 2018
Old 08-01-2021 , 23:26   Re: [L4D] Boss Rush
Reply With Quote #7

PHP Code:
Windows:
GetVersusMapMaxScore 0x3B8 current_map_number g_pGameRules

Linux
:
GetVersusMapMaxScore 0x3B0 current_map_number g_pGameRules 
__________________
cry
BHaType is offline
Send a message via AIM to BHaType
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 08-02-2021 , 01:37   Re: [L4D] Boss Rush
Reply With Quote #8

Quote:
Originally Posted by BHaType View Post
PHP Code:
Windows:
GetVersusMapMaxScore 0x3B8 current_map_number g_pGameRules

Linux
:
GetVersusMapMaxScore 0x3B0 current_map_number g_pGameRules 
BHaType and I arrived at the same conclusion:
PHP Code:
"VersusMaxCompletionScore"
{
    
"windows"    "952" //Found via "m_iVersusMapScoreMax" string
    
"linux"    "944"

Looking at it, it may be changeable using GameRules_SetProp.

Last edited by cravenge; 08-02-2021 at 01:50. Reason: More info
cravenge is offline
Beatles
Senior Member
Join Date: Feb 2014
Old 08-02-2021 , 17:17   Re: [L4D] Boss Rush
Reply With Quote #9

Quote:
Originally Posted by Silvers View Post
Please don't create multiple threads to ask the same question. I have merged these 2.
I understand Silvers, thanks for your help, if you add this to left4dhooks, I will take care of testing it myself, I will report any errors.

I also appreciate:

- Psyk0tik
- BHaType
- cravenge

For joining and collaborating with this publication, you are of great help, it is a project that I am doing, and I will not forget you when everything is finished, thank you very much.
Beatles is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 08-04-2021 , 07:12   Re: [L4D] Boss Rush
Reply With Quote #10

Here is a version with support for "*VersusMaxCompletionScore". When I tried on Windows it returned 0 and all the addresses around there (searched with sm_ptr) did not correspond to the max score value. I don't have more time to try right now.

Will be added to Left4DHooks later today.
__________________

Last edited by Silvers; 08-10-2021 at 06:22.
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 12:20.


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