disaptch_damage_event_actor (#994)

This commit is contained in:
Ethan Roseman 2023-03-23 15:44:58 +09:00 committed by GitHub
parent b8169491a4
commit 6efc4afac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 173 deletions

View File

@ -810,35 +810,35 @@ HitResult calc_enemy_damage_target(Actor* attacker) {
return hitResult; return hitResult;
} }
// missing one move, not equivalent
#ifdef NON_EQUIVALENT
s32 dispatch_damage_event_actor(Actor* actor, s32 damageAmount, s32 originalEvent, s32 stopMotion) { s32 dispatch_damage_event_actor(Actor* actor, s32 damageAmount, s32 originalEvent, s32 stopMotion) {
BattleStatus* battleStatus = &gBattleStatus; BattleStatus* battleStatus = &gBattleStatus;
ActorState* state; ActorState* state = &actor->state;
s32 dispatchEvent = originalEvent; s32 dispatchEvent = originalEvent;
s32 currentAttackDamage; s32 currentAttackDamage;
s32 hpChangeCounter; s32 hpChangeCounter;
s32 hpChange;
s32 flagCheck;
s32 new_var;
battleStatus->currentAttackDamage = damageAmount; battleStatus->currentAttackDamage = damageAmount;
currentAttackDamage = battleStatus->currentAttackDamage; hpChange = (s16) damageAmount;
actor->hpChangeCounter += hpChange;
actor->hpChangeCounter += currentAttackDamage; new_var = actor->hpChangeCounter;
hpChangeCounter = actor->hpChangeCounter; hpChange = new_var;
actor->damageCounter += hpChangeCounter; actor->damageCounter += hpChange;
actor->hpChangeCounter -= hpChangeCounter; actor->hpChangeCounter -= hpChange;
battleStatus->lastAttackDamage = 0; battleStatus->lastAttackDamage = 0;
do { } while (0); actor->currentHP -= hpChange;
actor->currentHP -= hpChangeCounter;
state = &actor->state;
if (actor->currentHP <= 0) { if (actor->currentHP <= 0) {
dispatchEvent = EVENT_DEATH; dispatchEvent = EVENT_DEATH;
battleStatus->lastAttackDamage += actor->currentHP; battleStatus->lastAttackDamage += actor->currentHP;
actor->currentHP = 0; actor->currentHP = 0;
} }
battleStatus->lastAttackDamage += currentAttackDamage;
battleStatus->lastAttackDamage += hpChange;
actor->lastDamageTaken = battleStatus->lastAttackDamage; actor->lastDamageTaken = battleStatus->lastAttackDamage;
battleStatus->unk_19A = 0; battleStatus->unk_19A = 0;
if (battleStatus->flags1 & BS_FLAGS1_SP_EVT_ACTIVE) { if (battleStatus->flags1 & BS_FLAGS1_SP_EVT_ACTIVE) {
if (dispatchEvent == EVENT_HIT_COMBO) { if (dispatchEvent == EVENT_HIT_COMBO) {
dispatchEvent = EVENT_HIT; dispatchEvent = EVENT_HIT;
@ -856,7 +856,7 @@ s32 dispatch_damage_event_actor(Actor* actor, s32 damageAmount, s32 originalEven
} }
} }
if (stopMotion == 0) { if (!stopMotion) {
s32 oldTargetActorID = actor->targetActorID; s32 oldTargetActorID = actor->targetActorID;
if (func_80263230(actor, actor) != 0) { if (func_80263230(actor, actor) != 0) {
@ -878,10 +878,6 @@ s32 dispatch_damage_event_actor(Actor* actor, s32 damageAmount, s32 originalEven
dispatch_event_actor(actor, dispatchEvent); dispatch_event_actor(actor, dispatchEvent);
return 0; return 0;
} }
#else
s32 dispatch_damage_event_actor(Actor* actor, s32 damageAmount, s32 originalEvent, s32 stopMotion);
INCLUDE_ASM(s32, "1A5830", dispatch_damage_event_actor);
#endif
s32 dispatch_damage_event_actor_0(Actor* actor, s32 damageAmount, s32 event) { s32 dispatch_damage_event_actor_0(Actor* actor, s32 damageAmount, s32 event) {
return dispatch_damage_event_actor(actor, damageAmount, event, FALSE); return dispatch_damage_event_actor(actor, damageAmount, event, FALSE);

View File

@ -896,7 +896,6 @@ s32 dispatch_damage_event_partner(s32 damageAmount, s32 event, s32 stopMotion) {
ActorState* state = &partner->state; ActorState* state = &partner->state;
s32 hpChange; s32 hpChange;
s32 flagCheck; s32 flagCheck;
s32 oldHP;
battleStatus->currentAttackDamage = damageAmount; battleStatus->currentAttackDamage = damageAmount;
@ -909,12 +908,10 @@ s32 dispatch_damage_event_partner(s32 damageAmount, s32 event, s32 stopMotion) {
partner->hpChangeCounter -= hpChange; partner->hpChangeCounter -= hpChange;
battleStatus->lastAttackDamage = 0; battleStatus->lastAttackDamage = 0;
partner->currentHP -= hpChange; partner->currentHP -= hpChange;
oldHP = partner->currentHP;
if (partner->currentHP <= 0) {
if (partner->currentHP < 1) {
event = EVENT_DEATH; event = EVENT_DEATH;
battleStatus->lastAttackDamage += oldHP; battleStatus->lastAttackDamage += partner->currentHP;
partner->currentHP = 0; partner->currentHP = 0;
} }

View File

@ -1,149 +0,0 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
glabel dispatch_damage_event_actor
/* 1A6FB4 802786D4 27BDFFD0 */ addiu $sp, $sp, -0x30
/* 1A6FB8 802786D8 AFB00018 */ sw $s0, 0x18($sp)
/* 1A6FBC 802786DC 0080802D */ daddu $s0, $a0, $zero
/* 1A6FC0 802786E0 AFB20020 */ sw $s2, 0x20($sp)
/* 1A6FC4 802786E4 00C0902D */ daddu $s2, $a2, $zero
/* 1A6FC8 802786E8 AFB30024 */ sw $s3, 0x24($sp)
/* 1A6FCC 802786EC 3C13800E */ lui $s3, %hi(gBattleStatus)
/* 1A6FD0 802786F0 2673C070 */ addiu $s3, $s3, %lo(gBattleStatus)
/* 1A6FD4 802786F4 AFBF0028 */ sw $ra, 0x28($sp)
/* 1A6FD8 802786F8 AFB1001C */ sw $s1, 0x1c($sp)
/* 1A6FDC 802786FC A665017E */ sh $a1, 0x17e($s3)
/* 1A6FE0 80278700 00052C00 */ sll $a1, $a1, 0x10
/* 1A6FE4 80278704 00052C03 */ sra $a1, $a1, 0x10
/* 1A6FE8 80278708 960301FA */ lhu $v1, 0x1fa($s0)
/* 1A6FEC 8027870C 960201FC */ lhu $v0, 0x1fc($s0)
/* 1A6FF0 80278710 00651821 */ addu $v1, $v1, $a1
/* 1A6FF4 80278714 A60301FA */ sh $v1, 0x1fa($s0)
/* 1A6FF8 80278718 00031C00 */ sll $v1, $v1, 0x10
/* 1A6FFC 8027871C 00031C03 */ sra $v1, $v1, 0x10
/* 1A7000 80278720 960401FA */ lhu $a0, 0x1fa($s0)
/* 1A7004 80278724 00431021 */ addu $v0, $v0, $v1
/* 1A7008 80278728 A60201FC */ sh $v0, 0x1fc($s0)
/* 1A700C 8027872C 00832023 */ subu $a0, $a0, $v1
/* 1A7010 80278730 A60401FA */ sh $a0, 0x1fa($s0)
/* 1A7014 80278734 A6600180 */ sh $zero, 0x180($s3)
/* 1A7018 80278738 920201B8 */ lbu $v0, 0x1b8($s0)
/* 1A701C 8027873C 0060282D */ daddu $a1, $v1, $zero
/* 1A7020 80278740 00451023 */ subu $v0, $v0, $a1
/* 1A7024 80278744 A20201B8 */ sb $v0, 0x1b8($s0)
/* 1A7028 80278748 00021600 */ sll $v0, $v0, 0x18
/* 1A702C 8027874C 00021E03 */ sra $v1, $v0, 0x18
/* 1A7030 80278750 1C600006 */ bgtz $v1, .L8027876C
/* 1A7034 80278754 2611000C */ addiu $s1, $s0, 0xc
/* 1A7038 80278758 96620180 */ lhu $v0, 0x180($s3)
/* 1A703C 8027875C 24120020 */ addiu $s2, $zero, 0x20
/* 1A7040 80278760 00431021 */ addu $v0, $v0, $v1
/* 1A7044 80278764 A6620180 */ sh $v0, 0x180($s3)
/* 1A7048 80278768 A20001B8 */ sb $zero, 0x1b8($s0)
.L8027876C:
/* 1A704C 8027876C 96620180 */ lhu $v0, 0x180($s3)
/* 1A7050 80278770 00451021 */ addu $v0, $v0, $a1
/* 1A7054 80278774 A6620180 */ sh $v0, 0x180($s3)
/* 1A7058 80278778 A60201F8 */ sh $v0, 0x1f8($s0)
/* 1A705C 8027877C 8E620000 */ lw $v0, ($s3)
/* 1A7060 80278780 30420020 */ andi $v0, $v0, 0x20
/* 1A7064 80278784 10400007 */ beqz $v0, .L802787A4
/* 1A7068 80278788 A260019A */ sb $zero, 0x19a($s3)
/* 1A706C 8027878C 24020009 */ addiu $v0, $zero, 9
/* 1A7070 80278790 52420001 */ beql $s2, $v0, .L80278798
/* 1A7074 80278794 2412000A */ addiu $s2, $zero, 0xa
.L80278798:
/* 1A7078 80278798 24020017 */ addiu $v0, $zero, 0x17
/* 1A707C 8027879C 52420001 */ beql $s2, $v0, .L802787A4
/* 1A7080 802787A0 24120019 */ addiu $s2, $zero, 0x19
.L802787A4:
/* 1A7084 802787A4 24020020 */ addiu $v0, $zero, 0x20
/* 1A7088 802787A8 16420006 */ bne $s2, $v0, .L802787C4
/* 1A708C 802787AC 24020011 */ addiu $v0, $zero, 0x11
/* 1A7090 802787B0 50C20001 */ beql $a2, $v0, .L802787B8
/* 1A7094 802787B4 24120025 */ addiu $s2, $zero, 0x25
.L802787B8:
/* 1A7098 802787B8 2402002F */ addiu $v0, $zero, 0x2f
/* 1A709C 802787BC 50C20001 */ beql $a2, $v0, .L802787C4
/* 1A70A0 802787C0 24120026 */ addiu $s2, $zero, 0x26
.L802787C4:
/* 1A70A4 802787C4 54E0002C */ bnel $a3, $zero, .L80278878
/* 1A70A8 802787C8 AFA00010 */ sw $zero, 0x10($sp)
/* 1A70AC 802787CC 0200202D */ daddu $a0, $s0, $zero
/* 1A70B0 802787D0 86110428 */ lh $s1, 0x428($s0)
/* 1A70B4 802787D4 0C098C8C */ jal func_80263230
/* 1A70B8 802787D8 0200282D */ daddu $a1, $s0, $zero
/* 1A70BC 802787DC 50400032 */ beql $v0, $zero, .L802788A8
/* 1A70C0 802787E0 A6110428 */ sh $s1, 0x428($s0)
/* 1A70C4 802787E4 86020230 */ lh $v0, 0x230($s0)
/* 1A70C8 802787E8 86030232 */ lh $v1, 0x232($s0)
/* 1A70CC 802787EC 86040234 */ lh $a0, 0x234($s0)
/* 1A70D0 802787F0 AFA00010 */ sw $zero, 0x10($sp)
/* 1A70D4 802787F4 86670180 */ lh $a3, 0x180($s3)
/* 1A70D8 802787F8 44826000 */ mtc1 $v0, $f12
/* 1A70DC 802787FC 00000000 */ nop
/* 1A70E0 80278800 46806320 */ cvt.s.w $f12, $f12
/* 1A70E4 80278804 44840000 */ mtc1 $a0, $f0
/* 1A70E8 80278808 00000000 */ nop
/* 1A70EC 8027880C 46800020 */ cvt.s.w $f0, $f0
/* 1A70F0 80278810 44060000 */ mfc1 $a2, $f0
/* 1A70F4 80278814 44837000 */ mtc1 $v1, $f14
/* 1A70F8 80278818 00000000 */ nop
/* 1A70FC 8027881C 0C09996B */ jal show_damage_popup
/* 1A7100 80278820 468073A0 */ cvt.s.w $f14, $f14
/* 1A7104 80278824 86020230 */ lh $v0, 0x230($s0)
/* 1A7108 80278828 86030232 */ lh $v1, 0x232($s0)
/* 1A710C 8027882C 44820000 */ mtc1 $v0, $f0
/* 1A7110 80278830 00000000 */ nop
/* 1A7114 80278834 46800020 */ cvt.s.w $f0, $f0
/* 1A7118 80278838 44050000 */ mfc1 $a1, $f0
/* 1A711C 8027883C 44830000 */ mtc1 $v1, $f0
/* 1A7120 80278840 00000000 */ nop
/* 1A7124 80278844 46800020 */ cvt.s.w $f0, $f0
/* 1A7128 80278848 44060000 */ mfc1 $a2, $f0
/* 1A712C 8027884C 86020234 */ lh $v0, 0x234($s0)
/* 1A7130 80278850 86630180 */ lh $v1, 0x180($s3)
/* 1A7134 80278854 44820000 */ mtc1 $v0, $f0
/* 1A7138 80278858 00000000 */ nop
/* 1A713C 8027885C 46800020 */ cvt.s.w $f0, $f0
/* 1A7140 80278860 44070000 */ mfc1 $a3, $f0
/* 1A7144 80278864 0200202D */ daddu $a0, $s0, $zero
/* 1A7148 80278868 0C0999B9 */ jal func_802666E4
/* 1A714C 8027886C AFA30010 */ sw $v1, 0x10($sp)
/* 1A7150 80278870 0809E22A */ j .L802788A8
/* 1A7154 80278874 A6110428 */ sh $s1, 0x428($s0)
.L80278878:
/* 1A7158 80278878 C62C000C */ lwc1 $f12, 0xc($s1)
/* 1A715C 8027887C C62E0010 */ lwc1 $f14, 0x10($s1)
/* 1A7160 80278880 86670180 */ lh $a3, 0x180($s3)
/* 1A7164 80278884 0C09996B */ jal show_damage_popup
/* 1A7168 80278888 8E260014 */ lw $a2, 0x14($s1)
/* 1A716C 8027888C 86620180 */ lh $v0, 0x180($s3)
/* 1A7170 80278890 AFA20010 */ sw $v0, 0x10($sp)
/* 1A7174 80278894 8E25000C */ lw $a1, 0xc($s1)
/* 1A7178 80278898 8E260010 */ lw $a2, 0x10($s1)
/* 1A717C 8027889C 8E270014 */ lw $a3, 0x14($s1)
/* 1A7180 802788A0 0C0999B9 */ jal func_802666E4
/* 1A7184 802788A4 0200202D */ daddu $a0, $s0, $zero
.L802788A8:
/* 1A7188 802788A8 86620180 */ lh $v0, 0x180($s3)
/* 1A718C 802788AC 18400003 */ blez $v0, .L802788BC
/* 1A7190 802788B0 0200202D */ daddu $a0, $s0, $zero
/* 1A7194 802788B4 0C099C06 */ jal func_80267018
/* 1A7198 802788B8 24050001 */ addiu $a1, $zero, 1
.L802788BC:
/* 1A719C 802788BC 0200202D */ daddu $a0, $s0, $zero
/* 1A71A0 802788C0 0240282D */ daddu $a1, $s2, $zero
/* 1A71A4 802788C4 8C820000 */ lw $v0, ($a0)
/* 1A71A8 802788C8 3C030008 */ lui $v1, 8
/* 1A71AC 802788CC 00431025 */ or $v0, $v0, $v1
/* 1A71B0 802788D0 0C09DC58 */ jal dispatch_event_actor
/* 1A71B4 802788D4 AC820000 */ sw $v0, ($a0)
/* 1A71B8 802788D8 8FBF0028 */ lw $ra, 0x28($sp)
/* 1A71BC 802788DC 8FB30024 */ lw $s3, 0x24($sp)
/* 1A71C0 802788E0 8FB20020 */ lw $s2, 0x20($sp)
/* 1A71C4 802788E4 8FB1001C */ lw $s1, 0x1c($sp)
/* 1A71C8 802788E8 8FB00018 */ lw $s0, 0x18($sp)
/* 1A71CC 802788EC 0000102D */ daddu $v0, $zero, $zero
/* 1A71D0 802788F0 03E00008 */ jr $ra
/* 1A71D4 802788F4 27BD0030 */ addiu $sp, $sp, 0x30