Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
StoneChompAI.inc.c
Go to the documentation of this file.
2
3void N(StoneChompAI_HopInit)(Evt* script, MobileAISettings* aiSettings, EnemyDetectVolume* territory) {
4 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
5
6 basic_ai_wander_init(script, aiSettings, territory);
7 npc->jumpVel = rand_int(5) + 8.0;
8 npc->jumpScale = 1.5f;
9}
10
11void N(StoneChompAI_ChaseInit)(Evt* script, MobileAISettings* aiSettings, EnemyDetectVolume* territory) {
12 Npc* npc = get_npc_unsafe(script->owner1.enemy->npcID);
13
14 basic_ai_chase_init(script, aiSettings, territory);
15 npc->jumpVel = rand_int(5) + 5.0;
16 npc->jumpScale = 1.5f;
17}
18
19API_CALLABLE(N(StoneChompAI_Main)) {
20 Enemy* enemy = script->owner1.enemy;
21 Bytecode* args = script->ptrReadPos;
22 Npc* npc = get_npc_unsafe(enemy->npcID);
23 EnemyDetectVolume territory;
24 EnemyDetectVolume* territoryPtr = &territory;
25 MobileAISettings* aiSettings = (MobileAISettings*)evt_get_variable(script, *args);
26
27 territory.skipPlayerDetectChance = 0;
28 territory.shape = enemy->territory->wander.detectShape;
29 territory.pointX = enemy->territory->wander.detectPos.x;
30 territory.pointZ = enemy->territory->wander.detectPos.z;
31 territory.sizeX = enemy->territory->wander.detectSize.x;
32 territory.sizeZ = enemy->territory->wander.detectSize.z;
33 territory.halfHeight = 100.0f;
34 territory.detectFlags = 0;
35
36 if (isInitialCall) {
37 npc->duration = 0;
38 npc->flags &= ~NPC_FLAG_JUMPING;
39 npc->flags &= ~NPC_FLAG_GRAVITY;
40 npc->flags |= NPC_FLAG_FLYING;
41 script->functionTemp[1] = 0;
42 script->AI_TEMP_STATE = AI_STATE_HOP_INIT;
44 script->AI_TEMP_STATE = AI_STATE_CHASE_INIT;
45 enemy->flags &= ~ENEMY_FLAG_BEGIN_WITH_CHASING;
46 }
47 }
48
49 switch (script->AI_TEMP_STATE) {
51 N(StoneChompAI_HopInit)(script, aiSettings, territoryPtr);
52 // fallthrough
53 case AI_STATE_HOP:
54 N(HoppingAI_Hop)(script, aiSettings, territoryPtr);
55 break;
57 N(HoppingAI_LoiterInit)(script, aiSettings, territoryPtr);
58 // fallthrough
59 case AI_STATE_LOITER:
60 N(HoppingAI_Loiter)(script, aiSettings, territoryPtr);
61 break;
63 N(StoneChompAI_ChaseInit)(script, aiSettings, territoryPtr);
64 // fallthrough
65 case AI_STATE_CHASE:
66 N(HoppingAI_Chase)(script, aiSettings, territoryPtr);
67 break;
69 N(HoppingAI_LosePlayer)(script, aiSettings, territoryPtr);
70 break;
71 }
72 return ApiStatus_BLOCK;
73}
74
void N HoppingAI_LosePlayer(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N HoppingAI_LoiterInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N HoppingAI_Chase(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N HoppingAI_Hop(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N HoppingAI_Loiter(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N StoneChompAI_ChaseInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
void N StoneChompAI_HopInit(Evt *script, MobileAISettings *aiSettings, EnemyDetectVolume *territory)
#define rand_int
@ AI_STATE_LOITER
Definition enums.h:4588
@ AI_STATE_HOP_INIT
Definition enums.h:4585
@ AI_STATE_LOITER_INIT
Definition enums.h:4587
@ AI_STATE_CHASE_INIT
Definition enums.h:4592
@ AI_STATE_HOP
Definition enums.h:4586
@ AI_STATE_CHASE
Definition enums.h:4593
@ AI_STATE_LOSE_PLAYER
Definition enums.h:4594
@ ENEMY_FLAG_BEGIN_WITH_CHASING
Definition enums.h:4551
@ NPC_FLAG_FLYING
Definition enums.h:3001
s32 Bytecode
Definition evt.h:7
#define ApiStatus_BLOCK
Definition evt.h:116
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
void basic_ai_chase_init(Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
Definition 23680.c:769
void basic_ai_wander_init(Evt *script, MobileAISettings *npcAISettings, EnemyDetectVolume *territory)
Definition 23680.c:567
enum TerritoryShape shape
Definition npc.h:201
s32 flags
Definition npc.h:295
VecXZi detectSize
Definition npc.h:216
enum TerritoryShape detectShape
Definition npc.h:217
s16 npcID
Definition npc.h:300
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
s16 detectFlags
Definition npc.h:207
s32 skipPlayerDetectChance
Definition npc.h:200
EnemyTerritoryWander wander
Definition npc.h:232
EnemyTerritory * territory
Definition npc.h:342
Definition npc.h:294
f32 jumpScale
f32 jumpVel
s32 flags
s16 duration