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

[Fix Included] Gluon Cloud Restored! #3066

Open
OpenRift412 opened this issue Feb 28, 2021 · 5 comments
Open

[Fix Included] Gluon Cloud Restored! #3066

OpenRift412 opened this issue Feb 28, 2021 · 5 comments

Comments

@OpenRift412
Copy link

OpenRift412 commented Feb 28, 2021

20210227211252_1

So I've been doing some experiments lately with trying to figure out how to fix the Gluon Beam myself to make my own circa 1.0.1.6-style dll files, and I found this code in the source code for the subtitles mod.

Okay, so first, in ev_hldm.cpp, paste the following code at line 1389:

TEMPENTITY *pFlare; //Egon beam flare

void EV_EgonFlareCallback(struct tempent_s* ent, float frametime, float currenttime)
{
float delta = currenttime - ent->tentOffset.z; // time past since the last scale
if (delta >= ent->tentOffset.y)
{
ent->entity.curstate.scale += ent->tentOffset.x * delta;
ent->tentOffset.z = currenttime;
}
}

Add a new line after 1469, Paste this on the new line 1470:

// Egon beam flare
pFlare = gEngfuncs.pEfxAPI->R_TempSprite(tr.endpos, vec3_origin, 1.0, gEngfuncs.pEventAPI->EV_FindModelIndex(EGON_FLARE_SPRITE), kRenderGlow, kRenderFxNoDissipation, 1.0, 99999, FTENT_SPRCYCLE | FTENT_PERSIST);

Add a new line after 1471, and paste this:

if (pFlare) // Store the last mode for EV_EgonStop()
{
pFlare->tentOffset.x = (iFireMode == FIRE_WIDE) ? 1.0f : 0.0f;
}

Add a new line at 1500, and paste this:

if (pFlare) // Vit_amiN: egon beam flare
{
pFlare->die = gEngfuncs.GetClientTime();

  	if (gEngfuncs.GetMaxClients() == 1 || !(pFlare->flags & FTENT_NOMODEL))
  	{
  		if (pFlare->tentOffset.x != 0.0f)	// true for iFireMode == FIRE_WIDE
  		{
  			pFlare->callback = &EV_EgonFlareCallback;
  			pFlare->fadeSpeed = 2.0;			// fade out will take 0.5 sec
  			pFlare->tentOffset.x = 10.0;		// scaling speed per second
  			pFlare->tentOffset.y = 0.1;			// min time between two scales
  			pFlare->tentOffset.z = pFlare->die;	// the last callback run time
  			pFlare->flags = FTENT_FADEOUT | FTENT_CLIENTCUSTOM;
  		}
  	}

  	pFlare = NULL;

Now, go to hl_objects.cpp at line 30, add a line and paste the following:

extern TEMPENTITY* pFlare; // Egon's energy flare

Next, go to line 76, add a line and paste this:

if (pFlare) // Vit_amiN: beam flare
{
pFlare->entity.origin = tr.endpos;
pFlare->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.

  if (gEngfuncs.GetMaxClients() != 1)	// Singleplayer always draws the egon's energy beam flare
  {
  	pFlare->flags |= FTENT_NOMODEL;

  	if (!(tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0))	// Beam hit some non-world entity
  	{
  		physent_t* pEntity = gEngfuncs.pEventAPI->EV_GetPhysent(tr.ent);

  		// Not the world, let's assume that we hit something organic ( dog, cat, uncle joe, etc )
  		if (pEntity && !(pEntity->solid == SOLID_BSP || pEntity->movetype == MOVETYPE_PUSHSTEP))
  		{
  			pFlare->flags &= ~FTENT_NOMODEL;
  		}
  	}
  }

}

Lastly, go to line 86.
Replace this:

void Game_AddObjects( void )
{
if ( pBeam && pBeam2 )
UpdateBeams();
}

With this:

void Game_AddObjects(void)
{
if (pBeam || pBeam2 || pFlare) // Egon flare added
UpdateBeams();
}

Let me know if this works for you guys too.

@OpenRift412
Copy link
Author

Updated to add missing code I forgot to include.

@SamVanheer
Copy link

This is an issue that was mentioned in #617 but not fixed.

Looks like this works, but it's missing some code from the original implementation:
https://github.com/Fograin/hl-subs-mod/blob/7503d88c68dd33ebe217749fe9a150e62c1f7d8b/src/cl_dll/hud_msg.cpp#L32
https://github.com/Fograin/hl-subs-mod/blob/7503d88c68dd33ebe217749fe9a150e62c1f7d8b/src/cl_dll/hud_msg.cpp#L106

These reset the flare pointer when the HUD is initialized, just like the beam pointers.

@OpenRift412
Copy link
Author

This is an issue that was mentioned in #617 but not fixed.

Looks like this works, but it's missing some code from the original implementation:
https://github.com/Fograin/hl-subs-mod/blob/7503d88c68dd33ebe217749fe9a150e62c1f7d8b/src/cl_dll/hud_msg.cpp#L32
https://github.com/Fograin/hl-subs-mod/blob/7503d88c68dd33ebe217749fe9a150e62c1f7d8b/src/cl_dll/hud_msg.cpp#L106

These reset the flare pointer when the HUD is initialized, just like the beam pointers.

Thanks for the additional info.

@SamVanheer
Copy link

Note that this fix is pretty much what Opposing Force does, aside from emulating multiplayer behavior more closely by turning off the flare sprite if it hits the world.

@BlackShadow
Copy link

@kisak-valve Duplicate of #617

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants