healing projectile

feature-map-and-sounds
m4xxx1m 2 years ago
parent 6e1fd803f1
commit 71fd6242fe

@ -69,10 +69,17 @@ void AProjectile::NotifyActorBeginOverlap(AActor *OtherActor) {
),
OtherTrooper->GetId(), OtherTrooper->GetPlayerIndex(), Damage,
PlayerIndex);
if (Damage > 0) {
if (PlayerIndex != -1 && PlayerIndex != OtherTrooper->
GetPlayerIndex()) {
OtherTrooper->TrooperTakeDamage(Damage);
}
} else {
if (PlayerIndex != -1 && PlayerIndex == OtherTrooper->
GetPlayerIndex()) {
OtherTrooper->TrooperTakeDamage(Damage);
}
}
} else {
UE_LOG(LogTemp, Warning, TEXT("Overlapped not a trooper"));
}

@ -308,16 +308,21 @@ void ATrooper::TrooperTakeDamage_Implementation(float Damage) {
if (bIsTakingDamage || bIsDead) {
return;
}
if (Damage > 0) {
HitPoints = FMath::Max<float>(0, HitPoints - Damage);
if (HitPoints == 0) {
bIsDead = true;
SetLifeSpan(DyingAnimationDuration);
GetWorld()->GetGameState<ABattleGameState>()->DecreaseLivingTroopers(
GetWorld()->GetGameState<ABattleGameState>()->
DecreaseLivingTroopers(
PlayerIndex);
} else {
// bIsTakingDamage = true;
SetIsTakingDamage(true);
}
} else {
HitPoints = FMath::Min<float>(StartHitPoints, HitPoints - Damage);
}
}
TSubclassOf<AProjectile> ATrooper::GetProjectileClass(

Loading…
Cancel
Save