Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
I'll start by copy pasting the function I have problems with. This is mostly work by Black Rose, I take very little credit.
Code:
The most desirable solution (probably) to my problem is to completely get rid of TakeDamage. That way, I wouldn't need to calculate the hitzone by myself and the mp_friendlyfire cvar should be ignored too, but I'm not exactly sure how CBasePlayer::TraceAttack works (no idea if it calls CBasePlayer::TakeDamage or does the damage in a different fashion). The problem with this, though, is that Ham_TraceAttack alone decides to only deal either 0 or 1 damage to the player regardless of what the damage is (I changed it to 1.0 for testing purposes, but even with 100000.0, it still does 1 or 0 damage). It also looks somehow jerky - there's no animation played on the player that gets hit, etc., but worst of all, if the victim dies, there's no attacker shown in the deathmsg. I have no idea what am I doing wrong. On the other hand, without Ham_TraceAttack, no hitzones are taken into account (which I can deal with by changing m_LastHitGroup, so that's fine) but no blood is shown, so I'd have to re-create it myself. With my way, both Ham_TraceAttack and Ham_TraceDamage is used. This creates the blood just fine and also shows the correct hitzone (headshot) in the DeathMsg, which is weird to say the least, since it's done in TraceAttack. It more or less works fine this way, however I'm unable to get rid of the friendly fire restriction. I need knives to deal damage even if mp_friendlyfire is off, as the knives have a special property (KN_CLL_IgnoreFriendlyFire) which would be extremely useful for example on my Banhammer. If you have any suggestion (either why TraceAttack acts stupid or how to disable the teamfire check in TakeDamage), please tell me. |
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
PHP Code:
Here are the sig : PHP Code:
|
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
Strange. Doesn't TraceAttack do that already?
Code:
|
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
Oh, i've edited my post after your post, sorry.
Look at the source code i posted @ApplyMultiDamage EDIT : You can go here to take a look |
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
All that does is call TakeDamage, which I'm already doing.
CBasePlayer::TraceAttack calls AddMultiDamage(), which does this: Code:
So in the end TraceAttack should send TakeDamage by itself, but it doesn't. At least not correctly... I'm not sure what Arkshine's comment means, is it bugged in the CSSDK itself? If it is, that would kinda explain why there's no killer shown in the DeathMsg. Anyway, seeing that my way is more or less correct, the real question still exists: How to fool TakeDamage so teamplayers can attack each other even if mp_friendlyfire is off? The only solution I can think of is to set mp_friendlyfire to 1 right before the damage and back to 0 after it, but is there anything better that this? It sounds dirty. |
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
AddMultiDamage cumulates the damage for an entity, when the entity isn't the same then it calls TakeDamage to apply all the damages cumulated, the proper way to call TraceAttack is the one i told you.
You can take a look at HLSDK, you will always see : ClearMultiDamage --> TraceAttack --> ApplyMultiDamage Connor already did a plugin for that if i am correct, take a look at it |
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
Like I said, all ApplyMultiDamage does is call TakeDamage. I can simply execute Ham_TakeDamage (like I do) and it will do the same thing plus I won't need a dependency (Orpheu). I'm doing pretty much the exactly same thing TraceAttack does. In fact, TraceAttack should do this by itself apparently, but it's bugged (it doesn't pass the attacker in the ApplyMultiDamage call).
|
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
2 things.
1) https://github.com/Arkshine/CSSDK/bl.../wpn_knife.cpp 2) PHP Code:
First: Quote:
PHP Code:
Second: Quote:
Third: Quote:
dlls/weapons.cpp PHP Code:
In conclusion, you'll have to use them. I use Orpheu for hooking ApplyMultiDamage and ClearMultiDamage, nothing is wrong with them, about your "dependency" it's something. Also, if you want to make fool TakeDamage when mp_friendlyfire is 0, you'll have to done a code like FFA does. (changing m_iTeam offset) |
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
No I didn't have to use them. You probably didn't read my post properly, but I clearly said that using Ham_TraceAttack first and then Ham_TakeDamage works perfectly but I'm unable to deal damage to my team mates. I got around this by setting mp_friendlyfire to 0 and then back, as changing the team didn't take other effects into account (friendly fire warning, reduced damage), which I wanted to remain.
I didn't have to use ClearMultiDamage at all. I never saw anyone do that to process damage on a player. Why should my plugin be an exception? It works great as it is without it. Quote:
About dependencies, yeah, it matters. You're looking at this from a programmer's perspective, not from a perspective of an average admin that just wants to have his things going without possibly breaking on CS updates. I'm not going to require Orpheu just because of one feature, especially if it works fine as it is. In conclusion, please stop posting in my threads with that attitude. You're being overly self centered and arrogant. If you have a need to attack people constantly then feel free to, but don't do so in my threads, thanks. |
Re: Ham_TakeDamage with FF, Ham_TraceAttack not working correctly
Well, you are also being stubborn. Plus, I see nothing rude from him (though what you quoted was unnecessary), he's actually helping you... Maybe you should calm down a bit, and trying to review how work things.
Anyway, what he said should be correct. You may not see at first glance any problems, but at some point you are not going to have reliable damage. By calling TraceAttack, you accumulate damage for a same entity. If you call TakeDamage wihtout clearing global multi-damage, once TraceAttack is called again but with another entity, The previous entity will take most likely and again the accumulated damage with different inflictor. This is not for nothing you have such code for the knife for example: Code:
ClearMultiDamage(); |
| All times are GMT -4. The time now is 13:02. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.