79 lines
1.6 KiB
C++
79 lines
1.6 KiB
C++
// Project Lab - NHTV Igad
|
|
|
|
#include "UnrealProject.h"
|
|
#include "NPCBase.h"
|
|
#include "NetworkDoor.h"
|
|
#include "DefaultGameMode.h"
|
|
#include "KOTHMinionSpawner.h"
|
|
#include "KOTHBossSpawner.h"
|
|
#include "NetworkCharacter.h"
|
|
|
|
|
|
|
|
AKOTHMinionSpawner::AKOTHMinionSpawner(const FObjectInitializer& init)
|
|
: Super(init)
|
|
{
|
|
respawnTime = 5;
|
|
// m_respawnTimer = 0;
|
|
|
|
spawnContinuous = true;
|
|
}
|
|
void AKOTHMinionSpawner::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
if (Role == ROLE_Authority)
|
|
{
|
|
kothagroRadius = aggroRadius;
|
|
kothdeagroRadius = deaggroRadius;
|
|
|
|
for (TActorIterator<AKOTHBossSpawner>bSpawn(GetWorld()); bSpawn; ++bSpawn)
|
|
{
|
|
if (bSpawn)
|
|
bossSpawner = *bSpawn;
|
|
}
|
|
Super::m_RespawnMobs();
|
|
}
|
|
}
|
|
void AKOTHMinionSpawner::Tick(float DeltaTime)
|
|
{
|
|
Super::Tick(DeltaTime);
|
|
|
|
if (!HasAuthority())
|
|
return;
|
|
|
|
// Reset the camp to the NPC team after an amount of time(captureTime)
|
|
m_captureTimer -= DeltaTime;
|
|
if (m_captureTimer < 0 && (int)team < 5)
|
|
{
|
|
SetTeam((int)(NPCTeam::Team1));
|
|
m_reset = true;
|
|
}
|
|
}
|
|
void AKOTHMinionSpawner::GetNewTarget(ANPCBase* mob)
|
|
{
|
|
|
|
if (team == bossSpawner->team || (int)team>5)
|
|
{
|
|
aggroRadius = kothagroRadius;
|
|
deaggroRadius = kothdeagroRadius;
|
|
Super::GetNewTarget(mob);
|
|
return;
|
|
}
|
|
for (ANPCBase* bMob : bossSpawner->m_mobs)
|
|
{
|
|
aggroRadius = 1e34;
|
|
deaggroRadius = 1e34;
|
|
ANetworkCharacter* threat = Cast<ANetworkCharacter>(bMob);
|
|
if (threat)
|
|
mob->target = threat;
|
|
|
|
}
|
|
}
|
|
void AKOTHMinionSpawner::m_RespawnMobs()
|
|
{
|
|
if (((int)team < 5 || m_reset))
|
|
{
|
|
Super::m_RespawnMobs();
|
|
}
|
|
}
|