Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
encounter_api.c File Reference

Go to the source code of this file.

Functions

void start_battle (Evt *script, s32 songID)
 

Function Documentation

◆ start_battle()

void start_battle ( Evt * script,
s32 songID )

Definition at line 189 of file encounter_api.c.

189 {
190 EncounterStatus* currentEncounter = &gCurrentEncounter;
191 Enemy* enemy = script->owner1.enemy;
192 Encounter* encounter;
193 s32 i;
194
196
197 currentEncounter->hitType = ENCOUNTER_TRIGGER_NONE;
198 enemy->encountered = TRUE;
199 currentEncounter->curEnemy = enemy;
200 currentEncounter->curEncounter = currentEncounter->encounterList[enemy->encounterIndex];
201 currentEncounter->firstStrikeType = FIRST_STRIKE_NONE;
202 currentEncounter->forbidFleeing = FALSE;
203 currentEncounter->songID = songID;
204 currentEncounter->unk_18 = -1;
205
206 if (enemy->aiScript != NULL) {
208 }
209
210 if (enemy->auxScript != NULL) {
212 }
213
216
217 encounter = currentEncounter->curEncounter;
218 for (i = 0; i < encounter->count; i++) {
219 enemy = encounter->enemy[i];
220 if (enemy != NULL && (!(enemy->flags & ENEMY_FLAG_ENABLE_HIT_SCRIPT) || enemy == currentEncounter->curEnemy)) {
221 if (enemy->hitBytecode != NULL) {
222 Evt* hitEvtInstance;
223 enemy->encountered = TRUE;
224
225 hitEvtInstance = start_script(enemy->hitBytecode, EVT_PRIORITY_A, 0);
226
227 enemy->hitScript = hitEvtInstance;
228 enemy->hitScriptID = hitEvtInstance->id;
229
230 hitEvtInstance = enemy->hitScript;
231 hitEvtInstance->owner1.enemy = enemy;
232 hitEvtInstance->owner2.npcID = enemy->npcID;
233 hitEvtInstance->groupFlags = enemy->scriptGroup;
234 }
235 }
236 }
237
238 currentEncounter->fadeOutAmount = 0;
239 currentEncounter->substateDelay = 0;
240 currentEncounter->scriptedBattle = TRUE;
244}
u8 groupFlags
union Evt::@8 owner1
Initially -1.
union Evt::@9 owner2
Initially -1.
@ ENCOUNTER_TRIGGER_NONE
Definition enums.h:268
@ ENEMY_FLAG_ENABLE_HIT_SCRIPT
Definition enums.h:4524
@ ENCOUNTER_SUBSTATE_PRE_BATTLE_INIT
Definition enums.h:6313
@ ENCOUNTER_STATE_PRE_BATTLE
Definition enums.h:6297
@ FIRST_STRIKE_NONE
Definition enums.h:3458
@ EVT_PRIORITY_A
Definition evt.h:153
@ EVT_GROUP_FLAG_INTERACT
Definition evt.h:134
void partner_disable_input(void)
Definition partners.c:2489
s32 disable_player_input(void)
Definition 77480.c:990
s32 resume_all_group(s32 groupFlags)
s32 suspend_all_script(s32 id)
Evt * start_script(EvtScript *source, s32 priority, s32 initialState)
s8 scriptedBattle
battle started by StartBattle but not by encounter
Definition npc.h:380
s32 flags
Definition npc.h:295
s16 npcID
Definition npc.h:300
struct Evt * hitScript
Definition npc.h:314
EvtScript * hitBytecode
Definition npc.h:308
s8 encounterIndex
Definition npc.h:296
u8 scriptGroup
Definition npc.h:298
s32 auxScriptID
Definition npc.h:321
Encounter * encounterList[24]
Definition npc.h:392
Enemy * curEnemy
Definition npc.h:394
Enemy * enemy[16]
Definition npc.h:352
s32 count
Definition npc.h:351
s8 forbidFleeing
Definition npc.h:379
s32 aiScriptID
Definition npc.h:319
s32 fadeOutAmount
Definition npc.h:395
EncounterStatus gCurrentEncounter
Definition encounter.c:176
struct Evt * auxScript
Definition npc.h:315
s8 encountered
Definition npc.h:297
s8 firstStrikeType
Definition npc.h:367
s32 substateDelay
Definition npc.h:396
Encounter * curEncounter
Definition npc.h:393
struct Evt * aiScript
Definition npc.h:313
s32 hitScriptID
Definition npc.h:320
Definition npc.h:294
s32 gEncounterState
Definition encounter.c:174
b32 EncounterStateChanged
Definition encounter.c:24
s32 gEncounterSubState
Definition encounter.c:175