private void Interact() { RPG.UIHandler.CloseAll(); Popup.CloseLastPopup(); var nearbyLoot = PlayerMethods.GetNearbyLoot(2.5f).FirstOrDefault(); if (nearbyLoot != null) { RPGMethods.Loot(nearbyLoot); } var nearestPed = RPGInfo.NearestPed; if (nearestPed != null && !Game.Player.Character.IsInCombat) { var npcObject = RPG.WorldData.Npcs.FirstOrDefault(n => n.IsQuestNpc && n.EntityHandle == nearestPed.Handle); if (npcObject != null) { if (npcObject.Name == "Matthew" && RPG.PlayerData.Tutorial.PressJToOpenMenu && RPG.PlayerData.Tutorial.BoughtAmmoFromShop && RPG.PlayerData.Tutorial.GetAKill && RPG.PlayerData.Tutorial.UnlockSkillWithSp && RPG.PlayerData.Tutorial.UsingSkills && RPG.PlayerData.Tutorial.SpawnVehicle) { var tut = RPG.GetPopup <TutorialBox>(); RPG.PlayerData.Tutorial.TutorialDoneExceptSpeak = true; RPG.PlayerData.Tutorial.SpokeToNpc = true; EventHandler.Do(o => { tut.Hide(); }); } RPG.UIHandler.StartDialog(npcObject); } } }
public void UpdateX() { if (Function.Call <bool>(Hash.IS_CUTSCENE_ACTIVE)) { return; } Ped player = Game.Player.Character; Vehicle vehicle = player.CurrentVehicle; //Loot Interact var nearbyLoot = RPGInfo.NearbyLoot; var showingLoot = false; if (nearbyLoot != null) { if (nearbyLoot.Item.Type == ItemType.Money || nearbyLoot.Item.Type == ItemType.QuestItem) { RPGMethods.Loot(nearbyLoot); } else if (RPGSettings.ShowUI) { var interactUI = new UIContainer(new Point(UI.WIDTH / 2 - 120, UI.HEIGHT - 100), new Size(240, 17), Color.FromArgb(70, 70, 200, 70)); var lootStr = RPG.UsingController ? "Hold (A) To Loot " : "Press E To Loot "; interactUI.Items.Add(new UIText(lootStr + nearbyLoot.Name, new Point(240 / 2, 1), 0.25f, Color.White, 0, true)); interactUI.Draw(); showingLoot = true; } } if (CurrentDialog != null && !IsOpen(DialogMenu)) { World.RenderingCamera = NpcCamera; OpenDialog(); } //Controller Support var up = Game.IsControlJustPressed(0, Control.ScriptPadUp); var down = Game.IsControlJustPressed(0, Control.ScriptPadDown); var left = Game.IsControlJustPressed(0, Control.ScriptPadLeft); var right = Game.IsControlJustPressed(0, Control.ScriptPadRight); var back = Game.IsControlJustPressed(0, Control.Reload); var interact = Game.IsControlJustPressed(0, Control.Sprint); var skillMod = Game.IsControlPressed(0, Control.Jump); var hotkeyMod = Game.IsControlPressed(0, Control.Reload); if (interact) { if (CurrentDialog != null) { DialogMenu.OnActivate(); } else { View.HandleActivate(); } } if (back) { View.HandleBack(); } if (!skillMod && !hotkeyMod) { if (left) { if (CurrentDialog != null) { DialogMenu.OnChangeItem(false); } else { View.HandleChangeItem(false); } } if (right) { if (CurrentDialog != null) { DialogMenu.OnChangeItem(true); } else { View.HandleChangeItem(true); } } if (up) { if (CurrentDialog != null) { DialogMenu.OnChangeSelection(false); } else { View.HandleChangeSelection(false); } } if (down) { if (CurrentDialog != null) { DialogMenu.OnChangeSelection(true); } else { View.HandleChangeSelection(true); } } } if (!RPGSettings.ShowUI || CurrentDialog != null) { return; } //NPC Interact if (!showingLoot && CurrentDialog == null && !Game.Player.Character.IsInCombat) { var nearestPed = RPGInfo.NearestPed; if (nearestPed != null) { var npcObject = RPG.WorldData.Npcs.FirstOrDefault(n => n.IsQuestNpc && n.EntityHandle == nearestPed.Handle); if (npcObject != null) { var interactUI = new UIContainer(new Point(UI.WIDTH / 2 - 120, UI.HEIGHT - 122), new Size(240, 17), Color.FromArgb(70, 190, 190, 190)); var interactStr = RPG.UsingController ? "Hold (A) to Interact with " : "Press E to Interact with "; interactUI.Items.Add(new UIText(interactStr + npcObject.Name, new Point(240 / 2, 1), 0.25f, Color.White, 0, true)); interactUI.Draw(); } } } //Player text //new UIText(PlayerData.Name.ToLower() + " level " + PlayerData.Level + " criminal", new Point(51, UI.HEIGHT - 55), 0.25f, Color.White, 0, false).Draw(); //Expbar var expBarUI = new UIContainer(new Point(0, UI.HEIGHT - 2), new Size(UI.WIDTH, 2), Color.FromArgb(180, 20, 20, 20)); var percentExp = (float)PlayerData.Exp / PlayerData.ExpToLevel; expBarUI.Items.Add(new UIRectangle(new Point(0, 0), new Size((int)(percentExp * UI.WIDTH), 2), Color.FromArgb(220, 255, 255, 0))); expBarUI.Draw(); #region "RPG Style UI" var borderColor = Color.FromArgb(255, 75, 75, 75); Point rectanglePoint; Point textPoint; switch (RPGSettings.SafeArea) { case 0: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 63 : 63), UI.HEIGHT - 47); textPoint = new Point((RPGInfo.IsWideScreen ? 63 : 63), UI.HEIGHT - 48); break; case 1: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 57 : 57), UI.HEIGHT - 43); textPoint = new Point((RPGInfo.IsWideScreen ? 57 : 57), UI.HEIGHT - 44); break; case 2: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 51 : 50), UI.HEIGHT - 40); // textPoint = new Point((RPGInfo.IsWideScreen ? 51 : 51), UI.HEIGHT - 41); // break; case 3: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 45 : 45), UI.HEIGHT - 36); textPoint = new Point((RPGInfo.IsWideScreen ? 45 : 45), UI.HEIGHT - 37); break; case 4: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 39 : 39), UI.HEIGHT - 33); textPoint = new Point((RPGInfo.IsWideScreen ? 39 : 39), UI.HEIGHT - 34); break; case 5: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 32 : 32), UI.HEIGHT - 29); textPoint = new Point((RPGInfo.IsWideScreen ? 32 : 32), UI.HEIGHT - 30); break; case 6: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 26 : 26), UI.HEIGHT - 26); textPoint = new Point((RPGInfo.IsWideScreen ? 26 : 26), UI.HEIGHT - 27); break; case 7: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 19 : 19), UI.HEIGHT - 22); textPoint = new Point((RPGInfo.IsWideScreen ? 19 : 19), UI.HEIGHT - 23); break; case 8: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 13 : 13), UI.HEIGHT - 18); textPoint = new Point((RPGInfo.IsWideScreen ? 13 : 13), UI.HEIGHT - 19); break; case 9: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 6 : 6), UI.HEIGHT - 15); textPoint = new Point((RPGInfo.IsWideScreen ? 6 : 6), UI.HEIGHT - 16); break; case 10: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 0 : 0), UI.HEIGHT - 10); textPoint = new Point((RPGInfo.IsWideScreen ? 0 : 0), (RPGInfo.IsWideScreen ? UI.HEIGHT - 11 : UI.HEIGHT - 12)); break; default: rectanglePoint = new Point((RPGInfo.IsWideScreen ? 0 : 0), UI.HEIGHT - 10); textPoint = new Point((RPGInfo.IsWideScreen ? 0 : 0), (RPGInfo.IsWideScreen ? UI.HEIGHT - 11 : UI.HEIGHT - 12)); break; } if (vehicle != null) { var speed = ((int)(vehicle.Speed * 2.45)).ToString("000"); new UIText(" MPH", new Point(RPGInfo.IsWideScreen ? textPoint.X + 156 : textPoint.X + 156, textPoint.Y), 0.22f, Color.White, 0, false).Draw(); //55 new UIText(speed, new Point(RPGInfo.IsWideScreen ? textPoint.X + 141 : textPoint.X + 141, textPoint.Y), 0.22f, Color.White, 0, false).Draw(); //55 } new UIRectangle(rectanglePoint, new Size(181, 10), borderColor).Draw(); //playerinfo new UIText(PlayerData.Name + " Level " + PlayerData.Level + " " + PlayerData.Class.ToString().Replace("_", " "), textPoint, 0.22f, Color.White, 0, false).Draw(); var offset = RPGSettings.ShowingSubtitle ? -85 : 0; new UIRectangle(new Point(UI.WIDTH / 2 - 173, UI.HEIGHT - 45 - 28 + offset), new Size(345, 10), Color.FromArgb(60, 0, 0, 0)).Draw(); new UIRectangle(new Point(UI.WIDTH / 2 - 173, UI.HEIGHT - 45 - 13 + offset), new Size(345, 10), Color.FromArgb(60, 0, 0, 0)).Draw(); var hpText = string.Format("HP: {0}/{1}", Game.Player.Character.Health, Game.Player.Character.MaxHealth); var armorText = string.Format("Armor: {0}/{1}", Game.Player.Character.Armor, 100); var hp = ((float)Game.Player.Character.Health / Game.Player.Character.MaxHealth); var ap = ((float)Game.Player.Character.Armor / 100); var hpColor = Color.FromArgb(120, 33, 149, 34); if (hp < 0.2f) { hpColor = Color.FromArgb(120, 139, 0, 0); } else if (hp < 0.4f) { hpColor = Color.FromArgb(120, 255, 69, 0); } new UIRectangle(new Point(UI.WIDTH / 2 - 173, UI.HEIGHT - 45 - 28 + offset), new Size((int)(hp * 345), 10), hpColor).Draw(); new UIRectangle(new Point(UI.WIDTH / 2 - 173, UI.HEIGHT - 45 - 13 + offset), new Size((int)(ap * 345), 10), Color.FromArgb(180, 30, 144, 255)).Draw(); new UIText(hpText, new Point(UI.WIDTH / 2, UI.HEIGHT - 45 - 28 - 2 + offset), 0.22f, Color.White, 0, true).Draw(); new UIText(armorText, new Point(UI.WIDTH / 2, UI.HEIGHT - 45 - 13 - 2 + offset), 0.22f, Color.White, 0, true).Draw(); #endregion //Character window #2 if (View.ActiveMenus > 0) { var charPanel = new UIContainer(new Point(UI.WIDTH - 300, View.MenuPosition.Y - 215), new Size(300, 200), Color.Gray); //todo: what should we draw here? //charPanel.Draw(); } //Quest Tracker if (RPGSettings.ShowQuestTracker) { GetQuestTracker().Draw(); } //Skill bar if (RPGSettings.ShowSkillBar) { var skillOffset = RPGSettings.ShowingSubtitle ? -80 : 0; var skillBarUI = RPG.SkillHandler.GetSkillBar(skillOffset); skillBarUI.Draw(); } }