Veteran Member
|
![Old](images/statusicon/post_old.svg)
05-12-2009
, 14:44
Re: Knife Distance by SchlumPF
|
#19
|
Quote:
Originally Posted by DeepBlueSea
Well good job in comprehend and reconstruct the hit-trace.
But i still for the life of me can't understand why you just don't TAKE the values the engine already calculated.
This is what i do:
On attack the engine conducts a hit-trace, resulting in values. I simply TAKE these values and display.
This is what you do:
On PreAttack you emulate the whole hit-trace and after returning from prehook, the engine conducts its own hit-trace AGAIN. What a redundancy, don't you think?
greets,
neotracer
//x-post xtreme-jumps.eu
|
ofc i dont like that way either but i tried a lot way which would have been a lot better but they have always the same bug, sometimes i hit a ent but the distance == attack range
just look at this
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <xs>
#pragma semicolon 1
new g_bAlive[33]; new g_szNickname[33][32];
public plugin_init( ) { register_plugin( "Knife Distance", "0.1", "SchlumPF" ); RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_knife", "hamKnifePrimaryAttack_Post", 1 ); RegisterHam( Ham_Weapon_SecondaryAttack, "weapon_knife", "hamKnifeSecondaryAttack_Post", 1 ); RegisterHam( Ham_Killed, "player", "hamKilledPlayer_Post", 1 ); RegisterHam( Ham_Spawn, "player", "hamSpawnPlayer_Post", 1 ); }
public hamKnifePrimaryAttack_Post( ent ) { static attacker; attacker = pev( ent, pev_owner ); static victim; victim = global_get( glb_trace_ent ); static Float:origin[3], Float:view_ofs[3], Float:vecSrc[3]; pev( attacker, pev_origin, origin ); pev( attacker, pev_view_ofs, view_ofs ); xs_vec_add( origin, view_ofs, vecSrc ); static Float:vecEndPos[3]; global_get( glb_trace_endpos, vecEndPos ); client_print( 0, print_chat, "slashed %i %.6f", victim, get_distance_f( vecSrc, vecEndPos ) ); }
public hamKnifeSecondaryAttack_Post( ent ) { static attacker; attacker = pev( ent, pev_owner ); static victim; victim = global_get( glb_trace_ent ); static Float:origin[3], Float:view_ofs[3], Float:vecSrc[3]; pev( attacker, pev_origin, origin ); pev( attacker, pev_view_ofs, view_ofs ); xs_vec_add( origin, view_ofs, vecSrc ); static Float:vecEndPos[3]; global_get( glb_trace_endpos, vecEndPos ); client_print( 0, print_chat, "stabbed %i %.6f", victim, get_distance_f( vecSrc, vecEndPos ) ); }
public client_connect( plr ) { get_user_name( plr, g_szNickname[plr], 31 ); }
public client_infochanged( plr ) { static curName[32], newName[32]; get_user_name( plr, curName, 31 ); get_user_info( plr, "name", newName, 31 );
if( !equal( newName, curName ) ) { copy( g_szNickname[plr], 31, newName ); } }
public hamKilledPlayer_Post( plr ) { g_bAlive[plr] = false; }
public hamSpawnPlayer_Post( plr ) { if( is_user_alive( plr ) && get_user_team( plr ) ) { g_bAlive[plr] = true; } }
__________________
|
|