SpaghettiKart
Loading...
Searching...
No Matches
update.inc.c
Go to the documentation of this file.
1#include "actors_extended.h"
2#include "collision.h"
3#include "defines.h"
4#include "external.h"
5#include "sounds.h"
6#include <actors.h>
7#include <main.h>
8
14void update_actor_fake_item_box(struct FakeItemBox* fake_item_box) {
15 u32 temp_v1 = fake_item_box->playerId;
16 Player* temp_v0_4 = &gPlayers[temp_v1];
17 struct Controller* temp_v1_3;
18
19 UNUSED s32 pad[7];
20 f32 temp_f2_2;
21 f32 temp_f14;
22 f32 temp_f16;
23 f32 temp_f18;
24 UNUSED s32 pad2[3];
25
26 switch (fake_item_box->state) {
27 case 0:
28 fake_item_box->boundingBoxSize = fake_item_box->sizeScaling * 5.5f;
29 fake_item_box->rot[0] -= 0xB6;
30 fake_item_box->rot[1] += 0x16C;
31 fake_item_box->rot[2] -= 0xB6;
32
33 temp_f14 = temp_v0_4->pos[0] - fake_item_box->pos[0];
34 temp_f16 = temp_v0_4->pos[1] - fake_item_box->pos[1];
35 temp_f18 = temp_v0_4->pos[2] - fake_item_box->pos[2];
36
37 temp_f2_2 = sqrtf((temp_f14 * temp_f14) + (temp_f16 * temp_f16) + (temp_f18 * temp_f18)) / 10.0f;
38 temp_f14 /= temp_f2_2;
39 temp_f16 /= temp_f2_2;
40 temp_f18 /= temp_f2_2;
41 fake_item_box->pos[0] = temp_v0_4->pos[0] - temp_f14;
42 fake_item_box->pos[1] = (temp_v0_4->pos[1] - temp_f16) - 1.0f;
43 fake_item_box->pos[2] = temp_v0_4->pos[2] - temp_f18;
44 check_bounding_collision(&fake_item_box->unk30, fake_item_box->boundingBoxSize, fake_item_box->pos[0],
45 fake_item_box->pos[1], fake_item_box->pos[2]);
46 func_802B4E30((struct Actor*) fake_item_box);
47 temp_v1_3 = &gControllers[temp_v1];
48 if ((temp_v0_4->type & PLAYER_HUMAN) != 0) {
49
50 if ((temp_v1_3->buttonDepressed & Z_TRIG) != 0) {
51 temp_v1_3->buttonDepressed &= 0xDFFF;
52 func_802A1064(fake_item_box);
53 temp_v0_4->triggers &= 0xFFFBFFFF;
54 func_800C9060((u8) (temp_v0_4 - gPlayerOne), SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12));
55 }
56 }
57 break;
58 case 1:
59 if (fake_item_box->sizeScaling < 1.0f) {
60 fake_item_box->sizeScaling += 0.05f;
61 } else if (fake_item_box->sizeScaling >= 1.0f) {
62 fake_item_box->sizeScaling = 1.0f;
63 }
64
65 fake_item_box->boundingBoxSize = fake_item_box->sizeScaling * 5.5f;
66 if (fake_item_box->targetY <= fake_item_box->pos[1]) {
67 fake_item_box->pos[1] = fake_item_box->targetY;
68 } else {
69 fake_item_box->pos[1] += 0.2f;
70 }
71 if ((fake_item_box->flags & 0x1000) != 0) {
72 if ((fake_item_box->someTimer <= 0) || (fake_item_box->someTimer >= 0x12D)) {
73 fake_item_box->flags &= 0xEFFF;
74 fake_item_box->someTimer = 0;
75 } else {
76 fake_item_box->someTimer--;
77 }
78 }
79 fake_item_box->rot[0] -= 0xB6;
80 fake_item_box->rot[1] += 0x16C;
81 fake_item_box->rot[2] -= 0xB6;
82 break;
83
84 case 2:
85 if ((fake_item_box->someTimer >= 0x14) || (fake_item_box->someTimer < 0)) {
86 destroy_actor((struct Actor*) fake_item_box);
87 } else {
88 fake_item_box->someTimer++;
89 fake_item_box->rot[0] += 0x444;
90 fake_item_box->rot[1] -= 0x2D8;
91 fake_item_box->rot[2] += 0x16C;
92 }
93 break;
94 default:
95 destroy_actor((struct Actor*) fake_item_box);
96 break;
97 }
98}
void destroy_actor(struct Actor *actor)
Definition actors.c:1207
void func_802A1064(struct FakeItemBox *fake_item_box)
Definition actors.c:2268
void func_802B4E30(struct Actor *arg0)
Definition actors_extended.c:990
u16 check_bounding_collision(Collision *collision, f32 boundingBoxSize, f32 posX, f32 posY, f32 posZ)
Definition collision.c:1299
#define PLAYER_HUMAN
Definition defines.h:114
void func_800C9060(u8 playerId, u32 soundBits)
Definition external.c:2971
void update_actor_fake_item_box(struct FakeItemBox *fake_item_box)
Updates the fake item box actor.
Definition update.inc.c:14
#define UNUSED
Definition macros.h:40
Player * gPlayerOne
Definition main.c:74
Player gPlayers[NUM_PLAYERS]
Definition main.c:73
struct Controller gControllers[NUM_PLAYERS]
Definition main.c:63
float sqrtf(float)
#define SOUND_ARG_LOAD(sound_bank, byte2, byte3, sound_id)
Definition sounds.h:14
Definition actor_types.h:124
Vec3s rot
Definition actor_types.h:131
s16 flags
Definition actor_types.h:126
Vec3f pos
Definition actor_types.h:133
f32 boundingBoxSize
Definition actor_types.h:130
Definition common_structs.h:66
u16 buttonDepressed
Definition common_structs.h:73
Definition actor_types.h:367
Vec3s rot
Definition actor_types.h:374
f32 boundingBoxSize
Definition actor_types.h:373
f32 sizeScaling
Definition actor_types.h:372
Collision unk30
Definition actor_types.h:380
f32 playerId
Definition actor_types.h:377
s16 state
Definition actor_types.h:371
Vec3f pos
Definition actor_types.h:376
Definition common_structs.h:264
s32 triggers
Definition common_structs.h:271
u16 type
Definition common_structs.h:265
Vec3f pos
Definition common_structs.h:274