Jump to content
View in the app

A better way to browse. Learn more.

RDR2Mods.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello i have this code for my raycast.cpp:

But when i hit a entity with the IntersectOptions on int 12.

My game crash any idea why?

 

I use like this:

if (features::activateRaycast) {
			Entity target;
			Vector3 camPos = Position();
			Vector3 camDir = DirectionFromScreenCentre();

			auto ray = RaycastResult::Raycast(camPos, camDir, 20000.0f, IntersectOptions::Peds1, features::myPed());

			if (ray.DidHitEntity()) {
				auto hitEntity = ray.HitEntity();
				printf("Entity id: %d", hitEntity);
				
			}

		}

 

 

Raycast.cpp

RaycastResult::RaycastResult()
	: mResult(0), mDidHit(false)
{
}

RaycastResult::RaycastResult(const RaycastResult& handle)
	: mResult(handle.mResult), mDidHit(handle.mDidHit), mHitEntity(handle.mHitEntity), mHitCoords(handle.mHitCoords), mSurfaceNormal(handle.mSurfaceNormal)
{
}

RaycastResult::RaycastResult(int handle)
{
	int hitsomething = 0;
	int enthandle = 0;
	Vector3 hitCoords, surfaceNormal;

	this->mResult = SHAPETEST::GET_SHAPE_TEST_RESULT(handle, &hitsomething, &hitCoords, &surfaceNormal, &enthandle);

	this->mDidHit = hitsomething != 0;
	this->mHitCoords = hitCoords;
	this->mSurfaceNormal = surfaceNormal;

	if (ENTITY::DOES_ENTITY_EXIST(enthandle) && (ENTITY::IS_ENTITY_A_PED(enthandle) || ENTITY::IS_ENTITY_A_VEHICLE(enthandle) || ENTITY::IS_ENTITY_AN_OBJECT(enthandle)))
	{
		this->mHitEntity = enthandle;
	}
	else
	{
		this->mHitEntity = 0;

	}
}


int RaycastResult::Result()
{
	return this->mResult;
}
bool RaycastResult::DidHitEntity()
{
	return mHitEntity != 0;
}
bool RaycastResult::DidHitAnything()
{
	return this->mDidHit;
}
Entity RaycastResult::HitEntity()
{
	return this->mHitEntity;
}
Vector3 RaycastResult::HitCoords()
{
	return this->mHitCoords;
}
Vector3 RaycastResult::SurfaceNormal()
{
	return this->mSurfaceNormal;
}


RaycastResult RaycastResult::Raycast(const Vector3& source, const Vector3& target, IntersectOptions options, Entity ignoreEntity)
{
	return RaycastResult(SHAPETEST::_START_SHAPE_TEST_RAY(source.x, source.y, source.z, target.x, target.y, target.z, static_cast<int>(options), ignoreEntity, 7));
}
RaycastResult RaycastResult::Raycast(const Vector3& source, const Vector3& direction, float maxDistance, IntersectOptions options, Entity ignoreEntity)
{
	Vector3 target = source + (direction * maxDistance);
	return RaycastResult(SHAPETEST::_START_SHAPE_TEST_RAY(source.x, source.y, source.z, target.x, target.y, target.z, static_cast<int>(options), ignoreEntity, 7));
}

 

1 hour ago, LMS said:

 

It might require bitflags but 12 is 1100b so it would just mean flag 3 and flag 4 are set.

 

Thats true but multiflag caused alot headache in gta iv/v for me back in the days so i always avoid them, tested with his settings and they work fine for peds. Would be interesting to know if it crashes for him with any other flags.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.