AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   DeathMsg and Damage order problems (https://forums.alliedmods.net/showthread.php?t=51137)

Warthog 02-12-2007 04:14

DeathMsg and Damage order problems
 
Hello all. I'm encountering a tricky problem. In CS:Source, log lines for attacks have additional information at the end for hitgroups: (hitgroup "stomach") ... for example. I'd like to add the same information to log lines in 1.6. My first thought was to simply capture the logevent with

register_logevent("hook_log_attacked", 9, "1=attacked")

and then grab the hitgroup from get_user_attacker() and add it on the end of the log line. The problem for attacks is, 'register_logevent()' occurs before the 'register_event("Damage")' and 'client_damage()' calls, so I cannot retrieve the hitgroup information this way.

So you could say, why not just block the normal attack message and re-create it in client_damage() with the hitgroup information? Well, one of the problems there is that the logevent contains how much armor damage was dealt, where client_damage() does not (along with the victim's health and armor stats). I could create a lot of extra code to calculate what the armor damage should be, but there's yet another problem.

The other problem is that if a player dies, the DeathMsg and Kill log lines occur before the final Damage event! So, if I waited to reconstruct the attack message in client_damage(), it would be out of order any time there is a kill. In fact, if it's the end of the round, DeathMsg won't take place until after both the Kill log AND the Round End logs.

Sorry if that's very confusing, but I'm trying to figure out the best possible solution (if any) to add hitgroups to the end of each attack log. The only solution I can think of right now is to block regular attack and kill logs, reconstruct both the attack and kill logs in client_damage(), and then set a flag to block the 2 Round End logs until the remaining Damage events have taken place. That's enormously complicated for what should be an easy task...

VEN 02-12-2007 07:33

Re: DeathMsg and Damage order problems
 
Quote:

Sorry if that's very confusing
Something like that. ;]

Can you show how you want your logs message(s) to look like?

Warthog 02-12-2007 08:27

Re: DeathMsg and Damage order problems
 
sure thing. basically i want attack logs to change from

"Wart<1><STEAM_0><T>" attacked "VEN<2><STEAM_1><CT>" with "usp" (damage "5") (damage_armor "3") (health "95") (armor "97")

to

"Wart<1><STEAM_0><T>" attacked "VEN<2><STEAM_1><CT>" with "usp" (damage "5") (damage_armor "3") (health "95") (armor "97") (hitgroup "head")

If I trigger on register_logevent(1=attacked), the hitgroup isn't available yet because it occurs before client_damage().

VEN 02-12-2007 11:10

Re: DeathMsg and Damage order problems
 
Quote:

the hitgroup isn't available yet
It is. It should be a get_user_attacker()'s fault. You have to cache the last three bullet attacking traces' hitgroup for every player. Use get_tr2(ptr, TR_iHitgroup) to get hitgroup, see [HOWTO] Detect fired particle creation/type/number/damage/obstacle/vector for details.

And on damage log message block/resend it using the original text and the cached hitgroup. Though you can't block/change a log message with register_logevent. You have to use the fakemeta module:
Code:
#include <amxmodx> #include <fakemeta> public plugin_init() {         register_forward(FM_AlertMessage, "AlertMessage") } public AlertMessage(AlertType:at_type, const message[]) {         // check if at_type == at_logged         // return FMRES_SUPERCEDE - to block the message         // return FMRES_IGNORED - to not block the message }

Warthog 02-12-2007 12:29

Re: DeathMsg and Damage order problems
 
That is excellent VEN, I really appreciate your help. I will try this out when I get home - and this will save me a TON of unnecessary and ugly code. When you say 'it should be get_user_attacker()'s fault', do you mean that particular function should have the information when that logevent occurs?

Now on your second part, I've noticed you cannot block a log message with register_logevent. However, I saw this thread (granted it was over 2 years ago), where BAILOPAN offered a different option:

http://forums.alliedmods.net/showthread.php?t=6385

Out of curiosity, is this method still valid / accurate? I'm guessing the FakeMeta function would be preferred?

--------
For future reference, this is what came from my initial testing and how messages are ordered:

L 02/12/2007 - 02:01:01: TEST: in register_logevent(1=attacked) message
L 02/12/2007 - 02:01:01: TEST: victim is 1, attacker is 0, weapon = 0, hitzone = 0

L 02/12/2007 - 02:01:01: "blah<2><STEAM_0><T>" attacked "me<1><STEAM_0:1><CT>" with "deagle" (damage "71") (damage_armor "0") (health "29") (armor "0")

L 02/12/2007 - 02:01:01: TEST: in register_event(Damage)
L 02/12/2007 - 02:01:01: TEST: victim is 1, attacker is 2, weapon = 26, hitzone = 1

L 02/12/2007 - 02:01:01: TEST: in client_damage()
L 02/12/2007 - 02:01:01: TEST: victim is 1, attacker is 2, weapon = 26, hitzone = 1

Notice how get_user_attacker() isn't set in the logevent. Even weirder, check out what happens when the attack results in a kill...and end of the round as well:


L 02/12/2007 - 02:00:17: TEST: in register_logevent(1=attacked) message
L 02/12/2007 - 02:00:17: TEST: victim is 2, attacker is 0, weapon = 0, hitzone = 0

L 02/12/2007 - 02:00:17: "blah<2><STEAM_0><T>" attacked "me<1><STEAM_0:1><CT>" with "knife" (damage "65") (damage_armor "0") (health "-59") (armor "0")

L 02/12/2007 - 02:00:17: TEST: in register_event(DeathMsg)
L 02/12/2007 - 02:00:17: TEST: in register_logevent(1=killed)

L 02/12/2007 - 02:00:17: "blah<2><STEAM_0><T>" killed "me<1><STEAM_0:1><CT>" with "knife"
L 02/12/2007 - 02:00:17: Team "CT" triggered "CTs_Win" (CT "1") (T "0")
L 02/12/2007 - 02:00:17: World triggered "Round_End"

L 02/12/2007 - 02:00:17: TEST: in register_event(Damage)
L 02/12/2007 - 02:00:17: victim is 1, attacker is 2, weapon = 29, hitzone = 4

L 02/12/2007 - 02:00:17: TEST: in client_damage()
L 02/12/2007 - 02:00:17: victim is 1, attacker is 2, weapon = 29, hitzone = 4

Look closely. This really caught me by surprise, because the DeathMsg event, logevent for the kill, and 2 logevents for the round ending all occur before Damage and client_damage(). I also found it strange how for kills, the DeathMsg occurs before the log, while for attacks it is the opposite.

VEN 02-12-2007 14:37

Re: DeathMsg and Damage order problems
 
Quote:

do you mean that particular function should have the information when that logevent occurs?
In dact the information should be available, it's just mannerism of that function.

Quote:

I saw this thread
Yes, i saw it too, just forgot that.

Quote:

I'm guessing the FakeMeta function would be preferred?
In your case yes, because the message is passed to the handler directly.

I believe that you shouldn't care about ordering at all because using the method i offered ordering will be exactly the same as original one.

Warthog 02-12-2007 15:20

Re: DeathMsg and Damage order problems
 
Okay thanks. Yeah it would be nice if get_user_attacker() was available earlier, and yes your method removes the ordering issues, I just thought it was interesting how HL orders the triggering of those events and figured I'd share. :)

XxAvalanchexX 02-12-2007 16:33

Re: DeathMsg and Damage order problems
 
VEN: I don't see how it's poor coding. get_user_attacker simply returns pev->dmg_inflictor, which is set by the game dll. It can't be helped if the game sends out the log message before applying a value to dmg_inflictor.

VEN 02-12-2007 21:30

Re: DeathMsg and Damage order problems
 
Avalanche: i agree, then let's say that the given native isn't suitable for given needs, edited the previous post a bit.


All times are GMT -4. The time now is 00:44.

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