fix: implement enemy clear threat script (#1678)

* brother

* use some better logic
This commit is contained in:
David Markowitz
2024-12-15 21:44:57 -08:00
committed by GitHub
parent 53242ad5d5
commit 0f8c5b436d
20 changed files with 197 additions and 64 deletions

View File

@@ -2,6 +2,7 @@ set(DSCRIPTS_SOURCES_02_SERVER_MAP_GENERAL
"BankInteractServer.cpp"
"BaseInteractDropLootServer.cpp"
"Binoculars.cpp"
"EnemyClearThreat.cpp"
"ExplodingAsset.cpp"
"FrictionVolumeServer.cpp"
"ForceVolumeServer.cpp"

View File

@@ -0,0 +1,25 @@
#include "EnemyClearThreat.h"
#include "BaseCombatAIComponent.h"
#include "PhysicsComponent.h"
void EnemyClearThreat::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target) return;
const auto colGroup = target->GetCollisionGroup();
if (colGroup == 12) { // enemy
auto* const baseCombatAiComponent = target->GetComponent<BaseCombatAIComponent>();
if (!baseCombatAiComponent) return;
baseCombatAiComponent->ClearThreat();
baseCombatAiComponent->ForceTether();
} else if (colGroup == 10) { // player
const auto enemies = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::BASE_COMBAT_AI);
for (const auto& enemy : enemies) {
auto* const baseCombatAiComponent = enemy->GetComponent<BaseCombatAIComponent>();
if (!baseCombatAiComponent) continue;
baseCombatAiComponent->IgnoreThreat(target->GetObjectID(), 3.0f);
}
}
}

View File

@@ -0,0 +1,11 @@
#ifndef ENEMYCLEARTHREAT_H
#define ENEMYCLEARTHREAT_H
#include "CppScripts.h"
class EnemyClearThreat : public CppScripts::Script {
public:
void OnCollisionPhantom(Entity* self, Entity* target) override;
};
#endif //!ENEMYCLEARTHREAT_H