From 891648288ac753ae15266e1c2a554111a8c0da0d Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Fri, 16 Jun 2023 01:56:02 -0700 Subject: [PATCH] Organize Entity header Probably the third or fourth pass of this darn header... Just keep making it better every time Rename some functions to make more sense to a reader Use different method for Observing/subscribing to component events Get rid of abomination of overloading GetParentUser --- dGame/Player.cpp | 4 +- dGame/Player.h | 4 +- dGame/dBehaviors/BasicAttackBehavior.cpp | 2 +- dGame/dBehaviors/TacArcBehavior.cpp | 2 +- dGame/dComponents/BaseCombatAIComponent.cpp | 2 +- dGame/dComponents/DestroyableComponent.cpp | 30 +++-- dGame/dComponents/DestroyableComponent.h | 8 +- dGame/dComponents/PhantomPhysicsComponent.cpp | 4 +- dGame/dEntity/Entity.cpp | 21 ++-- dGame/dEntity/Entity.h | 117 +++++++++++------- dGame/dGameMessages/GameMessageHandler.cpp | 2 +- .../02_server/Enemy/General/BaseEnemyApe.cpp | 2 +- dScripts/02_server/Map/AM/AmSkullkinDrill.cpp | 4 +- .../Objects/AgSurvivalBuffStation.cpp | 2 +- dScripts/BaseSurvivalServer.cpp | 2 +- dScripts/BaseWavesServer.cpp | 6 +- .../EquipmentTriggers/CoilBackpackBase.cpp | 4 +- dScripts/ai/ACT/ActPlayerDeathTrigger.cpp | 2 +- dScripts/ai/AG/ActSharkPlayerDeathTrigger.cpp | 2 +- dScripts/ai/AG/AgShipPlayerDeathTrigger.cpp | 2 +- dScripts/ai/FV/TriggerGas.cpp | 2 +- dScripts/ai/GF/PetDigBuild.cpp | 2 +- dScripts/ai/NS/NsConcertInstrument.cpp | 2 +- 23 files changed, 126 insertions(+), 102 deletions(-) diff --git a/dGame/Player.cpp b/dGame/Player.cpp index 0db57ce9..9ffa1775 100644 --- a/dGame/Player.cpp +++ b/dGame/Player.cpp @@ -55,13 +55,13 @@ void Player::SetSystemAddress(const SystemAddress& value) { m_SystemAddress = value; } -void Player::SetRespawnPos(const NiPoint3& position) { +void Player::SetRespawnPosition(const NiPoint3& position) { m_respawnPos = position; m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position); } -void Player::SetRespawnRot(const NiQuaternion& rotation) { +void Player::SetRespawnRotation(const NiQuaternion& rotation) { m_respawnRot = rotation; } diff --git a/dGame/Player.h b/dGame/Player.h index 591b298e..d3e9a146 100644 --- a/dGame/Player.h +++ b/dGame/Player.h @@ -44,9 +44,9 @@ public: void SetSystemAddress(const SystemAddress& value) override; - void SetRespawnPos(const NiPoint3& position) override; + void SetRespawnPosition(const NiPoint3& position) override; - void SetRespawnRot(const NiQuaternion& rotation) override; + void SetRespawnRotation(const NiQuaternion& rotation) override; void SetGhostReferencePoint(const NiPoint3& value); diff --git a/dGame/dBehaviors/BasicAttackBehavior.cpp b/dGame/dBehaviors/BasicAttackBehavior.cpp index 5e0b3953..d0f5ae90 100644 --- a/dGame/dBehaviors/BasicAttackBehavior.cpp +++ b/dGame/dBehaviors/BasicAttackBehavior.cpp @@ -213,7 +213,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet bitStream->Write(armorDamageDealt); bitStream->Write(healthDamageDealt); - bitStream->Write(targetEntity->GetIsDead()); + bitStream->Write(targetEntity->IsDead()); } bitStream->Write(successState); diff --git a/dGame/dBehaviors/TacArcBehavior.cpp b/dGame/dBehaviors/TacArcBehavior.cpp index 4f12b468..57c6644a 100644 --- a/dGame/dBehaviors/TacArcBehavior.cpp +++ b/dGame/dBehaviors/TacArcBehavior.cpp @@ -148,7 +148,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS continue; } - if (entity->GetIsDead()) continue; + if (entity->IsDead()) continue; const auto otherPosition = entity->GetPosition(); diff --git a/dGame/dComponents/BaseCombatAIComponent.cpp b/dGame/dComponents/BaseCombatAIComponent.cpp index e9de4473..316ffab8 100644 --- a/dGame/dComponents/BaseCombatAIComponent.cpp +++ b/dGame/dComponents/BaseCombatAIComponent.cpp @@ -180,7 +180,7 @@ void BaseCombatAIComponent::Update(const float deltaTime) { m_SoftTimer -= deltaTime; } - if (m_Disabled || m_ParentEntity->GetIsDead()) + if (m_Disabled || m_ParentEntity->IsDead()) return; bool stunnedThisFrame = m_Stunned; CalculateCombat(deltaTime); // Putting this here for now diff --git a/dGame/dComponents/DestroyableComponent.cpp b/dGame/dComponents/DestroyableComponent.cpp index 5e16cde1..0358522a 100644 --- a/dGame/dComponents/DestroyableComponent.cpp +++ b/dGame/dComponents/DestroyableComponent.cpp @@ -692,26 +692,32 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 Smash(source, eKillType::VIOLENT, u"", skillID); } -void DestroyableComponent::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd) { - m_SubscribedScripts.insert(std::make_pair(scriptObjId, scriptToAdd)); - Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_ParentEntity->GetObjectID()); +void DestroyableComponent::Subscribe(CppScripts::Script* scriptToAdd) { + auto foundScript = std::find(m_SubscribedScripts.begin(), m_SubscribedScripts.end(), scriptToAdd); + if (foundScript != m_SubscribedScripts.end()) { + Game::logger->LogDebug("DestroyableComponent", "WARNING: Tried to add a script for Entity %llu but the script was already subscribed", m_ParentEntity->GetObjectID()); + return; + } + m_SubscribedScripts.push_back(scriptToAdd); + Game::logger->LogDebug("DestroyableComponent", "A script has subscribed to entity %llu", m_ParentEntity->GetObjectID()); Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); } -void DestroyableComponent::Unsubscribe(LWOOBJID scriptObjId) { - auto foundScript = m_SubscribedScripts.find(scriptObjId); +void DestroyableComponent::Unsubscribe(CppScripts::Script* scriptToRemove) { + auto foundScript = std::find(m_SubscribedScripts.begin(), m_SubscribedScripts.end(), scriptToRemove); if (foundScript != m_SubscribedScripts.end()) { m_SubscribedScripts.erase(foundScript); - Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_ParentEntity->GetObjectID()); - } else { - Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_ParentEntity->GetObjectID(), scriptObjId); + Game::logger->LogDebug("DestroyableComponent", "Unsubscribed a script from entity %llu", m_ParentEntity->GetObjectID()); + Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); + return; } - Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); + Game::logger->LogDebug("DestroyableComponent", "WARNING: Tried to remove a script for Entity %llu but the script was not subscribed", m_ParentEntity->GetObjectID()); } void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) { - for (auto script : m_SubscribedScripts) { - script.second->NotifyHitOrHealResult(m_ParentEntity, attacker, damage); + for (auto* script : m_SubscribedScripts) { + DluAssert(script != nullptr); + script->NotifyHitOrHealResult(m_ParentEntity, attacker, damage); } } @@ -827,7 +833,7 @@ void DestroyableComponent::Smash(const LWOOBJID source, const eKillType killType std::vector scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY); for (Entity* scriptEntity : scriptedActs) { if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds - scriptEntity->GetScript()->OnPlayerDied(scriptEntity, m_ParentEntity); + scriptEntity->GetScript()->OnPlayerDied(scriptEntity, m_ParentEntity); } } } diff --git a/dGame/dComponents/DestroyableComponent.h b/dGame/dComponents/DestroyableComponent.h index db482e9c..bcb875ba 100644 --- a/dGame/dComponents/DestroyableComponent.h +++ b/dGame/dComponents/DestroyableComponent.h @@ -447,8 +447,8 @@ public: */ void NotifySubscribers(Entity* attacker, uint32_t damage); - void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd); - void Unsubscribe(LWOOBJID scriptObjId); + void Subscribe(CppScripts::Script* scriptToAdd); + void Unsubscribe(CppScripts::Script* scriptToRemove); // handle hardcode mode drops void DoHardcoreModeDrops(const LWOOBJID source); @@ -587,9 +587,9 @@ private: std::vector> m_OnHitCallbacks; /** - * The list of scripts subscribed to this components actions + * Scripts that are subscribed to this component */ - std::map m_SubscribedScripts; + std::vector m_SubscribedScripts; /** * status immunity counters diff --git a/dGame/dComponents/PhantomPhysicsComponent.cpp b/dGame/dComponents/PhantomPhysicsComponent.cpp index 8b1f3b6a..76ccf08e 100644 --- a/dGame/dComponents/PhantomPhysicsComponent.cpp +++ b/dGame/dComponents/PhantomPhysicsComponent.cpp @@ -366,8 +366,8 @@ void PhantomPhysicsComponent::Update(float deltaTime) { if (entity) { GameMessages::SendPlayerReachedRespawnCheckpoint(entity, m_RespawnPos, m_RespawnRot); - entity->SetRespawnPos(m_RespawnPos); - entity->SetRespawnRot(m_RespawnRot); + entity->SetRespawnPosition(m_RespawnPos); + entity->SetRespawnRotation(m_RespawnRot); } } } diff --git a/dGame/dEntity/Entity.cpp b/dGame/dEntity/Entity.cpp index 9d51c702..2511ca32 100644 --- a/dGame/dEntity/Entity.cpp +++ b/dGame/dEntity/Entity.cpp @@ -569,31 +569,26 @@ bool Entity::operator!=(const Entity& other) const { return !(other.m_ObjectID == m_ObjectID); } -// Move to header -User* Entity::GetParentUser() const { - return IsPlayer() ? static_cast(this)->GetParentUser() : nullptr; -} - // Move to header bool Entity::HasComponent(const eReplicaComponentType componentId) const { return m_Components.find(componentId) != m_Components.end(); } // Fine -void Entity::Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) { +void Entity::Subscribe(CppScripts::Script* scriptToAdd, const std::string& notificationName) { + Game::logger->Log("Entity", "Subscribing a script with notification %s", notificationName.c_str()); if (notificationName == "HitOrHealResult" || notificationName == "Hit") { auto* destroyableComponent = GetComponent(); - if (!destroyableComponent) return; - destroyableComponent->Subscribe(scriptObjId, scriptToAdd); + if (destroyableComponent) destroyableComponent->Subscribe(scriptToAdd); } } // Fine -void Entity::Unsubscribe(const LWOOBJID& scriptObjId, const std::string& notificationName) { +void Entity::Unsubscribe(CppScripts::Script* scriptToRemove, const std::string& notificationName) { + Game::logger->Log("Entity", "Unsubscribing a script with notification %s", notificationName.c_str()); if (notificationName == "HitOrHealResult" || notificationName == "Hit") { auto* destroyableComponent = GetComponent(); - if (!destroyableComponent) return; - destroyableComponent->Unsubscribe(scriptObjId); + if (destroyableComponent) destroyableComponent->Unsubscribe(scriptToRemove); } } @@ -857,7 +852,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { } } - if (!other->GetIsDead()) { + if (!other->IsDead()) { auto* combat = GetComponent(); if (combat != nullptr) { @@ -1053,7 +1048,7 @@ void Entity::AddRebuildCompleteCallback(const std::function& if (quickBuildComponent) quickBuildComponent->AddRebuildCompleteCallback(callback); } -bool Entity::GetIsDead() const { +bool Entity::IsDead() const { auto* dest = GetComponent(); return dest && dest->GetArmor() == 0 && dest->GetHealth() == 0; } diff --git a/dGame/dEntity/Entity.h b/dGame/dEntity/Entity.h index 0b905730..1fcadbc4 100644 --- a/dGame/dEntity/Entity.h +++ b/dGame/dEntity/Entity.h @@ -19,6 +19,10 @@ namespace tinyxml2 { class XMLDocument; }; +namespace CppScripts { + class Script; +}; + class Player; class EntityInfo; class User; @@ -37,10 +41,6 @@ enum class eReplicaComponentType : uint32_t; enum class eReplicaPacketType : uint8_t; enum class eCinematicEvent : uint32_t; -namespace CppScripts { - class Script; -}; - /** * An entity in the world. * Entities are composed of components which define their behavior. @@ -58,8 +58,15 @@ public: void ApplyComponentWhitelist(TemplateComponents& components) const; static const std::vector& GetComponentWhitelists() { return m_ComponentWhitelists; } - // There are some very very edge cases we need to take care of with what components - // are kept and removed. Here is where we take care of those cases. + /** + * Functions used for creating and setting up an Entity. + */ + void Initialize(); + + /** + * There are some very very edge cases we need to take care of with what components + * are kept and removed. Here is where we take care of those cases. + */ void ApplyComponentBlacklist(TemplateComponents& components) const; // For adding and removing components based on LDF keys @@ -68,84 +75,100 @@ public: // Paths have several components they could add. This function will add them. void AddPathComponent(TemplateComponents& components) const; + /** + * Determines if we should ghost an Entity or not. + * Ghosting means we no longer serialize it to a specific player because it is out of range. + */ void IsGhosted(); - virtual void Initialize(); bool operator==(const Entity& other) const; bool operator!=(const Entity& other) const; - /** - * Getters - */ - Character* GetCharacter() const { return m_Character; } - void SetCharacter(Character* value) { m_Character = value; } - + // General Entity info const LWOOBJID GetObjectID() const { return m_ObjectID; } const LOT GetLOT() const { return m_TemplateID; } - eGameMasterLevel GetGMLevel() const { return m_GMLevel; } - void SetGMLevel(const eGameMasterLevel value); - Entity* GetParentEntity() const { return m_ParentEntity; } - const std::vector& GetGroups() { return m_Groups; }; - void SetGroups(const std::vector& value) { m_Groups = value; } - - Spawner* GetSpawner() const { return m_Spawner; } - - LWOOBJID GetSpawnerID() const { return m_SpawnerID; } - - const std::vector& GetSettings() const { return m_Settings; } - - const std::vector& GetNetworkSettings() const { return m_NetworkSettings; } - - bool GetIsDead() const; - - bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; } - void SetPlayerReadyForUpdates() { m_PlayerIsReadyForUpdates = true; } - const bool GetIsGhostingCandidate() const { return m_IsGhostingCandidate; } - const int8_t GetObservers() const { return m_Observers; } - void SetObservers(const int8_t value); - - const uint16_t GetNetworkId() const { return m_NetworkID; } - void SetNetworkId(const uint16_t id) { m_NetworkID = id; } + const float GetDefaultScale() const { return m_Scale; } Entity* GetOwner() const; void SetOwnerOverride(const LWOOBJID& value) { m_OwnerOverride = value; }; + // Position related info const NiPoint3& GetDefaultPosition() const { return m_DefaultPosition; }; const NiQuaternion& GetDefaultRotation() const { return m_DefaultRotation; }; - const float GetDefaultScale() const { return m_Scale; } - const NiPoint3& GetPosition() const; void SetPosition(const NiPoint3& position); const NiQuaternion& GetRotation() const; void SetRotation(const NiQuaternion& rotation); - virtual User* GetParentUser() const; + // Spawner related info + Spawner* GetSpawner() const { return m_Spawner; } + + LWOOBJID GetSpawnerID() const { return m_SpawnerID; } + + const std::vector& GetGroups() { return m_Groups; }; + void SetGroups(const std::vector& value) { m_Groups = value; } + + // LDF related into + const std::vector& GetSettings() const { return m_Settings; } + + const std::vector& GetNetworkSettings() const { return m_NetworkSettings; } + + // Networking related info + const int8_t GetObservers() const { return m_Observers; } + void SetObservers(const int8_t value); + + const uint16_t GetNetworkId() const { return m_NetworkID; } + void SetNetworkId(const uint16_t id) { m_NetworkID = id; } + + // Player extended info + virtual User* GetParentUser() const { return nullptr; }; virtual const SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; }; - virtual void SetRespawnPos(const NiPoint3& position) {}; + virtual void SetRespawnPosition(const NiPoint3& position) {}; - virtual void SetRespawnRot(const NiQuaternion& rotation) {}; + virtual void SetRespawnRotation(const NiQuaternion& rotation) {}; virtual void SetSystemAddress(const SystemAddress& value) {}; - /** - * Component management - */ + eGameMasterLevel GetGMLevel() const { return m_GMLevel; } + void SetGMLevel(const eGameMasterLevel value); + + bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; } + void SetPlayerReadyForUpdates() { m_PlayerIsReadyForUpdates = true; } + + Character* GetCharacter() const { return m_Character; } + void SetCharacter(Character* value) { m_Character = value; } + + // End info + + bool IsDead() const; + + // If you are calling this, then calling GetComponent, just call GetComponent and check for nullptr. bool HasComponent(const eReplicaComponentType componentId) const; - void Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName); - void Unsubscribe(const LWOOBJID& scriptObjId, const std::string& notificationName); + /** + * Call these when you want to observe events. Observed events should follow the following naming convention + * in scripts Notify. For example, if you want to observe the "OnDeath" event, you would call + * entity->Subscribe(script, "OnDeath"). Then in your script, you would have a function called NotifyOnDeath. + */ + void Subscribe(CppScripts::Script* scriptToAdd, const std::string& notificationName); + /** + * Call this when you want to stop observing an event. The scriptToRemove will + * no longer be notified of notificationName events + */ + void Unsubscribe(CppScripts::Script* scriptToRemove, const std::string& notificationName); +// ### STOPPED HERE ### void SetProximityRadius(const float proxRadius, const std::string& name); void SetProximityRadius(dpEntity* entity, const std::string& name); diff --git a/dGame/dGameMessages/GameMessageHandler.cpp b/dGame/dGameMessages/GameMessageHandler.cpp index 04a013a3..cffaa9a8 100644 --- a/dGame/dGameMessages/GameMessageHandler.cpp +++ b/dGame/dGameMessages/GameMessageHandler.cpp @@ -143,7 +143,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System } //Kill player if health == 0 - if (entity->GetIsDead()) { + if (entity->IsDead()) { entity->Smash(entity->GetObjectID()); } diff --git a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp index 19a6490a..dcf71b92 100644 --- a/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp +++ b/dScripts/02_server/Enemy/General/BaseEnemyApe.cpp @@ -16,7 +16,7 @@ void BaseEnemyApe::OnStartup(Entity* self) { void BaseEnemyApe::OnDie(Entity* self, Entity* killer) { auto* anchor = EntityManager::Instance()->GetEntity(self->GetVar(u"QB")); - if (anchor != nullptr && !anchor->GetIsDead()) { + if (anchor != nullptr && !anchor->IsDead()) { anchor->Smash(self->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp index e35c700d..e964850a 100644 --- a/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp +++ b/dScripts/02_server/Map/AM/AmSkullkinDrill.cpp @@ -152,13 +152,13 @@ void AmSkullkinDrill::FreezePlayer(Entity* self, Entity* player, bool bFreeze) { auto StateChangeType = eStateChangeType::POP; if (bFreeze) { - if (player->GetIsDead()) { + if (player->IsDead()) { return; } StateChangeType = eStateChangeType::PUSH; } else { - if (player->GetIsDead()) { + if (player->IsDead()) { // } } diff --git a/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp b/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp index 158d9072..5dd4c20e 100644 --- a/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp +++ b/dScripts/02_server/Objects/AgSurvivalBuffStation.cpp @@ -54,7 +54,7 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { auto team = self->GetVar>(u"BuilderTeam"); for (auto memberID : team) { auto member = EntityManager::Instance()->GetEntity(memberID); - if (member != nullptr && !member->GetIsDead()) { + if (member != nullptr && !member->IsDead()) { GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); } else { // If player left the team or left early erase them from the team variable. diff --git a/dScripts/BaseSurvivalServer.cpp b/dScripts/BaseSurvivalServer.cpp index 3d72628d..3141d70a 100644 --- a/dScripts/BaseSurvivalServer.cpp +++ b/dScripts/BaseSurvivalServer.cpp @@ -312,7 +312,7 @@ bool BaseSurvivalServer::CheckAllPlayersDead() { for (const auto& playerID : state.players) { auto* player = EntityManager::Instance()->GetEntity(playerID); - if (player == nullptr || player->GetIsDead()) { + if (player == nullptr || player->IsDead()) { deadPlayers++; } } diff --git a/dScripts/BaseWavesServer.cpp b/dScripts/BaseWavesServer.cpp index 00340bd0..4bc53fae 100644 --- a/dScripts/BaseWavesServer.cpp +++ b/dScripts/BaseWavesServer.cpp @@ -310,7 +310,7 @@ bool BaseWavesServer::CheckAllPlayersDead() { for (const auto& playerID : state.players) { auto* player = EntityManager::Instance()->GetEntity(playerID); - if (player == nullptr || player->GetIsDead()) { + if (player == nullptr || player->IsDead()) { deadPlayers++; } } @@ -430,7 +430,7 @@ void BaseWavesServer::SpawnWave(Entity* self) { for (const auto& playerID : state.players) { auto* player = EntityManager::Instance()->GetEntity(playerID); - if (player && player->GetIsDead()) { + if (player && player->IsDead()) { player->Resurrect(); } } @@ -500,7 +500,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3 for (const auto& playerID : state.players) { auto* player = EntityManager::Instance()->GetEntity(playerID); - if (player != nullptr && !player->GetIsDead()) { + if (player != nullptr && !player->IsDead()) { SetActivityValue(self, playerID, 1, currentTime); SetActivityValue(self, playerID, 2, state.waveNumber); diff --git a/dScripts/EquipmentTriggers/CoilBackpackBase.cpp b/dScripts/EquipmentTriggers/CoilBackpackBase.cpp index 4e323a08..525e6b93 100644 --- a/dScripts/EquipmentTriggers/CoilBackpackBase.cpp +++ b/dScripts/EquipmentTriggers/CoilBackpackBase.cpp @@ -4,7 +4,7 @@ #include "SkillComponent.h" void CoilBackpackBase::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) { - itemOwner->Subscribe(itemObjId, this, "HitOrHealResult"); + itemOwner->Subscribe(this, "HitOrHealResult"); itemOwner->SetVar(u"coilCount", 0); } @@ -21,5 +21,5 @@ void CoilBackpackBase::NotifyHitOrHealResult(Entity* self, Entity* attacker, int } void CoilBackpackBase::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) { - itemOwner->Unsubscribe(itemObjId, "HitOrHealResult"); + itemOwner->Unsubscribe(this, "HitOrHealResult"); } diff --git a/dScripts/ai/ACT/ActPlayerDeathTrigger.cpp b/dScripts/ai/ACT/ActPlayerDeathTrigger.cpp index 0674f0dd..62ab0790 100644 --- a/dScripts/ai/ACT/ActPlayerDeathTrigger.cpp +++ b/dScripts/ai/ACT/ActPlayerDeathTrigger.cpp @@ -3,7 +3,7 @@ #include "Entity.h" void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { - if (!target->IsPlayer() || target->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready + if (!target->IsPlayer() || target->IsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready target->Smash(self->GetObjectID(), eKillType::SILENT); } diff --git a/dScripts/ai/AG/ActSharkPlayerDeathTrigger.cpp b/dScripts/ai/AG/ActSharkPlayerDeathTrigger.cpp index af3d39cb..2256665e 100644 --- a/dScripts/ai/AG/ActSharkPlayerDeathTrigger.cpp +++ b/dScripts/ai/AG/ActSharkPlayerDeathTrigger.cpp @@ -11,7 +11,7 @@ void ActSharkPlayerDeathTrigger::OnFireEventServerSide(Entity* self, Entity* sen missionComponent->Progress(eMissionTaskType::SCRIPT, 8419); - if (sender->GetIsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready + if (sender->IsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready if (sender->GetCharacter()) { sender->Smash(self->GetObjectID(), eKillType::VIOLENT, u"big-shark-death"); diff --git a/dScripts/ai/AG/AgShipPlayerDeathTrigger.cpp b/dScripts/ai/AG/AgShipPlayerDeathTrigger.cpp index a580be6e..67a37f60 100644 --- a/dScripts/ai/AG/AgShipPlayerDeathTrigger.cpp +++ b/dScripts/ai/AG/AgShipPlayerDeathTrigger.cpp @@ -2,7 +2,7 @@ #include "Entity.h" void AgShipPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { - if (target->GetLOT() == 1 && !target->GetIsDead()) { + if (target->GetLOT() == 1 && !target->IsDead()) { target->Smash(self->GetObjectID(), eKillType::VIOLENT, u"electro-shock-death"); } } diff --git a/dScripts/ai/FV/TriggerGas.cpp b/dScripts/ai/FV/TriggerGas.cpp index 8ff1ccbe..1e5242a8 100644 --- a/dScripts/ai/FV/TriggerGas.cpp +++ b/dScripts/ai/FV/TriggerGas.cpp @@ -28,7 +28,7 @@ void TriggerGas::OnTimerDone(Entity* self, std::string timerName) { if (timerName != this->m_TimerName) return; auto players = self->GetVar>(u"players"); for (auto player : players) { - if (player->GetIsDead() || !player){ + if (player->IsDead() || !player){ auto position = std::find(players.begin(), players.end(), player); if (position != players.end()) players.erase(position); continue; diff --git a/dScripts/ai/GF/PetDigBuild.cpp b/dScripts/ai/GF/PetDigBuild.cpp index 504a1199..e75f8218 100644 --- a/dScripts/ai/GF/PetDigBuild.cpp +++ b/dScripts/ai/GF/PetDigBuild.cpp @@ -45,7 +45,7 @@ void PetDigBuild::OnDie(Entity* self, Entity* killer) { return; // If the quick build expired and the treasure was not collected, hide the treasure - if (!treasure->GetIsDead()) { + if (!treasure->IsDead()) { treasure->Smash(self->GetObjectID(), eKillType::SILENT); } } diff --git a/dScripts/ai/NS/NsConcertInstrument.cpp b/dScripts/ai/NS/NsConcertInstrument.cpp index d37a8659..39121e43 100644 --- a/dScripts/ai/NS/NsConcertInstrument.cpp +++ b/dScripts/ai/NS/NsConcertInstrument.cpp @@ -27,7 +27,7 @@ void NsConcertInstrument::OnRebuildNotifyState(Entity* self, eRebuildState state } void NsConcertInstrument::OnRebuildComplete(Entity* self, Entity* target) { - if (!target->GetIsDead()) { + if (!target->IsDead()) { self->SetVar(u"activePlayer", target->GetObjectID()); self->AddCallbackTimer(0.2f, [self, target]() {