mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-17 13:38:18 +00:00
Render sparkling trail for invincible players
This commit is contained in:
parent
c91be7b19f
commit
5457e8fc3b
BIN
data/extras.png
BIN
data/extras.png
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 6.7 KiB |
|
@ -452,6 +452,7 @@ container.sprites.Add(Sprite("hud_lock_mode", set_hud, 10,6,2,2))
|
|||
container.sprites.Add(Sprite("hud_team0_mode", set_hud, 12,6,2,2))
|
||||
|
||||
container.sprites.Add(Sprite("part_snowflake", set_extras, 0,0,2,2))
|
||||
container.sprites.Add(Sprite("part_sparkle", set_extras, 2,0,2,2))
|
||||
|
||||
|
||||
anim = Animation("base")
|
||||
|
|
|
@ -103,6 +103,26 @@ void CEffects::FreezingFlakes(vec2 Pos, vec2 Size, float Alpha)
|
|||
m_pClient->m_Particles.Add(CParticles::GROUP_EXTRA, &p);
|
||||
}
|
||||
|
||||
void CEffects::SparkleTrail(vec2 Pos, float Alpha)
|
||||
{
|
||||
if(!m_Add50hz)
|
||||
return;
|
||||
|
||||
CParticle p;
|
||||
p.SetDefault();
|
||||
p.m_Spr = SPRITE_PART_SPARKLE;
|
||||
p.m_Pos = Pos + random_direction() * random_float(40.0f);
|
||||
p.m_Vel = vec2(0, 0);
|
||||
p.m_LifeSpan = 0.5f;
|
||||
p.m_StartSize = 0.0f;
|
||||
p.m_EndSize = random_float(20.0f, 30.0f);
|
||||
p.m_UseAlphaFading = true;
|
||||
p.m_StartAlpha = Alpha;
|
||||
p.m_EndAlpha = std::min(0.2f, Alpha);
|
||||
p.m_Collides = false;
|
||||
m_pClient->m_Particles.Add(CParticles::GROUP_TRAIL_EXTRA, &p);
|
||||
}
|
||||
|
||||
void CEffects::SmokeTrail(vec2 Pos, vec2 Vel, float Alpha, float TimePassed)
|
||||
{
|
||||
if(!m_Add50hz && TimePassed < 0.001f)
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
void PlayerDeath(vec2 Pos, int ClientId, float Alpha = 1.0f);
|
||||
void PowerupShine(vec2 Pos, vec2 Size, float Alpha = 1.0f);
|
||||
void FreezingFlakes(vec2 Pos, vec2 Size, float Alpha = 1.0f);
|
||||
void SparkleTrail(vec2 Pos, float Alpha = 1.0f);
|
||||
void Confetti(vec2 Pos, float Alpha = 1.0f);
|
||||
|
||||
void Update();
|
||||
|
|
|
@ -14,6 +14,7 @@ CParticles::CParticles()
|
|||
{
|
||||
OnReset();
|
||||
m_RenderTrail.m_pParts = this;
|
||||
m_RenderTrailExtra.m_pParts = this;
|
||||
m_RenderExplosions.m_pParts = this;
|
||||
m_RenderExtra.m_pParts = this;
|
||||
m_RenderGeneral.m_pParts = this;
|
||||
|
@ -181,9 +182,12 @@ void CParticles::OnInit()
|
|||
|
||||
m_ExtraParticleQuadContainerIndex = Graphics()->CreateQuadContainer(false);
|
||||
|
||||
// TODO: Use a loop similar to the one for m_ParticleQuadContainerIndex if you add more additional particles
|
||||
Graphics()->QuadsSetSubset(0, 0, 1, 1);
|
||||
RenderTools()->QuadContainerAddSprite(m_ExtraParticleQuadContainerIndex, 1.f);
|
||||
for(int i = 0; i <= (SPRITE_PART_SPARKLE - SPRITE_PART_SNOWFLAKE); ++i)
|
||||
{
|
||||
Graphics()->QuadsSetSubset(0, 0, 1, 1);
|
||||
RenderTools()->QuadContainerAddSprite(m_ExtraParticleQuadContainerIndex, 1.f);
|
||||
}
|
||||
|
||||
Graphics()->QuadContainerUpload(m_ExtraParticleQuadContainerIndex);
|
||||
}
|
||||
|
||||
|
@ -207,7 +211,7 @@ void CParticles::RenderGroup(int Group)
|
|||
IGraphics::CTextureHandle *aParticles = GameClient()->m_ParticlesSkin.m_aSpriteParticles;
|
||||
int FirstParticleOffset = SPRITE_PART_SLICE;
|
||||
int ParticleQuadContainerIndex = m_ParticleQuadContainerIndex;
|
||||
if(Group == GROUP_EXTRA)
|
||||
if(Group == GROUP_EXTRA || Group == GROUP_TRAIL_EXTRA)
|
||||
{
|
||||
aParticles = GameClient()->m_ExtrasSkin.m_aSpriteParticles;
|
||||
FirstParticleOffset = SPRITE_PART_SNOWFLAKE;
|
||||
|
|
|
@ -68,6 +68,7 @@ public:
|
|||
enum
|
||||
{
|
||||
GROUP_PROJECTILE_TRAIL = 0,
|
||||
GROUP_TRAIL_EXTRA,
|
||||
GROUP_EXPLOSIONS,
|
||||
GROUP_EXTRA,
|
||||
GROUP_GENERAL,
|
||||
|
@ -111,7 +112,10 @@ private:
|
|||
virtual void OnRender() override { m_pParts->RenderGroup(TGROUP); }
|
||||
};
|
||||
|
||||
// behind players
|
||||
CRenderGroup<GROUP_PROJECTILE_TRAIL> m_RenderTrail;
|
||||
CRenderGroup<GROUP_TRAIL_EXTRA> m_RenderTrailExtra;
|
||||
// in front of players
|
||||
CRenderGroup<GROUP_EXPLOSIONS> m_RenderExplosions;
|
||||
CRenderGroup<GROUP_EXTRA> m_RenderExtra;
|
||||
CRenderGroup<GROUP_GENERAL> m_RenderGeneral;
|
||||
|
|
|
@ -742,6 +742,10 @@ void CPlayers::RenderPlayer(
|
|||
{
|
||||
GameClient()->m_Effects.FreezingFlakes(BodyPos, vec2(32, 32), Alpha);
|
||||
}
|
||||
if(RenderInfo.m_TeeRenderFlags & TEE_EFFECT_SPARKLE)
|
||||
{
|
||||
GameClient()->m_Effects.SparkleTrail(BodyPos, Alpha);
|
||||
}
|
||||
|
||||
if(ClientId < 0)
|
||||
return;
|
||||
|
@ -833,6 +837,8 @@ void CPlayers::OnRender()
|
|||
aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_FROZEN | TEE_NO_WEAPON;
|
||||
if(m_pClient->m_aClients[i].m_LiveFrozen)
|
||||
aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_FROZEN;
|
||||
if(m_pClient->m_aClients[i].m_Invincible)
|
||||
aRenderInfo[i].m_TeeRenderFlags |= TEE_EFFECT_SPARKLE;
|
||||
|
||||
const CGameClient::CSnapState::CCharacterInfo &CharacterInfo = m_pClient->m_Snap.m_aCharacters[i];
|
||||
const bool Frozen = CharacterInfo.m_HasExtendedData && CharacterInfo.m_ExtendedData.m_FreezeEnd != 0;
|
||||
|
|
|
@ -128,6 +128,7 @@ void CGameClient::OnConsoleInit()
|
|||
&m_Background, // render instead of m_MapLayersBackground when g_Config.m_ClOverlayEntities == 100
|
||||
&m_MapLayersBackground, // first to render
|
||||
&m_Particles.m_RenderTrail,
|
||||
&m_Particles.m_RenderTrailExtra,
|
||||
&m_Items,
|
||||
&m_Ghost,
|
||||
&m_Players,
|
||||
|
@ -1683,6 +1684,7 @@ void CGameClient::OnNewSnapshot()
|
|||
pClient->m_ShotgunHitDisabled = pCharacterData->m_Flags & CHARACTERFLAG_SHOTGUN_HIT_DISABLED;
|
||||
pClient->m_HookHitDisabled = pCharacterData->m_Flags & CHARACTERFLAG_HOOK_HIT_DISABLED;
|
||||
pClient->m_Super = pCharacterData->m_Flags & CHARACTERFLAG_SUPER;
|
||||
pClient->m_Invincible = pCharacterData->m_Flags & CHARACTERFLAG_INVINCIBLE;
|
||||
|
||||
// Endless
|
||||
pClient->m_EndlessHook = pCharacterData->m_Flags & CHARACTERFLAG_ENDLESS_HOOK;
|
||||
|
@ -2457,6 +2459,7 @@ void CGameClient::CClientData::Reset()
|
|||
m_ShotgunHitDisabled = false;
|
||||
m_HookHitDisabled = false;
|
||||
m_Super = false;
|
||||
m_Invincible = false;
|
||||
m_HasTelegunGun = false;
|
||||
m_HasTelegunGrenade = false;
|
||||
m_HasTelegunLaser = false;
|
||||
|
@ -3697,6 +3700,7 @@ void CGameClient::LoadExtrasSkin(const char *pPath, bool AsDir)
|
|||
if(m_ExtrasSkinLoaded)
|
||||
{
|
||||
Graphics()->UnloadTexture(&m_ExtrasSkin.m_SpriteParticleSnowflake);
|
||||
Graphics()->UnloadTexture(&m_ExtrasSkin.m_SpriteParticleSparkle);
|
||||
|
||||
for(auto &SpriteParticle : m_ExtrasSkin.m_aSpriteParticles)
|
||||
SpriteParticle = IGraphics::CTextureHandle();
|
||||
|
@ -3731,7 +3735,11 @@ void CGameClient::LoadExtrasSkin(const char *pPath, bool AsDir)
|
|||
else if(PngLoaded && Graphics()->CheckImageDivisibility(aPath, ImgInfo, g_pData->m_aSprites[SPRITE_PART_SNOWFLAKE].m_pSet->m_Gridx, g_pData->m_aSprites[SPRITE_PART_SNOWFLAKE].m_pSet->m_Gridy, true) && Graphics()->IsImageFormatRgba(aPath, ImgInfo))
|
||||
{
|
||||
m_ExtrasSkin.m_SpriteParticleSnowflake = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_PART_SNOWFLAKE]);
|
||||
m_ExtrasSkin.m_SpriteParticleSparkle = Graphics()->LoadSpriteTexture(ImgInfo, &g_pData->m_aSprites[SPRITE_PART_SPARKLE]);
|
||||
|
||||
m_ExtrasSkin.m_aSpriteParticles[0] = m_ExtrasSkin.m_SpriteParticleSnowflake;
|
||||
m_ExtrasSkin.m_aSpriteParticles[1] = m_ExtrasSkin.m_SpriteParticleSparkle;
|
||||
|
||||
m_ExtrasSkinLoaded = true;
|
||||
}
|
||||
ImgInfo.Free();
|
||||
|
|
|
@ -394,6 +394,7 @@ public:
|
|||
bool m_ShotgunHitDisabled;
|
||||
bool m_HookHitDisabled;
|
||||
bool m_Super;
|
||||
bool m_Invincible;
|
||||
bool m_HasTelegunGun;
|
||||
bool m_HasTelegunGrenade;
|
||||
bool m_HasTelegunLaser;
|
||||
|
@ -768,7 +769,8 @@ public:
|
|||
struct SClientExtrasSkin
|
||||
{
|
||||
IGraphics::CTextureHandle m_SpriteParticleSnowflake;
|
||||
IGraphics::CTextureHandle m_aSpriteParticles[1];
|
||||
IGraphics::CTextureHandle m_SpriteParticleSparkle;
|
||||
IGraphics::CTextureHandle m_aSpriteParticles[2];
|
||||
};
|
||||
|
||||
SClientExtrasSkin m_ExtrasSkin;
|
||||
|
|
|
@ -123,6 +123,7 @@ enum
|
|||
{
|
||||
TEE_EFFECT_FROZEN = 1,
|
||||
TEE_NO_WEAPON = 2,
|
||||
TEE_EFFECT_SPARKLE = 4,
|
||||
};
|
||||
|
||||
// sprite renderings
|
||||
|
|
Loading…
Reference in a new issue