clean up coconut

This commit is contained in:
Alex Bates 2021-02-06 05:26:27 +00:00
parent 3e2a5c20f9
commit cf745c85cb
6 changed files with 70 additions and 52 deletions

View File

@ -12,6 +12,7 @@
}, },
"includePath": [ "includePath": [
"${workspaceFolder}/include", "${workspaceFolder}/include",
"${workspaceFolder}/build/include",
"${workspaceFolder}/src" "${workspaceFolder}/src"
], ],
"defines": [ "defines": [

View File

@ -6,6 +6,7 @@
"-std=gnu89", "-std=gnu89",
"-Iinclude", "-Iinclude",
"-Iinclude/PR", "-Iinclude/PR",
"-Ibuild/include",
"-Isrc", "-Isrc",
"-D_LANGUAGE_C", "-D_LANGUAGE_C",
"-DSCRIPT(...)={}", "-DSCRIPT(...)={}",

View File

@ -671,6 +671,7 @@ typedef s16 ItemId;
typedef UNK_TYPE PlayerAnim; typedef UNK_TYPE PlayerAnim;
#define PlayerAnim_STAND_STILL 0x00010000 #define PlayerAnim_STAND_STILL 0x00010000
#define PlayerAnim_CROUCH_STILL 0x00010001 #define PlayerAnim_CROUCH_STILL 0x00010001
#define PlayerAnim_2 0x00010002 // TODO
#define PlayerAnim_PANTING 0x00010003 #define PlayerAnim_PANTING 0x00010003
#define PlayerAnim_WALKING 0x00010004 #define PlayerAnim_WALKING 0x00010004
#define PlayerAnim_RUNNING 0x00010005 #define PlayerAnim_RUNNING 0x00010005

View File

@ -3,7 +3,7 @@
MenuIcon* D_802A1E80; MenuIcon* D_802A1E80;
void* D_80108A64; // an image void* D_80108A64; // an image
// Returns time to sleep for on SI_VAR(0). // Returns time to sleep for on $x.
ApiStatus N(GiveRefund)(ScriptInstance* script, s32 isInitialCall) { ApiStatus N(GiveRefund)(ScriptInstance* script, s32 isInitialCall) {
BattleStatus* battleStatus = BATTLE_STATUS; BattleStatus* battleStatus = BATTLE_STATUS;
Actor* player = PLAYER_ACTOR; Actor* player = PLAYER_ACTOR;
@ -60,93 +60,108 @@ ApiStatus N(GiveRefundCleanup)(ScriptInstance* script, s32 isInitialCall) {
return ApiStatus_DONE2; return ApiStatus_DONE2;
} }
Script D_802A1240_72F960 = SCRIPT({ /// Provide arg `TRUE` on `SI_VAR(1)` to disable refunding.
Script N(UseItemWithEffect) = SCRIPT({
if (SI_VAR(1) == 0) { if (SI_VAR(1) == 0) {
UseCamPreset(69); UseCamPreset(69); // Nice
sleep 10; sleep 10;
PlaySoundAtActor(0, 8333);
SetAnimation(0, 0, 0x1001F); PlaySoundAtActor(ActorID_PLAYER, 8333);
GetActorPos(0, SI_VAR(0), SI_VAR(1), SI_VAR(2)); SetAnimation(ActorID_PLAYER, 0, PlayerAnim_GOT_ITEM);
SI_VAR(0) += 18; GetActorPos(ActorID_PLAYER, $x, $y, $z);
SetActorSpeed(0, 4.0); $x += 18;
SetGoalPos(0, SI_VAR(0), SI_VAR(1), SI_VAR(2)); SetActorSpeed(ActorID_PLAYER, 4.0);
SetGoalPos(ActorID_PLAYER, $x, $y, $z);
PlayerRunToGoal(0); PlayerRunToGoal(0);
SI_VAR(1) += 45;
SI_VAR(3) = SI_VAR(1); $y += 45;
SI_VAR(3) += 10; $effectY = $y;
SI_VAR(3) += 2; $effectY += 10;
PlayEffect(51, 1, SI_VAR(0), SI_VAR(3), SI_VAR(2), 1.0, 30, 0, 0, 0, 0, 0, 0, 0); $effectY += 2;
MakeItemEntity(SI_VAR(10), SI_VAR(0), SI_VAR(1), SI_VAR(2), 1, 0); PlayEffect(51, 1, $x, $effectY, $z, 1.0, 30, 0, 0, 0, 0, 0, 0, 0);
SI_VAR(10) = SI_VAR(0); MakeItemEntity(SI_VAR(10), $x, $y, $z, 1, 0);
SI_VAR(10) = $x;
N(GiveRefund)(); N(GiveRefund)();
sleep SI_VAR(0); sleep $x;
sleep 15; sleep 15;
N(GiveRefundCleanup)(); N(GiveRefundCleanup)();
RemoveItemEntity(SI_VAR(10)); RemoveItemEntity(SI_VAR(10));
} else { } else {
GetActorPos(0, SI_VAR(0), SI_VAR(1), SI_VAR(2)); // No refund.
PlaySoundAtActor(0, 8333);
SetAnimation(0, 0, 0x1001F); GetActorPos(ActorID_PLAYER, $x, $y, $z);
PlaySoundAtActor(ActorID_PLAYER, 8333);
SetAnimation(ActorID_PLAYER, 0, PlayerAnim_GOT_ITEM);
sleep 4; sleep 4;
SI_VAR(1) += 45;
SI_VAR(3) = SI_VAR(1); $y += 45;
SI_VAR(3) += 10; $effectY = $y;
SI_VAR(3) += 2; $effectY += 10;
PlayEffect(51, 1, SI_VAR(0), SI_VAR(3), SI_VAR(2), 1.0, 30, 0, 0, 0, 0, 0, 0, 0); $effectY += 2;
MakeItemEntity(SI_VAR(10), SI_VAR(0), SI_VAR(1), SI_VAR(2), 1, 0); PlayEffect(51, 1, $x, $effectY, $z, 1.0, 30, 0, 0, 0, 0, 0, 0, 0);
SI_VAR(10) = SI_VAR(0); MakeItemEntity(SI_VAR(10), $x, $y, $z, 1, 0);
SI_VAR(10) = $x;
sleep 15; sleep 15;
RemoveItemEntity(SI_VAR(10)); RemoveItemEntity(SI_VAR(10));
} }
}); });
Script D_802A1544_72FC64 = SCRIPT({ Script N(UseItem) = SCRIPT({
UseCamPreset(19); UseCamPreset(19);
SetBattleCamTarget(0xFFFFFFAB, 1, 0); SetBattleCamTarget(-85, 1, 0);
SetBattleCamOffsetZ(41); SetBattleCamOffsetZ(41);
SetBattleCamZoom(248); SetBattleCamZoom(248);
MoveBattleCamOver(30); MoveBattleCamOver(30);
sleep 10; sleep 10;
SetAnimation(0, 0, 0x1001F);
GetActorPos(0, SI_VAR(0), SI_VAR(1), SI_VAR(2)); SetAnimation(ActorID_PLAYER, 0, PlayerAnim_GOT_ITEM);
SI_VAR(1) += 45; GetActorPos(ActorID_PLAYER, $x, $y, $z);
MakeItemEntity(SI_VAR(10), SI_VAR(0), SI_VAR(1), SI_VAR(2), 1, 0); $y += 45;
SI_VAR(14) = SI_VAR(0); MakeItemEntity(SI_VAR(10), $x, $y, $z, 1, 0);
SI_VAR(14) = $x;
N(GiveRefund)(); N(GiveRefund)();
sleep SI_VAR(0); sleep $x;
sleep 15; sleep 15;
N(GiveRefundCleanup)(); N(GiveRefundCleanup)();
RemoveItemEntity(SI_VAR(14)); RemoveItemEntity(SI_VAR(14));
}); });
Script D_802A1670_72FFD0 = SCRIPT({ Script N(PlayerGoHome) = SCRIPT({
UseIdleAnimation(0, 0); UseIdleAnimation(ActorID_PLAYER, 0);
SetGoalToHome(0); SetGoalToHome(ActorID_PLAYER);
SetActorSpeed(0, 8.0); SetActorSpeed(ActorID_PLAYER, 8.0);
SetAnimation(0, 0, PlayerAnim_RUNNING); SetAnimation(ActorID_PLAYER, 0, PlayerAnim_RUNNING);
PlayerRunToGoal(0); PlayerRunToGoal(0);
SetAnimation(0, 0, 0x10002);
UseIdleAnimation(0, 1); SetAnimation(ActorID_PLAYER, 0, PlayerAnim_2);
UseIdleAnimation(ActorID_PLAYER, 1);
}); });
Script Script_802A170C = SCRIPT({ Script N(EatItem) = SCRIPT({
spawn { spawn {
loop 4 { loop 4 {
PlaySoundAtActor(0, 0x2095); PlaySoundAtActor(0, 0x2095);
sleep 10; sleep 10;
} }
} }
SetAnimation(0, 0, 0x1001C); SetAnimation(ActorID_PLAYER, 0, PlayerAnim_EAT);
sleep 45; sleep 45;
}); });
Script D_802A1784_7300E4 = SCRIPT({ Script N(DrinkItem) = SCRIPT({
spawn { spawn {
loop 4 { loop 4 {
PlaySoundAtActor(0, 0x2095); PlaySoundAtActor(0, 0x2095);
sleep 10; sleep 10;
} }
} }
SetAnimation(0, 0, 0x10025); SetAnimation(ActorID_PLAYER, 0, PlayerAnim_DRINK);
sleep 45; sleep 45;
}); });

View File

@ -31,14 +31,14 @@ Gfx N(coconutDL)[] = {
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
s32 D_802A1B50_7304B0[] = { s32 N(coconutEntity)[] = {
0x00000004, 0x0000000D, 0x00000001, sizeof(N(coconutDL)) / sizeof(s32), &N(coconutDL), 0x00000002, 0x00000000, 0x00000004, 0x0000000D, 0x00000001, sizeof(N(coconutDL)) / sizeof(s32), &N(coconutDL), 0x00000002, 0x00000000,
}; };
Script N(main) = SCRIPT({ Script N(main) = SCRIPT({
SI_VAR(10) =c ItemId_COCONUT; SI_VAR(10) =c ItemId_COCONUT;
await D_802A1240_72F960; await N(UseItemWithEffect);
UseCamPreset(3); UseCamPreset(3);
MoveBattleCamOver(15); MoveBattleCamOver(15);
@ -47,7 +47,7 @@ Script N(main) = SCRIPT({
PlaySound(SoundId_THROW); PlaySound(SoundId_THROW);
sleep 3; sleep 3;
func_802D3474(SI_VAR(10), D_802A1B50_7304B0); func_802D3474(SI_VAR(10), N(coconutEntity));
$x = 1.0; $x = 1.0;
MultiplyByActorScale($x); MultiplyByActorScale($x);
@ -91,5 +91,5 @@ Script N(main) = SCRIPT({
func_802D3624(SI_VAR(10)); func_802D3624(SI_VAR(10));
await D_802A1670_72FFD0; // back to home pos await N(PlayerGoHome);
}); });

View File

@ -7,8 +7,8 @@
#undef NAMESPACE #undef NAMESPACE
#define NAMESPACE battle_item_coconut #define NAMESPACE battle_item_coconut
Script D_802A1240_72F960; Script N(UseItemWithEffect);
Script D_802A1670_72FFD0; Script N(PlayerGoHome);
ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall); ApiStatus func_802A1000_72F720(ScriptInstance* script, s32 isInitialCall);
ApiStatus func_802A11D4_72F8F4(ScriptInstance* script, s32 isInitialCall); ApiStatus func_802A11D4_72F8F4(ScriptInstance* script, s32 isInitialCall);