Merge pull request #404 from octorock/cloudPiranha

This commit is contained in:
notyourav 2022-02-23 18:37:55 -08:00 committed by GitHub
commit b712657613
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 348 additions and 645 deletions

View File

@ -1,612 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.syntax unified
.text
thumb_func_start CloudPiranha
CloudPiranha: @ 0x08038430
push {r4, lr}
adds r4, r0, #0
ldr r1, _0803844C @ =gUnk_080CF4F0
bl EnemyFunctionHandler
movs r3, #0x10
rsbs r3, r3, #0
adds r0, r4, #0
movs r1, #0
movs r2, #1
bl SetChildOffset
pop {r4, pc}
.align 2, 0
_0803844C: .4byte gUnk_080CF4F0
thumb_func_start sub_08038450
sub_08038450: @ 0x08038450
push {lr}
ldr r2, _08038464 @ =gUnk_080CF508
ldrb r1, [r0, #0xc]
lsls r1, r1, #2
adds r1, r1, r2
ldr r1, [r1]
bl _call_via_r1
pop {pc}
.align 2, 0
_08038464: .4byte gUnk_080CF508
thumb_func_start sub_08038468
sub_08038468: @ 0x08038468
push {r4, lr}
adds r4, r0, #0
adds r0, #0x43
ldrb r0, [r0]
cmp r0, #0
beq _0803847C
adds r0, r4, #0
movs r1, #0x1c
bl Create0x68FX
_0803847C:
ldr r1, _080384B0 @ =gUnk_080CF4F0
adds r0, r4, #0
bl EnemyFunctionHandlerAfterCollision
adds r0, r4, #0
adds r0, #0x41
ldrb r1, [r0]
movs r0, #0x80
ands r0, r1
cmp r0, #0
beq _080384D8
adds r0, r4, #0
adds r0, #0x3f
ldrb r0, [r0]
cmp r0, #0x5a
bne _080384CA
movs r0, #0x3f
ands r0, r1
cmp r0, #0x14
beq _080384BA
cmp r0, #0x14
bgt _080384B4
cmp r0, #0xe
beq _080384C0
b _080384D8
.align 2, 0
_080384B0: .4byte gUnk_080CF4F0
_080384B4:
cmp r0, #0x15
beq _080384C0
b _080384D8
_080384BA:
movs r0, #5
strb r0, [r4, #0xc]
b _080384D8
_080384C0:
adds r1, r4, #0
adds r1, #0x45
movs r0, #0
strb r0, [r1]
.ifdef EU
_080384CA: @TODO fix labels
.else
b _080384D8
_080384CA:
movs r0, #0x3f
ands r0, r1
cmp r0, #0x1d
bne _080384D8
adds r0, r4, #0
bl sub_08038754
.endif
_080384D8:
pop {r4, pc}
.align 2, 0
thumb_func_start nullsub_163
nullsub_163: @ 0x080384DC
bx lr
.align 2, 0
thumb_func_start sub_080384E0
sub_080384E0: @ 0x080384E0
push {r4, r5, r6, lr}
adds r6, r0, #0
bl sub_0804A720
movs r4, #0
movs r5, #1
movs r0, #1
strb r0, [r6, #0xc]
bl Random
movs r1, #0x1c
ands r0, r1
strb r0, [r6, #0x15]
lsrs r0, r0, #2
strb r0, [r6, #0x14]
ldrb r1, [r6, #0x10]
movs r0, #0x80
orrs r0, r1
strb r0, [r6, #0x10]
strb r4, [r6, #0xe]
movs r0, #0x20
strb r0, [r6, #0xf]
adds r0, r6, #0
adds r0, #0x82
strb r4, [r0]
bl Random
ands r0, r5
adds r1, r6, #0
adds r1, #0x80
strb r0, [r1]
adds r0, r6, #0
adds r0, #0x81
strb r4, [r0]
subs r1, #0x41
movs r0, #0x72
strb r0, [r1]
ldrb r1, [r6, #0x14]
adds r0, r6, #0
bl InitializeAnimation
pop {r4, r5, r6, pc}
thumb_func_start sub_08038534
sub_08038534: @ 0x08038534
push {r4, lr}
adds r4, r0, #0
bl sub_080387F0
ldrb r0, [r4, #0xf]
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
lsrs r0, r0, #0x18
cmp r0, #0
bne _08038594
strb r0, [r4, #0xe]
movs r0, #0x20
strb r0, [r4, #0xf]
adds r0, r4, #0
bl sub_08049FA0
cmp r0, #0
beq _08038578
ldrb r1, [r4, #0x14]
adds r0, r4, #0
adds r0, #0x80
ldrb r0, [r0]
cmp r0, #0
beq _0803856A
adds r1, #7
b _0803856C
_0803856A:
adds r1, #1
_0803856C:
movs r0, #7
ands r0, r1
strb r0, [r4, #0x14]
lsls r0, r0, #2
strb r0, [r4, #0x15]
b _0803858A
_08038578:
adds r0, r4, #0
bl sub_08049EE4
adds r0, #2
movs r1, #0x1c
ands r0, r1
strb r0, [r4, #0x15]
lsrs r0, r0, #2
strb r0, [r4, #0x14]
_0803858A:
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
b _080385C8
_08038594:
ldrb r0, [r4, #0xe]
cmp r0, #0
bne _080385C8
adds r0, r4, #0
movs r1, #0x80
bl sub_0803872C
cmp r0, #0
beq _080385C8
movs r0, #2
strb r0, [r4, #0xc]
movs r0, #0x10
strb r0, [r4, #0xf]
movs r0, #0x40
strh r0, [r4, #0x24]
ldr r1, [r4, #0x54]
adds r0, r4, #0
bl sub_0806FCAC
strb r0, [r4, #0x14]
lsls r0, r0, #2
strb r0, [r4, #0x15]
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
_080385C8:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_080385CC
sub_080385CC: @ 0x080385CC
push {r4, r5, r6, lr}
adds r4, r0, #0
bl sub_080387F0
adds r0, r4, #0
movs r1, #0x60
bl sub_0803872C
cmp r0, #0
beq _08038604
movs r0, #3
strb r0, [r4, #0xc]
movs r0, #0xc
strb r0, [r4, #0xf]
movs r0, #0x80
strh r0, [r4, #0x24]
ldr r1, [r4, #0x54]
adds r0, r4, #0
bl sub_0806FCAC
strb r0, [r4, #0x14]
lsls r0, r0, #2
strb r0, [r4, #0x15]
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
b _08038648
_08038604:
ldrb r0, [r4, #0xf]
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
cmp r0, #0
bne _08038648
movs r6, #0x10
strb r6, [r4, #0xf]
ldr r1, [r4, #0x54]
cmp r1, #0
beq _08038622
adds r0, r4, #0
bl sub_0806FCAC
b _08038638
_08038622:
ldrb r5, [r4, #0x14]
bl Random
ands r0, r6
cmp r0, #0
beq _08038632
adds r1, r5, #2
b _08038634
_08038632:
adds r1, r5, #6
_08038634:
movs r0, #7
ands r0, r1
_08038638:
strb r0, [r4, #0x14]
ldrb r0, [r4, #0x14]
lsls r0, r0, #2
strb r0, [r4, #0x15]
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
_08038648:
pop {r4, r5, r6, pc}
.align 2, 0
thumb_func_start sub_0803864C
sub_0803864C: @ 0x0803864C
push {r4, lr}
adds r4, r0, #0
bl sub_080387F0
adds r0, r4, #0
movs r1, #0x14
bl sub_0803872C
cmp r0, #0
beq _08038668
adds r0, r4, #0
bl sub_08038754
b _080386B4
_08038668:
ldrb r0, [r4, #0xf]
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
cmp r0, #0
bne _080386B4
movs r0, #0xa
strb r0, [r4, #0xf]
adds r2, r4, #0
adds r2, #0x81
ldrb r0, [r2]
cmp r0, #0
bne _08038698
ldrh r0, [r4, #0x24]
adds r0, #0x40
strh r0, [r4, #0x24]
lsls r0, r0, #0x10
movs r1, #0x80
lsls r1, r1, #0x12
cmp r0, r1
ble _080386B4
movs r0, #1
strb r0, [r2]
b _080386B4
_08038698:
ldrh r2, [r4, #0x24]
movs r0, #0x24
ldrsh r1, [r4, r0]
movs r0, #0x80
lsls r0, r0, #1
cmp r1, r0
ble _080386AE
adds r0, r2, #0
subs r0, #0x50
strh r0, [r4, #0x24]
b _080386B4
_080386AE:
adds r0, r4, #0
bl sub_08038754
_080386B4:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_080386B8
sub_080386B8: @ 0x080386B8
push {r4, lr}
adds r4, r0, #0
bl sub_080387F0
movs r1, #0xc0
lsls r1, r1, #5
adds r0, r4, #0
bl sub_080044EC
adds r1, r0, #0
cmp r1, #1
bne _08038720
strb r1, [r4, #0xc]
adds r2, r4, #0
adds r2, #0x3f
movs r0, #0x72
strb r0, [r2]
strb r1, [r4, #0xe]
movs r0, #0x80
strb r0, [r4, #0xf]
strh r0, [r4, #0x24]
subs r2, #0x16
ldrb r1, [r2]
subs r0, #0xb9
ands r0, r1
movs r1, #0x10
orrs r0, r1
strb r0, [r2]
movs r0, #0x92
lsls r0, r0, #1
bl EnqueueSFX
adds r0, r4, #0
movs r1, #0x70
bl ChangeObjPalette
ldrb r1, [r4, #0x15]
lsrs r1, r1, #2
adds r0, r4, #0
bl InitializeAnimation
adds r0, r4, #0
movs r1, #2
movs r2, #0
bl CreateFx
adds r1, r0, #0
cmp r1, #0
beq _08038720
adds r0, r4, #0
bl SortEntityAbove
_08038720:
pop {r4, pc}
.align 2, 0
thumb_func_start sub_08038724
sub_08038724: @ 0x08038724
push {lr}
bl sub_08038754
pop {pc}
thumb_func_start sub_0803872C
sub_0803872C: @ 0x0803872C
push {r4, r5, lr}
adds r4, r0, #0
adds r5, r1, #0
movs r0, #1
bl sub_08049DF4
adds r1, r0, #0
str r1, [r4, #0x54]
cmp r1, #0
beq _08038750
adds r0, r4, #0
adds r2, r5, #0
bl sub_0806FC80
cmp r0, #0
beq _08038750
movs r0, #1
b _08038752
_08038750:
movs r0, #0
_08038752:
pop {r4, r5, pc}
thumb_func_start sub_08038754
sub_08038754: @ 0x08038754
push {r4, lr}
adds r4, r0, #0
movs r0, #4
strb r0, [r4, #0xc]
ldrb r1, [r4, #0x10]
movs r0, #0x80
orrs r0, r1
strb r0, [r4, #0x10]
adds r1, r4, #0
adds r1, #0x3f
movs r0, #0x5a
strb r0, [r1]
movs r1, #0
.ifdef EU
adds r0, #0xa6
.else
movs r0, #0xc0
.endif
strh r0, [r4, #0x24]
movs r0, #0x80
lsls r0, r0, #0xa
str r0, [r4, #0x20]
adds r0, r4, #0
adds r0, #0x81
strb r1, [r0]
adds r2, r4, #0
adds r2, #0x29
ldrb r1, [r2]
movs r0, #0x39
rsbs r0, r0, #0
ands r0, r1
movs r1, #0x18
orrs r0, r1
strb r0, [r2]
ldr r0, _080387C0 @ =0x0000012B
bl EnqueueSFX
adds r0, r4, #0
movs r1, #0x71
bl ChangeObjPalette
ldrb r2, [r4, #0x15]
movs r0, #0xf
ands r0, r2
cmp r0, #0
beq _080387C4
movs r1, #0x10
ands r1, r2
lsls r1, r1, #0x18
lsrs r1, r1, #0x1b
lsls r1, r1, #0x18
lsrs r1, r1, #0x18
adds r1, #9
adds r0, r4, #0
bl InitializeAnimation
b _080387D8
.align 2, 0
_080387C0: .4byte 0x0000012B
_080387C4:
movs r1, #0x10
ands r1, r2
lsls r1, r1, #0x18
lsrs r1, r1, #0x1b
lsls r1, r1, #0x18
lsrs r1, r1, #0x18
adds r1, #8
adds r0, r4, #0
bl InitializeAnimation
_080387D8:
adds r0, r4, #0
movs r1, #2
movs r2, #0
bl CreateFx
adds r1, r0, #0
cmp r1, #0
beq _080387EE
adds r0, r4, #0
bl SortEntityAbove
_080387EE:
pop {r4, pc}
thumb_func_start sub_080387F0
sub_080387F0: @ 0x080387F0
push {r4, r5, r6, lr}
adds r4, r0, #0
ldrb r0, [r4, #0xc]
cmp r0, #4
beq _08038890
adds r5, r4, #0
adds r5, #0x82
ldrb r0, [r5]
cmp r0, #0
bne _08038890
movs r1, #0x2e
ldrsh r0, [r4, r1]
ldr r2, _08038868 @ =gRoomControls
ldrh r1, [r2, #6]
subs r0, r0, r1
asrs r0, r0, #4
movs r3, #0x3f
ands r0, r3
movs r6, #0x32
ldrsh r1, [r4, r6]
ldrh r2, [r2, #8]
subs r1, r1, r2
asrs r1, r1, #4
ands r1, r3
lsls r1, r1, #6
orrs r0, r1
adds r1, r4, #0
adds r1, #0x38
ldrb r1, [r1]
bl sub_080002E0
cmp r0, #0xf
beq _08038836
cmp r0, #0x2a
bne _0803883A
_08038836:
movs r0, #0x20
strb r0, [r5]
_0803883A:
ldrb r0, [r4, #0x15]
lsrs r0, r0, #1
ldr r1, _0803886C @ =gUnk_080CF520
adds r0, r0, r1
ldrb r5, [r4, #0x15]
movs r1, #0
ldrsb r1, [r0, r1]
movs r2, #1
ldrsb r2, [r0, r2]
adds r0, r4, #0
bl sub_080002CC
cmp r0, #0xf
beq _0803885A
cmp r0, #0x2a
bne _08038870
_0803885A:
ldrb r0, [r4, #0x15]
adds r0, #0x10
movs r1, #0x1f
ands r0, r1
strb r0, [r4, #0x15]
b _0803887E
.align 2, 0
_08038868: .4byte gRoomControls
_0803886C: .4byte gUnk_080CF520
_08038870:
ldrh r0, [r4, #0x2a]
cmp r0, #0
beq _0803887E
adds r1, r0, #0
adds r0, r4, #0
bl sub_0800417E
_0803887E:
ldrb r0, [r4, #0x15]
cmp r5, r0
beq _08038890
lsrs r0, r0, #2
strb r0, [r4, #0x14]
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
_08038890:
adds r0, r4, #0
bl GetNextFrame
adds r1, r4, #0
adds r1, #0x82
ldrb r0, [r1]
cmp r0, #0
bne _080388A8
adds r0, r4, #0
bl ProcessMovement0
b _080388B2
_080388A8:
subs r0, #1
strb r0, [r1]
adds r0, r4, #0
bl LinearMoveUpdate
_080388B2:
pop {r4, r5, r6, pc}

View File

@ -0,0 +1,65 @@
.syntax unified
push {r4, r5, r6, lr}
adds r4, r0, #0
bl sub_080387F0
adds r0, r4, #0
movs r1, #0x60
bl sub_0803872C
cmp r0, #0
beq _08038604
movs r0, #3
strb r0, [r4, #0xc]
movs r0, #0xc
strb r0, [r4, #0xf]
movs r0, #0x80
strh r0, [r4, #0x24]
ldr r1, [r4, #0x54]
adds r0, r4, #0
bl sub_0806FCAC
strb r0, [r4, #0x14]
lsls r0, r0, #2
strb r0, [r4, #0x15]
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
b _08038648
_08038604:
ldrb r0, [r4, #0xf]
subs r0, #1
strb r0, [r4, #0xf]
lsls r0, r0, #0x18
cmp r0, #0
bne _08038648
movs r6, #0x10
strb r6, [r4, #0xf]
ldr r1, [r4, #0x54]
cmp r1, #0
beq _08038622
adds r0, r4, #0
bl sub_0806FCAC
b _08038638
_08038622:
ldrb r5, [r4, #0x14]
bl Random
ands r0, r6
cmp r0, #0
beq _08038632
adds r1, r5, #2
b _08038634
_08038632:
adds r1, r5, #6
_08038634:
movs r0, #7
ands r0, r1
_08038638:
strb r0, [r4, #0x14]
ldrb r0, [r4, #0x14]
lsls r0, r0, #2
strb r0, [r4, #0x15]
ldrb r1, [r4, #0x14]
adds r0, r4, #0
bl InitializeAnimation
_08038648:
pop {r4, r5, r6, pc}
.align 2, 0
.syntax divided

View File

@ -26184,11 +26184,6 @@
"size": 13,
"type": "animation"
},
{
"path": "cloudPiranha/gUnk_080CF520.bin",
"start": 849184,
"size": 16
},
{
"path": "animations/gSpriteAnimations_ScissorsBeetle_0.bin",
"start": 849476,

View File

@ -1,24 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2
gUnk_080CF4F0:: @ 080CF4F0
.4byte sub_08038450
.4byte sub_08038468
.4byte GenericKnockback
.4byte GenericDeath
.4byte GenericConfused
.4byte nullsub_163
gUnk_080CF508:: @ 080CF508
.4byte sub_080384E0
.4byte sub_08038534
.4byte sub_080385CC
.4byte sub_0803864C
.4byte sub_080386B8
.4byte sub_08038724
gUnk_080CF520:: @ 080CF520
.incbin "cloudPiranha/gUnk_080CF520.bin"

View File

@ -19,8 +19,8 @@ u32 sub_0806F5A4(u32 idx);
u32 sub_0806F3E4(Entity*);
void LinearMoveUpdate(Entity*);
bool32 sub_0806FD54(Entity*);
u32 sub_0806FCAC(Entity*, Entity*);
extern const s16 gSineTable[64];
extern const s16 gCosineTable[256];
#endif

View File

@ -196,7 +196,7 @@ void Gibdo(Entity*);
void OctorokGolden(Entity*);
void TektiteGolden(Entity*);
void RopeGolden(Entity*);
void CloudPiranha(Entity*);
void CloudPiranha();
void ScissorsBeetle(Entity*);
void CuccoAggr(Entity*);
void Stalfos();

View File

@ -387,7 +387,7 @@ SECTIONS {
src/enemy/octorokGolden.o(.text);
src/enemy/tektiteGolden.o(.text);
src/enemy/ropeGolden.o(.text);
asm/enemy/cloudPiranha.o(.text);
src/enemy/cloudPiranha.o(.text);
src/enemy/scissorsBeetle.o(.text);
src/enemy/cuccoAggr.o(.text);
src/enemy/stalfos.o(.text);
@ -1049,7 +1049,7 @@ SECTIONS {
src/enemy/octorokGolden.o(.rodata);
data/const/enemy/tektiteGolden.o(.rodata);
data/const/enemy/ropeGolden.o(.rodata);
data/const/enemy/cloudPiranha.o(.rodata);
src/enemy/cloudPiranha.o(.rodata);
data/animations/enemy/cloudPiranha.o(.rodata);
src/enemy/scissorsBeetle.o(.rodata);
data/animations/enemy/scissorsBeetle.o(.rodata);

279
src/enemy/cloudPiranha.c Normal file
View File

@ -0,0 +1,279 @@
/**
* @file cloudPiranha.c
* @ingroup Enemies
*
* @brief Cloud Piranha enemy
*/
#define NENT_DEPRECATED
#include "global.h"
#include "enemy.h"
#include "functions.h"
#include "coord.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unk_68[0x18];
/*0x80*/ u8 unk_80;
/*0x81*/ u8 unk_81;
/*0x82*/ u8 unk_82;
} CloudPiranhaEntity;
void sub_08038754(CloudPiranhaEntity*);
void sub_080387F0(CloudPiranhaEntity*);
bool32 sub_0803872C(CloudPiranhaEntity*, u32);
void CloudPiranha_OnTick(CloudPiranhaEntity*);
void CloudPiranha_OnCollision(CloudPiranhaEntity*);
void CloudPiranha_OnGrabbed(CloudPiranhaEntity*);
void CloudPiranha_Init(CloudPiranhaEntity*);
void CloudPiranha_Action1(CloudPiranhaEntity*);
void sub_080385CC(CloudPiranhaEntity*);
void CloudPiranha_Action3(CloudPiranhaEntity*);
void CloudPiranha_Action4(CloudPiranhaEntity*);
void CloudPiranha_Action5(CloudPiranhaEntity*);
void (*const gUnk_080CF4F0[])(CloudPiranhaEntity*) = {
CloudPiranha_OnTick,
CloudPiranha_OnCollision,
(void (*)(CloudPiranhaEntity*))GenericKnockback,
(void (*)(CloudPiranhaEntity*))GenericDeath,
(void (*)(CloudPiranhaEntity*))GenericConfused,
CloudPiranha_OnGrabbed,
};
void CloudPiranha(CloudPiranhaEntity* this) {
EnemyFunctionHandler(super, (EntityActionArray)&gUnk_080CF4F0);
SetChildOffset(super, 0, 1, -0x10);
}
void CloudPiranha_OnTick(CloudPiranhaEntity* this) {
static void (*const CloudPiranha_Actions[])(CloudPiranhaEntity*) = {
CloudPiranha_Init, CloudPiranha_Action1, sub_080385CC,
CloudPiranha_Action3, CloudPiranha_Action4, CloudPiranha_Action5,
};
CloudPiranha_Actions[super->action](this);
}
void CloudPiranha_OnCollision(CloudPiranhaEntity* this) {
if (super->confusedTime != 0) {
Create0x68FX(super, FX_STARS);
}
EnemyFunctionHandlerAfterCollision(super, gUnk_080CF4F0);
if ((super->bitfield & 0x80) != 0) {
if (super->hitType == 0x5a) {
switch (super->bitfield & 0x3f) {
case 0x14:
super->action = 5;
break;
case 0x15:
case 0xe:
super->health = 0;
break;
}
#ifndef EU
} else if ((super->bitfield & 0x3f) == 0x1d) {
sub_08038754(this);
#endif
}
}
}
void CloudPiranha_OnGrabbed(CloudPiranhaEntity* this) {
}
void CloudPiranha_Init(CloudPiranhaEntity* this) {
sub_0804A720(super);
super->action = 1;
super->direction = (Random() & 0x1c);
super->animationState = super->direction >> 2;
super->flags |= ENT_COLLIDE;
super->actionDelay = 0;
super->field_0xf = 0x20;
this->unk_82 = 0;
this->unk_80 = Random() & 1;
this->unk_81 = 0;
super->hitType = 0x72;
InitializeAnimation(super, super->animationState);
}
void CloudPiranha_Action1(CloudPiranhaEntity* this) {
u32 tmp;
sub_080387F0(this);
if (--super->field_0xf == 0) {
super->actionDelay = 0;
super->field_0xf = 0x20;
if (sub_08049FA0(super)) {
u32 tmp = super->animationState;
if (this->unk_80 != 0) {
tmp += 7;
} else {
tmp++;
}
super->animationState = tmp & 7;
super->direction = super->animationState << 2;
} else {
super->direction = (sub_08049EE4(super) + 2) & 0x1c;
super->animationState = super->direction >> 2;
}
InitializeAnimation(super, (u32)super->animationState);
} else if ((super->actionDelay == 0) && sub_0803872C(this, 0x80)) {
super->action = 2;
super->field_0xf = 0x10;
super->speed = 0x40;
super->animationState = sub_0806FCAC(super, super->child);
super->direction = super->animationState << 2;
InitializeAnimation(super, super->animationState);
}
}
NONMATCH("asm/non_matching/cloudPiranha/sub_080385CC.inc", void sub_080385CC(CloudPiranhaEntity* this)) {
u32 tmp;
sub_080387F0(this);
if (sub_0803872C(this, 0x60)) {
super->action = 3;
super->field_0xf = 0xc;
super->speed = 0x80;
super->animationState = sub_0806FCAC(super, super->child);
super->direction = super->animationState << 2;
InitializeAnimation(super, super->animationState);
} else {
if (--super->field_0xf == 0) {
super->field_0xf = 0x10;
if (super->child != NULL) {
super->animationState = sub_0806FCAC(super, super->child);
} else {
tmp = super->animationState;
if ((Random() & 0x10) != 0) {
super->animationState = (tmp + 2) & 7;
} else {
super->animationState = (tmp + 6) & 7;
}
}
super->direction = super->animationState << 2;
InitializeAnimation(super, super->animationState);
}
}
}
END_NONMATCH
void CloudPiranha_Action3(CloudPiranhaEntity* this) {
s32 tmp;
sub_080387F0(this);
if (sub_0803872C(this, 0x14)) {
sub_08038754(this);
} else {
if (--super->field_0xf == 0) {
super->field_0xf = 0xa;
if (this->unk_81 == 0) {
tmp = super->speed += 0x40;
if (0x2000000 < (tmp * 0x10000)) {
this->unk_81 = 1;
}
} else if (super->speed > 0x100) {
super->speed -= 0x50;
} else {
sub_08038754(this);
}
}
}
}
void CloudPiranha_Action4(CloudPiranhaEntity* this) {
Entity* effect;
sub_080387F0(this);
if (sub_080044EC(super, 0x1800) == 1) {
super->action = 1;
super->hitType = 0x72;
super->actionDelay = 1;
super->field_0xf = 0x80;
super->speed = 0x80;
super->spritePriority.b1 = 2;
EnqueueSFX(SFX_124);
ChangeObjPalette(super, 0x70);
InitializeAnimation(super, super->direction >> 2);
effect = CreateFx(super, FX_DEATH, 0);
if (effect != NULL) {
SortEntityAbove(super, effect);
}
}
}
void CloudPiranha_Action5(CloudPiranhaEntity* this) {
sub_08038754(this);
}
bool32 sub_0803872C(CloudPiranhaEntity* this, u32 param_2) {
super->child = sub_08049DF4(1);
if ((super->child != NULL) && sub_0806FC80(super, super->child, param_2)) {
return TRUE;
} else {
return FALSE;
}
}
void sub_08038754(CloudPiranhaEntity* this) {
Entity* effect;
super->action = 4;
super->flags |= ENT_COLLIDE;
super->hitType = 0x5a;
#ifdef EU
super->speed = 0x100;
#else
super->speed = 0xc0;
#endif
super->zVelocity = 0x20000;
this->unk_81 = 0;
super->spritePriority.b1 = 3;
EnqueueSFX(SFX_12B);
ChangeObjPalette(super, 0x71);
if ((super->direction & 0xf) != 0) {
InitializeAnimation(super, ((super->direction & 0x10) >> 0x3) + 9);
} else {
InitializeAnimation(super, ((super->direction & 0x10) >> 0x3) + 8);
}
effect = CreateFx(super, FX_DEATH, 0);
if (effect != NULL) {
SortEntityAbove(super, effect);
}
}
void sub_080387F0(CloudPiranhaEntity* this) {
static const u8 gUnk_080CF520[] = {
0, 244, 8, 248, 12, 0, 8, 8, 0, 12, 248, 8, 244, 0, 248, 248,
};
u8 bVar1;
u8 bVar2;
s32 iVar4;
const s8* ptr;
if ((super->action != 4) && (this->unk_82 == 0)) {
iVar4 = sub_080002E0(COORD_TO_TILE(super), super->collisionLayer);
if ((iVar4 == 0xf) || (iVar4 == 0x2a)) {
this->unk_82 = 0x20;
}
ptr = &gUnk_080CF520[super->direction >> 1];
bVar1 = super->direction;
iVar4 = sub_080002CC(super, ptr[0], ptr[1]);
if ((iVar4 == 0xf) || (iVar4 == 0x2a)) {
super->direction = (super->direction + 0x10) & 0x1f;
} else {
if (super->collisions != 0) {
sub_0800417E(super, super->collisions);
}
}
bVar2 = super->direction;
if (bVar1 != bVar2) {
super->animationState = bVar2 >> 2;
InitializeAnimation(super, super->animationState);
}
}
GetNextFrame(super);
if (this->unk_82 == 0) {
ProcessMovement0(super);
} else {
this->unk_82--;
LinearMoveUpdate(super);
}
}