mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
fix: implement enemy clear threat script (#1678)
* brother * use some better logic
This commit is contained in:
@@ -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"
|
||||
|
25
dScripts/02_server/Map/General/EnemyClearThreat.cpp
Normal file
25
dScripts/02_server/Map/General/EnemyClearThreat.cpp
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
11
dScripts/02_server/Map/General/EnemyClearThreat.h
Normal file
11
dScripts/02_server/Map/General/EnemyClearThreat.h
Normal 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
|
Reference in New Issue
Block a user