Merge pull request #8717 from heinrich5991/pr_ddnet_birthday

Distinguish birthday from finish events
This commit is contained in:
Dennis Felsing 2024-08-13 09:43:11 +00:00 committed by GitHub
commit 192ae58a2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 25 additions and 11 deletions

View file

@ -345,6 +345,8 @@ Objects = [
NetIntAny("m_Angle"), NetIntAny("m_Angle"),
]), ]),
NetEventEx("Birthday:Common", "birthday@netevent.ddnet.org", []),
NetEventEx("Finish:Common", "finish@netevent.ddnet.org", []), NetEventEx("Finish:Common", "finish@netevent.ddnet.org", []),
NetObjectEx("MyOwnEvent", "my-own-event@heinrich5991.de", [ NetObjectEx("MyOwnEvent", "my-own-event@heinrich5991.de", [

View file

@ -226,7 +226,7 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientId, float Alpha)
} }
} }
void CEffects::FinishConfetti(vec2 Pos, float Alpha) void CEffects::Confetti(vec2 Pos, float Alpha)
{ {
ColorRGBA Red(1.0f, 0.4f, 0.4f); ColorRGBA Red(1.0f, 0.4f, 0.4f);
ColorRGBA Green(0.4f, 1.0f, 0.4f); ColorRGBA Green(0.4f, 1.0f, 0.4f);

View file

@ -30,7 +30,7 @@ public:
void PlayerDeath(vec2 Pos, int ClientId, float Alpha = 1.0f); void PlayerDeath(vec2 Pos, int ClientId, float Alpha = 1.0f);
void PowerupShine(vec2 Pos, vec2 Size, 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 FreezingFlakes(vec2 Pos, vec2 Size, float Alpha = 1.0f);
void FinishConfetti(vec2 Pos, float Alpha = 1.0f); void Confetti(vec2 Pos, float Alpha = 1.0f);
void Update(); void Update();
}; };

View file

@ -1183,10 +1183,15 @@ void CGameClient::ProcessEvents()
const CNetEvent_HammerHit *pEvent = (const CNetEvent_HammerHit *)Item.m_pData; const CNetEvent_HammerHit *pEvent = (const CNetEvent_HammerHit *)Item.m_pData;
m_Effects.HammerHit(vec2(pEvent->m_X, pEvent->m_Y), Alpha); m_Effects.HammerHit(vec2(pEvent->m_X, pEvent->m_Y), Alpha);
} }
else if(Item.m_Type == NETEVENTTYPE_BIRTHDAY)
{
const CNetEvent_Birthday *pEvent = (const CNetEvent_Birthday *)Item.m_pData;
m_Effects.Confetti(vec2(pEvent->m_X, pEvent->m_Y), Alpha);
}
else if(Item.m_Type == NETEVENTTYPE_FINISH) else if(Item.m_Type == NETEVENTTYPE_FINISH)
{ {
const CNetEvent_Finish *pEvent = (const CNetEvent_Finish *)Item.m_pData; const CNetEvent_Finish *pEvent = (const CNetEvent_Finish *)Item.m_pData;
m_Effects.FinishConfetti(vec2(pEvent->m_X, pEvent->m_Y), Alpha); m_Effects.Confetti(vec2(pEvent->m_X, pEvent->m_Y), Alpha);
} }
else if(Item.m_Type == NETEVENTTYPE_SPAWN) else if(Item.m_Type == NETEVENTTYPE_SPAWN)
{ {

View file

@ -258,7 +258,6 @@ void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount, CClientMas
void CGameContext::CreateHammerHit(vec2 Pos, CClientMask Mask) void CGameContext::CreateHammerHit(vec2 Pos, CClientMask Mask)
{ {
// create the event
CNetEvent_HammerHit *pEvent = m_Events.Create<CNetEvent_HammerHit>(Mask); CNetEvent_HammerHit *pEvent = m_Events.Create<CNetEvent_HammerHit>(Mask);
if(pEvent) if(pEvent)
{ {
@ -327,7 +326,6 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, bool NoDamag
void CGameContext::CreatePlayerSpawn(vec2 Pos, CClientMask Mask) void CGameContext::CreatePlayerSpawn(vec2 Pos, CClientMask Mask)
{ {
// create the event
CNetEvent_Spawn *pEvent = m_Events.Create<CNetEvent_Spawn>(Mask); CNetEvent_Spawn *pEvent = m_Events.Create<CNetEvent_Spawn>(Mask);
if(pEvent) if(pEvent)
{ {
@ -338,7 +336,6 @@ void CGameContext::CreatePlayerSpawn(vec2 Pos, CClientMask Mask)
void CGameContext::CreateDeath(vec2 Pos, int ClientId, CClientMask Mask) void CGameContext::CreateDeath(vec2 Pos, int ClientId, CClientMask Mask)
{ {
// create the event
CNetEvent_Death *pEvent = m_Events.Create<CNetEvent_Death>(Mask); CNetEvent_Death *pEvent = m_Events.Create<CNetEvent_Death>(Mask);
if(pEvent) if(pEvent)
{ {
@ -348,9 +345,18 @@ void CGameContext::CreateDeath(vec2 Pos, int ClientId, CClientMask Mask)
} }
} }
void CGameContext::CreateFinishConfetti(vec2 Pos, CClientMask Mask) void CGameContext::CreateBirthdayEffect(vec2 Pos, CClientMask Mask)
{
CNetEvent_Birthday *pEvent = m_Events.Create<CNetEvent_Birthday>(Mask);
if(pEvent)
{
pEvent->m_X = (int)Pos.x;
pEvent->m_Y = (int)Pos.y;
}
}
void CGameContext::CreateFinishEffect(vec2 Pos, CClientMask Mask)
{ {
// create the event
CNetEvent_Finish *pEvent = m_Events.Create<CNetEvent_Finish>(Mask); CNetEvent_Finish *pEvent = m_Events.Create<CNetEvent_Finish>(Mask);
if(pEvent) if(pEvent)
{ {

View file

@ -239,7 +239,8 @@ public:
void CreateHammerHit(vec2 Pos, CClientMask Mask = CClientMask().set()); void CreateHammerHit(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreatePlayerSpawn(vec2 Pos, CClientMask Mask = CClientMask().set()); void CreatePlayerSpawn(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreateDeath(vec2 Pos, int ClientId, CClientMask Mask = CClientMask().set()); void CreateDeath(vec2 Pos, int ClientId, CClientMask Mask = CClientMask().set());
void CreateFinishConfetti(vec2 Pos, CClientMask Mask = CClientMask().set()); void CreateBirthdayEffect(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreateFinishEffect(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreateSound(vec2 Pos, int Sound, CClientMask Mask = CClientMask().set()); void CreateSound(vec2 Pos, int Sound, CClientMask Mask = CClientMask().set());
void CreateSoundGlobal(int Sound, int Target = -1) const; void CreateSoundGlobal(int Sound, int Target = -1) const;

View file

@ -937,7 +937,7 @@ void CPlayer::ProcessScoreResult(CScorePlayerResult &Result)
GameServer()->SendBroadcast(aBuf, m_ClientId); GameServer()->SendBroadcast(aBuf, m_ClientId);
m_BirthdayAnnounced = true; m_BirthdayAnnounced = true;
GameServer()->CreateFinishConfetti(GetCharacter()->m_Pos, GetCharacter()->TeamMask()); GameServer()->CreateBirthdayEffect(GetCharacter()->m_Pos, GetCharacter()->TeamMask());
} }
GameServer()->SendRecord(m_ClientId); GameServer()->SendRecord(m_ClientId);
break; break;

View file

@ -854,7 +854,7 @@ void CGameTeams::OnFinish(CPlayer *Player, int TimeTicks, const char *pTimestamp
// Confetti // Confetti
CCharacter *pChar = Player->GetCharacter(); CCharacter *pChar = Player->GetCharacter();
m_pGameContext->CreateFinishConfetti(pChar->m_Pos, pChar->TeamMask()); m_pGameContext->CreateFinishEffect(pChar->m_Pos, pChar->TeamMask());
} }
void CGameTeams::RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team) void CGameTeams::RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team)