Пример #1
0
void ANavigationObjectBase::Validate()
{
	if ( ShouldBeBased() && (GoodSprite || BadSprite) )
	{
		FVector OrigLocation = GetActorLocation();
		const float Radius = CapsuleComponent->GetScaledCapsuleRadius();
		FVector const Slice(Radius, Radius, 1.f);

		bool bResult = true;

		// Check for adjustment
		FHitResult Hit(ForceInit);
		const FVector TraceStart = GetActorLocation();
		const FVector TraceEnd = GetActorLocation() - FVector(0.f,0.f, 4.f * CapsuleComponent->GetScaledCapsuleHalfHeight());
		GetWorld()->SweepSingleByChannel(Hit, TraceStart, TraceEnd, FQuat::Identity, ECC_Pawn, FCollisionShape::MakeBox(Slice), FCollisionQueryParams(NAME_None, false, this));
		if( Hit.bBlockingHit )
		{
			const FVector HitLocation = TraceStart + (TraceEnd - TraceStart) * Hit.Time;
			FVector Dest = HitLocation + FVector(0.f,0.f,CapsuleComponent->GetScaledCapsuleHalfHeight()-2.f);

			// Move actor (TEST ONLY) to see if navigation point moves
			TeleportTo( Dest, GetActorRotation(), false, true );

			// If only adjustment was down towards the floor, then it is a valid placement
			FVector NewLocation = GetActorLocation();
			bResult = ( NewLocation.X == OrigLocation.X &&  
				NewLocation.Y == OrigLocation.Y && 
				NewLocation.Z <= OrigLocation.Z );

			// Move actor back to original position
			TeleportTo( OrigLocation, GetActorRotation(), false, true );
		}	
		
		// Update sprites by result
		if( GoodSprite )
		{
			GoodSprite->SetVisibility(bResult);
		}
		if( BadSprite )
		{
			BadSprite->SetVisibility(!bResult);
		}
	}

	// Force update of icon
	MarkComponentsRenderStateDirty();
}
void ADonkeyKongCharacter::ClimbFinish(const FVector& LeaveLedderLocation, class ADKLadder* Ladder)
{
	if (Ladder == CurrentLadder)
	{
		TeleportTo(LeaveLedderLocation, FRotator(0, 0, 0));
		GetCharacterMovement()->SetMovementMode(EMovementMode::MOVE_Walking);
		bIsClimbing = false;
		bHaveClimbed = true;
	}
}
Пример #3
0
		void TeleportToActor(std::string const& name)
		{
			World* GameWorld = GetWorldObject();
			if (!GameWorld) return;

			for (auto const& actorRef : GameWorld->m_actors)
			{
				IActor* actor = actorRef.m_object;
				if (actor != nullptr)
				{
					std::string blueprint(actor->vfptr->GetBlueprintName(actor));
					if (blueprint.find(name) != std::string::npos)
					{
						Vector3 pos;
						actor->vfptr->GetLookPosition(actor, &pos);
						TeleportTo(&pos);
						return;
					}
				}
			}

			//Chat("Could not find actor \"" + name + "\"");
		}
Пример #4
0
		void TeleportForward(float distance)
		{
			IPlayer* me = GetMe();
			if (!me) return;

			Player* playerMe = me->GetPlayer();
			if (!playerMe) return;

			IActor* actorMe = me->vfptr->GetActorInterface(me);
			if (!actorMe) return;

			IUE4Actor* ue4actor = playerMe->baseclass_0.m_target;
			if (!ue4actor) return;

			Vector3 position;
			Rotation rotation;
			ue4actor->vfptr->GetPosition(ue4actor, &position);
			ue4actor->vfptr->GetRotation(ue4actor, &rotation);

			// Their angles go from [0, 180) and [-0, -180), convert to [0, 360).
			float facing = rotation.yaw;
			if (facing < 0.0f)
			{
				facing += 360.0f;
			}

			facing = facing * static_cast<float>(M_PI) / 180.0f;
			float const x = std::cos(facing);
			float const y = std::sin(facing);

			// TODO: z

			position.x += distance * x;
			position.y += distance * y;

			TeleportTo(&position);
		}
Пример #5
0
	void UpdateAI(const uint32 diff)
	{
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;
		if (!m_bPhase2 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 66)
		{
			if (m_pInstance)
			{
				m_pInstance->SetData(TYPE_PHASE_TWO, IN_PROGRESS);
			}
			m_bPhase2 = true;
		}
        if (!m_bPhase3 && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 66)
        {
            TeleportTo();
            m_bPhase3 = true;
        }
        if(!m_bEnd && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 3)
        {
            if (m_pInstance)
            {
                m_pInstance->SetData(TYPE_END, IN_PROGRESS);
            }
            TeleportToShip();
            m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            m_bPhaseThree = false;
            m_bEnd = true;
        }
		if (m_bPhase2)
		{
			if(!minions)
			{
				SpawnMinions();
                m_creature->MonsterYell("Get out of my sight!",LANG_UNIVERSAL,m_creature->getVictim());
			}
            if(m_uiAscendTimer < diff && !m_bAscend)
			{
				DoCastSpellIfCan(m_creature,SPELL_ASCEND);
                m_bAscend = true;
			}
			else
				m_uiAscendTimer -= diff;
		}
        if(m_bPhase3 && m_bPhaseThree)
        {
            if(m_uiTargetSwitchTimer < diff)
                GetTarget();
            else
                m_uiTargetSwitchTimer -= diff;
        }
		if(m_uiThrashTimer < diff)
		{
			Unit* pTarget = NULL;
			if(pTarget = m_creature->getVictim())
			{
				DoCast(pTarget,SPELL_THRASH);
			}
			m_uiThrashTimer = urand(2500,5000);
		}
		else
		{
			m_uiThrashTimer -= diff;
		}
		if(m_uiToxinTimer < diff)
		{
			Unit* pTarget = NULL;
			if(pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
			{
				DoCastSpellIfCan(pTarget,SPELL_HEMOTOXIN);
				m_uiToxinTimer = 15000;
			}
		}
		else
		{
			m_uiToxinTimer -= diff;
		}
		if(!m_bBerserk)
		{
			if (m_uiBerserkTimer < diff)
			{
				DoCastSpellIfCan(m_creature, SPELL_BERSERK);
				m_bBerserk = true;
			}
			else
			{
				m_uiBerserkTimer -= diff;
			}
		}
        if(minions && !minionsAlive[0] && !minionsAlive[1] && !minionsAlive[2] && !minionsAlive[3])
		{
            if(m_pInstance)
            {
                m_pInstance->SetData(TYPE_PHASE_TWO, DONE);
            }
			minions = false;
        }
		DoMeleeAttackIfReady();
	}