From b4385a48972ffe261d20dbc0d44fee9124e562a9 Mon Sep 17 00:00:00 2001 From: sireus Date: Sun, 23 Sep 2012 16:58:55 +0000 Subject: [PATCH] armor no longer affects knife damage git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6887 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 2 +- source/src/entity.h | 37 ++++++++++++++++++++----------------- source/src/server.cpp | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 8f227c8d..10f1e594 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -896,7 +896,7 @@ void dodamage(int damage, playerent *pl, playerent *actor, int gun, bool gib, bo audiomgr.playsound(S_PAIN1+rnd(5), pl); } - if(local) damage = pl->dodamage(damage); + if(local) damage = pl->dodamage(damage, gun); else if(actor==player1) return; if(pl==player1) diff --git a/source/src/entity.h b/source/src/entity.h index fce77b94..6b6cdbfc 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -344,7 +344,7 @@ public: } // just subtract damage here, can set death, etc. later in code calling this - int dodamage(int damage) + int dodamage(int damage, int gun) { if(damage == INT_MAX) { @@ -353,24 +353,27 @@ public: return damage; } - // 4-level armour - tiered approach: 16%, 33%, 37%, 41% - // Please update ./ac_website/htdocs/docs/introduction.html if this changes. - int armoursection = 0; - int ad = damage; - if(armour > 25) armoursection = 1; - if(armour > 50) armoursection = 2; - if(armour > 75) armoursection = 3; - switch(armoursection) + if(gun != GUN_KNIFE) { - case 0: ad = (int) (16.0f/25.0f * armour); break; // 16 - case 1: ad = (int) (17.0f/25.0f * armour) - 1; break; // 33 - case 2: ad = (int) (4.0f/25.0f * armour) + 25; break; // 37 - case 3: ad = (int) (4.0f/25.0f * armour) + 25; break; // 41 - default: break; + // 4-level armour - tiered approach: 16%, 33%, 37%, 41% + // Please update ./ac_website/htdocs/docs/introduction.html if this changes. + int armoursection = 0; + int ad = damage; + if(armour > 25) armoursection = 1; + if(armour > 50) armoursection = 2; + if(armour > 75) armoursection = 3; + switch(armoursection) + { + case 0: ad = (int) (16.0f/25.0f * armour); break; // 16 + case 1: ad = (int) (17.0f/25.0f * armour) - 1; break; // 33 + case 2: ad = (int) (4.0f/25.0f * armour) + 25; break; // 37 + case 3: ad = (int) (4.0f/25.0f * armour) + 25; break; // 41 + default: break; + } + int rd = (int) (ad * damage/100.0f); + armour -= rd; + damage -= rd; } - int rd = (int) (ad * damage/100.0f); - armour -= rd; - damage -= rd; health -= damage; return damage; } diff --git a/source/src/server.cpp b/source/src/server.cpp index 1ac8a8b3..c2d0a2e0 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -1442,7 +1442,7 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib, if (!m_demo && !m_coop && !validdamage(target, actor, damage, gun, gib)) return; if ( m_arena && gun == GUN_GRENADE && arenaroundstartmillis + 2000 > gamemillis && target != actor ) return; clientstate &ts = target->state; - ts.dodamage(damage); + ts.dodamage(damage, gun); if(damage < INT_MAX) { actor->state.damage += damage;