Raised This Month: $51 Target: $400
 12% 

Solved [ H3LP ] Entity disappearing?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-18-2018 , 20:52   [ H3LP ] Entity disappearing?
Reply With Quote #1

Hello, I did a "laser spot" like of RPG of Half-Life 1. I'm not sure why, but the entity disappear depending of the location that I walk around in the map. In some maps the laser nor appear. The laser is being updated in weapon idle.

Code:
CLaserSpot_Create() {     new pevLaserSpot = rg_create_entity("env_sprite");     set_entvar(pevLaserSpot, var_movetype, MOVETYPE_NONE);     set_entvar(pevLaserSpot, var_solid, SOLID_NOT);     set_entvar(pevLaserSpot, var_rendermode, kRenderGlow);     set_entvar(pevLaserSpot, var_renderfx, kRenderFxNoDissipation);     set_entvar(pevLaserSpot, var_renderamt, 255.0);     entity_set_model(pevLaserSpot, g_szLaserDotModel);     entity_set_size(pevLaserSpot, Float:{ 0.0, 0.0, 0.0 }, Float:{ 0.0, 0.0, 0.0 });     set_entvar(pevLaserSpot, var_classname, g_pszNameLaserSpot);     //set_entvar(pevLaserSpot, var_owner, this);     return pevLaserSpot; }

Code:
CRpg_UpdateSpot(this) {     if (is_nullent(g_pevLaserSpot[this]))         return;     static Float:vecSrc[3], Float:vecVelocity[3], Float:vecAiming[3], Float:vecEndPos[3];         ExecuteHamB(Ham_Player_GetGunPosition, this, vecSrc);     velocity_by_aim(this, 8192, vecVelocity);     xs_vec_add(vecSrc, vecVelocity, vecAiming);     engfunc(EngFunc_TraceLine, vecSrc, vecAiming, DONT_IGNORE_MONSTERS, this, 0);     get_tr2(0, TR_vecEndPos, vecEndPos);     //client_print(0, print_chat, "TR_pHit(%d)", get_tr2(0, TR_pHit))     //get_pmtrace(tr, pmt_endpos, vecEndPos);     /*message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, .player = this)     {         write_byte(TE_BEAMPOINTS);         write_coord_f(vecSrc[0]);         write_coord_f(vecSrc[1]);         write_coord_f(vecSrc[2]);         write_coord_f(vecEndPos[0]);         write_coord_f(vecEndPos[1]);         write_coord_f(vecEndPos[2]);         write_short(g_sModelIndexSmokeTrail)         write_byte(0)         write_byte(0)         write_byte(1)         write_byte(15)         write_byte(0)         write_byte(0)         write_byte(0)         write_byte(255)         write_byte(255)         write_byte(0)     }     message_end();*/     set_entvar(g_pevLaserSpot[this], var_origin, vecEndPos); }
__________________









Last edited by CrazY.; 07-19-2018 at 09:58.
CrazY. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-19-2018 , 09:58   Re: [ H3LP ] Entity disappearing?
Reply With Quote #2

Quote:
Originally Posted by KliPPy View Post
EngFunc_SetOrigin doesn't just set the origin, it does some other stuff that the physics system needs. While changing pev_origin may work in some cases, the former is the safest bet.
__________________








CrazY. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-19-2018 , 11:38   Re: [ H3LP ] Entity disappearing?
Reply With Quote #3

Apparently some of pev_* functions don't seem to properly set everything. Better to use EngFunc or Fun natives. Even pev_maxspeed is buggy and EngFunc_SetClientMaxspeed should be used instead.

Last edited by edon1337; 07-19-2018 at 11:38.
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-19-2018 , 12:01   Re: [ H3LP ] Entity disappearing?
Reply With Quote #4

Quote:
Originally Posted by edon1337 View Post
Apparently some of pev_* functions don't seem to properly set everything. Better to use EngFunc or Fun natives. Even pev_maxspeed is buggy and EngFunc_SetClientMaxspeed should be used instead.
It's because they are not functions. It has the same effect as setting a variable in your plugin - no additional code is executed.
__________________

Last edited by klippy; 07-19-2018 at 12:02.
klippy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-19-2018 , 12:26   Re: [ H3LP ] Entity disappearing?
Reply With Quote #5

It's not a bug, in Half-Life source code also it's used a engine function to set origin and size in entities (the same happens with size, better use EngFunc_SetSize or entity_set_size).

Code:
// enginecallback.h #define SET_SIZE        (*g_engfuncs.pfnSetSize) #define SET_ORIGIN    (*g_engfuncs.pfnSetOrigin) // util.cpp void UTIL_SetSize( entvars_t *pev, const Vector &vecMin, const Vector &vecMax ) {     SET_SIZE( ENT(pev), vecMin, vecMax ); } void UTIL_SetOrigin( entvars_t *pev, const Vector &vecOrigin ) {     SET_ORIGIN(ENT(pev), vecOrigin ); }
__________________









Last edited by CrazY.; 07-19-2018 at 12:27.
CrazY. 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 04:55.


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