1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-25 01:34:18 +00:00

Document ACTOR_FLAG_THROW_ONLY (#2274)

* document ACTOR_FLAG_THROW_ONLY

* flip function name

* add comments
This commit is contained in:
fig02 2024-10-15 14:10:21 -04:00 committed by GitHub
parent a53fb02699
commit df1815cf8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 22 additions and 12 deletions

View file

@ -184,8 +184,9 @@ typedef struct ActorShape {
// ignores point lights but not directional lights (such as environment lights) // ignores point lights but not directional lights (such as environment lights)
#define ACTOR_FLAG_IGNORE_POINT_LIGHTS (1 << 22) #define ACTOR_FLAG_IGNORE_POINT_LIGHTS (1 << 22)
// // When Player is carrying this actor, it can only be thrown, not dropped/placed.
#define ACTOR_FLAG_23 (1 << 23) // Typically an actor can only be thrown when moving, but this allows an actor to be thrown when standing still.
#define ACTOR_FLAG_THROW_ONLY (1 << 23)
// //
#define ACTOR_FLAG_24 (1 << 24) #define ACTOR_FLAG_24 (1 << 24)

View file

@ -11,7 +11,7 @@
#include "quake.h" #include "quake.h"
#include "terminal.h" #include "terminal.h"
#define FLAGS ACTOR_FLAG_23 #define FLAGS ACTOR_FLAG_THROW_ONLY
void EnIshi_Init(Actor* thisx, PlayState* play); void EnIshi_Init(Actor* thisx, PlayState* play);
void EnIshi_Destroy(Actor* thisx, PlayState* play2); void EnIshi_Destroy(Actor* thisx, PlayState* play2);

View file

@ -12,7 +12,7 @@
#include "assets/objects/object_kusa/object_kusa.h" #include "assets/objects/object_kusa/object_kusa.h"
#include "terminal.h" #include "terminal.h"
#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_THROW_ONLY)
void EnKusa_Init(Actor* thisx, PlayState* play); void EnKusa_Init(Actor* thisx, PlayState* play);
void EnKusa_Destroy(Actor* thisx, PlayState* play2); void EnKusa_Destroy(Actor* thisx, PlayState* play2);

View file

@ -10,7 +10,7 @@
#include "terminal.h" #include "terminal.h"
#include "versions.h" #include "versions.h"
#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_THROW_ONLY)
void EnNiw_Init(Actor* thisx, PlayState* play); void EnNiw_Init(Actor* thisx, PlayState* play);
void EnNiw_Destroy(Actor* thisx, PlayState* play); void EnNiw_Destroy(Actor* thisx, PlayState* play);

View file

@ -9,7 +9,7 @@
#include "assets/objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #include "assets/objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h"
#include "assets/objects/object_tsubo/object_tsubo.h" #include "assets/objects/object_tsubo/object_tsubo.h"
#define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_23) #define FLAGS (ACTOR_FLAG_4 | ACTOR_FLAG_THROW_ONLY)
void ObjTsubo_Init(Actor* thisx, PlayState* play); void ObjTsubo_Init(Actor* thisx, PlayState* play);
void ObjTsubo_Destroy(Actor* thisx, PlayState* play2); void ObjTsubo_Destroy(Actor* thisx, PlayState* play2);

View file

@ -7423,20 +7423,29 @@ void func_8083EA94(Player* this, PlayState* play) {
Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_throw, this->modelAnimType)); Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_throw, this->modelAnimType));
} }
s32 func_8083EAF0(Player* this, Actor* actor) { /**
if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_23) && * Checks if an actor can be thrown or dropped.
* It is assumed that the `actor` argument is the actor currently being carried.
*
* @return true if it can be thrown, false if it can be dropped.
*/
s32 Player_CanThrowCarriedActor(Player* this, Actor* actor) {
// If the actor arg is null, true will be returned.
// It doesn't make sense for a non-existent actor to be thrown or dropped, so
// the safety check should happen before this function is even called.
if ((actor != NULL) && !(actor->flags & ACTOR_FLAG_THROW_ONLY) &&
((this->speedXZ < 1.1f) || (actor->id == ACTOR_EN_BOM_CHU))) { ((this->speedXZ < 1.1f) || (actor->id == ACTOR_EN_BOM_CHU))) {
return 0; return false;
} }
return 1; return true;
} }
s32 Player_ActionHandler_9(Player* this, PlayState* play) { s32 Player_ActionHandler_9(Player* this, PlayState* play) {
if ((this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) && (this->heldActor != NULL) && if ((this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) && (this->heldActor != NULL) &&
CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) { CHECK_BTN_ANY(sControlInput->press.button, BTN_A | BTN_B | BTN_CLEFT | BTN_CDOWN | BTN_CRIGHT)) {
if (!func_80835644(play, this, this->heldActor)) { if (!func_80835644(play, this, this->heldActor)) {
if (!func_8083EAF0(this, this->heldActor)) { if (!Player_CanThrowCarriedActor(this, this->heldActor)) {
Player_SetupAction(play, this, Player_Action_808464B0, 1); Player_SetupAction(play, this, Player_Action_808464B0, 1);
Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_put, this->modelAnimType)); Player_AnimPlayOnce(play, this, GET_PLAYER_ANIM(PLAYER_ANIMGROUP_put, this->modelAnimType));
} else { } else {
@ -10897,7 +10906,7 @@ void Player_UpdateInterface(PlayState* play, Player* this) {
} else if ((this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) && (this->getItemId == GI_NONE) && } else if ((this->stateFlags1 & PLAYER_STATE1_CARRYING_ACTOR) && (this->getItemId == GI_NONE) &&
(heldActor != NULL)) { (heldActor != NULL)) {
if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (heldActor->id == ACTOR_EN_NIW)) { if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (heldActor->id == ACTOR_EN_NIW)) {
if (func_8083EAF0(this, heldActor) == 0) { if (!Player_CanThrowCarriedActor(this, heldActor)) {
doAction = DO_ACTION_DROP; doAction = DO_ACTION_DROP;
} else { } else {
doAction = DO_ACTION_THROW; doAction = DO_ACTION_THROW;