mirror of
https://github.com/zeldaret/tmc
synced 2026-07-09 23:01:43 -04:00
Merge pull request #353 from hatal175/picolyteBottle
This commit is contained in:
+147
-57
@@ -1,3 +1,4 @@
|
||||
#define NENT_DEPRECATED
|
||||
#include "entity.h"
|
||||
#include "script.h"
|
||||
#include "structures.h"
|
||||
@@ -6,106 +7,195 @@
|
||||
#include "object.h"
|
||||
#include "npc.h"
|
||||
|
||||
typedef struct {
|
||||
Entity base;
|
||||
Entity* ent1;
|
||||
Entity* ent2;
|
||||
Entity* ent3;
|
||||
u16 unk74;
|
||||
u16 unk76;
|
||||
} PicolyteBottleEntity;
|
||||
|
||||
extern ScreenTransitionData gUnk_0813AD4C;
|
||||
|
||||
void sub_0806E014(Entity* this);
|
||||
void sub_0806E0DC(Entity* this);
|
||||
|
||||
extern void (*const gUnk_081142BC[])(Entity*);
|
||||
void sub_0806E014(PicolyteBottleEntity* this);
|
||||
void sub_0806E0DC(PicolyteBottleEntity* this);
|
||||
void PicolyteBottle_Init(PicolyteBottleEntity* this);
|
||||
void PicolyteBottle_Action1(PicolyteBottleEntity* this);
|
||||
void PicolyteBottle_Action2(PicolyteBottleEntity* this);
|
||||
void nullsub_111(PicolyteBottleEntity* this);
|
||||
|
||||
extern void sub_08078828(Entity*);
|
||||
|
||||
extern Hitbox gHitbox_0;
|
||||
|
||||
void PicolyteBottle(Entity* this) {
|
||||
gUnk_081142BC[this->action](this);
|
||||
static void (*const PicolyteBottle_Actions[])(PicolyteBottleEntity*) = {
|
||||
PicolyteBottle_Init,
|
||||
PicolyteBottle_Action1,
|
||||
PicolyteBottle_Action2,
|
||||
nullsub_111,
|
||||
};
|
||||
|
||||
PicolyteBottle_Actions[this->action]((PicolyteBottleEntity*)this);
|
||||
if (this->type == 0) {
|
||||
gPlayerState.mobility |= 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0806DF00(Entity* this) {
|
||||
void PicolyteBottle_Init(PicolyteBottleEntity* this) {
|
||||
Entity* npc;
|
||||
|
||||
if (this->type == 0) {
|
||||
this->action = 1;
|
||||
if (super->type == 0) {
|
||||
super->action = 1;
|
||||
npc = CreateNPC(PICOLYTE_BOTTLE, 1, 0);
|
||||
*(Entity**)&this->field_0x68 = npc;
|
||||
npc->parent = this;
|
||||
this->ent1 = npc;
|
||||
npc->parent = super;
|
||||
npc = CreateNPC(PICOLYTE_BOTTLE, 1, 1);
|
||||
*(Entity**)&this->field_0x6c = npc;
|
||||
npc->parent = this;
|
||||
this->ent2 = npc;
|
||||
npc->parent = super;
|
||||
npc = CreateNPC(PICOLYTE_BOTTLE, 1, 2);
|
||||
*(Entity**)&this->field_0x70 = npc;
|
||||
npc->parent = this;
|
||||
this->field_0x74.HWORD = 0;
|
||||
this->field_0x76.HWORD = 10;
|
||||
this->ent3 = npc;
|
||||
npc->parent = super;
|
||||
this->unk74 = 0;
|
||||
this->unk76 = 10;
|
||||
gRoomTransition.field_0x6 = 10;
|
||||
sub_0806E014(this);
|
||||
sub_0807DD50(this);
|
||||
sub_0807DD50(super);
|
||||
} else {
|
||||
this->hitbox = &gHitbox_0;
|
||||
this->collisionLayer = 1;
|
||||
super->hitbox = &gHitbox_0;
|
||||
super->collisionLayer = 1;
|
||||
sub_0806E0DC(this);
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/picolyteBottles/sub_0806DF74.inc", void sub_0806DF74(Entity* this))
|
||||
void PicolyteBottle_Action1(PicolyteBottleEntity* this) {
|
||||
sub_0807DD94(super, 0);
|
||||
if (super->actionDelay != 0xff) {
|
||||
if (super->damage != 0) {
|
||||
this->ent3->actionDelay++;
|
||||
}
|
||||
this->ent1->actionDelay++;
|
||||
this->ent2->actionDelay++;
|
||||
super->actionDelay = 0xff;
|
||||
SetRoomFlag(0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0806DFB4(Entity* this) {
|
||||
void PicolyteBottle_Action2(PicolyteBottleEntity* this) {
|
||||
Entity* obj;
|
||||
|
||||
if (this->interactType != 0) {
|
||||
this->interactType = 0;
|
||||
this->parent->actionDelay = this->type2;
|
||||
this->parent->type2 = this->field_0xf;
|
||||
if (super->interactType != 0) {
|
||||
super->interactType = 0;
|
||||
super->parent->actionDelay = super->type2;
|
||||
super->parent->type2 = super->field_0xf;
|
||||
} else {
|
||||
if (this->actionDelay != 0) {
|
||||
this->actionDelay = 0;
|
||||
obj = CreateObject(OBJECT_35, 2, this->field_0xf);
|
||||
if (super->actionDelay != 0) {
|
||||
super->actionDelay = 0;
|
||||
obj = CreateObject(OBJECT_35, 2, super->field_0xf);
|
||||
if (obj != NULL) {
|
||||
obj->parent = this;
|
||||
this->child = obj;
|
||||
CopyPosition(this, obj);
|
||||
obj->parent = super;
|
||||
super->child = obj;
|
||||
CopyPosition(super, obj);
|
||||
}
|
||||
sub_080788E0(this);
|
||||
sub_0807B7D8(0x74, this->field_0x76.HWORD, 2);
|
||||
sub_080788E0(super);
|
||||
sub_0807B7D8(0x74, this->unk76, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nullsub_111(void) {
|
||||
void nullsub_111(PicolyteBottleEntity* this) {
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/picolyteBottles/sub_0806E014.inc", void sub_0806E014(Entity* this))
|
||||
void sub_0806E014(PicolyteBottleEntity* this) {
|
||||
static const u8 gUnk_081142CC[] = { 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0 };
|
||||
static const u8 gUnk_081142DC[] = { 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0 };
|
||||
u32 uVar1;
|
||||
int iVar2;
|
||||
const u8* ptr;
|
||||
|
||||
void sub_0806E0DC(Entity* this) {
|
||||
this->actionDelay = 0;
|
||||
if (this->field_0xf != 0xff) {
|
||||
this->action = 2;
|
||||
this->field_0x76.HWORD = TILE(this->x.HALF.HI, this->y.HALF.HI);
|
||||
if (this->child != NULL) {
|
||||
DeleteEntity(this->child);
|
||||
this->child = NULL;
|
||||
}
|
||||
sub_08078828(this);
|
||||
sub_0807B7D8(0x73, this->field_0x76.HWORD, 2);
|
||||
uVar1 = (Random() & 0x70) >> 4;
|
||||
super->type2 = 0xff;
|
||||
super->actionDelay = 0xff;
|
||||
if (CheckLocalFlag(0x93) == 0) {
|
||||
super->damage = 0;
|
||||
iVar2 = uVar1 * 2;
|
||||
ptr = &gUnk_081142CC[iVar2];
|
||||
this->ent1->field_0xf = ptr[0];
|
||||
PositionRelative(super, this->ent1, 0x480000, 0x480000);
|
||||
this->ent2->field_0xf = ptr[1];
|
||||
PositionRelative(super, this->ent2, 0x680000, 0x480000);
|
||||
this->ent3->field_0xf = 0xff;
|
||||
CopyPosition(super, this->ent3);
|
||||
} else {
|
||||
this->action = 3;
|
||||
super->damage = 1;
|
||||
iVar2 = uVar1 * 4;
|
||||
ptr = &gUnk_081142DC[iVar2];
|
||||
this->ent1->field_0xf = ptr[0];
|
||||
PositionRelative(super, this->ent1, 0x380000, 0x480000);
|
||||
this->ent2->field_0xf = ptr[1];
|
||||
PositionRelative(super, this->ent2, 0x580000, 0x480000);
|
||||
this->ent3->field_0xf = ptr[2];
|
||||
PositionRelative(super, this->ent3, 0x780000, 0x480000);
|
||||
}
|
||||
}
|
||||
|
||||
ASM_FUNC("asm/non_matching/picolyteBottles/sub_0806E140.inc",
|
||||
void sub_0806E140(Entity* this, ScriptExecutionContext* context))
|
||||
|
||||
void sub_0806E1E0(Entity* this) {
|
||||
sub_0806E014(this);
|
||||
sub_0806E0DC(*(Entity**)&this->field_0x68);
|
||||
sub_0806E0DC(*(Entity**)&this->field_0x6c);
|
||||
sub_0806E0DC(*(Entity**)&this->field_0x70);
|
||||
void sub_0806E0DC(PicolyteBottleEntity* this) {
|
||||
super->actionDelay = 0;
|
||||
if (super->field_0xf != 0xff) {
|
||||
super->action = 2;
|
||||
this->unk76 = TILE(super->x.HALF.HI, super->y.HALF.HI);
|
||||
if (super->child != NULL) {
|
||||
DeleteEntity(super->child);
|
||||
super->child = NULL;
|
||||
}
|
||||
sub_08078828(super);
|
||||
sub_0807B7D8(0x73, this->unk76, 2);
|
||||
} else {
|
||||
super->action = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0806E1FC(Entity* this) {
|
||||
void sub_0806E140(PicolyteBottleEntity* this, ScriptExecutionContext* context) {
|
||||
u32 uVar1, uVar2;
|
||||
|
||||
if (super->type2) {
|
||||
context->condition = 1;
|
||||
this->unk74++;
|
||||
uVar1 = this->unk76;
|
||||
if (super->damage == 0) {
|
||||
uVar2 = uVar1 << 1;
|
||||
} else {
|
||||
uVar2 = uVar1 * 3;
|
||||
}
|
||||
this->unk76 = uVar2;
|
||||
if ((this->unk76) >= 1000) {
|
||||
this->unk76 = 999;
|
||||
context->condition = 0;
|
||||
MessageFromTarget(0x421b);
|
||||
} else {
|
||||
MessageFromTarget(0x4218);
|
||||
gMessage.field_0x10 = this->unk76;
|
||||
}
|
||||
} else {
|
||||
context->condition = 0;
|
||||
this->unk74 = 0;
|
||||
this->unk76 = 0;
|
||||
MessageFromTarget(0x421c);
|
||||
}
|
||||
gRoomTransition.field_0x6 = this->unk76;
|
||||
gActiveScriptInfo.flags |= 1;
|
||||
}
|
||||
|
||||
void sub_0806E1E0(PicolyteBottleEntity* this) {
|
||||
sub_0806E014(this);
|
||||
sub_0806E0DC((PicolyteBottleEntity*)this->ent1);
|
||||
sub_0806E0DC((PicolyteBottleEntity*)this->ent2);
|
||||
sub_0806E0DC((PicolyteBottleEntity*)this->ent3);
|
||||
}
|
||||
|
||||
void sub_0806E1FC(PicolyteBottleEntity* this) {
|
||||
DoExitTransition(&gUnk_0813AD4C);
|
||||
}
|
||||
|
||||
@@ -124,7 +214,7 @@ void sub_0806E23C(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0806E250(Entity* this, ScriptExecutionContext* context) {
|
||||
void sub_0806E250(PicolyteBottleEntity* this, ScriptExecutionContext* context) {
|
||||
context->condition = 0;
|
||||
if (CheckKinstoneFused(0x31) != 0) {
|
||||
context->condition = 1;
|
||||
|
||||
Reference in New Issue
Block a user