void ARealmEnabler::OnTargetsUpdate() { for (TActorIterator<APlayerCharacter> plyitr(GetWorld()); plyitr; ++plyitr) { APlayerCharacter* pc = (*plyitr); if (!IsValid(pc) || !pc->IsAlive() || pc->GetTeamIndex() != GetTeamIndex()) continue; float distanceSq = (pc->GetActorLocation() - GetActorLocation()).SizeSquared2D(); if (distanceSq > FMath::Square(auraRange)) { if (IsValid(pc->GetStatsManager()) && protectedPlayers.Contains(pc) && protectedPlayers.Remove(pc) > 0) EnablerEffectFinished(pc); } else if (!protectedPlayers.Contains(pc) && protectedPlayers.AddUnique(pc) >= 0) { enablerAuraEffect = GetWorld()->SpawnActor<AEffect>(AEffect::StaticClass()); //effect descriptions enablerAuraEffect->uiName = LOCTEXT("enablereffect", "Enabler Protection Aura"); enablerAuraEffect->description = LOCTEXT("enablereffectdesc", "This unit is under protection from their Enabler and has increased Health and Flare regeneration."); enablerAuraEffect->keyName = "enablerprotection"; enablerAuraEffect->bCanBeInflictedMultipleTimes = false; //effect stat changes enablerAuraEffect->stats.AddUnique(EStat::ES_HPRegen); enablerAuraEffect->stats.AddUnique(EStat::ES_FlareRegen); enablerAuraEffect->amounts.Add(50.f); enablerAuraEffect->amounts.Add(50.f); pc->GetStatsManager()->AddCreatedEffect(enablerAuraEffect); } } }
void ARockSpell::StartBehavior(const APlayerCharacter& player) { this->SetActorHiddenInGame(false); this->SetActorEnableCollision(true); RockMesh->Activate(true); SetActorLocation(player.GetActorLocation() + player.GetActorForwardVector() * 100,false,(FHitResult*)nullptr,ETeleportType::TeleportPhysics); movementComponent->InitializeAndStart(MaxRockDistance, chargedTime, player.GetActorForwardVector()); }