mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-07-30 11:39:07 -07:00
Hookify TreesDropSticks (#5566)
* Hookify TreesDropSticks * fix off by one
This commit is contained in:
parent
dbc2ff09b5
commit
af99ef8e07
4 changed files with 51 additions and 9 deletions
31
soh/soh/Enhancements/TreesDropSticks.cpp
Normal file
31
soh/soh/Enhancements/TreesDropSticks.cpp
Normal file
|
@ -0,0 +1,31 @@
|
|||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||
#include "soh/ShipInit.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "src/overlays/actors/ovl_En_Wood02/z_en_wood02.h"
|
||||
}
|
||||
|
||||
extern PlayState* gPlayState;
|
||||
|
||||
void RegisterTreesDropSticks() {
|
||||
COND_VB_SHOULD(VB_TREE_DROP_COLLECTIBLE, CVarGetInteger(CVAR_ENHANCEMENT("TreesDropSticks"), 0), {
|
||||
if (INV_CONTENT(ITEM_STICK) != ITEM_NONE) {
|
||||
EnWood02* tree = va_arg(args, EnWood02*);
|
||||
Vec3f dropsSpawnPt = tree->actor.world.pos;
|
||||
dropsSpawnPt.y += 200.0f;
|
||||
|
||||
*should = false;
|
||||
for (s32 numDrops = Rand_Next() % 4; numDrops > 0; numDrops--) {
|
||||
Item_DropCollectible(gPlayState, &dropsSpawnPt, ITEM00_STICK);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
COND_VB_SHOULD(VB_PREVENT_ADULT_STICK, CVarGetInteger(CVAR_ENHANCEMENT("TreesDropSticks"), 0), {
|
||||
if (INV_CONTENT(ITEM_STICK) != ITEM_NONE) {
|
||||
*should = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static RegisterShipInitFunc initFunc(RegisterTreesDropSticks, { CVAR_ENHANCEMENT("TreesDropSticks") });
|
|
@ -1697,6 +1697,15 @@ typedef enum {
|
|||
// - `*ObjTsubo`
|
||||
VB_POT_SETUP_DRAW,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// dropId == ITEM00_STICK
|
||||
// ```
|
||||
// #### `args`
|
||||
// - None
|
||||
VB_PREVENT_ADULT_STICK,
|
||||
|
||||
// #### `result`
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
|
@ -2073,6 +2082,13 @@ typedef enum {
|
|||
VB_TRANSITION_TO_SAVE_SCREEN_ON_DEATH,
|
||||
|
||||
// #### `result`
|
||||
// ```c
|
||||
// true
|
||||
// ```
|
||||
// #### `args`
|
||||
// - `*EnWood02`
|
||||
VB_TREE_DROP_COLLECTIBLE,
|
||||
|
||||
// ```c
|
||||
// true
|
||||
// ```
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "overlays/effects/ovl_Effect_Ss_Dead_Sound/z_eff_ss_dead_sound.h"
|
||||
#include "textures/icon_item_static/icon_item_static.h"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||
#include "soh/OTRGlobals.h"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||
#include "soh/OTRGlobals.h"
|
||||
|
||||
#define FLAGS 0
|
||||
|
||||
|
@ -1536,7 +1536,7 @@ s16 func_8001F404(s16 dropId) {
|
|||
if (LINK_IS_ADULT) {
|
||||
if (dropId == ITEM00_SEEDS) {
|
||||
dropId = ITEM00_ARROWS_SMALL;
|
||||
} else if ((dropId == ITEM00_STICK) && !(CVarGetInteger(CVAR_ENHANCEMENT("TreesDropSticks"), 0))) {
|
||||
} else if (GameInteractor_Should(VB_PREVENT_ADULT_STICK, dropId == ITEM00_STICK)) {
|
||||
dropId = ITEM00_RUPEE_GREEN;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "z_en_wood02.h"
|
||||
#include "objects/object_wood02/object_wood02.h"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||
|
||||
#define FLAGS 0
|
||||
|
||||
|
@ -327,7 +328,6 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) {
|
|||
Vec3f dropsSpawnPt;
|
||||
s32 i;
|
||||
s32 leavesParams;
|
||||
s32 numDrops;
|
||||
|
||||
// Despawn extra trees in a group if out of range
|
||||
if ((this->spawnType == WOOD_SPAWN_SPAWNED) && (this->actor.parent != NULL)) {
|
||||
|
@ -358,12 +358,7 @@ void EnWood02_Update(Actor* thisx, PlayState* play2) {
|
|||
dropsSpawnPt.y += 200.0f;
|
||||
|
||||
if ((this->unk_14C >= 0) && (this->unk_14C < 0x64)) {
|
||||
if (CVarGetInteger(CVAR_ENHANCEMENT("TreesDropSticks"), 0) && INV_CONTENT(ITEM_STICK) != ITEM_NONE) {
|
||||
numDrops = Rand_ZeroOne() * 4;
|
||||
for (i = 0; i < numDrops; ++i) {
|
||||
Item_DropCollectible(play, &dropsSpawnPt, ITEM00_STICK);
|
||||
}
|
||||
} else {
|
||||
if (GameInteractor_Should(VB_TREE_DROP_COLLECTIBLE, true, this)) {
|
||||
Item_DropCollectibleRandom(play, &this->actor, &dropsSpawnPt, this->unk_14C << 4);
|
||||
}
|
||||
} else if (this->actor.home.rot.z != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue