From 5f3a8644a708e86a3a9f507fbecccfe854449578 Mon Sep 17 00:00:00 2001 From: Edmond Mondor Date: Mon, 24 Jan 2022 14:22:04 -0800 Subject: [PATCH 1/2] Files for Allowing disabling avatar panic links --- .../FeatureLib/pfCamera/plVirtualCamNeu.cpp | 16 ++++++++++++++++ .../Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h | 2 ++ Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp | 9 +++++++++ Sources/Plasma/FeatureLib/pfPython/cyAvatar.h | 8 ++++++++ .../Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp | 14 ++++++++++++++ .../Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp | 8 ++++---- .../Plasma/PubUtilLib/plAvatar/plArmatureMod.h | 4 +++- 7 files changed, 56 insertions(+), 5 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp index 85390771..d74605bb 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp +++ b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp @@ -499,6 +499,22 @@ void plVirtualCam1::SetCutNextTrans() #endif } +void plVirtualCam1::SetCutNext() +{ + plCameraModifier1* cam = GetCurrentCamera(); + if (cam && cam->GetBrain()) { + cam->GetBrain()->SetFlags(plCameraBrain1::kCutPosOnce); + cam->GetBrain()->SetFlags(plCameraBrain1::kCutPOAOnce); + } + + SetFlags(kCutNextTrans); + SetRender(true); + +#ifdef STATUS_LOG + camLog->AddLineF("Set Camera to cut on next frame"); +#endif +} + void plVirtualCam1::SetRender(hsBool render) { fFlags.SetBit(kRender,render); diff --git a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h index 0f4ebf07..6649eabc 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h +++ b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.h @@ -85,6 +85,7 @@ public: enum flags { kSetFOV, + /** Forces the next camera transition to be cut. */ kCutNextTrans, kRender, kRegionIgnore, @@ -145,6 +146,7 @@ public: hsPoint3 GetCameraPOA() { return fOutputPOA; } hsVector3 GetCameraUp() { return fOutputUp; } void SetCutNextTrans(); // used when player warps into a new camera region + void SetCutNext(); const hsMatrix44 GetCurrentMatrix() { return fMatrix; } static plVirtualCam1* Instance() { return fInstance; } diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp index cd5d123e..0d81bbba 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp @@ -1978,3 +1978,12 @@ hsBool cyAvatar::IsCurrentBrainHuman() } return false; } + +void cyAvatar::SetDontPanicLink(bool value) +{ + if (!fRecvr.empty()) { + plArmatureMod* mod = plAvatarMgr::FindAvatar(fRecvr[0]); + if (mod) + mod->SetDontPanicLinkFlag(value); + } +} diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h index e21a8929..168c748b 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h @@ -566,6 +566,14 @@ public: static hsBool IsCurrentBrainHuman(); + ///////////////////////////////////////////////////////////////////////////// + // + // Function : SetDontPanicLink + // PARAMETERS : value + // + // PURPOSE : Disables panic linking to Personal Age (warps the avatar back to the start instead) + // + void SetDontPanicLink(bool value); }; #endif // cyAvatar_h diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp index 8a538415..96b39c2c 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp @@ -597,6 +597,18 @@ PYTHON_METHOD_DEFINITION(ptAvatar, playSimpleAnimation, args) PYTHON_RETURN_NONE; } +PYTHON_METHOD_DEFINITION(ptAvatar, setDontPanicLink, args) +{ + bool value; + if (!PyArg_ParseTuple(args, "b", &value)) { + PyErr_SetString(PyExc_TypeError, "setDontPanicLink expects a boolean"); + PYTHON_RETURN_ERROR; + } + + self->fThis->SetDontPanicLink(value); + PYTHON_RETURN_NONE; +} + PYTHON_START_METHODS_TABLE(ptAvatar) PYTHON_METHOD(ptAvatar, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n" "- This is to be used if your Python program is running on only one client\n" @@ -651,6 +663,8 @@ PYTHON_START_METHODS_TABLE(ptAvatar) PYTHON_METHOD(ptAvatar, unRegisterForBehaviorNotify, "Params: selfKey\nThis will unregister behavior notifications"), PYTHON_METHOD(ptAvatar, playSimpleAnimation, "Params: animName\nPlay simple animation on avatar"), + + PYTHON_METHOD(ptAvatar, setDontPanicLink, "Params: value\nDisables panic linking to Personal Age (warps the avatar back to the start instead)"), PYTHON_END_METHODS_TABLE; PYTHON_GLOBAL_METHOD_DEFINITION(PtSetBehaviorLoopCount, args, "Params: behaviorKey,stage,loopCount,netForce\nThis will set the loop count for a particular stage in a multistage behavior") diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 90fc261c..b3660d6a 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -865,10 +865,10 @@ void plArmatureMod::SpawnAt(int spawnNum, double time) w2l.RemoveScale(); ci->SetTransform(l2w, w2l); ci->FlushTransform(); - - if (plVirtualCam1::Instance()) - plVirtualCam1::Instance()->SetCutNextTrans(); - + + if (IsLocalAvatar() && plVirtualCam1::Instance()) + plVirtualCam1::Instance()->SetCutNext(); + if (GetFollowerParticleSystemSO()) { // Since particles are in world space, if we've got some surrounding us, we've got to translate them to compensate for our warp. diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h index b79f2105..77eecb45 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.h @@ -234,7 +234,9 @@ public: virtual void PanicLink(hsBool playLinkOutAnim = true); virtual void PersonalLink(); - virtual bool ToggleDontPanicLinkFlag() { fDontPanicLink = fDontPanicLink ? false : true; return fDontPanicLink; } + bool ToggleDontPanicLinkFlag() { fDontPanicLink = fDontPanicLink ? false : true; return fDontPanicLink; } + + void SetDontPanicLinkFlag(bool value) { fDontPanicLink = value; } int GetBrainCount(); plArmatureBrain *GetNextBrain(plArmatureBrain *brain); From e81af06584e926ad03bd9352d423a1ff907f9ff7 Mon Sep 17 00:00:00 2001 From: Edmond Mondor Date: Mon, 24 Jan 2022 19:06:23 -0800 Subject: [PATCH 2/2] Fix error due to no Empty() --- Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp index 0d81bbba..2c7d61da 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp @@ -1981,7 +1981,7 @@ hsBool cyAvatar::IsCurrentBrainHuman() void cyAvatar::SetDontPanicLink(bool value) { - if (!fRecvr.empty()) { + if ( fRecvr.Count() > 0 ) { plArmatureMod* mod = plAvatarMgr::FindAvatar(fRecvr[0]); if (mod) mod->SetDontPanicLinkFlag(value);