Raised This Month: $32 Target: $400
 8% 

Solved Unexpected TraceAttack


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConorCC
Member
Join Date: Feb 2014
Old 01-10-2021 , 11:35   Unexpected TraceAttack
Reply With Quote #1

TraceAttack deal damage for no reason. (It shouldn't deal any).

I want to show the result video. It is only a few seconds but you will see.

Link: https://drive.google.com/file/d/1tTm...ew?usp=sharing

P1 is me and P2 is my helper.

1. I hit him with "att" command. Working fine. (do nothing) Expected prints.
2. I say start then he hits me with his knife or anything. (do nothing) Expected prints.
3. I hit him again with "att" command. I take the damage from the 2. point and it wasn't expected.

I had a bind to "att" so that's why you can't see I writed to console.

Same results with multiple players. If you traceattack someone. Then anybody else he will receive the first one's damage. Same results with different team members.

As I know the TraceAttack should deal any damage. It's only for the blood and directions. If I use TraceAttack as a CT on a T the result should be the same (with no damage) just with bloods.

Here is the code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>

new g_beam_spriteg_log[128];

public 
plugin_init() {

    
register_clcmd("att""cmd_att");

    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage_Post"1)
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack_Post"1);
}

public 
plugin_precache() {

    
g_beam_sprite precache_model("sprites/laserbeam.spr")
}

public 
cmd_att(id) {

    new 
Floatorigin[3], Floatview_ofs[3], Floatv_angle[3], Floatdirection[3], Floatend_origin[3];

    
pev(idpev_originorigin);
    
pev(idpev_view_ofsview_ofs);
    
xs_vec_add(originview_ofsorigin);
    
pev(idpev_v_anglev_angle);
    
angle_vector(v_angleANGLEVECTOR_FORWARDv_angle);
    
xs_vec_add_scaled(originv_angle100.0end_origin);

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BEAMPOINTS);
    
write_coord_f(origin[0]);
    
write_coord_f(origin[1]);
    
write_coord_f(origin[2]);
    
write_coord_f(end_origin[0]);
    
write_coord_f(end_origin[1]);
    
write_coord_f(end_origin[2]);
    
write_short(g_beam_sprite);
    
write_byte(0);
    
write_byte(0);
    
write_byte(10);
    
write_byte(10);
    
write_byte(0);
    
write_byte(255);
    
write_byte(255);
    
write_byte(80);
    
write_byte(170);
    
write_byte(0);
    
message_end();

    new 
trace create_tr2();

    
engfunc(EngFunc_TraceLineoriginend_originDONT_IGNORE_MONSTERSidtrace);

    new 
victim_id get_tr2(traceTR_pHit);

    if ( 
victim_id == -) {

        
victim_id 0
        set_tr2
(traceTR_pHitvictim_id);
    }

    new 
Floatdamage 50.0;

    
formatex(g_logcharsmax(g_log), "CMD ATT! FROM %n TO %n WITH %.2f"idvictim_iddamage);
    
client_print(0print_chatg_log);
    
log_to_file("att.log"g_log);

    
ExecuteHamB(Ham_TraceAttackvictim_ididdamagedirectiontraceDMG_NEVERGIB|DMG_BULLET);
    
free_tr2(trace);
}

public 
fw_TakeDamage_Post(victim_idinflictorattacker_idFloat:damagebits) {

    
formatex(g_logcharsmax(g_log), "TAKE DAMAGE! FROM %n TO %n WITH %.2f"attacker_idvictim_iddamage);
    
client_print(0print_chatg_log);
    
log_to_file("att.log"g_log);

    return 
HAM_IGNORED;


public 
fw_TraceAttack_Post(victim_idattacker_idFloatdamageFloatdirection[3], tracedamagebits) {

    
formatex(g_logcharsmax(g_log), "TRACE ATTACK! FROM %n TO %n WITH %.2f"attacker_idvictim_iddamage);
    
client_print(0print_chatg_log);
    
log_to_file("att.log"g_log);

    return 
HAM_IGNORED;

The server is using this one plugin only so nothing modify the results.

Last edited by ConorCC; 01-11-2021 at 12:38. Reason: Update source
ConorCC is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-10-2021 , 11:43   Re: Unexpected TraceAttack
Reply With Quote #2

show the test code.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
ConorCC
Member
Join Date: Feb 2014
Old 01-10-2021 , 12:59   Re: Unexpected TraceAttack
Reply With Quote #3

Tested with AMXX 1.8 and 1.9, on HLDS and ReHLDS, on Linux and Windows, with players and bots. The results are the same.

I detected when mystery damage has taken it says 15.0 that is actually not true cause after I repeat the last damage on myself it multipled by 1/3 so 5.0.

Edit: Updated source code in comment one. That is generating the following logs:

Code:
L 01/11/2021 - 08:22:14: CMD ATT! FROM Johan as Corn TO [POD]Headshot Deluxe (96) WITH 50.00
L 01/11/2021 - 08:22:14: TRACE ATTACK! FROM Johan as Corn TO [POD]Headshot Deluxe (96) WITH 50.00
L 01/11/2021 - 08:22:21: TRACE ATTACK! FROM [POD]Headshot Deluxe (96) TO Johan as Corn WITH 65.00
L 01/11/2021 - 08:22:21: TAKE DAMAGE! FROM [POD]Headshot Deluxe (96) TO Johan as Corn WITH 65.00
L 01/11/2021 - 08:22:22: CMD ATT! FROM Johan as Corn TO [POD]Headshot Deluxe (96) WITH 50.00
L 01/11/2021 - 08:22:22: TAKE DAMAGE! FROM Johan as Corn TO Johan as Corn WITH 65.00
L 01/11/2021 - 08:22:22: TRACE ATTACK! FROM Johan as Corn TO [POD]Headshot Deluxe (96) WITH 50.00
After a real attack (by a bot to me) (knife stab) I receive his last damage * 1/3 from myself. The first time this extra damage doesn't apper cause I think there is no prev damage in the puffer.

Edit: As I see the damage receiver will be te prev attack's target and not the sender. In this example it is me both but can be anybody else.

Last edited by ConorCC; 01-11-2021 at 02:42. Reason: Add tests
ConorCC is offline
Old 01-10-2021, 21:48
Bugsy
This message has been deleted by Bugsy.
ConorCC
Member
Join Date: Feb 2014
Old 01-11-2021 , 03:16   Re: Unexpected TraceAttack
Reply With Quote #5

Well, technically we can just block every damage from before the trace attack to after the trace attack. This solve the problem. (To make sure I will check this in more situations.)

After all this still be a problem or a bug. I think something is wrong in the general amxmodx. As soon as I can I will check the cpp files to find solution but i don't promise. My view is that the bug should be connected to the global trace attack. For some unknow reason the addon can't empty the trace puffer or something like that. Maybe it is all bullsh*t but who knows?

Here is the code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fakemeta_util>

new g_beam_spriteg_log[128], boolg_block_damage;

public 
plugin_init() {

    
register_clcmd("att""cmd_att");

    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage_Post"1)
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack_Post"1);
}

public 
plugin_precache() {

    
g_beam_sprite precache_model("sprites/laserbeam.spr")
}

public 
cmd_att(id) {

    new 
Floatorigin[3], Floatview_ofs[3], Floatv_angle[3], Floatdirection[3], Floatend_origin[3];

    
pev(idpev_originorigin);
    
pev(idpev_view_ofsview_ofs);
    
xs_vec_add(originview_ofsorigin);
    
pev(idpev_v_anglev_angle);
    
angle_vector(v_angleANGLEVECTOR_FORWARDv_angle);
    
xs_vec_add_scaled(originv_angle200.0end_origin);

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
    
write_byte(TE_BEAMPOINTS);
    
write_coord_f(origin[0]);
    
write_coord_f(origin[1]);
    
write_coord_f(origin[2]);
    
write_coord_f(end_origin[0]);
    
write_coord_f(end_origin[1]);
    
write_coord_f(end_origin[2]);
    
write_short(g_beam_sprite);
    
write_byte(0);
    
write_byte(0);
    
write_byte(10);
    
write_byte(10);
    
write_byte(0);
    
write_byte(255);
    
write_byte(255);
    
write_byte(80);
    
write_byte(170);
    
write_byte(0);
    
message_end();

    new 
trace create_tr2();

    
engfunc(EngFunc_TraceLineoriginend_originDONT_IGNORE_MONSTERSidtrace);

    new 
victim_id get_tr2(traceTR_pHit);

    if ( 
victim_id == -) {

        
victim_id 0
        set_tr2
(traceTR_pHitvictim_id);
    }

    new 
Floatdamage 50.0;

    
formatex(g_logcharsmax(g_log), "CMD ATT! FROM %n TO %n WITH %.2f"idvictim_iddamage);
    
client_print(0print_chatg_log);
    
log_to_file("att.log"g_log);

    
g_block_damage true;

    
ExecuteHamB(Ham_TraceAttackvictim_ididdamagedirectiontraceDMG_NEVERGIB|DMG_BULLET);

    
g_block_damage false;

    
// TAKE DAMAGE WILL BE HERE

    
free_tr2(trace);
}

public 
fw_TakeDamage(victim_idinflictorattacker_idFloat:damagebits) {

    if ( 
g_block_damage )
        return 
HAM_SUPERCEDE;

    
formatex(g_logcharsmax(g_log), "TAKE DAMAGE PRE! FROM %n TO %n WITH %.2f"attacker_idvictim_iddamage);
    
client_print(0print_chatg_log);
    
log_to_file("att.log"g_log);

    return 
HAM_IGNORED;


public 
fw_TakeDamage_Post(victim_idinflictorattacker_idFloat:damagebits) {

    if ( 
g_block_damage )
        return 
HAM_SUPERCEDE;

    
formatex(g_logcharsmax(g_log), "TAKE DAMAGE POST! FROM %n TO %n WITH %.2f"attacker_idvictim_iddamage);
    
client_print(0print_chatg_log);
    
log_to_file("att.log"g_log);

    return 
HAM_IGNORED;


public 
fw_TraceAttack_Post(victim_idattacker_idFloatdamageFloatdirection[3], tracedamagebits) {

    
formatex(g_logcharsmax(g_log), "TRACE ATTACK! FROM %n TO %n WITH %.2f"attacker_idvictim_iddamage);
    
client_print(0print_chatg_log);
    
log_to_file("att.log"g_log);

    return 
HAM_IGNORED;

Thanks for all the thinking I won't close this topic so if you have any information or idea don't keep it back.
ConorCC is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-11-2021 , 07:40   Re: Unexpected TraceAttack
Reply With Quote #6

Before and after calling TraceAttack you need to call "ClearMultiDamage" and "ApplyMultiDamage" respectively.
In reapi you can use rg_multidmg_clear and rg_multidmg_apply, in amxx you will need orpheu.
__________________









Last edited by CrazY.; 01-11-2021 at 07:42.
CrazY. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-11-2021 , 11:52   Re: Unexpected TraceAttack
Reply With Quote #7

TraceAttack calls TakeDamage, it should do damage. However, what you describe is likely because you are missing ClearMultiDamage/ApplyMultiDamage, like CrazY mentioned. You can find orpheu signatures around. This way the damage will be properly applied.

If, for some reasons, you don't want the damage, you have to block it manually.
__________________

Last edited by HamletEagle; 01-11-2021 at 11:55.
HamletEagle is offline
ConorCC
Member
Join Date: Feb 2014
Old 01-11-2021 , 12:37   Re: Unexpected TraceAttack
Reply With Quote #8

Wow. Good to know. Now I can mark this topic as solved. Thank you guys!

Last edited by ConorCC; 01-11-2021 at 12:38.
ConorCC 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 23:59.


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