healing projectile

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

@ -42,8 +42,8 @@ AProjectile::AProjectile() {
} }
void AProjectile::Initialize(const UAbility *Ability, void AProjectile::Initialize(const UAbility *Ability,
uint8 playerIndex, uint8 playerIndex,
float PathLength) { float PathLength) {
ProjectileMovementComponent->InitialSpeed = ProjectileMovementComponent->InitialSpeed =
ProjectileMovementComponent->MaxSpeed = Ability->Speed; ProjectileMovementComponent->MaxSpeed = Ability->Speed;
Damage = Ability->Damage; Damage = Ability->Damage;
@ -69,9 +69,16 @@ void AProjectile::NotifyActorBeginOverlap(AActor *OtherActor) {
), ),
OtherTrooper->GetId(), OtherTrooper->GetPlayerIndex(), Damage, OtherTrooper->GetId(), OtherTrooper->GetPlayerIndex(), Damage,
PlayerIndex); PlayerIndex);
if (PlayerIndex != -1 && PlayerIndex != OtherTrooper-> if (Damage > 0) {
GetPlayerIndex()) { if (PlayerIndex != -1 && PlayerIndex != OtherTrooper->
OtherTrooper->TrooperTakeDamage(Damage); GetPlayerIndex()) {
OtherTrooper->TrooperTakeDamage(Damage);
}
} else {
if (PlayerIndex != -1 && PlayerIndex == OtherTrooper->
GetPlayerIndex()) {
OtherTrooper->TrooperTakeDamage(Damage);
}
} }
} else { } else {
UE_LOG(LogTemp, Warning, TEXT("Overlapped not a trooper")); UE_LOG(LogTemp, Warning, TEXT("Overlapped not a trooper"));

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

Loading…
Cancel
Save