Ejemplo n.º 1
0
 public static void Recruit(this Ped ped, Ped leader)
 {
     if (leader != null)
     {
         PedGroup currentPedGroup = leader.CurrentPedGroup;
         ped.LeaveGroup();
         InputArgument[] arguments = new InputArgument[] { ped.Handle, false };
         Function.Call(Hash._0xF0A4F1BBF4FA7497, arguments);
         ped.Task.ClearAll();
         currentPedGroup.SeparationRange = 2.147484E+09f;
         if (!currentPedGroup.Contains(leader))
         {
             currentPedGroup.Add(leader, true);
         }
         if (!currentPedGroup.Contains(ped))
         {
             currentPedGroup.Add(ped, false);
         }
         ped.IsPersistent      = true;
         ped.RelationshipGroup = leader.RelationshipGroup;
         ped.NeverLeavesGroup  = true;
         Blip currentBlip = ped.CurrentBlip;
         if (currentBlip.Type != 0)
         {
             currentBlip.Remove();
         }
         Blip blip2 = ped.AddBlip();
         blip2.Color = BlipColor.Green;
         blip2.Scale = 0.65f;
         blip2.Name  = "Group";
         PlayerGroup.SetPedTasks(ped, PedTasks.Follow);
     }
 }
Ejemplo n.º 2
0
 public static void LoadWeapons()
 {
     if (!File.Exists("./scripts/UndeadStreets/SaveGame/Weapons.sav"))
     {
         UI.Notify("No ~r~Weapons ~w~available to load!");
     }
     else
     {
         PlayerGroup.PlayerWeapons = ReadFromBinaryFile <List <UndeadStreets.Weapon> >("./scripts/UndeadStreets/SaveGame/Weapons.sav");
         if (PlayerGroup.PlayerWeapons.Count <= 0)
         {
             UI.Notify("~r~Weapons ~w~load failed!");
         }
         else
         {
             Game.Player.Character.Weapons.RemoveAll();
             PlayerGroup.LoadPlayerWeapons();
             UI.Notify("~r~Weapons ~w~loaded!");
         }
     }
 }
Ejemplo n.º 3
0
 public static void LoadGroup()
 {
     if (!File.Exists("./scripts/UndeadStreets/SaveGame/Group.sav"))
     {
         UI.Notify("No ~p~Group ~w~available to load!");
     }
     else
     {
         PlayerGroup.PlayerPedCollection = ReadFromBinaryFile <PedCollection>("./scripts/UndeadStreets/SaveGame/Group.sav");
         if (PlayerGroup.PlayerPedCollection.Count <= 0)
         {
             UI.Notify("~p~Group ~w~load failed!");
         }
         else
         {
             List <PedData> list = PlayerGroup.PlayerPedCollection.ToList <PedData>();
             foreach (Ped ped in Game.Player.Character.CurrentPedGroup.ToList(false))
             {
                 Blip currentBlip = ped.CurrentBlip;
                 if (currentBlip.Type != 0)
                 {
                     currentBlip.Remove();
                 }
                 ped.LeaveGroup();
                 int index = Population.survivorList.FindIndex(a => a.pedEntity == ped);
                 Population.survivorList.RemoveAt(index);
                 ped.MarkAsNoLongerNeeded();
                 ped.Delete();
             }
             foreach (PedData data in list)
             {
                 PlayerGroup.LoadPedFromPedData(data);
             }
             UI.Notify("~p~Group ~w~loaded!");
         }
     }
 }
Ejemplo n.º 4
0
        public static void SaveWeapons()
        {
            int index = 0;

            while (true)
            {
                if (index >= PlayerGroup.PlayerWeapons.Count)
                {
                    PlayerGroup.SavePlayerWeapons();
                    try
                    {
                        WriteToBinaryFile <List <UndeadStreets.Weapon> >("./scripts/UndeadStreets/SaveGame/Weapons.sav", PlayerGroup.PlayerWeapons, false);
                        UI.Notify("~r~Weapons~w~ saved!");
                    }
                    catch (Exception exception1)
                    {
                        Debug.Log(exception1.ToString());
                    }
                    return;
                }
                PlayerGroup.PlayerWeapons.RemoveAt(index);
                index++;
            }
        }
Ejemplo n.º 5
0
        public static void SaveGroup()
        {
            List <Ped> list = Game.Player.Character.CurrentPedGroup.ToList(false);

            if (list.Count <= 0)
            {
                UI.Notify("You have no one in your group!");
                return;
            }
            else
            {
                int index = 0;
                while (true)
                {
                    if (index >= PlayerGroup.PlayerPedCollection.Count)
                    {
                        foreach (Ped ped in list)
                        {
                            PlayerGroup.AddPedData(ped);
                        }
                        break;
                    }
                    PlayerGroup.PlayerPedCollection.RemoveAt(index);
                    index++;
                }
            }
            try
            {
                WriteToBinaryFile <PedCollection>("./scripts/UndeadStreets/SaveGame/Group.sav", PlayerGroup.PlayerPedCollection, false);
                UI.Notify("~p~Group ~w~saved!");
            }
            catch (Exception exception1)
            {
                Debug.Log(exception1.ToString());
            }
        }
Ejemplo n.º 6
0
        public static void SurvivorGroupSpawn(Vector3 pos, GroupType groupType = 3, int groupSize = -1, PedTasks pedTasks = 1)
        {
            if (groupType == GroupType.Random)
            {
                int num = RandoMath.CachedRandom.Next(0, 3);
                if (num == 0)
                {
                    groupType = GroupType.Friendly;
                }
                if (num == 1)
                {
                    groupType = GroupType.Neutral;
                }
                if (num == 2)
                {
                    groupType = GroupType.Hostile;
                }
            }
            List <Ped> list  = new List <Ped>();
            PedGroup   group = new PedGroup();

            if (groupSize == -1)
            {
                groupSize = RandoMath.CachedRandom.Next(3, 9);
            }
            int num2 = 0;

            while (true)
            {
                if (num2 >= groupSize)
                {
                    foreach (Ped ped2 in list)
                    {
                        if (group.MemberCount < 1)
                        {
                            group.Add(ped2, true);
                            continue;
                        }
                        group.Add(ped2, false);
                    }
                    group.FormationType = FormationType.Default;
                    foreach (Ped ped3 in group.ToList(true))
                    {
                        PlayerGroup.SetPedTasks(ped3, pedTasks);
                    }
                    return;
                }
                SurvivorPed ped = SurvivorSpawn(pos);
                if (groupType == GroupType.Friendly)
                {
                    ped.pedEntity.RelationshipGroup = Relationships.FriendlyGroup;
                    ped.pedEntity.AddBlip();
                    ped.pedEntity.CurrentBlip.Color = BlipColor.Blue;
                    ped.pedEntity.CurrentBlip.Scale = 0.65f;
                    ped.pedEntity.CurrentBlip.Name  = "Friendly";
                }
                else if (groupType == GroupType.Neutral)
                {
                    ped.pedEntity.RelationshipGroup = Relationships.NeutralGroup;
                    ped.pedEntity.AddBlip();
                    ped.pedEntity.CurrentBlip.Color = BlipColor.Yellow;
                    ped.pedEntity.CurrentBlip.Scale = 0.65f;
                    ped.pedEntity.CurrentBlip.Name  = "Neutral";
                }
                else if (groupType == GroupType.Hostile)
                {
                    ped.pedEntity.RelationshipGroup = Relationships.HostileGroup;
                    ped.pedEntity.AddBlip();
                    ped.pedEntity.CurrentBlip.Color = BlipColor.Red;
                    ped.pedEntity.CurrentBlip.Scale = 0.65f;
                    ped.pedEntity.CurrentBlip.Name  = "Hostile";
                }
                list.Add(ped.pedEntity);
                num2++;
            }
        }