AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Entity disappearing? (https://forums.alliedmods.net/showthread.php?t=309253)

CrazY. 07-18-2018 20:52

[ H3LP ] Entity disappearing?
 
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); }

CrazY. 07-19-2018 09:58

Re: [ H3LP ] Entity disappearing?
 
Quote:

Originally Posted by KliPPy (Post 2604503)
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.


edon1337 07-19-2018 11:38

Re: [ H3LP ] Entity disappearing?
 
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.

klippy 07-19-2018 12:01

Re: [ H3LP ] Entity disappearing?
 
Quote:

Originally Posted by edon1337 (Post 2604815)
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.

CrazY. 07-19-2018 12:26

Re: [ H3LP ] Entity disappearing?
 
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 ); }


All times are GMT -4. The time now is 12:22.

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