AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   damage listening event... (https://forums.alliedmods.net/showthread.php?t=37202)

Graaf 01-24-2005 17:56

damage listening event...
 
IS it possible to check what kind of damage is done to a player?!

Like 15 damage on the left arm, and 20 damage on the right leg.
And after a while 120 damage on the head, what will result in player death with headshot.

tahvo 01-24-2005 18:06

You need plugin for that and I think nobody has not published that kind of plugin.

XAD 01-24-2005 19:34

Re: damage listening event...
 
Quote:

Originally Posted by Graaf
IS it possible to check what kind of damage is done to a player?!

Like 15 damage on the left arm, and 20 damage on the right leg.
And after a while 120 damage on the head, what will result in player death with headshot.

OK, you need to understand the system first... and then decide what you actually want to do...

You can get the proper info but it requires you to use the CSS internal classes, which doesn't have to look as the ones in the SDK (using anything else than official API will make your implementation more vulnerable to be non-working after an update). To do this you "only" have to browse through the source code example in the SDK...

This has always been true BUT people would then say it worked with CS 1.6 (AMXmod, AMXmodX, StatsMe)... well NONE of them logged where you hit!!! What they did was tracking where you aimed (using the trace function and saved the hitbox you aimed at). Then when a hit occured (regular trapping of events) they checked where the attacker last aimed at... Now this works pretty OK but as you know you are often not hitting where you aim so it won't be correct. This is also why you could have a headshot kill but not a headshot hit (HS-kill is sent in the message when you die so it's accurate).

If you want correct logging then you need to o the hard and vulnurable path or you take the pretty OK one and then you can use standard API's...

GL & HF
/X

vancelorgin 01-24-2005 20:22

Just read int CBaseCombatCharacter::m_LastHitGroup. BaseCombatCharacter.cpp line ~500,

#define HITGROUP_GENERIC 0
#define HITGROUP_HEAD 1
#define HITGROUP_CHEST 2
#define HITGROUP_STOMACH 3
#define HITGROUP_LEFTARM 4
#define HITGROUP_RIGHTARM 5
#define HITGROUP_LEFTLEG 6
#define HITGROUP_RIGHTLEG 7
#define HITGROUP_GEAR 10 // alerts NPC, but doesn't do damage or bleed (1/100th damage)

XAD 01-25-2005 02:53

Quote:

Originally Posted by vancelorgin
Just read int CBaseCombatCharacter::m_LastHitGroup. BaseCombatCharacter.cpp line ~500,

Well that var is "private" and the LastHitGroup is "protected". Also why do more than you need with checking events, resolve them, hack into the private and protected functions when you can hook public virtual functions that will only be called when needed and with all data you need :wink: (still hack but less and cleaner code)...

/X

Graaf 01-25-2005 04:16

It just looks like there's no-one out there working with the hl2sdk that want's to log damage and hitting information ?!

vancelorgin 01-25-2005 12:44

Quote:

Originally Posted by XAD
Well that var is "private" and the LastHitGroup is "protected".

So make them public.. :s Nothing is really private or protected

Quote:

Also why do more than you need with checking events, resolve them, hack into the private and protected functions when you can hook public virtual functions that will only be called when needed and with all data you need :wink: (still hack but less and cleaner code)...
Yeah, that'd give you more power, but accessing a class member is far far far far less hackish and alot easier than hooking a virtual method. I revere hackish stuff, myself, but others may not :P

Geesu 01-25-2005 15:03

vancel do you think it would be possible w/a memory hack or something to catch the damage done before the engine processes it? Basically being able to change it first?

Graaf 01-25-2005 15:23

Ah well .. I'll just wait untill someone creates an server plugin with damage logging
I've been looking at it .. and can't figure out how to create a simple damage logging.

vancelorgin 01-25-2005 15:58

Easily - hook these funcs as you see fit on CBaseCombatCharacter / CBasePlayer:

Code:

        virtual int                                OnTakeDamage( const CTakeDamageInfo &info );

        // Override these to control how your character takes damage in different states
        virtual int                                OnTakeDamage_Alive( const CTakeDamageInfo &info );
        virtual int                                OnTakeDamage_Dying( const CTakeDamageInfo &info );
        virtual int                                OnTakeDamage_Dead( const CTakeDamageInfo &info );

Change info as you see fit - it's the full damage container including type, originating entity, numeric value, reported position, etc etc.


All times are GMT -4. The time now is 23:29.

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