-
Notifications
You must be signed in to change notification settings - Fork 677
Gold Skulltula/Skullwalltula (En_Sw, En_Si, Obj_Makekinsuta) #2729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
a9bf86d
3e14b81
9ce45cd
d7138ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,15 +16,19 @@ | |||||||||||||||||
|
|
||||||||||||||||||
| #define FLAGS (ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOOKSHOT_PULLS_ACTOR) | ||||||||||||||||||
|
|
||||||||||||||||||
| // Params are set by spawning Gold Skulltula | ||||||||||||||||||
| #define ENSI_GS_AREA(this) PARAMS_GET_S(this->actor.params, 8, 5) // mapIndex for current area | ||||||||||||||||||
| #define ENSI_GS_ID(this) PARAMS_GET_S(this->actor.params, 0, 8) // ID flag for this Gold Skulltula | ||||||||||||||||||
|
|
||||||||||||||||||
| void EnSi_Init(Actor* thisx, PlayState* play); | ||||||||||||||||||
| void EnSi_Destroy(Actor* thisx, PlayState* play); | ||||||||||||||||||
| void EnSi_Update(Actor* thisx, PlayState* play); | ||||||||||||||||||
| void EnSi_Draw(Actor* thisx, PlayState* play); | ||||||||||||||||||
|
|
||||||||||||||||||
| s32 func_80AFB748(EnSi* this, PlayState* play); | ||||||||||||||||||
| void func_80AFB768(EnSi* this, PlayState* play); | ||||||||||||||||||
| void func_80AFB89C(EnSi* this, PlayState* play); | ||||||||||||||||||
| void func_80AFB950(EnSi* this, PlayState* play); | ||||||||||||||||||
| s32 EnSi_RemoveAC(EnSi* this, PlayState* play); | ||||||||||||||||||
| void EnSi_Action_Idle(EnSi* this, PlayState* play); | ||||||||||||||||||
| void EnSi_Action_HookshotPull(EnSi* this, PlayState* play); | ||||||||||||||||||
| void EnSi_Action_WaitTextbox(EnSi* this, PlayState* play); | ||||||||||||||||||
|
|
||||||||||||||||||
| static ColliderCylinderInit sCylinderInit = { | ||||||||||||||||||
| { | ||||||||||||||||||
|
|
@@ -46,7 +50,7 @@ static ColliderCylinderInit sCylinderInit = { | |||||||||||||||||
| { 20, 18, 2, { 0, 0, 0 } }, | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| static CollisionCheckInfoInit2 D_80AFBADC = { 0, 0, 0, 0, MASS_IMMOVABLE }; | ||||||||||||||||||
| static CollisionCheckInfoInit2 sEnSiColliderInfo = { 0, 0, 0, 0, MASS_IMMOVABLE }; | ||||||||||||||||||
|
|
||||||||||||||||||
| ActorProfile En_Si_Profile = { | ||||||||||||||||||
| /**/ ACTOR_EN_SI, | ||||||||||||||||||
|
|
@@ -65,10 +69,10 @@ void EnSi_Init(Actor* thisx, PlayState* play) { | |||||||||||||||||
|
|
||||||||||||||||||
| Collider_InitCylinder(play, &this->collider); | ||||||||||||||||||
| Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); | ||||||||||||||||||
| CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &D_80AFBADC); | ||||||||||||||||||
| CollisionCheck_SetInfo2(&this->actor.colChkInfo, NULL, &sEnSiColliderInfo); | ||||||||||||||||||
| Actor_SetScale(&this->actor, 0.025f); | ||||||||||||||||||
| this->unk_19C = 0; | ||||||||||||||||||
| this->actionFunc = func_80AFB768; | ||||||||||||||||||
| this->unused_19C = 0; | ||||||||||||||||||
| this->actionFunc = EnSi_Action_Idle; | ||||||||||||||||||
| this->actor.shape.yOffset = 42.0f; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -78,33 +82,36 @@ void EnSi_Destroy(Actor* thisx, PlayState* play) { | |||||||||||||||||
| Collider_DestroyCylinder(play, &this->collider); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| s32 func_80AFB748(EnSi* this, PlayState* play) { | ||||||||||||||||||
| s32 EnSi_RemoveAC(EnSi* this, PlayState* play) { | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RemoveAC isn't really an appropriate name. The way collision_check colliders work is that the actor has to pass them to the collision_check engine by calling CollisionCheck_SetAT/AC/OC every update cycle for them to be "active". Then on next update cycle, the AT-AC collisions and OC collisions are processed, with the results becoming available to the actors through the collider struct. When CollisionCheck_SetAT/AC/OC is called, the appropriate AT/AC/OC_HIT flags are zeroed on the collider. But you'll often see the flag manually being zeroed immediately after being checked. I believe the reason for this pattern is that there will be cases in some actors where a collider won't always be active, and so you see it get zeroed so that it doesn't get double processed, simplifying logic. So it's not really that the collider is being "removed". To me it looks like this code might be some incomplete codeblock for detecting hookshot/boomerang collision
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I couldn't figure this one out, why remove the AC hit flag. Any name suggestion?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest HandleACHit but idk 🤷 |
||||||||||||||||||
| if (this->collider.base.acFlags & AC_HIT) { | ||||||||||||||||||
| this->collider.base.acFlags &= ~AC_HIT; | ||||||||||||||||||
| } | ||||||||||||||||||
| return 0; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| void func_80AFB768(EnSi* this, PlayState* play) { | ||||||||||||||||||
| /** | ||||||||||||||||||
| * Rotate, wait for player to Hookshot or pick up | ||||||||||||||||||
| */ | ||||||||||||||||||
| void EnSi_Action_Idle(EnSi* this, PlayState* play) { | ||||||||||||||||||
| Player* player = GET_PLAYER(play); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (ACTOR_FLAGS_CHECK_ALL(&this->actor, ACTOR_FLAG_HOOKSHOT_ATTACHED)) { | ||||||||||||||||||
| this->actionFunc = func_80AFB89C; | ||||||||||||||||||
| this->actionFunc = EnSi_Action_HookshotPull; | ||||||||||||||||||
| } else { | ||||||||||||||||||
| Math_SmoothStepToF(&this->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f); | ||||||||||||||||||
| Actor_SetScale(&this->actor, this->actor.scale.x); | ||||||||||||||||||
| this->actor.shape.rot.y += 0x400; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (!Player_InCsMode(play)) { | ||||||||||||||||||
| func_80AFB748(this, play); | ||||||||||||||||||
| EnSi_RemoveAC(this, play); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (this->collider.base.ocFlags2 & OC2_HIT_PLAYER) { | ||||||||||||||||||
| this->collider.base.ocFlags2 &= ~OC2_HIT_PLAYER; | ||||||||||||||||||
| Item_Give(play, ITEM_SKULL_TOKEN); | ||||||||||||||||||
| player->actor.freezeTimer = 10; | ||||||||||||||||||
| Message_StartTextbox(play, 0xB4, NULL); | ||||||||||||||||||
| Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); | ||||||||||||||||||
| this->actionFunc = func_80AFB950; | ||||||||||||||||||
| this->actionFunc = EnSi_Action_WaitTextbox; | ||||||||||||||||||
| } else { | ||||||||||||||||||
| Collider_UpdateCylinder(&this->actor, &this->collider); | ||||||||||||||||||
| CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); | ||||||||||||||||||
|
|
@@ -114,7 +121,10 @@ void func_80AFB768(EnSi* this, PlayState* play) { | |||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| void func_80AFB89C(EnSi* this, PlayState* play) { | ||||||||||||||||||
| /** | ||||||||||||||||||
| * Pulled by Hookshot towards player, give item when detached | ||||||||||||||||||
| */ | ||||||||||||||||||
| void EnSi_Action_HookshotPull(EnSi* this, PlayState* play) { | ||||||||||||||||||
|
Comment on lines
+124
to
+127
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Despite the flag names, this should also handle being collected by the boomerang. Additionally, we typically don't use Action to name actionFuncs
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will add Boomerang comment, forgot about that. I assume the function still can be Hookshot-named like the flag? As changing it to something like FetchToken isn't as clear. For action functions, I see, is it something decided upon? I'm OK with changing it (especially for En_Si and Obj_Makekinsuta which are so short), but personally I find it so helpful when looking at new actors that the first thing I do is rename all action functions into
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah the pattern overall is
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I don't see the positive aspects of cramming everything into |
||||||||||||||||||
| Player* player = GET_PLAYER(play); | ||||||||||||||||||
|
|
||||||||||||||||||
| Math_SmoothStepToF(&this->actor.scale.x, 0.25f, 0.4f, 1.0f, 0.0f); | ||||||||||||||||||
|
|
@@ -126,17 +136,20 @@ void func_80AFB89C(EnSi* this, PlayState* play) { | |||||||||||||||||
| player->actor.freezeTimer = 10; | ||||||||||||||||||
| Message_StartTextbox(play, 0xB4, NULL); | ||||||||||||||||||
| Audio_PlayFanfare(NA_BGM_SMALL_ITEM_GET); | ||||||||||||||||||
| this->actionFunc = func_80AFB950; | ||||||||||||||||||
| this->actionFunc = EnSi_Action_WaitTextbox; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| void func_80AFB950(EnSi* this, PlayState* play) { | ||||||||||||||||||
| /** | ||||||||||||||||||
| * Wait for textbox to close, then set token as collected and kill actor | ||||||||||||||||||
| */ | ||||||||||||||||||
| void EnSi_Action_WaitTextbox(EnSi* this, PlayState* play) { | ||||||||||||||||||
| Player* player = GET_PLAYER(play); | ||||||||||||||||||
|
|
||||||||||||||||||
| if (Message_GetState(&play->msgCtx) != TEXT_STATE_CLOSING) { | ||||||||||||||||||
| player->actor.freezeTimer = 10; | ||||||||||||||||||
| } else { | ||||||||||||||||||
| SET_GS_FLAGS(PARAMS_GET_S(this->actor.params, 8, 5), PARAMS_GET_S(this->actor.params, 0, 8)); | ||||||||||||||||||
| SET_GS_FLAGS(ENSI_GS_AREA(this), ENSI_GS_ID(this)); | ||||||||||||||||||
| Actor_Kill(&this->actor); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
@@ -153,7 +166,7 @@ void EnSi_Update(Actor* thisx, PlayState* play) { | |||||||||||||||||
| void EnSi_Draw(Actor* thisx, PlayState* play) { | ||||||||||||||||||
| EnSi* this = (EnSi*)thisx; | ||||||||||||||||||
|
|
||||||||||||||||||
| if (this->actionFunc != func_80AFB950) { | ||||||||||||||||||
| if (this->actionFunc != EnSi_Action_WaitTextbox) { | ||||||||||||||||||
| func_8002ED80(&this->actor, play, 0); | ||||||||||||||||||
| func_8002EBCC(&this->actor, play, 0); | ||||||||||||||||||
| GetItem_Draw(play, GID_SKULL_TOKEN_2); | ||||||||||||||||||
|
|
||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.