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

[feature request] Add an option to customize transparency of player immunity #933

Open
damage220 opened this issue Jan 23, 2024 · 4 comments

Comments

@damage220
Copy link

damage220 commented Jan 23, 2024

Issue

There are custom player models which do not properly support transparency. I noticed it when I set transparency to 64 in resemiclip. The model is completely hidden and there is only weapon that you can see on the image (near crosshair).

20240123184820_1

I "fixed" it by increasing transparency to 128, however there is no such option in regamedll. I can see only these cvars:

mp_respawn_immunitytime
mp_respawn_immunity_effects
mp_respawn_immunity_force_unset

It looks like regamedll sets transparency below 128 to indicate player immunity.

Solution

It would be nice if we could have an option to customize it. If there are any plans on new effects to indicate immunity, possibly an option could be added, else we can rename mp_respawn_immunity_effects to mp_respawn_immunity_transparency, where
mp_respawn_immunity_transparency 255 is equal to mp_respawn_immunity_effects 0
mp_respawn_immunity_transparency <255 adds new possibilities to customize transparency effect

@SmileYzn
Copy link

SmileYzn commented Feb 2, 2024

Why these models are supposed to not support transparency?
I'm just curious

@damage220
Copy link
Author

They do not support low values of transparency, I dunno why. When I set transparency to 128, it works fine but when it is 120 the models completely disappear. It is correct both for transparency setting in resemiclip module and mp_respawn_immunity_effects 1 in regamedll. I have approx 12 custom models on my server. 4 of them works perfect even when transparency is 120 or below, but others are completely transparent. This is why I assumed there are models that are broken in terms of making them partly transparent.

@SmileYzn
Copy link

SmileYzn commented Feb 2, 2024

I guess that is related to textures, that do not support an value less than 128 in alpha channel.

pev->rendermode = kRenderTransAdd;
pev->renderamt  = 100.0f;

For now you have to rewrite

LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, SetSpawnProtection, (float flProtectionTime), flProtectionTime)

with an amxx plugin and make you own copy of that:

void EXT_FUNC CBasePlayer::__API_HOOK(SetSpawnProtection)(float flProtectionTime)
{
#ifdef REGAMEDLL_ADD
	if (respawn_immunity_effects.value > 0)
	{
		CSPlayer()->m_bSpawnProtectionEffects = true;
		pev->rendermode = kRenderTransAdd;
		pev->renderamt  = 100.0f;

		MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
			WRITE_BYTE(STATUSICON_FLASH);
			WRITE_STRING("suithelmet_full");
			WRITE_BYTE(0);
			WRITE_BYTE(160);
			WRITE_BYTE(0);
		MESSAGE_END();
	}

	CSPlayer()->m_flSpawnProtectionEndTime = gpGlobals->time + flProtectionTime;
#endif
}

@damage220
Copy link
Author

I guess that is related to textures, that do not support an value less than 128 in alpha channel.

pev->rendermode = kRenderTransAdd;
pev->renderamt  = 100.0f;

For now you have to rewrite

LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, SetSpawnProtection, (float flProtectionTime), flProtectionTime)

with an amxx plugin and make you own copy of that:

void EXT_FUNC CBasePlayer::__API_HOOK(SetSpawnProtection)(float flProtectionTime)
{
#ifdef REGAMEDLL_ADD
	if (respawn_immunity_effects.value > 0)
	{
		CSPlayer()->m_bSpawnProtectionEffects = true;
		pev->rendermode = kRenderTransAdd;
		pev->renderamt  = 100.0f;

		MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
			WRITE_BYTE(STATUSICON_FLASH);
			WRITE_STRING("suithelmet_full");
			WRITE_BYTE(0);
			WRITE_BYTE(160);
			WRITE_BYTE(0);
		MESSAGE_END();
	}

	CSPlayer()->m_flSpawnProtectionEndTime = gpGlobals->time + flProtectionTime;
#endif
}

While I can rewrite it with amxx plugin, it is good to have an option to customize immunity transparency value with almost no additional cost for implementing such an option.

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

No branches or pull requests

2 participants