add child loading (#1706)

Tested that the NT combat challenge, am skullkin towers and qa wall in avant gardens all function as before.
This commit is contained in:
David Markowitz
2024-12-31 22:46:00 -08:00
committed by GitHub
parent 0b261e934f
commit 021db0ecd1
10 changed files with 54 additions and 33 deletions

View File

@@ -91,7 +91,7 @@ void NtCombatChallengeServer::SpawnTargetDummy(Entity* self) {
info.rot = self->GetRotation();
info.settings = { new LDFData<std::string>(u"custom_script_server", "scripts\\02_server\\Map\\NT\\L_NT_COMBAT_CHALLENGE_DUMMY.lua") };
auto* dummy = Game::entityManager->CreateEntity(info);
auto* dummy = Game::entityManager->CreateEntity(info, nullptr, self);
dummy->SetVar(u"challengeObjectID", self->GetObjectID());
@@ -104,26 +104,18 @@ void NtCombatChallengeServer::SetAttackImmunity(LWOOBJID objID, bool bTurnOn) {
}
void NtCombatChallengeServer::OnChildLoaded(Entity* self, Entity* child) {
auto targetNumber = self->GetVar<int32_t>(u"TargetNumber");
if (targetNumber == 0) targetNumber = 1;
self->SetVar(u"TargetNumber", targetNumber + 1);
void NtCombatChallengeServer::OnChildLoaded(Entity& self, GameMessages::ChildLoaded& childLoaded) {
auto* const child = Game::entityManager->GetEntity(childLoaded.childID);
const auto playerID = self->GetVar<LWOOBJID>(u"playerID");
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
if (child) {
child->SetRotation(NiQuaternion::FromEulerAngles(child->GetRotation().GetEulerAngles() += NiPoint3(0, PI, 0))); // rotate 180 degrees
}
child->SetRotation(NiQuaternion::LookAt(child->GetPosition(), player->GetPosition()));
self->SetVar(u"currentTargetID", child->GetObjectID());
self.SetVar(u"currentTargetID", child->GetObjectID());
Game::entityManager->SerializeEntity(child);
child->GetGroups().push_back("targets_" + std::to_string(self->GetObjectID()));
child->GetGroups().push_back("targets_" + std::to_string(self.GetObjectID()));
}
void NtCombatChallengeServer::ResetGame(Entity* self) {