From ce38aec2eceadf112c8c5dd7adb7c57f5605f41c Mon Sep 17 00:00:00 2001 From: Jordy Ruiz Date: Sun, 25 Nov 2018 20:59:41 +0100 Subject: [PATCH] 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);