1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/**
* @file lilypadSmall.c
* @ingroup Objects
*
* @brief Lilypad Small object
*/
#include "object.h"
#include "asm.h"
#include "room.h"
#include "player.h"
typedef struct {
/*0x00*/ Entity base;
/*0x68*/ u8 unused1[8];
/*0x70*/ u16 unk_70;
} LilypadSmallEntity;
static void sub_08097B24(LilypadSmallEntity* this);
static bool32 CheckMovePlayer(LilypadSmallEntity* this);
void LilypadSmall(LilypadSmallEntity* this) {
u32 rand;
u16* psVar4;
if (super->action == 0) {
super->action = 1;
super->timer = 90;
rand = Random();
super->subtimer = rand;
super->frameIndex = (rand >> 0x10) & 3;
super->spriteSettings.draw = TRUE;
super->spritePriority.b0 = 7;
super->child = GetCurrentRoomProperty(super->type2);
UpdateRailMovement(super, (u16**)&super->child, &this->unk_70);
}
SyncPlayerToPlatform(super, CheckMovePlayer(this));
sub_08097B24(this);
psVar4 = &this->unk_70;
if (--*psVar4 == 0) {
UpdateRailMovement(super, (u16**)&super->child, psVar4);
}
}
static bool32 CheckMovePlayer(LilypadSmallEntity* this) {
if (!(gPlayerState.flags & PL_MINISH)) {
return FALSE;
} else if (EntityInRectRadius(super, &gPlayerEntity.base, 8, 8) == 0) {
return FALSE;
} else if (!PlayerCanBeMoved()) {
return FALSE;
} else {
gPlayerState.field_0x14 = 1;
if (gPlayerEntity.base.z.HALF.HI != 0) {
return FALSE;
} else {
return TRUE;
}
}
}
static void sub_08097B24(LilypadSmallEntity* this) {
static const u16 gUnk_08123318[] = {
0x100, 0x101, 0x102, 0x101, 0x100, 0xff, 0xfe, 0xff,
};
u32 temp;
u32 temp2;
const u16* temp3;
if (--super->timer == 0) {
super->timer = 90;
super->frameIndex = (super->frameIndex + 1) & 3;
}
temp3 = gUnk_08123318;
temp2 = ++super->subtimer;
temp = temp3[(temp2 >> 5) & 7];
SetAffineInfo(super, temp, temp, 0);
}
|