Skip to content

Commit

Permalink
version 0.3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff-Stapleton committed Oct 22, 2015
1 parent 3e83f95 commit 571b1cd
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 35 deletions.
8 changes: 4 additions & 4 deletions Config/DefaultGame.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

[/Script/TheArena.TheArenaGameMode]
WarmupTime=15
RoundTime=900
RoundKillLimit=25
RoundTime=600
RoundKillLimit=4
TimeBetweenMatches=15
KillScore=2
DeathScore=-1
KillScore=1
DeathScore=0
DamageSelfScale=1.0
MaxBots=1

Expand Down
55 changes: 48 additions & 7 deletions Source/TheArena/Private/Online/Arena_TeamDeathMatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ AArena_TeamDeathMatch::AArena_TeamDeathMatch(const class FObjectInitializer& Obj
: Super(ObjectInitializer)
{
NumTeams = 2;
Round = 0;
bDelayedStart = true;
}

Expand All @@ -26,6 +27,7 @@ void AArena_TeamDeathMatch::InitGameState()
AArenaGameState* const MyGameState = Cast<AArenaGameState>(GameState);
if (MyGameState)
{
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, FString::Printf(TEXT("Starting Round: %d"), Round));
MyGameState->NumTeams = NumTeams;
}
}
Expand All @@ -35,9 +37,8 @@ bool AArena_TeamDeathMatch::CanDealDamage(class AArenaPlayerState* DamageInstiga
return true;//DamageInstigator && DamagedPlayer && (DamagedPlayer == DamageInstigator || DamagedPlayer->GetTeamNum() != DamageInstigator->GetTeamNum());
}

int32 AArena_TeamDeathMatch::ChooseTeam(AArenaPlayerState* ForPlayerState) const
int32 AArena_TeamDeathMatch::ChooseTeam(AArenaPlayerState* ForPlayerState)
{
TArray<int32> TeamBalance;
TeamBalance.AddZeroed(NumTeams);

// get current team balance
Expand All @@ -50,7 +51,7 @@ int32 AArena_TeamDeathMatch::ChooseTeam(AArenaPlayerState* ForPlayerState) const
}
}

if (TeamBalance[0] < 4)
if (TeamBalance[0] <= TeamBalance[1])
{
return 0;
}
Expand All @@ -76,13 +77,53 @@ void AArena_TeamDeathMatch::DetermineMatchWinner()
BestTeam = i;
NumBestTeams = 1;
}
else if (BestScore == TeamScore)
}
WinnerTeam = (NumBestTeams == 1) ? BestTeam : NumTeams;

CheckTeamElimination();
Round++;
}

void AArena_TeamDeathMatch::CheckTeamElimination()
{
int32 TeamOneDead = 0;
int32 TeamTwoDead = 0;
for (int32 i = 0; i < GameState->PlayerArray.Num(); i++)
{
AArenaPlayerState const* const TestPlayerState = Cast<AArenaPlayerState>(GameState->PlayerArray[i]);
if (TestPlayerState->GetTeamNum() == 0)
{
AArenaCharacter *Pawn = Cast<AArenaCharacter>(TestPlayerState->GetOwner());
if (Pawn->GetCharacterAttributes()->bIsDying)//null pointer right here, is the character already destroyed?
{
TeamOneDead++;
}
}
if (TeamOneDead == TeamBalance[0])
{
NumBestTeams++;
WinnerTeam = 1;
bTeamEliminated = true;
return;
}
}
for (int32 i = 0; i < GameState->PlayerArray.Num(); i++)
{
AArenaPlayerState const* const TestPlayerState = Cast<AArenaPlayerState>(GameState->PlayerArray[i]);
if (TestPlayerState->GetTeamNum() == 1)
{
AArenaCharacter *Pawn = Cast<AArenaCharacter>(TestPlayerState->GetOwner());
if (Pawn->GetCharacterAttributes()->bIsDying)
{
TeamTwoDead++;
}
}
if (TeamOneDead == TeamBalance[1])
{
WinnerTeam = 0;
bTeamEliminated = true;
return;
}
}

WinnerTeam = (NumBestTeams == 1) ? BestTeam : NumTeams;
}

bool AArena_TeamDeathMatch::IsWinner(class AArenaPlayerState* PlayerState) const
Expand Down
31 changes: 9 additions & 22 deletions Source/TheArena/Private/Online/TheArenaGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ ATheArenaGameMode::ATheArenaGameMode(const class FObjectInitializer& PCIP)
//SpectatorClass = AArenaSpectatorPawn::StaticClass();
GameStateClass = AArenaGameState::StaticClass();

MinRespawnDelay = 5.0f;
MinRespawnDelay = 0.0f;

bAllowBots = false;
bTeamEliminated = false;
bUseSeamlessTravel = true;
}

Expand Down Expand Up @@ -79,26 +80,7 @@ void ATheArenaGameMode::DefaultTimer()
if (MyGameState && MyGameState->RemainingTime > 0 && !MyGameState->bTimerPaused)
{
MyGameState->RemainingTime--;

int32 BestScore = MAX_uint32;
int32 BestTeam = -1;
int32 NumBestTeams = 1;
for (int32 i = 0; i < MyGameState->TeamScores.Num(); i++)
{
const int32 TeamScore = MyGameState->TeamScores[i];
if (BestScore < TeamScore)
{
BestScore = TeamScore;
BestTeam = i;
NumBestTeams = 1;
}
else if (BestScore == TeamScore)
{
NumBestTeams++;
}
}

if (MyGameState->RemainingTime <= 0 || BestScore >= RoundKillLimit)
if (MyGameState->RemainingTime <= 0 || bTeamEliminated == true)
{
if (GetMatchState() == MatchState::WaitingPostMatch)
{
Expand Down Expand Up @@ -251,6 +233,11 @@ void ATheArenaGameMode::DetermineMatchWinner()
// nothing to do here
}

void ATheArenaGameMode::CheckTeamElimination()
{
// nothing to do here
}

bool ATheArenaGameMode::IsWinner(class AArenaPlayerState* PlayerState) const
{
return false;
Expand Down Expand Up @@ -301,12 +288,12 @@ void ATheArenaGameMode::Killed(AController* Killer, AController* KilledPlayer, A
KillerPlayerState->ScoreKill(VictimPlayerState, KillScore);
KillerPlayerState->InformAboutKill(KillerPlayerState, DamageType, VictimPlayerState);
}

if (VictimPlayerState)
{
VictimPlayerState->ScoreDeath(KillerPlayerState, DeathScore);
VictimPlayerState->BroadcastDeath(KillerPlayerState, DamageType, VictimPlayerState);
}
CheckTeamElimination();
}

float ATheArenaGameMode::ModifyDamage(float Damage, AActor* DamagedActor, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) const
Expand Down
2 changes: 1 addition & 1 deletion Source/TheArena/Private/Player/ArenaCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ void AArenaCharacter::SetRagdollPhysics()
}
else
{
SetLifeSpan(10.0f);
SetLifeSpan(900.0f);
}
}

Expand Down
11 changes: 10 additions & 1 deletion Source/TheArena/Public/Online/Arena_TeamDeathMatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,25 @@ class THEARENA_API AArena_TeamDeathMatch : public ATheArenaGameMode

/** number of teams */
int32 NumTeams;

/** round counter */
int32 Round;

/** best team */
int32 WinnerTeam;

/** team balance */
TArray<int32> TeamBalance;

/** pick team with least players in or random when it's equal */
int32 ChooseTeam(class AArenaPlayerState* ForPlayerState) const;
int32 ChooseTeam(class AArenaPlayerState* ForPlayerState);

/** check who won */
virtual void DetermineMatchWinner() override;

/** check if won */
virtual void CheckTeamElimination() override;

/** check if PlayerState is a winner */
virtual bool IsWinner(class AArenaPlayerState* PlayerState) const override;

Expand Down
5 changes: 5 additions & 0 deletions Source/TheArena/Public/Online/TheArenaGameMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,16 @@ class ATheArenaGameMode : public AGameMode
/** Handle for efficient management of DefaultTimer timer */
FTimerHandle TimerHandle_DefaultTimer;

bool bTeamEliminated;

bool bAllowBots;

/** check who won */
virtual void DetermineMatchWinner();

/** check who won */
virtual void CheckTeamElimination();

/** check if PlayerState is a winner */
virtual bool IsWinner(class AArenaPlayerState* PlayerState) const;

Expand Down

0 comments on commit 571b1cd

Please sign in to comment.