Raised This Month: $ Target: $400
 0% 

EngFunc_TraceLine problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
bogdyuttzu
Senior Member
Join Date: Dec 2009
Location: Romania
Old 08-23-2012 , 12:36   EngFunc_TraceLine problem
Reply With Quote #1

Hello.
I have a problem with EngFunc_TraceLine. I do not know how, but does not hit anything.

Here is the code:

PHP Code:
public CTripmine_OnBeamThink( const beam )
{
    static 
tripmine;
    
tripmine pevbeampev_owner );
    
    static 
Float:vecSrc[3], Float:vecEnd[3];
    
pevtripminepev_originvecSrc );
    
pevtripminepev_vecdirvecEnd );
    
    static 
trFloat:fraction;
    
engfunc(EngFunc_TraceLinevecSrcvecEndDONT_IGNORE_MONSTERStripminetr);
    
    
get_tr2(trTR_flFractionfraction);

    
client_print(print_chat,"fraction %f"fraction);

    if(
fraction 1.0)
    {
        static 
pHit;
        
pHit get_tr2trTR_pHit );

        
client_print(print_chat,"hit %d"pHit);

        if( 
<= pHit <= g_iMaxClients )
        {
            
client_print(print_chat,"Check hit %d"pHit);
            
//ExecuteHamB( Ham_Killed, tripmine, tripmine, 0);
        
}
    }
    
set_pev(beampev_nextthinkget_gametime()+0.1);

Every time TR_flFraction is 1.000000 and if I don't check if fraction < 1.0 TR_pHit is -1


Here is the full code:

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <xs>
#include <fun>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "New Plug-In"
#define VERSION "1.0.0"
#define AUTHOR "bogdyutzu"

#define pev_vecdir pev_vuser1
#define pev_beamindex pev_iuser1

#pragma semicolon 1

enum tripmine_e 
{
    
TRIPMINE_IDLE1 0,
    
TRIPMINE_IDLE2,
    
TRIPMINE_ARM1,
    
TRIPMINE_ARM2,
    
TRIPMINE_FIDGET,
    
TRIPMINE_HOLSTER,
    
TRIPMINE_DRAW,
    
TRIPMINE_WORLD,
    
TRIPMINE_GROUND,
};

new 
CClassStringMine[] = "ent_tripmine";
new 
CClassStringBeam[] = "beam";

new 
g_iBeamAllocedStringg_iLaserAllocedStringg_iLaserModelg_iMaxClients;

new const 
g_szMineModel    []     = "models/v_tripmine.mdl";
new const 
g_szMineDeploy[]     = "weapons/mine_deploy.wav";
new const 
g_szMineActivate[]     = "weapons/mine_activate.wav";
new const 
g_szMineCharge[]     = "weapons/mine_charge.wav";
new const 
g_szMineBeam[]     = "sprites/laserbeam.spr";

public 
plugin_precache()
{
    
g_iLaserModel precache_model(g_szMineBeam);    
    
precache_model(g_szMineModel);
    
precache_model("models/computergibs.mdl");
    
    
precache_sound(g_szMineDeploy);
    
precache_sound(g_szMineActivate);
    
precache_sound(g_szMineCharge);

    
g_iLaserAllocedString engfunc(EngFunc_AllocStringCClassStringMine);
    
g_iBeamAllocedString  engfunc(EngFunc_AllocStringCClassStringBeam);
    
    
precache_sound("buttons/spark5.wav");
    
precache_sound("buttons/spark6.wav");
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_c4""CTripmine_OnAttack");
    
//RegisterHam(Ham_Killed, "info_target", "CTripmine_OnKilled", 1);

    
register_think(CClassStringMine"CTripmine_OnThink");
    
register_think(CClassStringBeam"CTripmine_OnBeamThink");
        
    
register_clcmd("mata""suji");
    
    
g_iMaxClients get_maxplayers();
}

public 
suji(idgive_item(id"weapon_c4");

public 
CTripmine_OnAttack( const weapon )
{
    new 
playerid UTIl_GetWeaponOwnerweapon );
    
    if(!
is_user_alive(playerid)) return HAM_IGNORED;

    new 
Float:vAngle[3], Float:vPunch[3];
    
pev(playeridpev_v_anglevAngle);
    
pev(playeridpev_punchanglevPunch);
    
    
xs_vec_add(vAnglevPunchvAngle);
    
engfunc(EngFunc_MakeVectorsvAngle);
    
    new 
Float:vecSrc[3], Float:vecAiming[3];
    
ExecuteHamB(Ham_Player_GetGunPositionplayeridvecSrc);
    
global_get(glb_v_forwardvecAiming);
    
    new 
tr;
    
xs_vec_mul_scalar(vecAiming128.0vecAiming);
    
xs_vec_add(vecSrcvecAimingvecAiming);
    
engfunc(EngFunc_TraceLinevecSrcvecAimingIGNORE_MONSTERSplayeridtr);
    
    new 
Float:fraction;
    
get_tr2(trTR_flFractionfraction);
    
    if (
fraction 1.0)
    {
        new 
Float:vPlaneNormal[3], Float:vEndPos[3];
        
get_tr2(trTR_vecPlaneNormalvPlaneNormal);
        
engfunc(EngFunc_VecToAngles,vPlaneNormalvAngle);
        
        
get_tr2(trTR_vecEndPosvEndPos);
        
xs_vec_mul_scalar(vPlaneNormal8.0vPlaneNormal);
        
xs_vec_add(vPlaneNormalvEndPosvEndPos);
        
        
CTripmine_OnSpawn(playeridvEndPosvAngle);
    }
    return 
HAM_IGNORED;
}

CTripmine_OnSpawn( const playerid, const Float:Pos[3], const Float:Ang[3] )
{
    new 
mine FX_Breakableg_iLaserAllocedStringg_szMineModelPosFloat:{ -8.0, -8.0, -8.0 }, Float:{ 8.08.08.0 }, "6""100" );
    
    
set_pev(minepev_anglesAng);
    
set_pev(minepev_ownerplayerid);
    
set_pev(minepev_frame0);
    
set_pev(minepev_body3);
    
set_pev(minepev_sequenceTRIPMINE_WORLD);
    
set_pev(minepev_framerate0.0);
    
//set_pev(mine, pev_takedamage, DAMAGE_YES);
    
set_pev(minepev_solidSOLID_NOT);
    
set_pev(minepev_movetypeMOVETYPE_FLY);
    
    
emit_sound(mineCHAN_VOICEg_szMineDeployVOL_NORMATTN_NORM0PITCH_NORM);
    
emit_sound(mineCHAN_BODYg_szMineCharge0.2ATTN_NORM0PITCH_NORM);

    
set_pev(minepev_nextthinkget_gametime()+2.5);
}

public 
CTripmine_OnKilled(victimattackershouldgib)
{
    
}


public 
CTripmine_OnThink( const tripmine )
{
    new 
Float:vecSrc[3], Float:vForward[3];
    
pevtripminepev_originvecSrc );

    
UTIL_MakeAimVectorstripmine );
    
    
global_get(glb_v_forwardvForward);

    
xs_vec_mul_scalar(vForward8192.0vForward);
    
xs_vec_add(vForwardvecSrcvForward);
    
    new 
trFloat:fraction;
    
engfunc(EngFunc_TraceLinevecSrcvForwardIGNORE_MONSTERS, -1tr);
    
get_tr2(trTR_flFractionfraction);
    
    if(
fraction 1.0)
    {
        
get_tr2(trTR_vecEndPosvForward);
        new 
beam FX_BeamEntPoint(tripminevecSrcvForward10.0255.064.0Float:{ 0.0214.0198.0 });
        
        
set_pevtripminepev_vecdirvForward );
        
set_pevbeampev_ownertripmine );
        
        
set_pevbeampev_nextthinkget_gametime()+0.1);
    }
    
    
set_pev(tripminepev_solidSOLID_BBOX);
    
emit_sound(tripmineCHAN_VOICEg_szMineActivateVOL_NORMATTN_NORM0PITCH_NORM);
}

public 
CTripmine_OnBeamThink( const beam )
{
    static 
tripmine;
    
tripmine pevbeampev_owner );
    
    static 
Float:vecSrc[3], Float:vecEnd[3];
    
pevtripminepev_originvecSrc );
    
pevtripminepev_vecdirvecEnd );
    
    static 
trFloat:fraction;
    
engfunc(EngFunc_TraceLinevecSrcvecEndDONT_IGNORE_MONSTERStripminetr);
    
    
get_tr2(trTR_flFractionfraction);

    
client_print(print_chat,"fraction %f"fraction);

    if(
fraction 1.0)
    {
        static 
pHit;
        
pHit get_tr2trTR_pHit );

        
client_print(print_chat,"hit %d"pHit);

        if( 
<= pHit <= g_iMaxClients )
        {
            
client_print(print_chat,"Check hit %d"pHit);
            
//ExecuteHamB( Ham_Killed, tripmine, tripmine, 0);
        
}
    }
    
set_pev(beampev_nextthinkget_gametime()+0.1);
}

UTIL_MakeAimVectors( const id )
{
    static 
Float:flAngle[3];
    
pev(idpev_anglesflAngle);

    
flAngle[0] = -flAngle[0];
    
engfunc(EngFunc_MakeVectorsflAngle);
}

UTIl_GetWeaponOwner( const weapon )
{
    if(
pev_valid(weapon) != 2) return 0;
    
    return 
get_pdata_cbase(weapon414);
}

FX_BeamEntPoint(const i_Ent, const Float:vf_Origin[], const Float:vf_End[], const Float:f_Width, const Float:f_Scrollrate, const Float:f_Brightness, const Float:vf_Color[] )
{
    static 
beambeam engfunc(EngFunc_CreateNamedEntityg_iBeamAllocedString );

    
set_pev_string(beampev_classnameg_iBeamAllocedString );
    
set_pev(beampev_flagspev(beampev_flags ) | FL_CUSTOMENTITY );
    
set_pev(i_Entpev_beamindexbeam );

    
set_pev(beampev_modelg_szMineBeam );
    
set_pev(beampev_modelindexg_iLaserModel );

    
set_pev(beampev_body); 
    
set_pev(beampev_scalef_Width );        
    
set_pev(beampev_animtimef_Scrollrate );
    
set_pev(beampev_rendercolorvf_Color );
    
set_pev(beampev_renderamtf_Brightness ); 

    
set_pev(beampev_rendermodeTE_BEAMENTPOINT 0x0F );

    
set_pev(beampev_skin,(i_Ent 0x0FFF ) |(0xF000 ) << 12 );
    
set_pev(beampev_aimenti_Ent );

    
UTIL_RelinkBeam(beamvf_Originvf_End );
    
    return 
beam;
}

FX_Breakable( const classname, const model[], const Float:source], const Float:mins], const Float:maxs], const material[], const health[] )
{
    new 
entity create_entity"func_breakable" );

    
set_pev_stringentitypev_classnameclassname );
    
set_peventitypev_modelmodel );
    
set_peventitypev_healthhealth );

    
DispatchKeyValueentity"material"material );
    
DispatchKeyValueentity"health"health );

    
DispatchSpawnentity );

    
engfuncEngFunc_SetSizeentityminsmaxs );
    
engfuncEngFunc_SetOriginentitysource );
    
    return 
entity;
}

UTIL_RelinkBeam( const i_Beam, const Float:vf_Origin[], const Float:vf_End[] )
{
    static 
Float:vf_Mins], Float:vf_Maxs];

    
vf_Mins] = floatmin vf_End], vf_Origin] ) - vf_End];
    
vf_Mins] = floatmin vf_End], vf_Origin] ) - vf_End];
    
vf_Mins] = floatmin vf_End], vf_Origin] ) - vf_End];

    
vf_Maxs] = floatmax vf_End], vf_Origin] ) - vf_End];
    
vf_Maxs] = floatmax vf_End], vf_Origin] ) - vf_End];
    
vf_Maxs] = floatmax vf_End], vf_Origin] ) - vf_End];

    
engfunc EngFunc_SetSizei_Beamvf_Minsvf_Maxs );
    
engfunc EngFunc_SetOrigini_Beamvf_End );

PS: pev_solid also not work. Every time the entity is not-solid.

Thanks.

Last edited by bogdyuttzu; 08-23-2012 at 13:15.
bogdyuttzu is offline
Send a message via Yahoo to bogdyuttzu
 


Thread Tools
Display Modes

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 05:53.


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