Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
Bandit.inc.c
Go to the documentation of this file.
1
2#include "Bandit.h"
3
4#define HAS_COIN_FLAG AreaFlag(1)
5
6API_CALLABLE(N(Bandit_TetherStolenCoin)) {
7 Bytecode* args = script->ptrReadPos;
8 s32 npcID;
9 Npc* npc;
10 s32 itemEntityIndex;
11 s32 areaFlag;
12
13 if (isInitialCall) {
14 npcID = evt_get_variable(script, *args++);
15 itemEntityIndex = evt_get_variable(script, *args++);
16 areaFlag = *args++;
17
18 if (npcID == -1) {
19 npc = get_npc_unsafe(script->owner2.npcID);
20 } else if (npcID >= EVT_LIMIT) {
21 npc = get_npc_unsafe(npcID);
22 } else {
23 npc = (Npc*)npcID;
24 }
25
26 script->functionTempPtr[0] = npc;
27 script->functionTemp[1] = itemEntityIndex;
28 script->functionTemp[2] = areaFlag;
29 }
30
31 npc = script->functionTempPtr[0];
32 itemEntityIndex = script->functionTemp[1];
33 areaFlag = script->functionTemp[2];
34
35 if (evt_get_variable(script, areaFlag)) {
36 set_item_entity_position(itemEntityIndex, npc->pos.x, npc->pos.y + 30.0f, npc->pos.z);
37 return ApiStatus_BLOCK;
38 }
39
40 return ApiStatus_DONE2;
41}
42
43EvtScript N(EVS_Bandit_CreateStolenCoin) = {
46 Add(LVar2, 30)
48 Call(N(Bandit_TetherStolenCoin), LVarA, LVar0, HAS_COIN_FLAG)
50 Return
51 End
52};
53
54MobileAISettings N(AISettings_Bandit) = {
55 .moveSpeed = 2.7f,
56 .moveTime = 45,
57 .waitTime = 30,
58 .alertRadius = 450.0f,
59 .playerSearchInterval = 10,
60 .chaseSpeed = 8.3f,
61 .chaseTurnRate = 180,
62 .chaseUpdateInterval = 100,
63 .chaseRadius = 550.0f,
64 .chaseOffsetDist = 100.0f,
65 .unk_AI_2C = 1,
66};
67
68EvtScript N(EVS_NpcAI_Bandit) = {
69 Call(BasicAI_Main, Ref(N(AISettings_Bandit)))
70 Return
71 End
72};
73
74EvtScript N(EVS_NpcDefeat_Bandit) = {
83 Set(HAS_COIN_FLAG, TRUE)
85 Call(SetNpcAnimation, NPC_SELF, ANIM_Bandit_IdleHolding)
87 Exec(N(EVS_Bandit_CreateStolenCoin))
90 Add(LVar7, 20)
92 Add(LVar7, 20)
95 Add(LVar0, 180)
97 Call(SetNpcAnimation, NPC_SELF, ANIM_Bandit_RunHolding)
98 Wait(10)
100 Add(LVar7, 200)
102 Set(HAS_COIN_FLAG, FALSE)
107 Return
108 End
109};
110
111NpcSettings N(NpcSettings_Bandit) = {
112 .height = 26,
113 .radius = 24,
114 .level = ACTOR_LEVEL_BANDIT,
115 .ai = &N(EVS_NpcAI_Bandit),
116 .onHit = &EnemyNpcHit,
117 .onDefeat = &N(EVS_NpcDefeat_Bandit),
119};
#define HAS_COIN_FLAG
Definition Bandit.inc.c:4
Bytecode EvtScript[]
@ ITEM_SPAWN_MODE_DECORATION
Definition enums.h:2292
@ ENEMY_FLAG_FLED
Definition enums.h:4525
@ NPC_SELF
Definition enums.h:2526
@ OUTCOME_ENEMY_FLED
Definition enums.h:1905
@ OUTCOME_PLAYER_WON
Definition enums.h:1902
@ OUTCOME_PLAYER_FLED
Definition enums.h:1904
@ AI_ACTION_04
Definition enums.h:4614
@ AI_ACTION_JUMP_WHEN_SEE_PLAYER
Definition enums.h:4612
@ NPC_FLAG_IGNORE_WORLD_COLLISION
Definition enums.h:3004
#define ApiStatus_DONE2
Definition evt.h:118
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 set_item_entity_position(s32 itemEntityIndex, f32 x, f32 y, f32 z)
s16 height
Definition npc.h:145
f32 moveSpeed
Definition npc.h:93
Npc * get_npc_unsafe(s32 npcID)
Definition npc.c:995
ApiStatus RemoveItemEntity(Evt *script, b32 isInitialCall)
ApiStatus DisablePlayerInput(Evt *script, b32 isInitialCall)
Disables player and partner input, and disables the status menu.
ApiStatus GetNpcPos(Evt *script, b32 isInitialCall)
ApiStatus SetNpcSpeed(Evt *script, b32 isInitialCall)
ApiStatus SetNpcAnimation(Evt *script, b32 isInitialCall)
ApiStatus SetEnemyFlagBits(Evt *script, b32 isInitialCall)
ApiStatus GetNpcYaw(Evt *script, b32 isInitialCall)
EvtScript EnemyNpcHit
Definition encounter.c:131
ApiStatus InterpNpcYaw(Evt *script, b32 isInitialCall)
ApiStatus RemoveNpc(Evt *script, b32 isInitialCall)
ApiStatus DoNpcDefeat(Evt *script, b32 isInitialCall)
ApiStatus NpcJump0(Evt *script, b32 isInitialCall)
ApiStatus MakeItemEntity(Evt *script, b32 isInitialCall)
ApiStatus SetNpcJumpscale(Evt *script, b32 isInitialCall)
ApiStatus OnPlayerFled(Evt *script, b32 isInitialCall)
ApiStatus GetSelfNpcID(Evt *script, b32 isInitialCall)
ApiStatus NpcMoveTo(Evt *script, b32 isInitialCall)
ApiStatus SetNpcFlagBits(Evt *script, b32 isInitialCall)
ApiStatus GetPlayerPos(Evt *script, b32 isInitialCall)
ApiStatus GetBattleOutcome(Evt *script, b32 isInitialCall)
#define Switch(LVAR)
Marks the start of a switch statement.
Definition macros.h:311
#define Ref(sym)
Address/pointer constant.
Definition macros.h:60
#define Set(VAR, INT_VALUE)
Sets the given variable to a given value casted to an integer.
Definition macros.h:365
#define CaseEq(RVAR)
Marks the start of a switch case that executes only if LVAR == RVAR. It also marks the end of any pre...
Definition macros.h:319
#define End
Signals the end of EVT script data. A script missing this will likely crash on load.
Definition macros.h:213
#define Add(VAR, INT_VALUE)
Definition macros.h:376
#define Float(DOUBLE)
Definition macros.h:51
#define LVar7
Definition macros.h:155
#define LVar8
Definition macros.h:156
#define LVar2
Definition macros.h:150
#define LVar1
Definition macros.h:149
#define LVarA
Definition macros.h:158
#define Wait(NUM_FRAMES)
Blocks for the given number of frames.
Definition macros.h:254
#define LVar9
Definition macros.h:157
#define EndSwitch
Marks the end of a switch statement and any case.
Definition macros.h:362
#define Call(FUNC, ARGS...)
Calls a given C EVT API function with any number of arguments.
Definition macros.h:576
#define LVar3
Definition macros.h:151
#define EVT_LIMIT
Definition macros.h:47
#define LVar0
Definition macros.h:148
#define Exec(EVT_SOURCE)
Launches a new thread.
Definition macros.h:455
#define Return
Kills the current EVT thread.
Definition macros.h:217
Vec3f pos