public static void LoadPedFromPedData(PedData pedData) { Ped ped = World.CreatePed(pedData.Hash, pedData.Position); SurvivorPed survivorPed = new SurvivorPed(ped); Population.survivorList.Add(survivorPed); if (!(ped == null)) { ped.Rotation = pedData.Rotation; pedData.Weapons.ForEach(delegate(Weapon w) { ped.Weapons.Give(w.Hash, w.Ammo, true, true); }); pedData.Handle = ped.Handle; ped.Recruit(Game.Player.Character); SetPedTasks(ped, pedData.Task); } }
public static void AddPedData(Ped ped) { SurvivorPed survivorPed = Population.survivorList.Find(match: a => a.pedEntity == ped); PedTasks pedTasks = survivorPed.tasks; IEnumerable <WeaponHash> hashes = from hash in (WeaponHash[])Enum.GetValues(typeof(WeaponHash)) where ped.Weapons.HasWeapon(hash) select hash; WeaponComponent[] componentHashes = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent)); List <Weapon> weapons = hashes.ToList().ConvertAll(delegate(WeaponHash hash) { GTA.Weapon weapon = ped.Weapons[hash]; WeaponComponent[] components = (from h in componentHashes where weapon.IsComponentActive(h) select h).ToArray(); return(new Weapon(weapon.Ammo, weapon.Hash, components)); }).ToList(); PedData pedData = new PedData(ped.Handle, ped.Model.Hash, ped.Rotation, ped.Position, pedTasks, weapons); PlayerPedCollection.Add(pedData); }
public static SurvivorPed SurvivorSpawn(Vector3 pos) { Ped ped; if (customSurvivors == true) { Model model = new Model(RandoMath.GetRandomElementFromList(SurvivorModels)); ped = World.CreatePed(model, pos.Around(5f)); } else { ped = World.CreateRandomPed(pos.Around(5f)); } Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, ped.Handle, 0, 0); Function.Call(Hash.SET_PED_PATH_CAN_USE_CLIMBOVERS, ped.Handle, true); Function.Call(Hash.SET_PED_PATH_CAN_USE_LADDERS, ped.Handle, true); Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, ped.Handle, true); Function.Call(Hash.SET_PED_PATH_PREFER_TO_AVOID_WATER, ped.Handle, true); Function.Call(Hash.SET_PED_PATH_CAN_DROP_FROM_HEIGHT, ped.Handle, true); ped.Accuracy = 75; ped.DiesInstantlyInWater = false; Function.Call(Hash.SET_PED_COMBAT_MOVEMENT, ped.Handle, 1, true); int rndWeapon = RandoMath.CachedRandom.Next(0, 11); ped.MaxHealth = 100; ped.Health = ped.MaxHealth; ped.Armor = 70; if (rndWeapon < 5) { ped.Weapons.Give(WeaponHash.SMG, 300, true, true); ped.Weapons.Give(WeaponHash.Pistol, 120, true, true); ped.Weapons.Give(WeaponHash.Knife, 0, false, true); } if (rndWeapon >= 5) { ped.Weapons.Give(WeaponHash.AssaultRifle, 300, true, true); ped.Weapons.Give(WeaponHash.CombatPistol, 120, true, true); ped.Weapons.Give(WeaponHash.BattleAxe, 0, false, true); } ped.Money = 0; ped.NeverLeavesGroup = true; SurvivorPed newSurvivor = new SurvivorPed(ped); bool couldEnlistWithoutAdding = false; for (int i = 0; i < survivorList.Count; i++) { if (survivorList[i].pedEntity == null) { survivorList[i].AttachData(ped); newSurvivor = survivorList[i]; couldEnlistWithoutAdding = true; break; } } if (!couldEnlistWithoutAdding) { survivorList.Add(newSurvivor); } else { UI.Notify("Survivor not added to list"); } return(newSurvivor); }
public static void SurvivorGroupSpawn(Vector3 pos, GroupType groupType = GroupType.Random, int groupSize = -1, PedTasks pedTasks = PedTasks.Wander) { if (groupType == GroupType.Random) { int rndGroupType = RandoMath.CachedRandom.Next(0, 3); if (rndGroupType == 0) { groupType = GroupType.Friendly; } if (rndGroupType == 1) { groupType = GroupType.Neutral; } if (rndGroupType == 2) { groupType = GroupType.Hostile; } } List <Ped> peds = new List <Ped>(); PedGroup group = new PedGroup(); if (groupSize == -1) { groupSize = RandoMath.CachedRandom.Next(3, 9); } for (int i = 0; i < groupSize; i++) { SurvivorPed sPed = SurvivorSpawn(pos); if (groupType == GroupType.Friendly) { sPed.pedEntity.RelationshipGroup = Relationships.FriendlyGroup; sPed.pedEntity.AddBlip(); sPed.pedEntity.CurrentBlip.Color = BlipColor.Blue; sPed.pedEntity.CurrentBlip.Scale = 0.65f; sPed.pedEntity.CurrentBlip.Name = "Friendly"; } else if (groupType == GroupType.Neutral) { sPed.pedEntity.RelationshipGroup = Relationships.NeutralGroup; sPed.pedEntity.AddBlip(); sPed.pedEntity.CurrentBlip.Color = BlipColor.Yellow; sPed.pedEntity.CurrentBlip.Scale = 0.65f; sPed.pedEntity.CurrentBlip.Name = "Neutral"; } else if (groupType == GroupType.Hostile) { sPed.pedEntity.RelationshipGroup = Relationships.HostileGroup; sPed.pedEntity.AddBlip(); sPed.pedEntity.CurrentBlip.Color = BlipColor.Red; sPed.pedEntity.CurrentBlip.Scale = 0.65f; sPed.pedEntity.CurrentBlip.Name = "Hostile"; } peds.Add(sPed.pedEntity); } foreach (Ped ped in peds) { if (group.MemberCount < 1) { group.Add(ped, true); } else { group.Add(ped, false); } } group.FormationType = 0; List <Ped> groupPeds = group.ToList(true); foreach (Ped ped in groupPeds) { PlayerGroup.SetPedTasks(ped, pedTasks); } }