Skip to content

Instantly share code, notes, and snippets.

@NyaMisty
Last active January 26, 2024 08:37
Show Gist options
  • Save NyaMisty/3280e1d31260b4c2b869f7a083ec2c9d to your computer and use it in GitHub Desktop.
Save NyaMisty/3280e1d31260b4c2b869f7a083ec2c9d to your computer and use it in GitHub Desktop.
Evol deepspace damage calculation
// local variable allocation has failed, the output may be wrong!
__int64 __fastcall DamageFormula__CalcDamage(
DamageInfo **damageInfo,
void *damageExporter,
Actor *damageTaker,
Actor *assistor,
HitParamConfig *hitParamConfig,
float hurtAddAngle,
float damageProportion,
char isCritical,
void *attrModifyDatas,
char bIsTarget,
char isFirstEnterWeak)
{
long double v14; // q9
long double v15; // q8
__int64 Patch_44624988; // x0
Actor *damageCaster; // x0
DamageInfo *v24; // x8
char v25; // w25
float v26; // s10
float32x2_t v27; // d0
__int64 attributeOwner; // x0
float AdditionalAttrValue; // s0
DamageInfo *v30; // x8
v14 = *(long double *)&damageProportion;
v15 = *(long double *)&hurtAddAngle;
if...
if...
if...
DamageFormula___CalcTempModifyAttr(attrModifyDatas);
if ( !damageExporter )
goto LABEL_25;
damageCaster = (Actor *)(*(__int64 (__fastcall **)(void *, _QWORD))(*(_QWORD *)damageExporter + 424LL))(
damageExporter,
*(_QWORD *)(*(_QWORD *)damageExporter + 432LL));
DamageFormula__CalcDamageChild(
damageInfo,
damageExporter,
damageTaker,
hitParamConfig,
damageCaster,
*(float *)&v14,
isCritical & 1,
isFirstEnterWeak & 1);
v24 = *damageInfo;
if ( assistor )
{
if ( !v24 )
goto LABEL_25;
v25 = v24->isCritical;
*(_QWORD *)&v26 = *(_QWORD *)&v24->damage;
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
DamageFormula__CalcDamageChild(
damageInfo,
damageExporter,
damageTaker,
hitParamConfig,
assistor,
*(float *)&v14,
isCritical & 1,
isFirstEnterWeak & 1);
v24 = *damageInfo;
if ( !*damageInfo )
goto LABEL_25;
v27.n64_u64[0] = *(unsigned __int64 *)&v24->damage;
v24->isCritical = v25;
*(float32x2_t *)&v24->damage = vadd_f32(*(float32x2_t *)&v26, v27);
}
else if ( !v24 )
{
goto LABEL_25;
}
*(float *)&v14 = v24->damage;
if...
DamageFormula__CalcHpShieldDamage(damageInfo, damageExporter, damageTaker, v14, v15);
if ( !damageTaker )
goto LABEL_25;
attributeOwner = Actor__get_attributeOwner(damageTaker, 0LL);
AdditionalAttrValue = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_HP);
v30 = *damageInfo;
if ( !*damageInfo )
goto LABEL_25;
if ( AdditionalAttrValue < v30->realDamage )
v30->realDamage = AdditionalAttrValue;
if...
return DamageFormula___ClearTempModifyAttr();
}
// local variable allocation has failed, the output may be wrong!
void __fastcall DamageFormula__CalcDamageChild(
DamageInfo **damageInfo,
void *damageExporter,
Actor *damageTaker,
HitParamConfig *hitParamConfig,
Actor *damageCaster,
float damageProportion,
char isCritical,
char isFirstEnterWeak)
{
__int64 Patch_44624988; // x0
if...
if...
if ( !*damageInfo )
goto LABEL_24;
(*damageInfo)->isCritical = isCritical & 1;
if...
DamageFormula__CalcDamageBase(
damageInfo,
(__int64)damageExporter,
(__int64)damageTaker,
hitParamConfig,
(__int64)damageCaster);
if ( !hitParamConfig )
goto LABEL_24;
if ( !hitParamConfig->IsTrueDamage )
{
if...
DamageFormula__CalcDamageDef(damageInfo, damageExporter, damageTaker, hitParamConfig, damageCaster);
DamageFormula__CalcDamageCrit(damageInfo, damageExporter, damageTaker, hitParamConfig, damageCaster);
}
if...
DamageFormula__CalcDamagePlus(damageInfo, damageExporter, damageTaker, hitParamConfig, damageCaster);
if ( !hitParamConfig->IsTrueDamage )
{
if...
DamageFormula__CalcDamageTag(
damageInfo,
damageExporter,
damageTaker,
hitParamConfig,
damageCaster,
isFirstEnterWeak & 1);
DamageFormula__CalcDamageBonus(damageInfo, damageExporter, damageTaker, hitParamConfig, damageCaster);
}
if...
DamageFormula__CalcDamageDecorate(
damageInfo,
damageExporter,
damageTaker,
hitParamConfig,
damageCaster,
damageProportion);
if ( !*damageInfo )
goto LABEL_24;
(*damageInfo)->realDamage = (*damageInfo)->damage;
}
// local variable allocation has failed, the output may be wrong!
void __fastcall DamageFormula__CalcHpShieldDamage(
DamageInfo **damageInfo,
void *damageExporter,
Actor *damageTaker,
float damage,
float hurtAddAngle)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
if...
if...
if ( !damageTaker )
goto LABEL_30;
attributeOwner = Actor__get_attributeOwner(damageTaker, 0LL);
if...
AdditionalAttrValue = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_HpShield);
if ( AdditionalAttrValue > 0.0 )
{
v12 = AdditionalAttrValue;
transform = Actor__get_transform(damageTaker, 0LL);
if ( !transform )
goto LABEL_30;
forwardVec3 = ActorTransform__get_forward((__int64)transform);
if ( !damageExporter )
goto LABEL_30;
x = forwardVec3.x;
y = forwardVec3.y;
z = forwardVec3.z;
casterActor = (*(__int64 (__fastcall **)(void *, _QWORD))(*(_QWORD *)damageExporter + 424LL))(
damageExporter,
*(_QWORD *)(*(_QWORD *)damageExporter + 432LL));
if ( !casterActor )
goto LABEL_30;
v18 = Actor__get_transform(casterActor, 0LL);
if ( !v18 )
goto LABEL_30;
v34 = y;
v35 = x;
v36 = hurtAddAngle;
position = ActorTransform__get_position(v18, 0LL);
v19 = position.x;
v20 = *(double *)&position.y;
v21 = *(double *)&position.z;
v22 = Actor__get_transform(damageTaker, 0LL);
if ( !v22 )
goto LABEL_30;
LODWORD(v23) = (unsigned int)ActorTransform__get_position(v22, 0LL);
if ( !*((_DWORD *)UnityEngine_Vector3_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)UnityEngine_Vector3_TypeInfo);
v39 = sub_43C8730(v19, v20, v21, v23);
v24 = v39.x;
v25 = *(double *)&v39.y;
v26 = v39.z;
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v27 = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_HpShieldHurtAdd);
v28 = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_HpShieldHurtDec);
if ( sub_43C7E00(v24, v25, v26, v35, v34, z) <= v36 )
v29 = v28;
else
v29 = v27;
v30 = v29 + 1.0;
v31 = (float)(v29 + 1.0) * damage;
if ( !*((_DWORD *)UnityEngine_Mathf_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)UnityEngine_Mathf_TypeInfo);
if ( v31 <= v12 )
{
v12 = floorf(v31);
v32 = 0.0;
}
else
{
v32 = damage - floorf(v12 / v30);
}
v33 = *damageInfo;
if ( !*damageInfo )
LABEL_30:
sub_1786760();
v33->realDamage = v32;
v33->hpShieldDamage = v12;
}
}
float __fastcall DamageFormula__CalcDamageBase(
DamageInfo **damageInfo,
__int64 damageExporter,
Actor *damageTaker,
HitParamConfig *hitParamConfig,
Actor *damageCaster)
{
__int64 attributeOwner; // x22
float casterAdditional2; // s8
__int64 v10; // x0
float casterAdditional1; // s9
__int64 v12; // x0
float casterAdditional3; // s0
float result; // s0
if...
if...
if ( !damageCaster )
goto LABEL_12;
attributeOwner = Actor__get_attributeOwner(damageCaster, 0LL);
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
casterAdditional2 = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_PhyAttack);
v10 = Actor__get_attributeOwner(damageCaster, 0LL);
casterAdditional1 = DamageFormula___GetAdditionalAttrValue(v10, AttrType_MaxHP);
v12 = Actor__get_attributeOwner(damageCaster, 0LL);
casterAdditional3 = DamageFormula___GetAdditionalAttrValue(v12, AttrType_PhyDefence);
if ( !hitParamConfig || !*damageInfo )
LABEL_12:
sub_1786760();
result = (float)(casterAdditional3 * hitParamConfig->TargetDamageDefRatio)
+ (float)((float)(casterAdditional1 * hitParamConfig->TargetDamageHpRatio)
+ (float)((float)(casterAdditional2 * hitParamConfig->TargetDamageAtkRatio)
+ (float)hitParamConfig->TargetBasicDamage));
(*damageInfo)->damage = result;
return result;
}
float __fastcall DamageFormula__CalcDamageDef(
DamageInfo **damageInfo,
void *damageExporter,
Actor *damageTaker,
HitParamConfig *hitParamConfig,
Actor *damageCaster)
{
__int64 attributeOwner; // x21
float takerAttr3; // s0 MAPDST
__int64 v11; // x0
float casterAttr36; // s0
int32_t level; // w20
float v14; // s8
float v15; // s0
float v16; // s0
DamageInfo *v17; // x8
float result; // s0
if...
if...
if ( !damageTaker )
goto LABEL_17;
attributeOwner = Actor__get_attributeOwner(damageTaker, 0LL);
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
takerAttr3 = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_PhyDefence);
if ( !damageCaster )
goto LABEL_17;
v11 = Actor__get_attributeOwner(damageCaster, 0LL);
casterAttr36 = DamageFormula___GetAdditionalAttrValue(v11, AttrType_IgnoreDefence);
level = damageCaster->level;
v14 = takerAttr3 * (float)((float)(casterAttr36 * -0.001) + 1.0);
if ( !*((_DWORD *)System_Math_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)System_Math_TypeInfo);
v15 = (float)(30 * level);
v16 = v14 >= 0.0
? Math__Min_78949140(0LL, v14 / (float)((float)(v14 + v15) + 1600.0), 0.95)
: Math__Max_78948636(0LL, v14 / (float)((float)(v15 - v14) + 1600.0), -0.95);
v17 = *damageInfo;
if...
result = (float)(1.0 - v16) * v17->damage;
v17->damage = result;
return result;
}
float __fastcall DamageFormula__CalcDamageCrit(
DamageInfo **damageInfo,
void *damageExporter,
void *damageTaker,
HitParamConfig *hitParamConfig,
void *damageCaster)
{
float result; // s0
__int64 attributeOwner; // x20
float casterAttr6; // s8
float v10; // s0
DamageInfo *v11; // x8
if...
if...
if ( !*damageInfo )
goto LABEL_16;
if ( (*damageInfo)->isCritical != 1 )
return result;
if ( !damageCaster )
goto LABEL_16;
attributeOwner = Actor__get_attributeOwner(damageCaster, 0LL);
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
casterAttr6 = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_CritHurtAdd);
if ( !*((_DWORD *)System_Math_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)System_Math_TypeInfo);
v10 = Math__Max_78948636(0LL, 1.0, casterAttr6 * 0.001);
v11 = *damageInfo;
if ( !*damageInfo )
LABEL_16:
sub_1786760();
result = v10 * v11->damage;
v11->damage = result;
return result;
}
float __fastcall DamageFormula__CalcDamagePlus(
DamageInfo **damageInfo,
void *damageExporter,
void *damageTaker,
HitParamConfig *hitParamConfig,
void *damageCaster)
{
float TargetDamageHpRatioOther; // s8
float result; // s0
float v10; // s8
__int64 attributeOwner; // x20
float takerAttr1; // s0
DamageInfo *v13; // x8
if...
if...
if ( !hitParamConfig )
goto LABEL_16;
TargetDamageHpRatioOther = hitParamConfig->TargetDamageHpRatioOther;
if ( !*((_DWORD *)System_Math_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)System_Math_TypeInfo);
result = Math__Min_78949140(0LL, TargetDamageHpRatioOther, 1.0);
if ( result <= 0.0 )
return result;
if ( !damageTaker )
goto LABEL_16;
v10 = result;
attributeOwner = Actor__get_attributeOwner(damageTaker, 0LL);
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
takerAttr1 = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_MaxHP);
v13 = *damageInfo;
if...
result = (float)(v10 * takerAttr1) + v13->damage;
v13->damage = result;
return result;
}
float __fastcall DamageFormula__CalcDamageTag(
DamageInfo **damageInfo,
void *damageExporter,
void *damageTaker,
HitParamConfig *hitParamConfig,
void *damageCaster,
bool isFirstEnterWeak)
{
__int64 attributeOwner; // x23
float AdditionalAttrValue; // s0
float v12; // s8
__int64 v13; // x0
float v14; // s0
__int64 v15; // x23
float v16; // s8
float result; // s0
__int64 actorWeak; // x0
__int64 v19; // x20
float v20; // s0
DamageInfo *v21; // x8
if...
if...
if ( !damageCaster )
goto LABEL_25;
attributeOwner = Actor__get_attributeOwner(damageCaster, 0LL);
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
AdditionalAttrValue = DamageFormula___GetAdditionalAttrValue(attributeOwner, AttrType_HurtAdd);
if ( !damageTaker )
goto LABEL_25;
v12 = AdditionalAttrValue * 0.001;
v13 = Actor__get_attributeOwner(damageTaker, 0LL);
v14 = DamageFormula___GetAdditionalAttrValue(v13, AttrType_HurtDec) * 0.001;
if ( v12 != 0.0 || v14 != 0.0 )
{
if ( !*damageInfo )
goto LABEL_25;
(*damageInfo)->damage = (float)(1.0 - v14) * (float)((float)(v12 + 1.0) * (*damageInfo)->damage);
}
v15 = Actor__get_attributeOwner(damageTaker, 0LL);
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v16 = DamageFormula___GetAdditionalAttrValue(v15, AttrType_WeakHurtAdd);
if ( !Actor__get_actorWeak(damageTaker, 0LL) )
return result;
actorWeak = Actor__get_actorWeak(damageTaker, 0LL);
if ( !actorWeak )
goto LABEL_25;
if ( (ActorWeak__get_weak(actorWeak, 0LL) & 1) == 0 || isFirstEnterWeak )
return result;
v19 = Actor__get_attributeOwner(damageCaster, 0LL);
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v20 = DamageFormula___GetAdditionalAttrValue(v19, AttrType_WeakDamageAdd);
v21 = *damageInfo;
if ( *damageInfo )
{
result = (float)((float)((float)(v16 * 0.001) + 1.0) + (float)(v20 * 0.001)) * v21->damage;
v21->damage = result;
return result;
}
LABEL_25:
sub_1786760();
return result;
}
float __fastcall DamageFormula__CalcDamageBonus(
DamageInfo **damageInfo,
void *damageExporter,
void *damageTaker,
HitParamConfig *hitParamConfig,
void *damageCaster)
{
__int64 attributeOwner; // x0
__int64 v11; // x20
__int64 v12; // x0
__int64 v13; // x21
int32_t SkillDamageType; // w0
float v15; // s8
float v16; // s9
float AdditionalAttrValue; // s0
AttrType v18; // w1
AttrType v19; // w1
float v20; // s9
float v21; // s0
float v22; // s9
float result; // s0
DamageInfo *v24; // x8
if...
if...
if ( !damageCaster
|| (attributeOwner = Actor__get_attributeOwner(damageCaster, 0LL), !damageTaker)
|| (v11 = attributeOwner, v12 = Actor__get_attributeOwner(damageTaker, 0LL), !hitParamConfig) )
{
LABEL_48:
sub_1786760();
}
v13 = v12;
SkillDamageType = hitParamConfig->SkillDamageType;
if ( (SkillDamageType & 0x80000000) != 0 )
{
if ( !damageExporter )
goto LABEL_48;
SkillDamageType = (*(__int64 (__fastcall **)(void *, _QWORD))(*(_QWORD *)damageExporter + 488LL))(
damageExporter,
*(_QWORD *)(*(_QWORD *)damageExporter + 496LL));
}
v15 = 0.0;
v16 = 0.0;
switch ( SkillDamageType )
{
case DamageSkillType_Attack:
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
AdditionalAttrValue = DamageFormula___GetAdditionalAttrValue(v11, AttrType_AttackSkillAdd);
v18 = AttrType_WeaponAttackSkillAdd;
goto LABEL_22;
case DamageSkillType_Fill:
case DamageSkillType_Passive:
case DamageSkillType_Support:
case DamageSkillType_Dodge:
case DamageSkillType_Gemcore:
case DamageSkillType_ScorePhase:
case DamageSkillType_Card:
break;
case DamageSkillType_Active:
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
AdditionalAttrValue = DamageFormula___GetAdditionalAttrValue(v11, AttrType_ActiveSkillAdd);
v18 = AttrType_WeaponActiveSkillAdd;
LABEL_22:
v16 = AdditionalAttrValue * 0.001;
v15 = DamageFormula___GetAdditionalAttrValue(v11, v18) * 0.001;
break;
case DamageSkillType_Coop:
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v19 = AttrType_CoopSkillAdd;
goto LABEL_29;
case DamageSkillType_Ultra:
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v19 = AttrType_UltraSkillAdd;
goto LABEL_29;
case DamageSkillType_AttackHeavy:
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v19 = AttrType_ThumpSkillAdd;
LABEL_29:
v16 = DamageFormula___GetAdditionalAttrValue(v11, v19) * 0.001;
break;
default:
v16 = 0.0;
break;
}
if ( v15 != 0.0 || v16 != 0.0 )
{
if ( !*damageInfo )
goto LABEL_48;
(*damageInfo)->damage = (float)(v15 + 1.0) * (float)((float)(v16 + 1.0) * (*damageInfo)->damage);
}
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v20 = DamageFormula___GetAdditionalAttrValue(v11, AttrType_FinalDamageAdd) * 0.001;
v21 = DamageFormula___GetAdditionalAttrValue(v13, AttrType_FinalDamageDec) * 0.001;
if ( v20 != 0.0 || v21 != 0.0 )
{
if ( !*damageInfo )
goto LABEL_48;
(*damageInfo)->damage = (float)(1.0 - v21) * (float)((float)(v20 + 1.0) * (*damageInfo)->damage);
}
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v22 = DamageFormula___GetAdditionalAttrValue(v11, AttrType_GameplayDamageAdd) * 0.001;
result = DamageFormula___GetAdditionalAttrValue(v13, AttrType_GameplayDamageDec) * 0.001;
if ( v22 == 0.0 && result == 0.0 )
return result;
v24 = *damageInfo;
if ( !*damageInfo )
goto LABEL_48;
result = (float)(1.0 - result) * (float)((float)(v22 + 1.0) * v24->damage);
v24->damage = result;
return result;
}
float __fastcall DamageFormula__CalcDamageDecorate(
DamageInfo **damageInfo,
void *damageExporter,
void *damageTaker,
HitParamConfig *hitParamConfig,
void *damageCaster,
float damageProportion)
{
_QWORD **v8; // x0
__int64 random; // x0
double newRandomValue; // d0
DamageInfo *v11; // x19
float v12; // s0
float v13; // s8
float v14; // s8
float result; // s0
if...
if...
v8 = (_QWORD **)X3Battle_DamageFormula_TypeInfo;
if ( !*((_DWORD *)X3Battle_DamageFormula_TypeInfo + 56) )
{
j_il2cpp_runtime_class_init_0((__int64)X3Battle_DamageFormula_TypeInfo);
v8 = (_QWORD **)X3Battle_DamageFormula_TypeInfo;
}
random = *v8[23];
if ( !random
|| (newRandomValue = (*(double (__fastcall **)(__int64, _QWORD))(*(_QWORD *)random + 440LL))(
random,
*(_QWORD *)(*(_QWORD *)random + 448LL)),
(v11 = *damageInfo) == 0LL) )
{
LABEL_15:
sub_1786760();
}
v12 = (newRandomValue + newRandomValue + -1.0) * 0.0500000007;
v13 = (float)((float)(v12 + 1.0) * v11->damage) * damageProportion;
v11->damage = v13;
if...
v14 = Math__Max_78948636(0LL, v13, 1.0);
if...
result = floorf(v14);
v11->damage = result;
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment