mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-12-07 16:48:26 +00:00
fix: ape anchor not respawning (#1927)
* fix: ape anchor not respawning * add return Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -189,6 +189,10 @@ Entity::~Entity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_ParentEntity) {
|
if (m_ParentEntity) {
|
||||||
|
GameMessages::ChildRemoved removedMsg{};
|
||||||
|
removedMsg.childID = m_ObjectID;
|
||||||
|
removedMsg.target = m_ParentEntity->GetObjectID();
|
||||||
|
removedMsg.Send();
|
||||||
m_ParentEntity->RemoveChild(this);
|
m_ParentEntity->RemoveChild(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,6 +202,7 @@ void Entity::Initialize() {
|
|||||||
RegisterMsg<GameMessages::DropClientLoot>(this, &Entity::MsgDropClientLoot);
|
RegisterMsg<GameMessages::DropClientLoot>(this, &Entity::MsgDropClientLoot);
|
||||||
RegisterMsg<GameMessages::GetFactionTokenType>(this, &Entity::MsgGetFactionTokenType);
|
RegisterMsg<GameMessages::GetFactionTokenType>(this, &Entity::MsgGetFactionTokenType);
|
||||||
RegisterMsg<GameMessages::PickupItem>(this, &Entity::MsgPickupItem);
|
RegisterMsg<GameMessages::PickupItem>(this, &Entity::MsgPickupItem);
|
||||||
|
RegisterMsg<GameMessages::ChildRemoved>(this, &Entity::MsgChildRemoved);
|
||||||
/**
|
/**
|
||||||
* Setup trigger
|
* Setup trigger
|
||||||
*/
|
*/
|
||||||
@@ -2352,3 +2357,8 @@ bool Entity::MsgPickupItem(GameMessages::GameMsg& msg) {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Entity::MsgChildRemoved(GameMessages::GameMsg& msg) {
|
||||||
|
GetScript()->OnChildRemoved(*this, static_cast<GameMessages::ChildRemoved&>(msg));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ public:
|
|||||||
bool MsgGetFlag(GameMessages::GameMsg& msg);
|
bool MsgGetFlag(GameMessages::GameMsg& msg);
|
||||||
bool MsgGetFactionTokenType(GameMessages::GameMsg& msg);
|
bool MsgGetFactionTokenType(GameMessages::GameMsg& msg);
|
||||||
bool MsgPickupItem(GameMessages::GameMsg& msg);
|
bool MsgPickupItem(GameMessages::GameMsg& msg);
|
||||||
|
bool MsgChildRemoved(GameMessages::GameMsg& msg);
|
||||||
|
|
||||||
// This is expceted to never return nullptr, an assert checks this.
|
// This is expceted to never return nullptr, an assert checks this.
|
||||||
CppScripts::Script* const GetScript() const;
|
CppScripts::Script* const GetScript() const;
|
||||||
|
|||||||
@@ -937,5 +937,11 @@ namespace GameMessages {
|
|||||||
LWOOBJID lootID{};
|
LWOOBJID lootID{};
|
||||||
LWOOBJID lootOwnerID{};
|
LWOOBJID lootOwnerID{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ChildRemoved : public GameMsg {
|
||||||
|
ChildRemoved() : GameMsg(MessageType::Game::CHILD_REMOVED) {}
|
||||||
|
|
||||||
|
LWOOBJID childID{};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
#endif // GAMEMESSAGES_H
|
#endif // GAMEMESSAGES_H
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) {
|
|||||||
new LDFData<LWOOBJID>(u"ape", self->GetObjectID())
|
new LDFData<LWOOBJID>(u"ape", self->GetObjectID())
|
||||||
};
|
};
|
||||||
|
|
||||||
auto* anchor = Game::entityManager->CreateEntity(entityInfo);
|
auto* anchor = Game::entityManager->CreateEntity(entityInfo, nullptr, self);
|
||||||
Game::entityManager->ConstructEntity(anchor);
|
Game::entityManager->ConstructEntity(anchor);
|
||||||
self->SetVar<LWOOBJID>(u"QB", anchor->GetObjectID());
|
self->SetVar<LWOOBJID>(u"QB", anchor->GetObjectID());
|
||||||
|
|
||||||
@@ -140,3 +140,9 @@ void BaseEnemyApe::StunApe(Entity* self, bool stunState) {
|
|||||||
self->SetBoolean(u"knockedOut", stunState);
|
self->SetBoolean(u"knockedOut", stunState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseEnemyApe::OnChildRemoved(Entity& self, GameMessages::ChildRemoved& childRemoved) {
|
||||||
|
if (self.GetVar<LWOOBJID>(u"QB") == childRemoved.childID) {
|
||||||
|
self.SetVar<LWOOBJID>(u"QB", LWOOBJID_EMPTY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public:
|
|||||||
void OnTimerDone(Entity* self, std::string timerName) override;
|
void OnTimerDone(Entity* self, std::string timerName) override;
|
||||||
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||||
int32_t param3) override;
|
int32_t param3) override;
|
||||||
|
void OnChildRemoved(Entity& self, GameMessages::ChildRemoved& childRemoved) override;
|
||||||
private:
|
private:
|
||||||
static void StunApe(Entity* self, bool stunState);
|
static void StunApe(Entity* self, bool stunState);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -383,6 +383,8 @@ namespace CppScripts {
|
|||||||
* @param fire The child info
|
* @param fire The child info
|
||||||
*/
|
*/
|
||||||
virtual void OnChildLoaded(Entity& self, GameMessages::ChildLoaded& childLoaded) {};
|
virtual void OnChildLoaded(Entity& self, GameMessages::ChildLoaded& childLoaded) {};
|
||||||
|
|
||||||
|
virtual void OnChildRemoved(Entity& self, GameMessages::ChildRemoved& childRemoved) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
Script* const GetScript(Entity* parent, const std::string& scriptName);
|
Script* const GetScript(Entity* parent, const std::string& scriptName);
|
||||||
|
|||||||
Reference in New Issue
Block a user