From 624825854c34e81820199fe79708e2d6e3bc566f Mon Sep 17 00:00:00 2001 From: Freddie Witherden Date: Tue, 25 Dec 2007 22:06:51 +0000 Subject: [PATCH] Add getDroidEffectiveLevel that returns MAX(droidLevel, droidsCmdrLevel). git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3177 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/droid.c | 13 ++++++++----- src/droid.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/droid.c b/src/droid.c index c66a63831..49ed3fe00 100644 --- a/src/droid.c +++ b/src/droid.c @@ -216,11 +216,7 @@ float droidDamage(DROID *psDroid, UDWORD damage, UDWORD weaponClass, UDWORD weap actualDamage = damage - armour; // Retrieve highest, applicable, experience level - level = getDroidLevel(psDroid); - { - unsigned int cmdLevel = cmdGetCommanderLevel(psDroid); - level = MAX(level, cmdLevel); - } + level = getDroidEffectiveLevel(psDroid); // Reduce damage taken by EXP_REDUCE_DAMAGE % for each experience level actualDamage = (actualDamage * (100 - EXP_REDUCE_DAMAGE * level)) / 100; @@ -4149,6 +4145,13 @@ UDWORD getDroidLevel(DROID *psDroid) return lastRank - 1; } +UDWORD getDroidEffectiveLevel(DROID *psDroid) +{ + UDWORD level = getDroidLevel(psDroid); + UDWORD cmdLevel = cmdGetCommanderLevel(psDroid); + + return MAX(level, cmdLevel); +} const char *getDroidNameForRank(UDWORD rank) diff --git a/src/droid.h b/src/droid.h index 01fdbc132..00dabe40b 100644 --- a/src/droid.h +++ b/src/droid.h @@ -248,6 +248,7 @@ extern BOOL selectDroidByID(UDWORD id, UDWORD player); /* Droid experience stuff */ extern UDWORD getDroidLevel(DROID *psDroid); +extern UDWORD getDroidEffectiveLevel(DROID *psDroid); extern const char *getDroidLevelName(DROID *psDroid); // Get a droid's name.