AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Unexpected TraceAttack (https://forums.alliedmods.net/showthread.php?t=329856)

ConorCC 01-10-2021 11:35

Unexpected TraceAttack
 
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.

Natsheh 01-10-2021 11:43

Re: Unexpected TraceAttack
 
show the test code.

ConorCC 01-10-2021 12:59

Re: Unexpected TraceAttack
 
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.

ConorCC 01-11-2021 03:16

Re: Unexpected TraceAttack
 
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. :)

CrazY. 01-11-2021 07:40

Re: Unexpected TraceAttack
 
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.

HamletEagle 01-11-2021 11:52

Re: Unexpected TraceAttack
 
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.

ConorCC 01-11-2021 12:37

Re: Unexpected TraceAttack
 
Wow. Good to know. Now I can mark this topic as solved. Thank you guys! :)


All times are GMT -4. The time now is 14:08.

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