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,
uint8 playerIndex,
float PathLength) {
uint8 playerIndex,
float PathLength) {
ProjectileMovementComponent->InitialSpeed =
ProjectileMovementComponent->MaxSpeed = Ability->Speed;
Damage = Ability->Damage;
@ -69,9 +69,16 @@ void AProjectile::NotifyActorBeginOverlap(AActor *OtherActor) {
),
OtherTrooper->GetId(), OtherTrooper->GetPlayerIndex(), Damage,
PlayerIndex);
if (PlayerIndex != -1 && PlayerIndex != OtherTrooper->
GetPlayerIndex()) {
OtherTrooper->TrooperTakeDamage(Damage);
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,15 +308,20 @@ void ATrooper::TrooperTakeDamage_Implementation(float Damage) {
if (bIsTakingDamage || bIsDead) {
return;
}
HitPoints = FMath::Max<float>(0, HitPoints - Damage);
if (HitPoints == 0) {
bIsDead = true;
SetLifeSpan(DyingAnimationDuration);
GetWorld()->GetGameState<ABattleGameState>()->DecreaseLivingTroopers(
PlayerIndex);
if (Damage > 0) {
HitPoints = FMath::Max<float>(0, HitPoints - Damage);
if (HitPoints == 0) {
bIsDead = true;
SetLifeSpan(DyingAnimationDuration);
GetWorld()->GetGameState<ABattleGameState>()->
DecreaseLivingTroopers(
PlayerIndex);
} else {
// bIsTakingDamage = true;
SetIsTakingDamage(true);
}
} else {
// bIsTakingDamage = true;
SetIsTakingDamage(true);
HitPoints = FMath::Min<float>(StartHitPoints, HitPoints - Damage);
}
}

Loading…
Cancel
Save