Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
UpdateLogShadow.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "model.h"
3
4API_CALLABLE(N(UpdateLogShadow)) {
5 Bytecode* args = script->ptrReadPos;
6 f32 hitYaw, hitPitch, hitLength;
7 f32 x, y, z;
8 Shadow* shadow;
9 Model* model;
10
11 if (isInitialCall) {
12 s32 modelID = evt_get_variable(script, *args++);
13
14 script->functionTemp[3] = *args++;
15 script->functionTempPtr[1] = model = get_model_from_list_index(get_model_list_index_from_tree_index(modelID));
16 script->functionTemp[2] = create_shadow_type(SHADOW_VARYING_CIRCLE, model->center.x, 0.0f, model->center.z);
17 evt_set_variable(script, script->functionTemp[3], 0);
18 }
19
20 if (evt_get_variable(script, script->functionTemp[3])) {
21 delete_shadow(script->functionTemp[2]);
22 return ApiStatus_DONE2;
23 }
24
25 model = script->functionTempPtr[1];
26 shadow = get_shadow_by_index(script->functionTemp[2]);
27 x = model->center.x;
28 y = model->center.y;
29 z = model->center.z;
30 entity_raycast_down(&x, &y, &z, &hitYaw, &hitPitch, &hitLength);
31 set_standard_shadow_scale(shadow, hitLength);
32 shadow->rot.y = 0.0f;
33 shadow->pos.x = x;
34 shadow->pos.y = y;
35 shadow->pos.z = z;
36 shadow->rot.x = hitYaw;
37 shadow->rot.z = hitPitch;
38 shadow->scale.x *= 2.0f;
39 shadow->scale.z *= 2.0f;
40 return ApiStatus_BLOCK;
41}
Vec3f scale
@ SHADOW_VARYING_CIRCLE
Definition enums.h:2535
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:116
b32 entity_raycast_down(f32 *, f32 *, f32 *, f32 *, f32 *, f32 *)
Mostly used for shadows.
Definition entity.c:1637
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 get_model_list_index_from_tree_index(s32 treeIndex)
Definition model.c:3397
void set_standard_shadow_scale(Shadow *shadow, f32 scale)
Definition entity.c:1674
Shadow * get_shadow_by_index(s32 index)
Definition entity.c:534
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
struct Model * get_model_from_list_index(s32 listIndex)
Definition model.c:3315
s32 create_shadow_type(s32 type, f32 x, f32 y, f32 z)
Definition entity.c:1528
void delete_shadow(s32)
Definition entity.c:626
Vec3f center
Definition model.h:69
Definition model.h:59