From 4f2bb984f2abb6d77316444467398710c54e64d2 Mon Sep 17 00:00:00 2001 From: CraftyBoss Date: Fri, 8 Jul 2022 15:09:04 -0700 Subject: [PATCH] begin work on join/disconnect particle effect, fix index oob error --- include/actors/PuppetActor.h | 10 ++++++---- include/main.hpp | 2 -- source/main.cpp | 14 ++++++-------- source/puppets/PuppetActor.cpp | 32 +++++++++++++++++--------------- source/puppets/PuppetHolder.cpp | 9 +++++++-- source/server/Client.cpp | 6 +++--- 6 files changed, 39 insertions(+), 34 deletions(-) diff --git a/include/actors/PuppetActor.h b/include/actors/PuppetActor.h index 3f88254..b10868b 100644 --- a/include/actors/PuppetActor.h +++ b/include/actors/PuppetActor.h @@ -66,27 +66,29 @@ class PuppetActor : public al::LiveActor { void debugTeleportCapture(const sead::Vector3f& pos, int index); - bool mIsDebug = false; + void emitJoinEffect(); - float mClosingSpeed = 0; + bool mIsDebug = false; - NameTag *mNameTag = nullptr; // temp public private: void changeModel(const char* newModel); bool setCapture(const char* captureName); void syncPose(); - + PlayerCostumeInfo *mCostumeInfo = nullptr; PuppetInfo *mInfo = nullptr; PuppetCapActor *mPuppetCap = nullptr; PlayerModelHolder *mModelHolder = nullptr; HackModelHolder* mCaptures = nullptr; + NameTag *mNameTag = nullptr; CaptureTypes::Type mCurCapture = CaptureTypes::Type::Unknown; bool mIs2DModel = false; bool mIsCaptureModel = false; + + float mClosingSpeed = 0; }; diff --git a/include/main.hpp b/include/main.hpp index 7b82e89..548f2f7 100644 --- a/include/main.hpp +++ b/include/main.hpp @@ -51,8 +51,6 @@ #include "Keyboard.hpp" #include "server/DeltaTime.hpp" -static const int playBufSize = 8; - static bool isInGame = false; static bool debugMode = false; diff --git a/source/main.cpp b/source/main.cpp index 871878d..74b9010 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -167,12 +167,6 @@ void drawMainHook(HakoniwaSequence *curSequence, sead::Viewport *viewport, sead: al::LiveActor *curModel = debugPuppet->getCurrentModel(); - gTextWriter->printf("Is Nametag Visible: %s\n", BTOC(debugPuppet->mNameTag->isVisible())); - gTextWriter->printf("Is Nametag Alive: %s\n", BTOC(debugPuppet->mNameTag->mIsAlive)); - gTextWriter->printf("Nametag Normalized Dist: %f\n", debugPuppet->mNameTag->mNormalizedDist); - gTextWriter->printf("Nametag State: %s\n", debugPuppet->mNameTag->getCurrentState()); - gTextWriter->printf("Is Current Model Clipped: %s\n", - BTOC(al::isClipped(curModel))); gTextWriter->printf("Is Debug Puppet Tagged: %s\n", BTOC(debugInfo->isIt)); } @@ -370,9 +364,13 @@ bool hakoniwaSequenceHook(HakoniwaSequence* sequence) { } if (al::isPadTriggerUp(-1)) { if (debugMode) { - PuppetInfo* debugPuppet = Client::getDebugPuppetInfo(); + PuppetActor* debugPuppet = Client::getDebugPuppet(); if (debugPuppet) { - debugPuppet->isIt = !debugPuppet->isIt; + PuppetInfo *info = debugPuppet->getInfo(); + // info->isIt = !info->isIt; + + debugPuppet->emitJoinEffect(); + } } else { isDisableMusic = !isDisableMusic; diff --git a/source/puppets/PuppetActor.cpp b/source/puppets/PuppetActor.cpp index 1a5fdb2..2478571 100644 --- a/source/puppets/PuppetActor.cpp +++ b/source/puppets/PuppetActor.cpp @@ -1,4 +1,5 @@ #include +#include #include "al/util/SensorUtil.h" #include "rs/util/SensorUtil.h" #include "server/Client.hpp" @@ -217,19 +218,15 @@ void PuppetActor::makeActorAlive() { curModel->makeActorAlive(); } - if (al::isDead(this)) { - - // update name tag when puppet becomes active again - if (mInfo) { - if (mNameTag) { - mNameTag->setText(mInfo->puppetName); - } + // update name tag when puppet becomes active again + if (mInfo) { + if (mNameTag) { + mNameTag->setText(mInfo->puppetName); } - - al::LiveActor::makeActorAlive(); - } + al::LiveActor::makeActorAlive(); + } void PuppetActor::makeActorDead() { @@ -240,11 +237,9 @@ void PuppetActor::makeActorDead() { curModel->makeActorDead(); } - if (!al::isDead(this)) { - mPuppetCap->makeActorDead(); // make sure we kill the cap puppet along with regular puppet - - al::LiveActor::makeActorDead(); - } + mPuppetCap->makeActorDead(); + + al::LiveActor::makeActorDead(); } void PuppetActor::attackSensor(al::HitSensor* source, al::HitSensor* target) { @@ -403,3 +398,10 @@ void PuppetActor::syncPose() { al::setTrans(curModel, al::getTrans(this)); } + +void PuppetActor::emitJoinEffect() { + + al::tryDeleteEffect(this, "Disappear"); // remove previous effect (if played previously) + + al::tryEmitEffect(this, "Disappear", nullptr); +} \ No newline at end of file diff --git a/source/puppets/PuppetHolder.cpp b/source/puppets/PuppetHolder.cpp index d650478..f730c7b 100644 --- a/source/puppets/PuppetHolder.cpp +++ b/source/puppets/PuppetHolder.cpp @@ -2,6 +2,7 @@ #include #include "actors/PuppetActor.h" #include "al/util.hpp" +#include "al/util/LiveActorUtil.h" #include "container/seadPtrArray.h" #include "heap/seadHeap.h" #include "heap/seadHeapMgr.h" @@ -78,10 +79,14 @@ void PuppetHolder::update() { curInfo->isInSameStage = checkInfoIsInStage(curInfo); - if(curInfo->isInSameStage) { + if(curInfo->isInSameStage && al::isDead(curPuppet)) { curPuppet->makeActorAlive(); - }else if(!curInfo->isInSameStage) { + + curPuppet->emitJoinEffect(); + }else if(!curInfo->isInSameStage && !al::isDead(curPuppet)) { curPuppet->makeActorDead(); + + curPuppet->emitJoinEffect(); } } } diff --git a/source/server/Client.cpp b/source/server/Client.cpp index 7d2ce93..2380692 100644 --- a/source/server/Client.cpp +++ b/source/server/Client.cpp @@ -82,13 +82,13 @@ Client::Client() { nn::account::GetLastOpenedUser(&mUserID); - mUserID.print(); - nn::account::Nickname playerName; nn::account::GetNickname(&playerName, mUserID); Logger::setLogName(playerName.name); // set Debug logger name to player name mUsername = playerName.name; + + mUserID.print(); Logger::log("Player Name: %s\n", playerName.name); @@ -1064,7 +1064,7 @@ PuppetInfo* Client::findPuppetInfo(const nn::account::Uid& id, bool isFindAvaila PuppetInfo *firstAvailable = nullptr; - for (size_t i = 0; i < getMaxPlayerCount(); i++) { + for (size_t i = 0; i < getMaxPlayerCount() - 1; i++) { PuppetInfo* curInfo = mPuppetInfoArr[i];