revengeDamageAbility1258BonusAbility5173Ability5167Ability1458 // Mevius.Battle.BattleDamage

// Token: 0x06000672 RID: 1650 RVA: 0x00032670 File Offset: 0x00030870

public static void CalcDamage ( ref BattleDamage. DamageInfo damageInfo, BattleActor owner, BattleActor target, damageSourceElem, bool isRandMinTest, bool isNoCriticalCalc, bool isCritical, int powerPercent )

{

if ( damageSourceElem == null )

{

return ;

}

if ( Mobius. App . IsPartyMode ( ) && ( int ) damageSourceElem. getCondition ( ) == 0 && damageSourceElem. getPower ( ) == 0 )

{

Ceaf68fb2356fb8b84facc86d2fe79f0e. Cca912973d2eb55c3b74a5c95a6475670 cca912973d2eb55c3b74a5c95a = Ceaf68fb2356fb8b84facc86d2fe79f0e. Find ( owner. AbilityId ) ;

if ( cca912973d2eb55c3b74a5c95a ! = null && ( ( int ) cca912973d2eb55c3b74a5c95a. m84e50dafe5698576f43e0b3aeaf1b9f3 ( ) == 3 || ( int ) cca912973d2eb55c3b74a5c95a. m5aa5f8aa3146e23239a6f9658f17b054 ( ) == 3 ) )

{

return ;

}

}

damageInfo = new BattleDamage. DamageInfo ( ) ;

bool isAbilityMatchJob = owner. AbilityId == owner. JobAbilityId ; //if job matches?

int critChance = 0 ;

int breakDamage = 0 ;

float synchroBonusValue = 1f ;

bool isHealing = false ; //unsure.

bool uncapDamage = false ; //unsure

int Power = damageSourceElem. getPower ( ) ;

if ( ( int ) damageSourceElem. powerType ( ) ! = 23 )

{

if ( ( int ) damageSourceElem. getCondition ( ) == 1 && Power > 0 )

{

int useCardAbilitySkillNum = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5401 ) ;

if ( useCardAbilitySkillNum > 0 )

{

Power + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill14" , 50 ) * useCardAbilitySkillNum ;

}

}

Power = ( int ) ( ( float ) ( Power * powerPercent ) * 0.01f + 0.5f ) ;

}

int Damage ;

if ( owner. IsPlayer ( ) && ( int ) damageSourceElem. getCondition ( ) == 50 )

{

Damage = BattleUtility. GetPadAttackDamage ( owner ) ;

isHealing = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 3 )

{

Damage = Power ;

breakDamage = ( int ) damageSourceElem. baseBreakDamage ( ) ;

isHealing = true ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 7 ) //this looks like you heal enemy based on their target HP too.

{

Damage = ( int ) ( ( float ) target. Hp * ( ( float ) powerPercent / 100f ) + 0.5f ) ;

isHealing = true ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 28 ) //Might be when you heal enemy in perfect defense.

{

Damage = ( int ) ( ( float ) target. Hp * ( ( float ) powerPercent / 100f ) + 0.5f ) ;

isHealing = true ;

uncapDamage = true ;

damageInfo. ignorePerfectDefence = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 23 )

{

if ( ( int ) damageSourceElem. getCondition ( ) == 1 ) //getCondition() seems to be a heal.

{

Damage = Power - target. Hp ;

}

else

{

Damage = target. Hp - Power ;

}

if ( Damage < 0 )

{

Damage = 0 ;

}

isHealing = true ;

uncapDamage = true ;

}

else if ( owner. IsPlayer ( ) && ( int ) damageSourceElem. powerType ( ) == 1 )

{

int playerMPDamageBonus = 0 ;

if ( Mobius. App . IsPartyMode ( ) )

{

int [ ] partyParameterType = Mobius. Party . GetPartyParameterType ( ) ;

playerMPDamageBonus = partyParameterType [ owner. PartySlot ] ;

}

else if ( owner. IsPlayerSub ( ) )

{

playerMPDamageBonus = 1000 ;

}

int JobMatchAbilityBonus = owner. GetStatusEffectJobStatusUpValue ( ) ;

if ( owner. AbilityJobMatch )

{

JobMatchAbilityBonus + = owner. GetUseCardAbilitySkillJobPlayerTypeMatchValue ( ) ;

}

int AutoAbility1459Bonus ;

if ( owner. ManToMan && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1459 , out AutoAbility1459Bonus ) )

{

JobMatchAbilityBonus + = AutoAbility1459Bonus ;

}

int autoAbilityComboEnhancer ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1458 , out autoAbilityComboEnhancer ) && 0 < owner. NormalAttackCombo - 1 )

{

int AttackCombo = ( int ) ( owner. NormalAttackCombo - 1 ) * autoAbilityComboEnhancer ;

int Ability1458 = Mobius. DataSheet . GetResidentInteger ( "autoAbility1458_0" , 30 ) ;

if ( AttackCombo > Ability1458 )

{

AttackCombo = Ability1458 ;

}

JobMatchAbilityBonus + = AttackCombo ;

}

float JobMatchPercentage = 1f ;

if ( JobMatchAbilityBonus ! = 0 )

{

JobMatchPercentage + = ( float ) JobMatchAbilityBonus / 100f ;

}

bool doFF7Stuff = false ;

if ( ! isAbilityMatchJob && owner. NormalAttackNum == 0 && ! owner. AbilityJobMatch )

{

doFF7Stuff = true ;

}

int FF7PowerUp ;

if ( doFF7Stuff )

{

FF7PowerUp = 100 ;

FF7PowerUp + = BattleUtility. GetFF7IndependenceAbilityValue ( IndependenceAbility. PowerUp ) ;

}

else

{

FF7PowerUp = Mobius. Db . GetParameter ( DbManager. ParameterType . Power + playerMPDamageBonus ) ;

}

int playerFF7Bonuses ;

if ( BattleUtility. GetOptimaAbilityValue ( 2 , out playerFF7Bonuses ) )

{

FF7PowerUp + = playerFF7Bonuses ;

}

if ( owner. IsUseCardAbilitySkill ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5506 ) )

{

FF7PowerUp = ( int ) ( ( float ) ( FF7PowerUp * Mobius. DataSheet . GetResidentInteger ( "abilitySkill5506_0" , 50 ) ) * 0.01f + 0.5f ) ;

}

Damage = ( int ) ( ( float ) FF7PowerUp * JobMatchPercentage * ( ( float ) Power / 100f ) + 0.5f ) ;

critChance = Mobius. Db . GetParameter ( DbManager. ParameterType . CriticalValue + playerMPDamageBonus ) + ( int ) damageSourceElem. m31a2bc12a6fb70b72bfab3e85b658b3e ( ) ;

int FF7PierceUp ;

if ( doFF7Stuff )

{

FF7PierceUp = 100 ;

FF7PierceUp + = BattleUtility. GetFF7IndependenceAbilityValue ( IndependenceAbility. PierceUp ) ;

}

else

{

FF7PierceUp = Mobius. Db . GetParameter ( DbManager. ParameterType . Pierce + playerMPDamageBonus ) ;

}

if ( BattleUtility. GetOptimaAbilityValue ( 3 , out playerFF7Bonuses ) )

{

FF7PierceUp + = playerFF7Bonuses ;

}

if ( owner. IsUseCardAbilitySkill ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5506 ) )

{

FF7PierceUp = ( int ) ( ( float ) ( FF7PierceUp * Mobius. DataSheet . GetResidentInteger ( "abilitySkill5506_0" , 50 ) ) * 0.01f + 0.5f ) ;

}

breakDamage = ( int ) ( ( float ) FF7PierceUp * JobMatchPercentage * ( ( float ) damageSourceElem. baseBreakDamage ( ) / 100f ) + 0.5f ) ;

if ( Mobius. App . IsPartyMode ( ) && owner. IsPlayer ( ) && ! doFF7Stuff )

{

ElementAttributeType useCardAbilityAttribute = owner. GetUseCardAbilityAttribute ( ) ;

if ( useCardAbilityAttribute ! = ElementAttributeType. None )

{

int chainCommand = ( int ) Mobius. Party . GetChainCommand ( 2 , ( int ) useCardAbilityAttribute ) ;

float [ ] chainBonus = Mobius. Party . GetChainBonus ( ) ;

Damage = ( int ) ( ( float ) Damage * chainBonus [ chainCommand - 1 ] + 0.5f ) ;

breakDamage = ( int ) ( ( float ) breakDamage * chainBonus [ chainCommand - 1 ] + 0.5f ) ;

}

}

}

else if ( ( int ) damageSourceElem. powerType ( ) == 8 ) //idk what this garbage is. Looks like these are all healing stuff.

{

Damage = ( int ) ( ( float ) target. HpMax / 100f * ( float ) Power + 0.5f ) ;

breakDamage = ( int ) damageSourceElem. baseBreakDamage ( ) ;

isHealing = true ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 9 )

{

Damage = ( int ) ( ( float ) target. Hp / 100f * ( float ) Power + 0.5f ) ;

breakDamage = ( int ) damageSourceElem. baseBreakDamage ( ) ;

isHealing = true ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 25 )

{

Damage = ( int ) ( ( float ) owner. HpMax / 100f * ( float ) Power + 0.5f ) ;

breakDamage = ( int ) damageSourceElem. baseBreakDamage ( ) ;

isHealing = true ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 26 ) //based on current hp, UB?

{

Damage = ( int ) ( ( float ) owner. Hp / 100f * ( float ) Power + 0.5f ) ;

breakDamage = ( int ) damageSourceElem. baseBreakDamage ( ) ;

isHealing = true ;

uncapDamage = true ;

}

else

{

if ( ( int ) damageSourceElem. powerType ( ) == 2 )

{

Damage = ( int ) ( ( float ) target. HpMax / 100f * ( float ) Power + 0.5f ) ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 4 )

{

Damage = ( int ) ( ( float ) owner. HpMax / 100f * ( float ) Power + 0.5f ) ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 5 )

{

Damage = ( int ) ( ( float ) target. Hp / 100f * ( float ) Power + 0.5f ) ;

uncapDamage = true ;

}

else if ( ( int ) damageSourceElem. powerType ( ) == 6 )

{

Damage = ( int ) ( ( float ) owner. Hp / 100f * ( float ) Power + 0.5f ) ;

uncapDamage = true ;

}

else

{

if ( ( int ) damageSourceElem. getCondition ( ) == 25 )

{

Power * = target. GetManaElementNum ( ) ;

}

else if ( 26 <= ( int ) damageSourceElem. getCondition ( ) && ( int ) damageSourceElem. getCondition ( ) <= 31 )

{

Power * = target. GetManaElementNums ( ) [ ( int ) damageSourceElem. getCondition ( ) - 26 ] ;

}

if ( owner. IsPlayer ( ) )

{

Damage = Power ;

breakDamage = ( int ) damageSourceElem. baseBreakDamage ( ) ; //med3b109a0c7b9aaffc8f700ad530010f is the original value, not 100% if this is base break value.

if ( owner. AbilityJobMatch )

{

int partyBonus = 0 ;

if ( Mobius. App . IsPartyMode ( ) )

{

int [ ] partyParameterType2 = Mobius. Party . GetPartyParameterType ( ) ;

partyBonus = partyParameterType2 [ owner. PartySlot ] ;

}

else if ( owner. IsPlayerSub ( ) )

{

partyBonus = 1000 ;

}

critChance + = Mobius. Db . GetParameter ( DbManager. ParameterType . CriticalValue + partyBonus ) ;

int linkDamage = Mobius. Db . GetParameter ( DbManager. ParameterType . Link + partyAmpplifier ) ;

int playerLinkBonus ;

if ( BattleUtility. GetOptimaAbilityValue ( 4 , out playerLinkBonus ) )

{

linkDamage + = playerLinkBonus ;

}

synchroBonusValue = 1f + ( float ) linkDamage * 0.01f ;

int JobMatchAbilityBonus = owner. GetStatusEffectJobStatusUpValue ( ) ;

JobMatchAbilityBonus + = owner. GetUseCardAbilitySkillJobPlayerTypeMatchValue ( ) ;

int Ability1459Bonus ;

if ( owner. ManToMan && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1459 , out Ability1459Bonus ) )

{

JobMatchAbilityBonus + = Ability1459Bonus ;

}

if ( JobMatchAbilityBonus ! = 0 )

{

synchroBonusValue * = 1f + ( float ) JobMatchAbilityBonus / 100f ;

}

synchroBonusValue * = 1f + ( float ) owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . Synchro ) * 0.01f ;

if ( synchroBonusValue < 1f )

{

synchroBonusValue = 1f ;

}

}

int Ability1258Bonus = 0 ;

owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1258 , out Ability1258Bonus ) ;

int hasAbility5166 = 0 ;

if ( owner. IsUseCardAbilitySkill ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5166 ) )

{

hasAbility5166 = 100 ;

}

int 1258or5166Bonus = Math. Max ( Ability1258Bonus, hasAbility5166 ) ;

if ( 1258or5166Bonus ! = 0 )

{

float Ability5166_0Bonus = ( float ) Mobius. DataSheet . GetResidentInteger ( "abilitySkill5166_0" , 3 ) ;

float Ability5166_1Bonus = ( float ) Mobius. DataSheet . GetResidentInteger ( "abilitySkill5166_1" , 3 ) ;

float Ability5166_2Bonus = Mobius. DataSheet . GetResidentFloat ( "abilitySkill5166_2" , 1f ) ;

float revengeDamage = 0f ;

int Ability5166_3Bonus = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5166_3" , 3 ) ;

if ( Ability5166_3Bonus < 0 )

{

Ability5166_3Bonus = 0 ;

}

else if ( Ability5166_3Bonus > 3 )

{

Ability5166_3Bonus = 3 ;

}

for ( int i = 0 ; i < Ability5166_3Bonus ; i ++ )

{

revengeDamage + = ( float ) owner. RevengeDamages [ i ] ;

}

if ( revengeDamage > Ability5166_0Bonus )

{

revengeDamage = Ability5166_0Bonus ;

}

float num25 = ( Ability5166_1Bonus - Ability5166_0Bonus * Ability5166_2Bonus ) * 0.5f ; /* Some Crazy math going on here, can't even label the rest. */

float f = 3.14159274f * ( ( revengeDamage - Ability5166_0Bonus ) / Ability5166_0Bonus ) ;

float num26 = Mathf. Cos ( f ) + 1f ;

float num27 = Mathf. Sqrt ( revengeDamage / Ability5166_0Bonus ) ;

float num28 = revengeDamage * Ability5166_2Bonus ;

int num29 = ( int ) ( ( num25 * num26 * num27 + num28 ) * ( ( float ) 1258or5166Bonus * 0.01f ) + 0.5f ) ;

synchroBonusValue + = ( float ) num29 * 0.01f ;

}

if ( Mobius. App . IsPartyMode ( ) && owner. IsPlayer ( ) )

{

ElementAttributeType useCardAbilityAttribute2 = owner. GetUseCardAbilityAttribute ( ) ;

if ( useCardAbilityAttribute2 ! = ElementAttributeType. None )

{

int chainCommand2 = ( int ) Mobius. Party . GetChainCommand ( 2 , ( int ) useCardAbilityAttribute2 ) ;

float [ ] chainBonus2 = Mobius. Party . GetChainBonus ( ) ;

Damage = ( int ) ( ( float ) Damage * chainBonus2 [ chainCommand2 - 1 ] + 0.5f ) ;

breakDamage = ( int ) ( ( float ) breakDamage * chainBonus2 [ chainCommand2 - 1 ] + 0.5f ) ;

}

}

}

else

{

Damage = ( int ) ( ( float ) owner. Power * ( ( float ) Power / 100f ) + 0.5f ) ;

}

}

critChance + = ( int ) damageSourceElem. m31a2bc12a6fb70b72bfab3e85b658b3e ( ) ;

}

if ( target. IsStatusEffectEntry ( BattleStatusEffect. ProcType . BreakDisable ) )

{

breakDamage = 0 ;

}

bool isBreak = false ;

bool isResist = false ;

bool isWeakness = false ;

bool isAbsorb = false ;

bool isEnhance = false ;

bool isReduce = false ;

int originalDamage ;

if ( isHealing ) //if this is set to true, we absorb the damage. WTF IS FLAG2?!

{

originalDamage = Damage ; //set original damage to buffed damage

ElementAttributeBitType targetAbsorbs = ( ElementAttributeBitType ) target. targetAbsorbs ;

if ( ( targetAbsorbs & ElementAttributeBitType. Normal ) ! = ElementAttributeBitType. None ) //if target can absorb normal element.

{

isAbsorb = true ;

breakDamage = 0 ;

}

isCritical = false ;

}

else

{

float bravePercent = 1f ;

float breakDmgIncPercent = 1f ;

float critDmgIncPercent = 1f ;

float elementDmgIncPercent = 1f ;

float EleBoonDamage = 1f ;

float elementResistance = 1f ;

int enhancementBonuses = 0 ; //seems very important.

int targetDefPercent = 0 ;

int targetTakeDamage = 0 ;

int targetTakeDamageEnemy = 0 ;

int targetEleTolerance = 0 ;

int breakAbilityBonuses = 0 ;

int critAbilityBonuses = 0 ;

int targetSufferWeakness = 0 ;

int Ability1506Bonus_G = 0 ;

float breakDamageLower = 1f ; //breakdamage unweakness ability attack rate?

int flashBreak = 0 ; //flash break?

int ElementValueModifier = 0 ; //some sort of number that benefits from exploit weakness and opposite element

int takeBreakDamage = 0 ;

ElementAttributeBitType elementAttributeBit = ( ElementAttributeBitType ) target. GetElementAttributeBit ( ) ;

ElementAttributeBitType targetAbsorbs2 = ( ElementAttributeBitType ) target. targetAbsorbs ;

ElementAttributeBitType targetsWeakness = ( ElementAttributeBitType ) target. targetsWeakness ;

if ( ( int ) damageSourceElem. m056cb6b23e1a1553df9a90eb3f5f804b ( ) ! = 0 )

{

int statusEffectValue = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . BraveDamage ) ;

bravePercent * = 1f + ( float ) statusEffectValue * 0.01f ;

if ( owner. IsEnemy ( ) )

{

if ( statusEffectValue > 0 )

{

isEnhance = true ;

}

else if ( statusEffectValue < 0 )

{

isReduce = true ;

}

}

}

else if ( owner. IsEnemy ( ) && ( int ) damageSourceElem. getCondition ( ) ! = 1 )

{

int statusEffectValue2 = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . Synchro ) ;

bravePercent * = 1f + ( float ) statusEffectValue2 * 0.01f ;

if ( statusEffectValue2 > 0 )

{

isEnhance = true ;

}

else if ( statusEffectValue2 < 0 )

{

isReduce = true ;

}

}

int getElementResists = 0 ;

ElementAttributeBitType elementAttributeBitType = ElementAttributeBitType. None ;

if ( ( int ) damageSourceElem. mcdcc634daaa800ae30b0d9aa90d524cc ( ) ! = 0 ) //mcdcc634daaa800ae30b0d9aa90d524cc not 100% on this.

{

elementAttributeBitType | = ElementAttributeBitType. Fire ;

getElementResists ++ ;

}

if ( ( int ) damageSourceElem. m6374ec9bd9c83aa1592cd25bdd68315e ( ) ! = 0 )

{

if ( ( elementAttributeBitType & ElementAttributeBitType. Fire ) == ElementAttributeBitType. None )

{

elementAttributeBitType | = ElementAttributeBitType. Water ;

}

else

{

elementAttributeBitType & = ( ElementAttributeBitType ) ( - 2 ) ;

}

getElementResists ++ ;

}

if ( ( int ) damageSourceElem. m1ff35aae1a721dffe2c7ec2dfb4c573e ( ) ! = 0 )

{

elementAttributeBitType | = ElementAttributeBitType. Wind ;

getElementResists ++ ;

}

if ( ( int ) damageSourceElem. m957592ac75221a66cc4d1fa3831c59b8 ( ) ! = 0 )

{

if ( ( elementAttributeBitType & ElementAttributeBitType. Wind ) == ElementAttributeBitType. None )

{

elementAttributeBitType | = ElementAttributeBitType. Earth ;

}

else

{

elementAttributeBitType & = ( ElementAttributeBitType ) ( - 5 ) ;

}

getElementResists ++ ;

}

if ( ( int ) damageSourceElem. m4a78ffda98410f820411120ffcbc8045 ( ) ! = 0 )

{

elementAttributeBitType | = ElementAttributeBitType. Light ;

getElementResists ++ ;

}

if ( ( int ) damageSourceElem. m7b9ab26a81a7c308786cde1f6d7a628e ( ) ! = 0 )

{

if ( ( elementAttributeBitType & ElementAttributeBitType. Light ) == ElementAttributeBitType. None )

{

elementAttributeBitType | = ElementAttributeBitType. Dark ;

}

else

{

elementAttributeBitType & = ( ElementAttributeBitType ) ( - 17 ) ;

}

getElementResists ++ ;

}

if ( getElementResists >= 3 )

{

elementAttributeBitType = ElementAttributeBitType. None ;

}

bool ownerHasEnchantedWeapon = false ;

if ( elementAttributeBitType == ElementAttributeBitType. None && owner. NormalAttackNum > 0 )

{

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . EnchantFire ) )

{

elementAttributeBitType ++ ;

ownerHasEnchantedWeapon = true ;

}

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . EnchantWater ) )

{

elementAttributeBitType + = 2 ;

ownerHasEnchantedWeapon = true ;

}

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . EnchantWind ) )

{

elementAttributeBitType + = 4 ;

ownerHasEnchantedWeapon = true ;

}

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . EnchantEarth ) )

{

elementAttributeBitType + = 8 ;

ownerHasEnchantedWeapon = true ;

}

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . EnchantLight ) )

{

elementAttributeBitType + = 16 ;

ownerHasEnchantedWeapon = true ;

}

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . EnchantDark ) )

{

elementAttributeBitType + = 32 ;

ownerHasEnchantedWeapon = true ;

}

}

damageInfo. elementAttributeBit = ( int ) elementAttributeBitType ;

if ( target. IsBreakDamage ( ) && ( int ) damageSourceElem. getCondition ( ) ! = 50 )

{

isBreak = true ;

breakDmgIncPercent * = Mobius. DataSheet . GetResidentFloat ( "damageBreakRate" , 2f ) ;

}

float sameElementDebuff = Mobius. DataSheet . GetResidentFloat ( "damageSameAttributeRate" , 0.5f ) ;

float reverseElementBoon = Mobius. DataSheet . GetResidentFloat ( "damageReverseAttributeRate" , 2f ) ;

float reverseBrokenElementBoon = Mobius. DataSheet . GetResidentFloat ( "damageBreakReverseAttributeRate" , 2f ) ;

bool hasCardAbility5176 = owner. IsUseCardAbilitySkill ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5176 ) ;

bool hasCardAbility5177 = owner. IsUseCardAbilitySkill ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5177 ) ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None )

{

if ( ( targetAbsorbs2 & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None )

{

isAbsorb = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon ++ ; //This means remove fire weapon

}

breakDamage = 0 ;

}

else if ( ( elementAttributeBit & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None && ! hasCardAbility5176 )

{

if ( ! isAbsorb )

{

elementDmgIncPercent * = sameElementDebuff ;

int useCardAbilitySkillNum2 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5003 ) ;

if ( useCardAbilitySkillNum2 > 0 )

{

ElementValueModifier - = 100 - Mobius. DataSheet . GetResidentInteger ( "abilitySkill1" , 50 ) * useCardAbilitySkillNum2 ;

}

else

{

breakDamage = 0 ;

}

isResist = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon ++ ; //This means remove fire weapon

}

}

}

else if ( ( targetsWeakness & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None )

{

if ( isBreak )

{

elementDmgIncPercent * = reverseBrokenElementBoon ;

}

else

{

elementDmgIncPercent * = reverseElementBoon ;

EleBoonDamage * = reverseElementBoon ;

}

isWeakness = true ;

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Water ) ! = ElementAttributeBitType. None )

{

if ( ( targetAbsorbs2 & ElementAttributeBitType. Water ) ! = ElementAttributeBitType. None )

{

isAbsorb = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 2 ; //This means remove water weapon

}

breakDamage = 0 ;

}

else if ( ( elementAttributeBit & ElementAttributeBitType. Water ) ! = ElementAttributeBitType. None && ! hasCardAbility5176 )

{

if ( ! isAbsorb )

{

elementDmgIncPercent * = sameElementDebuff ;

int useCardAbilitySkillNum3 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5003 ) ;

if ( useCardAbilitySkillNum3 > 0 )

{

ElementValueModifier - = 100 - Mobius. DataSheet . GetResidentInteger ( "abilitySkill1" , 50 ) * useCardAbilitySkillNum3 ;

}

else

{

breakDamage = 0 ;

}

isResist = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 2 ; //This means remove water weapon

}

}

}

else if ( ( targetsWeakness & ElementAttributeBitType. Water ) ! = ElementAttributeBitType. None )

{

if ( isBreak )

{

elementDmgIncPercent * = reverseBrokenElementBoon ;

}

else

{

elementDmgIncPercent * = reverseElementBoon ;

EleBoonDamage * = reverseElementBoon ;

}

isWeakness = true ;

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Wind ) ! = ElementAttributeBitType. None )

{

if ( ( targetAbsorbs2 & ElementAttributeBitType. Wind ) ! = ElementAttributeBitType. None )

{

isAbsorb = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 4 ; //This means remove wind weapon

}

breakDamage = 0 ;

}

else if ( ( elementAttributeBit & ElementAttributeBitType. Wind ) ! = ElementAttributeBitType. None && ! hasCardAbility5176 )

{

if ( ! isAbsorb )

{

elementDmgIncPercent * = sameElementDebuff ;

int useCardAbilitySkillNum4 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5003 ) ;

if ( useCardAbilitySkillNum4 > 0 )

{

ElementValueModifier - = 100 - Mobius. DataSheet . GetResidentInteger ( "abilitySkill1" , 50 ) * useCardAbilitySkillNum4 ;

}

else

{

breakDamage = 0 ;

}

isResist = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 4 ; //This means remove wind weapon

}

}

}

else if ( ( targetsWeakness & ElementAttributeBitType. Wind ) ! = ElementAttributeBitType. None )

{

if ( isBreak )

{

elementDmgIncPercent * = reverseBrokenElementBoon ;

}

else

{

elementDmgIncPercent * = reverseElementBoon ;

EleBoonDamage * = reverseElementBoon ;

}

isWeakness = true ;

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Earth ) ! = ElementAttributeBitType. None )

{

if ( ( targetAbsorbs2 & ElementAttributeBitType. Earth ) ! = ElementAttributeBitType. None )

{

isAbsorb = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 8 ; //This means remove earth weapon

}

breakDamage = 0 ;

}

else if ( ( elementAttributeBit & ElementAttributeBitType. Earth ) ! = ElementAttributeBitType. None && ! hasCardAbility5176 )

{

if ( ! isAbsorb )

{

elementDmgIncPercent * = sameElementDebuff ;

int useCardAbilitySkillNum5 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5003 ) ;

if ( useCardAbilitySkillNum5 > 0 )

{

ElementValueModifier - = 100 - Mobius. DataSheet . GetResidentInteger ( "abilitySkill1" , 50 ) * useCardAbilitySkillNum5 ;

}

else

{

breakDamage = 0 ;

}

isResist = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 8 ; //This means remove earth weapon

}

}

}

else if ( ( targetsWeakness & ElementAttributeBitType. Earth ) ! = ElementAttributeBitType. None )

{

if ( isBreak )

{

elementDmgIncPercent * = reverseBrokenElementBoon ;

}

else

{

elementDmgIncPercent * = reverseElementBoon ;

EleBoonDamage * = reverseElementBoon ;

}

isWeakness = true ;

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Light ) ! = ElementAttributeBitType. None )

{

if ( ( targetAbsorbs2 & ElementAttributeBitType. Light ) ! = ElementAttributeBitType. None )

{

isAbsorb = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 16 ; //This means remove light weapon

}

breakDamage = 0 ;

}

else if ( ( elementAttributeBit & ElementAttributeBitType. Light ) ! = ElementAttributeBitType. None && ! hasCardAbility5176 )

{

if ( ! isAbsorb )

{

elementDmgIncPercent * = sameElementDebuff ;

int useCardAbilitySkillNum6 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5003 ) ;

if ( useCardAbilitySkillNum6 > 0 )

{

ElementValueModifier - = 100 - Mobius. DataSheet . GetResidentInteger ( "abilitySkill1" , 50 ) * useCardAbilitySkillNum6 ;

}

else

{

breakDamage = 0 ;

}

isResist = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 16 ; //This means remove light weapon

}

}

}

else if ( ( targetsWeakness & ElementAttributeBitType. Light ) ! = ElementAttributeBitType. None )

{

if ( isBreak )

{

elementDmgIncPercent * = reverseBrokenElementBoon ;

}

else

{

elementDmgIncPercent * = reverseElementBoon ;

EleBoonDamage * = reverseElementBoon ;

}

isWeakness = true ;

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Dark ) ! = ElementAttributeBitType. None )

{

if ( ( targetAbsorbs2 & ElementAttributeBitType. Dark ) ! = ElementAttributeBitType. None )

{

isAbsorb = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 32 ;

}

breakDamage = 0 ;

}

else if ( ( elementAttributeBit & ElementAttributeBitType. Dark ) ! = ElementAttributeBitType. None && ! hasCardAbility5176 )

{

if ( ! isAbsorb )

{

elementDmgIncPercent * = sameElementDebuff ;

int useCardAbilitySkillNum7 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5003 ) ;

if ( useCardAbilitySkillNum7 > 0 )

{

ElementValueModifier - = 100 - Mobius. DataSheet . GetResidentInteger ( "abilitySkill1" , 50 ) * useCardAbilitySkillNum7 ;

}

else

{

breakDamage = 0 ;

}

isResist = true ;

if ( ownerHasEnchantedWeapon )

{

damageInfo. removeEnchantedWeapon + = 32 ;

}

}

}

else if ( ( targetsWeakness & ElementAttributeBitType. Dark ) ! = ElementAttributeBitType. None )

{

if ( isBreak )

{

elementDmgIncPercent * = reverseBrokenElementBoon ;

}

else

{

elementDmgIncPercent * = reverseElementBoon ;

EleBoonDamage * = reverseElementBoon ;

}

isWeakness = true ;

}

}

if ( elementAttributeBitType == ElementAttributeBitType. None )

{

if ( ( targetAbsorbs2 & ElementAttributeBitType. Normal ) ! = ElementAttributeBitType. None )

{

isAbsorb = true ;

breakDamage = 0 ;

}

if ( ( elementAttributeBit & ElementAttributeBitType. Normal ) ! = ElementAttributeBitType. None && ! hasCardAbility5176 && ! isAbsorb )

{

elementDmgIncPercent * = sameElementDebuff ;

int useCardAbilitySkillNum8 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5003 ) ;

if ( useCardAbilitySkillNum8 > 0 )

{

ElementValueModifier - = 100 - Mobius. DataSheet . GetResidentInteger ( "abilitySkill1" , 50 ) * useCardAbilitySkillNum8 ;

}

else

{

breakDamage = 0 ;

}

isResist = true ;

}

if ( ( targetsWeakness & ElementAttributeBitType. Normal ) ! = ElementAttributeBitType. None )

{

if ( isBreak )

{

elementDmgIncPercent * = reverseBrokenElementBoon ;

}

else

{

elementDmgIncPercent * = reverseElementBoon ;

EleBoonDamage * = reverseElementBoon ;

}

isWeakness = true ;

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None )

{

enhancementBonuses + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . EnhanceDamageFire ) ;

int elementInfluenceType = BattleUtility. GetElementInfluenceType ( ) ;

if ( elementInfluenceType ! = 0 )

{

DbManager. BattleData battleData = Mobius. Db . GetBattleData ( ) ;

if ( ( int ) battleData. elementInfluenceAttribute == 0 )

{

damageInfo. elementInfluenceRate * = battleData. elementInfluenceRate ;

elementDmgIncPercent * = battleData. elementInfluenceRate ;

}

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Water ) ! = ElementAttributeBitType. None )

{

enhancementBonuses + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . EnhanceDamageWater ) ;

int elementInfluenceType2 = BattleUtility. GetElementInfluenceType ( ) ;

if ( elementInfluenceType2 ! = 0 )

{

DbManager. BattleData battleData2 = Mobius. Db . GetBattleData ( ) ;

if ( ( int ) battleData2. elementInfluenceAttribute == 1 )

{

damageInfo. elementInfluenceRate * = battleData2. elementInfluenceRate ;

elementDmgIncPercent * = battleData2. elementInfluenceRate ;

}

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Wind ) ! = ElementAttributeBitType. None )

{

enhancementBonuses + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . EnhanceDamageWind ) ;

int elementInfluenceType3 = BattleUtility. GetElementInfluenceType ( ) ;

if ( elementInfluenceType3 ! = 0 )

{

DbManager. BattleData battleData3 = Mobius. Db . GetBattleData ( ) ;

if ( ( int ) battleData3. elementInfluenceAttribute == 2 )

{

damageInfo. elementInfluenceRate * = battleData3. elementInfluenceRate ;

elementDmgIncPercent * = battleData3. elementInfluenceRate ;

}

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Earth ) ! = ElementAttributeBitType. None )

{

enhancementBonuses + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . EnhanceDamageEarth ) ;

int elementInfluenceType4 = BattleUtility. GetElementInfluenceType ( ) ;

if ( elementInfluenceType4 ! = 0 )

{

DbManager. BattleData battleData4 = Mobius. Db . GetBattleData ( ) ;

if ( ( int ) battleData4. elementInfluenceAttribute == 3 )

{

damageInfo. elementInfluenceRate * = battleData4. elementInfluenceRate ;

elementDmgIncPercent * = battleData4. elementInfluenceRate ;

}

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Light ) ! = ElementAttributeBitType. None )

{

enhancementBonuses + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . EnhanceDamageLight ) ;

int elementInfluenceType5 = BattleUtility. GetElementInfluenceType ( ) ;

if ( elementInfluenceType5 ! = 0 )

{

DbManager. BattleData battleData5 = Mobius. Db . GetBattleData ( ) ;

if ( ( int ) battleData5. elementInfluenceAttribute == 4 )

{

damageInfo. elementInfluenceRate * = battleData5. elementInfluenceRate ;

elementDmgIncPercent * = battleData5. elementInfluenceRate ;

}

}

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Dark ) ! = ElementAttributeBitType. None )

{

enhancementBonuses + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . EnhanceDamageDark ) ;

int elementInfluenceType6 = BattleUtility. GetElementInfluenceType ( ) ;

if ( elementInfluenceType6 ! = 0 )

{

DbManager. BattleData battleData6 = Mobius. Db . GetBattleData ( ) ;

if ( ( int ) battleData6. elementInfluenceAttribute == 5 )

{

damageInfo. elementInfluenceRate * = battleData6. elementInfluenceRate ;

elementDmgIncPercent * = battleData6. elementInfluenceRate ;

}

}

}

if ( owner. IsPlayer ( ) )

{

int fireStrengthenValue ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_FIRE_STRENGTHEN , out fireStrengthenValue ) )

{

enhancementBonuses + = fireStrengthenValue ;

}

int waterStrengthenValue ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Water ) ! = ElementAttributeBitType. None && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_ICE_STRENGTHEN , out waterStrengthenValue ) )

{

enhancementBonuses + = waterStrengthenValue ;

}

int windStrengthenValue ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Wind ) ! = ElementAttributeBitType. None && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_WIND_STRENGTHEN , out windStrengthenValue ) )

{

enhancementBonuses + = windStrengthenValue ;

}

int earthStrengthenValue ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Earth ) ! = ElementAttributeBitType. None && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_SOIL_STRENGTHEN , out earthStrengthenValue ) )

{

enhancementBonuses + = earthStrengthenValue ;

}

int lightStrengthenValue ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Light ) ! = ElementAttributeBitType. None && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_LIGHT_STRENGTHEN , out lightStrengthenValue ) )

{

enhancementBonuses + = lightStrengthenValue ;

}

int darkStrengthenValue ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Dark ) ! = ElementAttributeBitType. None && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_DARK_STRENGTHEN , out darkStrengthenValue ) )

{

enhancementBonuses + = darkStrengthenValue ;

}

}

if ( ( int ) damageSourceElem. powerType ( ) == 1 )

{

breakDamage = ( int ) ( ( float ) breakDamage * ( 1f + ( float ) owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . Break ) / 100f ) ) ; //Break Boon

}

if ( ( int ) damageSourceElem. getCondition ( ) ! = 1 )

{

enhancementBonuses + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . GiveDamage ) ;

targetTakeDamage - = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . TakeDamage ) ;

targetTakeDamageEnemy - = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . TakeDamageEnemy ) ;

if ( target. IsPlayer ( ) )

{

int fireTolerance ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None && target. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_FIRE_TOLERANCE , out fireTolerance ) )

{

targetEleTolerance + = fireTolerance ;

}

int waterTolerance ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Water ) ! = ElementAttributeBitType. None && target. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_ICE_TOLERANCE , out waterTolerance ) )

{

targetEleTolerance + = waterTolerance ;

}

int windTolerance ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Wind ) ! = ElementAttributeBitType. None && target. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_WIND_TOLERANCE , out windTolerance ) )

{

targetEleTolerance + = windTolerance ;

}

int earthTolerance ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Earth ) ! = ElementAttributeBitType. None && target. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_SOIL_TOLERANCE , out earthTolerance ) )

{

targetEleTolerance + = earthTolerance ;

}

int lightTolerance ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Light ) ! = ElementAttributeBitType. None && target. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_LIGHT_TOLERANCE , out lightTolerance ) )

{

targetEleTolerance + = lightTolerance ;

}

int darkTolerance ;

if ( ( elementAttributeBitType & ElementAttributeBitType. Dark ) ! = ElementAttributeBitType. None && target. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_DARK_TOLERANCE , out darkTolerance ) )

{

targetEleTolerance + = darkTolerance ;

}

}

if ( isWeakness )

{

targetSufferWeakness + = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . SufferDamageWeak ) ; //Weaken status boon

ElementValueModifier + = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . SufferDamageWeak ) ;

int useCardAbilitySkillNum9 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5103 ) ;

if ( useCardAbilitySkillNum9 > 0 )

{

flashBreak + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill8" , 50 ) * useCardAbilitySkillNum9 ;

}

int exploitWeaknessWeapon ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1310 , out exploitWeaknessWeapon ) ) //Exploit Weakness

{

targetSufferWeakness + = exploitWeaknessWeapon ;

ElementValueModifier + = exploitWeaknessWeapon ;

}

int useAbilitySkillValue = owner. GetUseAbilitySkillValue ( EnemyAbilitySkillType. Id1310 ) ; //Enemy Exploit Weakness Ailment?

targetSufferWeakness + = useAbilitySkillValue ;

ElementValueModifier + = useAbilitySkillValue ;

}

if ( owner. IsPlayer ( ) )

{

int useCardAbilitySkillNum10 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5152 ) ;

if ( useCardAbilitySkillNum10 > 0 )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill16" , 50 ) * useCardAbilitySkillNum10 ;

}

int AutoAbilityCS1314Bonus ;

if ( owner. PrevUseCardAbilityAttribute ! = ElementAttributeType. None && ! isAbilityMatchJob && owner. NormalAttackNum == 0 && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1314 , out AutoAbilityCS1314Bonus ) )

{

enhancementBonuses + = AutoAbilityCS1314Bonus ;

}

ElementAttributeType prevUseCardAbilityAttribute = owner. PrevUseCardAbilityAttribute ;

if ( prevUseCardAbilityAttribute ! = ElementAttributeType. None )

{

ElementAttributeType useCardAbilityAttribute3 = owner. GetUseCardAbilityAttribute ( ) ;

if ( useCardAbilityAttribute3 ! = ElementAttributeType. None )

{

int AutoAbilityCS1316Bonus ;

if ( prevUseCardAbilityAttribute == useCardAbilityAttribute3 )

{

int AutoAbilityCS1315Bonus ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1315 , out AutoAbilityCS1315Bonus ) )

{

enhancementBonuses + = AutoAbilityCS1315Bonus ;

}

enhancementBonuses + = owner. GetUseAbilitySkillValue ( EnemyAbilitySkillType. Id1315 ) ;

int useCardAbilitySkillNum11 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5164 ) ;

if ( useCardAbilitySkillNum11 > 0 )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5164" , 10 ) * useCardAbilitySkillNum11 ;

}

}

else if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1316 , out AutoAbilityCS1316Bonus ) )

{

enhancementBonuses + = AutoAbilityCS1316Bonus ;

}

}

}

int useCardAbilitySkillNum12 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5154 ) ;

if ( useCardAbilitySkillNum12 > 0 && BattleManager._i. GetEnemyNum ( false ) == 1 )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5154" , 10 ) * useCardAbilitySkillNum12 ;

}

int useCardAbilitySkillNum13 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5155 ) ;

if ( useCardAbilitySkillNum13 > 0 )

{

DiffLevel diffLevel = Api. GetDiffLevel ( Mevius. Field . Api . GadgetRouteApi . GetTargetGadgetName ( ) , Mobius. Db . GetCurrentCardDeck ( ) , Mobius. App . GetMainJobTypeCurrentDeck ( ) ) ;

if ( diffLevel == DiffLevel. VeryTough )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5155_0" , 10 ) * useCardAbilitySkillNum13 ;

}

else if ( diffLevel == DiffLevel. IncrediblyTough )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5155_1" , 10 ) * useCardAbilitySkillNum13 ;

}

}

int useCardAbilitySkillNum14 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5156 ) ;

if ( useCardAbilitySkillNum14 > 0 && BattleManager._i. TurnNum == 1 )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5156" , 10 ) * useCardAbilitySkillNum14 ;

}

int useCardAbilitySkillNum15 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5157 ) ;

if ( useCardAbilitySkillNum15 > 0 )

{

int statusEffectDebuffNum = target. GetStatusEffectDebuffNum ( ) ;

if ( statusEffectDebuffNum > 0 )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5157" , 10 ) * useCardAbilitySkillNum15 * statusEffectDebuffNum ;

}

}

int useCardAbilitySkillNum16 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5159 ) ;

if ( useCardAbilitySkillNum16 > 0 && target. Bp == target. BpMax && target. BpArmorDamage == 0 )

{

flashBreak + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5159" , 10 ) * useCardAbilitySkillNum16 ;

}

int useCardAbilitySkillNum17 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5160 ) ;

if ( useCardAbilitySkillNum17 > 0 )

{

float hpRate = target. GetHpRate ( ) ;

if ( hpRate <= 0.25f )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5160_1" , 10 ) * useCardAbilitySkillNum17 ;

}

else if ( hpRate <= 0.5f )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5160_0" , 10 ) * useCardAbilitySkillNum17 ;

}

}

if ( ( owner. ActionFlagBit & BattleActor. ActionFlagBitType . AbilitySkill5162 ) ! = ( BattleActor. ActionFlagBitType ) 0 )

{

int useCardAbilitySkillNum18 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5162 ) ;

if ( useCardAbilitySkillNum18 > 0 )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5162" , 10 ) * useCardAbilitySkillNum18 ;

}

}

if ( ( owner. ActionFlagBit & BattleActor. ActionFlagBitType . AbilitySkill5163 ) ! = ( BattleActor. ActionFlagBitType ) 0 )

{

int useCardAbilitySkillNum19 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5163 ) ;

if ( useCardAbilitySkillNum19 > 0 )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5163" , 10 ) * useCardAbilitySkillNum19 ;

}

}

int useCardAbilitySkillNum20 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5616 ) ;

if ( useCardAbilitySkillNum20 > 0 && target. IsStatusEffectEntry ( BattleStatusEffect. GroupType . Brave ) )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5616" , 10 ) * useCardAbilitySkillNum20 ;

}

int useCardAbilitySkillNum21 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5617 ) ;

if ( useCardAbilitySkillNum21 > 0 && target. IsStatusEffectEntry ( BattleStatusEffect. GroupType . Syncle ) )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5617" , 10 ) * useCardAbilitySkillNum21 ;

}

int useCardAbilitySkillNum22 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5618 ) ;

if ( useCardAbilitySkillNum22 > 0 && target. IsStatusEffectEntry ( BattleStatusEffect. GroupType . BuffStart ) )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5618" , 10 ) * useCardAbilitySkillNum22 ;

}

int useCardAbilitySkillNum23 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5619 ) ;

if ( useCardAbilitySkillNum23 > 0 && target. IsStatusEffectEntry ( BattleStatusEffect. GroupType . Clit ) )

{

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5619" , 10 ) * useCardAbilitySkillNum23 ;

}

int abilitySkillEnemySlayer = BattleUtility. GetAbilitySkillEnemySlayer ( owner, target ) ;

enhancementBonuses + = abilitySkillEnemySlayer ;

flashBreak + = abilitySkillEnemySlayer ;

int Ability1506Bonus ;

if ( Mobius. App . IsPartyMode ( ) && ! isAbilityMatchJob && owner. NormalAttackNum == 0 && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1506 , out Ability1506Bonus ) )

{

Ability1506Bonus_G + = Ability1506Bonus ;

}

if ( owner. NormalAttackNum > 0 )

{

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . JobAbilityRatioDamageUp ) )

{

float jobAbilityUseManaUseNumRate = owner. GetJobAbilityUseManaUseNumRate ( ) ;

float AutoAbility5502_0 = ( float ) Mobius. DataSheet . GetResidentInteger ( "abilitySkill5502_0" , 50 ) * 0.01f ;

if ( AutoAbility5502_0 <= jobAbilityUseManaUseNumRate )

{

float AutoAbility5502_1 = ( float ) Mobius. DataSheet . GetResidentInteger ( "abilitySkill5502_1" , 100 ) * 0.01f ;

float AutoAbility5502_0Perc = 1f - AutoAbility5502_0 ;

float num71 = jobAbilityUseManaUseNumRate - AutoAbility5502_0 ;

enhancementBonuses + = ( int ) ( AutoAbility5502_1 / ( AutoAbility5502_0Perc * AutoAbility5502_0Perc ) * num71 * num71 * 100f + 0.5f ) ;

}

}

if ( owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . JobAbilityRatioBreakDamageUp ) )

{

float jobAbilityUseManaUseNumRate2 = owner. GetJobAbilityUseManaUseNumRate ( ) ;

float AutoAbility5503_0 = ( float ) Mobius. DataSheet . GetResidentInteger ( "abilitySkill5503_0" , 50 ) * 0.01f ;

if ( AutoAbility5503_0 >= jobAbilityUseManaUseNumRate2 )

{

float AutoAbility5503_1 = ( float ) Mobius. DataSheet . GetResidentInteger ( "abilitySkill5503_1" , 100 ) * 0.01f ;

float AutoAbility5503_0Perc = AutoAbility5503_0 ;

float num75 = jobAbilityUseManaUseNumRate2 - AutoAbility5503_0 ;

flashBreak + = ( int ) ( AutoAbility5503_1 / ( AutoAbility5503_0Perc * AutoAbility5503_0Perc ) * num75 * num75 * 100f + 0.5f ) ;

}

}

}

int useCardAbilitySkillNum24 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5167 ) ;

if ( useCardAbilitySkillNum24 > 0 )

{

int targetDebuffNumber = target. GetStatusEffectDebuffNum ( ) ;

if ( targetDebuffNumber > 0 )

{

int Ability5167 = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5167_1" , 10 ) ;

if ( targetDebuffNumber > Ability5167 )

{

targetDebuffNumber = Ability5167 ;

}

enhancementBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5167" , 2 ) * targetDebuffNumber * useCardAbilitySkillNum24 ;

}

}

int AutoAbility1257Bonus ;

if ( ( isAbilityMatchJob || owner. NormalAttackNum ! = 0 || ( int ) damageSourceElem. powerType ( ) == 1 ) && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1257 , out AutoAbility1257Bonus ) && target. BpArmorDamage ! = 0 )

{

flashBreak + = AutoAbility1257Bonus ;

}

}

enhancementBonuses + = owner. ActionDamageGroupParam ;

if ( owner. NormalAttackNum == 3 )

{

int damageFinishAddRate = Mobius. DataSheet . GetResidentInteger ( "damageFinishAddRate" , 20 ) ;

enhancementBonuses + = damageFinishAddRate ;

flashBreak + = damageFinishAddRate ;

}

if ( ! isResist && ! isRandMinTest && ! owner. IsStatusEffectEntry ( BattleStatusEffect. ProcType . CriticalZero ) && ( Damage ! = 0 || breakDamage ! = 0 ) )

{

if ( target. IsStatusEffectEntry ( BattleStatusEffect. GroupType . CriticalDefenseUp ) && ! hasCardAbility5177 )

{

isCritical = false ;

}

else if ( ( ! isAbilityMatchJob && owner. NormalAttackNum <= 0 ) || ! isNoCriticalCalc )

{

critChance + = owner. GetStatusEffectValue ( BattleStatusEffect. ProcType . Critical ) ;

critChance + = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . TakeCritical ) ;

if ( owner. IsPlayer ( ) )

{

if ( isBreak )

{

int useCardAbilitySkillNum25 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5052 ) ;

if ( useCardAbilitySkillNum25 > 0 )

{

critChance + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill3" , 50 ) * useCardAbilitySkillNum25 ;

}

}

if ( isWeakness )

{

int useCardAbilitySkillNum26 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5104 ) ;

if ( useCardAbilitySkillNum26 > 0 )

{

critChance + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill9" , 50 ) * useCardAbilitySkillNum26 ;

}

}

}

if ( ! hasCardAbility5177 )

{

C4d4f3a800432e94568175cb31ad3c78d. C51747b7e0e19ad065084a2c5a6d8421b battleCharaSpecElem = target. GetBattleCharaSpecElem ( ) ;

if ( battleCharaSpecElem ! = null )

{

critChance - = ( int ) battleCharaSpecElem. m55cf0f9e548ca3ba7c5b283f670f1dec ( ) ;

}

}

if ( critChance > 0 ) //some sort of rate that decides if we crit or not.

{

uint randomInteger = Api. GetRandomUnsignedInteger ( ) % 100u ;

isCritical = ( ( ulong ) randomInteger < ( ulong ) ( ( long ) critChance ) ) ;

}

else

{

isCritical = false ;

}

damageInfo. isCriticalCalc = true ;

}

}

else

{

isCritical = false ;

}

if ( isCritical )

{

critDmgIncPercent = Mobius. DataSheet . GetResidentFloat ( "damageCriticalRate" , 1.5f ) ;

if ( owner. IsPlayer ( ) )

{

int useCardAbilitySkillNum27 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5053 ) ;

if ( useCardAbilitySkillNum27 > 0 )

{

flashBreak + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill4" , 50 ) * useCardAbilitySkillNum27 ;

}

int useCardAbilitySkillNum28 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5054 ) ;

if ( useCardAbilitySkillNum28 > 0 )

{

critAbilityBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5" , 50 ) * useCardAbilitySkillNum28 ;

}

int AutoAbility1311Bonus ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1311 , out AutoAbility1311Bonus ) )

{

critAbilityBonuses + = AutoAbility1311Bonus ;

}

critAbilityBonuses + = owner. GetUseAbilitySkillValue ( EnemyAbilitySkillType. Id1311 ) ;

int useCardAbilitySkillNum29 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5171 ) ;

if ( useCardAbilitySkillNum29 > 0 )

{

critAbilityBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5171_0" , 100 ) * useCardAbilitySkillNum29 ;

}

}

}

if ( isBreak && owner. IsPlayer ( ) )

{

int useCardAbilitySkillNum30 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5002 ) ;

if ( useCardAbilitySkillNum30 > 0 )

{

breakAbilityBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill0" , 50 ) * useCardAbilitySkillNum30 ;

}

if ( isWeakness )

{

int useCardAbilitySkillNum31 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5102 ) ;

if ( useCardAbilitySkillNum31 > 0 )

{

targetSufferWeakness + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill7" , 50 ) * useCardAbilitySkillNum31 ;

}

}

int AutoAbility1309Bonus ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1309 , out AutoAbility1309Bonus ) )

{

breakAbilityBonuses + = AutoAbility1309Bonus ;

}

breakAbilityBonuses + = owner. GetUseAbilitySkillValue ( EnemyAbilitySkillType. Id1309 ) ;

int useCardAbilitySkillNum32 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5168 ) ;

if ( useCardAbilitySkillNum32 > 0 )

{

breakAbilityBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5168_0" , 100 ) * useCardAbilitySkillNum32 ;

}

}

if ( target. IsStatusEffectEntry ( BattleStatusEffect. ProcType . TakeBreakDamage ) && ( isAbilityMatchJob || owner. NormalAttackNum > 0 ) )

{

takeBreakDamage - = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . TakeBreakDamage ) ;

}

if ( target. IsStatusEffectEntry ( BattleStatusEffect. ProcType . TakeAbilityBreakDamage ) && ! isAbilityMatchJob && owner. NormalAttackNum == 0 )

{

takeBreakDamage - = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . TakeAbilityBreakDamage ) ;

}

if ( ! target. IsStatusEffectEntry ( BattleStatusEffect. ProcType . DefenceZero ) && ! hasCardAbility5177 )

{

if ( owner. IsPlayer ( ) )

{

if ( ! isBreak )

{

targetDefPercent + = target. Defense ;

}

}

else if ( target. IsPlayer ( ) )

{

int defenderMPBonus = 0 ;

if ( Mobius. App . IsPartyMode ( ) )

{

int [ ] partyParameterType3 = Mobius. Party . GetPartyParameterType ( ) ;

defenderMPBonus = partyParameterType3 [ target. PartySlot ] ; //get targets paramters.

}

else if ( target. IsPlayerSub ( ) ) //isPlayerSub for some reason ignores ^

{

defenderMPBonus = 1000 ;

}

targetDefPercent + = Mobius. Db . GetParameter ( DbManager. ParameterType . GuardValue + defenderMPBonus ) ;

int AbilityValue61 ;

if ( BattleUtility. GetOptimaAbilityValue ( 61 , out AbilityValue61 ) )

{

targetDefPercent + = AbilityValue61 ;

}

}

else

{

targetDefPercent + = target. Defense ;

}

if ( isCritical )

{

int useCardAbilitySkillNum33 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5054 ) ;

if ( useCardAbilitySkillNum33 > 0 )

{

targetDefPercent - = Mobius. DataSheet . GetResidentInteger ( "abilitySkill6" , 20 ) * useCardAbilitySkillNum33 ;

}

}

if ( targetDefPercent < 0 )

{

targetDefPercent = 0 ;

}

}

}

else

{

int AutoAbility1508Bonus ;

if ( num4 > 0 && Mobius. App . IsPartyMode ( ) && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1508 , out AutoAbility1508Bonus ) )

{

enhancementBonuses + = AutoAbility1508Bonus ;

}

isCritical = false ;

}

if ( ( elementAttributeBitType & ElementAttributeBitType. Fire ) ! = ElementAttributeBitType. None && ( int ) damageSourceElem. m056cb6b23e1a1553df9a90eb3f5f804b ( ) == 0 && target. IsStatusEffectEntry ( BattleStatusEffect. ProcType . MagicDamageFire ) )

{

Damage = ( int ) ( ( float ) ( Damage * target. GetStatusEffectValue ( BattleStatusEffect. ProcType . MagicDamageFire ) ) * 0.01f + 0.5f ) ;

}

float enhancementIncPercent = 1f + ( float ) enhancementBonuses * 0.01f ;

breakDmgIncPercent + = ( float ) breakAbilityBonuses * 0.01f ;

elementDmgIncPercent + = ( float ) targetSufferWeakness * 0.01f ;

critDmgIncPercent + = ( float ) critAbilityBonuses * 0.01f ;

breakDamageLower + = ( float ) flashBreak * 0.01f ;

EleBoonDamage + = ( float ) ElementValueModifier * 0.01f ;

float AutoAbility1506Bonus_GPercent = 1f + ( float ) Ability1506Bonus_G * 0.01f ;

if ( synchroBonusValue < 0f )

{

synchroBonusValue = 0f ;

}

if ( enhancementIncPercent < 0f )

{

enhancementIncPercent = 0f ;

}

if ( breakDmgIncPercent < 0f )

{

breakDmgIncPercent = 0f ;

}

if ( elementDmgIncPercent < 0f )

{

elementDmgIncPercent = 0f ;

}

if ( critDmgIncPercent < 0f )

{

critDmgIncPercent = 0f ;

}

if ( breakDamageLower < 0f )

{

breakDamageLower = 0f ;

}

if ( EleBoonDamage < 0f )

{

EleBoonDamage = 0f ;

}

if ( ( int ) damageSourceElem. getCondition ( ) == 1 )

{

breakDmgIncPercent = 1f ;

}

if ( target. BpSpecialCalc && ! isWeakness && ( int ) damageSourceElem. powerType ( ) ! = 1 )

{

breakDamageLower * = Mobius. DataSheet . GetResidentFloat ( "breakDamageUnWeaknessAbilityAttackRate" , 0.25f ) ;

}

if ( isAbsorb )

{

Damage = ( int ) ( ( float ) Damage * owner. AbilityDamageCoef * synchroBonusValue * bravePercent * enhancementIncPercent * critDmgIncPercent * AutoAbility1506Bonus_GPercent + 0.5f ) ;

}

else

{

Damage = ( int ) ( ( float ) Damage * owner. AbilityDamageCoef * synchroBonusValue * elementDmgIncPercent * bravePercent * enhancementIncPercent * breakDmgIncPercent * critDmgIncPercent * AutoAbility1506Bonus_GPercent + 0.5f ) ;

}

float bpDamageDefenderRateMin = Mobius. DataSheet . GetResidentFloat ( "bpDamageDefenderRateMin" , 0.3f ) ;

float bpDamageDefenderRateMax = Mobius. DataSheet . GetResidentFloat ( "bpDamageDefenderRateMax" , 3f ) ;

float breakDefenses = ( float ) ( 100 - takeBreakDamage ) * 0.01f ;

if ( breakDefenses < bpDamageDefenderRateMin )

{

breakDefenses = bpDamageDefenderRateMin ;

}

else if ( breakDefenses > bpDamageDefenderRateMax )

{

breakDefenses = bpDamageDefenderRateMax ;

}

breakDamage = ( int ) ( ( float ) breakDamage * owner. AbilityDamageCoef * synchroBonusValue * EleBoonDamage * breakDamageLower * breakDefenses + 0.5f ) ;

if ( owner. IsPlayer ( ) && Damage ! = 0 )

{

int playerStats ;

if ( target. IsBreak ( ) )

{

int playerAddedDamage = 0 ;

if ( BattleUtility. GetOptimaAbilityValue ( 23 , out playerStats ) )

{

playerAddedDamage + = playerStats ;

}

int AutoAbility1341Bonus ;

if ( owner. NormalAttackNum > 0 && owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1341 , out AutoAbility1341Bonus ) )

{

playerAddedDamage + = AutoAbility1341Bonus ;

}

if ( playerAddedDamage > 0 )

{

Damage = ( int ) ( ( float ) Damage * ( 1f + ( float ) playerAddedDamage / 100f ) + 0.5f ) ;

}

}

int AutoAbilityExtraBonuses = 0 ;

Ceaf68fb2356fb8b84facc86d2fe79f0e. Cca912973d2eb55c3b74a5c95a6475670 cca912973d2eb55c3b74a5c95a2 = Ceaf68fb2356fb8b84facc86d2fe79f0e. Find ( owner. AbilityId ) ;

if ( cca912973d2eb55c3b74a5c95a2 ! = null && ( int ) cca912973d2eb55c3b74a5c95a2. m02be48e0485474e5cf059777a462cc3d ( ) ! = 0 )

{

if ( BattleUtility. GetOptimaAbilityValue ( 24 , out playerStats ) )

{

AutoAbilityExtraBonuses + = playerStats ;

}

int AutoAbility1342Bonus ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1342 , out AutoAbility1342Bonus ) )

{

AutoAbilityExtraBonuses + = AutoAbility1342Bonus ;

}

}

int useCardAbilitySkillNum34 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5173 ) ;

if ( useCardAbilitySkillNum34 > 0 )

{

int Ability5173TurnBonuses = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5173_0" , 10 ) * useCardAbilitySkillNum34 * owner. GetUseCardAbilityTurnCount ( ) ;

int Ability5173 = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5173_1" , 50 ) ;

if ( Ability5173TurnBonuses > Ability5173 )

{

Ability5173TurnBonuses = Ability5173 ;

}

AutoAbilityExtraBonuses + = Ability5173TurnBonuses ;

}

int useCardAbilitySkillNum35 = owner. GetUseCardAbilitySkillNum ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5175 ) ;

if ( useCardAbilitySkillNum35 > 0 && BattleManager._i. GetEnemyNum ( false ) == 1 )

{

AutoAbilityExtraBonuses + = Mobius. DataSheet . GetResidentInteger ( "abilitySkill5175_0" , 100 ) * useCardAbilitySkillNum35 ;

}

if ( AutoAbilityExtraBonuses > 0 )

{

Damage = ( int ) ( ( float ) Damage * ( 1f + ( float ) AutoAbilityExtraBonuses / 100f ) + 0.5f ) ;

}

if ( owner. NormalAttackNum > 0 )

{

if ( BattleUtility. GetOptimaAbilityValue ( 20 , out playerStats ) )

{

Damage = ( int ) ( ( float ) Damage * ( 1f + ( float ) playerStats / 100f ) + 0.5f ) ;

}

else if ( BattleUtility. GetOptimaAbilityValue ( 40 , out playerStats ) )

{

breakDamage = ( int ) ( ( float ) breakDamage * ( 1f + ( float ) playerStats / 100f ) + 0.5f ) ;

}

}

else if ( ! isAbilityMatchJob )

{

if ( BattleUtility. GetOptimaAbilityValue ( 21 , out playerStats ) ) //mantras maybe.

{

Damage = ( int ) ( ( float ) Damage * ( 1f + ( float ) playerStats / 100f ) + 0.5f ) ;

}

else if ( BattleUtility. GetOptimaAbilityValue ( 41 , out playerStats ) )

{

breakDamage = ( int ) ( ( float ) breakDamage * ( 1f + ( float ) playerStats / 100f ) + 0.5f ) ;

}

}

else if ( BattleUtility. GetOptimaAbilityValue ( 22 , out playerStats ) )

{

Damage = ( int ) ( ( float ) Damage * ( 1f + ( float ) playerStats / 100f ) + 0.5f ) ;

}

else if ( BattleUtility. GetOptimaAbilityValue ( 42 , out playerStats ) )

{

breakDamage = ( int ) ( ( float ) breakDamage * ( 1f + ( float ) playerStats / 100f ) + 0.5f ) ;

}

if ( target. Bp == target. BpMax )

{

int breakDamagePlayerAdded = 0 ;

if ( BattleUtility. GetOptimaAbilityValue ( 43 , out playerStats ) )

{

breakDamagePlayerAdded + = playerStats ;

}

int AutoAbility1343Bonus ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1343 , out AutoAbility1343Bonus ) )

{

breakDamagePlayerAdded + = AutoAbility1343Bonus ;

}

if ( breakDamagePlayerAdded > 0 )

{

breakDamage = ( int ) ( ( float ) breakDamage * ( 1f + ( float ) breakDamagePlayerAdded / 100f ) + 0.5f ) ;

}

}

if ( owner. IsUseCardAbilitySkill ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5170 ) )

{

Damage + = ( int ) ( ( float ) Damage * owner. GetHpRate ( ) * ( float ) Mobius. DataSheet . GetResidentInteger ( "abilitySkill5170_0" , 10 ) * 0.01f + 0.5f ) ;

}

}

if ( Damage > 0 )

{

float damageSourceSpread = ( float ) damageSourceElem. m0a3adefa2ef034c2e9556ec82f7fa3c6 ( ) / 100f ;

if ( damageSourceSpread ! = 0f )

{

float randomFloat = 0f ;

if ( ! isRandMinTest )

{

randomFloat = BattleDamage. GetRandomSingleFloat ( owner. IsPlayer ( ) ) ;

}

float damageRolled = randomFloat * 2f * damageSourceSpread - damageSourceSpread ;

int totalDamageAdded = ( int ) ( ( float ) Damage * damageRolled ) ;

if ( totalDamageAdded == 0 && ( randomFloat <= 0.3f || 0.7f <= randomFloat ) )

{

if ( randomFloat >= 0.5f )

{

totalDamageAdded = 1 ;

}

else

{

totalDamageAdded = - 1 ;

}

}

Damage + = totalDamageAdded ;

if ( Damage <= 0 )

{

Damage = 1 ;

}

}

}

originalDamage = Damage ;

if ( ! isAbsorb )

{

if ( ! hasCardAbility5176 )

{

for ( int j = 0 ; j < 7 ; j ++ )

{

if ( ( elementAttributeBitType & ( ElementAttributeBitType ) ( 1 << j ) ) ! = ElementAttributeBitType. None )

{

int resistValue = target. GetStatusEffectValue ( BattleStatusEffect. ProcType . ReductionDamageFire + j ) ;

int AutoAbility1317Bonus ;

if ( owner. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1317 , out AutoAbility1317Bonus ) )

{

resistValue + = AutoAbility1317Bonus ;

}

if ( resistValue > 0 )

{

isResist = true ;

}

elementResistance * = ( float ) ( 100 - resistValue ) * 0.01f ;

}

}

}

float targetDefPerc = ( float ) ( 100 - targetDefPercent ) * 0.01f ;

float targetTakeDamagePerc = ( float ) ( 100 - targetTakeDamage ) * 0.01f ;

float targetTakeDamageEnemyPerc = ( float ) ( 100 - targetTakeDamageEnemy ) * 0.01f ;

float targetEleTolerancePerc = ( float ) ( 100 - targetEleTolerance ) * 0.01f ;

if ( targetDefPerc > 1f )

{

targetDefPerc = 1f ;

}

else if ( target. IsPlayer ( ) )

{

if ( targetDefPerc < 0.2f )

{

targetDefPerc = 0.2f ;

}

}

else if ( targetDefPerc < 0f )

{

targetDefPerc = 0f ;

}

float damageDefenderRateMin = Mobius. DataSheet . GetResidentFloat ( "damageDefenderRateMin" , 0.3f ) ;

float damageDefenderRateMax = Mobius. DataSheet . GetResidentFloat ( "damageDefenderRateMax" , 3f ) ;

if ( targetTakeDamagePerc < damageDefenderRateMin )

{

targetTakeDamagePerc = damageDefenderRateMin ;

}

else if ( targetTakeDamagePerc > damageDefenderRateMax )

{

targetTakeDamagePerc = damageDefenderRateMax ;

}

float damageDefenderEnemyRateMin = Mobius. DataSheet . GetResidentFloat ( "damageDefenderEnemyRateMin" , 0f ) ;

float damageDefenderEnemyRateMax = Mobius. DataSheet . GetResidentFloat ( "damageDefenderEnemyRateMax" , 3f ) ;

if ( targetTakeDamageEnemyPerc < damageDefenderEnemyRateMin )

{

targetTakeDamageEnemyPerc = damageDefenderEnemyRateMin ;

}

else if ( targetTakeDamageEnemyPerc > damageDefenderEnemyRateMax )

{

targetTakeDamageEnemyPerc = damageDefenderEnemyRateMax ;

}

float damageDefenderElementRateMin = Mobius. DataSheet . GetResidentFloat ( "damageDefenderElementRateMin" , 0.3f ) ;

float damageDefenderElementRateMax = Mobius. DataSheet . GetResidentFloat ( "damageDefenderElementRateMax" , 2f ) ;

if ( targetEleTolerancePerc < damageDefenderElementRateMin )

{

targetEleTolerancePerc = damageDefenderElementRateMin ;

}

else if ( targetEleTolerancePerc > damageDefenderElementRateMax )

{

targetEleTolerancePerc = damageDefenderElementRateMax ;

}

if ( elementResistance < 0.3f )

{

elementResistance = 0.3f ;

}

else if ( elementResistance > 2f )

{

elementResistance = 2f ;

}

float enemyResistanceStatPerc = ( float ) ( 100 - BattleUtility. GetAutoAbilityEnemyResist ( owner, target ) ) * 0.01f ;

float damageDefenderEnemyTypeRateMin = Mobius. DataSheet . GetResidentFloat ( "damageDefenderEnemyTypeRateMin" , 0.3f ) ;

float damageDefenderEnemyTypeRateMax = Mobius. DataSheet . GetResidentFloat ( "damageDefenderEnemyTypeRateMax" , 2f ) ;

if ( elementResistance < damageDefenderEnemyTypeRateMin )

{

enemyResistanceStatPerc = damageDefenderEnemyTypeRateMin ;

}

else if ( elementResistance > damageDefenderEnemyTypeRateMax )

{

enemyResistanceStatPerc = damageDefenderEnemyTypeRateMax ;

}

float DeGuardPercentage = 1f ;

if ( target. IsPlayer ( ) )

{

int playerDeGuardRate = 0 ;

int playerStat ;

if ( BattleUtility. GetOptimaAbilityValue ( 64 , out playerStat ) )

{

playerDeGuardRate + = playerStat ;

}

int AutoAbility1346Bonus ;

if ( target. GetAutoAbilityParam ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1346 , out AutoAbility1346Bonus ) )

{

playerDeGuardRate + = AutoAbility1346Bonus ;

}

if ( playerDeGuardRate > 0 )

{

int totalDeGuard = ( 1 + target. DamageCount ) * playerDeGuardRate ;

int FF12RiseGuardMax = Mobius. DataSheet . GetResidentInteger ( "ff13RiseGuardMax" , 50 ) ;

if ( totalDeGuard > FF12RiseGuardMax )

{

totalDeGuard = FF12RiseGuardMax ;

}

DeGuardPercentage - = ( float ) totalDeGuard / 100f ;

}

}

Damage = ( int ) ( ( float ) Damage * targetDefPerc * enemyResistanceStatPerc * targetTakeDamagePerc * targetTakeDamageEnemyPerc * targetEleTolerancePerc * elementResistance * DeGuardPercentage + 0.5f ) ;

}

}

if ( Damage <= 0 )

{

if ( originalDamage ! = 0 )

{

Damage = 1 ;

}

else

{

Damage = 0 ;

}

}

if ( owner. IsPlayer ( ) && target. IsEnemy ( ) )

{

if ( isWeakness )

{

damageInfo. scoreRate + = Mobius. DataSheet . GetResidentFloat ( "scoreWeaknessRate" , 1.3f ) ;

}

if ( isCritical )

{

damageInfo. scoreRate + = Mobius. DataSheet . GetResidentFloat ( "scoreCriticalRate" , 1.2f ) ;

}

if ( isBreak )

{

damageInfo. scoreRate + = Mobius. DataSheet . GetResidentFloat ( "scoreBreakRate" , 1.5f ) ;

}

DbManager. JobCardInfo jobCardInfo = Mobius. Db . GetJobCardInfoSlot ( owner. Deck ) ;

if ( jobCardInfo ! = null )

{

jobCardInfo = jobCardInfo. getAvatarJobCard ( owner. Deck , null ) ;

uint jobPanelCount = jobCardInfo. CompleteSheetCount ( ) ;

if ( jobPanelCount > 8u )

{

jobPanelCount = 8u ;

}

damageInfo. scoreRate + = jobPanelCount * Mobius. DataSheet . GetResidentFloat ( "scoreSkillCompleteRate" , 0.05f ) ;

}

}

if ( owner. IsEnemy ( ) && target. IsPlayer ( ) )

{

float scoreResistRate = Mobius. DataSheet . GetResidentFloat ( "scoreResistRate" , 1.2f ) * BattleUtility. GetScoreRate ( ) ;

damageInfo. resistScore + = ( long ) ( ( float ) ( originalDamage - Damage ) * scoreResistRate + 0.5f ) ;

}

if ( ! isHealing && Damage > 9999 && ! isAbilityMatchJob && owner. IsPlayer ( ) && ( int ) damageSourceElem. getCondition ( ) ! = 50 && ( int ) damageSourceElem. getCondition ( ) ! = 1 && ! owner. IsFlagBit ( ( BattleActor. FlagBitType ) 10 ) )

{

if ( owner. NormalAttackNum > 0 )

{

if ( ! owner. IsAutoAbility ( DbManager. AutoAbilityType . AUTOABILITYTYPE_CS1331 ) )

{

Damage = 9999 ;

}

}

else if ( ! owner. IsUseCardAbilitySkill ( DbManager. AbilitySkillType . ABILITYSKILL_TYPE_5151 ) )

{

Damage = 9999 ;

}

}

if ( ! uncapDamage )

{

if ( ( int ) damageSourceElem. getCondition ( ) ! = 50 )

{

if ( Damage > 999999 )

{

Damage = 999999 ;

}

}

else

{

int padDamageLimit = Mobius. DataSheet . GetResidentInteger ( "padDamageLimit" , 9999999 ) ;

if ( Damage > padDamageLimit )

{

Damage = padDamageLimit ;

}

}

if ( breakDamage > 999999 )

{

breakDamage = 999999 ;

}

}

if ( ( int ) damageSourceElem. getCondition ( ) == 1 || isAbsorb )

{

Damage * = - 1 ;

originalDamage * = - 1 ;

}

damageInfo. owner = owner ;

damageInfo. damage = Damage ;

damageInfo. breakDamage = breakDamage ;

damageInfo. isCritical = isCritical ;

damageInfo. isWeakness = isWeakness ;

damageInfo. isResist = isResist ;

damageInfo. isBreak = isBreak ;

damageInfo. isEnhance = isEnhance ;

damageInfo. isReduce = isReduce ;

damageInfo. isAbsorb = isAbsorb ;

damageInfo. originalDamage = originalDamage ;

damageInfo. powerType = ( DamageSourcePowerType ) damageSourceElem. powerType ( ) ;

damageInfo. power = Power ;