Hey! I'm a Game and Engine developer I like your mod and I improve things in your code.
first, I've made your movement smooth we can easily and smoothly turn around now with this code: Atan2(moveDirection.X, moveDirection.Y) * 57.2958f Vector2.Lerp(moveDirection, currentDirection, 0.1f);
I'd like to try your code changes in my game. I can't use the mod as is. what lines of code does your code replace? (can I paste the code over his code at some location?) thanks for your code.
Rockstar just implemented an update, and so far it looks like it was aimed squarely at modding. None of the mods I was using work anymore and I double checked that they were installed correctly. I suspect none will work again until script hooks like the one needed for this one are updated.
Any chance of an update? Specifically, would loooooove to se a fix for the problem with being unable to fly down after failing a mission and choosing to restart it, continue from a checkpoint, or cancel the mission. I always have to reload the entire mission. Thanks! This is by far my favorite mod!
14 comments
first, I've made your movement smooth we can easily and smoothly turn around now with this code:
Atan2(moveDirection.X, moveDirection.Y) * 57.2958f
Vector2.Lerp(moveDirection, currentDirection, 0.1f);
that way I could remove lots of branches (if blocks, and checks)
this code will perform well and feel smoother
Vector2 moveDirection;
private void OnTick(object sender, EventArgs e)
{
Ped playerPed = Game.Player.Character;
if (FLYON)
{
if (player.Character.IsInVehicle())
{
Function.Call(Hash.SET_PED_GRAVITY, playerPed, true);
Function.Call(Hash.SET_PED_CAN_RAGDOLL, playerPed, true);
Function.Call(Hash.SET_PLAYER_CAN_USE_COVER, player, true);
FLYON = false;
if (FlyMount != null)
{
Function.Call(Hash.SET_PED_GRAVITY, FlyMount, true);
FlyMount = null;
}
RDR2.UI.Screen.ShowSubtitle("Cannot fly in vehicle. Fly Mode Off");
}
else
{
if (Game.IsKeyPressed(IncreaseSpeedKey))
{
FlySpeed = System.Math.Min(FlySpeed + 0.5f, MaxSpeed);
}
if (Game.IsKeyPressed(DecreaseSpeedKey))
{
FlySpeed = System.Math.Min(FlySpeed - 0.5f, MaxSpeed);
}
Function.Call(Hash.DRAW_RECT, 0.05, 0.35, 0.00375, 0.15, 200, 240, 255, 255);
Function.Call(Hash.DRAW_RECT, 0.05, 0.35, 0.0025, ((0.15 / MaxSpeed) * FlySpeed), 0, 40, 55, 255);
if (FlyMount != null)
{
if (!Function.Call<bool>(Hash.IS_PED_ON_MOUNT, playerPed))
{
Function.Call(Hash.SET_PED_GRAVITY, FlyMount, true);
Function.Call(Hash.SET_PED_CAN_RAGDOLL, FlyMount, true);
FlyMount = null;
RDR2.UI.Screen.ShowSubtitle("Fly without mount.");
}
else
{
if (Game.IsKeyPressed(Keys.W))
{
Function.Call(Hash.APPLY_FORCE_TO_ENTITY, FlyMount, 1, (0), (FlySpeed), (0), 0, 0, 0, 0, true, true, true, true, true);
Function.Call(Hash.SET_ENTITY_ROTATION, FlyMount, 0, 0, (NC_Get_Cam_Rotation()).Z, 2, true);
Function.Call(Hash.SET_ENTITY_VELOCITY, FlyMount, 0, 0, 0);
}
if (Game.IsKeyPressed(Keys.Space))
{
Function.Call(Hash.APPLY_FORCE_TO_ENTITY, FlyMount, 1, (0), (0), (FlySpeed), 0, 0, 0, 0, true, true, true, true, true);
Function.Call(Hash.SET_ENTITY_VELOCITY, FlyMount, 0, 0, 0);
}
}
}
else
{
if (Function.Call<bool>(Hash.IS_PED_ON_MOUNT, playerPed))
{
FlyMount = Function.Call<Ped>(Hash.GET_MOUNT, playerPed);
Function.Call(Hash.SET_PED_GRAVITY, FlyMount, false);
Function.Call(Hash.SET_PED_CAN_RAGDOLL, FlyMount, false);
RDR2.UI.Screen.ShowSubtitle("Fly with mount.");
}
else
{
?????// THIS IS WHERE I EDITED MOST
bool WPressed = Game.IsKeyPressed(Keys.W),
SPressed = Game.IsKeyPressed(Keys.S),
APressed = Game.IsKeyPressed(Keys.A),
DPressed = Game.IsKeyPressed(Keys.D);
if (WPressed | SPressed | APressed | DPressed)
{
Function.Call(Hash.APPLY_FORCE_TO_ENTITY, playerPed, 1, (0), (FlySpeed), (0), 0, 0, 0, 0, true, true, true, true, true);
Function.Call(Hash.SET_ENTITY_VELOCITY, playerPed, 0, 0, 0);
Vector2 currentDirection = new Vector2();
if (WPressed) currentDirection.Y += 1.0f;
if (SPressed) currentDirection.Y -= 1.0f;
if (APressed) currentDirection.X += 1.0f;
if (DPressed) currentDirection.X -= 1.0f;
moveDirection = Vector2.Lerp(moveDirection, currentDirection, 0.1f);
float angle = (float)System.Math.Atan2(moveDirection.X, moveDirection.Y) * 57.2958f;
Function.Call(Hash.SET_ENTITY_ROTATION, playerPed, 0, 0, NC_Get_Cam_Rotation().Z + angle, 2, true);
}
else
{
moveDirection = Vector2.Lerp(moveDirection, new Vector2(0.0f, 0.0f), 0.1f);
}
if (Game.IsKeyPressed(Keys.Space))
{
Function.Call(Hash.APPLY_FORCE_TO_ENTITY, playerPed, 1, (0), (0), (FlySpeed), 0, 0, 0, 0, true, true, true, true, true);
}
Function.Call(Hash.SET_PED_GRAVITY, playerPed, false);
if (Function.Call<bool>(Hash.IS_PED_RAGDOLL, playerPed))
{
Vector3 currentPosition = playerPed.Position;
Function.Call(Hash.SET_ENTITY_COORDS, playerPed, currentPosition.X, currentPosition.Y, (currentPosition.Z - 1), true, false, false, false);
}
if (Function.Call<bool>(Hash.IS_PED_JUMPING, playerPed))
{
Vector3 currentPosition = playerPed.Position;
Function.Call(Hash.SET_ENTITY_COORDS, playerPed, currentPosition.X, currentPosition.Y, (currentPosition.Z - 1), true, false, false, false);
}
}
}
}
}
}
Is there a fast running mod?
I have a question. Is it possible to remove the blue box/place it somewhere else? It's kinda hard to make screenshots and videos this way!