示例#1
0
        private void BuyShopItem(RPGListMenu obj)
        {
            var purchasableItems = ItemRepository.Items.Where(i => i.CanBuy).ToList();

            if (obj.SelectedIndex >= purchasableItems.Count)
            {
                View.PopMenu();
                return;
            }

            var itemToBuy = purchasableItems[obj.SelectedIndex];

            if (PlayerData.Money >= itemToBuy.Cost)
            {
                PlayerData.Money -= itemToBuy.Cost;
                var item = ItemRepository.Get(itemToBuy.Name);
                PlayerData.AddItem(item);
                RPG.Notify(Notification.Alert("Purchased: " + itemToBuy.Name));
                UpdateShop(obj.SelectedIndex);
            }
            else
            {
                RPG.Notify(Notification.Alert("Not enough money."));
            }
        }
示例#2
0
        private static void GetHigh(Skill skill)
        {
            var rng = Random.Range(0, 100);

            SkillEventHandler.Do(x =>
            {
                Function.Call(Hash.SET_TIME_SCALE, rng < 80 ? 0.4f : 0.2f);
                Function.Call(Hash.SET_TIMECYCLE_MODIFIER, rng < 80 ? "phone_cam6" : "phone_cam7");
                var slowTime = skill.GetIntParam("Slow Time");
                if (rng > 80)
                {
                    RPG.Notify(Notification.Danger("Unlucky, what a hit! HP Lost"));
                    if (Game.Player.Character.Health > 10)
                    {
                        Game.Player.Character.Health -= 10;
                    }
                    else
                    {
                        Game.Player.Character.Health = 5;
                    }
                }
                SkillEventHandler.Wait(slowTime);
                Function.Call(Hash.SET_TIME_SCALE, 1f);
                Function.Call(Hash.SET_TIMECYCLE_MODIFIER, "");
            });
        }
示例#3
0
        public static void UseSkill(Skill skill)
        {
            if (!skill.Unlocked)
            {
                RPG.Notify(Notification.Alert("You have not unlocked this skill."));
                return;
            }

            skill.Use(skill);

            //Cooldowns, mana use etc
        }
示例#4
0
        private void CraftItem(RPGListMenu obj)
        {
            var craftableItems = ItemRepository.Items.Where(i => i.CanCraft).ToList();

            if (obj.SelectedIndex >= craftableItems.Count)
            {
                View.PopMenu();
                return;
            }

            var itemToCraft = craftableItems[obj.SelectedIndex];

            //have items?
            var hasItems = true;

            foreach (var kvp in itemToCraft.CraftItems)
            {
                var inventoryItem = RPG.PlayerData.Inventory.FirstOrDefault(i => i.Name == kvp.Key);
                if (inventoryItem != null)
                {
                    if (inventoryItem.Quantity < kvp.Value)
                    {
                        hasItems = false;
                    }
                }
                else
                {
                    hasItems = false;
                }
            }

            if (hasItems)
            {
                foreach (var kvp in itemToCraft.CraftItems)
                {
                    var inventoryItem = RPG.PlayerData.Inventory.First(i => i.Name == kvp.Key);
                    inventoryItem.Quantity -= kvp.Value;
                    if (inventoryItem.Quantity <= 0)
                    {
                        PlayerData.Inventory.Remove(inventoryItem);
                    }
                }

                var item = ItemRepository.Get(itemToCraft.Name);
                PlayerData.AddItem(item);
                RPG.Notify(Notification.Alert("Crafted: " + itemToCraft.Name));
                UpdateCrafting(obj.SelectedIndex);
            }
            else
            {
                RPG.Notify(Notification.Alert("You do not have the items."));
            }
        }
示例#5
0
        private void UseInventoryItem(RPGListMenu obj)
        {
            var selected = obj.SelectedIndex;

            if (selected >= PlayerData.Inventory.Count)
            {
                View.PopMenu();
                return;
            }

            if (!PlayerData.Inventory.Any())
            {
                return;
            }


            var selectedItem = PlayerData.Inventory[selected];

            var used = RPGMethods.UseItem(selectedItem);

            if (selectedItem.Quantity <= 0)
            {
                selected--;
                if (selected < 0)
                {
                    selected = 0;
                }
            }

            UpdateInventory(selected);
            InventoryMenu.SelectedIndex = selected;
            if (used)
            {
                RPG.Notify(Notification.Alert("Used : " + selectedItem.Name));
            }
        }
示例#6
0
        public static void Loot(LootItem loot)
        {
            if (loot != null)
            {
                if (loot.Item.Type == ItemType.Money)
                {
                    var notification = Notification.Loot("Looted GTA$" + loot.Item.MoneyValue.ToString("N0"));
                    notification.Tracking = loot.Item.MoneyValue;
                    RPG.Notify(notification);
                    PlayerData.AddMoney(loot.Item.MoneyValue);
                    loot.Destroy();
                    Game.PlaySound("FocusOut", "HintCamSounds");
                }
                else
                {
                    RPG.Notify(Notification.Loot("Looted: " + loot.Name + " x" + loot.Item.Quantity));
                    PlayerData.AddItem(loot.Item);
                    loot.Destroy();
                    Game.PlaySound("FocusOut", "HintCamSounds");
                }
            }

            RPGInfo.NearbyLoot = null;
        }
示例#7
0
        private string TextToShow(object o)
        {
            if (o is int)
            {
                var c = (int)o;
                switch (c)
                {
                case 0:
                case 1:
                    return("");

                case 2:
                    RPG.Notify(Notification.Kill("double kill + 2"));
                    RPG.PlayerData.AddExp(2);
                    RPG.Audio.PlayKillStreak("doublekill");
                    return("double kill");

                case 3:
                    RPG.Notify(Notification.Kill("multi kill + 4"));
                    RPG.PlayerData.AddExp(4);
                    RPG.Audio.PlayKillStreak("multikill");
                    return("multi kill");

                case 4:
                    RPG.Notify(Notification.Kill("mega kill + 8"));
                    RPG.PlayerData.AddExp(8);
                    RPG.Audio.PlayKillStreak("megakill");
                    return("mega kill");

                case 5:
                    RPG.Notify(Notification.Kill("ultra kill + 12"));
                    RPG.PlayerData.AddExp(12);
                    RPG.Audio.PlayKillStreak("ultrakill");
                    return("ultra kill");

                case 6:
                    RPG.Notify(Notification.Kill("monster kill + 24"));
                    RPG.PlayerData.AddExp(24);
                    RPG.Audio.PlayKillStreak("monsterkill");
                    return("m m m monster kill");

                case 7:
                    RPG.Notify(Notification.Kill("ludicrous kill + 48"));
                    RPG.PlayerData.AddExp(48);
                    RPG.Audio.PlayKillStreak("ludicrouskill");
                    return("ludicrous kill");

                case 8:
                    RPG.Notify(Notification.Kill("rampage kill + 60"));
                    RPG.PlayerData.AddExp(60);
                    RPG.Audio.PlayKillStreak("rampage");
                    return("rampage kill");

                case 9:
                    RPG.Notify(Notification.Kill("wicked sick + 80"));
                    RPG.PlayerData.AddExp(80);
                    RPG.Audio.PlayKillStreak("wickedsick");
                    return("wicked sick");

                case 10:
                    RPG.Notify(Notification.Kill("unstoppable + 100"));
                    RPG.PlayerData.AddExp(100);
                    RPG.Audio.PlayKillStreak("unstoppable");
                    return("unstoppable");
                }

                if (c > 10)
                {
                    RPG.Notify(Notification.Kill("holy shit + 100"));
                    RPG.PlayerData.AddExp(100);
                    RPG.Audio.PlayKillStreak("holyshit");
                    return("h o l y  s h i t");
                }
            }

            return((string)o);
        }
示例#8
0
文件: RPG.cs 项目: tuita520/GTARPG
 public static void Notify(string notification)
 {
     Notifier.Notify(Notification.Alert(notification));
 }
示例#9
0
文件: RPG.cs 项目: tuita520/GTARPG
 public static void Notify(Notification notification)
 {
     Notifier.Notify(notification);
 }
示例#10
0
 public static Notification Danger(string message)
 {
     var n = new Notification(NotifyType.Danger, message);
     return n;
 }
示例#11
0
        private void AddNotification(Notification notification)
        {
            var updated = false;
            if(_notifications.Any())
            {
                if(notification.Type == NotifyType.Kill)
                {
                    if(notification.Text.Contains("target"))
                    {
                        var toUpdate = _notifications.FirstOrDefault(n => n.Type == NotifyType.Kill && n.Text.Contains("target"));
                        if (toUpdate != null)
                        {
                            toUpdate.Tracking++;

                            _notifications.Remove(toUpdate);
                            _notifications.Add(toUpdate);
                            if(toUpdate.Tracking > 1)
                            {
                                RPG.GetPopup<KillStreaks>().Pop(toUpdate.Tracking);
                            }
                            toUpdate.Text = "targets eliminated: +" + (toUpdate.Tracking * 5) + " Exp";
                            updated = true;
                        }
                    }
                }
                if(notification.Type == NotifyType.Loot)
                {
                    if(notification.Text.Contains("gta$"))
                    {
                        var toUpdate = _notifications.FirstOrDefault(n => n.Type == NotifyType.Loot && n.Text.Contains("gta$"));
                        if (toUpdate != null)
                        {
                            toUpdate.Tracking += notification.Tracking;

                            _notifications.Remove(toUpdate);
                            _notifications.Add(toUpdate);
                            toUpdate.Text = "looted gta$" + toUpdate.Tracking.ToString("N0");
                            updated = true;
                        }
                    }
                }

                if(notification.Type == NotifyType.Alert)
                {
                    if(notification.Text.Contains("cannot use"))
                    {
                        var toRemove = _notifications.FirstOrDefault(n => n.Type == NotifyType.Alert && n.Text.Contains("cannot use"));
                        if (toRemove != null)
                        {
                            _notifications.Remove(toRemove);
                        }
                    }
                }
            }

            if(!updated)
            {
                if(_notifications.Count >= 5)
                {
                    _notifications.RemoveAt(0);
                }
                _notifications.Add(notification);
            }
        }
示例#12
0
 public static Notification Loot(string message)
 {
     var n = new Notification(NotifyType.Loot, message);
     return n;
 }
示例#13
0
 public static Notification Kill(string message)
 {
     var n = new Notification(NotifyType.Kill, message) {Tracking = 1};
     return n;
 }
示例#14
0
        private void AddNotification(Notification notification)
        {
            var updated = false;

            if (_notifications.Any())
            {
                if (notification.Type == NotifyType.Kill)
                {
                    if (notification.Text.Contains("target"))
                    {
                        var toUpdate = _notifications.FirstOrDefault(n => n.Type == NotifyType.Kill && n.Text.Contains("target"));
                        if (toUpdate != null)
                        {
                            toUpdate.Tracking++;

                            _notifications.Remove(toUpdate);
                            _notifications.Add(toUpdate);
                            if (toUpdate.Tracking > 1)
                            {
                                RPG.GetPopup <KillStreaks>().Pop(toUpdate.Tracking);
                            }
                            toUpdate.Text = "targets eliminated: +" + (toUpdate.Tracking * 5) + " Exp";
                            updated       = true;
                        }
                    }
                }
                if (notification.Type == NotifyType.Loot)
                {
                    if (notification.Text.Contains("gta$"))
                    {
                        var toUpdate = _notifications.FirstOrDefault(n => n.Type == NotifyType.Loot && n.Text.Contains("gta$"));
                        if (toUpdate != null)
                        {
                            toUpdate.Tracking += notification.Tracking;

                            _notifications.Remove(toUpdate);
                            _notifications.Add(toUpdate);
                            toUpdate.Text = "looted gta$" + toUpdate.Tracking.ToString("N0");
                            updated       = true;
                        }
                    }
                }

                if (notification.Type == NotifyType.Alert)
                {
                    if (notification.Text.Contains("cannot use"))
                    {
                        var toRemove = _notifications.FirstOrDefault(n => n.Type == NotifyType.Alert && n.Text.Contains("cannot use"));
                        if (toRemove != null)
                        {
                            _notifications.Remove(toRemove);
                        }
                    }
                }
            }

            if (!updated)
            {
                if (_notifications.Count >= 5)
                {
                    _notifications.RemoveAt(0);
                }
                _notifications.Add(notification);
            }
        }
示例#15
0
 public void Notify(Notification notification)
 {
     Show(notification);
 }
示例#16
0
        public override void Update()
        {
            WorldData = RPG.WorldData;

            Ped player = Game.Player.Character;


            if (RPG.ExplosiveHits)
            {
                Function.Call(Hash.SET_EXPLOSIVE_AMMO_THIS_FRAME, Game.Player.Handle);
                Function.Call(Hash.SET_EXPLOSIVE_MELEE_THIS_FRAME, Game.Player.Handle);
            }

            if (RPG.SuperJump)
            {
                Function.Call(Hash.SET_SUPER_JUMP_THIS_FRAME, Game.Player.Handle);
            }

            if (!InitiateNpcs)
            {
                NpcDatas.AddRange(NpcRepository.Npcs);

                foreach (var npc in NpcDatas)
                {
                    npc.Spawned = false;

                    var blip = World.CreateBlip(npc.Position);
                    blip.Sprite = npc.BlipSprite;
                    WorldData.Blips.Add(new BlipObject("Blip_" + npc.Name, blip));
                }
                InitiateNpcs = true;
            }

            if (!PlayerData.Tutorial.BoughtAmmoFromShop && PlayerData.Tutorial.PressJToOpenMenu)
            {
                var tut  = RPG.GetPopup <TutorialBox>();
                var ammo = PlayerData.Inventory.FirstOrDefault(i => i.Name.Contains("Ammo"));
                if (ammo != null)
                {
                    PlayerData.Tutorial.BoughtAmmoFromShop = true;
                    EventHandler.Do(o =>
                    {
                        tut.Hide();
                        Wait(300);
                        if (!RPG.PlayerData.Tutorial.GetAKill)
                        {
                            tut.Pop("Getting kills, completing missions are just two ways to earn XP and Skill Points", "Get a kill.");
                        }
                    });
                }
            }
            if (!PlayerData.Tutorial.LearntAboutCrafting && PlayerData.Tutorial.LearntAboutIcons)
            {
                var tut       = RPG.GetPopup <TutorialBox>();
                var repairKit = PlayerData.Inventory.FirstOrDefault(i => i.Name.Contains("Vehicle Repair Kit"));
                if (repairKit != null)
                {
                    PlayerData.Tutorial.LearntAboutCrafting = true;
                    EventHandler.Do(o =>
                    {
                        PlayerData.AddItem("Health Kit", 5);
                        tut.Hide();
                        Wait(300);
                        tut.Pop("You can use items directly from the inventory or bind them to your skillbar.", "Access the menu > Character Menu > Set SkillBar and bind 'Health Kit' to T");
                    });
                }
            }
            if (!PlayerData.Tutorial.LearntAboutSkillbar && PlayerData.Tutorial.LearntAboutCrafting)
            {
                var tut          = RPG.GetPopup <TutorialBox>();
                var healthKitInT = !PlayerData.SkillSlots[0].IsEmpty && PlayerData.SkillSlots[0].IsItem && PlayerData.SkillSlots[0].ItemName == "Health Kit";
                if (healthKitInT)
                {
                    PlayerData.Tutorial.LearntAboutSkillbar = true;
                    EventHandler.Do(o =>
                    {
                        tut.Hide();
                    });
                }
            }

            CheckNpcs();

            foreach (var l in RPG.WorldData.Loot)
            {
                if (l.Prop != null && l.Prop.Exists() && l.Item != null)
                {
                    if (RPGSettings.ShowUI)
                    {
                        var dist = l.Prop.Position.DistanceTo(Game.Player.Character.Position);
                        if (dist < 60)
                        {
                            OutputArgument xArg       = new OutputArgument();
                            OutputArgument yArg       = new OutputArgument();
                            var            pos        = l.Prop.Position;
                            var            dimensions = l.Prop.Model.GetDimensions();
                            pos.Y -= dimensions.Y / 2;
                            pos.Z += 0.4f;
                            Function.Call(Hash._WORLD3D_TO_SCREEN2D, pos.X, pos.Y, pos.Z, xArg, yArg);
                            var x = xArg.GetResult <float>();
                            var y = yArg.GetResult <float>();

                            var itemName = l.Item.Type == ItemType.Money
                                ? "gta$" + l.Item.MoneyValue
                                : l.Item.Quantity + "x " + l.Item.Name;

                            new UIRectangle(new Point((int)(UI.WIDTH * x) - 50, (int)(UI.HEIGHT * y) + 12), new Size(100, 2), l.Item.GetRarityColor()).Draw();
                            new UIText(itemName, new Point((int)(UI.WIDTH * x), (int)(UI.HEIGHT * y)), 0.21f, Color.White, 0, true).Draw();
                        }
                    }

                    l.Prop.ApplyForce(new Vector3(0, 0, -0.1f));
                }
            }

            var nearbyForVecs = RPGInfo.NearbyVehicles;

            foreach (var vec in nearbyForVecs.Where(v => v.EngineHealth <= 0))
            {
                if (RPG.PlayerData.CurrentVehicle != null && vec.Handle == RPG.PlayerData.CurrentVehicle.Handle)
                {
                    continue;
                }

                if (!KilledVecs.Contains(vec.Handle))
                {
                    KilledVecs.Add(vec.Handle);


                    var rng = Random.Range(0, 100 + 1);
                    if (rng < 70)
                    {
                        var m = new Model(GM.GetHashKey("prop_box_guncase_03a"));
                        m.Request(1000);
                        var p = World.CreateProp(m, vec.Position + new Vector3(0, 0, 1.0f) + Vector3.RandomXY(), vec.Rotation, true, false);
                        p.ApplyForce(new Vector3(0, 0, -0.05f));
                        RPG.WorldData.AddLoot(new LootItem(ItemRepository.Get("Vehicle Parts"), p));
                    }
                    else if (rng < 80)
                    {
                        var m = new Model(GM.GetHashKey("prop_box_guncase_03a"));
                        m.Request(1000);
                        var p = World.CreateProp(m, vec.Position + new Vector3(0, 0, 1.0f) + Vector3.RandomXY(), vec.Rotation, true, false);
                        p.ApplyForce(new Vector3(0, 0, -0.05f));
                        RPG.WorldData.AddLoot(new LootItem(ItemRepository.Get("Vehicle Repair Kit"), p));
                    }


                    if (!vec.HasBeenDamagedBy(Game.Player.Character))
                    {
                        continue;
                    }

                    if (vec.Model.IsHelicopter)
                    {
                        RPG.Notify(Notification.Kill("destroyed helicopter: +100 Exp"));
                        PlayerData.AddExp(100);
                    }
                    else if (vec.Model.IsPlane)
                    {
                        RPG.Notify(Notification.Kill("destroyed aircraft: +150 Exp"));
                        PlayerData.AddExp(150);
                    }
                    else if (vec.Model.IsBoat)
                    {
                        RPG.Notify(Notification.Kill("Destroyed Boat: +200 Exp"));
                        PlayerData.AddExp(200);
                    }
                    else if (vec.Model.IsBike)
                    {
                        RPG.Notify(Notification.Kill("Destroyed Bike: +20 Exp"));
                        PlayerData.AddExp(20);
                    }
                    else if (vec.Model.IsTrain)
                    {
                        RPG.Notify(Notification.Kill("Destroyed Train: +500 Exp"));
                        PlayerData.AddExp(500);
                    }
                    else
                    {
                        RPG.Notify(Notification.Kill("Destroyed Vehicle: +15 Exp"));
                        PlayerData.AddExp(15);
                    }

                    CheckIfForQuest(vec, vec.Model.Hash, false);
                }
            }

            var nearbyForKills = RPGInfo.NearbyPeds;

            //var nearbyForKills = World.GetAllPeds();
            foreach (var ped in nearbyForKills.Where(p => !p.IsAlive))
            {
                if (ped.CurrentBlip != null)
                {
                    ped.CurrentBlip.Remove();
                }

                var n = RPG.WorldData.Npcs.FirstOrDefault(x => x.Ped != null && x.Ped.Handle == ped.Handle);
                if (n != null)
                {
                    RPG.WorldData.Npcs.Remove(n);
                }

                if (!KilledPeds.Contains(ped.Handle))
                {
                    KilledPeds.Add(ped.Handle);
                    //Check if kill needed for quest
                    var pedData = NpcDatas.FirstOrDefault(npc => npc.Ped != null && npc.Ped.Handle == ped.Handle);
                    if (pedData != null)
                    {
                        pedData.Destroy();
                    }
                    CheckIfForQuest(ped, ped.Model.Hash, true);
                    //If player didn't damage, continue
                    if (!ped.HasBeenDamagedBy(Game.Player.Character))
                    {
                        continue;
                    }


                    if (!PlayerData.Tutorial.GetAKill && PlayerData.Tutorial.PressJToOpenMenu && PlayerData.Tutorial.BoughtAmmoFromShop)
                    {
                        var tut = RPG.GetPopup <TutorialBox>();
                        PlayerData.Tutorial.GetAKill = true;
                        PlayerData.SkillExp         += 100;
                        EventHandler.Do(o =>
                        {
                            tut.Hide();
                            Wait(300);
                            if (!RPG.PlayerData.Tutorial.UnlockSkillWithSp)
                            {
                                tut.Pop("Hope you haven't attracted the cops. If so lose them. Time to unlock some skills.", "Access the menu > Character Menu > Skills. Unlock your first skill.");
                            }
                        });
                    }

                    RPG.Notify(Notification.Kill("target eliminated: +5 Exp"));

                    //Basic loot rng
                    var rng = Random.Range(0, 100 + 1);

                    if (rng < 70)
                    {
                        var m = new Model(GM.GetHashKey("prop_cash_pile_01"));
                        m.Request(1000);
                        var p = World.CreateProp(m, ped.Position + new Vector3(0, 0, 2.2F) + Vector3.RandomXYZ(), ped.Rotation, true, false);
                        p.ApplyForce(new Vector3(0, 0, 0.05f));
                        RPG.WorldData.AddLoot(new LootItem(ItemRepository.Cash(Random.Range(20, 80)), p));
                    }

                    if (rng < 30)
                    {
                        var items2 = new[] { "Bandages", "Basic Scraps", "Simple Protective Gear", "Ammo Pack I" };

                        var m2 = new Model(GM.GetHashKey("prop_money_bag_01"));
                        m2.Request(1000);
                        var p2 = World.CreateProp(m2, ped.Position + new Vector3(0, 0.5f, 2.2F) + Vector3.RandomXY(), ped.Rotation, true, false);
                        p2.ApplyForce(new Vector3(0, 0, 0.05f));
                        RPG.WorldData.AddLoot(new LootItem(ItemRepository.Get(items2[Random.Range(0, items2.Length)]), p2));
                    }
                    else if (rng < 40)
                    {
                        var items2 = new[] { "Health Kit", "Refurbished Kevlar", "Ammo Pack II" };

                        var m2 = new Model(GM.GetHashKey("prop_money_bag_01"));
                        m2.Request(1000);
                        var p2 = World.CreateProp(m2, ped.Position + new Vector3(0.5f, 0, 2.2F) + Vector3.RandomXY(), ped.Rotation, true, false);
                        p2.ApplyForce(new Vector3(0, 0, 0.05f));
                        RPG.WorldData.AddLoot(new LootItem(ItemRepository.Get(items2[Random.Range(0, items2.Length)]), p2));
                    }

                    PlayerData.AddExp(5);
                }
            }

            var activeQuests = PlayerData.Quests.Where(q => q.InProgress).ToList();

            for (int i = 0; i < activeQuests.Count; i++)
            {
                activeQuests[i].CheckState();
            }


            QuestUpdates();
        }
示例#17
0
 public static Notification Alert(string message)
 {
     var n = new Notification(NotifyType.Alert, message);
     return n;
 }
示例#18
0
 public void Notify(Notification notification)
 {
     Show(notification);
 }