Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: echo skill cast down to client for some server skills #1619

Merged
merged 4 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dGame/dBehaviors/BehaviorContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,26 @@ void BehaviorContext::UpdatePlayerSyncs(float deltaTime) {
i++;
continue;
}

if (this->skillUId != 0 && !clientInitalized) {
EchoSyncSkill echo;
echo.bDone = true;
echo.uiSkillHandle = this->skillUId;
echo.uiBehaviorHandle = entry.handle;

RakNet::BitStream bitStream{};
entry.behavior->SyncCalculation(this, bitStream, entry.branchContext);

echo.sBitStream.assign(reinterpret_cast<char*>(bitStream.GetData()), bitStream.GetNumberOfBytesUsed());

RakNet::BitStream message;
BitStreamUtils::WriteHeader(message, eConnectionType::CLIENT, eClientMessageType::GAME_MSG);
message.Write(this->originator);
echo.Serialize(message);

Game::server->Send(message, UNASSIGNED_SYSTEM_ADDRESS, true);
}

this->syncEntries.erase(this->syncEntries.begin() + i);
}
}
Expand Down
10 changes: 9 additions & 1 deletion dGame/dBehaviors/DamageAbsorptionBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
destroyable->SetIsShielded(true);

context->RegisterTimerBehavior(this, branch, target->GetObjectID());

Game::entityManager->SerializeEntity(target);
}

void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitStream, BehaviorBranchContext branch) {
Expand All @@ -52,7 +54,13 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon

const auto toRemove = std::min(present, this->m_absorbAmount);

destroyable->SetDamageToAbsorb(present - toRemove);
const auto remaining = present - toRemove;

destroyable->SetDamageToAbsorb(remaining);

destroyable->SetIsShielded(remaining > 0);

Game::entityManager->SerializeEntity(target);
}

void DamageAbsorptionBehavior::Load() {
Expand Down
Loading