Saltyq / ScriptHookRDR2DotNet

*this project is ABANDONED* An ASI plugin for Red Dead Redemption 2, which allows anyone to create scripts using any .NET language.
zlib License
92 stars 40 forks source link

Controlling toggle of first / third-person cameras? #6

Closed XaeroDegreaz closed 4 years ago

XaeroDegreaz commented 5 years ago

Is there a routine in this library that can toggle the first-person camera?

Not only just setting up a custom camera and setting it to render, but activating the full transition between first/third-person (including the character control changes for first person).

I've tried to use Function.Call( Hash._RENDER_FIRST_PERSON_CAM, true/false, 0, 3 ); according to https://www.dev-c.com/nativedb/ns/CAM

I've also tried a few other variations. I can tell that something is definitely clicking, because when I set it to true, and I'm in third-person mode, I can see the camera snap to an odd rotation, but I'll still be in first-person.

Saltyq commented 5 years ago

Are you sure you're calling it right? Or it possibly isnt the only native you have to call?

According to Unknowns nativedb, _RENDER_FIRST_PERSON_CAM takes 6 args _RENDER_FIRST_PERSON_CAM(Any p0, Any p1, Any p2, Any p3, Any p4, Any p5)

XaeroDegreaz commented 5 years ago

Yeah I've tried lots of different combinations, including (0, 0, 3, 0, 0, 1).

The game calls it like

__int64 __fastcall NATIVE_RENDER_FIRST_PERSON_CAM(scrNativeContext *cxt)
{
  scrArgStruct *v1; // r10

  v1 = cxt->stackPtr;
  return sub_7FF734F9D058(
           LODWORD(v1->arg1) != 0,
           *(float *)&v1->arg2,
           v1->arg3,
           v1->arg4,
           LODWORD(v1->arg5) != 0,
           LODWORD(v1->arg6) != 0);
}

I'm not sure what exactly going on, but I know something is triggering because of the camera rotation snap. No matter what parameters I pass through I get that same snap effect. I've used the F8 console and tried a whole bunch of different things, but I must just be missing something.

Perhaps there is some other native that needs to be called, but I'm not seeing anything obvious in regards to the camera swap.

XaeroDegreaz commented 4 years ago

Calling this hash once per frame is working for me:

//# _FORCE_FIRST_PERSON_CAM_THIS_FRAME: https://www.mod-rdr.com/nativedb/index/cam/_0x90da5ba5c2635416/
Function.Call( Hash._0x90DA5BA5C2635416 );

I guess we can close this issue.