Esempio n. 1
0
		void TeleportTo(Vector3* position)
		{
			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;

			World* GameWorld = GetWorldObject();
			if (!GameWorld) return;

			//auto const logMsg = boost::str(boost::format("TeleportTo(%.2f,%.2f,%.2f)")
			//	% position->x % position->y % position->z);
			//Chat(logMsg);

			Rotation rot{ 0, 0, 0 };
			ue4actor->vfptr->GetRotation(ue4actor, &rot);
			GameWorld->vfptr->SendRespawnEvent(GameWorld, me->GetPlayer(), position, &rot);
			ue4actor->vfptr->LocalRespawn(ue4actor, position, &rot);
		}
Esempio n. 2
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);
		}