Exemple #1
0
        public ZombiePed ZombieSpawn(Vector3 pos)
        {
            int tempMaxZombies = maxZombies;

            if (IsCityZone(Game.Player.Character.Position))
            {
                tempMaxZombies = maxZombies * 2;
            }
            if (zombieCount >= tempMaxZombies || pos == Vector3.Zero || Extensions.DistanceBetweenV3(pos, startingLoc) < minSpawnDistance || Extensions.DistanceBetweenV3(pos, Game.Player.Character.Position) < minSpawnDistance)
            {
                return(null);
            }
            else
            {
                Ped ped;
                if (customZombies == true)
                {
                    Model model = new Model(RandoMath.GetRandomElementFromList(ZombieModels));
                    ped = World.CreatePed(model, pos);
                }
                else
                {
                    ped = World.CreateRandomPed(pos);
                }
                Infect(ped);
                ZombiePed newZombie = zombieList.Find(match: a => a.pedEntity == ped);
                if (newZombie == null)
                {
                    return(null);
                }
                return(newZombie);
            }
        }
Exemple #2
0
        public static Ped Infect(Ped ped)
        {
            ped.Task.ClearAllImmediately();
            ped.Weapons.Drop();
            ped.LeaveGroup();
            ped.RelationshipGroup    = Relationships.ZombieGroup;
            ped.BlockPermanentEvents = true;
            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, ped.Handle, 46, true);
            Function.Call(Hash.APPLY_PED_DAMAGE_PACK, ped.Handle, "BigHitByVehicle", 0, 1);
            Function.Call(Hash.APPLY_PED_DAMAGE_PACK, ped.Handle, "HOSPITAL_8", 0, 1);
            Function.Call(Hash.APPLY_PED_DAMAGE_PACK, ped.Handle, "HOSPITAL_9", 0, 1);
            Function.Call(Hash.APPLY_PED_DAMAGE_PACK, ped.Handle, "Explosion_Med", 0, 1);
            ped.CanPlayGestures = false;
            Function.Call(Hash.SET_PED_CAN_PLAY_AMBIENT_ANIMS, ped.Handle, false);
            Function.Call(Hash.SET_PED_CAN_PLAY_AMBIENT_BASE_ANIMS, ped.Handle, false);
            Function.Call(Hash.SET_PED_PATH_CAN_USE_LADDERS, ped.Handle, false);
            Function.Call(Hash.SET_PED_PATH_CAN_USE_CLIMBOVERS, ped.Handle, true);
            Function.Call(Hash.SET_PED_PATH_CAN_DROP_FROM_HEIGHT, ped.Handle, true);
            Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, ped.Handle, false);
            Function.Call(Hash.SET_PED_PATH_PREFER_TO_AVOID_WATER, ped.Handle, true);
            Function.Call(Hash.SET_PED_PATH_AVOID_FIRE, ped.Handle, false);
            Function.Call(Hash.SET_PED_ALERTNESS, ped.Handle, 0);
            Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, ped.Handle, 0, 0);
            ped.DrownsInWater        = true;
            ped.DiesInstantlyInWater = true;
            if (Function.Call <bool>(Hash.IS_AMBIENT_SPEECH_PLAYING, ped.Handle))
            {
                Function.Call(Hash.STOP_CURRENT_PLAYING_AMBIENT_SPEECH, ped.Handle);
            }
            Function.Call(Hash.STOP_PED_SPEAKING, ped.Handle, 1);
            Function.Call(Hash.DISABLE_PED_PAIN_AUDIO, ped.Handle, true);
            int      runnerRnd = 0;
            TimeSpan time      = World.CurrentDayTime;

            if (time.Hours >= 20 || time.Hours <= 3)
            {
                runnerRnd = RandoMath.CachedRandom.Next(0, 100);
            }
            else
            {
                runnerRnd = RandoMath.CachedRandom.Next(0, 50);
            }
            bool isRunner = false;

            if (zombieRunners == false)
            {
                runnerRnd = 100;
            }
            if (runnerRnd <= 10)
            {
                isRunner = true;
                if (!Function.Call <bool>(Hash.HAS_ANIM_SET_LOADED, "move_m@injured"))
                {
                    Function.Call(Hash.REQUEST_ANIM_SET, "move_m@injured");
                }
                Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, ped.Handle, "move_m@injured", 1048576000);
            }
            else
            {
                isRunner = false;
                if (!Function.Call <bool>(Hash.HAS_ANIM_SET_LOADED, "move_m@drunk@verydrunk"))
                {
                    Function.Call(Hash.REQUEST_ANIM_SET, "move_m@drunk@verydrunk");
                }
                Function.Call(Hash.SET_PED_MOVEMENT_CLIPSET, ped.Handle, "move_m@drunk@verydrunk", 1048576000);
            }
            ped.CanWrithe = false;
            ped.MaxHealth = zombieHealth;
            ped.Health    = ped.MaxHealth;
            ped.Armor     = 0;
            ped.Money     = 0;
            Function.Call(Hash.SET_PED_SEEING_RANGE, ped.Handle, 150f);
            Function.Call(Hash.SET_PED_HEARING_RANGE, ped.Handle, 300f);
            ped.AlwaysDiesOnLowHealth = false;
            ped.AlwaysKeepTask        = true;
            ZombiePed newZombie = new ZombiePed(ped);
            bool      couldEnlistWithoutAdding = false;

            for (int i = 0; i < zombieList.Count; i++)
            {
                if (zombieList[i].pedEntity == null)
                {
                    zombieList[i].AttachData(ped);
                    if (isRunner == true)
                    {
                        zombieList[i].isRunner = true;
                    }
                    else
                    {
                        zombieList[i].isRunner = false;
                    }
                    newZombie = zombieList[i];
                    couldEnlistWithoutAdding = true;
                    break;
                }
            }
            if (!couldEnlistWithoutAdding)
            {
                zombieList.Add(newZombie);
                if (isRunner == true)
                {
                    zombieList[zombieList.Count - 1].isRunner = true;
                }
                else
                {
                    zombieList[zombieList.Count - 1].isRunner = false;
                }
            }
            else
            {
                UI.Notify("Zombie not added to list");
            }
            return(ped);
        }