Skip to content

Instantly share code, notes, and snippets.

@Lusamine
Created August 1, 2022 03:22
Show Gist options
  • Save Lusamine/36bc926231e12b0bea336bbaeda8dbbd to your computer and use it in GitHub Desktop.
Save Lusamine/36bc926231e12b0bea336bbaeda8dbbd to your computer and use it in GitHub Desktop.
__int64 __fastcall apply_damage_effectiveness_modifier(unsigned int damage, unsigned int effectiveness)
{
float eff_mod; // s1
float dam_temp; // s0
__int64 result; // x0
switch ( effectiveness )
{
case 0u:
goto LABEL_6;
case 1u:
case 2u:
case 3u:
case 4u:
case 5u:
eff_mod = 0.4;
dam_temp = (float)damage;
goto LABEL_4;
case 6u:
dam_temp = (float)damage;
eff_mod = 0.5;
goto LABEL_4;
case 8u:
return 2 * damage;
case 9u:
case 10u:
case 11u:
case 12u:
case 13u:
dam_temp = (float)damage;
eff_mod = 2.5;
LABEL_4:
result = (unsigned int)(float)(dam_temp * eff_mod);
break;
default:
effectiveness = damage;
LABEL_6:
result = effectiveness;
break;
}
return result;
}
-----
.text:000000710283EB50 ; __int64 __fastcall apply_damage_effectiveness_modifier(unsigned int damage, unsigned int effectiveness)
.text:000000710283EB50 apply_damage_effectiveness_modifier ; CODE XREF: sub_71007810FC+23C↑p
.text:000000710283EB50 ; calc_attack_damage+3718↓p ...
.text:000000710283EB50 CMP W1, #0xD ; switch 14 cases
.text:000000710283EB54 B.HI def_710283EB70 ; jumptable 000000710283EB70 default case, case 7
.text:000000710283EB58 MOV W8, W1
.text:000000710283EB5C ADRL X9, jpt_710283EB70
.text:000000710283EB64 ADR X10, loc_710283EB74 ; jumptable 000000710283EB70 cases 1-5
.text:000000710283EB68 LDRB W11, [X9,X8]
.text:000000710283EB6C ADD X10, X10, X11,LSL#2
.text:000000710283EB70 BR X10 ; switch jump
.text:000000710283EB74 ; ---------------------------------------------------------------------------
.text:000000710283EB74
.text:000000710283EB74 loc_710283EB74 ; CODE XREF: apply_damage_effectiveness_modifier+20↑j
.text:000000710283EB74 ; DATA XREF: apply_damage_effectiveness_modifier+14↑o
.text:000000710283EB74 MOV W8, #0x3ECCCCCD ; jumptable 000000710283EB70 cases 1-5
.text:000000710283EB7C FMOV S1, W8
.text:000000710283EB80 UCVTF S0, W0
.text:000000710283EB84 B loc_710283EB90
.text:000000710283EB88 ; ---------------------------------------------------------------------------
.text:000000710283EB88
.text:000000710283EB88 loc_710283EB88 ; CODE XREF: apply_damage_effectiveness_modifier+20↑j
.text:000000710283EB88 UCVTF S0, W0 ; jumptable 000000710283EB70 cases 9-13
.text:000000710283EB8C FMOV S1, #2.5
.text:000000710283EB90
.text:000000710283EB90 loc_710283EB90 ; CODE XREF: apply_damage_effectiveness_modifier+34↑j
.text:000000710283EB90 ; apply_damage_effectiveness_modifier+64↓j
.text:000000710283EB90 FMUL S0, S0, S1
.text:000000710283EB94 FCVTZU W1, S0
.text:000000710283EB98 MOV W0, W1
.text:000000710283EB9C RET
.text:000000710283EBA0 ; ---------------------------------------------------------------------------
.text:000000710283EBA0
.text:000000710283EBA0 def_710283EB70 ; CODE XREF: apply_damage_effectiveness_modifier+4↑j
.text:000000710283EBA0 ; apply_damage_effectiveness_modifier+20↑j
.text:000000710283EBA0 MOV W1, W0 ; jumptable 000000710283EB70 default case, case 7
.text:000000710283EBA4
.text:000000710283EBA4 loc_710283EBA4 ; CODE XREF: apply_damage_effectiveness_modifier+20↑j
.text:000000710283EBA4 MOV W0, W1 ; jumptable 000000710283EB70 case 0
.text:000000710283EBA8 RET
.text:000000710283EBAC ; ---------------------------------------------------------------------------
.text:000000710283EBAC
.text:000000710283EBAC loc_710283EBAC ; CODE XREF: apply_damage_effectiveness_modifier+20↑j
.text:000000710283EBAC UCVTF S0, W0 ; jumptable 000000710283EB70 case 6
.text:000000710283EBB0 FMOV S1, #0.5
.text:000000710283EBB4 B loc_710283EB90
.text:000000710283EBB8 ; ---------------------------------------------------------------------------
.text:000000710283EBB8
.text:000000710283EBB8 loc_710283EBB8 ; CODE XREF: apply_damage_effectiveness_modifier+20↑j
.text:000000710283EBB8 LSL W1, W0, #1 ; jumptable 000000710283EB70 case 8
.text:000000710283EBBC MOV W0, W1
.text:000000710283EBC0 RET
.text:000000710283EBC0 ; End of function apply_damage_effectiveness_modifier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment