Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
virtual_entity.c
Go to the documentation of this file.
1#include "common.h"
2#include "entity.h"
3
7
8s32 create_worker_backUI(void (*updateFunc)(void), void (*drawFunc)(void));
9
10void virtual_entity_appendGfx_quad(u8 r, u8 g, u8 b, u8 a, u16 left, u16 top, u16 right, u16 bottom) {
11 gDPPipeSync(gMainGfxPos++);
12
13 if (a == 0xFF) {
15 } else {
16 gDPSetRenderMode(gMainGfxPos++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
17 gDPSetCombineMode(gMainGfxPos++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
18 }
19
20 gDPSetPrimColor(gMainGfxPos++, 0, 0, r, g, b, a);
21 gDPFillRectangle(gMainGfxPos++, left, top, right, bottom);
22 gDPPipeSync(gMainGfxPos++);
23 gDPSetRenderMode(gMainGfxPos++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
24 gDPSetCombineMode(gMainGfxPos++, G_CC_DECALRGBA, G_CC_DECALRGBA);
25}
26
27void virtual_entity_render_quad(s32 r, s32 g, s32 b, s32 a, s32 posX, s32 posY, s32 width, s32 height) {
28 u16 endX = posX + width;
29 u16 endY = posY + height;
30
31 virtual_entity_appendGfx_quad(r, g, b, a, posX, posY, endX, endY);
32}
33
34void virtual_entity_move_polar(VirtualEntity* virtualEntity, f32 magnitude, f32 angle) {
35 f32 theta = DEG_TO_RAD(angle);
36 f32 sinTheta = sin_rad(theta);
37 f32 cosTheta = cos_rad(theta);
38
39 virtualEntity->pos.x += magnitude * sinTheta;
40 virtualEntity->pos.z += -magnitude * cosTheta;
41}
42
44 s32 i;
45
46 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
47 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[i];
48
49 if (virtualEntity != NULL && virtualEntity->entityModelIndex >= 0) {
51 }
52 }
53}
54
56 Matrix4f translation;
57 Matrix4f xRot;
58 Matrix4f yRot;
59 Matrix4f zRot;
60 Matrix4f rotation;
61 Matrix4f temp;
62 Matrix4f transform;
63 Matrix4f scale;
64 Mtx transformMtxL;
65 VirtualEntity* virtualEntity;
66 s32 i;
67
68 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
69 virtualEntity = (*gCurrentVirtualEntityListPtr)[i];
70 if (virtualEntity != NULL) {
71 if (!(virtualEntity->entityModelIndex < 0 || get_entity_model(virtualEntity->entityModelIndex)->flags & ENTITY_MODEL_FLAG_CAM3)) {
72 guTranslateF(translation, virtualEntity->pos.x, virtualEntity->pos.y, virtualEntity->pos.z);
73 guRotateF(xRot, virtualEntity->rot.x, 1.0f, 0.0f, 0.0f);
74 guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f);
75 guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f);
76 guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z);
77 guMtxCatF(zRot, xRot, temp);
78 guMtxCatF(temp, yRot, rotation);
79 guMtxCatF(scale, rotation, temp);
80 guMtxCatF(temp, translation, transform);
81 guMtxF2L(transform, &transformMtxL);
82 draw_entity_model_A(virtualEntity->entityModelIndex, &transformMtxL);
83 }
84 }
85 }
86}
87
89 Matrix4f translation;
90 Matrix4f xRot;
91 Matrix4f yRot;
92 Matrix4f zRot;
93 Matrix4f rotation;
94 Matrix4f temp;
95 Matrix4f transform;
96 Matrix4f scale;
97 Mtx transformMtxL;
98 VirtualEntity* virtualEntity;
99 s32 i;
100
101 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
102 virtualEntity = (*gCurrentVirtualEntityListPtr)[i];
103 if (virtualEntity != NULL) {
104 if (!(virtualEntity->entityModelIndex < 0 || !(get_entity_model(virtualEntity->entityModelIndex)->flags & ENTITY_MODEL_FLAG_CAM3))) {
105 guTranslateF(translation, virtualEntity->pos.x, virtualEntity->pos.y, virtualEntity->pos.z);
106 guRotateF(xRot, virtualEntity->rot.x, 1.0f, 0.0f, 0.0f);
107 guRotateF(yRot, virtualEntity->rot.y, 0.0f, 1.0f, 0.0f);
108 guRotateF(zRot, virtualEntity->rot.z, 0.0f, 0.0f, 1.0f);
109 guScaleF(scale, virtualEntity->scale.x, virtualEntity->scale.y, virtualEntity->scale.z);
110 guMtxCatF(zRot, xRot, temp);
111 guMtxCatF(temp, yRot, rotation);
112 guMtxCatF(scale, rotation, temp);
113 guMtxCatF(temp, translation, transform);
114 guMtxF2L(transform, &transformMtxL);
115 draw_entity_model_E(virtualEntity->entityModelIndex, &transformMtxL);
116 }
117 }
118 }
119}
120
121API_CALLABLE(InitVirtualEntityList) {
124 } else {
126 }
127 return ApiStatus_DONE2;
128}
129
130API_CALLABLE(CreateVirtualEntityAt) {
131 Bytecode* args = script->ptrReadPos;
132 s32 index = evt_get_variable(script, *args++);
133 EntityModelScript* cmdList = (EntityModelScript*) evt_get_variable(script, *args++);
134 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
135
136 virtualEntity->entityModelIndex = load_entity_model(cmdList);
137 virtualEntity->pos.x = 0.0f;
138 virtualEntity->pos.y = 0.0f;
139 virtualEntity->pos.z = 0.0f;
140 virtualEntity->rot.x = 0.0f;
141 virtualEntity->rot.y = 0.0f;
142 virtualEntity->rot.z = 0.0f;
143 virtualEntity->scale.x = 1.0f;
144 virtualEntity->scale.y = 1.0f;
145 virtualEntity->scale.z = 1.0f;
147
148 return ApiStatus_DONE2;
149}
150
151API_CALLABLE(CreateVirtualEntity) {
152 Bytecode* args = script->ptrReadPos;
153 s32 outVar = *args++;
154 EntityModelScript* cmdList = (EntityModelScript*)evt_get_variable(script, *args++);
155 VirtualEntity* virtualEntity;
156 s32 i;
157
158 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
159 virtualEntity = (*gCurrentVirtualEntityListPtr)[i];
160 if (virtualEntity->entityModelIndex < 0) {
161 break;
162 }
163 }
164
166 return ApiStatus_DONE2;
167 }
168
169 virtualEntity->entityModelIndex = load_entity_model(cmdList);
170 virtualEntity->pos.x = 0.0f;
171 virtualEntity->pos.y = 0.0f;
172 virtualEntity->pos.z = 0.0f;
173 virtualEntity->rot.x = 0.0f;
174 virtualEntity->rot.y = 0.0f;
175 virtualEntity->rot.z = 0.0f;
176 virtualEntity->scale.x = 1.0f;
177 virtualEntity->scale.y = 1.0f;
178 virtualEntity->scale.z = 1.0f;
179
181 evt_set_variable(script, outVar, i);
182
183 return ApiStatus_DONE2;
184}
185
186API_CALLABLE(CreateVirtualEntity_ALT) {
187 Bytecode* args = script->ptrReadPos;
188 s32 outVar = *args++;
189 EntityModelScript* cmdList = (EntityModelScript*) evt_get_variable(script, *args++);
190 VirtualEntity* virtualEntity;
191 s32 i;
192
193 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
194 virtualEntity = (*gCurrentVirtualEntityListPtr)[i];
195 if (virtualEntity->entityModelIndex < 0) {
196 break;
197 }
198 }
199
201 return ApiStatus_DONE2;
202 }
203
204 virtualEntity->entityModelIndex = ALT_load_entity_model(cmdList);
205 virtualEntity->pos.x = 0.0f;
206 virtualEntity->pos.y = 0.0f;
207 virtualEntity->pos.z = 0.0f;
208 virtualEntity->rot.x = 0.0f;
209 virtualEntity->rot.y = 0.0f;
210 virtualEntity->rot.z = 0.0f;
211 virtualEntity->scale.x = 1.0f;
212 virtualEntity->scale.y = 1.0f;
213 virtualEntity->scale.z = 1.0f;
214
216 evt_set_variable(script, outVar, i);
217
218 return ApiStatus_DONE2;
219}
220
221API_CALLABLE(DeleteVirtualEntity) {
222 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[evt_get_variable(script, *script->ptrReadPos)];
223
225 virtualEntity->entityModelIndex = -1;
226 return ApiStatus_DONE2;
227}
228
229API_CALLABLE(SetVirtualEntityRenderCommands) {
230 Bytecode* args = script->ptrReadPos;
231 s32 index = evt_get_variable(script, *args++);
232 EntityModelScript* cmdList = (EntityModelScript*) evt_get_variable(script, *args++);
233
234 set_entity_model_render_command_list((*gCurrentVirtualEntityListPtr)[index]->entityModelIndex, cmdList);
235 return ApiStatus_DONE2;
236}
237
238API_CALLABLE(SetVirtualEntityPosition) {
239 Bytecode* args = script->ptrReadPos;
240 s32 index = evt_get_variable(script, *args++);
241 f32 x = evt_get_float_variable(script, *args++);
242 f32 y = evt_get_float_variable(script, *args++);
243 f32 z = evt_get_float_variable(script, *args++);
244 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
245
246 virtualEntity->pos.x = x;
247 virtualEntity->pos.y = y;
248 virtualEntity->pos.z = z;
249 return ApiStatus_DONE2;
250}
251
252API_CALLABLE(GetVirtualEntityPosition) {
253 Bytecode* args = script->ptrReadPos;
254 s32 index = evt_get_variable(script, *args++);
255 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
256 s32 outVar1 = *args++;
257 s32 outVar2 = *args++;
258 s32 outVar3 = *args++;
259
260 evt_set_variable(script, outVar1, virtualEntity->pos.x);
261 evt_set_variable(script, outVar2, virtualEntity->pos.y);
262 evt_set_variable(script, outVar3, virtualEntity->pos.z);
263 return ApiStatus_DONE2;
264}
265
266API_CALLABLE(SetVirtualEntityRotation) {
267 Bytecode* args = script->ptrReadPos;
268 s32 index = evt_get_variable(script, *args++);
269 f32 x = evt_get_float_variable(script, *args++);
270 f32 y = evt_get_float_variable(script, *args++);
271 f32 z = evt_get_float_variable(script, *args++);
272 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
273
274 virtualEntity->rot.x = x;
275 virtualEntity->rot.y = y;
276 virtualEntity->rot.z = z;
277 return ApiStatus_DONE2;
278}
279
280API_CALLABLE(SetVirtualEntityScale) {
281 Bytecode* args = script->ptrReadPos;
282 s32 index = evt_get_variable(script, *args++);
283 f32 x = evt_get_float_variable(script, *args++);
284 f32 y = evt_get_float_variable(script, *args++);
285 f32 z = evt_get_float_variable(script, *args++);
286 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
287
288 virtualEntity->scale.x = x;
289 virtualEntity->scale.y = y;
290 virtualEntity->scale.z = z;
291 return ApiStatus_DONE2;
292}
293
294API_CALLABLE(SetVirtualEntityMoveSpeed) {
295 Bytecode* args = script->ptrReadPos;
296 s32 index = evt_get_variable(script, *args++);
297
298 (*gCurrentVirtualEntityListPtr)[index]->moveSpeed = evt_get_float_variable(script, *args++);
299 return ApiStatus_DONE2;
300}
301
302API_CALLABLE(SetVirtualEntityJumpGravity) {
303 Bytecode* args = script->ptrReadPos;
304 s32 index = evt_get_variable(script, *args++);
305
306 (*gCurrentVirtualEntityListPtr)[index]->jumpGravity = evt_get_float_variable(script, *args++);
307 return ApiStatus_DONE2;
308}
309
310API_CALLABLE(VirtualEntityMoveTo) {
311 Bytecode* args = script->ptrReadPos;
312 VirtualEntity* virtualEntity;
313
314 if (isInitialCall) {
315 script->functionTemp[0] = 0;
316 }
317
318 if (script->functionTemp[0] == 0) {
319 s32 index = evt_get_variable(script, *args++);
320 f32 xTemp = evt_get_variable(script, *args++);
321 f32 yTemp = evt_get_variable(script, *args++);
322 f32 zTemp = evt_get_variable(script, *args++);
323 s32 moveTime = evt_get_variable(script, *args++);
324 f32 goalPosX;
325 f32 goalPosZ;
326
327 virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
328 script->functionTemp[1] = index;
329
330 virtualEntity->goalPos.x = xTemp;
331 virtualEntity->goalPos.y = yTemp;
332 virtualEntity->goalPos.z = zTemp;
333
334 xTemp = virtualEntity->pos.x;
335 zTemp = virtualEntity->pos.z;
336
337 goalPosX = virtualEntity->goalPos.x;
338 goalPosZ = virtualEntity->goalPos.z;
339
340 virtualEntity->moveTime = moveTime;
341 virtualEntity->moveAngle = atan2(xTemp, zTemp, goalPosX, goalPosZ);
342 virtualEntity->moveDist = dist2D(xTemp, zTemp, goalPosX, goalPosZ);
343
344 if (virtualEntity->moveTime == 0.0f) {
345 virtualEntity->moveTime = virtualEntity->moveDist / virtualEntity->moveSpeed;
346 } else {
347 virtualEntity->moveSpeed = virtualEntity->moveDist / virtualEntity->moveTime;
348 }
349
350 script->functionTemp[0] = 1;
351 }
352
353 virtualEntity = (*gCurrentVirtualEntityListPtr)[script->functionTemp[1]];
354 virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle);
355 virtualEntity->moveTime--;
356
357 if (virtualEntity->moveTime <= 0.0f) {
358 virtualEntity->pos.x = virtualEntity->goalPos.x;
359 virtualEntity->pos.z = virtualEntity->goalPos.z;
360 return ApiStatus_DONE1;
361 }
362
363 return ApiStatus_BLOCK;
364}
365
366API_CALLABLE(VirtualEntityJumpTo) {
367 Bytecode* args = script->ptrReadPos;
368 VirtualEntity* virtualEntity;
369 s32 index;
370 f32 xTemp;
371 f32 yTemp;
372 f32 zTemp;
373 s32 moveTime;
374 f32 goalPosX;
375 f32 goalPosY;
376 f32 goalPosZ;
377
378 if (isInitialCall) {
379 script->functionTemp[0] = 0;
380 }
381
382 if (script->functionTemp[0] == 0) {
383 index = evt_get_variable(script, *args++);
384 xTemp = evt_get_variable(script, *args++);
385 yTemp = evt_get_variable(script, *args++);
386 zTemp = evt_get_variable(script, *args++);
387 moveTime = evt_get_variable(script, *args++);
388
389 virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
390 script->functionTemp[1] = index;
391
392 virtualEntity->goalPos.x = xTemp;
393 virtualEntity->goalPos.y = yTemp;
394 virtualEntity->goalPos.z = zTemp;
395
396 xTemp = virtualEntity->pos.x;
397 yTemp = virtualEntity->pos.y;
398 zTemp = virtualEntity->pos.z;
399
400 goalPosX = virtualEntity->goalPos.x;
401 yTemp = virtualEntity->goalPos.y - yTemp;
402 goalPosZ = virtualEntity->goalPos.z;
403
404
405 virtualEntity->moveTime = moveTime;
406 virtualEntity->moveAngle = atan2(xTemp, zTemp, goalPosX, goalPosZ);
407 virtualEntity->moveDist = dist2D(xTemp, zTemp, goalPosX, goalPosZ);
408
409 if (virtualEntity->moveTime == 0.0f) {
410 virtualEntity->moveTime = virtualEntity->moveDist / virtualEntity->moveSpeed;
411 } else {
412 virtualEntity->moveSpeed = virtualEntity->moveDist / virtualEntity->moveTime;
413 }
414
415 virtualEntity->jumpVel = (virtualEntity->jumpGravity * virtualEntity->moveTime / 2) +
416 (yTemp / virtualEntity->moveTime);
417 script->functionTemp[0] = 1;
418 }
419
420 virtualEntity = (*gCurrentVirtualEntityListPtr)[script->functionTemp[1]];
421 virtualEntity->pos.y += virtualEntity->jumpVel;
422 virtualEntity->jumpVel -= virtualEntity->jumpGravity;
423
424 virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle);
425
426 virtualEntity->moveTime -= 1.0f;
427 if (virtualEntity->moveTime <= 0.0f) {
428 virtualEntity->pos.x = virtualEntity->goalPos.x;
429 virtualEntity->pos.y = virtualEntity->goalPos.y;
430 virtualEntity->pos.z = virtualEntity->goalPos.z;
431 return ApiStatus_DONE1;
432 }
433
434 return ApiStatus_BLOCK;
435}
436
437API_CALLABLE(VirtualEntityLandJump) {
438 Bytecode* args = script->ptrReadPos;
439 VirtualEntity* virtualEntity;
440
441 if (isInitialCall) {
442 script->functionTemp[0] = 0;
443 }
444
445 if (script->functionTemp[0] == 0) {
446 script->functionTemp[1] = evt_get_variable(script, *args++);
447 script->functionTemp[0] = 1;
448 }
449
450 virtualEntity = (*gCurrentVirtualEntityListPtr)[script->functionTemp[1]];
451 virtualEntity->pos.y += virtualEntity->jumpVel;
452 virtualEntity->jumpVel -= virtualEntity->jumpGravity;
453
454 virtual_entity_move_polar(virtualEntity, virtualEntity->moveSpeed, virtualEntity->moveAngle);
455
456 if (virtualEntity->pos.y < 0.0f) {
457 virtualEntity->pos.y = 0.0f;
458 return ApiStatus_DONE1;
459 }
460
461 return ApiStatus_BLOCK;
462}
463
464API_CALLABLE(SetVirtualEntityFlags) {
465 Bytecode* args = script->ptrReadPos;
466 s32 index = evt_get_variable(script, *args++);
467 s32 flags = *args++;
468 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
469
470 get_entity_model(virtualEntity->entityModelIndex)->flags = flags;
471 return ApiStatus_DONE2;
472}
473
474API_CALLABLE(SetVirtualEntityFlagBits) {
475 Bytecode* args = script->ptrReadPos;
476 s32 index = evt_get_variable(script, *args++);
477 s32 bits = *args++;
478 s32 mode = evt_get_variable(script, *args++);
479 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
480
481 if (mode) {
482 set_entity_model_flags(virtualEntity->entityModelIndex, bits);
483 } else {
484 clear_entity_model_flags(virtualEntity->entityModelIndex, bits);
485 }
486
487 return ApiStatus_DONE2;
488}
489
490API_CALLABLE(SetVirtualEntityRenderMode) {
491 Bytecode* args = script->ptrReadPos;
492 s32 index = evt_get_variable(script, *args++);
493 s32 mode = evt_get_variable(script, *args++);
494 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
495 EntityModel* entityModel = get_entity_model(virtualEntity->entityModelIndex);
496
497 switch (mode) {
498 case -1:
499 entityModel->renderMode = RENDER_MODE_SURFACE_OPA;
500 break;
501 case 0:
502 entityModel->renderMode = RENDER_MODE_SURFACE_OPA;
503 evt_get_variable(script, *args++);
504 evt_get_variable(script, *args++);
505 evt_get_variable(script, *args++);
506 break;
507 case 2:
508 entityModel->renderMode = RENDER_MODE_ALPHATEST;
509 evt_get_variable(script, *args++);
510 evt_get_variable(script, *args++);
511 evt_get_variable(script, *args++);
512 break;
513 case 3:
515 evt_get_variable(script, *args++);
516 break;
517 case 4:
519 evt_get_variable(script, *args++);
520 evt_get_variable(script, *args++);
521 evt_get_variable(script, *args++);
522 evt_get_variable(script, *args++);
523 break;
524 }
525 return ApiStatus_DONE2;
526}
527
531
533 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
534
535 virtualEntity->entityModelIndex = load_entity_model(entityModelData);
536 virtualEntity->pos.x = 0.0f;
537 virtualEntity->pos.y = 0.0f;
538 virtualEntity->pos.z = 0.0f;
539 virtualEntity->rot.x = 0.0f;
540 virtualEntity->rot.y = 0.0f;
541 virtualEntity->rot.z = 0.0f;
542 virtualEntity->scale.x = 1.0f;
543 virtualEntity->scale.y = 1.0f;
544 virtualEntity->scale.z = 1.0f;
546
547 return (*gCurrentVirtualEntityListPtr)[index];
548}
549
551 s32 i;
552 VirtualEntity* virtualEntity;
553
554 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
555 virtualEntity = (*gCurrentVirtualEntityListPtr)[i];
556 if (virtualEntity->entityModelIndex < 0) {
557 break;
558 }
559 }
560
562 return 0;
563 }
564
565 virtualEntity->entityModelIndex = load_entity_model(cmdList);
566 virtualEntity->pos.x = 0.0f;
567 virtualEntity->pos.y = 0.0f;
568 virtualEntity->pos.z = 0.0f;
569 virtualEntity->rot.x = 0.0f;
570 virtualEntity->rot.y = 0.0f;
571 virtualEntity->rot.z = 0.0f;
572 virtualEntity->scale.x = 1.0f;
573 virtualEntity->scale.y = 1.0f;
574 virtualEntity->scale.z = 1.0f;
575
577
578 return i;
579}
580
582 s32 i;
583 VirtualEntity* virtualEntity;
584
585 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
586 virtualEntity = (*gCurrentVirtualEntityListPtr)[i];
587 if (virtualEntity->entityModelIndex < 0) {
588 break;
589 }
590 }
591
593 return NULL;
594 }
595
596 virtualEntity->entityModelIndex = ALT_load_entity_model(cmdList);
597 virtualEntity->pos.x = 0.0f;
598 virtualEntity->pos.y = 0.0f;
599 virtualEntity->pos.z = 0.0f;
600 virtualEntity->rot.x = 0.0f;
601 virtualEntity->rot.y = 0.0f;
602 virtualEntity->rot.z = 0.0f;
603 virtualEntity->scale.x = 1.0f;
604 virtualEntity->scale.y = 1.0f;
605 virtualEntity->scale.z = 1.0f;
606
608
609 return (*gCurrentVirtualEntityListPtr)[i];
610}
611
612void virtual_entity_set_pos(s32 index, s32 posX, s32 posY, s32 posZ) {
613 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
614
615 virtualEntity->pos.x = posX;
616 virtualEntity->pos.y = posY;
617 virtualEntity->pos.z = posZ;
618}
619
620void virtual_entity_set_scale(s32 index, f32 scaleX, f32 scaleY, f32 scaleZ) {
621 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
622
623 virtualEntity->scale.x = scaleX;
624 virtualEntity->scale.y = scaleY;
625 virtualEntity->scale.z = scaleZ;
626}
627
628void virtual_entity_set_rotation(s32 index, f32 angleX, f32 angleY, f32 angleZ) {
629 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
630
631 virtualEntity->rot.x = angleX;
632 virtualEntity->rot.y = angleY;
633 virtualEntity->rot.z = angleZ;
634}
635
637 VirtualEntity* virtualEntity = (*gCurrentVirtualEntityListPtr)[index];
638
640 virtualEntity->entityModelIndex = -1;
641}
642
644 s32 i;
645
646 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
647 if ((*gCurrentVirtualEntityListPtr)[i] == obj) {
649 return;
650 }
651 }
652}
653
655 s32 i;
656
659 } else {
661 }
662
663 for (i = 0; i < ARRAY_COUNT(*gCurrentVirtualEntityListPtr); i++) {
664 (*gCurrentVirtualEntityListPtr)[i] = heap_malloc(sizeof(VirtualEntity));
666 (*gCurrentVirtualEntityListPtr)[i]->entityModelIndex = -1;
667 }
668
671}
672
f32 Matrix4f[4][4]
VirtualEntity * VirtualEntityList[0x40]
s8 flags
Definition demo_api.c:15
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define atan2
#define guScaleF
#define ASSERT(condition)
s32 EntityModelScript[]
Definition entity.h:7
s32 load_entity_model(EntityModelScript *cmdList)
s32 ALT_load_entity_model(EntityModelScript *cmdList)
void set_entity_model_render_command_list(s32 idx, EntityModelScript *cmdList)
EntityModel * get_entity_model(s32 idx)
@ ENTITY_MODEL_FLAG_CAM3
Definition enums.h:5013
@ CONTEXT_WORLD
Definition enums.h:3529
@ RENDER_MODE_SURFACE_XLU_LAYER2
Definition enums.h:3287
@ RENDER_MODE_ALPHATEST
Definition enums.h:3276
@ RENDER_MODE_SURFACE_OPA
Definition enums.h:3264
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
#define ApiStatus_DONE1
Definition evt.h:117
#define ApiStatus_BLOCK
Definition evt.h:116
s32 create_worker_world(WorldArgs, WorldArgs)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void draw_entity_model_A(s32, Mtx *)
void clear_entity_model_flags(s32 idx, s32 newFlags)
void set_entity_model_flags(s32 idx, s32 newFlags)
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
f32 cos_rad(f32 x)
Definition 43F0.c:717
void exec_entity_model_commandlist(s32 idx)
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
f32 sin_rad(f32 x)
Definition 43F0.c:713
void draw_entity_model_E(s32, Mtx *)
void free_entity_model_by_index(s32 idx)
void * heap_malloc(s32 size)
Definition heap.c:34
ApiStatus CreateVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityFlags(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityMoveSpeed(Evt *script, b32 isInitialCall)
ApiStatus InitVirtualEntityList(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityFlagBits(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus CreateVirtualEntity_ALT(Evt *script, b32 isInitialCall)
ApiStatus GetVirtualEntityPosition(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityLandJump(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityJumpGravity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityScale(Evt *script, b32 isInitialCall)
ApiStatus DeleteVirtualEntity(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityRenderMode(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityJumpTo(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityRotation(Evt *script, b32 isInitialCall)
ApiStatus VirtualEntityMoveTo(Evt *script, b32 isInitialCall)
ApiStatus CreateVirtualEntityAt(Evt *script, b32 isInitialCall)
ApiStatus SetVirtualEntityRenderCommands(Evt *script, b32 isInitialCall)
#define PM_CC_PRIM_FULL_ALPHA
Definition macros.h:283
#define ARRAY_COUNT(arr)
Definition macros.h:40
#define DEG_TO_RAD(deg)
Definition macros.h:134
s32 flags
Definition entity.h:448
s8 renderMode
Definition entity.h:449
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Gfx * gMainGfxPos
Definition cam_main.c:15
VirtualEntityList wWorldVirtualEntityList
Definition script_list.c:46
void virtual_entity_set_rotation(s32 index, f32 angleX, f32 angleY, f32 angleZ)
void virtual_entity_list_render_world(void)
void virtual_entity_list_update(void)
void virtual_entity_appendGfx_quad(u8 r, u8 g, u8 b, u8 a, u16 left, u16 top, u16 right, u16 bottom)
s32 create_worker_backUI(void(*updateFunc)(void), void(*drawFunc)(void))
Definition worker.c:94
void init_virtual_entity_list(void)
void virtual_entity_move_polar(VirtualEntity *virtualEntity, f32 magnitude, f32 angle)
void virtual_entity_delete_by_ref(VirtualEntity *obj)
void virtual_entity_set_scale(s32 index, f32 scaleX, f32 scaleY, f32 scaleZ)
VirtualEntity * virtual_entity_get_by_index(s32 index)
void virtual_entity_delete_by_index(s32 index)
void clear_virtual_entity_list(void)
VirtualEntityList * gCurrentVirtualEntityListPtr
Definition script_list.c:47
void virtual_entity_set_pos(s32 index, s32 posX, s32 posY, s32 posZ)
s32 virtual_entity_create(EntityModelScript *cmdList)
VirtualEntity * virtual_entity_create_at_index(s32 index, EntityModelScript *entityModelData)
void virtual_entity_render_quad(s32 r, s32 g, s32 b, s32 a, s32 posX, s32 posY, s32 width, s32 height)
VirtualEntityList bBattleVirtualEntityList
Definition script_list.c:45
VirtualEntity * ALT_virtual_entity_create(EntityModelScript *cmdList)
void virtual_entity_list_render_UI(void)