Member
|
10-16-2021
, 02:11
Re: [L4D1 & L4D2] HP Laser [v1.0.7 | 23-February-2021]
|
#19
|
Quote:
Originally Posted by Marttt
Unfortunately, it is not possible. The plugin uses TE_SetupBeamPoints to display the laser according to every client's point of view and there is no such config to attach it to something.
That's why the "little lag", since I need to teleport it manually every 0.1s.
There is a cvar that sets it on every frame but is resource expensive (disabled by default).
Depending on your server config it can increase the networking a lot.
Maybe there is some way to attach but I wasn't able to find it.
If you want something more real-time attached to the client then you would have to use something like my other plugin [L4D1 & L4D2] HP Sprite.
Even then being similar, both behave differently, so is all about pros vs cons.
|
Hello Marttt! First off, this plugin is a great idea and its well executed, nicely done.
I've been working on Rochelle's smoker tongue ninja rope in XPMod and encountered the same issue you mentioned. I did some digging and found someone able to attach TempEnts using dummy entities. Putting some examples together and changing it a bit, I was very excited to have a working "rope" attached to two controllable entities. I thought I would share my findings with you and if you have the time to take a look at this, maybe it could be used with your plugin to reduce some overhead and "lag" that was mentioned.
This is taken directly from XPMod, so not everything will work standalone without editing, but just some small changes and it'll work. I think if you create the dummy entities at your beam start/end points, then use CreateBeamEntity, and lastly move dummy entities as needed to indicate the players health, it could work.
Code:
int CreateDummyEntity(
float xyzLocation[3],
float fLifetime = -1.0,
int iEntityToAttachTo = -1,
char[] strAttachmentPoint = "NONE")
{
// Create the entity
int iEntity = CreateEntityByName("prop_dynamic");
if (RunEntityChecks(iEntity) == false)
return -1;
// Set up the values needed
char strEntity[30];
Format(strEntity, sizeof(strEntity), "start%i", iEntity); // start/end, doesn't seem to matter if both are specified
DispatchKeyValue(iEntity, "targetname", strEntity);
DispatchKeyValue(iEntity, "model", "models/NULL.mdl"); // confirmed that this is required, but doesn't matter if the model exists
DispatchKeyValue(iEntity, "solid", "0");
DispatchKeyValue(iEntity, "rendermode", "10");
// Teleport the entity to appropriate location
if (RunEntityChecks(iEntityToAttachTo) == true)
{
float xyzAngles[3];
GetEntPropVector(iEntityToAttachTo, Prop_Send, "m_vecOrigin", xyzLocation);
GetClientEyeAngles(iEntityToAttachTo, xyzAngles);
TeleportEntity(iEntity, xyzLocation, xyzAngles, NULL_VECTOR);
}
else
{
TeleportEntity(iEntity, xyzLocation, NULL_VECTOR, NULL_VECTOR);
}
// Attachment if required
if (RunEntityChecks(iEntityToAttachTo) == true)
{
SetVariantString("!activator");
AcceptEntityInput(iEntity, "SetParent", iEntityToAttachTo, iEntity, 0);
SetVariantString(strAttachmentPoint);
AcceptEntityInput(iEntity, "SetParentAttachmentMaintainOffset", iEntity, iEntity, 0);
}
DispatchSpawn(iEntity);
ActivateEntity(iEntity);
if (fLifetime > 0.0)
PrintToChatAll("CreateDummyEntity: fLifeTime not implemented yet.");
return iEntity;
}
void CreateBeamEntity(
int iStartEntity,
int iEndEntity,
int iPrecachedModelIndex,
int iRed = 255, int iGreen = 255, int iBlue = 255, int iAlpha = 255,
float fLifeTime = 120.0,
float fStartWidth = 5.0,
float fEndWidth = 5.0,
int iFadeLength = 100,
float fAmplitude = 0.1,
int iSpeed = 1,
int iFrameRate = 60)
{
TE_Start("BeamEnts");
TE_WriteEncodedEnt("m_nStartEntity", iStartEntity);
TE_WriteEncodedEnt("m_nEndEntity", iEndEntity);
TE_WriteNum("m_nModelIndex", iPrecachedModelIndex);
TE_WriteNum("m_nHaloIndex", g_iSprite_Halo);
TE_WriteNum("r", iRed);
TE_WriteNum("g", iGreen);
TE_WriteNum("b", iBlue);
TE_WriteNum("a", iAlpha);
TE_WriteFloat("m_fLife", fLifeTime);
TE_WriteFloat("m_fWidth", fStartWidth);
TE_WriteFloat("m_fEndWidth", fEndWidth);
TE_WriteNum("m_nFadeLength", iFadeLength);
TE_WriteFloat("m_fAmplitude", fAmplitude);
TE_WriteNum("m_nSpeed", iSpeed);
TE_WriteNum("m_nStartFrame", 0);
TE_WriteNum("m_nFrameRate", iFrameRate);
TE_SendToAll();
}
void CreateSmokerTongueNinjaRope(int iClient)
{
float xyzLocation[3];
g_iRochelleRopeDummyEntityAttachmentHand[iClient] = CreateDummyEntity(xyzLocation, -1.0, iClient, "muzzle_flash");
g_iRochelleRopeDummyEntityAttachmentWall[iClient] = CreateDummyEntity(g_xyzRopeEndLocation[iClient]);
CreateBeamEntity(
g_iRochelleRopeDummyEntityAttachmentHand[iClient],
g_iRochelleRopeDummyEntityAttachmentWall[iClient],
g_iSprite_SmokerTongue);
}
void KillAllNinjaRopeEntities(int iClient)
{
KillEntitySafely(g_iRochelleRopeDummyEntityAttachmentWall[iClient]);
KillEntitySafely(g_iRochelleRopeDummyEntityAttachmentHand[iClient]);
}
bool KillEntitySafely(int iEntity)
{
if (RunEntityChecks(iEntity) == false)
return false;
AcceptEntityInput(iEntity, "Kill");
return true;
}
//These are in my precache function
g_iSprite_SmokerTongue = PrecacheModel("materials/particle/smoker_tongue_beam.vmt");
g_iSprite_Halo = PrecacheModel("materials/sprites/halo01.vmt");
|
|