Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG?] Entity teleportation can only be activated once #765

Open
ELDment opened this issue Feb 7, 2025 · 11 comments
Open

[BUG?] Entity teleportation can only be activated once #765

ELDment opened this issue Feb 7, 2025 · 11 comments
Labels
untriaged New issue has not been triaged

Comments

@ELDment
Copy link

ELDment commented Feb 7, 2025

Preface: Maybe This Is Not a Bug🥲

When the Alpha of CBaseModelEntity.Render Is Set to an Integer Between 1 and 255

The issue described in the title does not occur if the alpha value is set to an integer between 1 and 255.

Example (In CS2):
Image


When Alpha Is Set to 0

The unexpected behavior mentioned in the title occurs when alpha is set to 0.
Note: The title might not be fully accurate (details explained below).

Why set alpha to 0?
I aimed to make the entity glow without rendering its model/texture, similar to the prop_dynamic_glow effect in CS:GO.

Example (In CS2):
Image

Initially, I assumed the issue was caused by the entity not updating on the network when alpha=0. However, the m_lastNetworkChange property of the entity continuously increases, suggesting network updates are still occurring.


Key Observations

  1. After calling DispatchSpawn on an entity with alpha=0, only the first teleport takes effect. Subsequent teleports do not update the entity’s glow position (the glow remains static).
  2. The entity itself might still be teleporting (I dont know since it’s not rendered), but its glow does not follow.
  3. (Contradicts the title?) Printing the entity’s AbsOrigin after teleporting with alpha=0 confirms the coordinates match the target position.
  4. Tested CBaseModelEntity.RenderMode values:
    • kRenderTransColor
    • kRenderTransTexture
    • kRenderGlow
    • kRenderTransAlpha
    • kRenderTransAlphaAdd
    • kRenderWorldGlow
      All resulted in the same issue.
  5. Tested CBaseModelEntity.RenderFX values:
    • kRenderFxNone
    • kRenderFxFadeSlow
    • kRenderFxFadeIn
      No changes observed.
  6. Tested entity types:
    • prop_dynamic_override
    • prop_physics_override
    • CBaseModelEntity
      Issue persisted in all cases.
@github-actions github-actions bot added the untriaged New issue has not been triaged label Feb 7, 2025
@ELDment
Copy link
Author

ELDment commented Feb 7, 2025

Encountered a strange phenomenon: even if the Alpha of CBaseModelEntity.Render is set to an integer between 1 and 255, the healthshot model/texture will not be rendered, but it can be teleported multiple times!

Image

( actually this is what I expected 😅 )
Image

@ELDment
Copy link
Author

ELDment commented Feb 7, 2025

Both the client and the server are Windows systems...

@ELDment
Copy link
Author

ELDment commented Feb 7, 2025

What do you think @KillStr3aK
😭

@KillStr3aK
Copy link
Contributor

What if you set the follow entity input instead of teleporting around?

@ELDment
Copy link
Author

ELDment commented Feb 7, 2025

What if you set the follow entity input instead of teleporting around?

Nothing happened (the glow remains static)

@KillStr3aK
Copy link
Contributor

mind sharing your glow code?

@ELDment
Copy link
Author

ELDment commented Feb 8, 2025

mind sharing your glow code?

var buffer = Utilities.CreateEntityByName<CBaseModelEntity>("basemodelentity");

buffer!.DispatchSpawn();
buffer!.Spawnflags = 256U;
buffer!.SetModel("xxx");

buffer!.Collision.CollisionGroup = 0;
buffer!.ShadowStrength = 0.0f;
buffer!.AnimTime = 0.0f;

buffer!.RenderMode = RenderMode_t.kRenderWorldGlow;
buffer!.RenderFX = RenderFx_t.kRenderFxFadeSlow;
buffer!.Render = Color.FromArgb(1, 255, 255, 255);
buffer!.FadeMinDist = 100.0f;
buffer!.Glow.GlowRange = 5000;
buffer!.Glow.GlowTeam = -1;
buffer!.Glow.GlowType = 3;
buffer!.Glow.GlowRangeMin = 3;
buffer!.Glow.GlowColorOverride = Color.FromArgb(255, rand.Next(256), rand.Next(256), rand.Next(256));

Utilities.SetStateChanged(buffer!, "CBaseEntity", "m_CBodyComponent");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderMode");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderFX");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_clrRender");
buffer!.Teleport(new Vector(player.PlayerPawn.Value!.AbsOrigin!.X, player.PlayerPawn.Value!.AbsOrigin!.Y, player.PlayerPawn.Value!.AbsOrigin!.Z + player.PlayerPawn.Value!.ViewOffset.As<Vector>().Z + 40), new QAngle(0, 0, 0), new Vector(0, 0, 0));

My code is similar to this, but it will include more complex checks to ensure the entity is valid.

@Dliix66
Copy link

Dliix66 commented Feb 8, 2025

mind sharing your glow code?

var buffer = Utilities.CreateEntityByName("basemodelentity");

buffer!.DispatchSpawn();
buffer!.Spawnflags = 256U;
buffer!.SetModel("xxx");

buffer!.Collision.CollisionGroup = 0;
buffer!.ShadowStrength = 0.0f;
buffer!.AnimTime = 0.0f;

buffer!.RenderMode = RenderMode_t.kRenderWorldGlow;
buffer!.RenderFX = RenderFx_t.kRenderFxFadeSlow;
buffer!.Render = Color.FromArgb(1, 255, 255, 255);
buffer!.FadeMinDist = 100.0f;
buffer!.Glow.GlowRange = 5000;
buffer!.Glow.GlowTeam = -1;
buffer!.Glow.GlowType = 3;
buffer!.Glow.GlowRangeMin = 3;
buffer!.Glow.GlowColorOverride = Color.FromArgb(255, rand.Next(256), rand.Next(256), rand.Next(256));

Utilities.SetStateChanged(buffer!, "CBaseEntity", "m_CBodyComponent");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderMode");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderFX");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_clrRender");
buffer!.Teleport(new Vector(player.PlayerPawn.Value!.AbsOrigin!.X, player.PlayerPawn.Value!.AbsOrigin!.Y, player.PlayerPawn.Value!.AbsOrigin!.Z + player.PlayerPawn.Value!.ViewOffset.As().Z + 40), new QAngle(0, 0, 0), new Vector(0, 0, 0));
My code is similar to this, but it will include more complex checks to ensure the entity is valid.

This doesn't set the weapon as a parent or follow it, you need to try with either solutions as @KillStr3aK said 👍

@ELDment
Copy link
Author

ELDment commented Feb 8, 2025

mind sharing your glow code?

var buffer = Utilities.CreateEntityByName("basemodelentity");
buffer!.DispatchSpawn();
buffer!.Spawnflags = 256U;
buffer!.SetModel("xxx");
buffer!.Collision.CollisionGroup = 0;
buffer!.ShadowStrength = 0.0f;
buffer!.AnimTime = 0.0f;
buffer!.RenderMode = RenderMode_t.kRenderWorldGlow;
buffer!.RenderFX = RenderFx_t.kRenderFxFadeSlow;
buffer!.Render = Color.FromArgb(1, 255, 255, 255);
buffer!.FadeMinDist = 100.0f;
buffer!.Glow.GlowRange = 5000;
buffer!.Glow.GlowTeam = -1;
buffer!.Glow.GlowType = 3;
buffer!.Glow.GlowRangeMin = 3;
buffer!.Glow.GlowColorOverride = Color.FromArgb(255, rand.Next(256), rand.Next(256), rand.Next(256));
Utilities.SetStateChanged(buffer!, "CBaseEntity", "m_CBodyComponent");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderMode");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_nRenderFX");
Utilities.SetStateChanged(buffer!, "CBaseModelEntity", "m_clrRender");
buffer!.Teleport(new Vector(player.PlayerPawn.Value!.AbsOrigin!.X, player.PlayerPawn.Value!.AbsOrigin!.Y, player.PlayerPawn.Value!.AbsOrigin!.Z + player.PlayerPawn.Value!.ViewOffset.As().Z + 40), new QAngle(0, 0, 0), new Vector(0, 0, 0));
My code is similar to this, but it will include more complex checks to ensure the entity is valid.

This doesn't set the weapon as a parent or follow it, you need to try with either solutions as @KillStr3aK said 👍

I actually tried the method he mentioned and the glow stayed where it teleported.
(I removed it because setting the parent didn't solve the problem)

@Dliix66
Copy link

Dliix66 commented Feb 8, 2025

Try this, it works on pawn, it should work on a weapon (I didn't test it though)

public static void SetGlow(this CBaseEntity entity)
{
	CBaseModelEntity? modelGlow = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic");
	CBaseModelEntity? modelRelay = Utilities.CreateEntityByName<CBaseModelEntity>("prop_dynamic");
	if (modelGlow == null || modelRelay == null)
		return;

	string modelName = entity.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName;

	modelRelay.SetModel(modelName);
	modelRelay.Spawnflags = 256u;
	modelRelay.RenderMode = RenderMode_t.kRenderNone;
	modelRelay.DispatchSpawn();

	modelGlow.SetModel(modelName);
	modelGlow.Spawnflags = 256u;
	modelGlow.DispatchSpawn();

	modelGlow.Glow.GlowColorOverride = Color.Magenta;
	modelGlow.Glow.GlowRange = 5000;
	modelGlow.Glow.GlowTeam = -1;
	modelGlow.Glow.GlowType = 3;
	modelGlow.Glow.GlowRangeMin = 100;

	modelRelay.AcceptInput("FollowEntity", entity, modelRelay, "!activator");
	modelGlow.AcceptInput("FollowEntity", modelRelay, modelGlow, "!activator");
}

@ELDment
Copy link
Author

ELDment commented Feb 8, 2025

Try this, it works on pawn, it should work on a weapon (I didn't test it though)

public static void SetGlow(this CBaseEntity entity)
{
CBaseModelEntity? modelGlow = Utilities.CreateEntityByName("prop_dynamic");
CBaseModelEntity? modelRelay = Utilities.CreateEntityByName("prop_dynamic");
if (modelGlow == null || modelRelay == null)
return;

string modelName = entity.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName;

modelRelay.SetModel(modelName);
modelRelay.Spawnflags = 256u;
modelRelay.RenderMode = RenderMode_t.kRenderNone;
modelRelay.DispatchSpawn();

modelGlow.SetModel(modelName);
modelGlow.Spawnflags = 256u;
modelGlow.DispatchSpawn();

modelGlow.Glow.GlowColorOverride = Color.Magenta;
modelGlow.Glow.GlowRange = 5000;
modelGlow.Glow.GlowTeam = -1;
modelGlow.Glow.GlowType = 3;
modelGlow.Glow.GlowRangeMin = 100;

modelRelay.AcceptInput("FollowEntity", entity, modelRelay, "!activator");
modelGlow.AcceptInput("FollowEntity", modelRelay, modelGlow, "!activator");
}

Actually, I have already solved the model glowing. The purpose of opening this issue is to understand why the teleportation only works the first time when alpha = 0. Or is there a way to hide the model's texture?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged New issue has not been triaged
Projects
None yet
Development

No branches or pull requests

3 participants