summaryrefslogtreecommitdiff
path: root/src/object/thunderbolt.c
diff options
context:
space:
mode:
authoroctorock <79596758+octorock@users.noreply.github.com>2023-07-31 21:31:30 +0200
committeroctorock <79596758+octorock@users.noreply.github.com>2023-07-31 21:31:30 +0200
commit4d67e6fe1ff97f964e700b27dc2b1f8911002a12 (patch)
treef619a6244f304011fc681613d124d41023133623 /src/object/thunderbolt.c
parenteb233b05cdd259fe52737c8287fbdfc8e4bd7870 (diff)
Create new entity structs for Objects
Diffstat (limited to 'src/object/thunderbolt.c')
-rw-r--r--src/object/thunderbolt.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/object/thunderbolt.c b/src/object/thunderbolt.c
new file mode 100644
index 00000000..697a32e3
--- /dev/null
+++ b/src/object/thunderbolt.c
@@ -0,0 +1,118 @@
+/**
+ * @file thunderbolt.c
+ * @ingroup Objects
+ *
+ * @brief Thunderbolt object
+ */
+#define NENT_DEPRECATED
+#include "functions.h"
+#include "object.h"
+
+typedef struct {
+ /*0x00*/ Entity base;
+} ThunderboltEntity;
+
+void Thunderbolt_Init(ThunderboltEntity*);
+void Thunderbolt_Action1(ThunderboltEntity*);
+void sub_08093ED0(ThunderboltEntity*);
+void sub_08093EF0(ThunderboltEntity*);
+
+typedef struct {
+ u16 sfx;
+ u8 unk_2;
+ u8 unk_3;
+} struct_08122950;
+
+const struct_08122950 gUnk_08122950[] = {
+ { 244, 31, 0 },
+ { 0, 31, 0 },
+ { 0, 31, 0 },
+};
+
+void Thunderbolt(ThunderboltEntity* this) {
+ static void (*const Thunderbolt_Actions[])(ThunderboltEntity*) = {
+ Thunderbolt_Init,
+ Thunderbolt_Action1,
+ };
+ Thunderbolt_Actions[super->action](this);
+}
+
+void Thunderbolt_Init(ThunderboltEntity* this) {
+ const struct_08122950* ptr;
+ super->action = 1;
+ super->flags &= ~0x80;
+ super->spriteSettings.draw = 1;
+ if (super->collisionLayer == 0) {
+ ResolveCollisionLayer(super);
+ }
+ InitializeAnimation(super, super->type);
+ ptr = &gUnk_08122950[super->type];
+ if ((ptr->sfx != SFX_NONE) && ((super->type2 & 0x40) == 0)) {
+ EnqueueSFX(ptr->sfx);
+ }
+ if ((super->type2 & 0x20) != 0) {
+ super->spriteRendering.b3 = 1;
+ }
+}
+
+void Thunderbolt_Action1(ThunderboltEntity* this) {
+ static void (*const gUnk_08122964[])(ThunderboltEntity*) = {
+ sub_08093ED0,
+ sub_08093EF0,
+ };
+ gUnk_08122964[gUnk_08122950[super->type].unk_2 >> 4](this);
+}
+
+void sub_08093ED0(ThunderboltEntity* this) {
+ GetNextFrame(super);
+ if ((super->frame & ANIM_DONE) != 0) {
+ DeleteEntity(super);
+ }
+}
+
+void sub_08093EF0(ThunderboltEntity* this) {
+ Entity* object;
+ switch (super->type) {
+ case 0:
+ if (super->subAction != 0) {
+ return;
+ }
+ GetNextFrame(super);
+ if ((super->frame & ANIM_DONE) == 0) {
+ return;
+ }
+ object = CreateObject(THUNDERBOLT, 1, 0);
+ if (object != NULL) {
+ object->parent = super->parent;
+ CopyPosition(super, object);
+ }
+ DeleteThisEntity();
+ break;
+ case 1:
+ GetNextFrame(super);
+ if ((super->frame & 1) != 0) {
+ super->frame = 0;
+ object = CreateObject(THUNDERBOLT, 2, 0);
+ if (object != NULL) {
+ object->parent = super->parent;
+ CopyPosition(super, object);
+ }
+ }
+ if ((super->frame & ANIM_DONE) == 0) {
+ return;
+ }
+ if (super->parent == &gPlayerEntity) {
+ SoundReq(SFX_PLY_VO6);
+ sub_08079D84();
+ }
+ DeleteThisEntity();
+ break;
+ case 2:
+ GetNextFrame(super);
+ if ((super->frame & ANIM_DONE) == 0) {
+ return;
+ }
+ DeleteThisEntity();
+ break;
+ }
+}