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

SDK Hooks 2.1 - Updated 2011-9-10


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Jоnny
Senior Member
Join Date: Jun 2007
Old 05-04-2010 , 09:15   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#571

oh, ok, sry
Jоnny is offline
HL-SDK
Member
Join Date: Jan 2009
Old 05-04-2010 , 09:37   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#572

No, you made me realize it was disabled by the author. I need to re-enable it to test of course :-p

If you happen to have a .sp file that uses that particular hook and wouldn't mind posting it in full here, I would appreciate you saving me the effort of having to write a plugin for testing from scratch.
HL-SDK is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-04-2010 , 09:58   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#573

Quote:
Originally Posted by HL-SDK View Post
No, you made me realize it was disabled by the author. I need to re-enable it to test of course :-p
It can be re-enabled by adding this to the left4dead2 gamedata section under Offsets.
Code:
        "OnTakeDamage"
        {
            "windows"    "71"
            "linux"         "72"
        }
psychonic is offline
HL-SDK
Member
Join Date: Jan 2009
Old 05-04-2010 , 20:30   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#574

I come bearing more fruit.

First, my log:
Code:
C44BE5CA 439C6848 C3C718EB 44D52432 45E3B0E7 45268626 00000000 00000000 00000000 00000000 00000000 00000000 3747003 3747003 6E6A095 41C88280 4205AC55 7F7FFFFF 2

C44F5679 43E13F57 C32F965D 4507BB60 45CD4673 4529713F 00000000 00000000 00000000 00000000 00000000 00000000 00F0D002 00F0D002 03882139 0 4205F810 7F7FFFFF 2 0 0 1 0 0 0
|--------position?-------|                                              ^atkr/inflctr     ^wapon    ^ damage (float)  ^flgs
C451148C 437FFC59 44565600 43F7D6D8 45B33DA5 4535E080 00000000 00000000 00000000 C07BC52E C0458390 00000000 014DB0EC 0016B001 014DB0EC 0 428C0000 7F7FFFFF 200004 0 0 


C3B30F35 C45AD69C C324A4A2 43EA034A 45B10A6B 45353E9D 00000000 00000000 00000000 00000000 00000000 00000000 0016B001 0016B001 07B1C09E 3F9BE5BA 420B31AF 7F7FFFFF 000002 0 0 1

^Pistol

C41CEDE0 C47EE809 4380C73B 43F307BE 45B21EB2 4535E080 00000000 00000000 00000000 C09ED447 3F1A908E 80000000 02DAF179 0016B001 02DAF179 00000000 42480000 7F7FFFFF 200004 0 0 FFFFFFFF 
^Fireaxe

422283FB 4415A7DC 80000000 445176EC 45AF349E 45260080 00000000 00000000 00000000 00000000 00000000 00000000 025761AC 025761AC FFFFFFFF 40000000 40000000 7F7FFFFF 80 0 0 FFFFFFFF 
^Zombozo hit on coach

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 06BA11AA 0189A005 FFFFFFFF 40377800 40377800 7F7FFFFF 40400 0 DAAB5E0 FFFFFFFF 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
^spitter on coach

//------//------//------//------//------//------//------//------//------//------//------//------//------//------//------
//------//------//------//------//------//------//------//------//------//------//------//------//------//------//------
//------//------//------//------//------//------//------//------//------//------//------//------//------//------//------

HLSDK attacked Nick
 442B2E55 44252C97 C2FED0C2 44204F3C 45B4D901 453496C0 0 0 0 0 0 0 16E001 16E001 6D80E7 3F93041F 420343AE 7F7FFFFF 2 0 0 1
[SM] Attacker: CTerrorPlayer, inflictor CPistol attacked Victim: Nick for 32.816093 damage


HLSDK attacked Nick
 C49254C6 42C3C3FC 43AD3464 43FF486B 45B3A25C 4535E080 0 0 0 BFDF3307 4095F460 80000000 693C1B0 16E001 693C1B0 3FE00000 42480000 7F7FFFFF 200004 0 0 FFFFFFFF
[SM] Attacker: CTerrorMeleeWeapon, inflictor CTerrorMeleeWeapon attacked Victim: Nick for 50.000000 damage

//------//------//------//------//------//------//------//------//------//------//------//------//------//------//------
//------//------//------//------//------//------//------//------//------//------//------//------//------//------//------
//------//------//------//------//------//------//------//------//------//------//------//------//------//------//------
Second, my class changes / padding to CTakeDamageInfo:
Code:
    Vector            m_vecDamageForce;
    Vector            m_vecDamagePosition;
    Vector            m_vecReportedPosition;    // Position players are told damage is coming from --always null in testing
    float            m_DUMMY[3];
    EHANDLE            m_hAttacker;
    EHANDLE            m_hWeapon;
    EHANDLE            m_hInflictor;
    float            m_DUMMY1[1];
    float            m_flDamage;
    float            m_flMaxDamage;
    int            m_bitsDamageType;
    float            m_flBaseDamage;            // The damage amount before skill leve adjustments are made. Used to get uniform damage forces.
    int                m_iDamageCustom;
    int                m_iDamageStats;
    int                m_iAmmoType;            // AmmoType of the weapon used to cause this damage, if any
Notes - I may have things after flBaseDamage incorrect. I don't think they are passed to the user anyway.

That's pretty much it, just some padding. I also have a test .sp file:
PHP Code:
/**
 * vim: set ts=4 :
 * =============================================================================
 * SourceMod Anti-Flood Plugin
 * Protects against chat flooding.
 *
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
 * =============================================================================
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 3.0, as published by the
 * Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * As a special exception, AlliedModders LLC gives you permission to link the
 * code of this program (as well as its derivative works) to "Half-Life 2," the
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
 * by the Valve Corporation.  You must obey the GNU General Public License in
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
 * this exception to all derivative works.  AlliedModders LLC defines further
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
 * or <http://www.sourcemod.net/license.php>.
 *
 * Version: $Id$
 */

#pragma semicolon 1

#include <sourcemod>
#include <sdkhooks>

public Plugin:myinfo 
{
    
name "L4D2_Testing",
    
author "HL-SDK",
    
description "Reverse engineering helper buddy",
    
version SOURCEMOD_VERSION,
    
url "http://www.sourcemod.net/"
};

new 
Handle:sm_tenable;                                /* Handle to test enable convar */

public OnPluginStart()
{
    
sm_tenable CreateConVar("sm_tenable""1""ENABLE LOGGING OUR STUFF");
}

public 
OnClientPutInServer(client)
{
    if (
client == 100 || client == 2)
    {
        
SDKHook(clientSDKHook_OnTakeDamagePostOnTakeDamagePost);
        
ShowActivity(0"OnClientPutInServer: %i"client);
        
ShowActivity(0"Hooked!: %i"client);
    }
    else
    {
        
ShowActivity(0"OnClientPutInServer: %i"client);
    }
}
/* LogAction(client, -1, "\"%L\" refreshed the admin cache.", client); */

public OnTakeDamagePost(victimattackerinflictorFloat:damagedamagetype)
{
    
decl String:victimName[20];
    
GetClientName(victimvictimName20);
    
decl String:attackerName[20];
    
GetEntityNetClass(attackerattackerName20);
    
decl String:inflictorName[20];
    
GetEntityNetClass(inflictorinflictorName20);
    
ShowActivity(0"Attacker: %s, inflictor %s attacked Victim: %s for %f damage"attackerNameinflictorNamevictimNamedamage);

Nothing too professional, but it is trivial to add OnTakeDamage hooks into L4D2 now, because of psychonic and I.
HL-SDK is offline
DarkEnergy
SourceMod Donor
Join Date: Apr 2008
Location: Georgia Tech, MSECE
Old 05-05-2010 , 22:49   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#575

it appears in tf2 that the damage value passed through sdk hook is not the actual damage to the player, but just a generic number that later gets adjust after sdk hooks has messed with it

example:

you shoot someone when you are close, damage value is 60 from sdk hooks, but real in game damage is 100.

when you are far away, the damaged passed through sdk hooks is 10, but the real damage dealt is 5

so sdk hooks is not getting the real value of the damage dealt to the players

assuming no attack will not critical, you standing at the same distance from the target, sdk hooks will recieve the same number for the damage ie 60 (heavy shotgun, point blank), but damage dealt ingame is variable : sample data 84, 90,89,89,83,88.....

using fists on heavy, you will always get 65 damage passed from sdk hooks, but deal variable damage around 50-80 depending how far you are from the target

so sdk hooks can infact multiply all damage by multiplying the number passed (ie *2.0 will double all damage), but cannot guarantee increased/decreased damage by a specific amount ie (5 extra damage per hit) because the engine takes the new value (ie 60->65) and deals it's own damage according to that value (65) with it's own variance and distance from target

also critical hits will not show up on the sdk hooks damage, they will have normal non-critical values, so i guess critical is calculated after sdk hooks

Last edited by DarkEnergy; 05-05-2010 at 23:02.
DarkEnergy is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 05-05-2010 , 23:28   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#576

TF2 uses a concept of base damage, you can read about the values on the tf2wiki.
The damage value in the callback is correct when both damage spread and criticals are off.
It's impossible to calculate this perfectly from a SM plugin, as you do not have access to the server's random seeds.
__________________
asherkin is offline
HL-SDK
Member
Join Date: Jan 2009
Old 05-06-2010 , 10:38   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#577

Right, I mentioned in L4D2 certain damages were tweaked depending on their targets (you can't kill a teammate in VS with 4 pistol shots, even though they do ~30 dmg)

With enough hard work you could probably get the correct values, but what do you need that much accuracy for?

This is a poor way of solving it but you could potentially create an extremely short timer in the callback to check the player's health (so you get the modified version)
HL-SDK is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-06-2010 , 10:43   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#578

Quote:
Originally Posted by HL-SDK View Post
This is a poor way of solving it but you could potentially create an extremely short timer in the callback to check the player's health (so you get the modified version)
Or just use the OnTakeDamagePost hook type. It would allow you to get the amount the game calculated, just too late to modify.
psychonic is offline
dirtyminuth
Senior Member
Join Date: Sep 2009
Old 05-07-2010 , 05:24   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-04-29)
#579

I didn't see any conclusion regarding the SetTransmit hook. I can't seem to get this hook to fire in TF2. I'm running Windows, SM 1.3.2, MM 1.8.1, and the version of SDKHooks updated 29 Apr 2010.

I have been using the same code since before the latest round of TF2 updates / breakage, where it worked. Has this issue been resolved and I just missed it? Hopefully!

To cover the basics,

meta version
PHP Code:
Metamod:Source version 1.8.1
Build ID
702:b21cf03c429a
Loaded 
As: Valve Server Plugin
Compiled on
May  2 2010
Plugin 
interface version15:14
SourceHook version
5:5
http
://www.metamodsource.net/ 
sm version
PHP Code:
SourceMod Version Information:
    
SourceMod Version1.3.2
    SourcePawn Engine
SourcePawn 1.1jit-x86 (build 1.3.2)
    
SourcePawn APIv1 4v2 3
    Compiled on
May  2 2010 17:19:11
    Build ID
2958:a3e8f7a7fdf7
    http
://www.sourcemod.net/ 
sm plugins list
PHP Code:
[SMListing 18 plugins:
  
01 "Admin File Reader" (1.3.2by AlliedModders LLC
  02 
"Admin Help" (1.3.2by AlliedModders LLC
  03 
"Admin Menu" (1.3.2by AlliedModders LLC
  04 
"Anti-Flood" (1.3.2by AlliedModders LLC
  05 
"Basic Ban Commands" (1.3.2by AlliedModders LLC
  06 
"Basic Chat" (1.3.2by AlliedModders LLC
  07 
"Basic Comm Control" (1.3.2by AlliedModders LLC
  08 
"Basic Commands" (1.3.2by AlliedModders LLC
  09 
"Basic Info Triggers" (1.3.2by AlliedModders LLC
  10 
"Basic Votes" (1.3.2by AlliedModders LLC
  11 
"Client Preferences" (1.3.2by AlliedModders LLC
  12 
"Fun Commands" (1.3.2by AlliedModders LLC
  13 
"Fun Votes" (1.3.2by AlliedModders LLC
  14 
"Nextmap" (1.3.2by AlliedModders LLC
  15 
"Player Commands" (1.3.2by AlliedModders LLC
  16 
"Reserved Slots" (1.3.2by AlliedModders LLC
  17 
"Sound Commands" (1.3.2by AlliedModders LLC
  18 
"Zombie Fortress" (4.1.0.0cby dirtyminuth (Recode), Sirot (Original
dirtyminuth is offline
psychonic

BAFFLED
Join Date: May 2008
Old 05-12-2010 , 12:23   Re: [EXTENSION] SDK Hooks 1.3 (Updated 2010-05-12)
#580

I have updated the orangebox-valve and l4d2 downloads today.

The orangebox-valve one now supports CSS OB beta, and the Left 4 Dead 2 one now supports OnTakeDamage hooks correctly, thanks to HLSDK.
psychonic is offline
Closed Thread



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


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