Combat GetValidDeathblow

From Dragon Age Toolset Wiki
Jump to: navigation, search

Called by:

Calls:

Parameters:

Variables:

Returns:

Used for:

/**
* @brief Determine a valid deathblow for the current target
*
* Called when the script decides to do a deathblow, this function will return
* a DEATHBLOW_* constant representing the deathblow to use against the creature
*
* If the creature does not support deathblows (immunity, no animation) or can not
* be deathblowed (Immortal, Plot, Party Member, Flagged as invalid in the toolset)
* the function returns 0
*
* @param oTarget    The target for the Deathblow
*
* @returns  0 or DEATH_BLOW_*
*
* @author Georg Zoeller
*
**/
int Combat_GetValidDeathblow(object oAttacker, object oTarget);
int Combat_GetValidDeathblow(object oAttacker, object oTarget)
{
 
     // ------------------------------------------------------------------------
     // First, let's check if we can even perform deathblows with the attacker
     // ------------------------------------------------------------------------
     int bCanDeathblow =       CanPerformDeathblows(oAttacker);
 
     if (!bCanDeathblow)
     {
        return FALSE;
     }
 
     int nValid =              GetM2DAInt(TABLE_APPEARANCE,"ValidDeathblows", GetAppearanceType(oTarget));
 
     int bImmortal            = IsImmortal(oTarget);
     int bPlot                = IsPlot(oTarget);
     int bCanDiePermanently   = GetCanDiePermanently(oTarget);
     int bAlreadyDead         = HasDeathEffect(oTarget);
 
      #ifdef DEBUG
     Log_Trace(LOG_CHANNEL_COMBAT_DEATH,"GetValidDeathblow","nValid: " + ToString(nValid) + " bImmortal: " + ToString(bImmortal) + " bPlot:" +
                                ToString(bPlot) + " bCanDiePermanently:" + ToString(bCanDiePermanently));
 
     #endif
 
     // ------------------------------------------------------------------------
     // If we are immortal, Plot, or can not die permanently (e.g. a party member),
     // we return 0
     // ------------------------------------------------------------------------
     if (bImmortal || bPlot || !bCanDiePermanently || IsPartyMember(oTarget) || bAlreadyDead)
     {
       return 0;
     }
 
     return 1;
}