Skip to content

Commit

Permalink
initial prop puppet. todo: game controller/handler, prop player
Browse files Browse the repository at this point in the history
  • Loading branch information
inspectredc committed Sep 10, 2024
1 parent f50e2dc commit b81361d
Show file tree
Hide file tree
Showing 7 changed files with 880 additions and 7 deletions.
6 changes: 6 additions & 0 deletions soh/include/z64save.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ typedef struct {
Vec3f stickWeaponTip;
s16 unk_860;
s8 unk_862;
/* PropInfo */
s32 propId;
s32 propTeam;
} PlayerData;

typedef struct {
Expand Down Expand Up @@ -365,6 +368,9 @@ typedef struct {
// #region SOH [Network]
// Upstream TODO: Move these to their own struct or name to more obviously specific to Network
/* */ PlayerData playerData;
// Prop todo: Separate out into separate struct, or write directly into PlayerData
/* */ s32 propId;
/* */ s32 propTeam;
// #endregion
} SaveContext; // size = 0x1428

Expand Down
17 changes: 17 additions & 0 deletions soh/soh/ActorDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,13 +624,30 @@ static ActorDBInit EnLinkPuppetInit = {
(ActorFunc)LinkPuppet_Draw,
nullptr,
};

#include "src/overlays/actors/ovl_Link_Puppet/z_prop_puppet.h"
static ActorDBInit EnPropPuppetInit = {
"En_Prop_Puppet",
"Prop",
ACTORCAT_ITEMACTION,
(ACTOR_FLAG_UPDATE_WHILE_CULLED | ACTOR_FLAG_DRAW_WHILE_CULLED),
OBJECT_GAMEPLAY_KEEP,
sizeof(PropPuppet),
(ActorFunc)PropPuppet_Init,
(ActorFunc)PropPuppet_Destroy,
(ActorFunc)PropPuppet_Update,
(ActorFunc)PropPuppet_Draw,
nullptr,
};
#endif
extern "C" s16 gEnLinkPuppetId;
extern "C" s16 gEnPropPuppetId;

void ActorDB::AddBuiltInCustomActors() {
gEnPartnerId = ActorDB::Instance->AddEntry(EnPartnerInit).entry.id;
#ifdef ENABLE_REMOTE_CONTROL
gEnLinkPuppetId = ActorDB::Instance->AddEntry(EnLinkPuppetInit).entry.id;
gEnPropPuppetId = ActorDB::Instance->AddEntry(EnPropPuppetInit).entry.id;
#endif
}

Expand Down
19 changes: 16 additions & 3 deletions soh/soh/Enhancements/game-interactor/GameInteractor_Anchor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ extern "C" {
#include "z64scene.h"
#include "z64actor.h"
#include "functions.h"
extern "C" s16 gEnLinkPuppetId;
#include "overlays/actors/ovl_Link_Puppet/z_prop_puppet.h"
extern "C" s16 gEnPropPuppetId;
extern PlayState* gPlayState;
extern SaveContext gSaveContext;
}
Expand Down Expand Up @@ -77,6 +78,8 @@ void from_json(const json& j, PlayerData& playerData) {
j.at("stickWeaponTipZ").get_to(playerData.stickWeaponTip.z);
j.at("unk_860").get_to(playerData.unk_860);
j.at("unk_862").get_to(playerData.unk_862);
j.at("propId").get_to(playerData.propId);
j.at("propTeam").get_to(playerData.propTeam);
}

void to_json(json& j, const PlayerData& playerData) {
Expand Down Expand Up @@ -117,6 +120,8 @@ void to_json(json& j, const PlayerData& playerData) {
{ "stickWeaponTipZ", playerData.stickWeaponTip.z },
{ "unk_860", playerData.unk_860 },
{ "unk_862", playerData.unk_862 },
{ "propId", playerData.propId },
{ "propTeam", playerData.propTeam },
};
}

Expand Down Expand Up @@ -607,6 +612,8 @@ void GameInteractorAnchor::HandleRemoteJson(nlohmann::json payload) {
.message = "has killed Ganon.",
});
}
/*
Prop Todo: Stubbed -- find better way of disabling certain features
if (payload["type"] == "REQUEST_TELEPORT") {
Anchor_TeleportToPlayer(payload["clientId"].get<uint32_t>());
}
Expand All @@ -618,6 +625,7 @@ void GameInteractorAnchor::HandleRemoteJson(nlohmann::json payload) {
Play_SetRespawnData(gPlayState, RESPAWN_MODE_DOWN, entranceIndex, roomIndex, 0xDFF, &posRot.pos, posRot.rot.y);
Play_TriggerVoidOut(gPlayState);
}
*/
if (payload["type"] == "SERVER_MESSAGE") {
Anchor_DisplayMessage({
.prefix = "Server:",
Expand Down Expand Up @@ -803,7 +811,7 @@ void Anchor_RefreshClientActors() {
if (!GameInteractor::IsSaveLoaded()) return;
Actor* actor = gPlayState->actorCtx.actorLists[ACTORCAT_ITEMACTION].head;
while (actor != NULL) {
if (gEnLinkPuppetId == actor->id) {
if (gEnPropPuppetId == actor->id) {
Actor_Kill(actor);
}
actor = actor->next;
Expand All @@ -815,7 +823,7 @@ void Anchor_RefreshClientActors() {
for (auto [clientId, client] : GameInteractorAnchor::AnchorClients) {
GameInteractorAnchor::ActorIndexToClientId.push_back(clientId);
auto fairy = Actor_Spawn(
&gPlayState->actorCtx, gPlayState, gEnLinkPuppetId,
&gPlayState->actorCtx, gPlayState, gEnPropPuppetId,
client.posRot.pos.x, client.posRot.pos.y, client.posRot.pos.z,
client.posRot.rot.x, client.posRot.rot.y, client.posRot.rot.z,
3 + i, false
Expand Down Expand Up @@ -980,6 +988,11 @@ void Anchor_RegisterHooks() {
gSaveContext.playerData.stickWeaponTip = player->meleeWeaponInfo[0].tip;
gSaveContext.playerData.unk_860 = player->unk_860;
gSaveContext.playerData.unk_862 = player->unk_862;
/*
Prop Todo: figure out sourcing this
*/
gSaveContext.playerData.propId = gSaveContext.propId;
gSaveContext.playerData.propTeam = gSaveContext.propTeam;

payload["playerData"] = gSaveContext.playerData;

Expand Down
4 changes: 2 additions & 2 deletions soh/src/code/z_map_exp.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ void Map_Init(PlayState* play) {
}
}

extern s16 gEnLinkPuppetId;
extern s16 gEnPropPuppetId;

void Minimap_DrawCompassIcons(PlayState* play) {
s32 pad;
Expand Down Expand Up @@ -734,7 +734,7 @@ void Minimap_DrawCompassIcons(PlayState* play) {
// Other Anchor Players Arrow
Actor* actor = gPlayState->actorCtx.actorLists[ACTORCAT_ITEMACTION].head;
while (actor != NULL) {
if (gEnLinkPuppetId == actor->id &&
if (gEnPropPuppetId == actor->id &&
(Anchor_GetClientRoomIndex(actor->params - 3) == gPlayState->roomCtx.curRoom.num ||
(play->sceneNum >= SCENE_HYRULE_FIELD && play->sceneNum <= SCENE_OUTSIDE_GANONS_CASTLE))) {
if (actor->world.pos.x != -9999.0 && Anchor_GetClientScene(actor->params - 3) == gPlayState->sceneNum) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void BgHidanFirewall_Erupt(BgHidanFirewall* this, PlayState* play);
void BgHidanFirewall_Collide(BgHidanFirewall* this, PlayState* play);
void BgHidanFirewall_ColliderFollowPlayer(BgHidanFirewall* this, PlayState* play);

extern s16 gEnLinkPuppetId;
extern s16 gEnPropPuppetId;

const ActorInit Bg_Hidan_Firewall_InitVars = {
ACTOR_BG_HIDAN_FIREWALL,
Expand Down Expand Up @@ -97,7 +97,7 @@ s32 BgHidanFirewall_CheckProximity(BgHidanFirewall* this, PlayState* play) {
#ifdef ENABLE_REMOTE_CONTROL
Actor* actor = gPlayState->actorCtx.actorLists[ACTORCAT_ITEMACTION].head;
while (actor != NULL) {
if (gEnLinkPuppetId == actor->id && Anchor_GetClientRoomIndex(actor->params - 3) == gPlayState->roomCtx.curRoom.num && Anchor_GetClientScene(actor->params - 3) == gPlayState->sceneNum) {
if (gEnPropPuppetId == actor->id && Anchor_GetClientRoomIndex(actor->params - 3) == gPlayState->roomCtx.curRoom.num && Anchor_GetClientScene(actor->params - 3) == gPlayState->sceneNum) {
Vec3f actorDistance;
func_8002DBD0(&this->actor, &actorDistance, &actor->world.pos);
if (fabsf(actorDistance.x) < 100.0f && fabsf(actorDistance.z) < 120.0f) {
Expand Down
Loading

0 comments on commit b81361d

Please sign in to comment.