From 62089be53f2a6724101605545f66f695aedc933c Mon Sep 17 00:00:00 2001 From: Edmond Mondor Date: Fri, 7 Jan 2022 11:31:11 -0800 Subject: [PATCH] Changes needed so climbing works correctly with wall --- .../PubUtilLib/plAvatar/plAnimStage.cpp | 2 +- .../PubUtilLib/plAvatar/plAvBrainClimb.cpp | 4 +-- .../PubUtilLib/plAvatar/plAvBrainHuman.cpp | 26 +++++++++++++------ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp index 0b481513..98a82046 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAnimStage.cpp @@ -313,7 +313,7 @@ hsBool plAnimStage::ISendNotify(UInt32 notifyMask, UInt32 notifyType, plArmature int stageNum = genBrain ? genBrain->GetStageNum(this) : -1; msg->AddMultiStageEvent(stageNum, notifyType, armature->GetTarget(0)->GetKey()); - if (! genBrain->RelayNotifyMsg(msg) ) + if (stageNum < 0 || !genBrain || !genBrain->RelayNotifyMsg(msg) ) { msg->UnRef(); // couldn't send; destroy... } diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp index 872bfca7..9439ebe8 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainClimb.cpp @@ -703,8 +703,8 @@ void plAvBrainClimb::ICalcProbeLengths() { // we assume that the up and down climbs go the same distance; // same for the left and right climbs - plAGAnim *up = fAvMod->FindCustomAnim("ClimbUp"); - plAGAnim *left = fAvMod->FindCustomAnim("ClimbLeft"); + plAGAnim *up = fAvMod->FindCustomAnim("WallClimbUp"); + plAGAnim *left = fAvMod->FindCustomAnim("WallClimbLeft"); hsMatrix44 upMove, leftMove; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp index 6ba9da21..8a2856c5 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp @@ -75,6 +75,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "../plInputCore/plInputDevice.h" #include "../plMath/plRandom.h" #include "../plPipeline/plDebugText.h" +#include "../plNetClient/plNetClientMgr.h" #include "../plNetClient/plNetLinkingMgr.h" #include "../plMessage/plAvatarMsg.h" @@ -494,12 +495,20 @@ hsBool plAvBrainHuman::IHandleClimbMsg(plClimbMsg *msg) bool isStartClimb = msg->fCommand == plClimbMsg::kStartClimbing; if(isStartClimb) { - // let's build a seek task to get us to the attach point - plKey seekTarget = msg->fTarget; - plAvTaskSeek *seekTask = TRACKED_NEW plAvTaskSeek(seekTarget); - QueueTask(seekTask); - - // now a brain task to start the actual climb. + // Warp the player to the Seekpoint + plSceneObject *avatarObj = plSceneObject::ConvertNoRef(plNetClientMgr::GetInstance()->GetLocalPlayer()); + plSceneObject *obj = plSceneObject::ConvertNoRef(msg->fTarget->ObjectIsLoaded()); + plArmatureMod *localAvatar = plAvatarMgr::GetInstance()->GetLocalAvatar(); + plArmatureMod *climbAvatar = plArmatureMod::ConvertNoRef(fArmature); + if (climbAvatar == localAvatar) // is it our avatar who has to seek? + { + hsMatrix44 target = obj->GetLocalToWorld(); + plWarpMsg *warp = TRACKED_NEW plWarpMsg(NULL, avatarObj->GetKey(), plWarpMsg::kFlushTransform, target); + warp->SetBCastFlag(plMessage::kNetPropagate); + plgDispatch::MsgSend(warp); + } + + // build the Climb brain plAvBrainClimb::Mode startMode; switch(msg->fDirection) { @@ -515,10 +524,11 @@ hsBool plAvBrainHuman::IHandleClimbMsg(plClimbMsg *msg) case plClimbMsg::kRight: startMode = plAvBrainClimb::kMountingRight; break; + default: + break; } plAvBrainClimb *brain = TRACKED_NEW plAvBrainClimb(startMode); - plAvTaskBrain *brainTask = TRACKED_NEW plAvTaskBrain(brain); - QueueTask(brainTask); + climbAvatar->PushBrain(brain); } // ** potentially controversial: // It's fairly easy for a human brain to hit a climb trigger - like when falling off a wall.