/* Guesses how damage a shot might do. * \param psObj object that might be hit * \param damage amount of damage to deal * \param weaponClass the class of the weapon that deals the damage * \param weaponSubClass the subclass of the weapon that deals the damage * \param angle angle of impact (from the damage dealing projectile in relation to this object) * \return guess at amount of damage */ unsigned int objGuessFutureDamage(WEAPON_STATS *psStats, unsigned int player, BASE_OBJECT *psTarget, HIT_SIDE i) { unsigned int damage; int impactSide; int actualDamage, armour = 0, level = 1; if (psTarget == NULL) return 0; // Hard to destroy the ground. The armour on the mud is very strong and blocks all damage. damage = calcDamage(weaponDamage(psStats, player), psStats->weaponEffect, psTarget); // EMP cannons do no damage, if we are one return now if (psStats->weaponSubClass == WSC_EMP) { return 0; } // apply game difficulty setting damage = modifyForDifficultyLevel(damage, psTarget->player != selectedPlayer); for (impactSide = 0; impactSide != NUM_HIT_SIDES; ++impactSide) armour = MAX(armour, psTarget->armour[impactSide][psStats->weaponClass]); //debug(LOG_ATTACK, "objGuessFutureDamage(%d): body %d armour %d damage: %d", psObj->id, psObj->body, armour, damage); if (psTarget->type == OBJ_DROID) { DROID *psDroid = (DROID *)psTarget; // Retrieve highest, applicable, experience level level = getDroidEffectiveLevel(psDroid); } // Reduce damage taken by EXP_REDUCE_DAMAGE % for each experience level actualDamage = (damage * (100 - EXP_REDUCE_DAMAGE * level)) / 100; // You always do at least a third of the experience modified damage actualDamage = MAX(actualDamage - armour, actualDamage / 3); // And at least MIN_WEAPON_DAMAGE points actualDamage = MAX(actualDamage, MIN_WEAPON_DAMAGE); //objTrace(psObj->id, "objGuessFutureDamage: Would penetrate %d", actualDamage); return actualDamage; }
void YYEnemy::update(void){ processAI(); calcDamage(); updateAnimation(); }