// Splits the calling object into its components.
global func Split2Components()
{
	// Safety: can only be called from object context.
	if (!this || GetType(this) != C4V_C4Object)
		return FatalError(Format("Split2Components must be called from object context and not from %v", this));

	// Transfer all contents to container.
	var ctr = Contained();
	while (Contents())
		if (!ctr || !Contents()->Enter(ctr))
			Contents()->Exit();
			
	// Split components.
	for (var i = 0, compid; compid = GetComponent(nil, i); ++i)
		for (var j = 0; j < GetComponent(compid); ++j)
		{
			var comp = CreateObjectAbove(compid, nil, nil, GetOwner());
			if (OnFire()) comp->Incinerate();
			if (!ctr || !comp->Enter(ctr))
			{
				comp->SetR(Random(360));
				comp->SetXDir(Random(3) - 1);
				comp->SetYDir(Random(3) - 1);
				comp->SetRDir(Random(3) - 1);
			}
		}
	return RemoveObject();
}
void ATotemCharacter::TouchStarted(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	// only fire for first finger down
	if (FingerIndex == 0)
	{
		OnFire();
	}
}
Example #3
0
public func Activate(oCaller, oClonk)
{                            
  if(!oClonk) oClonk = oCaller;
  // Effekt prüfen
  var iChkEff;
  if (iChkEff = CheckEffect("ExtinguishPSpell", oExtiObj, 180)) return(iChkEff!=-1 && RemoveObject());
  // Lavafässer zu Granit werden lassen
  var obj;
  if (obj = FindContents(LBRL, oClonk))
    if (!CheckEffect("ExtinguishPSpell", obj, 180))
    {
      var mat = "Granite";
      // Granit nicht geladen -> Stein casten
      if (!MaterialLoaded(Material(mat))) mat = "Rock";
      // Stein nicht geladen -> Kohle casten
      if (!MaterialLoaded(Material(mat))) mat = "Coal";
      // Material schleudern
      var amount = Min(400, obj->GetAmount()*3);
      CastPXS(mat, amount, 40, AbsX(GetX(oClonk)), AbsY(GetY(oClonk)));
      // Objekt entfernen
      RemoveObject(obj);
    }
  // Nächstes brennendes Objekt finden
  var oExtiObj, iExtiCount;
  // Den Clonk selbst?
  if(OnFire(oClonk)) 
    iExtiCount += DoExtinguish(oClonk, oCaller);
  // Nächstliegende Objekte
  SetPosition(GetX(oCaller), GetY(oCaller));
  // Suchradius ist abhängig von Höhe des Aufrufenden - ein Zauberturm hat einen größeren Radius
  var iSearchRadius = GetObjHeight(oCaller) * 3;
  while(oExtiObj = FindObject(0, 0, 0, -1, -1, 0, 0, 0, 0, oExtiObj))
    if(ObjectDistance(oCaller, oExtiObj) > iSearchRadius)
      break;
    else if(OnFire(oExtiObj))
      iExtiCount += DoExtinguish(oExtiObj, oCaller);
    else if (oExtiObj->~MagicExtinguish(oCaller))
      iExtiCount += DoExtinguish(oExtiObj, oCaller);
  // Irgendwas gelöscht?
  if (!iExtiCount) return(0, Message("$NoExtinguish$", oClonk), RemoveObject());
  // Einmaliger Effekt pro Zauber
  Sound("Splash1");
  return(true);
}
void AMobileOpenCVCharacter::EndTouch(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	if (TouchItem.bIsPressed == false)
	{
		return;
	}
	if( ( FingerIndex == TouchItem.FingerIndex ) && (TouchItem.bMoved == false) )
	{
		OnFire();
	}
	TouchItem.bIsPressed = false;
}
void AFP_FirstPersonCharacter::EndTouch(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	// If we didnt record the start event do nothing, or this is a different index
	if((TouchItem.bIsPressed == false) || ( TouchItem.FingerIndex != FingerIndex) )
	{
		return;
	}

	// If the index matches the start index and we didn't process any movement we assume we want to fire
	if ((FingerIndex == TouchItem.FingerIndex) && (TouchItem.bMoved == false))
	{
		OnFire();
	}

	// Flag we are no longer processing the touch event
	TouchItem.bIsPressed = false;
}
Example #6
0
void ALD35Character::Tick(float deltaTime)
{
	Super::Tick(deltaTime);

	if (Health <= 0) return;

	ShotCooldown -= deltaTime;
	HealthRegenStoppedFor -= deltaTime;

	if (IsFiring && ShotCooldown <= 0)
	{
		ShotCooldown = IsInAlternateForm ? 0.5f : 1.5f;

		OnFire();
	}

	if (IsInAlternateForm)
	{
		Energy = FMath::Clamp(Energy - deltaTime / MaxTransformTime, 0.f, 1.f);

		if (Energy <= 0)
		{
			Transform();
		}

		if (HealthRegenStoppedFor <= 0) Health = FMath::Clamp(Health + deltaTime, 0.f, 4.f);
	}

	for (auto& a : GetComponentsByTag(UPrimitiveComponent::StaticClass(), TEXT("Human")))
	{
		Cast<UPrimitiveComponent>(a)->SetVisibility(!IsInAlternateForm);
	}

	for (auto& a : GetComponentsByTag(UPrimitiveComponent::StaticClass(), TEXT("Claw")))
	{
		Cast<UPrimitiveComponent>(a)->SetVisibility(IsInAlternateForm);
	}

	for (auto& a : GetComponentsByClass(UPointLightComponent::StaticClass()))
	{
		Cast<UPointLightComponent>(a)->SetVisibility(!IsSomeoneTransformed);
	}
}
void AFP_FirstPersonCharacter::BeginTouch(const ETouchIndex::Type FingerIndex, const FVector Location)
{
	// If touch is already pressed check the index. If it is not the same as the current touch assume a second touch and thus we want to fire
	if (TouchItem.bIsPressed == true)
	{
		if( TouchItem.FingerIndex != FingerIndex)
		{
			OnFire();			
		}
	}
	else 
	{
		// Cache the finger index and touch location and flag we are processing a touch
		TouchItem.bIsPressed = true;
		TouchItem.FingerIndex = FingerIndex;
		TouchItem.Location = Location;
		TouchItem.bMoved = false;
	}
}
Example #8
0
/* Called every frame. */
void ARTSUnit::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	switch (State)
	{
		/* Move unit to destination. */
		case UnitAction::Move:
			CurrentDistance = FVector::Dist(CurrentDestination, GetActorLocation());
			if (CurrentDistance < StopDistance)
			{
				State = UnitAction::Idle;
			}
			break;
		/* Tell unit to attack target. */
		case UnitAction::Attack:
			if (Target != NULL)
			{
				CurrentDistance = FVector::Dist(Target->GetActorLocation(), GetActorLocation());

				float Cooldown = 1.0f / CurrentAttackSpeed;

				if (CurrentDistance < AttackDistance)
				{
					GetController()->StopMovement();
					if (GetWorld()->GetTimeSeconds() >= NextTimeToAttack)
					{
						OnFire();
						NextTimeToAttack = GetWorld()->GetTimeSeconds() + Cooldown;
					}
				}

				FRotator LookRot = (Target->GetActorLocation() - GetActorLocation()).Rotation();

				FRotator NewRot = FMath::RInterpTo(GetActorRotation(), LookRot, DeltaTime, CharacterMovement->RotationRate.Yaw * DeltaTime);

				SetActorRelativeRotation(NewRot);
			}
			break;
	}
}
Example #9
0
//Such nach einem Objekt, dass ein Acquire-Command holen könnte
global func GetAvailableObject (def, xobj)
{
  var obj;
  // Next closest
  while (obj = FindObject (def, 0, 0, -1, -1, OCF_Available (), 0, 0, 0, obj))
  {
    if (ObjectDistance (obj) > 559) return (); 
    // Object is near enough
    if (!Inside (GetX () - GetX (obj), -500, +500)) continue;
    if (!Inside (GetY () - GetY (obj), -250, +250)) continue;
    // Object is not connected to a pipe (for line construction kits)
    if (FindObject (SPIP, 0, 0, 0, 0, 0, "Connect", obj)) continue;
    if (FindObject (DPIP, 0, 0, 0, 0, 0, "Connect", obj)) continue;
    // Must be complete
    if (~GetOCF (obj) & OCF_Fullcon ()) continue;
    // Doesn't burn
    if (OnFire( obj)) continue;
    // Not contained in xobj
    if (!(Contained (obj) == xobj) || !xobj)
      // We found one
      break;
  }
  return (obj);
}
void ATotemCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (TimeSinceHit > 0.0f)
	{
		TimeSinceHit -= DeltaTime;
	}
	else
	{
		PreviousHit.controller = nullptr;
		PreviousHit.type = AbilityType::NONE;
		PreviousHit.name = "";
	}

	if (bThirdPersonDeathCamLerp)
	{
		if (Controller)
		{
			Controller->SetControlRotation(FRotator(-1.0f * DeathCamAngle, 0, 0));
		}
	}

	if (bThirdPersonCamLerp || bThirdPersonDeathCamLerp )
	{
		CameraBoom->TargetArmLength = FMath::Lerp<float>(CameraBoom->TargetArmLength, ThirdPersonCamDistance, DeltaTime*4.0f);
	}
	else
	{
		CameraBoom->TargetArmLength = FMath::Lerp<float>(CameraBoom->TargetArmLength, 0, DeltaTime*4.0f);
	}

	if (bIsDead && (ThirdPersonCamDistance!= ThirdPersonDeathCamDistance))
	{
		ThirdPersonCamDistance = ThirdPersonDeathCamDistance;
	}

	if ( ((FMath::Abs(CameraBoom->TargetArmLength - ThirdPersonCamDistance) < 0.5f) && bIsDead && bThirdPersonDeathCamLerp))
	{
		ATotemPlayerController *PC = Cast<ATotemPlayerController>(Controller);
		if (PC)
		{
			if (HasAuthority())
			{
				PC->HandleDead(FVector(0, 0, 0), FRotator(0, 0, 0));
			}
			bThirdPersonDeathCamLerp = false;
		}
	}

	if (bDeathEffectFired && RayCastOnGround() )
	{
		FireMaterialEffect();
		bDeathEffectFired = false;
	}

	if ((CameraBoom->TargetArmLength > 0.5f) && (!bIsShamanVisible))
	{
		if (GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Controller)
		{
			MakeSelfVisible();
			bIsShamanVisible = true;
		}
	}
	
	if ((CameraBoom->TargetArmLength <= 0.5f) && (bIsShamanVisible))
	{
		if (GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Controller)
		{
			MakeSelfInvisible();
			bIsShamanVisible = false;
		}
	}

	if (Controller && FirstTick)
	{
		if (GEngine->GetGamePlayer(GetWorld(), 0)->PlayerController == Controller)
		{
			MakeSelfInvisible();
			bIsShamanVisible = false;
		}
		FirstTick = false;
	}

	ATotemPlayerState *TotemPlayerState = Cast<ATotemPlayerState>(PlayerState);
	if (TotemPlayerState && bFirstSpawn)
	{
		SetActorLocation(TotemPlayerState->StartingLocation);
		SetActorRotation(TotemPlayerState->StartingRotation);
		bFirstSpawn = false;
	}

	if (bReborn && HasAuthority())
	{
		TotalRebornDuration -= DeltaTime;
		if (TotalRebornDuration < 0.0f)
		{
			bReborn = false;
			ExitReborn();
		}
	}


	if (HasAuthority())
	{
		if (bBeingKnockedBack)
		{
			TimeSinceKnockedBack -= DeltaTime;
			if (TimeSinceKnockedBack < 0.0f)
			{
				bBeingKnockedBack = false;
			}
		}
#if (WRITE_METRICS > 1)
		if (DeltaTime >= .025)
		{
			ATotemPlayerController* control = Cast<ATotemPlayerController>(Controller);
			if(control)
			{
				ATotemPlayerState* state = Cast<ATotemPlayerState>(control->PlayerState);
				if(state)
				{
					std::string team;
					switch (state->Team)
					{
					case ETeam::RED_TEAM:
						team = "Red";
						break;
					case ETeam::BLUE_TEAM:
						team = "Blue";
						break;
					default:
						team = "None";
						break;
					}
					Metrics::WriteToFile(std::string(TCHAR_TO_UTF8(*(state->MyName))), team, std::string("Frame rate hit"), std::string(std::to_string(DeltaTime) + "ms"), std::string(std::to_string(1.0f/DeltaTime) + "fps"));
				}
			}
		}
#endif
	}


	//Keep track of how long has passed since the last attack
	TimeSinceAttack += DeltaTime;
	ShotPressedDuration += DeltaTime;

	//If shot is pressed and enough time has been pressed
	if (ShotPressed && TimeSinceAttack >= TimeBetweenShots)
	{
		//And you either can rapid fire or no shot has been fired since the shot button was pressed
		if (CanRapidFire || !ShotFired)
		{
			OnFire();
			ShotFired = true;
			TimeSinceAttack = 0.0f;
		}
	}
	else if (!ShotPressed)
	{
		ShotPressedDuration = 0;
	}

	//If get hit by cyclone, then the shaman cannnot move
	if (HasAuthority())
	{
		TArray<AActor* > OverlappedActors;
		TArray<ACyclone* > OverlappedCyclones;
		GetOverlappingActors(OverlappedActors);
		for (int32 i = 0; i < OverlappedActors.Num(); i++)
		{
			ACyclone* Cyclone = Cast<ACyclone>(OverlappedActors[i]);
			if (Cyclone && !Cyclone->IsPendingKill())
			{
				//overlap myself doesn't count
				if (Cyclone->GetOwner() != GetController())
				{
					OverlappedCyclones.Add(Cyclone);
				}
			}
		}

		if (OverlappedCyclones.Num() == 0)
		{
			//Do this to prevent bCanMove be replictated every frame
			if (!bCanMove)
			{
				bCanMove = true;
			}
			AttachCyclone = nullptr;
		}
		else if (OverlappedCyclones.Num() > 0)
		{
			if (bCanMove)
			{
				bCanMove = false;
			}
			if (AttachCyclone)
			{
				FVector CycloneVelocity = AttachCyclone->ProjectileMovement->Velocity;
				ATotemPlayerController* own = Cast<ATotemPlayerController>(AttachCyclone->GetOwner());
				if (own)
				{
					ReduceHealth(AttachCyclone->Damage * DeltaTime, own, AbilityType::WIND, FName(TEXT("Cyclone"))); //every second reduce Damage amount of health
				}
				LaunchCharacter(CycloneVelocity, true, true);
			}
			//CharacterMovement->Velocity = CycloneVelocity;
		}
	}

	//temporary solution, maybe later we need more fancy stuff.
	if (bIsDead && HasAuthority())
	{
		CurrentDeadBodyDuration -= DeltaTime;
		if (CurrentDeadBodyDuration <= 0)
		{
			Destroy();
		}
	}

	if (bClickedThisFrame)
	{
		bClickedThisFrame = false;
		if (Controller)
		{
			APlayerController* control = Cast<APlayerController>(Controller);
			if (control)
			{
				if (!control->IsInputKeyDown(EKeys::LeftMouseButton))
				{
					LeftUp();
				}
			}
		}
	}

	if (bRightButtonDownThisFrame)
	{
		bRightButtonDownThisFrame = false;
		if (Controller)
		{
			APlayerController* control = Cast<APlayerController>(Controller);
			if (control)
			{
				if (!control->IsInputKeyDown(EKeys::RightMouseButton))
				{
					RightUp();
				}
			}
		}
	}

	//CheckShiftKey();

}
Example #11
0
func ChkIncinerate()
{
  while(Var(0)=FindObject(0,-6,-6,12,12,OCF_Prey(),0,0,NoContainer(),Var())) 
    if(Hostile(GetOwner(),GetOwner(Var()))) if(!OnFire(Var())) Incinerate(Var(0));
  return(1);
}