forked from AmazingAmpharos/OoT-Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
30,377 additions
and
28,942 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#include <stdint.h> | ||
#include "z64.h" | ||
#include "en_wonderitem.h" | ||
#include "get_items.h" | ||
|
||
static colorRGBA8_t sEffectPrimColorRed = { 255, 0, 0, 0 }; | ||
static colorRGBA8_t sEffectPrimColorGreen = { 0, 255, 0, 0 }; | ||
static colorRGBA8_t sEffectPrimColorBlue = { 0, 0, 255, 0 }; | ||
static colorRGBA8_t sEffectPrimColorYellow = { 255, 255, 0, 0 }; | ||
static colorRGBA8_t sEffectPrimColoMagenta = { 255, 0, 255, 0 }; | ||
static colorRGBA8_t sEffectPrimColorCyan = {0, 255, 255, 0 }; | ||
static colorRGBA8_t sEffectEnvColor = { 255, 255, 255, 0 }; | ||
//static z64_xyzf_t sEffectVelocity = { 0.0f, 0.1f, 0.0f }; | ||
//static z64_xyzf_t sEffectAccel = { 0.0f, 0.01f, 0.0f }; | ||
static z64_xyzf_t sEffectVelocity = { 0.0f, 0.5f, 0.0f }; | ||
static z64_xyzf_t sEffectAccel = { 0.0f, 0.5f, 0.0f }; | ||
|
||
|
||
extern uint16_t drop_collectible_override_flag; | ||
extern uint16_t CURR_ACTOR_SPAWN_INDEX; | ||
|
||
void EnWonderitem_AfterInitHack(z64_actor_t* this, z64_game_t* globalCtx) | ||
{ | ||
if(this->main_proc == NULL) | ||
return; | ||
if(this->actor_id != 0x112) | ||
return; | ||
|
||
EnWonderItem* wonderitem = (EnWonderItem*)this; | ||
wonderitem->overridden = 0; | ||
|
||
EnItem00 dummy; | ||
dummy.actor.actor_id = 0x15; | ||
dummy.actor.rot_init.y = this->rot_init.y; //flag was just stored in y rotation | ||
dummy.actor.variable = 0; | ||
|
||
// Check if the Wonderitem should be overridden | ||
dummy.override = lookup_override(&(dummy.actor), globalCtx->scene_index, 0); | ||
if(dummy.override.key.all != 0 && !Get_CollectibleOverrideFlag(&dummy)) | ||
{ | ||
wonderitem->overridden = 1; | ||
} | ||
} | ||
|
||
void EnWonderItem_Multitag_DrawHack(z64_xyzf_t* tags, uint32_t index, EnWonderItem* this) | ||
{ | ||
if(this->overridden) | ||
{ | ||
colorRGBA8_t* color = &sEffectPrimColorBlue; | ||
if(this->wonderMode == WONDERITEM_MULTITAG_ORDERED) | ||
color = &sEffectPrimColorCyan; | ||
z64_xyzf_t pos = tags[index]; | ||
// if(this->wonderMode != WONDERITEM_INTERACT_SWITCH) | ||
// pos.y += 20.0; | ||
z64_EffectSsKiraKira_SpawnSmall(&z64_game, &pos, &sEffectVelocity, &sEffectAccel, color, &sEffectEnvColor ); | ||
} | ||
|
||
} | ||
|
||
void EnWonderItem_DropCollectible_Hack(EnWonderItem* this, z64_game_t* globalCtx, int32_t autoCollect) | ||
{ | ||
static int16_t dropTable[] = { | ||
ITEM00_NUTS, ITEM00_HEART_PIECE, ITEM00_MAGIC_LARGE, ITEM00_MAGIC_SMALL, | ||
ITEM00_HEART, ITEM00_ARROWS_SMALL, ITEM00_ARROWS_MEDIUM, ITEM00_ARROWS_LARGE, | ||
ITEM00_RUPEE_GREEN, ITEM00_RUPEE_BLUE, ITEM00_RUPEE_RED, ITEM00_FLEXIBLE, | ||
}; | ||
int16_t i; | ||
int16_t randomDrop; | ||
|
||
// Always play the SFX | ||
z64_PlaySFXID(NA_SE_SY_GET_ITEM); | ||
|
||
// Override behavior. Spawn an overridden collectible on link | ||
if(this->overridden) | ||
{ | ||
drop_collectible_override_flag = this->actor.rot_init.y; | ||
if(autoCollect) | ||
z64_Item_DropCollectible2(globalCtx, &(z64_link.common.pos_world), 0); | ||
else | ||
z64_Item_DropCollectible(globalCtx, &this->actor.pos_world, 0); | ||
drop_collectible_override_flag = 0; | ||
if (this->switchFlag >= 0) | ||
z64_Flags_SetSwitch(globalCtx, this->switchFlag); | ||
z64_ActorKill(&this->actor); | ||
return; | ||
} | ||
|
||
// Not overridden so use vanilla behavior | ||
if (this->dropCount == 0) { | ||
this->dropCount++; | ||
} | ||
for (i = this->dropCount; i > 0; i--) { | ||
if (this->itemDrop < WONDERITEM_DROP_RANDOM) { | ||
if ((this->itemDrop == WONDERITEM_DROP_FLEXIBLE) || !autoCollect) { | ||
z64_Item_DropCollectible(globalCtx, &this->actor.pos_world, dropTable[this->itemDrop]); | ||
} else { | ||
z64_Item_DropCollectible(globalCtx, &this->actor.pos_world, dropTable[this->itemDrop] | 0x8000); | ||
} | ||
} else { | ||
randomDrop = this->itemDrop - WONDERITEM_DROP_RANDOM; | ||
if (!autoCollect) { | ||
z64_Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.pos_world, randomDrop); | ||
} else { | ||
z64_Item_DropCollectibleRandom(globalCtx, NULL, &this->actor.pos_world, randomDrop | 0x8000); | ||
} | ||
} | ||
} | ||
if (this->switchFlag >= 0) { | ||
z64_Flags_SetSwitch(globalCtx, this->switchFlag); | ||
} | ||
z64_ActorKill(&this->actor); | ||
} | ||
|
||
void EnWonderItem_Update_Hack(EnWonderItem* this) { | ||
colorRGBA8_t* color = NULL; | ||
if(this->overridden) { | ||
switch(this->wonderMode){ | ||
case(WONDERITEM_PROXIMITY_DROP): { | ||
color = &sEffectPrimColorYellow; | ||
break; | ||
} | ||
case(WONDERITEM_INTERACT_SWITCH): | ||
case(WONDERITEM_BOMB_SOLDIER): { | ||
color = &sEffectPrimColorRed; | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
if(color) { | ||
z64_EffectSsKiraKira_SpawnSmall(&z64_game, &(this->actor.pos_world), &sEffectVelocity, &sEffectAccel, color, &sEffectEnvColor ); | ||
} | ||
} | ||
} | ||
|
||
// Hack to not kill wonderitem when switch flag is set if we need to override still | ||
uint32_t EnWonderItem_Kill_Hack(EnWonderItem* this) { | ||
EnItem00 dummy; | ||
dummy.actor.actor_id = 0x15; | ||
dummy.actor.rot_init.y = (CURR_ACTOR_SPAWN_INDEX) | (this->actor.room_index << 8); | ||
dummy.actor.variable = 0; | ||
|
||
// Check if the Wonderitem should be overridden | ||
dummy.override = lookup_override(&(dummy.actor), z64_game.scene_index, 0); | ||
|
||
if(dummy.override.key.all != 0 && !Get_CollectibleOverrideFlag(&dummy)) | ||
return 0; | ||
if ((this->switchFlag >= 0) && z64_Flags_GetSwitch(&z64_game, this->switchFlag)) | ||
return 1; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef Z_EN_WONDER_ITEM_H | ||
#define Z_EN_WONDER_ITEM_H | ||
|
||
#include <stdint.h> | ||
#include "z64.h" | ||
|
||
struct EnWonderItem; | ||
|
||
typedef void (*EnWonderItemUpdateFunc)(struct EnWonderItem*, z64_game_t*); | ||
|
||
void EnWonderitem_AfterInitHack(z64_actor_t* actor, z64_game_t* game); | ||
|
||
typedef struct EnWonderItem { | ||
/* 0x0000 */ z64_actor_t actor; | ||
/* 0x013C */ EnWonderItemUpdateFunc updateFunc; | ||
/* 0x0140 */ float unkHeight; // sets height of dummied out mode 4 | ||
/* 0x0144 */ int16_t wonderMode; | ||
/* 0x0146 */ int16_t itemDrop; | ||
/* 0x0148 */ int16_t numTagPoints; | ||
/* 0x014A */ int16_t dropCount; | ||
/* 0x014C */ int16_t timer; | ||
/* 0x014E */ int16_t tagFlags; | ||
/* 0x014A */ int16_t tagCount; | ||
/* 0x0152 */ int16_t switchFlag; | ||
/* 0x0154 */ char unk_164[4]; | ||
/* 0x0158 */ int16_t nextTag; | ||
/* 0x015A */ int16_t timerMod; | ||
/* 0x015C */ z64_xyzf_t unkPos; // set to initial position by mode bomb soldier, then never used. | ||
/* 0x0168 */ char unk_178[8]; | ||
/* 0x0170 */ char collider[0x4C]; | ||
/* 0x01BC */ char unk_1CC[4]; | ||
/* 0x01C0 */ uint8_t overridden; | ||
/* 0x01C1 */ uint8_t spare[15]; | ||
} EnWonderItem; // size = 0x01D0 | ||
|
||
typedef enum { | ||
/* 0 */ WONDERITEM_MULTITAG_FREE, | ||
/* 1 */ WONDERITEM_TAG_POINT_FREE, | ||
/* 2 */ WONDERITEM_PROXIMITY_DROP, | ||
/* 3 */ WONDERITEM_INTERACT_SWITCH, | ||
/* 4 */ WONDERITEM_UNUSED, | ||
/* 5 */ WONDERITEM_MULTITAG_ORDERED, | ||
/* 6 */ WONDERITEM_TAG_POINT_ORDERED, | ||
/* 7 */ WONDERITEM_PROXIMITY_SWITCH, | ||
/* 8 */ WONDERITEM_BOMB_SOLDIER, | ||
/* 9 */ WONDERITEM_ROLL_DROP | ||
} EnWonderItemMode; | ||
|
||
typedef enum { | ||
/* 0 */ WONDERITEM_DROP_NUTS, | ||
/* 1 */ WONDERITEM_DROP_HEART_PIECE, | ||
/* 2 */ WONDERITEM_DROP_MAGIC_LARGE, | ||
/* 3 */ WONDERITEM_DROP_MAGIC_SMALL, | ||
/* 4 */ WONDERITEM_DROP_HEART, | ||
/* 5 */ WONDERITEM_DROP_ARROWS_SMALL, | ||
/* 6 */ WONDERITEM_DROP_ARROWS_MEDIUM, | ||
/* 7 */ WONDERITEM_DROP_ARROWS_LARGE, | ||
/* 8 */ WONDERITEM_DROP_GREEN_RUPEE, | ||
/* 9 */ WONDERITEM_DROP_BLUE_RUPEE, | ||
/* A */ WONDERITEM_DROP_RED_RUPEE, | ||
/* B */ WONDERITEM_DROP_FLEXIBLE, | ||
/* C */ WONDERITEM_DROP_RANDOM | ||
} EnWonderItemDrop; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.