Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
25AF0.c
Go to the documentation of this file.
1#include "common.h"
2#include "npc.h"
3
4void ai_suspend_for_time(Evt* script) {
5 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
6
7 npc->duration--;
8 if (npc->duration <= 0) {
9 script->functionTemp[0] = script->functionTemp[1];
10 }
11}
12
13void basic_ai_suspend(Evt* script) {
14 Enemy* enemy = script->owner1.enemy;
15
16 get_npc_unsafe(enemy->npcID);
17 if (enemy->aiSuspendTime == 0) {
18 script->functionTemp[0] = script->functionTemp[1];
19 }
20}
21
22s32 ai_check_fwd_collisions(Npc* npc, f32 time, f32* outYaw, f32* outDistFwd, f32* outDistCW, f32* outDistCCW) {
23 f32 x1, y1, z1;
24 f32 x2, y2, z2;
25 f32 x3, y3, z3;
26 f32 fwdHitDist = -1.0f;
27 f32 cwHitDist = -1.0f;
28 f32 ccwHitDist = -1.0f;
29 f32 yaw;
30 b32 fwdHit;
31
32 x1 = npc->pos.x;
33 y1 = npc->pos.y;
34 z1 = npc->pos.z;
35 yaw = *outYaw;
36
38 &x1, &y1, &z1,
39 npc->moveSpeed * time,
40 yaw,
41 npc->collisionHeight,
43
44 if (fwdHit != 0) {
45 fwdHitDist = dist2D(npc->pos.x, npc->pos.z, x1, z1);
46
47 x2 = npc->pos.x;
48 y2 = npc->pos.y;
49 z2 = npc->pos.z;
51 &x2, &y2, &z2, npc->moveSpeed * time,
52 clamp_angle(yaw + 35.0f),
53 npc->collisionHeight,
54 npc->collisionDiameter) != 0) {
55 cwHitDist = dist2D(npc->pos.x, npc->pos.z, x2, z2);
56 }
57
58 x3 = npc->pos.x;
59 y3 = npc->pos.y;
60 z3 = npc->pos.z;
62 &x3, &y3, &z3,
63 npc->moveSpeed * time,
64 clamp_angle(yaw - 35.0f),
65 npc->collisionHeight,
66 npc->collisionDiameter) != 0) {
67 ccwHitDist = dist2D(npc->pos.x, npc->pos.z, x3, z3);
68 }
69
70 if ((cwHitDist < fwdHitDist && ccwHitDist < cwHitDist) || (ccwHitDist < fwdHitDist && cwHitDist < ccwHitDist)) {
71 yaw = npc->yaw;
72 } else if ((fwdHitDist < cwHitDist && ccwHitDist < fwdHitDist) || (ccwHitDist < cwHitDist && fwdHitDist < ccwHitDist)) {
73 yaw = npc->yaw + 35.0f;
74 } else if ((fwdHitDist < ccwHitDist && cwHitDist < fwdHitDist) || (cwHitDist < ccwHitDist && fwdHitDist < cwHitDist)) {
75 yaw = npc->yaw - 35.0f;
76 }
77 }
78
79 if (outYaw != NULL) {
80 *outYaw = clamp_angle(yaw);
81 }
82 if (outDistFwd != NULL) {
83 *outDistFwd = fwdHitDist;
84 }
85 if (outDistCW != NULL) {
86 *outDistCW = cwHitDist;
87 }
88 if (outDistCCW != NULL) {
89 *outDistCCW = ccwHitDist;
90 }
91 return fwdHit;
92}
void ai_suspend_for_time(Evt *script)
Definition 25AF0.c:4
void basic_ai_suspend(Evt *script)
Definition 25AF0.c:13
s32 ai_check_fwd_collisions(Npc *npc, f32 time, f32 *outYaw, f32 *outDistFwd, f32 *outDistCW, f32 *outDistCCW)
Definition 25AF0.c:22
s32 b32
union Evt::@8 owner1
Initially -1.
#define clamp_angle
f32 dist2D(f32 ax, f32 ay, f32 bx, f32 by)
Definition 43F0.c:670
b32 npc_test_move_simple_with_slipping(s32, f32 *, f32 *, f32 *, f32, f32, f32, f32)
s16 npcID
Definition npc.h:300
s8 aiSuspendTime
Definition npc.h:333
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
Definition npc.h:294
s16 collisionDiameter
s32 collisionChannel
s16 collisionHeight
Vec3f pos
f32 moveSpeed
s16 duration