private void SetCam(Vector3 pos, bool lookAtPlayer = false) { if(Camera != null) Camera.Destroy(); Camera = World.CreateCamera(pos, Vector3.Zero, GameplayCamera.FieldOfView); if(lookAtPlayer) { Camera.PointAt(Game.Player.Character); } World.RenderingCamera = Camera; }
public void OnTick(object sender, EventArgs e) { var veh = FindNearbyPoliceVehicle(VehicleType.Car); if (veh?.Handle != 0 && !notifyVehicle && World.RenderingCamera.Handle != mainCamera?.Handle) { UI.Notify("Vehicle Cam Available."); notifyVehicle = true; } else if (veh == null || veh.Handle == 0) notifyVehicle = false; veh = FindNearbyPoliceVehicle(VehicleType.Helicopter); if (veh?.Handle != 0 && !notifyHeli && World.RenderingCamera.Handle != mainCamera?.Handle) { UI.Notify("Helicopter Cam Available."); notifyHeli = true; } else if (veh == null || veh.Handle == 0) notifyHeli = false; if (Game.Player.Character.IsOnFoot && Function.Call<int>(Hash.GET_FOLLOW_PED_CAM_VIEW_MODE) == 2 || Game.Player.Character.IsInVehicle() && Function.Call<int>(Hash.GET_FOLLOW_VEHICLE_CAM_VIEW_MODE) == 2) { Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, 0, true); if (Function.Call<bool>(Hash.IS_DISABLED_CONTROL_JUST_PRESSED, 0, 0)) { var player = Game.Player.Character; switch (mViewModeCounter) { case 0: var policeVeh = FindNearbyPoliceVehicle(VehicleType.Car); if (policeVeh != null && policeVeh.Handle != 0) { var boneIndex = Function.Call<int>(Hash._GET_ENTITY_BONE_INDEX, policeVeh.Handle, "windscreen"); var bonePos = Function.Call<Vector3>(Hash._GET_ENTITY_BONE_COORDS, policeVeh.Handle, boneIndex); var camPos = Function.Call<Vector3>(Hash.GET_OFFSET_FROM_ENTITY_GIVEN_WORLD_COORDS, policeVeh.Handle, bonePos.X, bonePos.Y, bonePos.Z); mainCamera = World.CreateCamera(camPos, policeVeh.Rotation, 40f); mainCamera.AttachTo(policeVeh, new Vector3(camPos.X, camPos.Y - 0.3f, camPos.Z - 0.02f)); mainCamera.PointAt(player); World.RenderingCamera = mainCamera; mViewModeCounter++; } else { mViewModeCounter++; goto case1; } break; case 1: case1: var policeHeli = FindNearbyPoliceVehicle(VehicleType.Helicopter); if (policeHeli != null && policeHeli.Handle != 0) { mainCamera = World.CreateCamera(policeHeli.Position, policeHeli.Rotation, 50f); mainCamera.AttachTo(policeHeli, new Vector3(0, 0, -1.4f)); mainCamera.PointAt(player); World.RenderingCamera = mainCamera; mViewModeCounter++; } else { ExitCustomCameraView(); mViewModeCounter = 0; } break; default: ExitCustomCameraView(); mViewModeCounter = 0; break; } } } }
public void ToggleBombBayView() { if (bombCam == null) { ControlMonitor.DisableControl(Control.VehicleFlyAttack); ControlMonitor.DisableControl(Control.VehicleFlyAttack2); int boneIndex = Function.Call<int>(Hash._GET_ENTITY_BONE_INDEX, vehicle.Handle, "chassis_dummy"); var boneCoord = Function.Call<Vector3>(Hash._GET_ENTITY_BONE_COORDS, vehicle.Handle, boneIndex); bombCam = new Camera(Function.Call<int>(Hash.CREATE_CAMERA_WITH_PARAMS, 0x19286a9, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 65.0f, 0, 2)); bombCam.AttachTo(vehicle, new Vector3(0f, 1.3324f, -0.9f)); bombCam.PointAt(vehicle, vehicle.GetOffsetFromWorldCoords(boneCoord - new Vector3(0, 0, 1.3f))); bombCam.Shake(CameraShake.RoadVibration, 0.4f); bombCam.FieldOfView = 65.0f; bombCam.IsActive = true; Function.Call(Hash.RENDER_SCRIPT_CAMS, 1, 0, 3000, 1, 0, 0); Function.Call(Hash.DISPLAY_RADAR, 0); Function.Call(Hash.DISPLAY_HUD, 0); SetAutopilot(true); } else { World.RenderingCamera = null; bombCam.IsActive = false; bombCam.Destroy(); bombCam = null; Function.Call(Hash.DISPLAY_RADAR, 1); Function.Call(Hash.DISPLAY_HUD, 1); ControlMonitor.EnableControl(Control.VehicleFlyAttack); ControlMonitor.EnableControl(Control.VehicleFlyAttack2); SetAutopilot(false); } }
public static void DrawSettings(Race settingsForRace, Vehicle previewVehicle) { if(!IsInMenu) return; // CAMERA if (MainCamera == null || MainCamera.Position != settingsForRace.Trigger + new Vector3(3f, 3f, 3f)) { World.DestroyAllCameras(); MainCamera = World.CreateCamera(settingsForRace.Trigger + new Vector3(3f, 3f, 3f), new Vector3(), 60f); MainCamera.PointAt(settingsForRace.Trigger); } World.RenderingCamera = MainCamera; // UI DRAWING var safe = UIMenu.GetSafezoneBounds(); var res = UIMenu.GetScreenResolutionMantainRatio(); new UIResText(settingsForRace.Name, new Point(safe.X, safe.Y), 0.8f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) { Outline = true}.Draw(); new UIResText(settingsForRace.Description, new Point(safe.X, 50 + safe.Y), 0.4f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) {WordWrap = new Size(Convert.ToInt32(res.Width) - (safe.X*2),0), Outline = true}.Draw(); new UIResRectangle(new Point(safe.X + 435, safe.Y + 107), new Size(1200, 37), Color.Black).Draw(); new UIResText("VEHICLE", new Point(safe.X + 1000, safe.Y + 110), 0.35f, Color.White, Font.ChaletLondon, UIResText.Alignment.Centered).Draw(); string vehClass = ""; switch (Function.Call<int>(Hash.GET_VEHICLE_CLASS, previewVehicle.Handle)) { case 0: vehClass = "Compacts"; break; case 1: vehClass = "Sedans"; break; case 2: vehClass = "SUVs"; break; case 3: vehClass = "Coupes"; break; case 4: vehClass = "Muscle"; break; case 5: vehClass = "Sports Classics"; break; case 6: vehClass = "Sports"; break; case 7: vehClass = "Super"; break; case 8: vehClass = "Motorcycle"; break; case 9: vehClass = "Offroad"; break; case 10: vehClass = "Industrial"; break; case 11: vehClass = "Utility"; break; case 12: vehClass = "Vans"; break; case 13: vehClass = "Bicycle"; break; case 14: vehClass = "Boats"; break; case 15: vehClass = "Helicopter"; break; case 16: vehClass = "Airplane"; break; case 17: vehClass = "Service"; break; case 18: vehClass = "Emergency"; break; case 19: vehClass = "Military"; break; case 20: vehClass = "Commercial"; break; } new UIResText(vehClass, new Point(Convert.ToInt32(res.Width) - 430 - safe.X, 800 - safe.Y), 1.5f, Color.White, Font.ChaletComprimeCologne, UIResText.Alignment.Left) {DropShadow = true}.Draw(); new UIResText(previewVehicle.FriendlyName, new Point(Convert.ToInt32(res.Width) - 400 - safe.X, 840 - safe.Y), 1.5f, Color.DodgerBlue, Font.HouseScript, UIResText.Alignment.Left) {DropShadow = true}.Draw(); // MENU CORRECTIONS MainMenu.Subtitle.Position = new Point(safe.X + 200, MainMenu.Subtitle.Position.Y); MainMenu.Subtitle.TextAlignment = UIResText.Alignment.Centered; }