From 79fda7979ab1395fe15cf62cf1e0b45b8803e74c Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Sat, 24 Nov 2018 23:59:17 +0100 Subject: [PATCH 1/4] Added Damage net event, informs of angle from which damage is taken and its amount; preparing future work --- datasrc/network.py | 8 ++++++ src/game/server/entities/character.cpp | 32 +++++++++++---------- src/game/server/entities/character.h | 2 +- src/game/server/entities/laser.cpp | 2 +- src/game/server/entities/projectile.cpp | 2 +- src/game/server/gamecontext.cpp | 38 ++++++++++++++++++++++--- src/game/server/gamecontext.h | 3 +- 7 files changed, 64 insertions(+), 23 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index 6b6849703..4b97924b1 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -233,6 +233,14 @@ Objects = [ NetEvent("DamageInd:Common", [ NetIntAny("m_Angle"), + NetBool("m_Armored"), + ]), + + NetEvent("Damage:Common", [ # Unused yet + NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), + NetIntAny("m_Angle"), + NetIntRange("m_Amount", 1, 9), + NetBool("m_Armored"), ]), ] diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 47c9cca5c..3cfc1c71a 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -187,7 +187,7 @@ void CCharacter::HandleNinja() if(m_NumObjectsHit < 10) m_apHitObjects[m_NumObjectsHit++] = aEnts[i]; - aEnts[i]->TakeDamage(vec2(0, -10.0f), g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA); + aEnts[i]->TakeDamage(vec2(0, -10.0f), m_Ninja.m_ActivationDir*-1, g_pData->m_Weapons.m_Ninja.m_pBase->m_Damage, m_pPlayer->GetCID(), WEAPON_NINJA); } } @@ -320,7 +320,7 @@ void CCharacter::FireWeapon() else Dir = vec2(0.f, -1.f); - pTarget->TakeDamage(vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, + pTarget->TakeDamage(vec2(0.f, -1.f) + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f, Dir*-1, g_pData->m_Weapons.m_Hammer.m_pBase->m_Damage, m_pPlayer->GetCID(), m_ActiveWeapon); Hits++; } @@ -679,7 +679,7 @@ void CCharacter::Die(int Killer, int Weapon) GameServer()->CreateDeath(m_Pos, m_pPlayer->GetCID()); } -bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) +bool CCharacter::TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weapon) { m_Core.m_Vel += Force; @@ -692,18 +692,7 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) m_DamageTaken++; - // create healthmod indicator - if(Server()->Tick() < m_DamageTakenTick+25) - { - // make sure that the damage indicators doesn't group together - GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg); - } - else - { - m_DamageTaken = 0; - GameServer()->CreateDamageInd(m_Pos, 0, Dmg); - } - + int OldHealth = m_Health, OldArmor = m_Armor; if(Dmg) { if(m_Armor) @@ -729,6 +718,19 @@ bool CCharacter::TakeDamage(vec2 Force, int Dmg, int From, int Weapon) m_Health -= Dmg; } + // create healthmod indicator + if(Server()->Tick() < m_DamageTakenTick+25) + { + // make sure that the damage indicators doesn't group together + GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, OldHealth-m_Health, OldArmor-m_Armor); + } + else + { + m_DamageTaken = 0; + GameServer()->CreateDamageInd(m_Pos, 0, OldHealth-m_Health, OldArmor-m_Armor); + } + GameServer()->CreateDamage(m_Pos, m_pPlayer->GetCID(), Source, OldHealth-m_Health, OldArmor-m_Armor); + m_DamageTakenTick = Server()->Tick(); // do damage Hit sound diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 12b990ee3..a4d7bfde7 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -42,7 +42,7 @@ public: void FireWeapon(); void Die(int Killer, int Weapon); - bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon); + bool TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weapon); bool Spawn(class CPlayer *pPlayer, vec2 Pos); bool Remove(); diff --git a/src/game/server/entities/laser.cpp b/src/game/server/entities/laser.cpp index 7edbe627b..198f95979 100644 --- a/src/game/server/entities/laser.cpp +++ b/src/game/server/entities/laser.cpp @@ -30,7 +30,7 @@ bool CLaser::HitCharacter(vec2 From, vec2 To) m_From = From; m_Pos = At; m_Energy = -1; - pHit->TakeDamage(vec2(0.f, 0.f), g_pData->m_Weapons.m_aId[WEAPON_LASER].m_Damage, m_Owner, WEAPON_LASER); + pHit->TakeDamage(vec2(0.f, 0.f), normalize(To-From), g_pData->m_Weapons.m_aId[WEAPON_LASER].m_Damage, m_Owner, WEAPON_LASER); return true; } diff --git a/src/game/server/entities/projectile.cpp b/src/game/server/entities/projectile.cpp index da990034d..ea09fd7e5 100644 --- a/src/game/server/entities/projectile.cpp +++ b/src/game/server/entities/projectile.cpp @@ -76,7 +76,7 @@ void CProjectile::Tick() GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, m_Damage); else if(TargetChr) - TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Damage, m_Owner, m_Weapon); + TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Direction*-1, m_Damage, m_Owner, m_Weapon); GameServer()->m_World.DestroyEntity(this); } diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index bd6336163..18cc392a4 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -93,21 +93,51 @@ class CCharacter *CGameContext::GetPlayerChar(int ClientID) return m_apPlayers[ClientID]->GetCharacter(); } -void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount) +void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int HealthAmount, int ArmorAmount) { + int TotalAmount = HealthAmount+ArmorAmount; float a = 3*pi/2 + Angle; //float a = get_angle(dir); float s = a-pi/3; float e = a+pi/3; - for(int i = 0; i < Amount; i++) + for(int i = 0; i < TotalAmount; i++) { - float f = mix(s, e, float(i+1)/float(Amount+2)); + float f = mix(s, e, float(i+1)/float(TotalAmount+2)); CNetEvent_DamageInd *pEvent = (CNetEvent_DamageInd *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(CNetEvent_DamageInd)); if(pEvent) { pEvent->m_X = (int)Pos.x; pEvent->m_Y = (int)Pos.y; pEvent->m_Angle = (int)(f*256.0f); + if(ArmorAmount) + { + pEvent->m_Armored = true; + ArmorAmount--; + } + else + pEvent->m_Armored = false; + + } + } +} + +void CGameContext::CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount) +{ + for(int ArmorType = 0; ArmorType < 2; ArmorType++) + { + if((ArmorType && ArmorAmount) || (!ArmorType && HealthAmount)) + { + float f = angle(Source); + CNetEvent_Damage *pEvent = (CNetEvent_Damage *)m_Events.Create(NETEVENTTYPE_DAMAGE, sizeof(CNetEvent_Damage)); + if(pEvent) + { + pEvent->m_X = (int)Pos.x; + pEvent->m_Y = (int)Pos.y; + pEvent->m_ClientID = Id; + pEvent->m_Angle = (int)(f*256.0f); + pEvent->m_Amount = ArmorType ? ArmorAmount : HealthAmount; + pEvent->m_Armored = ArmorType; + } } } } @@ -149,7 +179,7 @@ void CGameContext::CreateExplosion(vec2 Pos, int Owner, int Weapon, int MaxDamag Force = normalize(Diff) * MaxForce; float Factor = 1 - clamp((l-InnerRadius)/(Radius-InnerRadius), 0.0f, 1.0f); if((int)(Factor * MaxDamage)) - apEnts[i]->TakeDamage(Force * Factor, (int)(Factor * MaxDamage), Owner, Weapon); + apEnts[i]->TakeDamage(Force * Factor, Diff*-1, (int)(Factor * MaxDamage), Owner, Weapon); } } diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index cc0682411..e3009bcad 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -123,7 +123,8 @@ public: CVoteOptionServer *m_pVoteOptionLast; // helper functions - void CreateDamageInd(vec2 Pos, float AngleMod, int Amount); + void CreateDamageInd(vec2 Pos, float AngleMod, int HealthAmount, int ArmorAmount); + void CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount); void CreateExplosion(vec2 Pos, int Owner, int Weapon, int MaxDamage); void CreateHammerHit(vec2 Pos); void CreatePlayerSpawn(vec2 Pos); From ce38aec2eceadf112c8c5dd7adb7c57f5605f41c Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Sun, 25 Nov 2018 20:59:41 +0100 Subject: [PATCH 2/4] Remove DamageInd armor flag, add a type field in Damage to distinguish self damage --- datasrc/network.py | 5 +++-- src/game/server/entities/character.cpp | 6 +++--- src/game/server/gamecontext.cpp | 22 ++++++++-------------- src/game/server/gamecontext.h | 4 ++-- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index 4b97924b1..c0747be87 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -5,6 +5,7 @@ Emotes = Enum("EMOTE", ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"] Emoticons = Enum("EMOTICON", ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]) Votes = Enum("VOTE", ["UNKNOWN", "START_OP", "START_KICK", "START_SPEC", "END_ABORT", "END_PASS", "END_FAIL"]) ChatModes = Enum("CHAT", ["NONE", "ALL", "TEAM", "WHISPER"]) +DamageType = Enum("DAMAGE", ["NORMAL", "ARMOR", "SELF", "SELF_ARMOR"]) PlayerFlags = Flags("PLAYERFLAG", ["ADMIN", "CHATTING", "SCOREBOARD", "READY", "DEAD", "WATCHING"]) GameFlags = Flags("GAMEFLAG", ["TEAMS", "FLAGS", "SURVIVAL"]) @@ -57,6 +58,7 @@ Enums = [ Emoticons, Votes, ChatModes, + DamageType, GameMsgIDs, ] @@ -233,14 +235,13 @@ Objects = [ NetEvent("DamageInd:Common", [ NetIntAny("m_Angle"), - NetBool("m_Armored"), ]), NetEvent("Damage:Common", [ # Unused yet NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntAny("m_Angle"), NetIntRange("m_Amount", 1, 9), - NetBool("m_Armored"), + NetEnum("m_Type", DamageType), ]), ] diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 3cfc1c71a..2755c10d9 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -722,14 +722,14 @@ bool CCharacter::TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weap if(Server()->Tick() < m_DamageTakenTick+25) { // make sure that the damage indicators doesn't group together - GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, OldHealth-m_Health, OldArmor-m_Armor); + GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg); } else { m_DamageTaken = 0; - GameServer()->CreateDamageInd(m_Pos, 0, OldHealth-m_Health, OldArmor-m_Armor); + GameServer()->CreateDamageInd(m_Pos, 0, Dmg); } - GameServer()->CreateDamage(m_Pos, m_pPlayer->GetCID(), Source, OldHealth-m_Health, OldArmor-m_Armor); + GameServer()->CreateDamage(m_Pos, m_pPlayer->GetCID(), Source, OldHealth-m_Health, OldArmor-m_Armor, From == m_pPlayer->GetCID()); m_DamageTakenTick = Server()->Tick(); diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 18cc392a4..a592aa41c 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -93,35 +93,26 @@ class CCharacter *CGameContext::GetPlayerChar(int ClientID) return m_apPlayers[ClientID]->GetCharacter(); } -void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int HealthAmount, int ArmorAmount) +void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount) { - int TotalAmount = HealthAmount+ArmorAmount; float a = 3*pi/2 + Angle; //float a = get_angle(dir); float s = a-pi/3; float e = a+pi/3; - for(int i = 0; i < TotalAmount; i++) + for(int i = 0; i < Amount; i++) { - float f = mix(s, e, float(i+1)/float(TotalAmount+2)); + float f = mix(s, e, float(i+1)/float(Amount+2)); CNetEvent_DamageInd *pEvent = (CNetEvent_DamageInd *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(CNetEvent_DamageInd)); if(pEvent) { pEvent->m_X = (int)Pos.x; pEvent->m_Y = (int)Pos.y; pEvent->m_Angle = (int)(f*256.0f); - if(ArmorAmount) - { - pEvent->m_Armored = true; - ArmorAmount--; - } - else - pEvent->m_Armored = false; - } } } -void CGameContext::CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount) +void CGameContext::CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount, bool Self) { for(int ArmorType = 0; ArmorType < 2; ArmorType++) { @@ -136,7 +127,10 @@ void CGameContext::CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, pEvent->m_ClientID = Id; pEvent->m_Angle = (int)(f*256.0f); pEvent->m_Amount = ArmorType ? ArmorAmount : HealthAmount; - pEvent->m_Armored = ArmorType; + if(!Self) + pEvent->m_Type = ArmorType ? DAMAGE_ARMOR : DAMAGE_NORMAL; + else + pEvent->m_Type = ArmorType ? DAMAGE_SELF_ARMOR : DAMAGE_SELF; } } } diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index e3009bcad..9ce947442 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -123,8 +123,8 @@ public: CVoteOptionServer *m_pVoteOptionLast; // helper functions - void CreateDamageInd(vec2 Pos, float AngleMod, int HealthAmount, int ArmorAmount); - void CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount); + void CreateDamageInd(vec2 Pos, float AngleMod, int Amount); + void CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount, bool Self); void CreateExplosion(vec2 Pos, int Owner, int Weapon, int MaxDamage); void CreateHammerHit(vec2 Pos); void CreatePlayerSpawn(vec2 Pos); From 029b0accbd7eebc0e3f8d205f62ff6ccf9da77b6 Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Tue, 27 Nov 2018 18:57:17 +0100 Subject: [PATCH 3/4] Removed DamageInd net event. Moved the server code to the client, using the new Damage net event. --- datasrc/network.py | 11 ++---- src/game/client/components/effects.cpp | 29 ++++++++++++++-- src/game/client/components/effects.h | 5 ++- src/game/client/gameclient.cpp | 6 ++-- src/game/server/entities/character.cpp | 15 -------- src/game/server/entities/character.h | 4 --- src/game/server/gamecontext.cpp | 47 ++++++-------------------- src/game/server/gamecontext.h | 1 - 8 files changed, 47 insertions(+), 71 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index c0747be87..c56b2b9ff 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -5,7 +5,6 @@ Emotes = Enum("EMOTE", ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"] Emoticons = Enum("EMOTICON", ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]) Votes = Enum("VOTE", ["UNKNOWN", "START_OP", "START_KICK", "START_SPEC", "END_ABORT", "END_PASS", "END_FAIL"]) ChatModes = Enum("CHAT", ["NONE", "ALL", "TEAM", "WHISPER"]) -DamageType = Enum("DAMAGE", ["NORMAL", "ARMOR", "SELF", "SELF_ARMOR"]) PlayerFlags = Flags("PLAYERFLAG", ["ADMIN", "CHATTING", "SCOREBOARD", "READY", "DEAD", "WATCHING"]) GameFlags = Flags("GAMEFLAG", ["TEAMS", "FLAGS", "SURVIVAL"]) @@ -58,7 +57,6 @@ Enums = [ Emoticons, Votes, ChatModes, - DamageType, GameMsgIDs, ] @@ -233,15 +231,12 @@ Objects = [ NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'), ]), - NetEvent("DamageInd:Common", [ - NetIntAny("m_Angle"), - ]), - NetEvent("Damage:Common", [ # Unused yet NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'), NetIntAny("m_Angle"), - NetIntRange("m_Amount", 1, 9), - NetEnum("m_Type", DamageType), + NetIntRange("m_HealthAmount", 1, 9), + NetIntRange("m_ArmorAmount", 1, 9), + NetBool("m_Self"), ]), ] diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp index bac5e698e..d98a1b93b 100644 --- a/src/game/client/components/effects.cpp +++ b/src/game/client/components/effects.cpp @@ -22,6 +22,8 @@ CEffects::CEffects() { m_Add50hz = false; m_Add100hz = false; + m_DamageTaken = 0; + m_DamageTakenTick = 0; } void CEffects::AirJump(vec2 Pos) @@ -47,9 +49,32 @@ void CEffects::AirJump(vec2 Pos) m_pClient->m_pSounds->PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, Pos); } -void CEffects::DamageIndicator(vec2 Pos, vec2 Dir) +void CEffects::DamageIndicator(vec2 Pos, int Amount) { - m_pClient->m_pDamageind->Create(Pos, Dir); + m_DamageTaken++; + int Angle; + // create healthmod indicator + if(Client()->LocalTime() < m_DamageTakenTick+0.5f) + { + // make sure that the damage indicators don't group together + Angle = m_DamageTaken*0.25f; + } + else + { + m_DamageTaken = 0; + Angle = 0; + } + + float a = 3*pi/2 + Angle; + float s = a-pi/3; + float e = a+pi/3; + for(int i = 0; i < Amount; i++) + { + float f = mix(s, e, float(i+1)/float(Amount+2)); + m_pClient->m_pDamageind->Create(vec2(Pos.x, Pos.y), direction(f)); + } + + m_DamageTakenTick = Client()->LocalTime(); } void CEffects::PowerupShine(vec2 Pos, vec2 size) diff --git a/src/game/client/components/effects.h b/src/game/client/components/effects.h index 9ededb832..d46da9a88 100644 --- a/src/game/client/components/effects.h +++ b/src/game/client/components/effects.h @@ -8,6 +8,9 @@ class CEffects : public CComponent { bool m_Add50hz; bool m_Add100hz; + + int m_DamageTaken; + float m_DamageTakenTick; public: CEffects(); @@ -19,7 +22,7 @@ public: void Explosion(vec2 Pos); void HammerHit(vec2 Pos); void AirJump(vec2 Pos); - void DamageIndicator(vec2 Pos, vec2 Dir); + void DamageIndicator(vec2 Pos, int Amount); void PlayerSpawn(vec2 Pos); void PlayerDeath(vec2 Pos, int ClientID); void PowerupShine(vec2 Pos, vec2 Size); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 366de9531..389d96984 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -819,10 +819,10 @@ void CGameClient::ProcessEvents() IClient::CSnapItem Item; const void *pData = Client()->SnapGetItem(SnapType, Index, &Item); - if(Item.m_Type == NETEVENTTYPE_DAMAGEIND) + if(Item.m_Type == NETEVENTTYPE_DAMAGE) { - CNetEvent_DamageInd *ev = (CNetEvent_DamageInd *)pData; - m_pEffects->DamageIndicator(vec2(ev->m_X, ev->m_Y), direction(ev->m_Angle/256.0f)); + CNetEvent_Damage *ev = (CNetEvent_Damage *)pData; + m_pEffects->DamageIndicator(vec2(ev->m_X, ev->m_Y), ev->m_HealthAmount + ev->m_ArmorAmount); } else if(Item.m_Type == NETEVENTTYPE_EXPLOSION) { diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 2755c10d9..7ce71dcca 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -620,7 +620,6 @@ void CCharacter::TickDefered() void CCharacter::TickPaused() { ++m_AttackTick; - ++m_DamageTakenTick; ++m_Ninja.m_ActivationTick; ++m_ReckoningTick; if(m_LastAction != -1) @@ -690,8 +689,6 @@ bool CCharacter::TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weap if(From == m_pPlayer->GetCID()) Dmg = max(1, Dmg/2); - m_DamageTaken++; - int OldHealth = m_Health, OldArmor = m_Armor; if(Dmg) { @@ -719,20 +716,8 @@ bool CCharacter::TakeDamage(vec2 Force, vec2 Source, int Dmg, int From, int Weap } // create healthmod indicator - if(Server()->Tick() < m_DamageTakenTick+25) - { - // make sure that the damage indicators doesn't group together - GameServer()->CreateDamageInd(m_Pos, m_DamageTaken*0.25f, Dmg); - } - else - { - m_DamageTaken = 0; - GameServer()->CreateDamageInd(m_Pos, 0, Dmg); - } GameServer()->CreateDamage(m_Pos, m_pPlayer->GetCID(), Source, OldHealth-m_Health, OldArmor-m_Armor, From == m_pPlayer->GetCID()); - m_DamageTakenTick = Server()->Tick(); - // do damage Hit sound if(From >= 0 && From != m_pPlayer->GetCID() && GameServer()->m_apPlayers[From]) { diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index a4d7bfde7..eb3e9e93c 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -83,8 +83,6 @@ private: int m_ReloadTimer; int m_AttackTick; - int m_DamageTaken; - int m_EmoteType; int m_EmoteStop; @@ -101,8 +99,6 @@ private: int m_NumInputs; int m_Jumped; - int m_DamageTakenTick; - int m_Health; int m_Armor; diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index a592aa41c..866ac2737 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -93,46 +93,19 @@ class CCharacter *CGameContext::GetPlayerChar(int ClientID) return m_apPlayers[ClientID]->GetCharacter(); } -void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount) -{ - float a = 3*pi/2 + Angle; - //float a = get_angle(dir); - float s = a-pi/3; - float e = a+pi/3; - for(int i = 0; i < Amount; i++) - { - float f = mix(s, e, float(i+1)/float(Amount+2)); - CNetEvent_DamageInd *pEvent = (CNetEvent_DamageInd *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(CNetEvent_DamageInd)); - if(pEvent) - { - pEvent->m_X = (int)Pos.x; - pEvent->m_Y = (int)Pos.y; - pEvent->m_Angle = (int)(f*256.0f); - } - } -} - void CGameContext::CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount, bool Self) { - for(int ArmorType = 0; ArmorType < 2; ArmorType++) + float f = angle(Source); + CNetEvent_Damage *pEvent = (CNetEvent_Damage *)m_Events.Create(NETEVENTTYPE_DAMAGE, sizeof(CNetEvent_Damage)); + if(pEvent) { - if((ArmorType && ArmorAmount) || (!ArmorType && HealthAmount)) - { - float f = angle(Source); - CNetEvent_Damage *pEvent = (CNetEvent_Damage *)m_Events.Create(NETEVENTTYPE_DAMAGE, sizeof(CNetEvent_Damage)); - if(pEvent) - { - pEvent->m_X = (int)Pos.x; - pEvent->m_Y = (int)Pos.y; - pEvent->m_ClientID = Id; - pEvent->m_Angle = (int)(f*256.0f); - pEvent->m_Amount = ArmorType ? ArmorAmount : HealthAmount; - if(!Self) - pEvent->m_Type = ArmorType ? DAMAGE_ARMOR : DAMAGE_NORMAL; - else - pEvent->m_Type = ArmorType ? DAMAGE_SELF_ARMOR : DAMAGE_SELF; - } - } + pEvent->m_X = (int)Pos.x; + pEvent->m_Y = (int)Pos.y; + pEvent->m_ClientID = Id; + pEvent->m_Angle = (int)(f*256.0f); + pEvent->m_HealthAmount = HealthAmount; + pEvent->m_ArmorAmount = HealthAmount; + pEvent->m_Self = Self; } } diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 9ce947442..68a93f28a 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -123,7 +123,6 @@ public: CVoteOptionServer *m_pVoteOptionLast; // helper functions - void CreateDamageInd(vec2 Pos, float AngleMod, int Amount); void CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, int ArmorAmount, bool Self); void CreateExplosion(vec2 Pos, int Owner, int Weapon, int MaxDamage); void CreateHammerHit(vec2 Pos); From ff1ba08a0c7d3a806c820e65d8947cfc1606a131 Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Tue, 27 Nov 2018 19:23:00 +0100 Subject: [PATCH 4/4] Fix typo --- src/game/server/gamecontext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 866ac2737..8641101b1 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -104,7 +104,7 @@ void CGameContext::CreateDamage(vec2 Pos, int Id, vec2 Source, int HealthAmount, pEvent->m_ClientID = Id; pEvent->m_Angle = (int)(f*256.0f); pEvent->m_HealthAmount = HealthAmount; - pEvent->m_ArmorAmount = HealthAmount; + pEvent->m_ArmorAmount = ArmorAmount; pEvent->m_Self = Self; } }