papermario/src/code_20ec0_len_5040.c

229 lines
5.9 KiB
C
Raw Normal View History

2020-08-04 08:49:11 +02:00
#include "common.h"
2020-11-06 01:30:17 +01:00
#include "map.h"
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045AC0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045B10);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045B68);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045BC8);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045C28);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045C88);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045CC4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045D00);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045D7C);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045E4C);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045ED0);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045FA4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80045FB4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80046030);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800465E0);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047608);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800476F4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004778C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800477F4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047820);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047898);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800478F8);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047928);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800479A0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047A00);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047A30);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047AA8);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047B08);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047B38);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047B84);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047BE4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047C14);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047CA4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047D00);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047D30);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047DC0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047E1C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047E4C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047EDC);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047F28);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047F58);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80047FE8);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048034);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048064);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800480F4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048140);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048170);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048200);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004824C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", spawn_drops);
2020-08-04 08:49:11 +02:00
2020-11-07 15:33:22 +01:00
// The issues here are only in the beginning where max and min are flipped
2020-10-03 22:04:49 +02:00
#ifdef NON_MATCHING
2020-10-02 08:07:54 +02:00
s32 get_coin_drop_amount(Enemy* enemy) {
2020-11-06 01:30:17 +01:00
EncounterStatus* currentEncounter = &gCurrentEncounter;
s16* dropTables = enemy->dropTables;
s32 t1;
s32 t2;
2020-10-02 08:07:54 +02:00
s32 amt;
s32 diff;
s32 max;
s32 min;
2020-11-06 01:30:17 +01:00
t1 = dropTables[89];
t2 = dropTables[90];
2020-10-02 08:07:54 +02:00
2020-11-06 01:30:17 +01:00
min = t1;
max = t2;
2020-10-02 08:07:54 +02:00
if (max < min) {
2020-11-06 01:30:17 +01:00
min = t2;
max = t1;
2020-10-02 08:07:54 +02:00
}
diff = max - min;
amt = min;
if ((min < 0) || (diff != 0)) {
amt = rand_int(diff) + min;
}
if (amt < 0) {
amt = 0;
}
if (is_ability_active(Ability_PAY_OFF)) {
amt += currentEncounter->damageTaken / 2;
}
if (currentEncounter->merleeCoinBonus != 0) {
amt *= 3;
}
2020-10-03 22:20:12 +02:00
if (is_ability_active(Ability_MONEY_MONEY)) {
2020-10-02 08:07:54 +02:00
amt *= 2;
}
amt += currentEncounter->coinsEarned;
if (enemy->flags & 0x840000) {
amt = 0;
}
2020-10-03 22:20:12 +02:00
2020-10-02 08:07:54 +02:00
if (amt > 20) {
amt = 20;
}
return amt;
}
2020-10-03 22:04:49 +02:00
#else
INCLUDE_ASM(s32, "code_20ec0_len_5040", get_coin_drop_amount);
#endif
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048E34);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80048F0C);
2020-09-24 05:16:13 +02:00
2020-10-02 08:07:54 +02:00
s32 is_point_within_region(s32 shape, f32 pointX, f32 pointY, f32 centerX, f32 centerY, f32 sizeX, f32 sizeZ) {
f32 dist1;
f32 dist2;
switch (shape) {
case 0:
dist1 = dist2D(pointX, pointY, centerX, centerY);
return (sizeX < dist1);
case 1:
dist1 = dist2D(pointX, 0, centerX, 0);
dist2 = dist2D(0, pointY, 0, centerY);
return ((sizeX < dist1) || (sizeZ < dist2));
default:
return FALSE;
}
}
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800490B4);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800493EC);
2020-09-24 05:16:13 +02:00
2020-10-08 21:03:58 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800494C0, Npc* npc, s32 arg1, s32 arg2);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80049550);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800495A0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_800496B8);
2020-08-04 08:49:11 +02:00
2020-11-20 05:08:05 +01:00
// Same as UnkNpcAIFunc1
2020-11-22 02:45:02 +01:00
void func_80049B44(ScriptInstance* script, NpcAISettings* aiSettings) {
2020-11-20 05:08:05 +01:00
Enemy* enemy = script->owner1.enemy;
Npc* npc = get_npc_unsafe(enemy->npcID);
npc->duration = (aiSettings->waitTime / 2) + rand_int((aiSettings->waitTime / 2) + 1);
npc->yaw = clamp_angle(npc->yaw + rand_int(180) - 90.0f);
npc->currentAnim = *enemy->animList;
script->functionTemp[0].s = 3;
}
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80049C04);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80049E3C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80049ECC);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_80049F7C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004A124);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004A3E8);
2020-08-04 08:49:11 +02:00
2020-11-06 01:30:17 +01:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", DoBasicAI, ScriptInstance* script, s32 isInitialCall);
2020-09-24 05:16:13 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004A6F0);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004A73C);
2020-08-04 08:49:11 +02:00
2020-09-25 23:18:09 +02:00
INCLUDE_ASM(s32, "code_20ec0_len_5040", func_8004A784);